Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / qa / extras / ooxmlexport / ooxmlexport9.cxx
blob402c2ddcc04ab55d5af1beccc0ffd3906eeb1605
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
10 #include <swmodeltestbase.hxx>
12 #include <config_fonts.h>
14 #include <com/sun/star/text/XFootnote.hpp>
15 #include <com/sun/star/text/XPageCursor.hpp>
16 #include <com/sun/star/text/XTextColumns.hpp>
17 #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
18 #include <com/sun/star/style/BreakType.hpp>
19 #include <com/sun/star/style/PageStyleLayout.hpp>
20 #include <com/sun/star/text/HoriOrientation.hpp>
21 #include <com/sun/star/text/RelOrientation.hpp>
22 #include <com/sun/star/text/VertOrientation.hpp>
23 #include <com/sun/star/text/WrapTextMode.hpp>
24 #include <com/sun/star/view/XFormLayerAccess.hpp>
25 #include <com/sun/star/view/XViewSettingsSupplier.hpp>
26 #include <com/sun/star/view/XSelectionSupplier.hpp>
27 #include <com/sun/star/style/LineSpacing.hpp>
28 #include <com/sun/star/style/LineSpacingMode.hpp>
29 #include <com/sun/star/style/ParagraphAdjust.hpp>
30 #include <com/sun/star/drawing/XControlShape.hpp>
31 #include <com/sun/star/packages/zip/ZipFileAccess.hpp>
32 #include <com/sun/star/text/XTextTable.hpp>
34 #include <sfx2/docfile.hxx>
35 #include <sfx2/docfilt.hxx>
36 #include <comphelper/processfactory.hxx>
37 #include <tools/UnitConversion.hxx>
38 #include <o3tl/string_view.hxx>
40 #include <docsh.hxx>
41 #include <ftninfo.hxx>
42 #include <unotxdoc.hxx>
44 class Test : public SwModelTestBase
46 public:
47 Test() : SwModelTestBase("/sw/qa/extras/ooxmlexport/data/", "Office Open XML Text") {}
50 class DocmTest : public SwModelTestBase
52 public:
53 DocmTest()
54 : SwModelTestBase("/sw/qa/extras/ooxmlexport/data/", "MS Word 2007 XML VBA")
59 DECLARE_OOXMLEXPORT_TEST(testFdo55381, "fdo55381.docx")
61 CPPUNIT_ASSERT_EQUAL(4, getPages());
62 //TODO: frames not located on the correct pages
65 CPPUNIT_TEST_FIXTURE(Test, testDocm)
67 loadAndSave("hello.docm");
68 // Make sure that we check the name of the export filter.
69 // This was application/vnd.ms-word.document.macroEnabled.main+xml when the
70 // name of the import filter was checked.
71 xmlDocUniquePtr pXmlDoc = parseExport("[Content_Types].xml");
72 assertXPath(pXmlDoc,
73 "/ContentType:Types/ContentType:Override[@PartName='/word/document.xml']",
74 "ContentType",
75 "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml");
78 CPPUNIT_TEST_FIXTURE(Test, testDefaultContentTypes)
80 loadAndSave("fdo55381.docx");
81 xmlDocUniquePtr pXmlDoc = parseExport("[Content_Types].xml");
82 assertXPath(pXmlDoc,
83 "/ContentType:Types/ContentType:Default[@Extension='xml']",
84 "ContentType",
85 "application/xml");
87 assertXPath(pXmlDoc,
88 "/ContentType:Types/ContentType:Default[@Extension='rels']",
89 "ContentType",
90 "application/vnd.openxmlformats-package.relationships+xml");
92 assertXPath(pXmlDoc,
93 "/ContentType:Types/ContentType:Default[@Extension='png']",
94 "ContentType",
95 "image/png");
97 assertXPath(pXmlDoc,
98 "/ContentType:Types/ContentType:Default[@Extension='jpeg']",
99 "ContentType",
100 "image/jpeg");
103 DECLARE_SW_ROUNDTRIP_TEST(testDocmSave, "hello.docm", nullptr, DocmTest)
105 // This was
106 // application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml,
107 // we used the wrong content type for .docm files.
108 if (isExported())
110 xmlDocUniquePtr pXmlDoc = parseExport("[Content_Types].xml");
111 assertXPath(pXmlDoc,
112 "/ContentType:Types/ContentType:Override[@PartName='/word/document.xml']",
113 "ContentType",
114 "application/vnd.ms-word.document.macroEnabled.main+xml");
118 DECLARE_SW_ROUNDTRIP_TEST(testBadDocm, "bad.docm", nullptr, DocmTest)
120 SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
121 CPPUNIT_ASSERT(pTextDoc);
122 // This was 'MS Word 2007 XML', broken docm files were not recognized.
123 CPPUNIT_ASSERT_EQUAL(OUString("MS Word 2007 XML VBA"), pTextDoc->GetDocShell()->GetMedium()->GetFilter()->GetName());
126 CPPUNIT_TEST_FIXTURE(Test, testTdf109063)
128 auto verify = [this]() {
129 // A near-page-width table should be allowed to split:
130 uno::Reference<text::XTextFramesSupplier> xDocument(mxComponent, uno::UNO_QUERY);
131 uno::Reference<beans::XPropertySet> xFrame(xDocument->getTextFrames()->getByName("Frame1"),
132 uno::UNO_QUERY);
133 bool bIsSplitAllowed{};
134 xFrame->getPropertyValue("IsSplitAllowed") >>= bIsSplitAllowed;
135 CPPUNIT_ASSERT(bIsSplitAllowed);
137 createSwDoc("tdf109063.docx");
138 verify();
139 saveAndReload("Office Open XML Text");
140 verify();
143 CPPUNIT_TEST_FIXTURE(DocmTest, testTdf108269)
145 loadAndReload("tdf108269.docm");
146 uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), maTempFile.GetURL());
147 // This failed: VBA streams were not roundtripped via the doc-level
148 // grab-bag.
149 CPPUNIT_ASSERT(xNameAccess->hasByName("word/vbaProject.bin"));
150 CPPUNIT_ASSERT(xNameAccess->hasByName("word/vbaData.xml"));
153 CPPUNIT_TEST_FIXTURE(Test, testTdf125338)
155 loadAndSave("tdf125338.docm");
156 uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), maTempFile.GetURL());
157 // docm files should not retain macros when saved as docx
158 CPPUNIT_ASSERT(!xNameAccess->hasByName("word/vbaProject.bin"));
161 DECLARE_OOXMLEXPORT_TEST(testTdf92045, "tdf92045.docx")
163 // This was true, <w:effect w:val="none"/> resulted in setting the blinking font effect.
164 CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(getRun(getParagraph(1), 1), "CharFlash"));
167 DECLARE_OOXMLEXPORT_TEST(testTdf95031, "tdf95031.docx")
169 // This was 494, in-numbering paragraph's automating spacing was handled as visible spacing, while it should not.
170 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraph(2), "ParaBottomMargin"));
171 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraph(3), "ParaTopMargin"));
174 DECLARE_OOXMLEXPORT_TEST(testTdf106690, "tdf106690.docx")
176 // This was 0, numbering rules with automatic spacing meant 0
177 // before/autospacing for all text nodes, even for ones at the start/end of
178 // a numbered text node block.
179 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(494), getProperty<sal_Int32>(getParagraph(2), "ParaBottomMargin"));
180 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(494), getProperty<sal_Int32>(getParagraph(2), "ParaTopMargin"));
183 DECLARE_OOXMLEXPORT_TEST(testTdf106690Cell, "tdf106690-cell.docx")
185 uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
186 uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
187 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
188 uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
189 // This was 0, bottom margin of the second paragraph in the A1 table cell
190 // had a reduced auto-space, just because of a next paragraph in the A2
191 // cell.
192 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(494), getProperty<sal_Int32>(getParagraphOfText(2, xCell->getText()), "ParaBottomMargin"));
195 DECLARE_OOXMLEXPORT_TEST(testTdf122342, "tdf122342.docx")
197 // These were 494, style based numbering rules with automatic spacing meant 0
198 // before/autospacing for all text nodes, even for ones at the start/end of
199 // a numbered text node block.
200 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraph(1), "ParaBottomMargin"));
201 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraph(2), "ParaBottomMargin"));
202 // last list item
203 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(494), getProperty<sal_Int32>(getParagraph(3), "ParaBottomMargin"));
206 CPPUNIT_TEST_FIXTURE(Test, testTdf132802)
208 loadAndSave("tdf132802.docx");
209 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
210 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:spacing", "after", "0");
211 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:pPr/w:spacing", "after", "0");
212 // This was 0 (list auto spacing is not zero before tables)
213 assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:pPr/w:spacing", "after", "280");
214 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc/w:p[1]/w:pPr/w:spacing", "after", "0");
215 // This was 0 (list auto spacing is not zero at the end of table cells)
216 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc/w:p[2]/w:pPr/w:spacing", "after", "280");
217 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:tc/w:p[1]/w:pPr/w:spacing", "after", "280");
218 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:p[1]/w:pPr/w:spacing", "after", "280");
219 // This was 0 (list auto spacing is not zero at list end)
220 assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:pPr/w:spacing", "after", "280");
223 CPPUNIT_TEST_FIXTURE(Test, testTdf132807)
225 loadAndSave("tdf132807.docx");
226 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
227 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:pPr/w:spacing", "before", "280");
228 // This was 240 (list auto spacing is zero in lists)
229 assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:pPr/w:spacing", "before", "0");
230 assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:pPr/w:spacing", "before", "0");
232 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc/w:p[1]/w:pPr/w:spacing", "before", "0");
233 // This was 240 (list auto spacing is zero in lists)
234 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc/w:p[2]/w:pPr/w:spacing", "before", "0");
236 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:tc/w:p[1]/w:pPr/w:spacing", "before", "0");
237 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:tc/w:p[2]/w:pPr/w:spacing", "before", "280");
238 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:p[1]/w:pPr/w:spacing", "before", "0");
239 assertXPath(pXmlDoc, "/w:document/w:body/w:p[5]/w:pPr/w:spacing", "before", "280");
242 CPPUNIT_TEST_FIXTURE(Test, testTdf133052)
244 loadAndSave("tdf133052.docx");
245 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
246 // These were 240 (top auto spacing of list subitems are zero)
247 assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:pPr/w:spacing", "before", "0");
248 assertXPath(pXmlDoc, "/w:document/w:body/w:p[5]/w:pPr/w:spacing", "before", "0");
249 // in tables, too
250 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc/w:p[2]/w:pPr/w:spacing", "before", "0");
251 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc/w:p[3]/w:pPr/w:spacing", "before", "0");
252 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc/w:p[4]/w:pPr/w:spacing", "before", "0");
253 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc/w:p[5]/w:pPr/w:spacing", "before", "0");
256 CPPUNIT_TEST_FIXTURE(Test, testTdf134648)
258 loadAndSave("tdf134648.docx");
259 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
261 // list item with direct top auto spacing
262 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:spacing", "after", "240");
263 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:spacing", "beforeAutospacing", "1");
265 // This was spacing w:after=200, but bottom auto spacing of first list subitem is zero
266 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:pPr/w:spacing", 0);
269 DECLARE_OOXMLEXPORT_TEST(testTdf129575_directBefore, "tdf129575-directBefore.docx")
271 uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
272 uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
273 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
274 uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
275 // direct paragraph formatting
276 // This was 212 twips from the table style, but always direct paragraph formatting wins, in the case of the default 0 margin, too
277 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(1, xCell->getText()), "ParaTopMargin"));
278 // default margin
279 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(1, xCell->getText()), "ParaBottomMargin"));
282 DECLARE_OOXMLEXPORT_TEST(testTdf129575_directAfter, "tdf129575-directAfter.docx")
284 uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
285 uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
286 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
287 uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
288 // from table style
289 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(212), getProperty<sal_Int32>(getParagraphOfText(1, xCell->getText()), "ParaTopMargin"));
290 // direct paragraph formatting
291 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(1, xCell->getText()), "ParaBottomMargin"));
294 DECLARE_OOXMLEXPORT_TEST(testTdf129575_styleAfter, "tdf129575-styleAfter.docx")
296 uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
297 uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
298 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
299 uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
300 // direct paragraph formatting
301 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(1, xCell->getText()), "ParaTopMargin"));
302 // from table style
303 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(212), getProperty<sal_Int32>(getParagraphOfText(1, xCell->getText()), "ParaBottomMargin"));
306 DECLARE_OOXMLEXPORT_TEST(testTdf129575_docDefault, "tdf129575-docDefault.docx")
308 uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
309 uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
310 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
311 uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
312 // docDefault defines both bottom margin and line spacing, but
313 // applied bottom margin values are based on non-docDefault paragraph styles, line spacing is based on table style
315 // docDefault: <w:spacing w:after="160" w:line="320" w:lineRule="auto"/>
316 // table style: <w:spacing w:after="0" w:line="240" w:lineRule="auto"/> (single line space, overwriting bigger docDefault)
318 // Paragraph style Normal: <w:spacing w:after="160"/> (same as docDefault),
319 // table style based single line spacing
320 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(282), getProperty<sal_Int32>(getParagraphOfText(1, xCell->getText()), "ParaBottomMargin"));
321 style::LineSpacing aLineSpacing = getProperty<style::LineSpacing>(getParagraphOfText(1, xCell->getText()), "ParaLineSpacing");
322 CPPUNIT_ASSERT_EQUAL(sal_Int16(style::LineSpacingMode::PROP), aLineSpacing.Mode);
323 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), aLineSpacing.Height);
324 // Heading 2: <w:spacing w:after="360"/> (different from docDefault),
325 // table style based single line spacing
326 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(635), getProperty<sal_Int32>(getParagraphOfText(2, xCell->getText()), "ParaBottomMargin"));
327 aLineSpacing = getProperty<style::LineSpacing>(getParagraphOfText(1, xCell->getText()), "ParaLineSpacing");
328 CPPUNIT_ASSERT_EQUAL(sal_Int16(style::LineSpacingMode::PROP), aLineSpacing.Mode);
329 CPPUNIT_ASSERT_EQUAL(sal_Int16(100), aLineSpacing.Height);
333 CPPUNIT_TEST_FIXTURE(Test, testTdf118812)
335 loadAndSave("tdf118812_tableStyles-comprehensive.docx");
336 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
337 // cell A1
338 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc/w:p/w:pPr/w:pStyle", "val", "Normal");
339 assertXPathNoAttribute(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc/w:p/w:pPr/w:spacing", "lineRule");
340 assertXPathNoAttribute(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc/w:p/w:pPr/w:spacing", "line");
341 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc/w:p/w:pPr/w:spacing", "before", "480");
342 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc/w:p/w:pPr/w:spacing", "after", "20");
343 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc/w:p/w:r[1]/w:rPr/w:color", 0);
344 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc/w:p/w:r[1]/w:rPr/w:sz", "val", "16");
345 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc/w:p/w:r[2]/w:rPr/w:rStyle", "val", "CharSubStyleDefaults");
346 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc/w:p/w:r[2]/w:rPr/w:color", 0);
347 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc/w:p/w:r[2]/w:rPr/w:sz", "val", "16");
348 // cell A2
349 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:tc/w:p/w:pPr/w:pStyle", "val", "Normal");
350 assertXPathNoAttribute(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:tc/w:p/w:pPr/w:spacing", "lineRule");
351 assertXPathNoAttribute(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:tc/w:p/w:pPr/w:spacing", "line");
352 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:tc/w:p/w:pPr/w:spacing", "before", "480");
353 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:tc/w:p/w:pPr/w:spacing", "after", "20");
354 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:tc/w:p/w:r[1]/w:rPr/w:color", 0);
355 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:tc/w:p/w:r[1]/w:rPr/w:sz", "val", "16");
356 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:tc/w:p/w:r[2]/w:rPr/w:rStyle", "val", "ParaSubStyleDefaultsChar");
357 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:tc/w:p/w:r[2]/w:rPr/w:color", 0);
358 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:tc/w:p/w:r[2]/w:rPr/w:sz", "val", "16");
359 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:tc/w:p/w:r[3]/w:rPr/w:rStyle", "val", "CharSubStyleNormal");
360 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:tc/w:p/w:r[3]/w:rPr/w:color", 0);
361 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:tc/w:p/w:r[3]/w:rPr/w:sz", "val", "16");
362 // cell A3
363 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:p/w:pPr/w:pStyle", "val", "ParaSubStyleNormal");
364 assertXPathNoAttribute(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:p/w:pPr/w:spacing", "lineRule");
365 assertXPathNoAttribute(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:p/w:pPr/w:spacing", "line");
366 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:p/w:pPr/w:spacing", "before", "480");
367 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:p/w:pPr/w:spacing", "after", "280");
368 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:p/w:r[1]/w:rPr/w:color", 0);
369 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:p/w:r[1]/w:rPr/w:sz", 0);
370 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:p/w:r[2]/w:rPr/w:rStyle", "val", "CharSubStyleNormal");
371 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:p/w:r[2]/w:rPr/w:color", 0);
372 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:p/w:r[2]/w:rPr/w:sz", 0);
373 // cell A4
374 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[4]/w:tc/w:p/w:pPr/w:pStyle", "val", "ParaSubStyleDefaults");
375 assertXPathNoAttribute(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[4]/w:tc/w:p/w:pPr/w:spacing", "lineRule");
376 assertXPathNoAttribute(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[4]/w:tc/w:p/w:pPr/w:spacing", "line");
377 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[4]/w:tc/w:p/w:pPr/w:spacing", "before", "480");
378 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[4]/w:tc/w:p/w:pPr/w:spacing", "after", "200");
379 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[4]/w:tc/w:p/w:r[1]/w:rPr/w:color", 0);
380 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[4]/w:tc/w:p/w:r[1]/w:rPr/w:sz", 0);
381 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[4]/w:tc/w:p/w:r[2]/w:rPr/w:rStyle", "val", "CharSubStyleDefaults");
382 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[4]/w:tc/w:p/w:r[2]/w:rPr/w:color", 0);
383 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[4]/w:tc/w:p/w:r[2]/w:rPr/w:sz", 0);
384 // cell A5
385 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[5]/w:tc/w:p/w:pPr/w:pStyle", "val", "Normal");
386 assertXPathNoAttribute(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[5]/w:tc/w:p/w:pPr/w:spacing", "lineRule");
387 assertXPathNoAttribute(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[5]/w:tc/w:p/w:pPr/w:spacing", "line");
388 assertXPathNoAttribute(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[5]/w:tc/w:p/w:pPr/w:rPr", "color");
389 assertXPathNoAttribute(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[5]/w:tc/w:p/w:pPr/w:rPr", "sz");
390 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[5]/w:tc/w:p/w:pPr/w:spacing", "before", "480");
391 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[5]/w:tc/w:p/w:pPr/w:spacing", "after", "20");
392 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[5]/w:tc/w:p/w:r[1]/w:rPr/w:color", 1);
393 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[5]/w:tc/w:p/w:r[1]/w:rPr/w:color", "val", "AAAA00"); // all text in color
394 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[5]/w:tc/w:p/w:r[1]/w:rPr/w:sz", "val", "16");
395 // cell A6
396 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[6]/w:tc/w:p/w:pPr/w:pStyle", "val", "Normal");
397 assertXPathNoAttribute(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[6]/w:tc/w:p/w:pPr/w:spacing", "lineRule");
398 assertXPathNoAttribute(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[6]/w:tc/w:p/w:pPr/w:spacing", "line");
399 assertXPathNoAttribute(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[6]/w:tc/w:p/w:pPr/w:rPr", "color");
400 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[6]/w:tc/w:p/w:pPr/w:rPr/w:sz", "val", "16");
401 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[6]/w:tc/w:p/w:pPr/w:spacing", "before", "480");
402 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[6]/w:tc/w:p/w:pPr/w:spacing", "after", "20");
403 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[6]/w:tc/w:p/w:r[1]/w:rPr/w:color", 0);
404 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[6]/w:tc/w:p/w:r[1]/w:rPr/w:sz", "val", "16");
405 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[6]/w:tc/w:p/w:r[2]/w:rPr/w:color", 1);
406 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[6]/w:tc/w:p/w:r[2]/w:rPr/w:color", "val", "AAAA00");
407 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[6]/w:tc/w:p/w:r[2]/w:rPr/w:sz", "val", "16");
409 // tdf#131070 keep paragraph style based right indentation with indentation of direct numbering
410 // cell A7 - This was <w:ind w:start="1440" w:hanging="0"/>
411 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[7]/w:tc/w:p/w:pPr/w:ind", 0);
412 // cell A8
413 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[8]/w:tc/w:p/w:pPr/w:ind", "start", "714");
414 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[8]/w:tc/w:p/w:pPr/w:ind", "end", "1701");
415 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[8]/w:tc/w:p/w:pPr/w:ind", "hanging", "357");
416 // cell A9
417 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[9]/w:tc/w:p/w:pPr/w:ind", "end", "1440");
418 // This was 1440
419 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[9]/w:tc/w:p/w:pPr/w:ind", "start", "720");
420 // This was 0
421 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[9]/w:tc/w:p/w:pPr/w:ind", "hanging", "360");
424 CPPUNIT_TEST_FIXTURE(Test, testTdf107626)
426 loadAndSave("tdf107626.odt");
427 CPPUNIT_ASSERT_EQUAL(1, getPages());
428 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
429 // This was 2 (missing trailing cell in merged cell range)
430 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[3]/w:tc", 3);
433 DECLARE_OOXMLEXPORT_TEST(testTdf106970, "tdf106970.docx")
435 // The second paragraph (first numbered one) had 0 bottom margin:
436 // autospacing was even collapsed between different numbering styles.
437 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(494), getProperty<sal_Int32>(getParagraph(2), "ParaBottomMargin"));
438 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraph(3), "ParaBottomMargin"));
439 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(494), getProperty<sal_Int32>(getParagraph(4), "ParaBottomMargin"));
442 DECLARE_OOXMLEXPORT_TEST(testTdf79272_strictDxa, "tdf79272_strictDxa.docx")
444 uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
445 uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
446 CPPUNIT_ASSERT_EQUAL(sal_Int32(4318), getProperty<sal_Int32>(xTables->getByIndex(0), "Width"));
448 if (!isExported())
449 return;
450 xmlDocUniquePtr pXmlDoc = parseExport("word/styles.xml");
451 // Validation test: order of elements was wrong. Order was: insideH, end, insideV.
452 int nEnd = getXPathPosition(pXmlDoc, "/w:styles/w:style[@w:styleId='TableGrid']/w:tblPr/w:tblBorders", "end");
453 int nInsideH = getXPathPosition(pXmlDoc, "/w:styles/w:style[@w:styleId='TableGrid']/w:tblPr/w:tblBorders", "insideH");
454 int nInsideV = getXPathPosition(pXmlDoc, "/w:styles/w:style[@w:styleId='TableGrid']/w:tblPr/w:tblBorders", "insideV");
455 CPPUNIT_ASSERT(nEnd < nInsideH);
456 CPPUNIT_ASSERT(nInsideH < nInsideV);
459 DECLARE_OOXMLEXPORT_TEST(testTdf109306, "tdf109306.docx")
461 uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
462 uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
463 // Both types of relative width specification (pct): simple integers (in fiftieths of percent)
464 // and floats with "%" unit specification must be treated correctly
465 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xTables->getByIndex(0), "IsWidthRelative"));
466 CPPUNIT_ASSERT_EQUAL(sal_Int16(9), getProperty<sal_Int16>(xTables->getByIndex(0), "RelativeWidth"));
468 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xTables->getByIndex(1), "IsWidthRelative"));
469 CPPUNIT_ASSERT_EQUAL(sal_Int16(80), getProperty<sal_Int16>(xTables->getByIndex(1), "RelativeWidth"));
472 DECLARE_OOXMLEXPORT_TEST(testKern, "kern.docx")
474 CPPUNIT_ASSERT(getProperty<bool>(getRun(getParagraph(1), 1), "CharAutoKerning"));
475 // This failed: kerning was also enabled for the second paragraph.
476 CPPUNIT_ASSERT(!getProperty<bool>(getRun(getParagraph(2), 1), "CharAutoKerning"));
478 uno::Reference<beans::XPropertySet> xStyle(getStyles("ParagraphStyles")->getByName("Default Paragraph Style"), uno::UNO_QUERY);
479 //tdf107801: kerning normally isn't enabled by default for .docx
480 CPPUNIT_ASSERT_EQUAL_MESSAGE("AutoKern should be false", false, getProperty<bool>(xStyle, "CharAutoKerning"));
483 DECLARE_OOXMLEXPORT_TEST(testTdf89377, "tdf89377_tableWithBreakBeforeParaStyle.docx")
485 // the paragraph style should set table's text-flow break-before-page
486 CPPUNIT_ASSERT_EQUAL( 3, getPages() );
488 uno::Reference<beans::XPropertySet> xStyle(getStyles("ParagraphStyles")->getByName("Default Paragraph Style"), uno::UNO_QUERY);
489 //tdf107801: kerning info wasn't exported previously.
490 CPPUNIT_ASSERT_EQUAL_MESSAGE("AutoKern should be true", true, getProperty<bool>(xStyle, "CharAutoKerning"));
493 DECLARE_OOXMLEXPORT_TEST(testTdf104420, "tdf104420_lostParagraph.docx")
495 // the add/remove dummy paragraph was losing an entire header and paragraph
496 CPPUNIT_ASSERT_EQUAL( 2, getPages() );
499 CPPUNIT_TEST_FIXTURE(Test, testTdf41542_borderlessPadding)
501 loadAndReload("tdf41542_borderlessPadding.odt");
502 // the page style's borderless padding should force this to 3 pages, not 1
503 CPPUNIT_ASSERT_EQUAL( 3, getPages() );
506 #if HAVE_MORE_FONTS
507 DECLARE_OOXMLEXPORT_TEST(tdf105490_negativeMargins, "tdf105490_negativeMargins.docx")
509 // negative margins should change to minimal margins, not default margins.
510 CPPUNIT_ASSERT_EQUAL( 1, getPages() );
512 #endif
514 DECLARE_OOXMLEXPORT_TEST(testTdf97648_relativeWidth, "tdf97648_relativeWidth.docx")
516 CPPUNIT_ASSERT_DOUBLES_EQUAL( sal_Int32(7616), getShape(1)->getSize().Width, 10);
517 CPPUNIT_ASSERT_DOUBLES_EQUAL( sal_Int32(8001), getShape(2)->getSize().Width, 10);
518 CPPUNIT_ASSERT_DOUBLES_EQUAL( sal_Int32(4001), getShape(3)->getSize().Width, 10);
519 CPPUNIT_ASSERT_EQUAL( style::ParagraphAdjust_LEFT, static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(getParagraph(6), "ParaAdjust")) );
520 CPPUNIT_ASSERT_DOUBLES_EQUAL( sal_Int32(1600), getShape(4)->getSize().Width, 10);
521 CPPUNIT_ASSERT_EQUAL( style::ParagraphAdjust_RIGHT, static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(getParagraph(8), "ParaAdjust")) );
524 CPPUNIT_ASSERT_EQUAL( sal_Int32(0), getProperty<sal_Int32>(getShape(1), "LeftMargin") );
525 if (!isExported())
527 CPPUNIT_ASSERT_EQUAL_MESSAGE("Text should wrap above/below the line", text::WrapTextMode_NONE, getProperty<text::WrapTextMode>(getShape(1), "Surround"));
528 CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::CENTER, getProperty<sal_Int16>(getShape(2), "HoriOrient"));
529 CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::RIGHT, getProperty<sal_Int16>(getShape(3), "HoriOrient"));
530 CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::LEFT, getProperty<sal_Int16>(getShape(4), "HoriOrient"));
533 uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
534 uno::Reference<container::XIndexAccess> xSections(xTextSectionsSupplier->getTextSections(),
535 uno::UNO_QUERY);
537 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xSections->getCount());
539 uno::Reference<beans::XPropertySet> xTextSection(xSections->getByIndex(2), uno::UNO_QUERY);
540 uno::Reference<text::XTextColumns> xTextColumns
541 = getProperty<uno::Reference<text::XTextColumns>>(xTextSection, "TextColumns");
542 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount());
545 DECLARE_OOXMLEXPORT_TEST(testTdf144362, "tdf144362.odt")
547 uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
548 uno::Reference<container::XIndexAccess> xSections(xTextSectionsSupplier->getTextSections(),
549 uno::UNO_QUERY);
551 // This is difference OK: tdf#107837 extra section added on export to preserve balanced columns.
552 CPPUNIT_ASSERT_GREATEREQUAL(sal_Int32(2), xSections->getCount());
554 uno::Reference<beans::XPropertySet> xTextSection(xSections->getByIndex(1), uno::UNO_QUERY);
555 uno::Reference<text::XTextColumns> xTextColumns
556 = getProperty<uno::Reference<text::XTextColumns>>(xTextSection, "TextColumns");
557 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount());
560 DECLARE_OOXMLEXPORT_TEST(testTdf104061_tableSectionColumns,"tdf104061_tableSectionColumns.docx")
562 CPPUNIT_ASSERT_MESSAGE("There should be two or three pages", getPages() <= 3 );
564 //tdf#95114 - follow style is Text Body - DOCX test
565 uno::Reference< beans::XPropertySet > properties(getStyles("ParagraphStyles")->getByName("annotation subject"), uno::UNO_QUERY);
566 CPPUNIT_ASSERT_EQUAL(OUString("annotation text"), getProperty<OUString>(properties, "FollowStyle"));
569 DECLARE_OOXMLEXPORT_TEST(testTdf46940_dontEquallyDistributeColumns, "tdf46940_dontEquallyDistributeColumns.docx")
571 uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
572 uno::Reference<container::XIndexAccess> xTextSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY);
573 CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xTextSections->getByIndex(0), "DontBalanceTextColumns"));
574 // This was false, columns before a section-page-break were balanced.
575 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xTextSections->getByIndex(2), "DontBalanceTextColumns"));
576 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xTextSections->getByIndex(3), "DontBalanceTextColumns"));
579 CPPUNIT_TEST_FIXTURE(Test, testTdf98700_keepWithNext)
581 loadAndReload("tdf98700_keepWithNext.odt");
582 CPPUNIT_ASSERT_EQUAL(2, getPages());
583 CPPUNIT_ASSERT_EQUAL_MESSAGE("Heading style keeps with next", true, getProperty<bool>(getParagraph(1), "ParaKeepTogether"));
584 CPPUNIT_ASSERT_EQUAL_MESSAGE("Default style doesn't keep with next", false, getProperty<bool>(getParagraph(2), "ParaKeepTogether"));
585 CPPUNIT_ASSERT_EQUAL_MESSAGE("Heading 1 style inherits keeps with next", true, getProperty<bool>(getParagraph(3), "ParaKeepTogether"));
586 CPPUNIT_ASSERT_EQUAL_MESSAGE("Heading 2 style disabled keep with next", false, getProperty<bool>(getParagraph(4), "ParaKeepTogether"));
587 CPPUNIT_ASSERT_EQUAL_MESSAGE("Text Body style toggled off keep with next", false, getProperty<bool>(getParagraph(5), "ParaKeepTogether"));
589 //tdf#95114 - follow style is Text Body - ODT test
590 uno::Reference< beans::XPropertySet > properties(getStyles("ParagraphStyles")->getByName("Heading 1"), uno::UNO_QUERY);
591 CPPUNIT_ASSERT_EQUAL(OUString("Text body"), getProperty<OUString>(properties, "FollowStyle"));
594 // base class to supply a helper method for testHFLinkToPrev
595 class testHFBase : public Test
597 protected:
598 OUString
599 getHFText(const uno::Reference<style::XStyle>& xPageStyle,
600 const OUString &sPropName)
602 auto xTextRange = getProperty< uno::Reference<text::XTextRange> >(
603 xPageStyle, sPropName);
604 return xTextRange->getString();
608 DECLARE_SW_EXPORT_TEST(testHFLinkToPrev, "headerfooter-link-to-prev.docx", nullptr, testHFBase)
610 uno::Reference<container::XNameAccess> xPageStyles = getStyles("PageStyles");
612 // get a page cursor
613 uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
614 uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(
615 xModel->getCurrentController(), uno::UNO_QUERY);
616 uno::Reference<text::XPageCursor> xCursor(
617 xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
619 // get LO page style for page 1, corresponding to docx section 1 first page
620 xCursor->jumpToFirstPage();
621 OUString pageStyleName = getProperty<OUString>(xCursor, "PageStyleName");
622 uno::Reference<style::XStyle> xPageStyle(
623 xPageStyles->getByName(pageStyleName), uno::UNO_QUERY);
624 // check page 1 header & footer text
625 CPPUNIT_ASSERT_EQUAL(OUString("First page header for all sections"),
626 getHFText(xPageStyle, "HeaderTextFirst"));
627 CPPUNIT_ASSERT_EQUAL(OUString("First page footer for section 1 only"),
628 getHFText(xPageStyle, "FooterTextFirst"));
630 // get LO page style for page 2, corresponding to docx section 1
631 xCursor->jumpToPage(2);
632 pageStyleName = getProperty<OUString>(xCursor, "PageStyleName");
633 xPageStyle.set( xPageStyles->getByName(pageStyleName), uno::UNO_QUERY );
634 // check header & footer text
635 CPPUNIT_ASSERT_EQUAL(OUString("Even page header for section 1 only"),
636 getHFText(xPageStyle, "HeaderTextLeft"));
637 CPPUNIT_ASSERT_EQUAL(OUString("Even page footer for all sections"),
638 getHFText(xPageStyle, "FooterTextLeft"));
639 CPPUNIT_ASSERT_EQUAL(OUString("Odd page header for all sections"),
640 getHFText(xPageStyle, "HeaderText"));
641 CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer for section 1 only"),
642 getHFText(xPageStyle, "FooterText"));
644 // get LO page style for page 4, corresponding to docx section 2 first page
645 xCursor->jumpToPage(4);
646 pageStyleName = getProperty<OUString>(xCursor, "PageStyleName");
647 xPageStyle.set( xPageStyles->getByName(pageStyleName), uno::UNO_QUERY );
648 // check header & footer text
649 CPPUNIT_ASSERT_EQUAL(OUString("First page header for all sections"),
650 getHFText(xPageStyle, "HeaderTextFirst"));
651 CPPUNIT_ASSERT_EQUAL(OUString("First page footer for sections 2 and 3 only"),
652 getHFText(xPageStyle, "FooterTextFirst"));
654 // get LO page style for page 5, corresponding to docx section 2
655 xCursor->jumpToPage(5);
656 pageStyleName = getProperty<OUString>(xCursor, "PageStyleName");
657 xPageStyle.set( xPageStyles->getByName(pageStyleName), uno::UNO_QUERY );
658 // check header & footer text
659 CPPUNIT_ASSERT_EQUAL(OUString("Even page header for sections 2 and 3 only"),
660 getHFText(xPageStyle, "HeaderTextLeft"));
661 CPPUNIT_ASSERT_EQUAL(OUString("Even page footer for all sections"),
662 getHFText(xPageStyle, "FooterTextLeft"));
663 CPPUNIT_ASSERT_EQUAL(OUString("Odd page header for all sections"),
664 getHFText(xPageStyle, "HeaderText"));
665 CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer for sections 2 and 3 only"),
666 getHFText(xPageStyle, "FooterText"));
668 // get LO page style for page 7, corresponding to docx section 3 first page
669 xCursor->jumpToPage(7);
670 pageStyleName = getProperty<OUString>(xCursor, "PageStyleName");
671 xPageStyle.set( xPageStyles->getByName(pageStyleName), uno::UNO_QUERY );
672 // check header & footer text
673 CPPUNIT_ASSERT_EQUAL(OUString("First page header for all sections"),
674 getHFText(xPageStyle, "HeaderTextFirst"));
675 CPPUNIT_ASSERT_EQUAL(OUString("First page footer for sections 2 and 3 only"),
676 getHFText(xPageStyle, "FooterTextFirst"));
678 // get LO page style for page 8, corresponding to docx section 3
679 xCursor->jumpToPage(8);
680 pageStyleName = getProperty<OUString>(xCursor, "PageStyleName");
681 xPageStyle.set( xPageStyles->getByName(pageStyleName), uno::UNO_QUERY );
682 // check header & footer text
683 CPPUNIT_ASSERT_EQUAL(OUString("Even page header for sections 2 and 3 only"),
684 getHFText(xPageStyle, "HeaderTextLeft"));
685 CPPUNIT_ASSERT_EQUAL(OUString("Even page footer for all sections"),
686 getHFText(xPageStyle, "FooterTextLeft"));
687 CPPUNIT_ASSERT_EQUAL(OUString("Odd page header for all sections"),
688 getHFText(xPageStyle, "HeaderText"));
689 CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer for sections 2 and 3 only"),
690 getHFText(xPageStyle, "FooterText"));
693 DECLARE_OOXMLEXPORT_TEST(testRhbz988516, "rhbz988516.docx")
695 // The problem was that the list properties of the footer leaked into body
696 CPPUNIT_ASSERT_EQUAL(OUString(), getProperty<OUString>(getParagraph(1), "NumberingStyleName"));
697 CPPUNIT_ASSERT_EQUAL(OUString("Enclosure 3"), getParagraph(2)->getString());
698 CPPUNIT_ASSERT_EQUAL(OUString(), getProperty<OUString>(getParagraph(2), "NumberingStyleName"));
699 CPPUNIT_ASSERT_EQUAL(OUString(), getProperty<OUString>(getParagraph(3), "NumberingStyleName"));
700 CPPUNIT_ASSERT_EQUAL(OUString(), getProperty<OUString>(getParagraph(4), "NumberingStyleName"));
702 // tdf#103975 The problem was that an empty paragraph with page break info was removed.
703 CPPUNIT_ASSERT_EQUAL( 2, getPages() );
706 DECLARE_OOXMLEXPORT_TEST(testTdf103975_notPageBreakB, "tdf103975_notPageBreakB.docx")
708 // turn on View Formatting Marks to see these documents.
709 uno::Reference<beans::XPropertySet> xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(1), "TextSection");
710 CPPUNIT_ASSERT(xTextSection.is());
711 uno::Reference<text::XTextColumns> xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
712 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount());
714 xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(2), "TextSection");
715 CPPUNIT_ASSERT(xTextSection.is());
716 xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
717 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount());
719 xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(3), "TextSection");
720 CPPUNIT_ASSERT(xTextSection.is());
721 xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
722 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount());
724 xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(4), "TextSection");
725 CPPUNIT_ASSERT(xTextSection.is());
726 xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
727 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount());
729 CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty<style::BreakType>(getParagraph(2), "BreakType"));
730 CPPUNIT_ASSERT_EQUAL( 4, getParagraphs() );
731 CPPUNIT_ASSERT_EQUAL( 1, getPages() );
734 DECLARE_OOXMLEXPORT_TEST(testTdf103975_notPageBreakC, "tdf103975_notPageBreakC.docx")
736 // turn on View Formatting Marks to see these documents.
737 uno::Reference<beans::XPropertySet> xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(1), "TextSection");
738 CPPUNIT_ASSERT(xTextSection.is());
739 uno::Reference<text::XTextColumns> xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
740 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount());
742 xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(2), "TextSection");
743 CPPUNIT_ASSERT(xTextSection.is());
744 xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
745 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount());
747 xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(3), "TextSection");
748 CPPUNIT_ASSERT(xTextSection.is());
749 xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
750 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount());
752 xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(4), "TextSection");
753 CPPUNIT_ASSERT(xTextSection.is());
754 xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
755 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount());
757 CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty<style::BreakType>(getParagraph(2), "BreakType"));
758 CPPUNIT_ASSERT_EQUAL( 4, getParagraphs() );
759 CPPUNIT_ASSERT_EQUAL( 1, getPages() );
762 DECLARE_OOXMLEXPORT_TEST(testTdf103975_notPageBreakD, "tdf103975_notPageBreakD.docx")
764 // The problem was that the column break was moving outside of the columns, making a page break.
765 CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty<style::BreakType>(getParagraph(2), "BreakType"));
766 CPPUNIT_ASSERT_EQUAL( 1, getPages() );
769 DECLARE_OOXMLEXPORT_TEST(testTdf103975_notPageBreakE, "tdf103975_notPageBreakE.docx")
771 // The problem was that the column break was getting lost.
772 CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty<style::BreakType>(getParagraph(2), "BreakType"));
775 DECLARE_OOXMLEXPORT_TEST(testTdf112352_nextPageColumns, "tdf112352_nextPageColumns.docx")
777 uno::Reference<beans::XPropertySet> xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(2), "TextSection");
778 uno::Reference<text::XTextColumns> xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
779 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount());
781 xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(3), "TextSection");
782 xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
783 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount());
786 CPPUNIT_TEST_FIXTURE(Test, testTdf109310_endnoteStyleForMSO)
788 loadAndSave("tdf109310_endnoteStyleForMSO.docx");
789 xmlDocUniquePtr pXmlDoc = parseExport("word/endnotes.xml");
790 // Check w:rStyle element has w:val attribute - note that w: is not specified for attribute
791 assertXPath(pXmlDoc, "/w:endnotes/w:endnote[@w:id='2']/w:p/w:r[1]/w:rPr/w:rStyle", "val",
792 "EndnoteCharacters");
795 CPPUNIT_TEST_FIXTURE(Test, testTdf103389)
797 loadAndSave("tdf103389.docx");
798 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
799 // No geometry was exported for the second canvas
800 // Check both canvases' geometry
801 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:inline/a:graphic/a:graphicData/wpg:wgp/wps:wsp/wps:spPr/a:prstGeom", "prst", "rect");
802 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:inline/a:graphic/a:graphicData/wpg:wgp/wps:wsp/wps:spPr/a:prstGeom", "prst", "rect");
805 DECLARE_OOXMLEXPORT_TEST(testTdf84678, "tdf84678.docx")
807 // This was 0, left margin inside a shape+text wasn't imported from DOCX.
808 // 360000 EMU, but layout uses twips.
809 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(567), parseDump("/root/page/body/txt/anchored/fly/infos/prtBounds", "left").toInt32());
813 DECLARE_OOXMLEXPORT_TEST(testTdf103544, "tdf103544.docx")
815 // We have two shapes: a frame and an image
816 CPPUNIT_ASSERT_EQUAL(2, getShapes());
818 // Image was lost because of the frame export
819 uno::Reference<beans::XPropertySet> xImage(getShape(1), uno::UNO_QUERY);
820 auto xGraphic = getProperty<uno::Reference<graphic::XGraphic> >(xImage, "Graphic");
821 CPPUNIT_ASSERT(xGraphic.is());
824 DECLARE_OOXMLEXPORT_TEST(testTdf103573, "tdf103573.docx")
826 // Relative positions to the left or right margin (MS Word naming) was not handled.
827 uno::Reference<beans::XPropertySet> xShapeProperties( getShape(1), uno::UNO_QUERY );
828 sal_Int16 nValue;
829 xShapeProperties->getPropertyValue("HoriOrient") >>= nValue;
830 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not centered horizontally", text::HoriOrientation::CENTER, nValue);
831 xShapeProperties->getPropertyValue("HoriOrientRelation") >>= nValue;
832 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not centered horizontally relatively to left page border", text::RelOrientation::PAGE_LEFT, nValue);
834 xShapeProperties.set( getShape(2), uno::UNO_QUERY );
835 xShapeProperties->getPropertyValue("HoriOrient") >>= nValue;
836 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not centered horizontally", text::HoriOrientation::CENTER, nValue);
837 xShapeProperties->getPropertyValue("HoriOrientRelation") >>= nValue;
838 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not centered horizontally relatively to right page border", text::RelOrientation::PAGE_RIGHT, nValue);
841 DECLARE_OOXMLEXPORT_TEST(testTdf106132, "tdf106132.docx")
843 uno::Reference<beans::XPropertySet> xShape(getShapeByName(u"Frame1"), uno::UNO_QUERY);
844 // This was 250, <wps:bodyPr ... rIns="0" ...> was ignored for an outer shape.
845 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(xShape, "TextRightDistance"));
848 DECLARE_OOXMLEXPORT_TEST(testBnc519228OddBreaks, "bnc519228_odd-breaksB.docx")
850 // Check that all the normal styles are not set as right-only, those should be only those used after odd page breaks.
851 uno::Reference<beans::XPropertySet> defaultStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY);
852 CPPUNIT_ASSERT_EQUAL(uno::Any(style::PageStyleLayout_ALL), defaultStyle->getPropertyValue("PageStyleLayout"));
853 uno::Reference<beans::XPropertySet> firstPage( getStyles("PageStyles")->getByName("First Page"), uno::UNO_QUERY );
854 CPPUNIT_ASSERT_EQUAL(uno::Any(style::PageStyleLayout_ALL), firstPage->getPropertyValue("PageStyleLayout"));
856 OUString page1StyleName = getProperty<OUString>( getParagraph( 1, "This is the first page." ), "PageDescName");
857 uno::Reference<beans::XPropertySet> page1Style(getStyles("PageStyles")->getByName(page1StyleName), uno::UNO_QUERY);
858 CPPUNIT_ASSERT_EQUAL(uno::Any(style::PageStyleLayout_RIGHT), page1Style->getPropertyValue("PageStyleLayout"));
859 getParagraphOfText( 1, getProperty< uno::Reference<text::XText> >(page1Style, "HeaderText"), "This is the header for odd pages");
861 // Page2 comes from follow of style for page 1 and should be a normal page. Also check the two page style have the same properties,
862 // since page style for page1 was created from page style for page 2.
863 OUString page2StyleName = getProperty<OUString>( page1Style, "FollowStyle" );
864 uno::Reference<beans::XPropertySet> page2Style(getStyles("PageStyles")->getByName(page2StyleName), uno::UNO_QUERY);
865 CPPUNIT_ASSERT_EQUAL(uno::Any(style::PageStyleLayout_ALL), page2Style->getPropertyValue("PageStyleLayout"));
866 getParagraphOfText( 1, getProperty< uno::Reference<text::XText> >(page2Style, "HeaderTextLeft"), "This is the even header");
867 getParagraphOfText( 1, getProperty< uno::Reference<text::XText> >(page2Style, "HeaderTextRight"), "This is the header for odd pages");
868 CPPUNIT_ASSERT_EQUAL(getProperty<sal_Int32>(page1Style, "TopMargin"), getProperty<sal_Int32>(page2Style, "TopMargin"));
870 OUString page5StyleName = getProperty<OUString>( getParagraph( 4, "Then an odd break after an odd page, should lead us to page #5." ), "PageDescName");
871 uno::Reference<beans::XPropertySet> page5Style(getStyles("PageStyles")->getByName(page5StyleName), uno::UNO_QUERY);
872 CPPUNIT_ASSERT_EQUAL(uno::Any(style::PageStyleLayout_RIGHT), page5Style->getPropertyValue("PageStyleLayout"));
873 getParagraphOfText( 1, getProperty< uno::Reference<text::XText> >(page5Style, "HeaderText"), "This is the header for odd pages");
876 CPPUNIT_TEST_FIXTURE(Test, testTdf79329)
878 auto verify = [this]() {
879 uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
880 uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
881 // This was 1: only the inner, not the outer table was created.
882 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xTables->getCount());
884 createSwDoc("tdf79329.docx");
885 verify();
886 saveAndReload("Office Open XML Text");
887 verify();
890 CPPUNIT_TEST_FIXTURE(Test, testTdf103982)
892 loadAndReload("tdf103982.docx");
893 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
894 sal_Int32 nDistB = getXPath(pXmlDoc, "//wp:anchor", "distB").toInt32();
895 // This was -260350, which is not a valid value for an unsigned type.
896 CPPUNIT_ASSERT(nDistB >= 0);
898 // tdf#115670 the shadow should not be enabled (no on="t")
899 uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY);
900 CPPUNIT_ASSERT(!getProperty<bool>(xPropertySet, "Shadow"));
903 CPPUNIT_TEST_FIXTURE(Test, testTdf104115)
905 loadAndSave("tdf104115.docx");
906 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
907 // This found 0 nodes: the custom geometry was not written for the Bezier
908 // curve -> Word refused to open the document.
909 assertXPath(pXmlDoc, "//a:custGeom", 1);
912 DECLARE_OOXMLEXPORT_TEST(testTdf103651, "tdf103651.docx")
914 uno::Reference<beans::XPropertySet> xTextField = getProperty< uno::Reference<beans::XPropertySet> >(getRun(getParagraph(1), 1), "TextField");
915 OUString sContent;
916 xTextField->getPropertyValue("Content") >>= sContent;
917 // Comment in the first paragraph should not have smiley ( 0xf04a ).
918 CPPUNIT_ASSERT_EQUAL( sal_Int32( -1 ) , sContent.indexOf( u'\xf04a' ));
920 // this document has a w:kern setting in the DocDefault character properties. Ensure it applies.
921 CPPUNIT_ASSERT(getProperty<bool>(getRun(getParagraph(1), 1), "CharAutoKerning"));
924 CPPUNIT_TEST_FIXTURE(Test, testTdf99227)
926 loadAndSave("tdf99227.docx");
927 // A drawing anchored as character to a footnote caused write past end of document.xml at export to docx.
928 // After that, importing after export failed with
929 // SAXParseException: '[word/document.xml line 2]: Extra content at the end of the document', Stream 'word / document.xml',
930 // and before commit ebf767eeb2a169ba533e1b2ffccf16f41d95df35, the drawing was silently lost.
931 xmlDocUniquePtr pXmlDoc = parseExport("word/footnotes.xml");
933 assertXPath(pXmlDoc, "//w:footnote/w:p/w:r/w:drawing", 1);
936 DECLARE_OOXMLEXPORT_TEST(testTdf37153, "tdf37153_considerWrapOnObjPos.docx")
938 CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGH, getProperty<text::WrapTextMode>(getShape(1), "Surround"));
940 uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
941 uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
942 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
943 CPPUNIT_ASSERT_EQUAL(text::VertOrientation::BOTTOM, getProperty<sal_Int16>(xTable->getCellByName("A1"), "VertOrient"));
945 //For MSO compatibility, the textbox should be at the top of the cell, not at the bottom - despite VertOrientation::BOTTOM
946 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
947 sal_Int32 nFlyTop = getXPath(pXmlDoc, "/root/page/body/tab/row/cell[1]/txt/anchored/fly/infos/bounds", "top").toInt32();
948 CPPUNIT_ASSERT_MESSAGE("FlyTop should be 2865, not 5649", nFlyTop < sal_Int32(3000));
949 sal_Int32 nTextTop = getXPath(pXmlDoc, "/root/page/body/tab/row/cell[2]/txt[1]/infos/bounds", "top").toInt32();
950 CPPUNIT_ASSERT_MESSAGE("TextTop should be 3856", nTextTop > 3000);
953 DECLARE_OOXMLEXPORT_TEST(testTdf112446_frameStyle, "tdf112446_frameStyle.docx")
955 CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::NONE, getProperty<sal_Int16>(getShape(1), "HoriOrient"));
958 DECLARE_OOXMLEXPORT_TEST(testTdf82173_footnoteStyle, "tdf82173_footnoteStyle.docx")
960 uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
961 uno::Reference<container::XIndexAccess> xFootnotes = xFootnotesSupplier->getFootnotes();
963 uno::Reference<text::XText> xFootnoteText;
964 xFootnotes->getByIndex(0) >>= xFootnoteText;
965 // This was footnote text, which didn't match with newly created footnotes
966 CPPUNIT_ASSERT_EQUAL(OUString("Footnote"), getProperty<OUString>(getParagraphOfText(1, xFootnoteText), "ParaStyleName"));
968 uno::Reference<beans::XPropertySet> xPageStyle(getStyles("CharacterStyles")->getByName("Footnote Characters"), uno::UNO_QUERY);
969 CPPUNIT_ASSERT_EQUAL( sal_Int32(58), getProperty< sal_Int32 >(xPageStyle, "CharEscapementHeight") );
970 CPPUNIT_ASSERT_EQUAL( Color(0x00FF00), getProperty<Color>(xPageStyle, "CharColor"));
972 xPageStyle.set(getStyles("CharacterStyles")->getByName("Footnote anchor"), uno::UNO_QUERY);
973 CPPUNIT_ASSERT_EQUAL( sal_Int32(58), getProperty< sal_Int32 >(xPageStyle, "CharEscapementHeight") );
974 CPPUNIT_ASSERT_EQUAL( Color(0x00FF00), getProperty<Color>(xPageStyle, "CharColor"));
976 //tdf#118361 - in RTL locales, the footnote separator should still be left aligned.
977 uno::Any aPageStyle = getStyles("PageStyles")->getByName("Standard");
978 CPPUNIT_ASSERT_EQUAL_MESSAGE("Footnote separator LTR", sal_Int16(0), getProperty<sal_Int16>(aPageStyle, "FootnoteLineAdjust"));
981 DECLARE_OOXMLEXPORT_TEST(testTdf82173_endnoteStyle, "tdf82173_endnoteStyle.docx")
983 uno::Reference<text::XEndnotesSupplier> xEndnotesSupplier(mxComponent, uno::UNO_QUERY);
984 uno::Reference<container::XIndexAccess> xEndnotes = xEndnotesSupplier->getEndnotes();
985 uno::Reference<text::XFootnote> xEndnote;
986 xEndnotes->getByIndex(0) >>= xEndnote;
987 // character properties were previously not assigned to the footnote/endnote in-text anchor.
988 CPPUNIT_ASSERT_EQUAL( 24.0f, getProperty< float >(xEndnote->getAnchor(), "CharHeight") );
989 CPPUNIT_ASSERT_EQUAL( Color(0xFF0000), getProperty<Color>(xEndnote->getAnchor(), "CharColor"));
991 uno::Reference<text::XText> xEndnoteText;
992 xEndnotes->getByIndex(0) >>= xEndnoteText;
993 // This was Endnote Symbol
994 CPPUNIT_ASSERT_EQUAL(OUString("Endnote"), getProperty<OUString>(getParagraphOfText(1, xEndnoteText), "ParaStyleName"));
995 CPPUNIT_ASSERT_EQUAL(Color(0x993300), getProperty<Color>(getParagraphOfText(1, xEndnoteText), "CharColor"));
997 uno::Reference<beans::XPropertySet> xPageStyle(getStyles("CharacterStyles")->getByName("Endnote Characters"), uno::UNO_QUERY);
998 CPPUNIT_ASSERT_EQUAL( sal_Int32(58), getProperty< sal_Int32 >(xPageStyle, "CharEscapementHeight") );
999 CPPUNIT_ASSERT_EQUAL( Color(0xFF00FF), getProperty<Color>(xPageStyle, "CharColor"));
1001 xPageStyle.set(getStyles("CharacterStyles")->getByName("Endnote anchor"), uno::UNO_QUERY);
1002 CPPUNIT_ASSERT_EQUAL( sal_Int32(58), getProperty< sal_Int32 >(xPageStyle, "CharEscapementHeight") );
1003 CPPUNIT_ASSERT_EQUAL( Color(0xFF00FF), getProperty<Color>(xPageStyle, "CharColor"));
1006 CPPUNIT_TEST_FIXTURE(Test, testTdf55427_footnote2endnote)
1008 loadAndReload("tdf55427_footnote2endnote.odt");
1009 CPPUNIT_ASSERT_EQUAL(4, getPages());
1010 uno::Reference<beans::XPropertySet> xPageStyle(getStyles("ParagraphStyles")->getByName("Footnote"), uno::UNO_QUERY);
1011 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Footnote style is rose color", Color(0xFF007F), getProperty<Color>(xPageStyle, "CharColor"));
1012 xPageStyle.set(getStyles("ParagraphStyles")->getByName("Endnote"), uno::UNO_QUERY);
1013 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Endnote style is cyan3 color", Color(0x2BD0D2), getProperty<Color>(xPageStyle, "CharColor"));
1015 SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
1016 CPPUNIT_ASSERT(pTextDoc);
1017 SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
1018 // The footnote numbering type of ARABIC will not transfer over when those footnotes are converted to endnotes.
1019 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Footnote numbering type", SVX_NUM_ARABIC, pDoc->GetFootnoteInfo().m_aFormat.GetNumberingType() );
1020 // The original document has a real endnote using ROMAN_LOWER numbering, so that setting MUST remain unchanged.
1021 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Endnote numbering type", SVX_NUM_ROMAN_LOWER, pDoc->GetEndNoteInfo().m_aFormat.GetNumberingType() );
1023 uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
1024 uno::Reference<container::XIndexAccess> xFootnotes = xFootnotesSupplier->getFootnotes();
1026 uno::Reference<text::XEndnotesSupplier> xEndnotesSupplier(mxComponent, uno::UNO_QUERY);
1027 uno::Reference<container::XIndexAccess> xEndnotes = xEndnotesSupplier->getEndnotes();
1028 uno::Reference<text::XFootnote> xEndnote;
1029 xEndnotes->getByIndex(0) >>= xEndnote;
1030 uno::Reference<text::XText> xEndnoteText;
1031 xEndnotes->getByIndex(0) >>= xEndnoteText;
1033 // ODT footnote-at-document-end's closest DOCX match is an endnote, so the two imports will not exactly match by design.
1034 if (!isExported())
1036 CPPUNIT_ASSERT_EQUAL_MESSAGE( "original footnote count", sal_Int32(5), xFootnotes->getCount() );
1037 CPPUNIT_ASSERT_EQUAL_MESSAGE( "original endnote count", sal_Int32(1), xEndnotes->getCount() );
1039 uno::Reference<text::XFootnote> xFootnote;
1040 xFootnotes->getByIndex(0) >>= xFootnote;
1041 CPPUNIT_ASSERT_EQUAL_MESSAGE( "original footnote's number", OUString("1"), xFootnote->getAnchor()->getString() );
1042 CPPUNIT_ASSERT_EQUAL_MESSAGE( "original endnote's number", OUString("i"), xEndnote->getAnchor()->getString() );
1044 uno::Reference<text::XText> xFootnoteText;
1045 xFootnotes->getByIndex(0) >>= xFootnoteText;
1046 CPPUNIT_ASSERT_EQUAL_MESSAGE( "original footnote style", OUString("Footnote"), getProperty<OUString>(getParagraphOfText(1, xFootnoteText), "ParaStyleName") );
1047 CPPUNIT_ASSERT_EQUAL_MESSAGE( "original endnote style", OUString("Endnote"), getProperty<OUString>(getParagraphOfText(1, xEndnoteText), "ParaStyleName") );
1049 else
1051 // These asserted items are major differences in the conversion from footnote to endnote, NOT necessary conditions for a proper functioning document.
1052 CPPUNIT_ASSERT_EQUAL_MESSAGE( "At-Document-End footnotes were converted into endnotes", sal_Int32(0), xFootnotes->getCount() );
1053 CPPUNIT_ASSERT_EQUAL_MESSAGE( "At-Document-End footnotes became endnotes", sal_Int32(6), xEndnotes->getCount() );
1055 CPPUNIT_ASSERT_EQUAL_MESSAGE( "converted footnote's number", OUString("i"), xEndnote->getAnchor()->getString() );
1056 xEndnotes->getByIndex(4) >>= xEndnote;
1057 CPPUNIT_ASSERT_EQUAL_MESSAGE( "original endnote's new number", OUString("v"), xEndnote->getAnchor()->getString() );
1059 CPPUNIT_ASSERT_EQUAL_MESSAGE( "retained footnote style", OUString("Footnote"), getProperty<OUString>(getParagraphOfText(1, xEndnoteText), "ParaStyleName") );
1060 xEndnotes->getByIndex(4) >>= xEndnoteText;
1061 CPPUNIT_ASSERT_EQUAL_MESSAGE( "original endnote style", OUString("Endnote"), getProperty<OUString>(getParagraphOfText(1, xEndnoteText), "ParaStyleName") );
1065 DECLARE_OOXMLEXPORT_TEST(testTdf104162, "tdf104162.docx")
1067 // This crashed: the comment field contained a table with a <w:hideMark/>.
1068 uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
1069 uno::Reference<container::XElementAccess> xTextFields(xTextFieldsSupplier->getTextFields());
1070 CPPUNIT_ASSERT(xTextFields->hasElements());
1073 DECLARE_OOXMLEXPORT_TEST(testTdf104150, "tdf104150.docx")
1075 uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY);
1076 // This was 0xff0000, i.e. red: background shape wasn't ignored.
1077 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-1), getProperty<sal_Int32>(xPageStyle, "BackColor"));
1080 DECLARE_OOXMLEXPORT_TEST(testTdf103976, "tdf103976.docx")
1082 uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
1083 uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
1084 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
1085 uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
1086 // This was 0, table style inheritance went wrong and w:afterLines had priority over w:after.
1087 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(convertTwipToMm100(60)), getProperty<sal_Int32>(getParagraphOfText(1, xCell->getText()), "ParaBottomMargin"));
1089 // tdf#116549: heading 2 style should not have a bottom border.
1090 uno::Reference<beans::XPropertySet> xStyle(getStyles("ParagraphStyles")->getByName("Heading 2"), uno::UNO_QUERY);
1091 table::BorderLine2 aBottomBorder = getProperty<table::BorderLine2>(xStyle, "BottomBorder");
1092 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), aBottomBorder.LineWidth);
1095 DECLARE_OOXMLEXPORT_TEST(testTdf106001, "tdf106001.docx")
1097 // This was 0 (1 on UI), while Word treats outliers as 100 (outlier = not in [1..600])
1098 CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16>( 100 ), getProperty<sal_Int16>(getRun(getParagraph(1), 1), "CharScaleWidth" ));
1101 CPPUNIT_TEST_FIXTURE(Test, testTdf106001_2)
1103 loadAndSave("tdf106001-2.odt");
1104 CPPUNIT_ASSERT_EQUAL(1, getPages());
1105 // In test ODT CharScaleWidth = 900, this was not changed upon OOXML export to stay in [1..600], now it's clamped to 600
1106 // Note: we disregard what's set in pPr / rPr and only care about r / rPr
1107 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
1108 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:rPr/w:w","val","600");
1111 DECLARE_OOXMLEXPORT_TEST(testTdf99074, "tdf99074.docx")
1113 uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
1114 uno::Reference<view::XViewSettingsSupplier> const xController(
1115 xModel->getCurrentController(), uno::UNO_QUERY);
1116 uno::Reference<beans::XPropertySet> const xViewSettings(
1117 xController->getViewSettings());
1119 // The behavior changed - Word 2013 and 2016 ignore this setting on
1120 // import, and instead honor the user's setting.
1121 // Let's ignore the <w:view w:val="web"/> too.
1122 CPPUNIT_ASSERT(!getProperty<bool>(xViewSettings, "ShowOnlineLayout"));
1125 DECLARE_OOXMLEXPORT_TEST(testDefaultSectBreakCols, "default-sect-break-cols.docx")
1127 // First problem: the first two paragraphs did not have their own text section, so the whole document had two columns.
1128 uno::Reference<beans::XPropertySet> xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(1, "First."), "TextSection");
1129 CPPUNIT_ASSERT(xTextSection.is());
1130 uno::Reference<text::XTextColumns> xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
1131 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount());
1133 // Second problem: the page style had two columns, while it shouldn't have any.
1134 uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY);
1135 xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xPageStyle, "TextColumns");
1136 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount());
1137 // Check for the Column Separator value.It should be FALSE as the document does not contain separator line.
1138 bool bValue = getProperty< bool >(xTextColumns, "SeparatorLineIsOn");
1139 CPPUNIT_ASSERT(!bValue) ;
1142 DECLARE_OOXMLEXPORT_TEST(testMultiColumnSeparator, "multi-column-separator-with-line.docx")
1144 uno::Reference<beans::XPropertySet> xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(1, "First data."), "TextSection");
1145 CPPUNIT_ASSERT(xTextSection.is());
1146 uno::Reference<text::XTextColumns> xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
1147 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount());
1148 // Check for the Column Separator value.It should be TRUE as the document contains separator line.
1149 bool bValue = getProperty< bool >(xTextColumns, "SeparatorLineIsOn");
1150 CPPUNIT_ASSERT(bValue);
1153 DECLARE_OOXMLEXPORT_TEST(testUnbalancedColumns, "unbalanced-columns.docx")
1155 uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
1156 uno::Reference<container::XIndexAccess> xTextSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY);
1157 // This was false, last section was balanced, but it's unbalanced in Word.
1158 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xTextSections->getByIndex(2), "DontBalanceTextColumns"));
1161 DECLARE_OOXMLEXPORT_TEST(testTdf121670_columnsInSectionsOnly, "tdf121670_columnsInSectionsOnly.docx")
1163 uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
1164 uno::Reference<container::XIndexAccess> xTextSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY);
1165 CPPUNIT_ASSERT_EQUAL_MESSAGE("DontBalanceTextColumns?", true, getProperty<bool>(xTextSections->getByIndex(0), "DontBalanceTextColumns"));
1167 uno::Reference<beans::XPropertySet> xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(2), "TextSection");
1168 CPPUNIT_ASSERT(xTextSection.is());
1169 uno::Reference<text::XTextColumns> xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
1170 CPPUNIT_ASSERT_EQUAL_MESSAGE("# of columns", sal_Int16(3), xTextColumns->getColumnCount());
1172 xTextSection.set( getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(3), "TextSection") );
1173 CPPUNIT_ASSERT(xTextSection.is());
1174 xTextColumns.set( getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns") );
1175 CPPUNIT_ASSERT_EQUAL_MESSAGE("# of columns", sal_Int16(0), xTextColumns->getColumnCount());
1178 CPPUNIT_TEST_FIXTURE(Test, testTdf106492)
1180 loadAndSave("tdf106492.docx");
1181 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
1182 // This was 4: an additional sectPr was added to the document.
1183 assertXPath(pXmlDoc, "//w:sectPr", 3);
1186 DECLARE_OOXMLEXPORT_TEST(testTdf107104, "tdf107104.docx")
1188 CPPUNIT_ASSERT(getShape(1)->getSize().Width > 0);
1189 // This failed: the second arrow was invisible because it had zero width.
1190 CPPUNIT_ASSERT(getShape(2)->getSize().Width > 0);
1193 DECLARE_OOXMLEXPORT_TEST(testTdf107033, "tdf107033.docx")
1195 uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY);
1196 // This was 0: footnote separator was disabled even in case the document
1197 // had no footnotes.
1198 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(25), getProperty<sal_Int32>(xPageStyle, "FootnoteLineRelativeWidth"));
1201 #if HAVE_MORE_FONTS
1202 CPPUNIT_TEST_FIXTURE(Test, testTdf107889)
1204 auto verify = [this]() {
1205 // This was 1, multi-page table was imported as a non-split fly.
1206 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
1207 assertXPath(pXmlDoc, "//tab", 2);
1209 createSwDoc("tdf107889.docx");
1210 verify();
1211 saveAndReload("Office Open XML Text");
1212 verify();
1214 #endif
1216 CPPUNIT_TEST_FIXTURE(Test, testTdf107837)
1218 loadAndReload("tdf107837.odt");
1219 CPPUNIT_ASSERT_EQUAL(1, getPages());
1220 uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
1221 uno::Reference<container::XIndexAccess> xTextSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY);
1222 // This was true, a balanced section from ODF turned into a non-balanced one after OOXML roundtrip.
1223 CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xTextSections->getByIndex(0), "DontBalanceTextColumns"));
1226 CPPUNIT_TEST_FIXTURE(Test, testTdf107684)
1228 loadAndReload("tdf107684.odt");
1229 CPPUNIT_ASSERT_EQUAL(1, getPages());
1230 xmlDocUniquePtr pXmlDoc = parseExport("word/styles.xml");
1231 // This was 1, <w:outlineLvl> was duplicated for Heading1.
1232 assertXPath(pXmlDoc, "//w:style[@w:styleId='Heading1']/w:pPr/w:outlineLvl", 1);
1235 CPPUNIT_TEST_FIXTURE(Test, testTdf107618)
1237 loadAndReload("tdf107618.doc");
1238 // This was false, header was lost on export.
1239 uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY);
1240 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xPageStyle, "HeaderIsOn"));
1243 DECLARE_OOXMLEXPORT_TEST(testTdf108682, "tdf108682.docx")
1245 auto aLineSpacing = getProperty<style::LineSpacing>(getParagraph(1), "ParaLineSpacing");
1246 // This was style::LineSpacingMode::PROP.
1247 CPPUNIT_ASSERT_EQUAL(style::LineSpacingMode::FIX, aLineSpacing.Mode);
1248 // 260 twips in mm100, this was a negative value.
1249 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(459), aLineSpacing.Height);
1252 DECLARE_OOXMLEXPORT_TEST(testTdf100075, "tdf100075.docx")
1254 uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
1255 uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
1257 // There are two frames in document
1258 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xIndexAccess->getCount());
1260 uno::Reference<beans::XPropertySet> xFrame1(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
1261 uno::Reference<beans::XPropertySet> xFrame2(xIndexAccess->getByIndex(1), uno::UNO_QUERY);
1263 // Ensure that frame#1 height is more that frame#2: if no hRul attribute
1264 // defined, MS Word will use hRul=auto if height is not defined,
1265 // and hRul=atLeast if height is provided. So frame#1 should be higher
1266 CPPUNIT_ASSERT(getProperty<sal_Int32>(xFrame1, "Height") > getProperty<sal_Int32>(xFrame2, "Height"));
1269 DECLARE_OOXMLEXPORT_TEST(testTdf105095, "tdf105095.docx")
1271 uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
1272 uno::Reference<container::XIndexAccess> xFootnotes = xFootnotesSupplier->getFootnotes();
1273 uno::Reference<text::XTextRange> xTextRange(xFootnotes->getByIndex(0), uno::UNO_QUERY);
1274 // This failed, tab between the footnote number and the footnote content
1275 // was lost on import.
1276 CPPUNIT_ASSERT_EQUAL( OUString("\tfootnote"), xTextRange->getString() );
1279 CPPUNIT_TEST_FIXTURE(Test, testTdf106062_nonHangingFootnote)
1281 loadAndReload("tdf106062_nonHangingFootnote.odt");
1282 CPPUNIT_ASSERT_EQUAL(1, getPages());
1283 uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
1284 uno::Reference<container::XIndexAccess> xFootnotes = xFootnotesSupplier->getFootnotes();
1285 uno::Reference<text::XTextRange> xTextRange(xFootnotes->getByIndex(0), uno::UNO_QUERY);
1286 // This failed, tab between the footnote number and the footnote content was lost on import.
1287 CPPUNIT_ASSERT_MESSAGE( "Footnote starts with a tab", xTextRange->getString().startsWith("\t") );
1290 DECLARE_OOXMLEXPORT_TEST( testActiveXTextfield, "activex_textbox.docx" )
1292 uno::Reference<drawing::XControlShape> xControlShape( getShape(1), uno::UNO_QUERY );
1293 CPPUNIT_ASSERT( xControlShape.is() );
1295 // Check control type
1296 uno::Reference<beans::XPropertySet> xPropertySet( xControlShape->getControl(), uno::UNO_QUERY );
1297 uno::Reference<lang::XServiceInfo> xServiceInfo( xPropertySet, uno::UNO_QUERY );
1298 CPPUNIT_ASSERT_EQUAL( true, bool( xServiceInfo->supportsService ( "com.sun.star.form.component.TextField" ) ) );
1300 // Check textfield is multi-line
1301 CPPUNIT_ASSERT_EQUAL( true, getProperty<bool>(xPropertySet, "MultiLine") );
1303 uno::Reference<drawing::XControlShape> xControlShape2( getShape(2), uno::UNO_QUERY );
1304 CPPUNIT_ASSERT( xControlShape2.is() );
1306 // Check control type
1307 uno::Reference<beans::XPropertySet> xPropertySet2( xControlShape2->getControl(), uno::UNO_QUERY );
1308 uno::Reference<lang::XServiceInfo> xServiceInfo2( xPropertySet2, uno::UNO_QUERY );
1309 CPPUNIT_ASSERT_EQUAL( true, bool( xServiceInfo2->supportsService ( "com.sun.star.form.component.TextField" ) ) );
1311 // Check textfield is single-line
1312 CPPUNIT_ASSERT_EQUAL( false, getProperty<bool>(xPropertySet2, "MultiLine") );
1314 // Don't open in design mode when form controls exist
1315 uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
1316 uno::Reference<view::XFormLayerAccess> xFormLayerAccess(xModel->getCurrentController(), uno::UNO_QUERY);
1317 CPPUNIT_ASSERT( !xFormLayerAccess->isFormDesignMode() );
1320 DECLARE_OOXMLEXPORT_TEST( testActiveXCheckbox, "activex_checkbox.docx" )
1322 uno::Reference<drawing::XControlShape> xControlShape( getShape(1), uno::UNO_QUERY );
1323 CPPUNIT_ASSERT( xControlShape.is() );
1325 // Check control type
1326 uno::Reference<beans::XPropertySet> xPropertySet( xControlShape->getControl(), uno::UNO_QUERY );
1327 uno::Reference<lang::XServiceInfo> xServiceInfo( xPropertySet, uno::UNO_QUERY );
1328 CPPUNIT_ASSERT_EQUAL( true, bool( xServiceInfo->supportsService( "com.sun.star.form.component.CheckBox" ) ) );
1330 // Check custom label
1331 CPPUNIT_ASSERT_EQUAL( OUString( "Custom Caption" ), getProperty<OUString>(xPropertySet, "Label") );
1333 // Check background color (highlight system color)
1334 CPPUNIT_ASSERT_EQUAL( Color( 0x316AC5 ), getProperty<Color>(xPropertySet, "BackgroundColor") );
1336 // Check Text color (active border system color)
1337 CPPUNIT_ASSERT_EQUAL(Color(0xD4D0C8), getProperty<Color>(xPropertySet, "TextColor"));
1339 // Check state of the checkbox
1340 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), getProperty<sal_Int16>(xPropertySet, "State"));
1342 // Check anchor type
1343 uno::Reference<beans::XPropertySet> xPropertySet2(xControlShape, uno::UNO_QUERY);
1344 CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER,getProperty<text::TextContentAnchorType>(xPropertySet2,"AnchorType"));
1347 CPPUNIT_TEST_FIXTURE(Test, testActiveXControlAlign)
1349 loadAndReload("activex_control_align.odt");
1350 CPPUNIT_ASSERT_EQUAL(2, getShapes());
1351 CPPUNIT_ASSERT_EQUAL(1, getPages());
1352 // First check box aligned as a floating object
1353 uno::Reference<drawing::XControlShape> xControlShape(getShape(1), uno::UNO_QUERY);
1354 CPPUNIT_ASSERT(xControlShape.is());
1356 // Check whether we have the right control
1357 uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
1358 uno::Reference<lang::XServiceInfo> xServiceInfo(xPropertySet, uno::UNO_QUERY);
1359 CPPUNIT_ASSERT_EQUAL(true, bool(xServiceInfo->supportsService( "com.sun.star.form.component.CheckBox")));
1360 CPPUNIT_ASSERT_EQUAL(OUString("Floating Check Box"), getProperty<OUString>(xPropertySet, "Label"));
1362 // Check anchor type
1363 uno::Reference<beans::XPropertySet> xPropertySet2(xControlShape, uno::UNO_QUERY);
1364 CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER,getProperty<text::TextContentAnchorType>(xPropertySet2,"AnchorType"));
1366 // Also check position and size
1367 uno::Reference<drawing::XShape> xShape(xControlShape, uno::UNO_QUERY);
1368 CPPUNIT_ASSERT(xShape.is());
1369 CPPUNIT_ASSERT_EQUAL(sal_Int32(4470), xShape->getSize().Width);
1370 CPPUNIT_ASSERT_EQUAL(sal_Int32(1427), xShape->getSize().Height);
1371 CPPUNIT_ASSERT_EQUAL(sal_Int32(5126), xShape->getPosition().X);
1372 CPPUNIT_ASSERT_EQUAL(sal_Int32(2341), xShape->getPosition().Y);
1374 // Second check box aligned inline / as character
1375 xControlShape.set(getShape(2), uno::UNO_QUERY);
1377 // Check whether we have the right control
1378 xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
1379 xServiceInfo.set(xPropertySet, uno::UNO_QUERY);
1380 CPPUNIT_ASSERT_EQUAL(true, bool(xServiceInfo->supportsService("com.sun.star.form.component.CheckBox")));
1381 CPPUNIT_ASSERT_EQUAL(OUString("Inline Check Box"), getProperty<OUString>(xPropertySet, "Label"));
1383 // Check anchor type
1384 xPropertySet2.set(xControlShape, uno::UNO_QUERY);
1385 CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER,getProperty<text::TextContentAnchorType>(xPropertySet2,"AnchorType"));
1386 CPPUNIT_ASSERT_EQUAL(sal_Int32(text::VertOrientation::TOP),getProperty<sal_Int32>(xPropertySet2,"VertOrient"));
1388 // Also check position and size
1389 xShape.set(xControlShape, uno::UNO_QUERY);
1390 CPPUNIT_ASSERT(xShape.is());
1391 CPPUNIT_ASSERT_EQUAL(sal_Int32(4410), xShape->getSize().Width);
1392 CPPUNIT_ASSERT_EQUAL(sal_Int32(1083), xShape->getSize().Height);
1393 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xShape->getPosition().X);
1394 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1085), xShape->getPosition().Y);
1396 // Also check the specific OOXML elements
1397 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
1398 CPPUNIT_ASSERT(pXmlDoc);
1399 // For inline controls use w:object as parent element and pictureFrame shapetype
1400 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:object", 1);
1401 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:object/v:shapetype", "spt", "75");
1402 // For floating controls use w:pict as parent element and hostControl shapetype
1403 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r[1]/w:pict", 1);
1404 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r[1]/w:pict/v:shapetype", "spt", "201");
1406 // Have different shape ids
1407 CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:object/v:shape", "id") !=
1408 getXPath(pXmlDoc, "/w:document/w:body/w:p/w:r[1]/w:pict/v:shape", "id"));
1411 DECLARE_OOXMLEXPORT_TEST(testTdf109184, "tdf109184.docx")
1413 uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
1414 uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
1415 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
1417 // Before table background color was white, should be transparent (auto).
1418 uno::Reference<text::XTextRange> xCell1(xTable->getCellByName("A1"), uno::UNO_QUERY);
1419 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-1), getProperty<sal_Int32>(xCell1, "BackColor"));
1421 // Cell with auto color but with 15% fill, shouldn't be transparent.
1422 uno::Reference<text::XTextRange> xCell2(xTable->getCellByName("B1"), uno::UNO_QUERY);
1423 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xd8d8d8), getProperty<sal_Int32>(xCell2, "BackColor"));
1425 // Cell with color defined (red).
1426 uno::Reference<text::XTextRange> xCell3(xTable->getCellByName("A2"), uno::UNO_QUERY);
1427 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xff0000), getProperty<sal_Int32>(xCell3, "BackColor"));
1430 CPPUNIT_TEST_FIXTURE(Test, testTdf111964)
1432 loadAndSave("tdf111964.docx");
1433 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
1434 // Unicode spaces that are not XML whitespace must not be trimmed
1435 static constexpr OUStringLiteral sWSReference = u"\u2002\u2002\u2002\u2002\u2002";
1436 assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:r[6]/w:t", sWSReference);
1439 DECLARE_OOXMLEXPORT_TEST(testWatermark, "watermark-shapetype.docx")
1441 uno::Reference<drawing::XShape> xShape1(getShape(1), uno::UNO_QUERY);
1442 CPPUNIT_ASSERT(xShape1.is());
1443 uno::Reference<beans::XPropertySet> xPropertySet1(xShape1, uno::UNO_QUERY);
1445 uno::Reference<drawing::XShape> xShape2(getShape(2), uno::UNO_QUERY);
1446 CPPUNIT_ASSERT(xShape2.is());
1447 uno::Reference<beans::XPropertySet> xPropertySet2(xShape2, uno::UNO_QUERY);
1449 CPPUNIT_ASSERT_EQUAL(xPropertySet1->getPropertyValue("TextAutoGrowHeight"), xPropertySet2->getPropertyValue("TextAutoGrowHeight"));
1452 CPPUNIT_TEST_FIXTURE(Test, testActiveXControlAtRunEnd)
1454 loadAndReload("activex_control_at_run_end.odt");
1455 CPPUNIT_ASSERT_EQUAL(2, getShapes());
1456 CPPUNIT_ASSERT_EQUAL(1, getPages());
1457 // Two issues were here:
1458 // 1) second shape was not export (it is anchored to the end of the run)
1459 // 2) inline property was inherited to the second shape by mistake
1461 // First checkbox is the inlined one
1462 uno::Reference<drawing::XControlShape> xControlShape(getShape(1), uno::UNO_QUERY);
1463 CPPUNIT_ASSERT(xControlShape.is());
1465 // Check whether we have the right control
1466 uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
1467 uno::Reference<lang::XServiceInfo> xServiceInfo(xPropertySet, uno::UNO_QUERY);
1468 CPPUNIT_ASSERT_EQUAL(true, bool(xServiceInfo->supportsService( "com.sun.star.form.component.CheckBox")));
1469 CPPUNIT_ASSERT_EQUAL(OUString("Inline Checkbox"), getProperty<OUString>(xPropertySet, "Label"));
1471 // Check anchor type
1472 uno::Reference<beans::XPropertySet> xPropertySet2(xControlShape, uno::UNO_QUERY);
1473 CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER,getProperty<text::TextContentAnchorType>(xPropertySet2,"AnchorType"));
1475 // Second check box anchored to character
1476 xControlShape.set(getShape(2), uno::UNO_QUERY);
1478 // Check whether we have the right control
1479 xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
1480 xServiceInfo.set(xPropertySet, uno::UNO_QUERY);
1481 CPPUNIT_ASSERT_EQUAL(true, bool(xServiceInfo->supportsService("com.sun.star.form.component.CheckBox")));
1482 CPPUNIT_ASSERT_EQUAL(OUString("Floating Checkbox"), getProperty<OUString>(xPropertySet, "Label"));
1484 // Check anchor type
1485 xPropertySet2.set(xControlShape, uno::UNO_QUERY);
1486 CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER,getProperty<text::TextContentAnchorType>(xPropertySet2,"AnchorType"));
1489 DECLARE_OOXMLEXPORT_TEST(testActiveXOptionButtonGroup, "activex_option_button_group.docx")
1491 // Optionbutton groups were not handled
1492 // The two optionbutton should have the same group name
1493 const OUString sGroupName = "GroupX";
1495 uno::Reference<drawing::XControlShape> xControlShape(getShape(1), uno::UNO_QUERY);
1496 CPPUNIT_ASSERT(xControlShape.is());
1497 uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
1498 CPPUNIT_ASSERT_EQUAL(sGroupName, getProperty<OUString>(xPropertySet, "GroupName"));
1500 xControlShape.set(getShape(2), uno::UNO_QUERY);
1501 CPPUNIT_ASSERT(xControlShape.is());
1502 xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
1503 CPPUNIT_ASSERT_EQUAL(sGroupName, getProperty<OUString>(xPropertySet, "GroupName"));
1506 CPPUNIT_TEST_FIXTURE(Test, tdf112169)
1508 loadAndSave("tdf112169.odt");
1509 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1510 CPPUNIT_ASSERT_EQUAL(6, getPages());
1511 // LO crashed while export because of character background color handling
1513 //tdf76683 - Cannot be negative number - use firstLine instead of hanging
1514 xmlDocUniquePtr pXmlDoc = parseExport("word/numbering.xml");
1515 assertXPathNoAttribute(pXmlDoc, "/w:numbering/w:abstractNum[1]/w:lvl[1]/w:pPr/w:ind", "hanging");
1516 assertXPath(pXmlDoc, "/w:numbering/w:abstractNum[1]/w:lvl[1]/w:pPr/w:ind", "firstLine","360");
1519 CPPUNIT_TEST_FIXTURE(Test, testTdf103090)
1521 loadAndSave("tdf103090.odt");
1522 CPPUNIT_ASSERT_EQUAL(1, getPages());
1523 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
1525 // Get bookmark name
1526 OUString bookmarkName = getXPath(pXmlDoc, "/w:document/w:body/w:p/w:bookmarkStart", "name");
1528 // Ensure that name has no spaces
1529 CPPUNIT_ASSERT(bookmarkName.indexOf(" ") < 0);
1531 // Get PAGEREF field
1532 OUString fieldName = getXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:r[2]/w:instrText");
1534 // Ensure that PAGEREF field refers exactly our bookmark
1535 OUString expectedFieldName = " PAGEREF " + bookmarkName + " \\h ";
1536 CPPUNIT_ASSERT_EQUAL(expectedFieldName, fieldName);
1539 CPPUNIT_TEST_FIXTURE(Test, testTdf107111)
1541 loadAndSave("tdf107111.docx");
1542 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
1544 // Ensure that hyperlink and its properties are in place.
1545 assertXPath(pXmlDoc, "/w:document/w:body/w:p[5]/w:hyperlink/w:r/w:rPr", 1);
1547 // Ensure that hyperlink properties do not contain <w:webHidden/>.
1548 assertXPath(pXmlDoc, "/w:document/w:body/w:p[5]/w:hyperlink/w:r/w:rPr/w:webHidden", 0);
1551 DECLARE_OOXMLEXPORT_TEST(testTdf90789, "tdf90789.docx")
1553 uno::Reference<text::XTextContent> xShape(getShape(1), uno::UNO_QUERY_THROW);
1554 CPPUNIT_ASSERT(xShape->getAnchor() != nullptr);
1556 uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY_THROW);
1557 uno::Reference<view::XSelectionSupplier> xCtrl(xModel->getCurrentController(), uno::UNO_QUERY_THROW);
1558 xCtrl->select(uno::Any(xShape->getAnchor()));
1560 uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xCtrl, uno::UNO_QUERY_THROW);
1561 uno::Reference<text::XTextViewCursor> xTextCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_SET_THROW);
1562 uno::Reference<text::XPageCursor> xPageCursor(xTextCursor, uno::UNO_QUERY_THROW);
1563 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(1), xPageCursor->getPage());
1566 DECLARE_OOXMLEXPORT_TEST(testTdf90789_2, "tdf90789-2.docx")
1568 // Section break before frame and shape was ignored
1569 CPPUNIT_ASSERT_EQUAL( 3, getPages() );
1572 DECLARE_OOXMLEXPORT_TEST(testTdf104354_2, "tdf104354-2.docx")
1574 uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
1575 uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
1576 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
1577 uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
1579 // top margin of the first paragraph and bottom margin of the last paragraph
1580 // is zero, when auto spacing is used.
1582 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(1, xCell->getText()), "ParaTopMargin"));
1583 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(494), getProperty<sal_Int32>(getParagraphOfText(1, xCell->getText()), "ParaBottomMargin"));
1584 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(494), getProperty<sal_Int32>(getParagraphOfText(2, xCell->getText()), "ParaTopMargin"));
1585 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(494), getProperty<sal_Int32>(getParagraphOfText(2, xCell->getText()), "ParaBottomMargin"));
1586 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(494), getProperty<sal_Int32>(getParagraphOfText(3, xCell->getText()), "ParaTopMargin"));
1587 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(3, xCell->getText()), "ParaBottomMargin"));
1589 // top margin is not auto spacing
1590 uno::Reference<text::XTextRange> xCell2(xTable->getCellByName("A2"), uno::UNO_QUERY);
1591 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(847), getProperty<sal_Int32>(getParagraphOfText(1, xCell2->getText()), "ParaTopMargin"));
1592 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(1, xCell2->getText()), "ParaBottomMargin"));
1594 // bottom margin is not auto spacing
1595 uno::Reference<text::XTextRange> xCell3(xTable->getCellByName("A3"), uno::UNO_QUERY);
1596 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(1, xCell3->getText()), "ParaTopMargin"));
1597 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(847), getProperty<sal_Int32>(getParagraphOfText(1, xCell3->getText()), "ParaBottomMargin"));
1599 // auto spacing, if the paragraph contains footnotes
1600 uno::Reference<text::XTextRange> xCell4(xTable->getCellByName("A4"), uno::UNO_QUERY);
1601 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(1, xCell4->getText()), "ParaTopMargin"));
1602 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(1, xCell4->getText()), "ParaBottomMargin"));
1604 // auto spacing is explicitly disabled, and no margins are defined.
1605 xCell.set(xTable->getCellByName("A5"), uno::UNO_QUERY);
1606 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(1, xCell->getText()), "ParaTopMargin"));
1607 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(1, xCell->getText()), "ParaBottomMargin"));
1608 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(2, xCell->getText()), "ParaTopMargin"));
1609 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(2, xCell->getText()), "ParaBottomMargin"));
1610 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(3, xCell->getText()), "ParaTopMargin"));
1611 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(3, xCell->getText()), "ParaBottomMargin"));
1613 // auto spacing on a paragraph
1614 uno::Reference<text::XTextTable> xTable2(xTables->getByIndex(1), uno::UNO_QUERY);
1615 uno::Reference<text::XTextRange> xCell5(xTable2->getCellByName("A1"), uno::UNO_QUERY);
1616 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(1, xCell5->getText()), "ParaTopMargin"));
1617 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(1, xCell5->getText()), "ParaBottomMargin"));
1620 CPPUNIT_TEST_FIXTURE(Test, testTdf137593)
1622 loadAndSave("tdf137593.docx");
1623 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
1625 // zero auto spacing, if the first paragraph contains text boxes
1626 // This was 280.
1627 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl[1]/w:tr/w:tc/w:p[1]/w:pPr/w:spacing", "before", "0");
1630 CPPUNIT_TEST_FIXTURE(Test, testTdf115557)
1632 loadAndSave("tdf115557.docx");
1633 // A chart anchored to a footnote multiplied during import
1634 xmlDocUniquePtr pXmlDoc = parseExport("word/footnotes.xml");
1636 assertXPath(pXmlDoc, "//w:footnote/w:p/w:r/w:drawing", 1);
1639 CPPUNIT_TEST_FIXTURE(Test, testAlignmentRelativeFromTopMarginDML)
1641 loadAndSave("tdf137641_RelativeFromTopMargin.docx");
1642 // Import as DML.
1643 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
1645 assertXPath(pXmlDoc,
1646 "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/"
1647 "wp:anchor/wp:positionV",
1648 "relativeFrom", "topMargin");
1649 assertXPathContent(pXmlDoc,
1650 "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/"
1651 "wp:anchor/wp:positionV/wp:align",
1652 "top");
1653 assertXPath(pXmlDoc,
1654 "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent[2]/mc:Choice/w:drawing/"
1655 "wp:anchor/wp:positionV",
1656 "relativeFrom", "topMargin");
1657 assertXPathContent(pXmlDoc,
1658 "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent[2]/mc:Choice/w:drawing/"
1659 "wp:anchor/wp:positionV/wp:align",
1660 "bottom");
1661 assertXPath(pXmlDoc,
1662 "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent[3]/mc:Choice/w:drawing/"
1663 "wp:anchor/wp:positionV",
1664 "relativeFrom", "topMargin");
1665 assertXPathContent(pXmlDoc,
1666 "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent[3]/mc:Choice/w:drawing/"
1667 "wp:anchor/wp:positionV/wp:align",
1668 "center");
1671 CPPUNIT_TEST_FIXTURE(Test, testAlignmentRelativeFromTopMarginVML)
1673 loadAndSave("tdf137642_Vertical_Alignment_toppage.docx");
1674 // Import as VML.
1675 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
1677 assertXPath(pXmlDoc,
1678 "/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/"
1679 "wp:anchor/wp:positionV",
1680 "relativeFrom", "topMargin");
1681 assertXPathContent(pXmlDoc,
1682 "/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/"
1683 "wp:anchor/wp:positionV/wp:align",
1684 "top");
1685 assertXPath(pXmlDoc,
1686 "/w:document/w:body/w:p/w:r/mc:AlternateContent[2]/mc:Choice/w:drawing/"
1687 "wp:anchor/wp:positionV",
1688 "relativeFrom", "topMargin");
1689 assertXPathContent(pXmlDoc,
1690 "/w:document/w:body/w:p/w:r/mc:AlternateContent[2]/mc:Choice/w:drawing/"
1691 "wp:anchor/wp:positionV/wp:align",
1692 "bottom");
1693 assertXPath(pXmlDoc,
1694 "/w:document/w:body/w:p/w:r/mc:AlternateContent[3]/mc:Choice/w:drawing/"
1695 "wp:anchor/wp:positionV",
1696 "relativeFrom", "topMargin");
1697 assertXPathContent(pXmlDoc,
1698 "/w:document/w:body/w:p/w:r/mc:AlternateContent[3]/mc:Choice/w:drawing/"
1699 "wp:anchor/wp:positionV/wp:align",
1700 "center");
1703 CPPUNIT_TEST_FIXTURE(Test, testVmlShapeWithTextbox)
1705 loadAndSave("tdf41466_testVmlShapeWithTextbox.docx");
1706 // Import as VML.
1707 // tdf#41466: check whether VML DOCX shape with text is imported as shape with a text frame
1708 // (text box). These kind of shapes were imported only as text frames previously, losing the
1709 // preset shape geometry, in this case "wedgeRectCallout".
1710 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
1712 // the wrong value was "rect" instead of "wedgeRectCallout"
1713 assertXPath(pXmlDoc,
1714 "/w:document/w:body/w:p/w:r/"
1715 "mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:prstGeom",
1716 "prst", "wedgeRectCallout");
1719 CPPUNIT_TEST_FIXTURE(Test, testLayoutFlowAltAlone)
1721 loadAndSave("layout-flow-alt-alone.docx");
1722 // moved from oox/qa/unit/vml.cxx
1723 // FIXME: now the DML part is checked, but we should check VML part in Fallback (too)
1724 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
1725 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/"
1726 "a:graphic/a:graphicData/wps:wsp/wps:bodyPr", "vert", "vert270");
1729 CPPUNIT_PLUGIN_IMPLEMENT();
1731 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */