diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2016-09-19 09:26:41 +0900 |
---|---|---|
committer | Takeshi Abe <tabe@fixedpoint.jp> | 2016-09-20 06:46:39 +0000 |
commit | 3a8035bcb6cf081572d86813021bbccab265a935 (patch) | |
tree | 753d6a1780d702137e1aa7dac37c3896184a5f00 /starmath | |
parent | d5f1e7c5adac5f38379c56b536640f3aaf9ec7d5 (diff) |
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>
Diffstat (limited to 'starmath')
-rw-r--r-- | starmath/qa/extras/mmlexport-test.cxx | 12 | ||||
-rw-r--r-- | starmath/source/mathmlexport.cxx | 16 | ||||
-rw-r--r-- | starmath/source/mathmlexport.hxx | 1 |
3 files changed, 29 insertions, 0 deletions
diff --git a/starmath/qa/extras/mmlexport-test.cxx b/starmath/qa/extras/mmlexport-test.cxx index f13ee9deba21..3a2d222f18e4 100644 --- a/starmath/qa/extras/mmlexport-test.cxx +++ b/starmath/qa/extras/mmlexport-test.cxx @@ -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 \ diff --git a/starmath/source/mathmlexport.cxx b/starmath/source/mathmlexport.cxx index 0567181f6df6..2aab22693fa4 100644 --- a/starmath/source/mathmlexport.cxx +++ b/starmath/source/mathmlexport.cxx @@ -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; diff --git a/starmath/source/mathmlexport.hxx b/starmath/source/mathmlexport.hxx index 4581db8f6cf1..19a29cb35ef7 100644 --- a/starmath/source/mathmlexport.hxx +++ b/starmath/source/mathmlexport.hxx @@ -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( |