tdf#97049 Export "intd" to MathML

Change-Id: Ie1fc33e18958e73d4876b2b5daceec127011c3cc
Reviewed-on: https://gerrit.libreoffice.org/29003
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Takeshi Abe <tabe@fixedpoint.jp>
This commit is contained in:
Takeshi Abe 2016-09-19 09:26:41 +09:00
parent d5f1e7c5ad
commit 3a8035bcb6
3 changed files with 29 additions and 0 deletions

View File

@ -35,9 +35,11 @@ public:
virtual void setUp() override;
virtual void tearDown() override;
void testTdf97049();
void testTdf101022();
CPPUNIT_TEST_SUITE(MathMLExportTest);
CPPUNIT_TEST(testTdf97049);
CPPUNIT_TEST(testTdf101022);
CPPUNIT_TEST_SUITE_END();
@ -85,6 +87,16 @@ xmlDocPtr MathMLExportTest::exportAndParse()
return pDoc;
}
void MathMLExportTest::testTdf97049()
{
mxDocShell->SetText("intd {{1 over x} dx}");
xmlDocPtr pDoc = exportAndParse();
assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mo[1]", "stretchy", "true");
auto aContent = getXPathContent(pDoc, "/m:math/m:semantics/m:mrow/m:mo[1]");
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aContent.getLength());
CPPUNIT_ASSERT_EQUAL(sal_Unicode(0x222B), aContent[0]);
}
void MathMLExportTest::testTdf101022()
{
#define CHECK_MATHVARIANT(capital, small) do \

View File

@ -811,6 +811,11 @@ void SmXMLExport::ExportMath(const SmNode *pNode, int /*nLevel*/)
AddAttribute(XML_NAMESPACE_MATH, XML_MATHVARIANT, XML_NORMAL);
pMath = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MI, true, false);
}
else if (pNode->GetType() == NDYNINTSYMBOL)
{
AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_TRUE);
pMath = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MO, true, false);
}
else
{
// Export NMATHIDENT and NPLACE symbols as <mi> elements:
@ -1456,6 +1461,13 @@ void SmXMLExport::ExportMatrix(const SmNode *pNode, int nLevel)
}
}
void SmXMLExport::ExportDynIntegral(const SmDynIntegralNode *pNode, int nLevel)
{
SvXMLElementExport aRow(*this, XML_NAMESPACE_MATH, XML_MROW, true, true);
ExportNodes(pNode->Symbol(), nLevel+1);
ExportNodes(pNode->Body(), nLevel+1);
}
void SmXMLExport::ExportNodes(const SmNode *pNode, int nLevel)
{
if (!pNode)
@ -1520,6 +1532,7 @@ void SmXMLExport::ExportNodes(const SmNode *pNode, int nLevel)
case NSPECIAL: //NSPECIAL requires some sort of Entity preservation in the XML engine.
case NMATHIDENT :
case NPLACE:
case NDYNINTSYMBOL:
ExportMath(pNode, nLevel);
break;
case NBINHOR:
@ -1561,6 +1574,9 @@ void SmXMLExport::ExportNodes(const SmNode *pNode, int nLevel)
case NBLANK:
ExportBlank(pNode, nLevel);
break;
case NDYNINT:
ExportDynIntegral(static_cast<const SmDynIntegralNode *>(pNode), nLevel);
break;
default:
SAL_WARN("starmath", "Warning: failed to export a node?");
break;

View File

@ -92,6 +92,7 @@ protected:
void ExportVerticalBrace(const SmVerticalBraceNode *pNode, int nLevel);
void ExportMatrix(const SmNode *pNode, int nLevel);
void ExportBlank(const SmNode *pNode, int nLevel);
void ExportDynIntegral(const SmDynIntegralNode *pNode, int nLevel);
public:
SmXMLExport(