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 <swmodeltestbase.hxx>
12 #include <com/sun/star/awt/FontWeight.hpp>
13 #include <com/sun/star/drawing/FillStyle.hpp>
14 #include <com/sun/star/text/RelOrientation.hpp>
15 #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
16 #include <com/sun/star/text/XPageCursor.hpp>
17 #include <com/sun/star/text/XTextColumns.hpp>
18 #include <com/sun/star/text/XTextTable.hpp>
19 #include <com/sun/star/text/XTextTablesSupplier.hpp>
20 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
21 #include <com/sun/star/text/XTextField.hpp>
22 #include <o3tl/string_view.hxx>
24 class Test
: public SwModelTestBase
27 Test() : SwModelTestBase(u
"/sw/qa/extras/ooxmlexport/data/"_ustr
, u
"Office Open XML Text"_ustr
) {}
30 CPPUNIT_TEST_FIXTURE(Test
, testTdf123621
)
32 loadAndSave("tdf123621.docx");
33 xmlDocUniquePtr pXmlDocument
= parseExport(u
"word/document.xml"_ustr
);
35 assertXPathContent(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor"
36 "/wp:positionV/wp:posOffset", u
"1080135");
39 CPPUNIT_TEST_FIXTURE(Test
, testTdf131540
)
41 loadAndReload("tdf131540.odt");
42 CPPUNIT_ASSERT_EQUAL(2, getShapes());
43 CPPUNIT_ASSERT_EQUAL(1, getPages());
44 // There are 2 OLEs test if one of them moved on save:
45 CPPUNIT_ASSERT_EQUAL_MESSAGE("The shape1 moved on saving!", text::RelOrientation::PAGE_FRAME
,
46 getProperty
<sal_Int16
>(getShape(1), u
"HoriOrientRelation"_ustr
));
47 CPPUNIT_ASSERT_EQUAL_MESSAGE("The shape2 moved on saving!", text::RelOrientation::PAGE_FRAME
,
48 getProperty
<sal_Int16
>(getShape(2), u
"HoriOrientRelation"_ustr
));
51 CPPUNIT_TEST_FIXTURE(Test
, testTdf131801
)
53 auto verify
= [this]() {
54 CPPUNIT_ASSERT_EQUAL(1, getPages());
56 xmlDocUniquePtr pDump
= parseLayoutDump();
58 assertXPath(pDump
, "//page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion", "expand", u
"1.");
59 assertXPath(pDump
, "//page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion/SwFont", "color", u
"00ff0000");
61 assertXPath(pDump
, "//page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwFieldPortion", "expand", u
"2.");
62 assertXPath(pDump
, "//page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwFieldPortion/SwFont", "color", u
"00ff0000");
64 assertXPath(pDump
, "//page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwFieldPortion", "expand", u
"3.");
65 assertXPath(pDump
, "//page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwFieldPortion/SwFont", "color", u
"ffffffff");
67 assertXPath(pDump
, "//page[1]/body/txt[4]/SwParaPortion/SwLineLayout/SwFieldPortion", "expand", u
"4.");
68 assertXPath(pDump
, "//page[1]/body/txt[4]/SwParaPortion/SwLineLayout/SwFieldPortion/SwFont", "color", u
"ffffffff");
70 assertXPath(pDump
, "//page[1]/body/txt[5]/SwParaPortion/SwLineLayout/SwFieldPortion", "expand", u
"5.");
71 assertXPath(pDump
, "//page[1]/body/txt[5]/SwParaPortion/SwLineLayout/SwFieldPortion/SwFont", "color", u
"00ff0000");
73 assertXPath(pDump
, "//page[1]/body/txt[6]/SwParaPortion/SwLineLayout/SwFieldPortion", "expand", u
"6.");
74 assertXPath(pDump
, "//page[1]/body/txt[6]/SwParaPortion/SwLineLayout/SwFieldPortion/SwFont", "color", u
"00ff0000");
76 assertXPath(pDump
, "//page[1]/body/txt[7]/SwParaPortion/SwLineLayout/SwFieldPortion", "expand", u
"7.");
77 assertXPath(pDump
, "//page[1]/body/txt[7]/SwParaPortion/SwLineLayout/SwFieldPortion/SwFont", "color", u
"ffffffff");
79 assertXPath(pDump
, "//page[1]/body/txt[8]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", "expand", u
"8.");
80 assertXPath(pDump
, "//page[1]/body/txt[8]/SwParaPortion/SwLineLayout/SwFieldPortion[1]/SwFont", "color", u
"ffffffff");
83 createSwDoc("tdf131801.docx");
85 saveAndReload(mpFilter
);
88 xmlDocUniquePtr pXmlDocument
= parseExport(u
"word/document.xml"_ustr
);
90 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:pPr/w:rPr/w:rStyle",
92 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[2]/w:pPr/w:rPr/w:rStyle",
94 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[3]/w:pPr/w:rPr/w:rStyle", 0);
95 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[4]/w:pPr/w:rPr/w:rStyle", 0);
96 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[5]/w:pPr/w:rPr/w:rStyle",
98 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[5]/w:pPr/w:rPr/w:sz",
100 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[6]/w:pPr/w:rPr/w:rStyle",
102 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[6]/w:pPr/w:rPr/w:sz",
104 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[7]/w:pPr/w:rPr/w:rStyle", 0);
105 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[8]/w:pPr/w:rPr/w:rStyle", 0);
108 CPPUNIT_TEST_FIXTURE(Test
, testTdf133334_followPgStyle
)
110 loadAndReload("tdf133334_followPgStyle.odt");
111 CPPUNIT_ASSERT_EQUAL(2, getPages());
114 DECLARE_OOXMLEXPORT_TEST(testTdf137850_compat14ZOrder
, "tdf137850_compat14ZOrder.docx")
116 // The file contains 2 shapes which have a different value of behindDoc.
117 // Test that the textbox is hidden behind the arrow (for Word <= 2010/compatibilityMode==14)
118 uno::Reference
<text::XText
> xShape(getShape(1), uno::UNO_QUERY
);
119 CPPUNIT_ASSERT_EQUAL(u
"2015"_ustr
, xShape
->getString());
120 CPPUNIT_ASSERT_EQUAL_MESSAGE("Textbox is in the background", false, getProperty
<bool>(xShape
, u
"Opaque"_ustr
));
123 DECLARE_OOXMLEXPORT_TEST(testTdf137850_compat15ZOrder
, "tdf137850_compat15ZOrder.docx")
125 // The file contains 2 shapes which have a different value of behindDoc.
126 // Test that the textbox is not hidden behind the arrow (for Word >= 2013/compatibilityMode==15)
127 uno::Reference
<text::XText
> xShape(getShape(2), uno::UNO_QUERY
);
128 CPPUNIT_ASSERT_EQUAL(u
"2015"_ustr
, xShape
->getString());
129 CPPUNIT_ASSERT_EQUAL_MESSAGE("Textbox is in the foreground", true, getProperty
<bool>(xShape
, u
"Opaque"_ustr
));
132 CPPUNIT_TEST_FIXTURE(Test
, testTdf118701
)
134 loadAndSave("tdf118701.docx");
135 // This was 6, related to moving inline images after the page breaks
136 CPPUNIT_ASSERT_EQUAL(4, getPages());
138 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
140 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:pPr[1]/w:numPr", 0);
141 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[2]/w:pPr[1]/w:numPr", 0);
142 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[3]/w:pPr[1]/w:numPr", 0);
143 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[4]/w:pPr[1]/w:numPr", 1);
145 // Keep numbering of the paragraph of the inline image
146 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[8]/w:pPr[1]/w:numPr", 0);
147 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[9]/w:pPr[1]/w:numPr", 1);
149 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[10]/w:pPr[1]/w:numPr", 1);
152 DECLARE_OOXMLEXPORT_TEST(testTdf123388
, "tdf123388.docx")
154 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
155 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
156 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
158 // Tests new cell formula PRODUCT
159 uno::Reference
<text::XTextField
> xEnumerationAccess1(xFields
->nextElement(), uno::UNO_QUERY
);
160 CPPUNIT_ASSERT_EQUAL(u
"PRODUCT(<B2:B3>)"_ustr
, xEnumerationAccess1
->getPresentation(true).trim());
161 CPPUNIT_ASSERT_EQUAL(u
"640"_ustr
, xEnumerationAccess1
->getPresentation(false).trim());
164 DECLARE_OOXMLEXPORT_TEST(testTdf123381
, "tdf123381.docx")
166 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
167 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
168 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
170 uno::Reference
<text::XTextField
> xEnumerationAccess1(xFields
->nextElement(), uno::UNO_QUERY
);
171 CPPUNIT_ASSERT_EQUAL(u
"INT(5.65)"_ustr
, xEnumerationAccess1
->getPresentation(true).trim());
172 CPPUNIT_ASSERT_EQUAL(u
"5"_ustr
, xEnumerationAccess1
->getPresentation(false).trim());
174 uno::Reference
<text::XTextField
> xEnumerationAccess2(xFields
->nextElement(), uno::UNO_QUERY
);
175 CPPUNIT_ASSERT_EQUAL(u
"INT(<A1>)"_ustr
, xEnumerationAccess2
->getPresentation(true).trim());
176 CPPUNIT_ASSERT_EQUAL(u
"6"_ustr
, xEnumerationAccess2
->getPresentation(false).trim());
179 CPPUNIT_TEST_FIXTURE(Test
, testTdf123401
)
181 loadAndReload("tdf123401.fodt");
182 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
183 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
184 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
186 // Tests new cell formula AVERAGE
187 uno::Reference
<text::XTextField
> xEnumerationAccess1(xFields
->nextElement(), uno::UNO_QUERY
);
188 CPPUNIT_ASSERT_EQUAL(u
"AVERAGE(<A1:A2>)"_ustr
, xEnumerationAccess1
->getPresentation(true).trim());
189 CPPUNIT_ASSERT_EQUAL(u
"3"_ustr
, xEnumerationAccess1
->getPresentation(false).trim());
191 uno::Reference
<text::XTextField
> xEnumerationAccess2(xFields
->nextElement(), uno::UNO_QUERY
);
192 CPPUNIT_ASSERT_EQUAL(u
"AVERAGE(<A1:A3>)"_ustr
, xEnumerationAccess2
->getPresentation(true).trim());
193 CPPUNIT_ASSERT_EQUAL(u
"3"_ustr
, xEnumerationAccess2
->getPresentation(false).trim());
195 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
197 // MEAN converted to AVERAGE
198 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:p/w:r[2]/w:instrText", u
" =AVERAGE(A1:A2)");
199 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[4]/w:tc/w:p/w:r[2]/w:instrText", u
" =AVERAGE(A1:A3)");
202 CPPUNIT_TEST_FIXTURE(Test
, testTdf116394
)
204 auto verify
= [this]() {
205 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
206 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
207 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
209 uno::Reference
<text::XTextField
> xEnumerationAccess(xFields
->nextElement(), uno::UNO_QUERY
);
211 // Without the fix in place, this test would have failed with
212 // - Expected: ab=cd..
214 CPPUNIT_ASSERT_EQUAL(u
"ab=cd.."_ustr
, xEnumerationAccess
->getPresentation(true).trim());
217 createSwDoc("tdf116394.docx");
219 saveAndReload(mpFilter
);
221 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
222 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:p/w:r[2]/w:instrText", u
" MERGEFIELD ab=cd ");
225 CPPUNIT_TEST_FIXTURE(Test
, testTdf123356
)
227 loadAndReload("tdf123356.fodt");
228 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
229 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
230 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
232 // Tests new cell formula COUNT
233 uno::Reference
<text::XTextField
> xEnumerationAccess1(xFields
->nextElement(), uno::UNO_QUERY
);
234 CPPUNIT_ASSERT_EQUAL(u
"COUNT(<A1>)"_ustr
, xEnumerationAccess1
->getPresentation(true).trim());
235 CPPUNIT_ASSERT_EQUAL(u
"1"_ustr
, xEnumerationAccess1
->getPresentation(false).trim());
237 uno::Reference
<text::XTextField
> xEnumerationAccess2(xFields
->nextElement(), uno::UNO_QUERY
);
238 CPPUNIT_ASSERT_EQUAL(u
"COUNT(<A1:B2>)"_ustr
, xEnumerationAccess2
->getPresentation(true).trim());
239 CPPUNIT_ASSERT_EQUAL(u
"4"_ustr
, xEnumerationAccess2
->getPresentation(false).trim());
242 CPPUNIT_TEST_FIXTURE(Test
, testTdf136404
)
244 loadAndReload("tdf136404.fodt");
245 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
246 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
247 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
249 // Ignore empty cells or cells with text content with new interoperability functions COUNT, AVERAGE and PRODUCT
250 uno::Reference
<text::XTextField
> xEnumerationAccess1(xFields
->nextElement(), uno::UNO_QUERY
);
251 CPPUNIT_ASSERT_EQUAL(u
"COUNT(<A1:F1>)"_ustr
, xEnumerationAccess1
->getPresentation(true).trim());
252 CPPUNIT_ASSERT_EQUAL(u
"2"_ustr
, xEnumerationAccess1
->getPresentation(false).trim());
254 uno::Reference
<text::XTextField
> xEnumerationAccess2(xFields
->nextElement(), uno::UNO_QUERY
);
255 CPPUNIT_ASSERT_EQUAL(u
"AVERAGE(<B1:C1>)"_ustr
, xEnumerationAccess2
->getPresentation(true).trim());
257 CPPUNIT_ASSERT_EQUAL(u
"** Expression is faulty **"_ustr
, xEnumerationAccess2
->getPresentation(false).trim());
259 uno::Reference
<text::XTextField
> xEnumerationAccess3(xFields
->nextElement(), uno::UNO_QUERY
);
260 CPPUNIT_ASSERT_EQUAL(u
"AVERAGE(<B1>)"_ustr
, xEnumerationAccess3
->getPresentation(true).trim());
262 CPPUNIT_ASSERT_EQUAL(u
"** Expression is faulty **"_ustr
, xEnumerationAccess3
->getPresentation(false).trim());
264 uno::Reference
<text::XTextField
> xEnumerationAccess4(xFields
->nextElement(), uno::UNO_QUERY
);
265 CPPUNIT_ASSERT_EQUAL(u
"COUNT(<B1:C1>)"_ustr
, xEnumerationAccess4
->getPresentation(true).trim());
267 CPPUNIT_ASSERT_EQUAL(u
"0"_ustr
, xEnumerationAccess4
->getPresentation(false).trim());
269 uno::Reference
<text::XTextField
> xEnumerationAccess5(xFields
->nextElement(), uno::UNO_QUERY
);
270 CPPUNIT_ASSERT_EQUAL(u
"COUNT(<B1>)"_ustr
, xEnumerationAccess5
->getPresentation(true).trim());
272 CPPUNIT_ASSERT_EQUAL(u
"0"_ustr
, xEnumerationAccess5
->getPresentation(false).trim());
274 uno::Reference
<text::XTextField
> xEnumerationAccess6(xFields
->nextElement(), uno::UNO_QUERY
);
275 CPPUNIT_ASSERT_EQUAL(u
"PRODUCT(<A1:F1>)"_ustr
, xEnumerationAccess6
->getPresentation(true).trim());
277 CPPUNIT_ASSERT_EQUAL(u
"60"_ustr
, xEnumerationAccess6
->getPresentation(false).trim());
279 uno::Reference
<text::XTextField
> xEnumerationAccess7(xFields
->nextElement(), uno::UNO_QUERY
);
280 CPPUNIT_ASSERT_EQUAL(u
"AVERAGE(<A1:F1>)"_ustr
, xEnumerationAccess7
->getPresentation(true).trim());
282 CPPUNIT_ASSERT_EQUAL(u
"8"_ustr
, xEnumerationAccess7
->getPresentation(false).trim());
285 DECLARE_OOXMLEXPORT_TEST(testTdf138739
, "tdf138739.docx")
287 uno::Reference
<beans::XPropertySet
> xParaProps(getParagraph(1), uno::UNO_QUERY
);
288 CPPUNIT_ASSERT_EQUAL_MESSAGE("Font type name does not match!", u
"Comic Sans MS"_ustr
,
289 xParaProps
->getPropertyValue(u
"CharFontName"_ustr
).get
<OUString
>());
291 // tdf#148565: text at anchor point should be bold, Comic Sans MS font
292 CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD
, getProperty
<float>(getRun(getParagraph(5), 3), u
"CharWeight"_ustr
));
295 CPPUNIT_TEST_FIXTURE(Test
, testTdf123390
)
297 loadAndReload("tdf123390.fodt");
298 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
299 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
300 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
302 // Tests new cell formula SIGN
303 uno::Reference
<text::XTextField
> xEnumerationAccess1(xFields
->nextElement(), uno::UNO_QUERY
);
304 CPPUNIT_ASSERT_EQUAL(u
"SIGN(<A1>)"_ustr
, xEnumerationAccess1
->getPresentation(true).trim());
305 CPPUNIT_ASSERT_EQUAL(u
"-1"_ustr
, xEnumerationAccess1
->getPresentation(false).trim());
307 uno::Reference
<text::XTextField
> xEnumerationAccess2(xFields
->nextElement(), uno::UNO_QUERY
);
308 CPPUNIT_ASSERT_EQUAL(u
"SIGN(<C1>)"_ustr
, xEnumerationAccess2
->getPresentation(true).trim());
309 CPPUNIT_ASSERT_EQUAL(u
"1"_ustr
, xEnumerationAccess2
->getPresentation(false).trim());
311 uno::Reference
<text::XTextField
> xEnumerationAccess3(xFields
->nextElement(), uno::UNO_QUERY
);
312 CPPUNIT_ASSERT_EQUAL(u
"SIGN(<B1>)"_ustr
, xEnumerationAccess3
->getPresentation(true).trim());
313 CPPUNIT_ASSERT_EQUAL(u
"0"_ustr
, xEnumerationAccess3
->getPresentation(false).trim());
316 CPPUNIT_TEST_FIXTURE(Test
, testTdf123354
)
318 loadAndReload("tdf123354.fodt");
319 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
320 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
321 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
323 // Tests new cell formula SIGN
324 uno::Reference
<text::XTextField
> xEnumerationAccess1(xFields
->nextElement(), uno::UNO_QUERY
);
325 CPPUNIT_ASSERT_EQUAL(u
"ABS(<A1>)"_ustr
, xEnumerationAccess1
->getPresentation(true).trim());
326 CPPUNIT_ASSERT_EQUAL(u
"10"_ustr
, xEnumerationAccess1
->getPresentation(false).trim());
328 uno::Reference
<text::XTextField
> xEnumerationAccess2(xFields
->nextElement(), uno::UNO_QUERY
);
329 CPPUNIT_ASSERT_EQUAL(u
"ABS(<C1>)"_ustr
, xEnumerationAccess2
->getPresentation(true).trim());
330 CPPUNIT_ASSERT_EQUAL(u
"10"_ustr
, xEnumerationAccess2
->getPresentation(false).trim());
332 uno::Reference
<text::XTextField
> xEnumerationAccess3(xFields
->nextElement(), uno::UNO_QUERY
);
333 CPPUNIT_ASSERT_EQUAL(u
"ABS(<B1>)"_ustr
, xEnumerationAccess3
->getPresentation(true).trim());
334 CPPUNIT_ASSERT_EQUAL(u
"0"_ustr
, xEnumerationAccess3
->getPresentation(false).trim());
337 CPPUNIT_TEST_FIXTURE(Test
, testTdf123355
)
339 auto verify
= [this]() {
340 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
341 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
342 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
344 // Tests conversion of range IDs ABOVE, BELOW, LEFT and RIGHT
345 uno::Reference
<text::XTextField
> xEnumerationAccess1(xFields
->nextElement(), uno::UNO_QUERY
);
346 // Note: range ends at B4 here, which is a cell with text content
347 CPPUNIT_ASSERT_EQUAL(u
"average( <B2:B3> )"_ustr
, xEnumerationAccess1
->getPresentation(true).trim());
348 CPPUNIT_ASSERT_EQUAL(u
"5,5"_ustr
, xEnumerationAccess1
->getPresentation(false).trim());
350 // range ends at the end of the empty cells
351 uno::Reference
<text::XTextField
> xEnumerationAccess6(xFields
->nextElement(), uno::UNO_QUERY
);
352 CPPUNIT_ASSERT_EQUAL(u
"SUM(<C6:A6>)"_ustr
, xEnumerationAccess6
->getPresentation(true).trim());
353 CPPUNIT_ASSERT_EQUAL(u
"0"_ustr
, xEnumerationAccess6
->getPresentation(false).trim());
355 // range starts at the first cell above D5
356 uno::Reference
<text::XTextField
> xEnumerationAccess2(xFields
->nextElement(), uno::UNO_QUERY
);
357 CPPUNIT_ASSERT_EQUAL(u
"AVERAGE(<D4:D1>)"_ustr
, xEnumerationAccess2
->getPresentation(true).trim());
358 CPPUNIT_ASSERT_EQUAL(u
"5,33"_ustr
, xEnumerationAccess2
->getPresentation(false).trim());
360 uno::Reference
<text::XTextField
> xEnumerationAccess3(xFields
->nextElement(), uno::UNO_QUERY
);
361 CPPUNIT_ASSERT_EQUAL(u
"AVERAGE(<C2:C1>)"_ustr
, xEnumerationAccess3
->getPresentation(true).trim());
362 CPPUNIT_ASSERT_EQUAL(u
"3,5"_ustr
, xEnumerationAccess3
->getPresentation(false).trim());
364 uno::Reference
<text::XTextField
> xEnumerationAccess4(xFields
->nextElement(), uno::UNO_QUERY
);
365 CPPUNIT_ASSERT_EQUAL(u
"AVERAGE(<D2:D2>)"_ustr
, xEnumerationAccess4
->getPresentation(true).trim());
366 CPPUNIT_ASSERT_EQUAL(u
"5"_ustr
, xEnumerationAccess4
->getPresentation(false).trim());
368 uno::Reference
<text::XTextField
> xEnumerationAccess5(xFields
->nextElement(), uno::UNO_QUERY
);
369 CPPUNIT_ASSERT_EQUAL(u
"AVERAGE(<A2:A2>)"_ustr
, xEnumerationAccess5
->getPresentation(true).trim());
370 CPPUNIT_ASSERT_EQUAL(u
"4"_ustr
, xEnumerationAccess5
->getPresentation(false).trim());
373 createSwDoc("tdf123355.docx");
375 saveAndReload(mpFilter
);
378 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
380 // keep original formula IDs
381 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[2]/w:p/w:r[2]/w:instrText", u
" =average( below )");
382 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[2]/w:p/w:r[2]/w:instrText", u
" =AVERAGE(LEFT)");
383 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[3]/w:p/w:r[2]/w:instrText", u
" =AVERAGE(RIGHT)");
384 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[3]/w:tc[3]/w:p/w:r[2]/w:instrText", u
" =AVERAGE(ABOVE)");
385 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[5]/w:tc[4]/w:p/w:r[2]/w:instrText", u
" =AVERAGE(ABOVE)");
386 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[6]/w:tc[4]/w:p/w:r[2]/w:instrText", u
" =SUM(LEFT)");
389 CPPUNIT_TEST_FIXTURE(Test
, testTdf123382
)
391 auto verify
= [this]() {
392 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
393 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
394 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
396 // Tests conversion of range IDs ABOVE, BELOW, LEFT and RIGHT
397 uno::Reference
<text::XTextField
> xEnumerationAccess1(xFields
->nextElement(), uno::UNO_QUERY
);
398 // Note: range ends at B4 here, which is a cell with text content
399 CPPUNIT_ASSERT_EQUAL(u
"MAX(<B1:D1>)"_ustr
, xEnumerationAccess1
->getPresentation(true).trim());
400 CPPUNIT_ASSERT_EQUAL(u
"12"_ustr
, xEnumerationAccess1
->getPresentation(false).trim());
402 // range ends at the end of the empty cells
403 uno::Reference
<text::XTextField
> xEnumerationAccess6(xFields
->nextElement(), uno::UNO_QUERY
);
404 CPPUNIT_ASSERT_EQUAL(u
"MAX(<C4:D4>)"_ustr
, xEnumerationAccess6
->getPresentation(true).trim());
405 CPPUNIT_ASSERT_EQUAL(u
"9"_ustr
, xEnumerationAccess6
->getPresentation(false).trim());
407 // range starts at the first cell above D5
408 uno::Reference
<text::XTextField
> xEnumerationAccess2(xFields
->nextElement(), uno::UNO_QUERY
);
409 CPPUNIT_ASSERT_EQUAL(u
"SUM(<B3:D3>)"_ustr
, xEnumerationAccess2
->getPresentation(true).trim());
410 CPPUNIT_ASSERT_EQUAL(u
"30"_ustr
, xEnumerationAccess2
->getPresentation(false).trim());
412 uno::Reference
<text::XTextField
> xEnumerationAccess3(xFields
->nextElement(), uno::UNO_QUERY
);
413 CPPUNIT_ASSERT_EQUAL(u
"MAX(<C2:A2>)"_ustr
, xEnumerationAccess3
->getPresentation(true).trim());
414 CPPUNIT_ASSERT_EQUAL(u
"7"_ustr
, xEnumerationAccess3
->getPresentation(false).trim());
416 uno::Reference
<text::XTextField
> xEnumerationAccess4(xFields
->nextElement(), uno::UNO_QUERY
);
417 CPPUNIT_ASSERT_EQUAL(u
"MAX(<B2:D2>)"_ustr
, xEnumerationAccess4
->getPresentation(true).trim());
418 CPPUNIT_ASSERT_EQUAL(u
"7"_ustr
, xEnumerationAccess4
->getPresentation(false).trim());
420 uno::Reference
<text::XTextField
> xEnumerationAccess5(xFields
->nextElement(), uno::UNO_QUERY
);
421 CPPUNIT_ASSERT_EQUAL(u
"MAX(<D2:D4>)"_ustr
, xEnumerationAccess5
->getPresentation(true).trim());
422 CPPUNIT_ASSERT_EQUAL(u
"12"_ustr
, xEnumerationAccess5
->getPresentation(false).trim());
424 uno::Reference
<text::XTextField
> xEnumerationAccess7(xFields
->nextElement(), uno::UNO_QUERY
);
425 CPPUNIT_ASSERT_EQUAL(u
"MAX(<B2:B4>)"_ustr
, xEnumerationAccess7
->getPresentation(true).trim());
426 CPPUNIT_ASSERT_EQUAL(u
"10"_ustr
, xEnumerationAccess7
->getPresentation(false).trim());
429 createSwDoc("tdf123382.docx");
431 saveAndReload(mpFilter
);
434 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
436 // keep original formula IDs
437 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:p/w:r[2]/w:instrText", u
" =MAX(RIGHT)");
438 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[1]/w:p/w:r[2]/w:instrText", u
" =MAX(RIGHT)");
439 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[3]/w:tc[1]/w:p/w:r[2]/w:instrText", u
" =SUM(RIGHT)");
440 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[2]/w:p/w:r[2]/w:instrText", u
" =MAX(BELOW)");
441 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[4]/w:tc[2]/w:p/w:r[2]/w:instrText", u
" =MAX(RIGHT)");
442 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[4]/w:p/w:r[2]/w:instrText", u
" =MAX(BELOW)");
443 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[4]/w:p/w:r[2]/w:instrText", u
" =MAX(LEFT)");
446 CPPUNIT_TEST_FIXTURE(Test
, testTdf122648
)
448 auto verify
= [this]() {
449 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
450 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
451 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
453 // table formula conversion worked only in the first table
454 uno::Reference
<text::XTextField
> xEnumerationAccess1(xFields
->nextElement(), uno::UNO_QUERY
);
455 CPPUNIT_ASSERT_EQUAL(u
"<A1>"_ustr
, xEnumerationAccess1
->getPresentation(true).trim());
456 CPPUNIT_ASSERT_EQUAL(u
"1"_ustr
, xEnumerationAccess1
->getPresentation(false).trim());
458 uno::Reference
<text::XTextField
> xEnumerationAccess2(xFields
->nextElement(), uno::UNO_QUERY
);
459 CPPUNIT_ASSERT_EQUAL(u
"SUM(<A1:B1>)"_ustr
, xEnumerationAccess2
->getPresentation(true).trim());
460 CPPUNIT_ASSERT_EQUAL(u
"2"_ustr
, xEnumerationAccess2
->getPresentation(false).trim());
462 // These were <?> and SUM(<?:?>) with zero values
463 uno::Reference
<text::XTextField
> xEnumerationAccess3(xFields
->nextElement(), uno::UNO_QUERY
);
464 CPPUNIT_ASSERT_EQUAL(u
"<A1>"_ustr
, xEnumerationAccess3
->getPresentation(true).trim());
465 CPPUNIT_ASSERT_EQUAL(u
"1"_ustr
, xEnumerationAccess3
->getPresentation(false).trim());
467 uno::Reference
<text::XTextField
> xEnumerationAccess4(xFields
->nextElement(), uno::UNO_QUERY
);
468 CPPUNIT_ASSERT_EQUAL(u
"SUM(<A1:B1>)"_ustr
, xEnumerationAccess4
->getPresentation(true).trim());
469 CPPUNIT_ASSERT_EQUAL(u
"2"_ustr
, xEnumerationAccess4
->getPresentation(false).trim());
472 createSwDoc("tdf122648.docx");
474 saveAndReload(mpFilter
);
477 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
479 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl[1]/w:tr[1]/w:tc[2]/w:p/w:r[2]/w:instrText", u
" =A1");
480 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl[1]/w:tr[2]/w:tc[2]/w:p/w:r[2]/w:instrText", u
" =SUM(A1:B1)");
481 // These were =<?> and =SUM(<?:?>)
482 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl[2]/w:tr[1]/w:tc[2]/w:p/w:r[2]/w:instrText", u
" =A1");
483 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl[2]/w:tr[2]/w:tc[2]/w:p/w:r[2]/w:instrText", u
" =SUM(A1:B1)");
486 CPPUNIT_TEST_FIXTURE(Test
, testTdf98000_changePageStyle
)
488 loadAndReload("tdf98000_changePageStyle.odt");
489 uno::Reference
<frame::XModel
> xModel(mxComponent
, uno::UNO_QUERY
);
490 uno::Reference
<text::XTextViewCursorSupplier
> xTextViewCursorSupplier(xModel
->getCurrentController(), uno::UNO_QUERY
);
492 uno::Reference
<text::XPageCursor
> xCursor(xTextViewCursorSupplier
->getViewCursor(), uno::UNO_QUERY_THROW
);
493 OUString sPageOneStyle
= getProperty
<OUString
>( xCursor
, u
"PageStyleName"_ustr
);
495 xCursor
->jumpToNextPage();
496 OUString sPageTwoStyle
= getProperty
<OUString
>( xCursor
, u
"PageStyleName"_ustr
);
497 CPPUNIT_ASSERT_MESSAGE("Different page1/page2 styles", sPageOneStyle
!= sPageTwoStyle
);
500 CPPUNIT_TEST_FIXTURE(Test
, testTdf145998_unnecessaryPageStyles
)
502 loadAndReload("tdf145998_unnecessaryPageStyles.odt");
504 // Sanity check - always good to test when dealing with page styles and breaks.
505 CPPUNIT_ASSERT_EQUAL(5, getPages());
506 xmlDocUniquePtr pXmlDoc
= parseLayoutDump();
508 // Page Style should be explicitly mentioned - otherwise it would be a "follow" style
509 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(2, u
"2"_ustr
), uno::UNO_QUERY_THROW
);
510 CPPUNIT_ASSERT(uno::Any() != xPara
->getPropertyValue(u
"PageDescName"_ustr
));
511 // CPPUNIT_ASSERT_EQUAL(OUString("First Page header"),
512 // getXPathContent(pXmlDoc, "/root/page[2]/header/txt"));
514 // Page Style is converted into a page break instead. Still shows "first" header.
515 xPara
.set(getParagraph(3, u
"3"_ustr
), uno::UNO_QUERY_THROW
);
516 CPPUNIT_ASSERT_EQUAL(uno::Any(), xPara
->getPropertyValue(u
"PageDescName"_ustr
));
517 // CPPUNIT_ASSERT_EQUAL(OUString("Default page style - first page style"),
518 // getXPathContent(pXmlDoc, "/root/page[3]/header/txt"));
519 assertXPathContent(pXmlDoc
, "/root/page[3]/footer/txt", u
"");
521 // Page Style is converted into a page break instead. Shows the "normal" header.
522 xPara
.set(getParagraph(5, u
"4"_ustr
), uno::UNO_QUERY_THROW
);
523 CPPUNIT_ASSERT_EQUAL(uno::Any(), xPara
->getPropertyValue(u
"PageDescName"_ustr
));
524 assertXPathContent(pXmlDoc
, "/root/page[4]/header/txt", u
"Default page style");
526 // Page Style is retained (with wrong header) in order to preserve page re-numbering.
527 xPara
.set(getParagraph(7, u
"1"_ustr
), uno::UNO_QUERY_THROW
);
528 CPPUNIT_ASSERT(uno::Any() != xPara
->getPropertyValue(u
"PageDescName"_ustr
));
529 assertXPathContent(pXmlDoc
, "/root/page[5]/footer/txt", u
"");
532 CPPUNIT_TEST_FIXTURE(Test
, testTdf136929_framesOfParagraph
)
534 loadAndReload("tdf136929_framesOfParagraph.odt");
535 // Before this fix, the image was placed in the footer instead of in the text body - messing everything up.
536 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Number of Pages", 5, getPages() );
537 xmlDocUniquePtr pXmlDoc
= parseLayoutDump();
538 CPPUNIT_ASSERT_EQUAL_MESSAGE("Header2 text", u
"* | *"_ustr
, getXPathContent(pXmlDoc
, "/root/page[4]/footer/txt"));
541 DECLARE_OOXMLEXPORT_TEST(testTdf136589_paraHadField
, "tdf136589_paraHadField.docx")
543 // The section break should not add an additional CR - which equals an empty page two.
544 CPPUNIT_ASSERT_EQUAL(2, getPages());
546 //tdf#118711 - don't explicitly specify the default page style at the beginning of the document
547 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(1), uno::UNO_QUERY_THROW
);
548 CPPUNIT_ASSERT_EQUAL(uno::Any(), xPara
->getPropertyValue(u
"PageDescName"_ustr
));
551 CPPUNIT_TEST_FIXTURE(Test
, testTdf133370_columnBreak
)
553 loadAndReload("tdf133370_columnBreak.odt");
554 // Since non-DOCX formats ignores column breaks in non-column situations, don't export to docx.
555 CPPUNIT_ASSERT_EQUAL(1, getPages());
558 CPPUNIT_TEST_FIXTURE(Test
, testTdf134649_pageBreak
)
560 loadAndReload("tdf134649_pageBreak.fodt");
561 // This was 1 (missing page break between tables).
562 CPPUNIT_ASSERT_EQUAL(2, getPages());
565 DECLARE_OOXMLEXPORT_TEST(testTdf135343_columnSectionBreak_c14
, "tdf135343_columnSectionBreak_c14.docx")
567 uno::Reference
<beans::XPropertySet
> xTextSection
= getProperty
<uno::Reference
<beans::XPropertySet
>>(getParagraph(1), u
"TextSection"_ustr
);
568 uno::Reference
<text::XTextColumns
> xTextColumns
= getProperty
<uno::Reference
<text::XTextColumns
>>(xTextSection
, u
"TextColumns"_ustr
);
569 CPPUNIT_ASSERT_EQUAL_MESSAGE("Section one's columns", sal_Int16(2), xTextColumns
->getColumnCount());
571 // Old Word 2010 version - nextColumn breaks inside column sections are just treated as regular column breaks.
572 //xTextSection = getProperty<uno::Reference<beans::XPropertySet>>(getParagraph(12, "RTL 2"), "TextSection");
573 //xTextColumns = getProperty<uno::Reference<text::XTextColumns>>(xTextSection, "TextColumns");
574 //CPPUNIT_ASSERT_EQUAL_MESSAGE("Section four's columns", sal_Int16(3), xTextColumns->getColumnCount());
575 //CPPUNIT_ASSERT_EQUAL(1, getPages());
578 CPPUNIT_TEST_FIXTURE(Test
, testTdf135973
)
580 loadAndReload("tdf135973.odt");
581 CPPUNIT_ASSERT_EQUAL(1, getPages());
583 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(2), uno::UNO_QUERY
);
584 CPPUNIT_ASSERT_EQUAL(u
"1."_ustr
, getProperty
<OUString
>(xPara
, u
"ListLabelString"_ustr
));
587 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(3), uno::UNO_QUERY
);
588 CPPUNIT_ASSERT_EQUAL(u
"2."_ustr
, getProperty
<OUString
>(xPara
, u
"ListLabelString"_ustr
));
591 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(5), uno::UNO_QUERY
);
592 CPPUNIT_ASSERT_EQUAL(u
"1."_ustr
, getProperty
<OUString
>(xPara
, u
"ListLabelString"_ustr
));
595 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(6), uno::UNO_QUERY
);
596 CPPUNIT_ASSERT_EQUAL(u
"2."_ustr
, getProperty
<OUString
>(xPara
, u
"ListLabelString"_ustr
));
600 DECLARE_OOXMLEXPORT_TEST(testTdf135343_columnSectionBreak_c14v2
, "tdf135343_columnSectionBreak_c14v2.docx")
602 // In this Word 2010 v2, section three was changed to start with a nextColumn break instead of a continuous break.
603 // The previous section has no columns, so this time start the columns on a new page.
604 uno::Reference
<beans::XPropertySet
> xTextSection
= getProperty
<uno::Reference
<beans::XPropertySet
>>(getParagraph(10, u
""_ustr
), u
"TextSection"_ustr
);
605 uno::Reference
<text::XTextColumns
> xTextColumns
= getProperty
<uno::Reference
<text::XTextColumns
>>(xTextSection
, u
"TextColumns"_ustr
);
606 CPPUNIT_ASSERT_EQUAL_MESSAGE("Section three's columns", sal_Int16(3), xTextColumns
->getColumnCount());
607 //CPPUNIT_ASSERT_EQUAL(2, getPages());
610 DECLARE_OOXMLEXPORT_TEST(testTdf135343_columnSectionBreak_c12v3
, "tdf135343_columnSectionBreak_c12v3.docx")
612 // In this Word 20-3 v3, section one and two have different number of columns. It acts like a page break.
613 uno::Reference
<beans::XPropertySet
> xTextSection
= getProperty
<uno::Reference
<beans::XPropertySet
>>(getParagraph(1, u
"Four columns,"_ustr
), u
"TextSection"_ustr
);
614 uno::Reference
<text::XTextColumns
> xTextColumns
= getProperty
<uno::Reference
<text::XTextColumns
>>(xTextSection
, u
"TextColumns"_ustr
);
615 CPPUNIT_ASSERT_EQUAL_MESSAGE("Section one's columns", sal_Int16(4), xTextColumns
->getColumnCount());
617 xTextSection
= getProperty
<uno::Reference
<beans::XPropertySet
>>(getParagraph(6, u
"RTL 2"_ustr
), u
"TextSection"_ustr
);
618 xTextColumns
= getProperty
<uno::Reference
<text::XTextColumns
>>(xTextSection
, u
"TextColumns"_ustr
);
619 CPPUNIT_ASSERT_EQUAL_MESSAGE("Section two's columns", sal_Int16(2), xTextColumns
->getColumnCount());
620 CPPUNIT_ASSERT_EQUAL(2, getPages());
623 DECLARE_OOXMLEXPORT_TEST(testTdf135343_columnSectionBreak_c15
, "tdf135343_columnSectionBreak_c15.docx")
625 // Word 2013+ version - nextColumn breaks inside column sections are always handled like nextPage breaks.
626 uno::Reference
<beans::XPropertySet
> xTextSection
= getProperty
<uno::Reference
<beans::XPropertySet
>>(getParagraph(12, u
"RTL 2"_ustr
), u
"TextSection"_ustr
);
627 uno::Reference
<text::XTextColumns
> xTextColumns
= getProperty
<uno::Reference
<text::XTextColumns
>>(xTextSection
, u
"TextColumns"_ustr
);
628 CPPUNIT_ASSERT_EQUAL_MESSAGE("Section four's columns", sal_Int16(3), xTextColumns
->getColumnCount());
629 CPPUNIT_ASSERT_EQUAL_MESSAGE("Fits on two pages", 2, getPages());
632 DECLARE_OOXMLEXPORT_TEST(testTdf121669_equalColumns
, "tdf121669_equalColumns.docx")
634 uno::Reference
<beans::XPropertySet
> xTextSection
= getProperty
< uno::Reference
<beans::XPropertySet
> >(getParagraph(1), u
"TextSection"_ustr
);
635 CPPUNIT_ASSERT(xTextSection
.is());
636 uno::Reference
<text::XTextColumns
> xTextColumns
= getProperty
< uno::Reference
<text::XTextColumns
> >(xTextSection
, u
"TextColumns"_ustr
);
637 // The property was ignored when deciding at export whether the columns were equal or not. Layout isn't reliable.
638 CPPUNIT_ASSERT(getProperty
<bool>(xTextColumns
, u
"IsAutomatic"_ustr
));
641 CPPUNIT_TEST_FIXTURE(Test
, testTdf132149_pgBreak
)
643 loadAndReload("tdf132149_pgBreak.odt");
644 // This 5 page document is designed to visually exaggerate the problems
645 // of emulating LO's followed-by-page-style into MSWord's sections.
646 // While much has been improved, there are extra pages present, which still need fixing.
647 xmlDocUniquePtr pDump
= parseLayoutDump();
649 // No header on pages 1,2,3.
650 assertXPath(pDump
, "//page[2]/header", 0);
652 // Margins/page orientation between Right and Left page styles are different
653 assertXPath(pDump
, "//page[1]/infos/prtBounds", "left", u
"1134"); //Right page style
654 assertXPath(pDump
, "//page[2]/infos/prtBounds", "left", u
"2268"); //Left page style
656 assertXPath(pDump
, "//page[1]/infos/bounds", "width", u
"8391"); //landscape
657 assertXPath(pDump
, "//page[2]/infos/bounds", "width", u
"5940"); //portrait
658 // This two-line 3rd page ought not to exist. DID YOU FIX ME? The real page 3 should be "8391" landscape.
659 assertXPath(pDump
, "//page[3]/infos/bounds", "width", u
"5940");
660 // This really ought to be on odd page 3, but now it is on odd page 5.
661 assertXPath(pDump
, "//page[5]/infos/bounds", "width", u
"8391");
662 assertXPath(pDump
, "//page[5]/infos/prtBounds", "right", u
"6122"); //Left page style
665 //Page style change here must not be lost. This SHOULD be on page 4, but sadly it is not.
666 assertXPathContent(pDump
, "//page[6]/header/txt", u
"First Page Style");
667 CPPUNIT_ASSERT(getXPathContent(pDump
, "//page[6]/body/txt[1]").startsWith("Lorem ipsum"));
670 CPPUNIT_TEST_FIXTURE(Test
, testTdf132149_pgBreakB
)
672 loadAndReload("tdf132149_pgBreakB.odt");
673 // This 5 page document is designed to visually exaggerate the problems
674 // of emulating LO's followed-by-page-style into MSWord's sections.
675 xmlDocUniquePtr pDump
= parseLayoutDump();
677 //Sanity check to ensure the correct page is being tested. This SHOULD be on page 3, but sadly it is not.
678 CPPUNIT_ASSERT(getXPathContent(pDump
, "//page[5]/body/txt[1]").startsWith("Lorem ipsum"));
679 //Prior to this fix, the original alternation between portrait and landscape was completely lost.
680 assertXPath(pDump
, "//page[5]/infos/bounds", "width", u
"8391"); //landscape
683 CPPUNIT_TEST_FIXTURE(Test
, testTdf132149_pgBreak2
)
685 loadAndReload("tdf132149_pgBreak2.odt");
686 // This 3 page document is designed to visually exaggerate the problems
687 // of emulating LO's followed-by-page-style into MSWord's sections.
689 // The only specified page style change should be between page 1 and 2.
690 // When the first paragraph was split into 3, each paragraph specified a page break. The last was unnecessary.
691 uno::Reference
<beans::XPropertySet
> xParaThree(getParagraph(3), uno::UNO_QUERY_THROW
);
692 CPPUNIT_ASSERT_EQUAL(uno::Any(), xParaThree
->getPropertyValue(u
"PageDescName"_ustr
));
693 // The ODT is only 2 paragraphs, but a hack to get the right page style breaks para1 into pieces.
694 // This was 4 paragraphs - the unnecessary page break had hacked in another paragraph split.
695 CPPUNIT_ASSERT_LESSEQUAL( 3, getParagraphs() );
698 CPPUNIT_TEST_FIXTURE(Test
, testTdf136952_pgBreak3B
)
700 loadAndReload("tdf136952_pgBreak3B.odt");
701 // This 4 page document is designed to visually exaggerate the problems
702 // of emulating LO's followed-by-page-style into MSWord's sections.
703 xmlDocUniquePtr pDump
= parseLayoutDump();
705 //page::breakAfter must not be lost.
706 //Prior to this bug fix, the Lorem ipsum paragraph was in the middle of a portrait page, with no switch to landscape occurring.
707 CPPUNIT_ASSERT(getXPathContent(pDump
, "//page[3]/body/txt[1]").startsWith("Lorem ipsum"));
708 assertXPath(pDump
, "//page[3]/infos/bounds", "width", u
"8391"); //landscape
711 DECLARE_OOXMLEXPORT_TEST(testTdf135949_anchoredBeforeBreak
, "tdf135949_anchoredBeforeBreak.docx")
713 xmlDocUniquePtr pDump
= parseLayoutDump();
714 //The picture was shown on page 2, because the empty paragraph before the page break was removed
715 assertXPath(pDump
, "//page[1]/body/txt/anchored/fly", 1);
718 DECLARE_OOXMLEXPORT_TEST(testTdf129452_excessBorder
, "tdf129452_excessBorder.docx")
720 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
721 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
722 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY_THROW
);
724 // The outside border should not be applied on inside cells. The merge doesn't extend to the table bottom.
725 // [Note: as humans, we would call this cell D3, but since row 4 hasn't been analyzed yet, it is considered column C.]
726 table::BorderLine2 aBorder
= getProperty
<table::BorderLine2
>(xTable
->getCellByName(u
"C3"_ustr
), u
"BottomBorder"_ustr
);
727 CPPUNIT_ASSERT_EQUAL_MESSAGE("No bottom border on merged cell", sal_uInt32(0), aBorder
.LineWidth
);
729 // [Note: as humans, we would call this cell C3, but since row 4 hasn't been analyzed yet, it is considered column B.]
730 aBorder
= getProperty
<table::BorderLine2
>(xTable
->getCellByName(u
"B3"_ustr
), u
"BottomBorder"_ustr
);
731 CPPUNIT_ASSERT_EQUAL_MESSAGE("No bottom border on merged cell", sal_uInt32(0), aBorder
.LineWidth
);
734 DECLARE_OOXMLEXPORT_TEST(testTdf132898_missingBorder
, "tdf132898_missingBorder.docx")
736 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
737 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
738 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
740 // The bottom border from the last merged cell was not showing
741 table::BorderLine2 aBorder
= getProperty
<table::BorderLine2
>(xTable
->getCellByName(u
"A1"_ustr
), u
"BottomBorder"_ustr
);
742 CPPUNIT_ASSERT_MESSAGE("Bottom border on merged cell", aBorder
.LineWidth
> 0);
745 DECLARE_OOXMLEXPORT_TEST(testTdf132898_extraBorder
, "tdf132898_extraBorder.docx")
747 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
748 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
749 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
751 // A border defined on an earlier merged cell was showing
752 table::BorderLine2 aBorder
= getProperty
<table::BorderLine2
>(xTable
->getCellByName(u
"C1"_ustr
), u
"BottomBorder"_ustr
);
753 CPPUNIT_ASSERT_EQUAL_MESSAGE("No bottom border on merged cell", sal_uInt32(0), aBorder
.LineWidth
);
754 // MS Word is interesting here. 2/3 of the merged cell has the right border, so what to do?
755 aBorder
= getProperty
<table::BorderLine2
>(xTable
->getCellByName(u
"C1"_ustr
), u
"RightBorder"_ustr
);
756 CPPUNIT_ASSERT_EQUAL_MESSAGE("No right border on merged cell", sal_uInt32(0), aBorder
.LineWidth
);
759 DECLARE_OOXMLEXPORT_TEST(testTdf131561_necessaryBorder
, "tdf131561_necessaryBorder.docx")
761 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
762 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
763 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
765 // Hand-crafted pre-emptive test to make sure borders aren't lost.
766 // MS Word is interesting here. 2/3 of the merged cell has the right border, so what to do?
767 table::BorderLine2 aBorderR
= getProperty
<table::BorderLine2
>(xTable
->getCellByName(u
"A1"_ustr
), u
"RightBorder"_ustr
);
768 table::BorderLine2 aBorderL
= getProperty
<table::BorderLine2
>(xTable
->getCellByName(u
"B1"_ustr
), u
"LeftBorder"_ustr
);
769 CPPUNIT_ASSERT_MESSAGE("Border between A1 and B1", (aBorderR
.LineWidth
+ aBorderL
.LineWidth
) > 0);
770 aBorderR
= getProperty
<table::BorderLine2
>(xTable
->getCellByName(u
"A3"_ustr
), u
"RightBorder"_ustr
);
771 aBorderL
= getProperty
<table::BorderLine2
>(xTable
->getCellByName(u
"B3"_ustr
), u
"LeftBorder"_ustr
);
772 CPPUNIT_ASSERT_MESSAGE("Border between A3 and B3", (aBorderR
.LineWidth
+ aBorderL
.LineWidth
) > 0);
775 CPPUNIT_TEST_FIXTURE(Test
, testTdf135655
)
777 loadAndSave("tdf135655.odt");
778 const xmlDocUniquePtr pExpDoc
= parseExport(u
"word/document.xml"_ustr
);
779 const OUString sXFillColVal
= getXPath(pExpDoc
, "/w:document/w:body/w:p/w:r/w:object/v:shape", "fillcolor");
780 CPPUNIT_ASSERT_EQUAL(u
"#00A933"_ustr
, sXFillColVal
);
783 CPPUNIT_TEST_FIXTURE(Test
, testTdf138374
)
785 loadAndSave("tdf138374.odt");
786 xmlDocUniquePtr pXmlDocument
= parseExport(u
"word/document.xml"_ustr
);
787 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[2]/w:r/w:pict/v:shape", "fillcolor", u
"#ffd320");
788 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[2]/w:r/w:pict/v:shape", "coordsize", u
"1315,6116");
790 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[2]/w:r/w:pict/v:shape", "path",
791 u
"m0,0l1314,0l1314,5914l416,5914l416,6115l106,5715l416,5415l416,5715l1014,5715l1014,224l0,224l0,16l0,0e");
792 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[2]/w:r/w:pict/v:shape", "style",
793 u
"position:absolute;margin-left:394.3pt;margin-top:204pt;width:37.2pt;height:173.3pt;mso-wrap-style:none;v-text-anchor:middle");
796 DECLARE_OOXMLEXPORT_TEST(testTdf134609_gridAfter
, "tdf134609_gridAfter.docx")
798 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
799 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
800 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
802 // Table borders (width 159) apply to edge cells, even in uneven cases caused by gridBefore/gridAfter,
803 table::BorderLine2 aBorder
= getProperty
<table::BorderLine2
>(xTable
->getCellByName(u
"A1"_ustr
), u
"RightBorder"_ustr
);
804 CPPUNIT_ASSERT_MESSAGE("Right border before gridAfter cells", aBorder
.LineWidth
> 0);
805 aBorder
= getProperty
<table::BorderLine2
>(xTable
->getCellByName(u
"E2"_ustr
), u
"LeftBorder"_ustr
);
806 CPPUNIT_ASSERT_MESSAGE("Left edge border after gridBefore cells", aBorder
.LineWidth
> 100);
807 aBorder
= getProperty
<table::BorderLine2
>(xTable
->getCellByName(u
"E2"_ustr
), u
"TopBorder"_ustr
);
808 // but only for left/right borders, not top and bottom.
809 // So somewhat inconsistently, gridBefore/After affects outside edges of columns, but not of rows.
810 // insideH borders are width 53. (no insideV borders defined to emphasize missing edge borders)
811 CPPUNIT_ASSERT_MESSAGE("Top border on 'inside' cell", aBorder
.LineWidth
> 0);
812 CPPUNIT_ASSERT_MESSAGE("Top border is not an edge border", aBorder
.LineWidth
< 100);
815 CPPUNIT_TEST_FIXTURE(Test
, testTdf135329_lostImage
)
817 loadAndReload("tdf135329_lostImage.odt");
818 // the character-anchored image was being skipped, since searchNext didn't notice it.
819 uno::Reference
<beans::XPropertySet
> xImageProps(getShape(2), uno::UNO_QUERY_THROW
);
822 CPPUNIT_TEST_FIXTURE(Test
, testTdf136441_commentInFootnote
)
824 loadAndReload("tdf136441_commentInFootnote.odt");
825 // failed to load without error if footnote contained a comment.
826 // (MS Word's UI doesn't allow adding comments to a footnote.)
829 CPPUNIT_TEST_FIXTURE(Test
, testTdf137683_charHighlightTests
)
831 auto verify
= [this]() {
832 uno::Reference
<beans::XPropertySet
> xRun(getRun(getParagraph(10), 2, u
"no highlight"_ustr
), uno::UNO_QUERY_THROW
);
833 // This test was failing with a cyan charHighlight of 65535 (0x00FFFF), instead of COL_TRANSPARENT (0xFFFFFFFF)
834 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(COL_AUTO
), getProperty
<sal_Int32
>(xRun
, u
"CharHighlight"_ustr
));
837 // Don't export unnecessary w:highlight="none" (Unnecessary one intentionally hand-added to original .docx)
838 createSwDoc("tdf137683_charHighlightTests.docx");
840 saveAndReload(mpFilter
);
843 xmlDocUniquePtr pXmlStyles
= parseExport(u
"word/styles.xml"_ustr
);
844 assertXPath(pXmlStyles
, "/w:styles/w:style[@w:styleId='Normal']/w:rPr/w:highlight", 0);
847 DECLARE_OOXMLEXPORT_TEST(testTdf138345_charStyleHighlight
, "tdf138345_charStyleHighlight.docx")
849 // MS Word ignores the w:highlight setting in character styles. So shall we.
850 // Without the fix, there would be an orange or yellow background on some words.
851 const uno::Reference
<beans::XPropertySet
> xRun(getRun(getParagraph(1), 2, u
"orange background"_ustr
), uno::UNO_QUERY
);
852 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(COL_TRANSPARENT
), getProperty
<sal_Int32
>(xRun
,u
"CharHighlight"_ustr
));
853 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(COL_TRANSPARENT
), getProperty
<sal_Int32
>(xRun
,u
"CharBackColor"_ustr
));
856 CPPUNIT_TEST_FIXTURE(Test
, testTdf125268
)
858 loadAndReload("tdf125268.odt");
859 CPPUNIT_ASSERT_EQUAL(1, getPages());
860 const uno::Reference
<beans::XPropertySet
> xRun(getRun(getParagraph(1), 1, u
"Hello"_ustr
), uno::UNO_QUERY
);
861 // Without the fix in place, this test would have failed with
864 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(COL_TRANSPARENT
), getProperty
<sal_Int32
>(xRun
,u
"CharHighlight"_ustr
));
865 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(COL_BLACK
), getProperty
<sal_Int32
>(xRun
,u
"CharBackColor"_ustr
));
868 CPPUNIT_TEST_FIXTURE(Test
, testTdf138345_numberingHighlight
)
870 loadAndSave("tdf138345_numberingHighlight.docx");
871 // Before the fix, the highlight was completely lost.
872 xmlDocUniquePtr pXmlStyles
= parseExport(u
"word/numbering.xml"_ustr
);
874 assertXPath(pXmlStyles
, "/w:numbering/w:abstractNum[@w:abstractNumId='1']/w:lvl[@w:ilvl='0']/w:rPr/w:highlight", "val", u
"red");
877 DECLARE_OOXMLEXPORT_TEST(testTdf134063
, "tdf134063.docx")
879 CPPUNIT_ASSERT_EQUAL(2, getPages());
881 xmlDocUniquePtr pDump
= parseLayoutDump();
883 // There are three tabs with default width
884 CPPUNIT_ASSERT_EQUAL(sal_Int32(720), getXPath(pDump
, "//page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFixPortion[1]", "width").toInt32());
885 CPPUNIT_ASSERT_EQUAL(sal_Int32(720), getXPath(pDump
, "//page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFixPortion[2]", "width").toInt32());
886 CPPUNIT_ASSERT_EQUAL(sal_Int32(720), getXPath(pDump
, "//page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFixPortion[3]", "width").toInt32());
889 DECLARE_OOXMLEXPORT_TEST(TestTdf135653
, "tdf135653.docx")
891 uno::Reference
<beans::XPropertySet
> xOLEProps(getShape(1), uno::UNO_QUERY_THROW
);
892 drawing::FillStyle nFillStyle
= static_cast<drawing::FillStyle
>(-1);
893 xOLEProps
->getPropertyValue(u
"FillStyle"_ustr
) >>= nFillStyle
;
894 Color
aFillColor(COL_AUTO
);
895 xOLEProps
->getPropertyValue(u
"FillColor"_ustr
) >>= aFillColor
;
897 CPPUNIT_ASSERT_EQUAL_MESSAGE("Fill style setting does not match!",
898 drawing::FillStyle::FillStyle_SOLID
, nFillStyle
);
899 Color aExpectedColor
;
900 aExpectedColor
.SetRed(255);
901 aExpectedColor
.SetGreen(0);
902 aExpectedColor
.SetBlue(0);
903 CPPUNIT_ASSERT_EQUAL_MESSAGE("OLE bg color does not match!", aExpectedColor
, aFillColor
);
906 DECLARE_OOXMLEXPORT_TEST(testTdf135665
, "tdf135665.docx")
908 uno::Reference
<beans::XPropertySet
> xOLEProps1(getShape(1), uno::UNO_QUERY_THROW
);
909 uno::Reference
<beans::XPropertySet
> xOLEProps2(getShape(2), uno::UNO_QUERY_THROW
);
910 bool bSurroundContour1
= false;
911 bool bSurroundContour2
= false;
912 xOLEProps1
->getPropertyValue(u
"SurroundContour"_ustr
) >>= bSurroundContour1
;
913 xOLEProps2
->getPropertyValue(u
"SurroundContour"_ustr
) >>= bSurroundContour2
;
915 CPPUNIT_ASSERT_EQUAL_MESSAGE("OLE tight wrap setting not imported correctly", true, bSurroundContour1
);
916 CPPUNIT_ASSERT_EQUAL_MESSAGE("OLE tight wrap setting not imported correctly", false, bSurroundContour2
);
919 CPPUNIT_TEST_FIXTURE(Test
, testAtPageShapeRelOrientation
)
921 loadAndSave("rotated_shape.fodt");
922 // invalid combination of at-page anchor and horizontal-rel="paragraph"
923 // caused relativeFrom="column" instead of relativeFrom="page"
925 xmlDocUniquePtr pXmlDocument
= parseExport(u
"word/document.xml"_ustr
);
927 assertXPathContent(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor"
928 "/wp:positionH/wp:posOffset", u
"-480060");
929 assertXPath(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor"
930 "/wp:positionH", "relativeFrom", u
"page");
931 assertXPathContent(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor"
932 "/wp:positionV/wp:posOffset", u
"8147685");
933 assertXPath(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor"
934 "/wp:positionV", "relativeFrom", u
"page");
937 assertXPathContent(pXmlDocument
, "/w:document/w:body/w:p/w:r/w:drawing/wp:anchor"
938 "/wp:positionH/wp:posOffset", u
"720090");
939 assertXPath(pXmlDocument
, "/w:document/w:body/w:p/w:r/w:drawing/wp:anchor"
940 "/wp:positionH", "relativeFrom", u
"page");
941 assertXPathContent(pXmlDocument
, "/w:document/w:body/w:p/w:r/w:drawing/wp:anchor"
942 "/wp:positionV/wp:posOffset", u
"1080135");
943 assertXPath(pXmlDocument
, "/w:document/w:body/w:p/w:r/w:drawing/wp:anchor"
944 "/wp:positionV", "relativeFrom", u
"page");
946 // now test text rotation -> VML writing direction
947 assertXPath(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Fallback/w:pict/v:shape/v:textbox", "style", u
"mso-layout-flow-alt:bottom-to-top");
949 assertXPath(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Fallback/w:pict/v:shape/w10:wrap", "type", u
"none");
950 // vertical alignment -> VML
951 OUString
const style
= getXPath(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Fallback/w:pict/v:shape", "style");
952 CPPUNIT_ASSERT(style
.indexOf("v-text-anchor:middle") != -1);
955 CPPUNIT_TEST_FIXTURE(Test
, testVMLallowincell
)
957 loadAndSave("shape-atpage-in-table.fodt");
958 xmlDocUniquePtr pXmlDocument
= parseExport(u
"word/document.xml"_ustr
);
960 // VML o:allowincell, apparently the default is "t"
961 assertXPath(pXmlDocument
, "/w:document/w:body/w:tbl[1]/w:tr[1]/w:tc[1]/w:p[1]/w:r/mc:AlternateContent[1]/mc:Fallback/w:pict/v:shape", "allowincell", u
"f");
964 assertXPath(pXmlDocument
, "/w:document/w:body/w:tbl[1]/w:tr[1]/w:tc[1]/w:p[1]/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor", "layoutInCell", u
"0");
967 CPPUNIT_TEST_FIXTURE(Test
, testRelativeAnchorHeightFromBottomMarginHasFooter
)
969 loadAndSave("tdf133070_testRelativeAnchorHeightFromBottomMarginHasFooter.docx");
970 // tdf#133070 The height was set relative to page print area bottom,
971 // but this was handled relative to page height.
972 // Note: page print area bottom = margin + footer height.
973 // In this case the footer exists.
974 xmlDocUniquePtr pXmlDoc
= parseLayoutDump();
975 assertXPath(pXmlDoc
, "//anchored/SwAnchoredDrawObject/bounds", "height", u
"1147");
978 DECLARE_OOXMLEXPORT_TEST(TestTdf132483
, "tdf132483.docx")
980 uno::Reference
<beans::XPropertySet
> xOLEProps(getShape(1), uno::UNO_QUERY_THROW
);
981 sal_Int16 nVRelPos
= -1;
982 sal_Int16 nHRelPos
= -1;
983 xOLEProps
->getPropertyValue(u
"VertOrientRelation"_ustr
) >>= nVRelPos
;
984 xOLEProps
->getPropertyValue(u
"HoriOrientRelation"_ustr
) >>= nHRelPos
;
985 CPPUNIT_ASSERT_EQUAL_MESSAGE("The OLE is shifted vertically",
986 text::RelOrientation::PAGE_FRAME
, nVRelPos
);
987 CPPUNIT_ASSERT_EQUAL_MESSAGE("The OLE is shifted horizontally",
988 text::RelOrientation::PAGE_FRAME
, nHRelPos
);
991 CPPUNIT_TEST_FIXTURE(Test
, TestTdf143028
)
993 loadAndSave("fail_bracePair.odt");
994 CPPUNIT_ASSERT_EQUAL(1, getShapes());
995 CPPUNIT_ASSERT_EQUAL(1, getPages());
996 auto pExportXml
= parseExport(u
"word/document.xml"_ustr
);
998 assertXPath(pExportXml
, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/"
999 "a:graphic/a:graphicData/wps:wsp/wps:spPr/a:xfrm");
1003 CPPUNIT_TEST_FIXTURE(Test
, testRelativeAnchorHeightFromBottomMarginNoFooter
)
1005 loadAndSave("tdf133070_testRelativeAnchorHeightFromBottomMarginNoFooter.docx");
1006 // tdf#133070 The height was set relative to page print area bottom,
1007 // but this was handled relative to page height.
1008 // Note: page print area bottom = margin + footer height.
1009 // In this case the footer does not exist, so OpenDocument and OOXML margins are the same.
1010 xmlDocUniquePtr pXmlDoc
= parseLayoutDump();
1011 assertXPath(pXmlDoc
, "//anchored/SwAnchoredDrawObject/bounds", "height", u
"1147");
1014 CPPUNIT_TEST_FIXTURE(Test
, testTdf133702
)
1016 loadAndSave("tdf133702.docx");
1017 xmlDocUniquePtr pXmlDocument
= parseExport(u
"word/document.xml"_ustr
);
1018 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:pPr/w:framePr");
1021 CPPUNIT_TEST_FIXTURE(Test
, testTdf135667
)
1023 loadAndSave("tdf135667.odt");
1024 xmlDocUniquePtr pXmlDocument
= parseExport(u
"word/document.xml"_ustr
);
1026 // This was missing.
1027 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[2]/w:r/w:object/v:shapetype");
1030 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[2]/w:r/w:object/v:shape", "stroked", u
"t");
1031 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[2]/w:r/w:object/v:shape", "strokecolor", u
"#FF0000");
1032 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[2]/w:r/w:object/v:shape", "strokeweight", u
"4pt");
1035 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[2]/w:r/w:object/v:shape/v:stroke", "linestyle", u
"Single");
1036 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[2]/w:r/w:object/v:shape/v:stroke", "dashstyle", u
"Dash");
1039 CPPUNIT_TEST_FIXTURE(Test
, testImageSpaceSettings
)
1041 loadAndSave("tdf135047_ImageSpaceSettings.fodt");
1042 // tdf#135047 The spaces of image were not saved.
1043 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/document.xml"_ustr
);
1044 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[1]/w:drawing/wp:anchor", "distT", u
"90170");
1045 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[1]/w:drawing/wp:anchor", "distB", u
"90170");
1046 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[1]/w:drawing/wp:anchor", "distL", u
"90170");
1047 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[1]/w:drawing/wp:anchor", "distR", u
"90170");
1050 CPPUNIT_TEST_FIXTURE(Test
, testTdf137295
)
1052 loadAndReload("tdf137295.doc");
1053 CPPUNIT_ASSERT_EQUAL(1, getPages());
1055 // Without the fix in place, the test would have failed with
1058 CPPUNIT_ASSERT_EQUAL(2, getShapes());
1061 DECLARE_OOXMLEXPORT_TEST(testTdf135660
, "tdf135660.docx")
1063 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1064 const uno::Reference
<drawing::XShape
> xShape
= getShape(1);
1065 const uno::Reference
<beans::XPropertySet
> xOLEProps(xShape
, uno::UNO_QUERY_THROW
);
1066 sal_Int32 nWrapDistanceLeft
= -1;
1067 sal_Int32 nWrapDistanceRight
= -1;
1068 sal_Int32 nWrapDistanceTop
= -1;
1069 sal_Int32 nWrapDistanceBottom
= -1;
1070 xOLEProps
->getPropertyValue(u
"LeftMargin"_ustr
) >>= nWrapDistanceLeft
;
1071 xOLEProps
->getPropertyValue(u
"RightMargin"_ustr
) >>= nWrapDistanceRight
;
1072 xOLEProps
->getPropertyValue(u
"TopMargin"_ustr
) >>= nWrapDistanceTop
;
1073 xOLEProps
->getPropertyValue(u
"BottomMargin"_ustr
) >>= nWrapDistanceBottom
;
1074 CPPUNIT_ASSERT_EQUAL_MESSAGE("Left wrap distance is wrong", static_cast<sal_Int32
>(0), nWrapDistanceLeft
);
1075 CPPUNIT_ASSERT_EQUAL_MESSAGE("Right wrap distance is wrong", static_cast<sal_Int32
>(400), nWrapDistanceRight
);
1076 CPPUNIT_ASSERT_EQUAL_MESSAGE("Top wrap distance is wrong", static_cast<sal_Int32
>(300), nWrapDistanceTop
);
1077 CPPUNIT_ASSERT_EQUAL_MESSAGE("Bottom wrap distance is wrong", static_cast<sal_Int32
>(199), nWrapDistanceBottom
);
1080 CPPUNIT_TEST_FIXTURE(Test
, testTdf136814
)
1082 loadAndSave("tdf136814.odt");
1083 xmlDocUniquePtr pXmlDocument
= parseExport(u
"word/document.xml"_ustr
);
1085 // Padding in this document is 0.10 cm which should translate to 3 pt (approx. 1.0583mm)
1086 assertXPath(pXmlDocument
, "/w:document/w:body/w:sectPr/w:pgBorders/w:top", "space", u
"3");
1087 assertXPath(pXmlDocument
, "/w:document/w:body/w:sectPr/w:pgBorders/w:left", "space", u
"3");
1088 assertXPath(pXmlDocument
, "/w:document/w:body/w:sectPr/w:pgBorders/w:bottom", "space", u
"3");
1089 assertXPath(pXmlDocument
, "/w:document/w:body/w:sectPr/w:pgBorders/w:right", "space", u
"3");
1092 CPPUNIT_PLUGIN_IMPLEMENT();
1094 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */