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/.
11 #include <swmodeltestbase.hxx>
13 #include <test/htmltesttools.hxx>
15 class XHtmlExportTest
: public SwModelTestBase
, public HtmlTestTools
19 : SwModelTestBase("/sw/qa/extras/odfexport/data/", "XHTML Writer File")
24 virtual std::unique_ptr
<Resetter
> preTest(const char*) override
26 setFilterOptions("UTF8");
31 #define DECLARE_HTMLEXPORT_TEST(TestName, filename) \
32 DECLARE_SW_EXPORT_TEST(TestName, filename, nullptr, XHtmlExportTest)
34 DECLARE_HTMLEXPORT_TEST(testImageEmbedding
, "image-mimetype.odt")
36 htmlDocUniquePtr pDoc
= parseHtml(maTempFile
);
39 assertXPath(pDoc
, "/html/body", 1);
40 assertXPath(pDoc
, "/html/body/div[1]/div[1]/img", 1);
41 OUString aValue
= getXPath(pDoc
, "/html/body/div[1]/div[1]/img", "src");
42 CPPUNIT_ASSERT(aValue
.startsWith("data:image/svg+xml;base64"));
45 DECLARE_HTMLEXPORT_TEST(testTdf131812
, "tdf131812.odt")
47 SvStream
* pStream
= maTempFile
.GetStream(StreamMode::READ
);
48 CPPUNIT_ASSERT(pStream
);
49 sal_uInt64 nLength
= pStream
->TellEnd();
50 OString
aStream(read_uInt8s_ToOString(*pStream
, nLength
));
52 aStream
.indexOf(".paragraph-P1{ font-size:12pt; font-family:\'Liberation Serif\'; "
53 "writing-mode:horizontal-tb; direction:rtl; text-align:right ! important;}")
57 DECLARE_HTMLEXPORT_TEST(testTdf146264
, "tdf146264.odt")
59 SvStream
* pStream
= maTempFile
.GetStream(StreamMode::READ
);
60 CPPUNIT_ASSERT(pStream
);
61 sal_uInt64 nLength
= pStream
->TellEnd();
62 OString
aStream(read_uInt8s_ToOString(*pStream
, nLength
));
63 sal_Int32 nFirstHello
= aStream
.indexOf("Hello");
64 CPPUNIT_ASSERT(nFirstHello
> 0);
67 sal_Int32 nSecondHello
= aStream
.indexOf("Hello", nFirstHello
+ 1);
68 constexpr sal_Int32 nMinusOne
= -1;
69 CPPUNIT_ASSERT_EQUAL(nMinusOne
, nSecondHello
);
73 DECLARE_HTMLEXPORT_TEST(testTdf118637
, "tdf118637.odt")
75 SvStream
* pStream
= maTempFile
.GetStream(StreamMode::READ
);
76 CPPUNIT_ASSERT(pStream
);
77 sal_uInt64 nLength
= pStream
->TellEnd();
78 OString
aStream(read_uInt8s_ToOString(*pStream
, nLength
));
79 CPPUNIT_ASSERT(aStream
.indexOf("The formula ") != -1);
80 CPPUNIT_ASSERT(aStream
.indexOf("should be inline.</div>") != -1);
83 DECLARE_HTMLEXPORT_TEST(testTdf145361
, "tdf145361.odt")
85 // Without the fix in place, this test would have failed with
86 // - SfxBaseModel::impl_store <file:///tmp/lu66091ameq.tmp> failed: 0xc10(Error Area:Io Class:Write Code:16)
87 SvStream
* pStream
= maTempFile
.GetStream(StreamMode::READ
);
88 CPPUNIT_ASSERT(pStream
);
89 sal_uInt64 nLength
= pStream
->TellEnd();
90 OString
aStream(read_uInt8s_ToOString(*pStream
, nLength
));
92 aStream
.indexOf("List entry has<br/><span style=\"margin-left:0cm\"/>a line break") != -1);
95 DECLARE_HTMLEXPORT_TEST(testTdf142483
, "tdf142483.odt")
97 SvStream
* pStream
= maTempFile
.GetStream(StreamMode::READ
);
98 CPPUNIT_ASSERT(pStream
);
99 sal_uInt64 nLength
= pStream
->TellEnd();
100 OString
aStream(read_uInt8s_ToOString(*pStream
, nLength
));
102 aStream
.indexOf("padding:0.0382in; border-left-width:thin; border-left-style:solid; "
103 "border-left-color:#000000; border-right-style:none; "
104 "border-top-width:thin; border-top-style:solid; border-top-color:#000000; "
105 "border-bottom-width:thin; border-bottom-style:solid; "
106 "border-bottom-color:#000000;")
109 aStream
.indexOf("padding:0.0382in; border-left-width:thin; border-left-style:solid; "
110 "border-left-color:#000000; border-right-style:none; "
111 "border-top-style:none; border-bottom-width:thin; "
112 "border-bottom-style:solid; border-bottom-color:#000000;")
115 aStream
.indexOf("border-top-width:thin; border-top-style:solid; border-top-color:#000000; "
116 "border-left-width:thin; border-left-style:solid; "
117 "border-left-color:#000000; border-bottom-width:thin; "
118 "border-bottom-style:solid; border-bottom-color:#000000; "
119 "border-right-width:thin; border-right-style:solid; "
120 "border-right-color:#000000; padding:0.0382in;")
123 aStream
.indexOf("padding:0.0382in; border-left-width:thin; border-left-style:solid; "
124 "border-left-color:#000000; border-right-width:thin; "
125 "border-right-style:solid; border-right-color:#000000; "
126 "border-top-style:none; border-bottom-width:thin; "
127 "border-bottom-style:solid; border-bottom-color:#000000;")
131 DECLARE_HTMLEXPORT_TEST(testTdf107696
, "tdf107696.odt")
133 SvStream
* pStream
= maTempFile
.GetStream(StreamMode::READ
);
134 CPPUNIT_ASSERT(pStream
);
135 sal_uInt64 nLength
= pStream
->TellEnd();
136 OString
aStream(read_uInt8s_ToOString(*pStream
, nLength
));
138 CPPUNIT_ASSERT(aStream
.indexOf("span.heading_numbering { margin-right: 0.8rem; }* { margin:0;}")
141 aStream
.indexOf("<h2 class=\"paragraph-Heading_20_2\"><a "
142 "id=\"a__Level_2_without_number\"><span/></a>Level 2 without number</h2>")
146 "<h2 class=\"paragraph-Heading_20_2\"><a id=\"a_3_1_Level_2__number_3_1\"><span "
147 "class=\"heading_numbering\">3.1</span></a>Level <span "
148 "class=\"text-T2\">2</span>, <span class=\"text-T1\">number 3.1</span></h2>")
152 "<h2 class=\"paragraph-Heading_20_2\"><a id=\"a_3_2_Level_2__number_3_2\"><span "
153 "class=\"heading_numbering\">3.2</span></a>Level 2, <span "
154 "class=\"text-T1\">number 3.2</span></h2>")
158 DECLARE_HTMLEXPORT_TEST(testTdf66305
, "tdf66305.odt")
160 SvStream
* pStream
= maTempFile
.GetStream(StreamMode::READ
);
161 CPPUNIT_ASSERT(pStream
);
162 sal_uInt64 nLength
= pStream
->TellEnd();
163 OString
aStream(read_uInt8s_ToOString(*pStream
, nLength
));
165 aStream
.indexOf("<p class=\"paragraph-P6\"><a href=\"#__RefHeading__82004_486970805\" "
166 "class=\"text-Internet_20_link\">Introduction</a></p><p "
167 "class=\"paragraph-P7\"> </p>")
171 CPPUNIT_PLUGIN_IMPLEMENT();
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */