1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <sal/config.h>
11 #include <test/bootstrapfixture.hxx>
13 #include <sfx2/docfile.hxx>
14 #include <sfx2/docfilt.hxx>
15 #include <sfx2/sfxmodelfactory.hxx>
17 #include <document.hxx>
22 using namespace ::com::sun::star
;
24 typedef tools::SvRef
<SmDocShell
> SmDocShellRef
;
26 class Test
: public test::BootstrapFixture
29 virtual void setUp() SAL_OVERRIDE
;
30 virtual void tearDown() SAL_OVERRIDE
;
33 void testNsPrefixMath();
36 CPPUNIT_TEST_SUITE(Test
);
37 CPPUNIT_TEST(testSimple
);
38 CPPUNIT_TEST(testNsPrefixMath
);
39 CPPUNIT_TEST(testMaction
);
40 CPPUNIT_TEST_SUITE_END();
43 void loadURL(const OUString
&rURL
)
46 // filter/source/config/fragments/filters/MathML_XML__Math_.xcu
47 SfxFilter
* pFilter
= new SfxFilter(MATHML_XML
,
49 SfxFilterFlags::IMPORT
| SfxFilterFlags::EXPORT
| SfxFilterFlags::TEMPLATE
,
50 SotClipboardFormatId::STARCALC_8
,
55 "private:factory/smath*");
56 pFilter
->SetVersion(SOFFICE_FILEFORMAT_60
);
58 mxDocShell
= new SmDocShell(SfxModelFlags::EMBEDDED_OBJECT
|
59 SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS
|
60 SfxModelFlags::DISABLE_DOCUMENT_RECOVERY
);
62 SfxMedium
* pSrcMed
= new SfxMedium(rURL
, STREAM_STD_READ
);
63 pSrcMed
->SetFilter(pFilter
);
64 pSrcMed
->UseInteractionHandler(false);
65 bool bLoaded
= mxDocShell
->DoLoad(pSrcMed
);
66 CPPUNIT_ASSERT_MESSAGE(OUStringToOString("failed to load " + rURL
, RTL_TEXTENCODING_UTF8
).getStr(),
70 SmDocShellRef mxDocShell
;
75 BootstrapFixture::setUp();
81 if (mxDocShell
) mxDocShell
->DoClose();
82 BootstrapFixture::tearDown();
85 void Test::testSimple()
87 loadURL(getURLFromSrc("starmath/qa/extras/data/simple.mml"));
88 OUString
sExpected("left ( {italic \"a\" + italic \"b\"} right )^italic \"2\"");
89 CPPUNIT_ASSERT_EQUAL_MESSAGE("loaded text", sExpected
, mxDocShell
->GetText());
92 void Test::testNsPrefixMath()
94 loadURL(getURLFromSrc("starmath/qa/extras/data/ns-prefix-math.mml"));
95 OUString
sExpected("left ( {italic \"a\" + italic \"b\"} right )^italic \"2\"");
96 CPPUNIT_ASSERT_EQUAL_MESSAGE("loaded text", sExpected
, mxDocShell
->GetText());
99 void Test::testMaction()
101 loadURL(getURLFromSrc("starmath/qa/extras/data/maction.mml"));
102 OUString
sExpected("matrix {italic \"1\" ## italic \"2\" ## italic \"3\"}");
103 CPPUNIT_ASSERT_EQUAL_MESSAGE("loaded text", sExpected
, mxDocShell
->GetText());
106 CPPUNIT_TEST_SUITE_REGISTRATION(Test
);
110 CPPUNIT_PLUGIN_IMPLEMENT();
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */