diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 05:54:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 05:54:39 +0000 |
commit | 267c6f2ac71f92999e969232431ba04678e7437e (patch) | |
tree | 358c9467650e1d0a1d7227a21dac2e3d08b622b2 /starmath/qa/extras | |
parent | Initial commit. (diff) | |
download | libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.tar.xz libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.zip |
Adding upstream version 4:24.2.0.upstream/4%24.2.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'starmath/qa/extras')
-rw-r--r-- | starmath/qa/extras/data/color.mml | 24 | ||||
-rw-r--r-- | starmath/qa/extras/data/hadd.mml | 11 | ||||
-rw-r--r-- | starmath/qa/extras/data/maction.mml | 10 | ||||
-rw-r--r-- | starmath/qa/extras/data/maj.mml | 18 | ||||
-rw-r--r-- | starmath/qa/extras/data/mspace.mml | 12 | ||||
-rw-r--r-- | starmath/qa/extras/data/mthmlentities.mml | 9 | ||||
-rw-r--r-- | starmath/qa/extras/data/ns-prefix-math.mml | 13 | ||||
-rw-r--r-- | starmath/qa/extras/data/simple.mml | 13 | ||||
-rw-r--r-- | starmath/qa/extras/data/tdf103430.mml | 17 | ||||
-rw-r--r-- | starmath/qa/extras/data/tdf103500.mml | 41 | ||||
-rw-r--r-- | starmath/qa/extras/data/tdf137008.mml | 1 | ||||
-rw-r--r-- | starmath/qa/extras/data/tdf151842.odf | bin | 0 -> 6073 bytes | |||
-rw-r--r-- | starmath/qa/extras/data/tdf99556-1.mml | 3 | ||||
-rw-r--r-- | starmath/qa/extras/mmlexport-test.cxx | 160 | ||||
-rw-r--r-- | starmath/qa/extras/mmlimport-test.cxx | 212 |
15 files changed, 544 insertions, 0 deletions
diff --git a/starmath/qa/extras/data/color.mml b/starmath/qa/extras/data/color.mml new file mode 100644 index 0000000000..41294eff83 --- /dev/null +++ b/starmath/qa/extras/data/color.mml @@ -0,0 +1,24 @@ +<math xmlns="http://www.w3.org/1998/Math/MathML"> + <mrow> + <mi mathcolor="black">b</mi> + <mi mathcolor="white">w</mi> + <mi mathcolor="red">r</mi> + <mi mathcolor="green">g</mi> + <mi mathcolor="blue">b</mi> + <mi mathcolor="yellow">y</mi> + <mi mathcolor="silver">s</mi> + <mi mathcolor="gray">g</mi> + <mi mathcolor="maroon">m</mi> + <mi mathcolor="purple">p</mi> + <mi mathcolor="lime">l</mi> + <mi mathcolor="olive">o</mi> + <mi mathcolor="navy">n</mi> + <mi mathcolor="teal">t</mi> + <mi mathcolor="aqua">a</mi> + <mi mathcolor="fuchsia">f</mi> + <mi mathcolor="#DC143C">c</mi> + <mi mathcolor="#FFB781">a</mi> + <mi mathcolor="#FF0">y</mi> + <mi mathcolor="#DC143D">x</mi> + </mrow> +</math> diff --git a/starmath/qa/extras/data/hadd.mml b/starmath/qa/extras/data/hadd.mml new file mode 100644 index 0000000000..b6ebd374a5 --- /dev/null +++ b/starmath/qa/extras/data/hadd.mml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"> + <mrow> + <munderover> + <mi>ðž»±</mi> + <mi>𞹎</mi> + <mi>𞹎</mi> + </munderover> + <mi>𞹎</mi> + </mrow> +</math> diff --git a/starmath/qa/extras/data/maction.mml b/starmath/qa/extras/data/maction.mml new file mode 100644 index 0000000000..3650087999 --- /dev/null +++ b/starmath/qa/extras/data/maction.mml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<math xmlns="http://www.w3.org/1998/Math/MathML"> + <mrow> + <mtable> + <mtr><maction actiontype="toggle"><mn>1</mn><mn>0</mn><mn>0</mn></maction></mtr> + <mtr><maction actiontype="toggle" selection="2"><mn>0</mn><mn>2</mn><mn>0</mn></maction></mtr> + <mtr><maction actiontype="toggle" selection="3"><mn>0</mn><mn>0</mn><mn>3</mn></maction></mtr> + </mtable> + </mrow> +</math> diff --git a/starmath/qa/extras/data/maj.mml b/starmath/qa/extras/data/maj.mml new file mode 100644 index 0000000000..ea3b4067d5 --- /dev/null +++ b/starmath/qa/extras/data/maj.mml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"> + <mrow> + <munderover> + <mo stretchy="false">ðž»°</mo> + <mrow> + <mi>𞸊</mi> + <mo stretchy="false">=</mo> + <mn>Ù </mn> + </mrow> + <mn>Ù¡</mn> + </munderover> + <mfrac> + <mn>Ù¡</mn> + <mi>𞸊</mi> + </mfrac> + </mrow> +</math> diff --git a/starmath/qa/extras/data/mspace.mml b/starmath/qa/extras/data/mspace.mml new file mode 100644 index 0000000000..1906510940 --- /dev/null +++ b/starmath/qa/extras/data/mspace.mml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<math xmlns="http://www.w3.org/1998/Math/MathML"> + <mrow> + <mi>a</mi> + <mspace /> + <mi>b</mi> + <mspace width="2em" /> + <mi>c</mi> + <mspace width="5.5em" /> + <mi>d</mi> + </mrow> +</math> diff --git a/starmath/qa/extras/data/mthmlentities.mml b/starmath/qa/extras/data/mthmlentities.mml new file mode 100644 index 0000000000..328d689ce5 --- /dev/null +++ b/starmath/qa/extras/data/mthmlentities.mml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"> + <semantics> + <mi>σ</mi> + <mi>∞</mi> + <mi>∞</mi> + <mi>σ</mi> + </semantics> +</math> diff --git a/starmath/qa/extras/data/ns-prefix-math.mml b/starmath/qa/extras/data/ns-prefix-math.mml new file mode 100644 index 0000000000..c4c961223b --- /dev/null +++ b/starmath/qa/extras/data/ns-prefix-math.mml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<math:math xmlns:math="http://www.w3.org/1998/Math/MathML"> + <math:msup> + <math:mfenced> + <math:mrow> + <math:mi>a</math:mi> + <math:mo>+</math:mo> + <math:mi>b</math:mi> + </math:mrow> + </math:mfenced> + <math:mn>2</math:mn> + </math:msup> +</math:math> diff --git a/starmath/qa/extras/data/simple.mml b/starmath/qa/extras/data/simple.mml new file mode 100644 index 0000000000..822d1a7096 --- /dev/null +++ b/starmath/qa/extras/data/simple.mml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<math xmlns="http://www.w3.org/1998/Math/MathML"> + <msup> + <mfenced> + <mrow> + <mi>a</mi> + <mo>+</mo> + <mi>b</mi> + </mrow> + </mfenced> + <mn>2</mn> + </msup> +</math> diff --git a/starmath/qa/extras/data/tdf103430.mml b/starmath/qa/extras/data/tdf103430.mml new file mode 100644 index 0000000000..f8ea8f8d2d --- /dev/null +++ b/starmath/qa/extras/data/tdf103430.mml @@ -0,0 +1,17 @@ +<math xmlns="http://www.w3.org/1998/Math/MathML"> + <mfrac> + <mrow> + <msup> + <mo form="prefix" rspace="0">d</mo> + <mn>2</mn> + </msup> + <mi mathvariant="normal" mathcolor="blue">y</mi> + </mrow> + <mrow> + <mstyle mathcolor="#ffb781"> + <mo fontstyle="italic" fontweight="bold" mathvariant="normal" form="prefix" rspace="0">d</mo> + </mstyle> + <mi fontfamily="serif" mathvariant="sans-serif-bold-italic" mathcolor="red">x</mi> + </mrow> + </mfrac> +</math> diff --git a/starmath/qa/extras/data/tdf103500.mml b/starmath/qa/extras/data/tdf103500.mml new file mode 100644 index 0000000000..7c49669859 --- /dev/null +++ b/starmath/qa/extras/data/tdf103500.mml @@ -0,0 +1,41 @@ +<math xmlns="http://www.w3.org/1998/Math/MathML"> + <mrow> + <mrow> + <munderover> + <mo stretchy="false">∫</mo> + <mi>a</mi> + <mi>b</mi> + </munderover> + <mrow> + <mfrac> + <mn>1</mn> + <mi>x</mi> + </mfrac> + <mspace width="0.5em"/> + <mstyle mathvariant="normal"> + <mi mathvariant="normal">d</mi> + </mstyle> + <mi>x</mi> + </mrow> + </mrow> + <mo stretchy="false">=</mo> + <mrow> + <munderover> + <mo stretchy="true">∫</mo> + <mi>a</mi> + <mi>b</mi> + </munderover> + <mrow> + <mfrac> + <mn>1</mn> + <mi>y</mi> + </mfrac> + <mspace width="0.5em"/> + <mstyle mathvariant="normal"> + <mi mathvariant="normal">d</mi> + </mstyle> + <mi>y</mi> + </mrow> + </mrow> + </mrow> +</math> diff --git a/starmath/qa/extras/data/tdf137008.mml b/starmath/qa/extras/data/tdf137008.mml new file mode 100644 index 0000000000..bc6ee25db3 --- /dev/null +++ b/starmath/qa/extras/data/tdf137008.mml @@ -0,0 +1 @@ +<math xmlns='http://www.w3.org/1998/Math/MathML'><mtable><mtr><mtd></mtd></mtr><mtr></mtr></mtable></math>
\ No newline at end of file diff --git a/starmath/qa/extras/data/tdf151842.odf b/starmath/qa/extras/data/tdf151842.odf Binary files differnew file mode 100644 index 0000000000..cd8166dd9d --- /dev/null +++ b/starmath/qa/extras/data/tdf151842.odf diff --git a/starmath/qa/extras/data/tdf99556-1.mml b/starmath/qa/extras/data/tdf99556-1.mml new file mode 100644 index 0000000000..0eae8b2df2 --- /dev/null +++ b/starmath/qa/extras/data/tdf99556-1.mml @@ -0,0 +1,3 @@ +<math xmlns="http://www.w3.org/1998/Math/MathML"> +<msqrt/> +</math> diff --git a/starmath/qa/extras/mmlexport-test.cxx b/starmath/qa/extras/mmlexport-test.cxx new file mode 100644 index 0000000000..402df43130 --- /dev/null +++ b/starmath/qa/extras/mmlexport-test.cxx @@ -0,0 +1,160 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <sal/config.h> +#include <test/unoapixml_test.hxx> + +#include <o3tl/cppunittraitshelper.hxx> +#include <sfx2/sfxbasemodel.hxx> + +#include <document.hxx> +#include <smdll.hxx> + +#include <memory> + +using namespace ::com::sun::star; + +class MathMLExportTest : public UnoApiXmlTest +{ +public: + MathMLExportTest() + : UnoApiXmlTest("starmath/qa/extras/data/") + { + } + + void testBlank(); + void testTdf97049(); + void testTdf101022(); + void testMaj(); + void testHadd(); + + CPPUNIT_TEST_SUITE(MathMLExportTest); + CPPUNIT_TEST(testBlank); + CPPUNIT_TEST(testTdf97049); + CPPUNIT_TEST(testTdf101022); + CPPUNIT_TEST(testMaj); + CPPUNIT_TEST(testHadd); + CPPUNIT_TEST_SUITE_END(); + +protected: + virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override; + + void checkMathVariant(SmDocShell& rDocShell, bool bCapital, bool bSmall); +}; + +void MathMLExportTest::registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) +{ + xmlXPathRegisterNs(pXmlXPathCtx, BAD_CAST("m"), BAD_CAST("http://www.w3.org/1998/Math/MathML")); +} + +void MathMLExportTest::testBlank() +{ + mxComponent = loadFromDesktop("private:factory/smath"); + SfxBaseModel* pModel = dynamic_cast<SfxBaseModel*>(mxComponent.get()); + SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell()); + pDocShell->SetText("x`y~~z"); + save("MathML XML (Math)"); + xmlDocUniquePtr pDoc = parseXml(maTempFile); + CPPUNIT_ASSERT(pDoc); + assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mspace[1]"_ostr, "width"_ostr, "0.5em"); + assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mspace[2]"_ostr, "width"_ostr, "4em"); +} + +void MathMLExportTest::testTdf97049() +{ + mxComponent = loadFromDesktop("private:factory/smath"); + SfxBaseModel* pModel = dynamic_cast<SfxBaseModel*>(mxComponent.get()); + SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell()); + pDocShell->SetText("intd {{1 over x} dx}"); + save("MathML XML (Math)"); + xmlDocUniquePtr pDoc = parseXml(maTempFile); + CPPUNIT_ASSERT(pDoc); + assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mo[1]"_ostr, "stretchy"_ostr, "true"); + auto aContent = getXPathContent(pDoc, "/m:math/m:semantics/m:mrow/m:mo[1]"_ostr); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aContent.getLength()); + CPPUNIT_ASSERT_EQUAL(u'\x222B', aContent[0]); +} + +void MathMLExportTest::checkMathVariant(SmDocShell& rDocShell, bool bCapital, bool bSmall) +{ + rDocShell.SetText("%GAMMA %iGAMMA {ital %GAMMA} {nitalic %iGAMMA} " + "%gamma %igamma {ital %gamma} {nitalic %igamma}"); + save("MathML XML (Math)"); + xmlDocUniquePtr pDoc = parseXml(maTempFile); + CPPUNIT_ASSERT(pDoc); + if (bCapital) + assertXPathNoAttribute(pDoc, "/m:math/m:semantics/m:mrow/m:mi[1]"_ostr, "mathvariant"_ostr); + else + assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mi[1]"_ostr, "mathvariant"_ostr, "normal"); + assertXPathNoAttribute(pDoc, "/m:math/m:semantics/m:mrow/m:mstyle[1]/m:mi[1]"_ostr, + "mathvariant"_ostr); + assertXPathNoAttribute(pDoc, "/m:math/m:semantics/m:mrow/m:mi[2]"_ostr, "mathvariant"_ostr); + assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mstyle[2]/m:mi[1]"_ostr, "mathvariant"_ostr, + "normal"); + if (bSmall) + assertXPathNoAttribute(pDoc, "/m:math/m:semantics/m:mrow/m:mi[3]"_ostr, "mathvariant"_ostr); + else + assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mi[3]"_ostr, "mathvariant"_ostr, "normal"); + assertXPathNoAttribute(pDoc, "/m:math/m:semantics/m:mrow/m:mstyle[3]/m:mi[1]"_ostr, + "mathvariant"_ostr); + assertXPathNoAttribute(pDoc, "/m:math/m:semantics/m:mrow/m:mi[4]"_ostr, "mathvariant"_ostr); + assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mstyle[4]/m:mi[1]"_ostr, "mathvariant"_ostr, + "normal"); + rDocShell.SetText(""); +} + +void MathMLExportTest::testTdf101022() +{ + mxComponent = loadFromDesktop("private:factory/smath"); + SfxBaseModel* pModel = dynamic_cast<SfxBaseModel*>(mxComponent.get()); + SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell()); + + checkMathVariant(*pDocShell, false, true); // default mode 2 + + pDocShell->SetGreekCharStyle(1); // mode 1 + checkMathVariant(*pDocShell, true, true); + + pDocShell->SetGreekCharStyle(0); // mode 0 + checkMathVariant(*pDocShell, false, false); +} + +void MathMLExportTest::testMaj() +{ + mxComponent = loadFromDesktop("private:factory/smath"); + SfxBaseModel* pModel = dynamic_cast<SfxBaseModel*>(mxComponent.get()); + SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell()); + pDocShell->SetText( + u"maj to { \u0661 } from { \U0001EE0A = \u0660 } { \u0661 over \U0001EE0A }"_ustr); + save("MathML XML (Math)"); + xmlDocUniquePtr pDoc = parseXml(maTempFile); + CPPUNIT_ASSERT(pDoc); + assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:munderover/m:mo"_ostr, "stretchy"_ostr, + "false"); + assertXPathContent(pDoc, "/m:math/m:semantics/m:mrow/m:munderover/m:mo"_ostr, + u"\U0001EEF0"_ustr); +} + +void MathMLExportTest::testHadd() +{ + mxComponent = loadFromDesktop("private:factory/smath"); + SfxBaseModel* pModel = dynamic_cast<SfxBaseModel*>(mxComponent.get()); + SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell()); + pDocShell->SetText(u"hadd to { \U0001EE4E } from { \U0001EE4E } \U0001EE4E"_ustr); + save("MathML XML (Math)"); + xmlDocUniquePtr pDoc = parseXml(maTempFile); + CPPUNIT_ASSERT(pDoc); + assertXPathContent(pDoc, "/m:math/m:semantics/m:mrow/m:munderover/m:mi"_ostr, + u"\U0001EEF1"_ustr); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(MathMLExportTest); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/starmath/qa/extras/mmlimport-test.cxx b/starmath/qa/extras/mmlimport-test.cxx new file mode 100644 index 0000000000..d57dee0aa7 --- /dev/null +++ b/starmath/qa/extras/mmlimport-test.cxx @@ -0,0 +1,212 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <sal/config.h> +#include <test/unoapi_test.hxx> + +#include <sfx2/sfxbasemodel.hxx> + +#include <document.hxx> +#include <smdll.hxx> + +using namespace ::com::sun::star; + +class Test : public UnoApiTest +{ +public: + Test() + : UnoApiTest("starmath/qa/extras/data/") + { + } + + void testColor(); + void testSimple(); + void testNsPrefixMath(); + void testMaction(); + void testMspace(); + void testtdf99556(); + void testTdf103430(); + void testTdf103500(); + void testTdf137008(); + void testTdf151842(); + void testMathmlEntities(); + void testMaj(); + void testHadd(); + + CPPUNIT_TEST_SUITE(Test); + CPPUNIT_TEST(testColor); + CPPUNIT_TEST(testSimple); + CPPUNIT_TEST(testNsPrefixMath); + CPPUNIT_TEST(testMaction); + CPPUNIT_TEST(testMspace); + CPPUNIT_TEST(testtdf99556); + CPPUNIT_TEST(testTdf103430); + CPPUNIT_TEST(testTdf103500); + CPPUNIT_TEST(testTdf137008); + CPPUNIT_TEST(testTdf151842); + CPPUNIT_TEST(testMathmlEntities); + CPPUNIT_TEST(testMaj); + CPPUNIT_TEST(testHadd); + CPPUNIT_TEST_SUITE_END(); +}; + +void Test::testColor() +{ + loadFromFile(u"color.mml"); + SfxBaseModel* pModel = dynamic_cast<SfxBaseModel*>(mxComponent.get()); + SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell()); + CPPUNIT_ASSERT_EQUAL(OUString("{ color black b" + " color white w" + " color red r" + " color green g" + " color blue b" + " color yellow y" + " color silver s" + " color gray g" + " color maroon m" + " color purple p" + " color lime l" + " color olive o" + " color navy n" + " color teal t" + " color aqua a" + " color fuchsia f" + " color crimson c" + " color dvip apricot" + " a color yellow y" + " color rgb 220 20 61 x }"), + pDocShell->GetText()); +} + +void Test::testSimple() +{ + loadFromFile(u"simple.mml"); + SfxBaseModel* pModel = dynamic_cast<SfxBaseModel*>(mxComponent.get()); + SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("loaded text", OUString("left ( { a + b } right ) ^ 2"), + pDocShell->GetText()); +} + +void Test::testNsPrefixMath() +{ + loadFromFile(u"ns-prefix-math.mml"); + SfxBaseModel* pModel = dynamic_cast<SfxBaseModel*>(mxComponent.get()); + SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("loaded text", OUString("left ( { a + b } right ) ^ 2"), + pDocShell->GetText()); +} + +void Test::testMaction() +{ + loadFromFile(u"maction.mml"); + SfxBaseModel* pModel = dynamic_cast<SfxBaseModel*>(mxComponent.get()); + SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("loaded text", OUString("matrix{ 1 ## 2 ## 3 }"), + pDocShell->GetText()); +} + +void Test::testMspace() +{ + loadFromFile(u"mspace.mml"); + SfxBaseModel* pModel = dynamic_cast<SfxBaseModel*>(mxComponent.get()); + SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell()); + CPPUNIT_ASSERT_EQUAL(OUString("{ a b ~ c ~~``` d }"), pDocShell->GetText()); +} + +void Test::testtdf99556() +{ + loadFromFile(u"tdf99556-1.mml"); + SfxBaseModel* pModel = dynamic_cast<SfxBaseModel*>(mxComponent.get()); + SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("loaded text", OUString("sqrt { }"), pDocShell->GetText()); +} + +void Test::testTdf103430() +{ + loadFromFile(u"tdf103430.mml"); + SfxBaseModel* pModel = dynamic_cast<SfxBaseModel*>(mxComponent.get()); + SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell()); + CPPUNIT_ASSERT_EQUAL( + OUString("{ frac { { nitalic d ^ 2 nitalic color blue y } } { { color dvip " + "apricot nitalic d font sans bold italic color red x } } }"), + pDocShell->GetText()); +} + +void Test::testTdf103500() +{ + loadFromFile(u"tdf103500.mml"); + SfxBaseModel* pModel = dynamic_cast<SfxBaseModel*>(mxComponent.get()); + SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell()); + CPPUNIT_ASSERT_EQUAL( + OUString("{ { int csup b csub a { { frac { 1 } { x } } ` nitalic d x } } = { " + "intd csup b csub a { { frac { 1 } { y } } ` nitalic d y } } }"), + pDocShell->GetText()); +} + +void Test::testTdf137008() +{ + // Without the fix in place, this test would have crashed + loadFromFile(u"tdf137008.mml"); + SfxBaseModel* pModel = dynamic_cast<SfxBaseModel*>(mxComponent.get()); + SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell()); + CPPUNIT_ASSERT_EQUAL(OUString("matrix{ { } # ## # }"), pDocShell->GetText()); +} + +void Test::testTdf151842() +{ + // Without the fix in place, this test would have crashed + loadFromFile(u"tdf151842.odf"); + SfxBaseModel* pModel = dynamic_cast<SfxBaseModel*>(mxComponent.get()); + SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell()); + CPPUNIT_ASSERT_EQUAL(OUString("test"), pDocShell->GetText()); + SmFormat aFormat = pDocShell->GetFormat(); + + // Without the fix in place, this test would have failed with + // - Expected: 2400 + // - Actual : 423 + CPPUNIT_ASSERT_EQUAL(tools::Long(2400), aFormat.GetBaseSize().Height()); +} + +void Test::testMathmlEntities() +{ + loadFromFile(u"mthmlentities.mml"); + SfxBaseModel* pModel = dynamic_cast<SfxBaseModel*>(mxComponent.get()); + SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell()); + CPPUNIT_ASSERT_EQUAL(u"{ \u03C3 \u221E \u221E \u03C3 }"_ustr, pDocShell->GetText()); +} + +void Test::testMaj() +{ + loadFromFile(u"maj.mml"); + SfxBaseModel* pModel = dynamic_cast<SfxBaseModel*>(mxComponent.get()); + CPPUNIT_ASSERT(pModel); + SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell()); + CPPUNIT_ASSERT(pDocShell); + CPPUNIT_ASSERT_EQUAL(u"{ maj csup \u0661 csub { nitalic \U0001EE0A = \u0660 } { frac " + u"{ \u0661 } { nitalic \U0001EE0A } } }"_ustr, + pDocShell->GetText()); +} + +void Test::testHadd() +{ + loadFromFile(u"hadd.mml"); + SfxBaseModel* pModel = dynamic_cast<SfxBaseModel*>(mxComponent.get()); + CPPUNIT_ASSERT(pModel); + SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell()); + CPPUNIT_ASSERT(pDocShell); + CPPUNIT_ASSERT_EQUAL(u"{ nitalic \U0001EEF1 csup nitalic \U0001EE4E csub nitalic " + u"\U0001EE4E nitalic \U0001EE4E }"_ustr, + pDocShell->GetText()); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(Test); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |