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("/sw/qa/extras/ooxmlexport/data/", "Office Open XML Text") {}
30 CPPUNIT_TEST_FIXTURE(Test
, testTdf123621
)
32 loadAndSave("tdf123621.docx");
33 xmlDocUniquePtr pXmlDocument
= parseExport("word/document.xml");
35 assertXPathContent(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor"
36 "/wp:positionV/wp:posOffset", "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), "HoriOrientRelation"));
47 CPPUNIT_ASSERT_EQUAL_MESSAGE("The shape2 moved on saving!", text::RelOrientation::PAGE_FRAME
,
48 getProperty
<sal_Int16
>(getShape(2), "HoriOrientRelation"));
51 DECLARE_OOXMLEXPORT_TEST(testTdf131801
, "tdf131801.docx")
53 CPPUNIT_ASSERT_EQUAL(1, getPages());
55 xmlDocUniquePtr pDump
= parseLayoutDump();
57 CPPUNIT_ASSERT_EQUAL(OUString("1."), getXPath(pDump
, "//page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion", "expand"));
58 CPPUNIT_ASSERT_EQUAL(OUString("00ff0000"), getXPath(pDump
, "//page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion/SwFont", "color"));
60 CPPUNIT_ASSERT_EQUAL(OUString("2."), getXPath(pDump
, "//page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwFieldPortion", "expand"));
61 CPPUNIT_ASSERT_EQUAL(OUString("00ff0000"), getXPath(pDump
, "//page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwFieldPortion/SwFont", "color"));
63 CPPUNIT_ASSERT_EQUAL(OUString("3."), getXPath(pDump
, "//page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwFieldPortion", "expand"));
64 CPPUNIT_ASSERT_EQUAL(OUString("ffffffff"), getXPath(pDump
, "//page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwFieldPortion/SwFont", "color"));
66 CPPUNIT_ASSERT_EQUAL(OUString("4."), getXPath(pDump
, "//page[1]/body/txt[4]/SwParaPortion/SwLineLayout/SwFieldPortion", "expand"));
67 CPPUNIT_ASSERT_EQUAL(OUString("ffffffff"), getXPath(pDump
, "//page[1]/body/txt[4]/SwParaPortion/SwLineLayout/SwFieldPortion/SwFont", "color"));
69 CPPUNIT_ASSERT_EQUAL(OUString("5."), getXPath(pDump
, "//page[1]/body/txt[5]/SwParaPortion/SwLineLayout/SwFieldPortion", "expand"));
70 CPPUNIT_ASSERT_EQUAL(OUString("00ff0000"), getXPath(pDump
, "//page[1]/body/txt[5]/SwParaPortion/SwLineLayout/SwFieldPortion/SwFont", "color"));
72 CPPUNIT_ASSERT_EQUAL(OUString("6."), getXPath(pDump
, "//page[1]/body/txt[6]/SwParaPortion/SwLineLayout/SwFieldPortion", "expand"));
73 CPPUNIT_ASSERT_EQUAL(OUString("00ff0000"), getXPath(pDump
, "//page[1]/body/txt[6]/SwParaPortion/SwLineLayout/SwFieldPortion/SwFont", "color"));
75 CPPUNIT_ASSERT_EQUAL(OUString("7."), getXPath(pDump
, "//page[1]/body/txt[7]/SwParaPortion/SwLineLayout/SwFieldPortion", "expand"));
76 CPPUNIT_ASSERT_EQUAL(OUString("ffffffff"), getXPath(pDump
, "//page[1]/body/txt[7]/SwParaPortion/SwLineLayout/SwFieldPortion/SwFont", "color"));
78 CPPUNIT_ASSERT_EQUAL(OUString("8."), getXPath(pDump
, "//page[1]/body/txt[8]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", "expand"));
79 CPPUNIT_ASSERT_EQUAL(OUString("ffffffff"), getXPath(pDump
, "//page[1]/body/txt[8]/SwParaPortion/SwLineLayout/SwFieldPortion[1]/SwFont", "color"));
83 xmlDocUniquePtr pXmlDocument
= parseExport("word/document.xml");
85 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:pPr/w:rPr/w:rStyle",
87 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[2]/w:pPr/w:rPr/w:rStyle",
89 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[3]/w:pPr/w:rPr/w:rStyle", 0);
90 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[4]/w:pPr/w:rPr/w:rStyle", 0);
91 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[5]/w:pPr/w:rPr/w:rStyle",
93 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[5]/w:pPr/w:rPr/w:sz",
95 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[6]/w:pPr/w:rPr/w:rStyle",
97 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[6]/w:pPr/w:rPr/w:sz",
99 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[7]/w:pPr/w:rPr/w:rStyle", 0);
100 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[8]/w:pPr/w:rPr/w:rStyle", 0);
103 CPPUNIT_TEST_FIXTURE(Test
, testTdf133334_followPgStyle
)
105 loadAndReload("tdf133334_followPgStyle.odt");
106 CPPUNIT_ASSERT_EQUAL(2, getPages());
109 DECLARE_OOXMLEXPORT_TEST(testTdf137850_compat14ZOrder
, "tdf137850_compat14ZOrder.docx")
111 // The file contains 2 shapes which have a different value of behindDoc.
112 // Test that the textbox is hidden behind the arrow (for Word <= 2010/compatibilityMode==14)
113 uno::Reference
<text::XText
> xShape(getShape(2), uno::UNO_QUERY
);
114 CPPUNIT_ASSERT_EQUAL(OUString("2015"), xShape
->getString());
115 CPPUNIT_ASSERT_EQUAL_MESSAGE("Textbox is in the background", false, getProperty
<bool>(xShape
, "Opaque"));
118 DECLARE_OOXMLEXPORT_TEST(testTdf137850_compat15ZOrder
, "tdf137850_compat15ZOrder.docx")
120 // The file contains 2 shapes which have a different value of behindDoc.
121 // Test that the textbox is not hidden behind the arrow (for Word >= 2013/compatibilityMode==15)
122 uno::Reference
<text::XText
> xShape(getShape(2), uno::UNO_QUERY
);
123 CPPUNIT_ASSERT_EQUAL(OUString("2015"), xShape
->getString());
124 CPPUNIT_ASSERT_EQUAL_MESSAGE("Textbox is in the foreground", true, getProperty
<bool>(xShape
, "Opaque"));
127 CPPUNIT_TEST_FIXTURE(Test
, testTdf118701
)
129 loadAndSave("tdf118701.docx");
130 // This was 6, related to moving inline images after the page breaks
131 CPPUNIT_ASSERT_EQUAL(4, getPages());
133 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
135 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:pPr[1]/w:numPr", 0);
136 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[2]/w:pPr[1]/w:numPr", 0);
137 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[3]/w:pPr[1]/w:numPr", 0);
138 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[4]/w:pPr[1]/w:numPr", 1);
140 // Keep numbering of the paragraph of the inline image
141 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[8]/w:pPr[1]/w:numPr", 0);
142 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[9]/w:pPr[1]/w:numPr", 1);
144 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[10]/w:pPr[1]/w:numPr", 1);
147 DECLARE_OOXMLEXPORT_TEST(testTdf123388
, "tdf123388.docx")
149 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
150 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
151 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
153 // Tests new cell formula PRODUCT
154 uno::Reference
<text::XTextField
> xEnumerationAccess1(xFields
->nextElement(), uno::UNO_QUERY
);
155 CPPUNIT_ASSERT_EQUAL(OUString("PRODUCT(<B2:B3>)"), xEnumerationAccess1
->getPresentation(true).trim());
156 CPPUNIT_ASSERT_EQUAL(OUString("640"), xEnumerationAccess1
->getPresentation(false).trim());
159 DECLARE_OOXMLEXPORT_TEST(testTdf123381
, "tdf123381.docx")
161 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
162 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
163 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
165 uno::Reference
<text::XTextField
> xEnumerationAccess1(xFields
->nextElement(), uno::UNO_QUERY
);
166 CPPUNIT_ASSERT_EQUAL(OUString("INT(5.65)"), xEnumerationAccess1
->getPresentation(true).trim());
167 CPPUNIT_ASSERT_EQUAL(OUString("5"), xEnumerationAccess1
->getPresentation(false).trim());
169 uno::Reference
<text::XTextField
> xEnumerationAccess2(xFields
->nextElement(), uno::UNO_QUERY
);
170 CPPUNIT_ASSERT_EQUAL(OUString("INT(<A1>)"), xEnumerationAccess2
->getPresentation(true).trim());
171 CPPUNIT_ASSERT_EQUAL(OUString("6"), xEnumerationAccess2
->getPresentation(false).trim());
174 CPPUNIT_TEST_FIXTURE(Test
, testTdf123401
)
176 loadAndReload("tdf123401.fodt");
177 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
178 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
179 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
181 // Tests new cell formula AVERAGE
182 uno::Reference
<text::XTextField
> xEnumerationAccess1(xFields
->nextElement(), uno::UNO_QUERY
);
183 CPPUNIT_ASSERT_EQUAL(OUString("AVERAGE(<A1:A2>)"), xEnumerationAccess1
->getPresentation(true).trim());
184 CPPUNIT_ASSERT_EQUAL(OUString("3"), xEnumerationAccess1
->getPresentation(false).trim());
186 uno::Reference
<text::XTextField
> xEnumerationAccess2(xFields
->nextElement(), uno::UNO_QUERY
);
187 CPPUNIT_ASSERT_EQUAL(OUString("AVERAGE(<A1:A3>)"), xEnumerationAccess2
->getPresentation(true).trim());
188 CPPUNIT_ASSERT_EQUAL(OUString("3"), xEnumerationAccess2
->getPresentation(false).trim());
190 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
192 // MEAN converted to AVERAGE
193 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:p/w:r[2]/w:instrText", " =AVERAGE(A1:A2)");
194 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[4]/w:tc/w:p/w:r[2]/w:instrText", " =AVERAGE(A1:A3)");
197 DECLARE_OOXMLEXPORT_TEST(testTdf116394
, "tdf116394.docx")
199 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
200 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
201 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
203 uno::Reference
<text::XTextField
> xEnumerationAccess(xFields
->nextElement(), uno::UNO_QUERY
);
205 // Without the fix in place, this test would have failed with
206 // - Expected: ab=cd..
208 CPPUNIT_ASSERT_EQUAL(OUString("ab=cd.."), xEnumerationAccess
->getPresentation(true).trim());
212 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
213 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:p/w:r[2]/w:instrText", " MERGEFIELD ab=cd ");
216 CPPUNIT_TEST_FIXTURE(Test
, testTdf123356
)
218 loadAndReload("tdf123356.fodt");
219 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
220 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
221 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
223 // Tests new cell formula COUNT
224 uno::Reference
<text::XTextField
> xEnumerationAccess1(xFields
->nextElement(), uno::UNO_QUERY
);
225 CPPUNIT_ASSERT_EQUAL(OUString("COUNT(<A1>)"), xEnumerationAccess1
->getPresentation(true).trim());
226 CPPUNIT_ASSERT_EQUAL(OUString("1"), xEnumerationAccess1
->getPresentation(false).trim());
228 uno::Reference
<text::XTextField
> xEnumerationAccess2(xFields
->nextElement(), uno::UNO_QUERY
);
229 CPPUNIT_ASSERT_EQUAL(OUString("COUNT(<A1:B2>)"), xEnumerationAccess2
->getPresentation(true).trim());
230 CPPUNIT_ASSERT_EQUAL(OUString("4"), xEnumerationAccess2
->getPresentation(false).trim());
233 CPPUNIT_TEST_FIXTURE(Test
, testTdf136404
)
235 loadAndReload("tdf136404.fodt");
236 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
237 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
238 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
240 // Ignore empty cells or cells with text content with new interoperability functions COUNT, AVERAGE and PRODUCT
241 uno::Reference
<text::XTextField
> xEnumerationAccess1(xFields
->nextElement(), uno::UNO_QUERY
);
242 CPPUNIT_ASSERT_EQUAL(OUString("COUNT(<A1:F1>)"), xEnumerationAccess1
->getPresentation(true).trim());
243 CPPUNIT_ASSERT_EQUAL(OUString("2"), xEnumerationAccess1
->getPresentation(false).trim());
245 uno::Reference
<text::XTextField
> xEnumerationAccess2(xFields
->nextElement(), uno::UNO_QUERY
);
246 CPPUNIT_ASSERT_EQUAL(OUString("AVERAGE(<B1:C1>)"), xEnumerationAccess2
->getPresentation(true).trim());
248 CPPUNIT_ASSERT_EQUAL(OUString("** Expression is faulty **"), xEnumerationAccess2
->getPresentation(false).trim());
250 uno::Reference
<text::XTextField
> xEnumerationAccess3(xFields
->nextElement(), uno::UNO_QUERY
);
251 CPPUNIT_ASSERT_EQUAL(OUString("AVERAGE(<B1>)"), xEnumerationAccess3
->getPresentation(true).trim());
253 CPPUNIT_ASSERT_EQUAL(OUString("** Expression is faulty **"), xEnumerationAccess3
->getPresentation(false).trim());
255 uno::Reference
<text::XTextField
> xEnumerationAccess4(xFields
->nextElement(), uno::UNO_QUERY
);
256 CPPUNIT_ASSERT_EQUAL(OUString("COUNT(<B1:C1>)"), xEnumerationAccess4
->getPresentation(true).trim());
258 CPPUNIT_ASSERT_EQUAL(OUString("0"), xEnumerationAccess4
->getPresentation(false).trim());
260 uno::Reference
<text::XTextField
> xEnumerationAccess5(xFields
->nextElement(), uno::UNO_QUERY
);
261 CPPUNIT_ASSERT_EQUAL(OUString("COUNT(<B1>)"), xEnumerationAccess5
->getPresentation(true).trim());
263 CPPUNIT_ASSERT_EQUAL(OUString("0"), xEnumerationAccess5
->getPresentation(false).trim());
265 uno::Reference
<text::XTextField
> xEnumerationAccess6(xFields
->nextElement(), uno::UNO_QUERY
);
266 CPPUNIT_ASSERT_EQUAL(OUString("PRODUCT(<A1:F1>)"), xEnumerationAccess6
->getPresentation(true).trim());
268 CPPUNIT_ASSERT_EQUAL(OUString("60"), xEnumerationAccess6
->getPresentation(false).trim());
270 uno::Reference
<text::XTextField
> xEnumerationAccess7(xFields
->nextElement(), uno::UNO_QUERY
);
271 CPPUNIT_ASSERT_EQUAL(OUString("AVERAGE(<A1:F1>)"), xEnumerationAccess7
->getPresentation(true).trim());
273 CPPUNIT_ASSERT_EQUAL(OUString("8"), xEnumerationAccess7
->getPresentation(false).trim());
276 DECLARE_OOXMLEXPORT_TEST(testTdf138739
, "tdf138739.docx")
278 uno::Reference
<beans::XPropertySet
> xParaProps(getParagraph(1), uno::UNO_QUERY
);
279 CPPUNIT_ASSERT_EQUAL_MESSAGE("Font type name does not match!", OUString("Comic Sans MS"),
280 xParaProps
->getPropertyValue("CharFontName").get
<OUString
>());
282 // tdf#148565: text at anchor point should be bold, Comic Sans MS font
283 CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD
, getProperty
<float>(getRun(getParagraph(5), 3), "CharWeight"));
286 CPPUNIT_TEST_FIXTURE(Test
, testTdf123390
)
288 loadAndReload("tdf123390.fodt");
289 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
290 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
291 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
293 // Tests new cell formula SIGN
294 uno::Reference
<text::XTextField
> xEnumerationAccess1(xFields
->nextElement(), uno::UNO_QUERY
);
295 CPPUNIT_ASSERT_EQUAL(OUString("SIGN(<A1>)"), xEnumerationAccess1
->getPresentation(true).trim());
296 CPPUNIT_ASSERT_EQUAL(OUString("-1"), xEnumerationAccess1
->getPresentation(false).trim());
298 uno::Reference
<text::XTextField
> xEnumerationAccess2(xFields
->nextElement(), uno::UNO_QUERY
);
299 CPPUNIT_ASSERT_EQUAL(OUString("SIGN(<C1>)"), xEnumerationAccess2
->getPresentation(true).trim());
300 CPPUNIT_ASSERT_EQUAL(OUString("1"), xEnumerationAccess2
->getPresentation(false).trim());
302 uno::Reference
<text::XTextField
> xEnumerationAccess3(xFields
->nextElement(), uno::UNO_QUERY
);
303 CPPUNIT_ASSERT_EQUAL(OUString("SIGN(<B1>)"), xEnumerationAccess3
->getPresentation(true).trim());
304 CPPUNIT_ASSERT_EQUAL(OUString("0"), xEnumerationAccess3
->getPresentation(false).trim());
307 CPPUNIT_TEST_FIXTURE(Test
, testTdf123354
)
309 loadAndReload("tdf123354.fodt");
310 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
311 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
312 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
314 // Tests new cell formula SIGN
315 uno::Reference
<text::XTextField
> xEnumerationAccess1(xFields
->nextElement(), uno::UNO_QUERY
);
316 CPPUNIT_ASSERT_EQUAL(OUString("ABS(<A1>)"), xEnumerationAccess1
->getPresentation(true).trim());
317 CPPUNIT_ASSERT_EQUAL(OUString("10"), xEnumerationAccess1
->getPresentation(false).trim());
319 uno::Reference
<text::XTextField
> xEnumerationAccess2(xFields
->nextElement(), uno::UNO_QUERY
);
320 CPPUNIT_ASSERT_EQUAL(OUString("ABS(<C1>)"), xEnumerationAccess2
->getPresentation(true).trim());
321 CPPUNIT_ASSERT_EQUAL(OUString("10"), xEnumerationAccess2
->getPresentation(false).trim());
323 uno::Reference
<text::XTextField
> xEnumerationAccess3(xFields
->nextElement(), uno::UNO_QUERY
);
324 CPPUNIT_ASSERT_EQUAL(OUString("ABS(<B1>)"), xEnumerationAccess3
->getPresentation(true).trim());
325 CPPUNIT_ASSERT_EQUAL(OUString("0"), xEnumerationAccess3
->getPresentation(false).trim());
328 DECLARE_OOXMLEXPORT_TEST(testTdf123355
, "tdf123355.docx")
330 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
331 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
332 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
334 // Tests conversion of range IDs ABOVE, BELOW, LEFT and RIGHT
335 uno::Reference
<text::XTextField
> xEnumerationAccess1(xFields
->nextElement(), uno::UNO_QUERY
);
336 // Note: range ends at B4 here, which is a cell with text content
337 CPPUNIT_ASSERT_EQUAL(OUString("average( <B2:B3> )"), xEnumerationAccess1
->getPresentation(true).trim());
338 CPPUNIT_ASSERT_EQUAL(OUString("5,5"), xEnumerationAccess1
->getPresentation(false).trim());
340 // range ends at the end of the empty cells
341 uno::Reference
<text::XTextField
> xEnumerationAccess6(xFields
->nextElement(), uno::UNO_QUERY
);
342 CPPUNIT_ASSERT_EQUAL(OUString("SUM(<C6:A6>)"), xEnumerationAccess6
->getPresentation(true).trim());
343 CPPUNIT_ASSERT_EQUAL(OUString("0"), xEnumerationAccess6
->getPresentation(false).trim());
345 // range starts at the first cell above D5
346 uno::Reference
<text::XTextField
> xEnumerationAccess2(xFields
->nextElement(), uno::UNO_QUERY
);
347 CPPUNIT_ASSERT_EQUAL(OUString("AVERAGE(<D4:D1>)"), xEnumerationAccess2
->getPresentation(true).trim());
348 CPPUNIT_ASSERT_EQUAL(OUString("5,33"), xEnumerationAccess2
->getPresentation(false).trim());
350 uno::Reference
<text::XTextField
> xEnumerationAccess3(xFields
->nextElement(), uno::UNO_QUERY
);
351 CPPUNIT_ASSERT_EQUAL(OUString("AVERAGE(<C2:C1>)"), xEnumerationAccess3
->getPresentation(true).trim());
352 CPPUNIT_ASSERT_EQUAL(OUString("3,5"), xEnumerationAccess3
->getPresentation(false).trim());
354 uno::Reference
<text::XTextField
> xEnumerationAccess4(xFields
->nextElement(), uno::UNO_QUERY
);
355 CPPUNIT_ASSERT_EQUAL(OUString("AVERAGE(<D2:D2>)"), xEnumerationAccess4
->getPresentation(true).trim());
356 CPPUNIT_ASSERT_EQUAL(OUString("5"), xEnumerationAccess4
->getPresentation(false).trim());
358 uno::Reference
<text::XTextField
> xEnumerationAccess5(xFields
->nextElement(), uno::UNO_QUERY
);
359 CPPUNIT_ASSERT_EQUAL(OUString("AVERAGE(<A2:A2>)"), xEnumerationAccess5
->getPresentation(true).trim());
360 CPPUNIT_ASSERT_EQUAL(OUString("4"), xEnumerationAccess5
->getPresentation(false).trim());
364 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
366 // keep original formula IDs
367 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[2]/w:p/w:r[2]/w:instrText", " =average( below )");
368 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[2]/w:p/w:r[2]/w:instrText", " =AVERAGE(LEFT)");
369 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[3]/w:p/w:r[2]/w:instrText", " =AVERAGE(RIGHT)");
370 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[3]/w:tc[3]/w:p/w:r[2]/w:instrText", " =AVERAGE(ABOVE)");
371 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[5]/w:tc[4]/w:p/w:r[2]/w:instrText", " =AVERAGE(ABOVE)");
372 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[6]/w:tc[4]/w:p/w:r[2]/w:instrText", " =SUM(LEFT)");
375 DECLARE_OOXMLEXPORT_TEST(testTdf123382
, "tdf123382.docx")
377 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
378 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
379 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
381 // Tests conversion of range IDs ABOVE, BELOW, LEFT and RIGHT
382 uno::Reference
<text::XTextField
> xEnumerationAccess1(xFields
->nextElement(), uno::UNO_QUERY
);
383 // Note: range ends at B4 here, which is a cell with text content
384 CPPUNIT_ASSERT_EQUAL(OUString("MAX(<B1:D1>)"), xEnumerationAccess1
->getPresentation(true).trim());
385 CPPUNIT_ASSERT_EQUAL(OUString("12"), xEnumerationAccess1
->getPresentation(false).trim());
387 // range ends at the end of the empty cells
388 uno::Reference
<text::XTextField
> xEnumerationAccess6(xFields
->nextElement(), uno::UNO_QUERY
);
389 CPPUNIT_ASSERT_EQUAL(OUString("MAX(<C4:D4>)"), xEnumerationAccess6
->getPresentation(true).trim());
390 CPPUNIT_ASSERT_EQUAL(OUString("9"), xEnumerationAccess6
->getPresentation(false).trim());
392 // range starts at the first cell above D5
393 uno::Reference
<text::XTextField
> xEnumerationAccess2(xFields
->nextElement(), uno::UNO_QUERY
);
394 CPPUNIT_ASSERT_EQUAL(OUString("SUM(<B3:D3>)"), xEnumerationAccess2
->getPresentation(true).trim());
395 CPPUNIT_ASSERT_EQUAL(OUString("30"), xEnumerationAccess2
->getPresentation(false).trim());
397 uno::Reference
<text::XTextField
> xEnumerationAccess3(xFields
->nextElement(), uno::UNO_QUERY
);
398 CPPUNIT_ASSERT_EQUAL(OUString("MAX(<C2:A2>)"), xEnumerationAccess3
->getPresentation(true).trim());
399 CPPUNIT_ASSERT_EQUAL(OUString("7"), xEnumerationAccess3
->getPresentation(false).trim());
401 uno::Reference
<text::XTextField
> xEnumerationAccess4(xFields
->nextElement(), uno::UNO_QUERY
);
402 CPPUNIT_ASSERT_EQUAL(OUString("MAX(<B2:D2>)"), xEnumerationAccess4
->getPresentation(true).trim());
403 CPPUNIT_ASSERT_EQUAL(OUString("7"), xEnumerationAccess4
->getPresentation(false).trim());
405 uno::Reference
<text::XTextField
> xEnumerationAccess5(xFields
->nextElement(), uno::UNO_QUERY
);
406 CPPUNIT_ASSERT_EQUAL(OUString("MAX(<D2:D4>)"), xEnumerationAccess5
->getPresentation(true).trim());
407 CPPUNIT_ASSERT_EQUAL(OUString("12"), xEnumerationAccess5
->getPresentation(false).trim());
409 uno::Reference
<text::XTextField
> xEnumerationAccess7(xFields
->nextElement(), uno::UNO_QUERY
);
410 CPPUNIT_ASSERT_EQUAL(OUString("MAX(<B2:B4>)"), xEnumerationAccess7
->getPresentation(true).trim());
411 CPPUNIT_ASSERT_EQUAL(OUString("10"), xEnumerationAccess7
->getPresentation(false).trim());
415 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
417 // keep original formula IDs
418 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:p/w:r[2]/w:instrText", " =MAX(RIGHT)");
419 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[1]/w:p/w:r[2]/w:instrText", " =MAX(RIGHT)");
420 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[3]/w:tc[1]/w:p/w:r[2]/w:instrText", " =SUM(RIGHT)");
421 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[2]/w:p/w:r[2]/w:instrText", " =MAX(BELOW)");
422 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[4]/w:tc[2]/w:p/w:r[2]/w:instrText", " =MAX(RIGHT)");
423 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[4]/w:p/w:r[2]/w:instrText", " =MAX(BELOW)");
424 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[4]/w:p/w:r[2]/w:instrText", " =MAX(LEFT)");
427 DECLARE_OOXMLEXPORT_TEST(testTdf122648
, "tdf122648.docx")
429 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
430 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
431 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
433 // table formula conversion worked only in the first table
434 uno::Reference
<text::XTextField
> xEnumerationAccess1(xFields
->nextElement(), uno::UNO_QUERY
);
435 CPPUNIT_ASSERT_EQUAL(OUString("<A1>"), xEnumerationAccess1
->getPresentation(true).trim());
436 CPPUNIT_ASSERT_EQUAL(OUString("1"), xEnumerationAccess1
->getPresentation(false).trim());
438 uno::Reference
<text::XTextField
> xEnumerationAccess2(xFields
->nextElement(), uno::UNO_QUERY
);
439 CPPUNIT_ASSERT_EQUAL(OUString("SUM(<A1:B1>)"), xEnumerationAccess2
->getPresentation(true).trim());
440 CPPUNIT_ASSERT_EQUAL(OUString("2"), xEnumerationAccess2
->getPresentation(false).trim());
442 // These were <?> and SUM(<?:?>) with zero values
443 uno::Reference
<text::XTextField
> xEnumerationAccess3(xFields
->nextElement(), uno::UNO_QUERY
);
444 CPPUNIT_ASSERT_EQUAL(OUString("<A1>"), xEnumerationAccess3
->getPresentation(true).trim());
445 CPPUNIT_ASSERT_EQUAL(OUString("1"), xEnumerationAccess3
->getPresentation(false).trim());
447 uno::Reference
<text::XTextField
> xEnumerationAccess4(xFields
->nextElement(), uno::UNO_QUERY
);
448 CPPUNIT_ASSERT_EQUAL(OUString("SUM(<A1:B1>)"), xEnumerationAccess4
->getPresentation(true).trim());
449 CPPUNIT_ASSERT_EQUAL(OUString("2"), xEnumerationAccess4
->getPresentation(false).trim());
453 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
455 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl[1]/w:tr[1]/w:tc[2]/w:p/w:r[2]/w:instrText", " =A1");
456 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl[1]/w:tr[2]/w:tc[2]/w:p/w:r[2]/w:instrText", " =SUM(A1:B1)");
457 // These were =<?> and =SUM(<?:?>)
458 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl[2]/w:tr[1]/w:tc[2]/w:p/w:r[2]/w:instrText", " =A1");
459 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl[2]/w:tr[2]/w:tc[2]/w:p/w:r[2]/w:instrText", " =SUM(A1:B1)");
462 CPPUNIT_TEST_FIXTURE(Test
, testTdf98000_changePageStyle
)
464 loadAndReload("tdf98000_changePageStyle.odt");
465 uno::Reference
<frame::XModel
> xModel(mxComponent
, uno::UNO_QUERY
);
466 uno::Reference
<text::XTextViewCursorSupplier
> xTextViewCursorSupplier(xModel
->getCurrentController(), uno::UNO_QUERY
);
468 uno::Reference
<text::XPageCursor
> xCursor(xTextViewCursorSupplier
->getViewCursor(), uno::UNO_QUERY_THROW
);
469 OUString sPageOneStyle
= getProperty
<OUString
>( xCursor
, "PageStyleName" );
471 xCursor
->jumpToNextPage();
472 OUString sPageTwoStyle
= getProperty
<OUString
>( xCursor
, "PageStyleName" );
473 CPPUNIT_ASSERT_MESSAGE("Different page1/page2 styles", sPageOneStyle
!= sPageTwoStyle
);
476 CPPUNIT_TEST_FIXTURE(Test
, testTdf145998_unnecessaryPageStyles
)
478 loadAndReload("tdf145998_unnecessaryPageStyles.odt");
480 // Sanity check - always good to test when dealing with page styles and breaks.
481 CPPUNIT_ASSERT_EQUAL(5, getPages());
483 // Page Style should be explicitly mentioned - otherwise it would be a "follow" style
484 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(2, "2"), uno::UNO_QUERY_THROW
);
485 CPPUNIT_ASSERT(uno::Any() != xPara
->getPropertyValue("PageDescName"));
486 // CPPUNIT_ASSERT_EQUAL(OUString("First Page header"),
487 // parseDump("/root/page[2]/header/txt"));
489 // Page Style is converted into a page break instead. Still shows "first" header.
490 xPara
.set(getParagraph(3, "3"), uno::UNO_QUERY_THROW
);
491 CPPUNIT_ASSERT_EQUAL(uno::Any(), xPara
->getPropertyValue("PageDescName"));
492 // CPPUNIT_ASSERT_EQUAL(OUString("Default page style - first page style"),
493 // parseDump("/root/page[3]/header/txt"));
494 CPPUNIT_ASSERT_EQUAL(OUString(), parseDump("/root/page[3]/footer/txt"));
496 // Page Style is converted into a page break instead. Shows the "normal" header.
497 xPara
.set(getParagraph(5, "4"), uno::UNO_QUERY_THROW
);
498 CPPUNIT_ASSERT_EQUAL(uno::Any(), xPara
->getPropertyValue("PageDescName"));
499 CPPUNIT_ASSERT_EQUAL(OUString("Default page style"),
500 parseDump("/root/page[4]/header/txt"));
502 // Page Style is retained (with wrong header) in order to preserve page re-numbering.
503 xPara
.set(getParagraph(7, "1"), uno::UNO_QUERY_THROW
);
504 CPPUNIT_ASSERT(uno::Any() != xPara
->getPropertyValue("PageDescName"));
505 CPPUNIT_ASSERT_EQUAL(OUString(), parseDump("/root/page[5]/footer/txt"));
508 CPPUNIT_TEST_FIXTURE(Test
, testTdf145998_firstHeader
)
510 loadAndReload("tdf145998_firstHeader.odt");
512 // Sanity check - always good to test when dealing with page styles and breaks.
513 CPPUNIT_ASSERT_EQUAL(2, getPages());
515 CPPUNIT_ASSERT_EQUAL(OUString("Very first header"), parseDump("/root/page[1]/header/txt"));
517 // Page Style is already used in prior section - this can't be the first-header
518 CPPUNIT_ASSERT_EQUAL(OUString("Normal Header"), parseDump("/root/page[2]/header/txt"));
521 CPPUNIT_TEST_FIXTURE(Test
, testTdf135216_evenOddFooter
)
523 loadAndReload("tdf135216_evenOddFooter.odt");
524 uno::Reference
<frame::XModel
> xModel(mxComponent
, uno::UNO_QUERY
);
525 uno::Reference
<text::XTextViewCursorSupplier
> xTextViewCursorSupplier(xModel
->getCurrentController(), uno::UNO_QUERY
);
526 uno::Reference
<text::XPageCursor
> xCursor(xTextViewCursorSupplier
->getViewCursor(), uno::UNO_QUERY
);
528 // get LO page style for the first page (even page #2)
529 OUString pageStyleName
= getProperty
<OUString
>(xCursor
, "PageStyleName");
530 uno::Reference
<container::XNameAccess
> xPageStyles
= getStyles("PageStyles");
531 uno::Reference
<style::XStyle
> xPageStyle(xPageStyles
->getByName(pageStyleName
), uno::UNO_QUERY
);
533 xCursor
->jumpToFirstPage(); // Even/Left page #2
534 uno::Reference
<text::XText
> xFooter
= getProperty
<uno::Reference
<text::XText
>>(xPageStyle
, "FooterTextLeft");
535 CPPUNIT_ASSERT_EQUAL(OUString("even page"), xFooter
->getString());
537 xCursor
->jumpToNextPage();
538 pageStyleName
= getProperty
<OUString
>(xCursor
, "PageStyleName");
539 xPageStyle
.set(xPageStyles
->getByName(pageStyleName
), uno::UNO_QUERY
);
540 xFooter
.set(getProperty
<uno::Reference
<text::XText
>>(xPageStyle
, "FooterTextFirst"));
541 CPPUNIT_ASSERT_EQUAL(OUString("odd page - first footer"), xFooter
->getString());
543 xCursor
->jumpToNextPage();
544 pageStyleName
= getProperty
<OUString
>(xCursor
, "PageStyleName");
545 xPageStyle
.set(xPageStyles
->getByName(pageStyleName
), uno::UNO_QUERY
);
546 xFooter
.set(getProperty
<uno::Reference
<text::XText
>>(xPageStyle
, "FooterTextLeft"));
547 CPPUNIT_ASSERT_EQUAL(OUString("even page"), xFooter
->getString());
549 // The contents of paragraph 2 should be the page number (2) located on page 1.
550 getParagraph(2, "2");
553 CPPUNIT_TEST_FIXTURE(Test
, testTdf136929_framesOfParagraph
)
555 loadAndReload("tdf136929_framesOfParagraph.odt");
556 // Before this fix, the image was placed in the footer instead of in the text body - messing everything up.
557 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Number of Pages", 5, getPages() );
558 CPPUNIT_ASSERT_EQUAL_MESSAGE("Header2 text", OUString("* | *"), parseDump("/root/page[4]/footer/txt"));
561 DECLARE_OOXMLEXPORT_TEST(testTdf136589_paraHadField
, "tdf136589_paraHadField.docx")
563 // The section break should not add an additional CR - which equals an empty page two.
564 CPPUNIT_ASSERT_EQUAL(2, getPages());
566 //tdf#118711 - don't explicitly specify the default page style at the beginning of the document
567 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(1), uno::UNO_QUERY_THROW
);
568 CPPUNIT_ASSERT_EQUAL(uno::Any(), xPara
->getPropertyValue("PageDescName"));
571 CPPUNIT_TEST_FIXTURE(Test
, testTdf133370_columnBreak
)
573 loadAndReload("tdf133370_columnBreak.odt");
574 // Since non-DOCX formats ignores column breaks in non-column situations, don't export to docx.
575 CPPUNIT_ASSERT_EQUAL(1, getPages());
578 CPPUNIT_TEST_FIXTURE(Test
, testTdf134649_pageBreak
)
580 loadAndReload("tdf134649_pageBreak.fodt");
581 // This was 1 (missing page break between tables).
582 CPPUNIT_ASSERT_EQUAL(2, getPages());
585 DECLARE_OOXMLEXPORT_TEST(testTdf135343_columnSectionBreak_c14
, "tdf135343_columnSectionBreak_c14.docx")
587 uno::Reference
<beans::XPropertySet
> xTextSection
= getProperty
<uno::Reference
<beans::XPropertySet
>>(getParagraph(1), "TextSection");
588 uno::Reference
<text::XTextColumns
> xTextColumns
= getProperty
<uno::Reference
<text::XTextColumns
>>(xTextSection
, "TextColumns");
589 CPPUNIT_ASSERT_EQUAL_MESSAGE("Section one's columns", sal_Int16(2), xTextColumns
->getColumnCount());
591 // Old Word 2010 version - nextColumn breaks inside column sections are just treated as regular column breaks.
592 //xTextSection = getProperty<uno::Reference<beans::XPropertySet>>(getParagraph(12, "RTL 2"), "TextSection");
593 //xTextColumns = getProperty<uno::Reference<text::XTextColumns>>(xTextSection, "TextColumns");
594 //CPPUNIT_ASSERT_EQUAL_MESSAGE("Section four's columns", sal_Int16(3), xTextColumns->getColumnCount());
595 //CPPUNIT_ASSERT_EQUAL(1, getPages());
598 CPPUNIT_TEST_FIXTURE(Test
, testTdf135973
)
600 loadAndReload("tdf135973.odt");
601 CPPUNIT_ASSERT_EQUAL(1, getPages());
603 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(2), uno::UNO_QUERY
);
604 CPPUNIT_ASSERT_EQUAL(OUString("1."), getProperty
<OUString
>(xPara
, "ListLabelString"));
607 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(3), uno::UNO_QUERY
);
608 CPPUNIT_ASSERT_EQUAL(OUString("2."), getProperty
<OUString
>(xPara
, "ListLabelString"));
611 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(5), uno::UNO_QUERY
);
612 CPPUNIT_ASSERT_EQUAL(OUString("1."), getProperty
<OUString
>(xPara
, "ListLabelString"));
615 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(6), uno::UNO_QUERY
);
616 CPPUNIT_ASSERT_EQUAL(OUString("2."), getProperty
<OUString
>(xPara
, "ListLabelString"));
620 DECLARE_OOXMLEXPORT_TEST(testTdf135343_columnSectionBreak_c14v2
, "tdf135343_columnSectionBreak_c14v2.docx")
622 // In this Word 2010 v2, section three was changed to start with a nextColumn break instead of a continuous break.
623 // The previous section has no columns, so this time start the columns on a new page.
624 uno::Reference
<beans::XPropertySet
> xTextSection
= getProperty
<uno::Reference
<beans::XPropertySet
>>(getParagraph(10, ""), "TextSection");
625 uno::Reference
<text::XTextColumns
> xTextColumns
= getProperty
<uno::Reference
<text::XTextColumns
>>(xTextSection
, "TextColumns");
626 CPPUNIT_ASSERT_EQUAL_MESSAGE("Section three's columns", sal_Int16(3), xTextColumns
->getColumnCount());
627 //CPPUNIT_ASSERT_EQUAL(2, getPages());
630 DECLARE_OOXMLEXPORT_TEST(testTdf135343_columnSectionBreak_c12v3
, "tdf135343_columnSectionBreak_c12v3.docx")
632 // In this Word 20-3 v3, section one and two have different number of columns. It acts like a page break.
633 uno::Reference
<beans::XPropertySet
> xTextSection
= getProperty
<uno::Reference
<beans::XPropertySet
>>(getParagraph(1, "Four columns,"), "TextSection");
634 uno::Reference
<text::XTextColumns
> xTextColumns
= getProperty
<uno::Reference
<text::XTextColumns
>>(xTextSection
, "TextColumns");
635 CPPUNIT_ASSERT_EQUAL_MESSAGE("Section one's columns", sal_Int16(4), xTextColumns
->getColumnCount());
637 xTextSection
= getProperty
<uno::Reference
<beans::XPropertySet
>>(getParagraph(6, "RTL 2"), "TextSection");
638 xTextColumns
= getProperty
<uno::Reference
<text::XTextColumns
>>(xTextSection
, "TextColumns");
639 CPPUNIT_ASSERT_EQUAL_MESSAGE("Section two's columns", sal_Int16(2), xTextColumns
->getColumnCount());
640 CPPUNIT_ASSERT_EQUAL(2, getPages());
643 DECLARE_OOXMLEXPORT_TEST(testTdf135343_columnSectionBreak_c15
, "tdf135343_columnSectionBreak_c15.docx")
645 // Word 2013+ version - nextColumn breaks inside column sections are always handled like nextPage breaks.
646 uno::Reference
<beans::XPropertySet
> xTextSection
= getProperty
<uno::Reference
<beans::XPropertySet
>>(getParagraph(12, "RTL 2"), "TextSection");
647 uno::Reference
<text::XTextColumns
> xTextColumns
= getProperty
<uno::Reference
<text::XTextColumns
>>(xTextSection
, "TextColumns");
648 CPPUNIT_ASSERT_EQUAL_MESSAGE("Section four's columns", sal_Int16(3), xTextColumns
->getColumnCount());
649 CPPUNIT_ASSERT_EQUAL_MESSAGE("Fits on two pages", 2, getPages());
652 DECLARE_OOXMLEXPORT_TEST(testTdf121669_equalColumns
, "tdf121669_equalColumns.docx")
654 uno::Reference
<beans::XPropertySet
> xTextSection
= getProperty
< uno::Reference
<beans::XPropertySet
> >(getParagraph(1), "TextSection");
655 CPPUNIT_ASSERT(xTextSection
.is());
656 uno::Reference
<text::XTextColumns
> xTextColumns
= getProperty
< uno::Reference
<text::XTextColumns
> >(xTextSection
, "TextColumns");
657 // The property was ignored when deciding at export whether the columns were equal or not. Layout isn't reliable.
658 CPPUNIT_ASSERT(getProperty
<bool>(xTextColumns
, "IsAutomatic"));
661 CPPUNIT_TEST_FIXTURE(Test
, testTdf132149_pgBreak
)
663 loadAndReload("tdf132149_pgBreak.odt");
664 // This 5 page document is designed to visually exaggerate the problems
665 // of emulating LO's followed-by-page-style into MSWord's sections.
666 // While much has been improved, there are extra pages present, which still need fixing.
667 xmlDocUniquePtr pDump
= parseLayoutDump();
669 // No header on pages 1,2,3.
670 assertXPath(pDump
, "//page[2]/header", 0);
672 // Margins/page orientation between Right and Left page styles are different
673 assertXPath(pDump
, "//page[1]/infos/prtBounds", "left", "1134"); //Right page style
674 assertXPath(pDump
, "//page[2]/infos/prtBounds", "left", "2268"); //Left page style
676 assertXPath(pDump
, "//page[1]/infos/bounds", "width", "8391"); //landscape
677 assertXPath(pDump
, "//page[2]/infos/bounds", "width", "5940"); //portrait
678 // This two-line 3rd page ought not to exist. DID YOU FIX ME? The real page 3 should be "8391" landscape.
679 assertXPath(pDump
, "//page[3]/infos/bounds", "width", "5940");
680 // This really ought to be on odd page 3, but now it is on odd page 5.
681 assertXPath(pDump
, "//page[5]/infos/bounds", "width", "8391");
682 assertXPath(pDump
, "//page[5]/infos/prtBounds", "right", "6122"); //Left page style
685 //Page style change here must not be lost. This SHOULD be on page 4, but sadly it is not.
686 assertXPathContent(pDump
, "//page[6]/header/txt", "First Page Style");
687 CPPUNIT_ASSERT(getXPathContent(pDump
, "//page[6]/body/txt[1]").startsWith("Lorem ipsum"));
690 CPPUNIT_TEST_FIXTURE(Test
, testTdf132149_pgBreakB
)
692 loadAndReload("tdf132149_pgBreakB.odt");
693 // This 5 page document is designed to visually exaggerate the problems
694 // of emulating LO's followed-by-page-style into MSWord's sections.
695 xmlDocUniquePtr pDump
= parseLayoutDump();
697 //Sanity check to ensure the correct page is being tested. This SHOULD be on page 3, but sadly it is not.
698 CPPUNIT_ASSERT(getXPathContent(pDump
, "//page[5]/body/txt[1]").startsWith("Lorem ipsum"));
699 //Prior to this fix, the original alternation between portrait and landscape was completely lost.
700 assertXPath(pDump
, "//page[5]/infos/bounds", "width", "8391"); //landscape
703 CPPUNIT_TEST_FIXTURE(Test
, testTdf132149_pgBreak2
)
705 loadAndReload("tdf132149_pgBreak2.odt");
706 // This 3 page document is designed to visually exaggerate the problems
707 // of emulating LO's followed-by-page-style into MSWord's sections.
709 // The only specified page style change should be between page 1 and 2.
710 // When the first paragraph was split into 3, each paragraph specified a page break. The last was unnecessary.
711 uno::Reference
<beans::XPropertySet
> xParaThree(getParagraph(3), uno::UNO_QUERY_THROW
);
712 CPPUNIT_ASSERT_EQUAL(uno::Any(), xParaThree
->getPropertyValue("PageDescName"));
713 // The ODT is only 2 paragraphs, but a hack to get the right page style breaks para1 into pieces.
714 // This was 4 paragraphs - the unnecessary page break had hacked in another paragraph split.
715 CPPUNIT_ASSERT_LESSEQUAL( 3, getParagraphs() );
718 CPPUNIT_TEST_FIXTURE(Test
, testTdf136952_pgBreak3B
)
720 loadAndReload("tdf136952_pgBreak3B.odt");
721 // This 4 page document is designed to visually exaggerate the problems
722 // of emulating LO's followed-by-page-style into MSWord's sections.
723 xmlDocUniquePtr pDump
= parseLayoutDump();
725 //page::breakAfter must not be lost.
726 //Prior to this bug fix, the Lorem ipsum paragraph was in the middle of a portrait page, with no switch to landscape occurring.
727 CPPUNIT_ASSERT(getXPathContent(pDump
, "//page[3]/body/txt[1]").startsWith("Lorem ipsum"));
728 assertXPath(pDump
, "//page[3]/infos/bounds", "width", "8391"); //landscape
731 DECLARE_OOXMLEXPORT_TEST(testTdf135949_anchoredBeforeBreak
, "tdf135949_anchoredBeforeBreak.docx")
733 xmlDocUniquePtr pDump
= parseLayoutDump();
734 //The picture was shown on page 2, because the empty paragraph before the page break was removed
735 assertXPath(pDump
, "//page[1]/body/txt/anchored/fly", 1);
738 DECLARE_OOXMLEXPORT_TEST(testTdf129452_excessBorder
, "tdf129452_excessBorder.docx")
740 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
741 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
742 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY_THROW
);
744 // The outside border should not be applied on inside cells. The merge doesn't extend to the table bottom.
745 // [Note: as humans, we would call this cell D3, but since row 4 hasn't been analyzed yet, it is considered column C.]
746 table::BorderLine2 aBorder
= getProperty
<table::BorderLine2
>(xTable
->getCellByName("C3"), "BottomBorder");
747 CPPUNIT_ASSERT_EQUAL_MESSAGE("No bottom border on merged cell", sal_uInt32(0), aBorder
.LineWidth
);
749 // [Note: as humans, we would call this cell C3, but since row 4 hasn't been analyzed yet, it is considered column B.]
750 aBorder
= getProperty
<table::BorderLine2
>(xTable
->getCellByName("B3"), "BottomBorder");
751 CPPUNIT_ASSERT_EQUAL_MESSAGE("No bottom border on merged cell", sal_uInt32(0), aBorder
.LineWidth
);
754 DECLARE_OOXMLEXPORT_TEST(testTdf132898_missingBorder
, "tdf132898_missingBorder.docx")
756 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
757 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
758 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
760 // The bottom border from the last merged cell was not showing
761 table::BorderLine2 aBorder
= getProperty
<table::BorderLine2
>(xTable
->getCellByName("A1"), "BottomBorder");
762 CPPUNIT_ASSERT_MESSAGE("Bottom border on merged cell", aBorder
.LineWidth
> 0);
765 DECLARE_OOXMLEXPORT_TEST(testTdf132898_extraBorder
, "tdf132898_extraBorder.docx")
767 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
768 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
769 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
771 // A border defined on an earlier merged cell was showing
772 table::BorderLine2 aBorder
= getProperty
<table::BorderLine2
>(xTable
->getCellByName("C1"), "BottomBorder");
773 CPPUNIT_ASSERT_EQUAL_MESSAGE("No bottom border on merged cell", sal_uInt32(0), aBorder
.LineWidth
);
774 // MS Word is interesting here. 2/3 of the merged cell has the right border, so what to do?
775 aBorder
= getProperty
<table::BorderLine2
>(xTable
->getCellByName("C1"), "RightBorder");
776 CPPUNIT_ASSERT_EQUAL_MESSAGE("No right border on merged cell", sal_uInt32(0), aBorder
.LineWidth
);
779 DECLARE_OOXMLEXPORT_TEST(testTdf131561_necessaryBorder
, "tdf131561_necessaryBorder.docx")
781 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
782 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
783 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
785 // Hand-crafted pre-emptive test to make sure borders aren't lost.
786 // MS Word is interesting here. 2/3 of the merged cell has the right border, so what to do?
787 table::BorderLine2 aBorderR
= getProperty
<table::BorderLine2
>(xTable
->getCellByName("A1"), "RightBorder");
788 table::BorderLine2 aBorderL
= getProperty
<table::BorderLine2
>(xTable
->getCellByName("B1"), "LeftBorder");
789 CPPUNIT_ASSERT_MESSAGE("Border between A1 and B1", (aBorderR
.LineWidth
+ aBorderL
.LineWidth
) > 0);
790 aBorderR
= getProperty
<table::BorderLine2
>(xTable
->getCellByName("A3"), "RightBorder");
791 aBorderL
= getProperty
<table::BorderLine2
>(xTable
->getCellByName("B3"), "LeftBorder");
792 CPPUNIT_ASSERT_MESSAGE("Border between A3 and B3", (aBorderR
.LineWidth
+ aBorderL
.LineWidth
) > 0);
795 CPPUNIT_TEST_FIXTURE(Test
, testTdf135655
)
797 loadAndSave("tdf135655.odt");
798 const xmlDocUniquePtr pExpDoc
= parseExport("word/document.xml");
799 const OUString sXFillColVal
= getXPath(pExpDoc
, "/w:document/w:body/w:p/w:r/w:object/v:shape", "fillcolor");
800 CPPUNIT_ASSERT_EQUAL(OUString("#00A933"), sXFillColVal
);
803 CPPUNIT_TEST_FIXTURE(Test
, testTdf138374
)
805 loadAndSave("tdf138374.odt");
806 xmlDocUniquePtr pXmlDocument
= parseExport("word/document.xml");
807 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[2]/w:r/w:pict/v:shape", "fillcolor", "#ffd320");
808 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[2]/w:r/w:pict/v:shape", "coordsize", "1315,6116");
810 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[2]/w:r/w:pict/v:shape", "path",
811 "m0,0l1314,0l1314,5914l416,5914l416,6115l106,5715l416,5415l416,5715l1014,5715l1014,224l0,224l0,16l0,0e");
812 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[2]/w:r/w:pict/v:shape", "style",
813 "position:absolute;margin-left:394.3pt;margin-top:204pt;width:37.2pt;height:173.3pt;mso-wrap-style:none;v-text-anchor:middle");
816 DECLARE_OOXMLEXPORT_TEST(testTdf134609_gridAfter
, "tdf134609_gridAfter.docx")
818 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
819 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
820 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
822 // Table borders (width 159) apply to edge cells, even in uneven cases caused by gridBefore/gridAfter,
823 table::BorderLine2 aBorder
= getProperty
<table::BorderLine2
>(xTable
->getCellByName("A1"), "RightBorder");
824 CPPUNIT_ASSERT_MESSAGE("Right border before gridAfter cells", aBorder
.LineWidth
> 0);
825 aBorder
= getProperty
<table::BorderLine2
>(xTable
->getCellByName("E2"), "LeftBorder");
826 CPPUNIT_ASSERT_MESSAGE("Left edge border after gridBefore cells", aBorder
.LineWidth
> 100);
827 aBorder
= getProperty
<table::BorderLine2
>(xTable
->getCellByName("E2"), "TopBorder");
828 // but only for left/right borders, not top and bottom.
829 // So somewhat inconsistently, gridBefore/After affects outside edges of columns, but not of rows.
830 // insideH borders are width 53. (no insideV borders defined to emphasize missing edge borders)
831 CPPUNIT_ASSERT_MESSAGE("Top border on 'inside' cell", aBorder
.LineWidth
> 0);
832 CPPUNIT_ASSERT_MESSAGE("Top border is not an edge border", aBorder
.LineWidth
< 100);
835 CPPUNIT_TEST_FIXTURE(Test
, testTdf135329_lostImage
)
837 loadAndReload("tdf135329_lostImage.odt");
838 // the character-anchored image was being skipped, since searchNext didn't notice it.
839 uno::Reference
<beans::XPropertySet
> xImageProps(getShape(2), uno::UNO_QUERY_THROW
);
842 CPPUNIT_TEST_FIXTURE(Test
, testTdf136441_commentInFootnote
)
844 loadAndReload("tdf136441_commentInFootnote.odt");
845 // failed to load without error if footnote contained a comment.
846 // (MS Word's UI doesn't allow adding comments to a footnote.)
849 DECLARE_OOXMLEXPORT_TEST(testTdf137683_charHighlightTests
, "tdf137683_charHighlightTests.docx")
851 // Don't export unnecessary w:highlight="none" (Unnecessary one intentionally hand-added to original .docx)
854 xmlDocUniquePtr pXmlStyles
= parseExport("word/styles.xml");
855 assertXPath(pXmlStyles
, "/w:styles/w:style[@w:styleId='Normal']/w:rPr/w:highlight", 0);
858 uno::Reference
<beans::XPropertySet
> xRun(getRun(getParagraph(10), 2, "no highlight"), uno::UNO_QUERY_THROW
);
859 // This test was failing with a cyan charHighlight of 65535 (0x00FFFF), instead of COL_TRANSPARENT (0xFFFFFFFF)
860 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(COL_AUTO
), getProperty
<sal_Int32
>(xRun
, "CharHighlight"));
863 DECLARE_OOXMLEXPORT_TEST(testTdf138345_charStyleHighlight
, "tdf138345_charStyleHighlight.docx")
865 // MS Word ignores the w:highlight setting in character styles. So shall we.
866 // Without the fix, there would be an orange or yellow background on some words.
867 const uno::Reference
<beans::XPropertySet
> xRun(getRun(getParagraph(1), 2, "orange background"), uno::UNO_QUERY
);
868 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(COL_TRANSPARENT
), getProperty
<sal_Int32
>(xRun
,"CharHighlight"));
869 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(COL_TRANSPARENT
), getProperty
<sal_Int32
>(xRun
,"CharBackColor"));
872 CPPUNIT_TEST_FIXTURE(Test
, testTdf125268
)
874 loadAndReload("tdf125268.odt");
875 CPPUNIT_ASSERT_EQUAL(1, getPages());
876 const uno::Reference
<beans::XPropertySet
> xRun(getRun(getParagraph(1), 1, "Hello"), uno::UNO_QUERY
);
877 // Without the fix in place, this test would have failed with
880 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(COL_TRANSPARENT
), getProperty
<sal_Int32
>(xRun
,"CharHighlight"));
881 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(COL_BLACK
), getProperty
<sal_Int32
>(xRun
,"CharBackColor"));
884 CPPUNIT_TEST_FIXTURE(Test
, testTdf138345_numberingHighlight
)
886 loadAndSave("tdf138345_numberingHighlight.docx");
887 // Before the fix, the highlight was completely lost.
888 xmlDocUniquePtr pXmlStyles
= parseExport("word/numbering.xml");
890 assertXPath(pXmlStyles
, "/w:numbering/w:abstractNum[@w:abstractNumId='1']/w:lvl[@w:ilvl='0']/w:rPr/w:highlight", "val", "red");
893 DECLARE_OOXMLEXPORT_TEST(testTdf134063
, "tdf134063.docx")
895 CPPUNIT_ASSERT_EQUAL(2, getPages());
897 xmlDocUniquePtr pDump
= parseLayoutDump();
899 // There are three tabs with default width
900 CPPUNIT_ASSERT_EQUAL(sal_Int32(720), getXPath(pDump
, "//page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFixPortion[1]", "width").toInt32());
901 CPPUNIT_ASSERT_EQUAL(sal_Int32(720), getXPath(pDump
, "//page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFixPortion[2]", "width").toInt32());
902 CPPUNIT_ASSERT_EQUAL(sal_Int32(720), getXPath(pDump
, "//page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFixPortion[3]", "width").toInt32());
905 DECLARE_OOXMLEXPORT_TEST(TestTdf135653
, "tdf135653.docx")
907 uno::Reference
<beans::XPropertySet
> xOLEProps(getShape(1), uno::UNO_QUERY_THROW
);
908 drawing::FillStyle nFillStyle
= static_cast<drawing::FillStyle
>(-1);
909 xOLEProps
->getPropertyValue("FillStyle") >>= nFillStyle
;
910 Color
aFillColor(COL_AUTO
);
911 xOLEProps
->getPropertyValue("FillColor") >>= aFillColor
;
913 CPPUNIT_ASSERT_EQUAL_MESSAGE("Fill style setting does not match!",
914 drawing::FillStyle::FillStyle_SOLID
, nFillStyle
);
915 Color aExpectedColor
;
916 aExpectedColor
.SetRed(255);
917 aExpectedColor
.SetGreen(0);
918 aExpectedColor
.SetBlue(0);
919 CPPUNIT_ASSERT_EQUAL_MESSAGE("OLE bg color does not match!", aExpectedColor
, aFillColor
);
922 DECLARE_OOXMLEXPORT_TEST(testTdf135665
, "tdf135665.docx")
924 uno::Reference
<beans::XPropertySet
> xOLEProps1(getShape(1), uno::UNO_QUERY_THROW
);
925 uno::Reference
<beans::XPropertySet
> xOLEProps2(getShape(2), uno::UNO_QUERY_THROW
);
926 bool bSurroundContour1
= false;
927 bool bSurroundContour2
= false;
928 xOLEProps1
->getPropertyValue("SurroundContour") >>= bSurroundContour1
;
929 xOLEProps2
->getPropertyValue("SurroundContour") >>= bSurroundContour2
;
931 CPPUNIT_ASSERT_EQUAL_MESSAGE("OLE tight wrap setting not imported correctly", true, bSurroundContour1
);
932 CPPUNIT_ASSERT_EQUAL_MESSAGE("OLE tight wrap setting not imported correctly", false, bSurroundContour2
);
935 CPPUNIT_TEST_FIXTURE(Test
, testAtPageShapeRelOrientation
)
937 loadAndSave("rotated_shape.fodt");
938 // invalid combination of at-page anchor and horizontal-rel="paragraph"
939 // caused relativeFrom="column" instead of relativeFrom="page"
941 xmlDocUniquePtr pXmlDocument
= parseExport("word/document.xml");
943 assertXPathContent(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor"
944 "/wp:positionH/wp:posOffset", "-480060");
945 assertXPath(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor"
946 "/wp:positionH", "relativeFrom", "page");
947 assertXPathContent(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor"
948 "/wp:positionV/wp:posOffset", "8147685");
949 assertXPath(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor"
950 "/wp:positionV", "relativeFrom", "page");
953 assertXPathContent(pXmlDocument
, "/w:document/w:body/w:p/w:r/w:drawing/wp:anchor"
954 "/wp:positionH/wp:posOffset", "720090");
955 assertXPath(pXmlDocument
, "/w:document/w:body/w:p/w:r/w:drawing/wp:anchor"
956 "/wp:positionH", "relativeFrom", "page");
957 assertXPathContent(pXmlDocument
, "/w:document/w:body/w:p/w:r/w:drawing/wp:anchor"
958 "/wp:positionV/wp:posOffset", "1080135");
959 assertXPath(pXmlDocument
, "/w:document/w:body/w:p/w:r/w:drawing/wp:anchor"
960 "/wp:positionV", "relativeFrom", "page");
962 // now test text rotation -> VML writing direction
963 assertXPath(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Fallback/w:pict/v:shape/v:textbox", "style", "mso-layout-flow-alt:bottom-to-top");
965 assertXPath(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Fallback/w:pict/v:shape/w10:wrap", "type", "none");
966 // vertical alignment -> VML
967 OUString
const style
= getXPath(pXmlDocument
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Fallback/w:pict/v:shape", "style");
968 CPPUNIT_ASSERT(style
.indexOf("v-text-anchor:middle") != -1);
971 CPPUNIT_TEST_FIXTURE(Test
, testVMLallowincell
)
973 loadAndSave("shape-atpage-in-table.fodt");
974 xmlDocUniquePtr pXmlDocument
= parseExport("word/document.xml");
976 // VML o:allowincell, apparently the default is "t"
977 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", "f");
980 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", "0");
983 CPPUNIT_TEST_FIXTURE(Test
, testRelativeAnchorHeightFromBottomMarginHasFooter
)
985 loadAndSave("tdf133070_testRelativeAnchorHeightFromBottomMarginHasFooter.docx");
986 // tdf#133070 The height was set relative to page print area bottom,
987 // but this was handled relative to page height.
988 // Note: page print area bottom = margin + footer height.
989 // In this case the footer exists.
990 xmlDocUniquePtr pXmlDoc
= parseLayoutDump();
991 assertXPath(pXmlDoc
, "//anchored/SwAnchoredDrawObject/bounds", "height", "1147");
994 DECLARE_OOXMLEXPORT_TEST(TestTdf132483
, "tdf132483.docx")
996 uno::Reference
<beans::XPropertySet
> xOLEProps(getShape(1), uno::UNO_QUERY_THROW
);
997 sal_Int16 nVRelPos
= -1;
998 sal_Int16 nHRelPos
= -1;
999 xOLEProps
->getPropertyValue("VertOrientRelation") >>= nVRelPos
;
1000 xOLEProps
->getPropertyValue("HoriOrientRelation") >>= nHRelPos
;
1001 CPPUNIT_ASSERT_EQUAL_MESSAGE("The OLE is shifted vertically",
1002 text::RelOrientation::PAGE_FRAME
, nVRelPos
);
1003 CPPUNIT_ASSERT_EQUAL_MESSAGE("The OLE is shifted horizontally",
1004 text::RelOrientation::PAGE_FRAME
, nHRelPos
);
1007 CPPUNIT_TEST_FIXTURE(Test
, TestTdf143028
)
1009 loadAndSave("fail_bracePair.odt");
1010 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1011 CPPUNIT_ASSERT_EQUAL(1, getPages());
1012 auto pExportXml
= parseExport("word/document.xml");
1014 assertXPath(pExportXml
, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/"
1015 "a:graphic/a:graphicData/wps:wsp/wps:spPr/a:xfrm");
1019 CPPUNIT_TEST_FIXTURE(Test
, testRelativeAnchorHeightFromBottomMarginNoFooter
)
1021 loadAndSave("tdf133070_testRelativeAnchorHeightFromBottomMarginNoFooter.docx");
1022 // tdf#133070 The height was set relative to page print area bottom,
1023 // but this was handled relative to page height.
1024 // Note: page print area bottom = margin + footer height.
1025 // In this case the footer does not exist, so OpenDocument and OOXML margins are the same.
1026 xmlDocUniquePtr pXmlDoc
= parseLayoutDump();
1027 assertXPath(pXmlDoc
, "//anchored/SwAnchoredDrawObject/bounds", "height", "1147");
1030 CPPUNIT_TEST_FIXTURE(Test
, testTdf133702
)
1032 loadAndSave("tdf133702.docx");
1033 xmlDocUniquePtr pXmlDocument
= parseExport("word/document.xml");
1034 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[1]/w:pPr/w:framePr");
1037 CPPUNIT_TEST_FIXTURE(Test
, testTdf135667
)
1039 loadAndSave("tdf135667.odt");
1040 xmlDocUniquePtr pXmlDocument
= parseExport("word/document.xml");
1042 // This was missing.
1043 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[2]/w:r/w:object/v:shapetype");
1046 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[2]/w:r/w:object/v:shape", "stroked", "t");
1047 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[2]/w:r/w:object/v:shape", "strokecolor", "#FF0000");
1048 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[2]/w:r/w:object/v:shape", "strokeweight", "4pt");
1051 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[2]/w:r/w:object/v:shape/v:stroke", "linestyle", "Single");
1052 assertXPath(pXmlDocument
, "/w:document/w:body/w:p[2]/w:r/w:object/v:shape/v:stroke", "dashstyle", "Dash");
1055 CPPUNIT_TEST_FIXTURE(Test
, testImageSpaceSettings
)
1057 loadAndSave("tdf135047_ImageSpaceSettings.fodt");
1058 // tdf#135047 The spaces of image were not saved.
1059 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1060 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[1]/w:drawing/wp:anchor", "distT", "90170");
1061 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[1]/w:drawing/wp:anchor", "distB", "90170");
1062 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[1]/w:drawing/wp:anchor", "distL", "90170");
1063 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[1]/w:drawing/wp:anchor", "distR", "90170");
1066 CPPUNIT_TEST_FIXTURE(Test
, testTdf137295
)
1068 loadAndReload("tdf137295.doc");
1069 CPPUNIT_ASSERT_EQUAL(1, getPages());
1071 // Without the fix in place, the test would have failed with
1074 CPPUNIT_ASSERT_EQUAL(2, getShapes());
1077 DECLARE_OOXMLEXPORT_TEST(testTdf135660
, "tdf135660.docx")
1079 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1080 const uno::Reference
<drawing::XShape
> xShape
= getShape(1);
1081 const uno::Reference
<beans::XPropertySet
> xOLEProps(xShape
, uno::UNO_QUERY_THROW
);
1082 sal_Int32 nWrapDistanceLeft
= -1;
1083 sal_Int32 nWrapDistanceRight
= -1;
1084 sal_Int32 nWrapDistanceTop
= -1;
1085 sal_Int32 nWrapDistanceBottom
= -1;
1086 xOLEProps
->getPropertyValue("LeftMargin") >>= nWrapDistanceLeft
;
1087 xOLEProps
->getPropertyValue("RightMargin") >>= nWrapDistanceRight
;
1088 xOLEProps
->getPropertyValue("TopMargin") >>= nWrapDistanceTop
;
1089 xOLEProps
->getPropertyValue("BottomMargin") >>= nWrapDistanceBottom
;
1090 CPPUNIT_ASSERT_EQUAL_MESSAGE("Left wrap distance is wrong", static_cast<sal_Int32
>(0), nWrapDistanceLeft
);
1091 CPPUNIT_ASSERT_EQUAL_MESSAGE("Right wrap distance is wrong", static_cast<sal_Int32
>(400), nWrapDistanceRight
);
1092 CPPUNIT_ASSERT_EQUAL_MESSAGE("Top wrap distance is wrong", static_cast<sal_Int32
>(300), nWrapDistanceTop
);
1093 CPPUNIT_ASSERT_EQUAL_MESSAGE("Bottom wrap distance is wrong", static_cast<sal_Int32
>(199), nWrapDistanceBottom
);
1096 CPPUNIT_TEST_FIXTURE(Test
, testTdf136814
)
1098 loadAndSave("tdf136814.odt");
1099 xmlDocUniquePtr pXmlDocument
= parseExport("word/document.xml");
1101 // Padding in this document is 0.10 cm which should translate to 3 pt (approx. 1.0583mm)
1102 assertXPath(pXmlDocument
, "/w:document/w:body/w:sectPr/w:pgBorders/w:top", "space", "3");
1103 assertXPath(pXmlDocument
, "/w:document/w:body/w:sectPr/w:pgBorders/w:left", "space", "3");
1104 assertXPath(pXmlDocument
, "/w:document/w:body/w:sectPr/w:pgBorders/w:bottom", "space", "3");
1105 assertXPath(pXmlDocument
, "/w:document/w:body/w:sectPr/w:pgBorders/w:right", "space", "3");
1108 CPPUNIT_PLUGIN_IMPLEMENT();
1110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */