1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <swmodeltestbase.hxx>
12 #include <com/sun/star/awt/FontSlant.hpp>
13 #include <com/sun/star/awt/XBitmap.hpp>
14 #include <com/sun/star/drawing/FillStyle.hpp>
15 #include <com/sun/star/style/BreakType.hpp>
16 #include <com/sun/star/text/FontEmphasis.hpp>
17 #include <com/sun/star/text/HoriOrientation.hpp>
18 #include <com/sun/star/text/XTextRangeCompare.hpp>
19 #include <com/sun/star/text/WritingMode2.hpp>
20 #include <com/sun/star/text/TableColumnSeparator.hpp>
21 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
22 #include <com/sun/star/frame/XStorable.hpp>
23 #include <com/sun/star/text/XTextTablesSupplier.hpp>
24 #include <com/sun/star/text/XTextTable.hpp>
25 #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
26 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
27 #include <com/sun/star/packages/zip/ZipFileAccess.hpp>
29 #include <o3tl/cppunittraitshelper.hxx>
30 #include <oox/drawingml/drawingmltypes.hxx>
31 #include <comphelper/sequenceashashmap.hxx>
32 #include <comphelper/processfactory.hxx>
33 #include <tools/UnitConversion.hxx>
34 #include <frameformats.hxx>
36 class Test
: public SwModelTestBase
39 Test() : SwModelTestBase("/sw/qa/extras/ooxmlexport/data/", "Office Open XML Text") {}
42 CPPUNIT_TEST_FIXTURE(Test
, testfdo81381
)
44 loadAndSave("fdo81381.docx");
45 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
46 assertXPath(pXmlDoc
, "/w:document/w:body/w:p[1]/w:r[1]/w:object[1]/o:OLEObject[1]", "DrawAspect", "Icon");
49 CPPUNIT_TEST_FIXTURE(Test
, testSdtAlias
)
51 loadAndSave("sdt-alias.docx");
52 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
54 // <w:alias> was completely missing.
55 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:alias", "val", "Subtitle");
58 CPPUNIT_TEST_FIXTURE(Test
, testFooterBodyDistance
)
60 loadAndSave("footer-body-distance.docx");
61 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
62 // Page break was exported as section break, this was 0
63 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/w:br", 1);
66 // Check for correct header/footer with special first page with TOC inside:
67 // - DECLARE_ODFEXPORT_TEST(testTdf118393, "tdf118393.odt")
68 // - DECLARE_OOXMLEXPORT_TEST(testTdf118393, "tdf118393.odt")
69 CPPUNIT_TEST_FIXTURE(Test
, testTdf118393
)
71 loadAndReload("tdf118393.odt");
72 CPPUNIT_ASSERT_EQUAL( 7, getPages() );
74 // First page has no header/footer
76 xmlDocUniquePtr pXmlDoc
= parseLayoutDump();
79 assertXPath(pXmlDoc
, "/root/page[1]/header", 0);
80 assertXPath(pXmlDoc
, "/root/page[1]/footer", 0);
82 // check second page in the same way
83 assertXPath(pXmlDoc
, "/root/page[2]/header");
84 assertXPath(pXmlDoc
, "/root/page[2]/footer");
87 // All other pages should have header/footer
89 CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[2]/header/txt/text()"));
90 CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[2]/footer/txt/text()"));
92 CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[3]/header/txt/text()"));
93 CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[3]/footer/txt/text()"));
95 CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[4]/header/txt/text()"));
96 CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[4]/footer/txt/text()"));
98 CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[5]/header/txt/text()"));
99 CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[5]/footer/txt/text()"));
101 CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[6]/header/txt/text()"));
102 CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[6]/footer/txt/text()"));
104 CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[7]/header/txt/text()"));
105 CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[7]/footer/txt/text()"));
108 DECLARE_OOXMLEXPORT_TEST(testfdo81031
, "fdo81031.docx")
110 // vml image was not rendered
111 // As there are also numPicBullets in the file,
112 // the fragmentPath was not changed hence relationships were not resolved.
114 uno::Reference
<drawing::XShape
> image
= getShape(1);
115 uno::Reference
<beans::XPropertySet
> xImage(image
, uno::UNO_QUERY
);
116 uno::Reference
<graphic::XGraphic
> xGraphic
= getProperty
<uno::Reference
<graphic::XGraphic
> >(xImage
, "Graphic");
117 uno::Reference
<awt::XBitmap
> xBitmap(xGraphic
, uno::UNO_QUERY
);
118 CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int32
>(381), xBitmap
->getSize().Width
);
119 CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int32
>(148), xBitmap
->getSize().Height
);
122 CPPUNIT_TEST_FIXTURE(Test
, testPlausableBorder
)
124 loadAndSave("plausable-border.docx");
125 // sw::util::IsPlausableSingleWordSection() did not merge two page styles due to borders.
126 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
127 // Page break was exported as section break, this was 0
128 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/w:br", 1);
130 CPPUNIT_ASSERT_EQUAL( 2, getPages() );
133 CPPUNIT_TEST_FIXTURE(Test
, testUnwantedSectionBreak
)
135 loadAndSave("unwanted-section-break.docx");
136 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
137 // This was 2: an additional sectPr was added to the document.
138 assertXPath(pXmlDoc
, "//w:sectPr", 1);
141 CPPUNIT_TEST_FIXTURE(Test
, testfdo80897
)
143 loadAndSave("fdo80897.docx");
144 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
145 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:bodyPr/a:prstTxWarp", "prst", "textTriangle");
149 DECLARE_OOXMLEXPORT_TEST(testFdo80997
, "fdo80997.docx")
151 // The problem was that the DOCX exporter not able to export text behind textbox, if textbox has a wrap property.
152 uno::Reference
< text::XTextRange
> xParagraph
= getParagraph( 1 );
153 getRun( xParagraph
, 1, " text");
156 CPPUNIT_TEST_FIXTURE(Test
, testFdo80902
)
158 loadAndSave("fdo80902.docx");
159 // The problem was that the docGrid type was set as default so fix it for other grid type
160 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
162 assertXPath(pXmlDoc
, "/w:document/w:body/w:sectPr/w:docGrid", "type", "lines");
165 CPPUNIT_TEST_FIXTURE(Test
, testParaShading
)
167 loadAndSave("para-shading.docx");
168 // Make sure the themeColor attribute is not written when it would be empty.
169 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
170 assertXPathNoAttribute(pXmlDoc
, "/w:document/w:body/w:p/w:pPr/w:shd", "themeColor");
173 DECLARE_OOXMLEXPORT_TEST(testFirstHeaderFooter
, "first-header-footer.docx")
175 // Test import and export of a section's headerf/footerf properties.
176 // (copied from a ww8export test, with doc converted to docx using Word)
178 CPPUNIT_ASSERT_EQUAL( 6, getPages() );
180 // The document has 6 pages. Note that we don't test if 4 or just 2 page
181 // styles are created, the point is that layout should be correct.
182 CPPUNIT_ASSERT_EQUAL(OUString("First page header"), parseDump("/root/page[1]/header/txt/text()"));
183 CPPUNIT_ASSERT_EQUAL(OUString("First page footer"), parseDump("/root/page[1]/footer/txt/text()"));
184 CPPUNIT_ASSERT_EQUAL(OUString("Even page header"), parseDump("/root/page[2]/header/txt/text()"));
185 CPPUNIT_ASSERT_EQUAL(OUString("Even page footer"), parseDump("/root/page[2]/footer/txt/text()"));
186 CPPUNIT_ASSERT_EQUAL(OUString("Odd page header"), parseDump("/root/page[3]/header/txt/text()"));
187 CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer"), parseDump("/root/page[3]/footer/txt/text()"));
188 CPPUNIT_ASSERT_EQUAL(OUString("First page header2"), parseDump("/root/page[4]/header/txt/text()"));
189 CPPUNIT_ASSERT_EQUAL(OUString("First page footer 2"), parseDump("/root/page[4]/footer/txt/text()"));
190 CPPUNIT_ASSERT_EQUAL(OUString("Odd page header 2"), parseDump("/root/page[5]/header/txt/text()"));
191 CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer 2"), parseDump("/root/page[5]/footer/txt/text()"));
192 CPPUNIT_ASSERT_EQUAL(OUString("Even page header 2"), parseDump("/root/page[6]/header/txt/text()"));
193 CPPUNIT_ASSERT_EQUAL(OUString("Even page footer 2"), parseDump("/root/page[6]/footer/txt/text()"));
196 CPPUNIT_TEST_FIXTURE(Test
, testFirstHeaderFooterB
)
198 loadAndReload("first-header-footerB.odt");
199 CPPUNIT_ASSERT_EQUAL( 6, getPages() );
201 CPPUNIT_ASSERT_EQUAL(OUString("First page header"), parseDump("/root/page[1]/header/txt/text()"));
202 CPPUNIT_ASSERT_EQUAL(OUString("First page footer"), parseDump("/root/page[1]/footer/txt/text()"));
203 CPPUNIT_ASSERT_EQUAL(OUString("Even page header"), parseDump("/root/page[2]/header/txt/text()"));
204 CPPUNIT_ASSERT_EQUAL(OUString("Even page footer"), parseDump("/root/page[2]/footer/txt/text()"));
205 CPPUNIT_ASSERT_EQUAL(OUString("Odd page header"), parseDump("/root/page[3]/header/txt/text()"));
206 CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer"), parseDump("/root/page[3]/footer/txt/text()"));
207 CPPUNIT_ASSERT_EQUAL(OUString("First page header2"), parseDump("/root/page[4]/header/txt/text()"));
208 CPPUNIT_ASSERT_EQUAL(OUString("First page footer 2"), parseDump("/root/page[4]/footer/txt/text()"));
209 CPPUNIT_ASSERT_EQUAL(OUString("Odd page header 2"), parseDump("/root/page[5]/header/txt/text()"));
210 CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer 2"), parseDump("/root/page[5]/footer/txt/text()"));
211 CPPUNIT_ASSERT_EQUAL(OUString("Even page header 2"), parseDump("/root/page[6]/header/txt/text()"));
212 CPPUNIT_ASSERT_EQUAL(OUString("Even page footer 2"), parseDump("/root/page[6]/footer/txt/text()"));
215 CPPUNIT_TEST_FIXTURE(Test
, testFDO83044
)
217 loadAndSave("fdo83044.docx");
218 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
220 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:text", 1);
223 DECLARE_OOXMLEXPORT_TEST(testfdo83428
, "fdo83428.docx")
225 uno::Reference
<document::XDocumentPropertiesSupplier
> xDocumentPropertiesSupplier(mxComponent
, uno::UNO_QUERY
);
226 uno::Reference
<document::XDocumentProperties
> xProps(xDocumentPropertiesSupplier
->getDocumentProperties());
227 uno::Reference
<beans::XPropertySet
> xUDProps(xProps
->getUserDefinedProperties(), uno::UNO_QUERY
);
228 CPPUNIT_ASSERT_EQUAL(OUString("Document"), getProperty
<OUString
>(xUDProps
, "Testing"));
231 CPPUNIT_TEST_FIXTURE(Test
, testShapeInFloattable
)
233 loadAndSave("shape-in-floattable.docx");
234 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
235 // No nested drawingML w:txbxContent.
236 assertXPath(pXmlDoc
, "//mc:Choice//w:txbxContent//w:txbxContent", 0);
237 // Instead, make sure we have a separate shape and a table
238 assertXPath(pXmlDoc
, "//mc:AlternateContent//mc:Choice[@Requires='wpg']", 1);
239 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl", 1);
242 CPPUNIT_TEST_FIXTURE(Test
, testEmptyAnnotationMark
)
244 loadAndReload("empty-annotation-mark.docx");
245 // Delete the word that is commented, and save again.
246 uno::Reference
<text::XTextRange
> xRun
= getRun(getParagraph(1), 3);
247 CPPUNIT_ASSERT_EQUAL(OUString("with"), xRun
->getString());
249 uno::Reference
<frame::XStorable
> xStorable(mxComponent
, uno::UNO_QUERY
);
252 // Then inspect the OOXML markup of the modified document model.
253 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
254 // There were two commentReference nodes.
255 assertXPath(pXmlDoc
, "//w:commentReference", "id", "0");
256 // Empty comment range was not ignored on export, this was 1.
257 assertXPath(pXmlDoc
, "//w:commentRangeStart", 0);
259 assertXPath(pXmlDoc
, "//w:commentRangeEnd", 0);
262 DECLARE_OOXMLEXPORT_TEST(testDropdownInCell
, "dropdown-in-cell.docx")
264 // First problem: table was missing from the document, this was 0.
265 uno::Reference
<text::XTextTablesSupplier
> xTablesSupplier(mxComponent
, uno::UNO_QUERY
);
266 uno::Reference
<container::XIndexAccess
> xTables(xTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
267 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables
->getCount());
269 // Second problem: dropdown shape wasn't anchored inside the B1 cell.
272 uno::Reference
<text::XTextContent
> xShape(getShape(1), uno::UNO_QUERY
);
273 uno::Reference
<text::XTextRange
> xAnchor
= xShape
->getAnchor();
274 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
275 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName("B1"), uno::UNO_QUERY
);
276 uno::Reference
<text::XTextRangeCompare
> xTextRangeCompare(xCell
, uno::UNO_QUERY
);
277 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextRangeCompare
->compareRegionStarts(xAnchor
, xCell
));
279 else if (!isExported())
281 // ComboBox was imported as DropDown text field
282 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
283 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
284 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
285 CPPUNIT_ASSERT(xFields
->hasMoreElements());
286 uno::Any aField
= xFields
->nextElement();
287 uno::Reference
<lang::XServiceInfo
> xServiceInfo(aField
, uno::UNO_QUERY
);
288 CPPUNIT_ASSERT(xServiceInfo
->supportsService("com.sun.star.text.textfield.DropDown"));
292 // DropDown text field is exported as inline SDT, we import that back here.
293 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
294 uno::Reference
<table::XCell
> xCell
= xTable
->getCellByName("B1");
295 uno::Reference
<container::XEnumerationAccess
> xParagraphsAccess(xCell
, uno::UNO_QUERY
);
296 uno::Reference
<container::XEnumeration
> xParagraphs
= xParagraphsAccess
->createEnumeration();
297 uno::Reference
<container::XEnumerationAccess
> xParagraph(xParagraphs
->nextElement(),
299 uno::Reference
<container::XEnumeration
> xPortions
= xParagraph
->createEnumeration();
300 uno::Reference
<beans::XPropertySet
> xTextPortion(xPortions
->nextElement(), uno::UNO_QUERY
);
301 OUString aPortionType
;
302 xTextPortion
->getPropertyValue("TextPortionType") >>= aPortionType
;
303 CPPUNIT_ASSERT_EQUAL(OUString("ContentControl"), aPortionType
);
304 uno::Reference
<text::XTextContent
> xContentControl
;
305 xTextPortion
->getPropertyValue("ContentControl") >>= xContentControl
;
306 uno::Reference
<beans::XPropertySet
> xContentControlProps(xContentControl
, uno::UNO_QUERY
);
307 uno::Sequence
<beans::PropertyValues
> aListItems
;
308 xContentControlProps
->getPropertyValue("ListItems") >>= aListItems
;
309 CPPUNIT_ASSERT(aListItems
.hasElements());
313 DECLARE_OOXMLEXPORT_TEST(testTableAlignment
, "table-alignment.docx")
315 uno::Reference
<text::XTextTablesSupplier
> xTablesSupplier(mxComponent
, uno::UNO_QUERY
);
316 uno::Reference
<container::XIndexAccess
> xTables(xTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
317 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
318 // This was LEFT_AND_WIDTH, i.e. table alignment wasn't imported correctly.
319 CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::RIGHT
, getProperty
<sal_Int16
>(xTable
, "HoriOrient"));
322 CPPUNIT_TEST_FIXTURE(Test
, testSdtIgnoredFooter
)
324 loadAndSave("sdt-ignored-footer.docx");
325 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
326 // This was 1, make sure no w:sdt sneaks into the main document from the footer.
327 assertXPath(pXmlDoc
, "//w:sdt", 0);
330 CPPUNIT_TEST_FIXTURE(Test
, testSdtRunPicture
)
332 loadAndSave("sdt-run-picture.docx");
333 // SDT around run was exported as SDT around paragraph
334 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
335 // This was 1: there was an SDT around w:p.
336 assertXPath(pXmlDoc
, "//w:body/w:sdt", 0);
337 // This was 0: there were no SDT around w:r.
338 assertXPath(pXmlDoc
, "//w:body/w:p/w:sdt", 1);
341 DECLARE_OOXMLEXPORT_TEST(testChartDupe
, "chart-dupe.docx")
343 // Single chart was exported back as two charts.
344 uno::Reference
<text::XTextEmbeddedObjectsSupplier
> xTextEmbeddedObjectsSupplier(mxComponent
, uno::UNO_QUERY
);
345 uno::Reference
<container::XIndexAccess
> xEmbeddedObjects(xTextEmbeddedObjectsSupplier
->getEmbeddedObjects(), uno::UNO_QUERY
);
346 // This was 2, on second import we got a duplicated chart copy.
347 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xEmbeddedObjects
->getCount());
351 return; // initial import
353 xmlDocUniquePtr pXmlDocCT
= parseExport("[Content_Types].xml");
355 assertXPath(pXmlDocCT
,
356 "/ContentType:Types/ContentType:Override[@PartName='/word/charts/chart1.xml']",
358 "application/vnd.openxmlformats-officedocument.drawingml.chart+xml");
359 assertXPath(pXmlDocCT
, "/ContentType:Types/ContentType:Override[@PartName='/word/embeddings/Microsoft_Excel_Worksheet1.xlsx']", "ContentType", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
361 // check the rels too
362 xmlDocUniquePtr pXmlDocRels
= parseExport("word/charts/_rels/chart1.xml.rels");
363 assertXPath(pXmlDocRels
,
364 "/rels:Relationships/rels:Relationship[@Target='../embeddings/Microsoft_Excel_Worksheet1.xlsx']",
366 "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package");
367 // check the content too
368 xmlDocUniquePtr pXmlDocChart1
= parseExport("word/charts/chart1.xml");
369 assertXPath(pXmlDocChart1
,
370 "/c:chartSpace/c:externalData",
375 DECLARE_OOXMLEXPORT_TEST(testPositionAndRotation
, "position-and-rotation.docx")
377 // The document should look like: "This line is tricky, <image> because only 'This line is tricky,' is on the left."
378 // But the image was pushed down, so it did not break the line into two text portions.
379 uno::Reference
<drawing::XShape
> xShape
= getShape(1);
380 // Should be 1559, was -5639
381 CPPUNIT_ASSERT(xShape
->getPosition().X
> 1500);
382 // Should be 88, was 473
383 CPPUNIT_ASSERT(xShape
->getPosition().Y
< 100);
386 DECLARE_OOXMLEXPORT_TEST(testNumberingFont
, "numbering-font.docx")
388 // check that the original numrule font name is still Calibri
389 uno::Reference
<beans::XPropertySet
> xStyle(getStyles("CharacterStyles")->getByName("ListLabel 1"), uno::UNO_QUERY
);
390 CPPUNIT_ASSERT_EQUAL(OUString("Calibri"), getProperty
<OUString
>(xStyle
, "CharFontName"));
392 uno::Reference
<text::XTextRange
> xPara
= getParagraph(2);
393 uno::Reference
<beans::XPropertySet
> properties(xPara
, uno::UNO_QUERY
);
394 uno::Any aValue
= properties
->getPropertyValue("ListAutoFormat");
395 CPPUNIT_ASSERT(aValue
.hasValue());
396 uno::Sequence
<beans::NamedValue
> aListAutoFormat
;
397 CPPUNIT_ASSERT(aValue
>>= aListAutoFormat
);
398 auto it
= std::find_if(std::cbegin(aListAutoFormat
), std::cend(aListAutoFormat
),
399 [](const css::beans::NamedValue
& val
) { return val
.Name
== "CharFontName"; });
400 CPPUNIT_ASSERT(it
!= std::cend(aListAutoFormat
));
401 OUString sOverrideFontName
;
402 CPPUNIT_ASSERT(it
->Value
>>= sOverrideFontName
);
403 // but the overridden font name is Verdana
404 CPPUNIT_ASSERT_EQUAL(OUString("Verdana"), sOverrideFontName
);
407 CPPUNIT_TEST_FIXTURE(Test
, testTdf106541_noinheritChapterNumbering
)
409 loadAndReload("tdf106541_noinheritChapterNumbering.odt");
410 CPPUNIT_ASSERT_EQUAL(1, getPages());
411 // in LO, it appears that styles based on the Chapter Numbering style explicitly set the
412 // numbering style/outline level to 0 by default, and that LO prevents inheriting directly from "Outline" style.
413 // Adding this preventative unit test to ensure that any fix for tdf106541 doesn't make incorrect assumptions.
415 //reverting tdf#76817 hard-codes the numbering style on the paragraph, preventing RT of "Outline" style
416 // CPPUNIT_ASSERT_EQUAL(OUString("Outline"), getProperty<OUString>(getParagraph(1), "NumberingStyleName"));
418 OUString sPara3NumberingStyle
= getProperty
<OUString
>(getParagraph(3), "NumberingStyleName");
419 CPPUNIT_ASSERT_EQUAL(sPara3NumberingStyle
, getProperty
<OUString
>(getParagraph(4), "NumberingStyleName"));
421 xmlDocUniquePtr pXmlDoc
= parseLayoutDump();
422 assertXPath(pXmlDoc
, "//body/txt/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']", 3); //three of the four paragraphs have numbering
423 assertXPath(pXmlDoc
, "//body/txt[1]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']", "expand", "1");
424 assertXPath(pXmlDoc
, "//body/txt[2]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']", 0); //second paragraph style disables numbering
425 assertXPath(pXmlDoc
, "//body/txt[3]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']", "expand", "I.");
426 assertXPath(pXmlDoc
, "//body/txt[4]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']", "expand", "II.");
429 DECLARE_OOXMLEXPORT_TEST(testTdf53856_conflictingStyle
, "tdf53856_conflictingStyle.docx")
431 // The "Text" style conflicted with builtin paragraph style Caption -> Text
432 uno::Reference
<beans::XPropertySet
> xStyle(getStyles("ParagraphStyles")->getByName("Text"), uno::UNO_QUERY
);
433 CPPUNIT_ASSERT_EQUAL(OUString("Times New Roman"), getProperty
<OUString
>(xStyle
, "CharFontName"));
434 CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE
, getProperty
<awt::FontSlant
>(xStyle
, "CharPosture"));
437 DECLARE_OOXMLEXPORT_TEST(testTdf104713_undefinedStyles
, "tdf104713_undefinedStyles.docx")
439 // Normal paragraph style was not defined, so don't replace conflicting styles
440 uno::Reference
<beans::XPropertySet
> xStyle(getStyles("ParagraphStyles")->getByName("Heading 1"), uno::UNO_QUERY
);
441 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(212), getProperty
<sal_Int32
>(xStyle
, "ParaBottomMargin"));
443 // tdf108765: once importing is finished, use default values for any styles not yet defined.
444 xStyle
.set( getStyles("ParagraphStyles")->getByName("Footnote"), uno::UNO_QUERY
);
445 CPPUNIT_ASSERT_EQUAL_MESSAGE("Font size", 10.f
, getProperty
<float>(xStyle
, "CharHeight"));
448 CPPUNIT_TEST_FIXTURE(Test
, testDrawingmlFlipv
)
450 loadAndSave("drawingml-flipv.docx");
451 // The problem was that the shape had vertical flip only, but then we added rotation as well on export.
452 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
453 assertXPathNoAttribute(pXmlDoc
, "//a:xfrm", "rot");
456 CPPUNIT_TEST_FIXTURE(Test
, testRot90Fliph
)
458 loadAndSave("rot90-fliph.docx");
459 // The problem was that a shape rotation of 90° got turned into 270° after roundtrip.
460 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
461 assertXPath(pXmlDoc
, "//a:xfrm", "flipH", "1");
462 // This was 16200000 (270 * 60000).
463 assertXPath(pXmlDoc
, "//a:xfrm", "rot", "5400000");
466 CPPUNIT_TEST_FIXTURE(Test
, testRot180Flipv
)
468 loadAndSave("rot180-flipv.docx");
469 // 180° rotation got lost after roundtrip.
470 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
471 assertXPath(pXmlDoc
, "//a:xfrm", "flipV", "1");
472 // This attribute was completely missing.
473 assertXPath(pXmlDoc
, "//a:xfrm", "rot", "10800000");
476 CPPUNIT_TEST_FIXTURE(Test
, testRot270Flipv
)
478 loadAndSave("rot270-flipv.docx");
479 // 270° rotation got turned into 90° after roundtrip.
480 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
481 assertXPath(pXmlDoc
, "//a:xfrm", "flipV", "1");
483 assertXPath(pXmlDoc
, "//a:xfrm", "rot", "16200000");
486 CPPUNIT_TEST_FIXTURE(Test
, testMsoPosition
)
488 loadAndSave("bnc884615-mso-position.docx");
490 xmlDocUniquePtr doc
= parseExport("word/footer1.xml");
491 // We write the frames out in different order than they were read, so check it's the correct
492 // textbox first by checking width. These tests may need reordering if that gets fixed.
493 OUString style1
= getXPath(doc
, "/w:ftr/w:p/w:r[3]/mc:AlternateContent/mc:Fallback/w:pict/v:rect", "style");
494 CPPUNIT_ASSERT( style1
.indexOf( ";width:531pt;" ) >= 0 );
495 CPPUNIT_ASSERT( style1
.indexOf( ";mso-position-vertical-relative:page" ) >= 0 );
496 CPPUNIT_ASSERT( style1
.indexOf( ";mso-position-horizontal-relative:page" ) >= 0 );
497 OUString style2
= getXPath(doc
, "/w:ftr/w:p/w:r[4]/mc:AlternateContent/mc:Fallback/w:pict/v:rect", "style");
498 CPPUNIT_ASSERT( style2
.indexOf( ";width:549pt;" ) >= 0 );
499 CPPUNIT_ASSERT( style2
.indexOf( ";mso-position-vertical-relative:text" ) >= 0 );
500 CPPUNIT_ASSERT( style2
.indexOf( ";mso-position-horizontal:center" ) >= 0 );
501 CPPUNIT_ASSERT( style2
.indexOf( ";mso-position-horizontal-relative:text" ) >= 0 );
502 OUString style3
= getXPath(doc
, "/w:ftr/w:p/w:r[5]/mc:AlternateContent/mc:Fallback/w:pict/v:rect", "style");
503 CPPUNIT_ASSERT( style3
.indexOf( ";width:36pt;" ) >= 0 );
504 CPPUNIT_ASSERT( style3
.indexOf( ";mso-position-horizontal-relative:text" ) >= 0 );
505 CPPUNIT_ASSERT( style3
.indexOf( ";mso-position-vertical-relative:text" ) >= 0 );
508 xmlDocUniquePtr doc
= parseExport("word/header1.xml");
509 OUString style1
= getXPath(doc
, "/w:hdr/w:p/w:r[2]/mc:AlternateContent/mc:Fallback/w:pict/v:rect", "style");
510 CPPUNIT_ASSERT( style1
.indexOf( ";width:335.75pt;" ) >= 0 );
511 CPPUNIT_ASSERT( style1
.indexOf( ";mso-position-horizontal-relative:page" ) >= 0 );
512 CPPUNIT_ASSERT( style1
.indexOf( ";mso-position-vertical-relative:page" ) >= 0 );
513 OUString style2
= getXPath(doc
, "/w:hdr/w:p/w:r[3]/mc:AlternateContent/mc:Fallback/w:pict/v:rect", "style");
514 CPPUNIT_ASSERT( style2
.indexOf( ";width:138.15pt;" ) >= 0 );
515 CPPUNIT_ASSERT( style2
.indexOf( ";mso-position-horizontal-relative:page" ) >= 0 );
516 CPPUNIT_ASSERT( style2
.indexOf( ";mso-position-vertical-relative:page" ) >= 0 );
517 OUString style3
= getXPath(doc
, "/w:hdr/w:p/w:r[4]/mc:AlternateContent/mc:Fallback/w:pict/v:rect", "style");
518 CPPUNIT_ASSERT( style3
.indexOf( ";width:163.8pt;" ) >= 0 );
519 CPPUNIT_ASSERT( style3
.indexOf( ";mso-position-horizontal-relative:page" ) >= 0 );
520 CPPUNIT_ASSERT( style3
.indexOf( ";mso-position-vertical-relative:page" ) >= 0 );
524 DECLARE_OOXMLEXPORT_TEST(testWpsCharColor
, "wps-char-color.docx")
526 uno::Reference
<text::XTextRange
> xShape(getShape(1), uno::UNO_QUERY
);
527 // This was -1, i.e. the character color was default (-1), not white.
528 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, getProperty
<Color
>(xShape
->getStart(), "CharColor"));
531 DECLARE_OOXMLEXPORT_TEST(testTableStyleCellBackColor
, "table-style-cell-back-color.docx")
533 // The problem was that cell background was white, not green.
534 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
535 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
536 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
537 uno::Reference
<table::XCell
> xCell
= xTable
->getCellByName("A1");
538 // This was 0xffffff.
539 CPPUNIT_ASSERT_EQUAL(Color(0x00ff00), getProperty
<Color
>(xCell
, "BackColor"));
542 DECLARE_OOXMLEXPORT_TEST(testTableStyleBorder
, "table-style-border.docx")
544 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
545 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
546 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
548 // This was 0, the second cell was missing its right border.
549 uno::Reference
<table::XCell
> xCell
= xTable
->getCellByName("A2");
550 CPPUNIT_ASSERT(getProperty
<table::BorderLine2
>(xCell
, "RightBorder").LineWidth
> 0);
552 // This was also 0 (even after fixing the previous problem), the first cell was missing its right border, too.
553 xCell
= xTable
->getCellByName("A1");
554 CPPUNIT_ASSERT(getProperty
<table::BorderLine2
>(xCell
, "RightBorder").LineWidth
> 0);
557 DECLARE_OOXMLEXPORT_TEST(testTableStyleBorderExport
, "table-style-border-export.docx")
559 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
560 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
561 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
562 uno::Reference
<table::XCell
> xCell
= xTable
->getCellByName("A3");
563 // Bottom border was white, so this was 0xffffff.
564 CPPUNIT_ASSERT_EQUAL(Color(0x8064A2), Color(ColorTransparency
, getProperty
<table::BorderLine2
>(xCell
, "BottomBorder").Color
));
567 DECLARE_OOXMLEXPORT_TEST(testAnchorPosition
, "anchor-position.docx")
569 // The problem was that the at-char anchored picture was at the end of the
570 // paragraph, so there were only two positions: a Text, then a Frame one.
571 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(getRun(getParagraph(1), 1), "TextPortionType"));
572 CPPUNIT_ASSERT_EQUAL(OUString("Frame"), getProperty
<OUString
>(getRun(getParagraph(1), 2), "TextPortionType"));
573 CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty
<OUString
>(getRun(getParagraph(1), 3), "TextPortionType"));
576 DECLARE_OOXMLEXPORT_TEST(testMultiPageToc
, "multi-page-toc.docx")
578 // Import of this document triggered an STL assertion.
580 // Document has a ToC from its second paragraph.
581 uno::Reference
<container::XNamed
> xTextSection
= getProperty
< uno::Reference
<container::XNamed
> >(getParagraph(2), "TextSection");
582 CPPUNIT_ASSERT_EQUAL(OUString("Table of Contents1"), xTextSection
->getName());
583 // There should be a field in the header as well.
584 uno::Reference
<text::XText
> xHeaderText
= getProperty
< uno::Reference
<text::XText
> >(getStyles("PageStyles")->getByName("Standard"), "HeaderText");
585 CPPUNIT_ASSERT_EQUAL(OUString("TextFieldStart"), getProperty
<OUString
>(getRun(getParagraphOfText(1, xHeaderText
), 1), "TextPortionType"));
588 DECLARE_OOXMLEXPORT_TEST(testTextboxTable
, "textbox-table.docx")
590 // We wrote not-well-formed XML during export for this one:
591 // Shape with textbox, having a table and also anchored inside a table.
593 // Just make sure that we have both tables.
594 uno::Reference
<text::XTextTablesSupplier
> xTablesSupplier(mxComponent
, uno::UNO_QUERY
);
595 uno::Reference
<container::XIndexAccess
> xTables(xTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
596 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTables
->getCount());
599 CPPUNIT_TEST_FIXTURE(Test
, testCropPixel
)
601 loadAndSave("crop-pixel.docx");
602 // If map mode of the graphic is in pixels, then we used to handle original
603 // size of the graphic as mm100, but it was in pixels.
604 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
605 // This is 17667 in the original document, was 504666 (so the image
606 // become invisible), now is around 19072.
607 CPPUNIT_ASSERT(getXPath(pXmlDoc
, "//a:srcRect", "l").toInt32() <= 22452);
609 /* FixMe: tdf#142805 Test disabled, because the picture is not load at all.
610 CPPUNIT_TEST_FIXTURE(Test, testEffectExtent)
612 loadAndSave("effect-extent.docx");
613 // The problem was that in case there were no shadows on the picture, we
614 // wrote a <wp:effectExtent> full or zeros.
615 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
617 assertXPath(pXmlDoc, "//wp:effectExtent", "l", "114300");
620 CPPUNIT_TEST_FIXTURE(Test
, testEffectExtentInline
)
622 loadAndSave("effect-extent-inline.docx");
623 // The problem was that in case there was inline rotated picture, we
624 // wrote a <wp:effectExtent> full or zeros.
625 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
627 assertXPath(pXmlDoc
, "//wp:effectExtent", "l", "609600");
628 assertXPath(pXmlDoc
, "//wp:effectExtent", "r", "590550");
629 assertXPath(pXmlDoc
, "//wp:effectExtent", "t", "590550");
630 assertXPath(pXmlDoc
, "//wp:effectExtent", "b", "571500");
633 DECLARE_OOXMLEXPORT_TEST(testEm
, "em.docx")
635 // Test all possible <w:em> arguments.
636 CPPUNIT_ASSERT_EQUAL(text::FontEmphasis::NONE
, getProperty
<sal_Int16
>(getRun(getParagraph(1), 1), "CharEmphasis"));
637 // This was ACCENT_ABOVE.
638 CPPUNIT_ASSERT_EQUAL(text::FontEmphasis::DOT_ABOVE
, getProperty
<sal_Int16
>(getRun(getParagraph(1), 2), "CharEmphasis"));
639 // This was DOT_ABOVE.
640 CPPUNIT_ASSERT_EQUAL(text::FontEmphasis::ACCENT_ABOVE
, getProperty
<sal_Int16
>(getRun(getParagraph(1), 3), "CharEmphasis"));
641 CPPUNIT_ASSERT_EQUAL(text::FontEmphasis::CIRCLE_ABOVE
, getProperty
<sal_Int16
>(getRun(getParagraph(1), 4), "CharEmphasis"));
642 CPPUNIT_ASSERT_EQUAL(text::FontEmphasis::DOT_BELOW
, getProperty
<sal_Int16
>(getRun(getParagraph(1), 5), "CharEmphasis"));
645 DECLARE_OOXMLEXPORT_TEST(testFdo77716
, "fdo77716.docx")
647 // The problem was that there should be 200 twips spacing between the two paragraphs, but there wasn't any.
648 uno::Reference
<beans::XPropertySet
> xStyle(getStyles("ParagraphStyles")->getByName("Standard"), uno::UNO_QUERY
);
650 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(convertTwipToMm100(200)), getProperty
<sal_Int32
>(xStyle
, "ParaBottomMargin"));
653 DECLARE_OOXMLEXPORT_TEST(testAfterlines
, "afterlines.docx")
655 // This was 353, i.e. the value of <w:spacing w:after="200"> from <w:pPrDefault>, instead of <w:spacing w:afterLines="100"/> from <w:pPr>.
656 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(423), getProperty
<sal_Int32
>(getParagraph(1), "ParaBottomMargin"));
659 DECLARE_OOXMLEXPORT_TEST(testParagraphMark
, "paragraph-mark.docx")
661 // The problem was that we didn't handle the situation when an empty paragraph's marker had both a char style and some direct formatting.
664 CPPUNIT_ASSERT_EQUAL(12.f
, getProperty
<float>(getParagraph(1), "CharHeight"));
666 CPPUNIT_ASSERT_EQUAL(OUString("Emphasis"), getProperty
<OUString
>(getRun(getParagraph(1), 1), "CharStyleName"));
669 DECLARE_OOXMLEXPORT_TEST(testParagraphMark2
, "paragraph-mark2.docx")
671 // The problem was that we didn't handle the situation when an empty paragraph's marker had both a char style and some direct formatting.
673 // This was Segoe UI, set by Char Style FontStyle11 presumably.
674 CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty
<OUString
>(getRun(getParagraph(1), 1), "CharFontName"));
675 // This was 11, set by Char Style FontStyle11 presumably.
676 CPPUNIT_ASSERT_EQUAL(10.f
, getProperty
<float>(getRun(getParagraph(1), 1), "CharHeight"));
679 CPPUNIT_TEST_FIXTURE(Test
, testParagraphMarkNonempty
)
681 loadAndSave("paragraph-mark-nonempty.odt");
682 validate(maTempFile
.GetFileName(), test::OOXML
);
683 CPPUNIT_ASSERT_EQUAL(1, getPages());
684 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
685 // There were two <w:sz> elements, make sure the 40 one is dropped and the 20 one is kept.
686 assertXPath(pXmlDoc
, "//w:p/w:pPr/w:rPr/w:sz", "val", "20");
689 DECLARE_OOXMLEXPORT_TEST(testPageBreakBefore
, "page-break-before.docx")
691 // This was style::BreakType_PAGE_BEFORE, i.e. page break wasn't ignored, as it should have been.
692 CPPUNIT_ASSERT_EQUAL(style::BreakType_NONE
, getProperty
<style::BreakType
>(getParagraph(2), "BreakType"));
695 DECLARE_OOXMLEXPORT_TEST(testTableRtl
, "table-rtl.docx")
697 uno::Reference
<text::XTextTablesSupplier
> xTablesSupplier(mxComponent
, uno::UNO_QUERY
);
698 uno::Reference
<container::XIndexAccess
> xTables(xTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
699 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
700 // This was text::WritingMode2::LR_TB, i.e. direction of the table was ignored.
701 CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB
, getProperty
<sal_Int16
>(xTable
, "WritingMode"));
704 DECLARE_OOXMLEXPORT_TEST(testTableLr
, "table-ltr.docx")
706 uno::Reference
<text::XTextTablesSupplier
> xTablesSupplier(mxComponent
, uno::UNO_QUERY
);
707 uno::Reference
<container::XIndexAccess
> xTables(xTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
708 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
709 // This was text::WritingMode2::RL_TB, i.e. direction of the table was wrongly guessed.
710 CPPUNIT_ASSERT_EQUAL(text::WritingMode2::CONTEXT
, getProperty
<sal_Int16
>(xTable
, "WritingMode"));
713 DECLARE_OOXMLEXPORT_TEST(testOoxmlCjklist30
, "cjklist30.docx")
715 sal_Int16 numFormat
= getNumberingTypeOfParagraph(1);
716 CPPUNIT_ASSERT_EQUAL(style::NumberingType::TIAN_GAN_ZH
, numFormat
);
719 DECLARE_OOXMLEXPORT_TEST(testOoxmlCjklist31
, "cjklist31.docx")
721 sal_Int16 numFormat
= getNumberingTypeOfParagraph(1);
722 CPPUNIT_ASSERT_EQUAL(style::NumberingType::DI_ZI_ZH
, numFormat
);
725 DECLARE_OOXMLEXPORT_TEST(testOoxmlCjklist34
, "cjklist34.docx")
727 sal_Int16 numFormat
= getNumberingTypeOfParagraph(1);
728 CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_UPPER_ZH_TW
, numFormat
);
731 DECLARE_OOXMLEXPORT_TEST(testOoxmlCjklist35
, "cjklist35.docx")
733 sal_Int16 numFormat
= getNumberingTypeOfParagraph(1);
734 CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_LOWER_ZH
, numFormat
);
737 DECLARE_OOXMLEXPORT_TEST(testOoxmlCjklist44
, "cjklist44.docx")
739 sal_Int16 numFormat
= getNumberingTypeOfParagraph(1);
740 CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_DIGITAL2_KO
, numFormat
);
743 DECLARE_OOXMLEXPORT_TEST(testOoxmlTextNumberList
, "text_number_list.docx")
745 sal_Int16 numFormat
= getNumberingTypeOfParagraph(1);
746 CPPUNIT_ASSERT_EQUAL(style::NumberingType::TEXT_NUMBER
, numFormat
);
749 DECLARE_OOXMLEXPORT_TEST(testOoxmlTextCardinalList
, "text_cardinal_list.docx")
751 sal_Int16 numFormat
= getNumberingTypeOfParagraph(1);
752 CPPUNIT_ASSERT_EQUAL(style::NumberingType::TEXT_CARDINAL
, numFormat
);
755 DECLARE_OOXMLEXPORT_TEST(testOoxmlTextOrdinalList
, "text_ordinal_list.docx")
757 sal_Int16 numFormat
= getNumberingTypeOfParagraph(1);
758 CPPUNIT_ASSERT_EQUAL(style::NumberingType::TEXT_ORDINAL
, numFormat
);
761 DECLARE_OOXMLEXPORT_TEST(testOoxmlSymbolChicagoList
, "symbol_chicago_list.docx")
763 sal_Int16 numFormat
= getNumberingTypeOfParagraph(1);
764 CPPUNIT_ASSERT_EQUAL(style::NumberingType::SYMBOL_CHICAGO
, numFormat
);
767 CPPUNIT_TEST_FIXTURE(Test
, testOoxmlNumListZHTW
)
769 loadAndSave("numlist-zhtw.odt");
770 CPPUNIT_ASSERT_EQUAL(1, getPages());
771 xmlDocUniquePtr pXmlDoc
= parseExport("word/numbering.xml");
773 assertXPath ( pXmlDoc
, "/w:numbering/w:abstractNum[1]/w:lvl[1]/w:numFmt","val","taiwaneseCountingThousand" );
776 CPPUNIT_TEST_FIXTURE(Test
, testOoxmlNumListZHCN
)
778 loadAndSave("numlist-zhcn.odt");
779 CPPUNIT_ASSERT_EQUAL(1, getPages());
780 xmlDocUniquePtr pXmlDoc
= parseExport("word/numbering.xml");
782 assertXPath ( pXmlDoc
, "/w:numbering/w:abstractNum[1]/w:lvl[1]/w:numFmt","val","chineseCountingThousand" );
785 CPPUNIT_TEST_FIXTURE(Test
, testOOxmlOutlineNumberTypes
)
787 loadAndSave("outline-number-types.odt");
788 CPPUNIT_ASSERT_EQUAL(1, getPages());
789 xmlDocUniquePtr pXmlDoc
= parseExport("word/numbering.xml");
791 assertXPath(pXmlDoc
, "/w:numbering/w:abstractNum[1]/w:lvl[1]/w:pStyle", "val", "Heading1");
792 assertXPath(pXmlDoc
, "/w:numbering/w:abstractNum[1]/w:lvl[1]/w:numFmt", "val", "none");
793 assertXPath(pXmlDoc
, "/w:numbering/w:abstractNum[1]/w:lvl[2]/w:numFmt", "val", "decimalEnclosedCircle");
794 assertXPath(pXmlDoc
, "/w:numbering/w:abstractNum[1]/w:lvl[3]/w:numFmt", "val", "decimal"); // CHARS_GREEK_UPPER_LETTER fallback to decimal
795 assertXPath(pXmlDoc
, "/w:numbering/w:abstractNum[1]/w:lvl[4]/w:numFmt", "val", "decimal"); // CHARS_GREEK_LOWER_LETTER fallback to decimal
796 assertXPath(pXmlDoc
, "/w:numbering/w:abstractNum[1]/w:lvl[5]/w:numFmt", "val", "arabicAlpha");
797 assertXPath(pXmlDoc
, "/w:numbering/w:abstractNum[1]/w:lvl[6]/w:numFmt", "val", "hindiVowels");
798 assertXPath(pXmlDoc
, "/w:numbering/w:abstractNum[1]/w:lvl[7]/w:numFmt", "val", "thaiLetters");
800 assertXPath(pXmlDoc
, "/w:numbering/w:abstractNum[2]/w:lvl[1]/w:numFmt", "val", "decimal");
801 assertXPath(pXmlDoc
, "/w:numbering/w:abstractNum[2]/w:lvl[2]/w:numFmt", "val", "decimal");
802 assertXPath(pXmlDoc
, "/w:numbering/w:abstractNum[2]/w:lvl[3]/w:numFmt", "val", "decimal");
803 assertXPath(pXmlDoc
, "/w:numbering/w:abstractNum[2]/w:lvl[4]/w:numFmt", "val", "decimal");
804 assertXPath(pXmlDoc
, "/w:numbering/w:abstractNum[2]/w:lvl[5]/w:numFmt", "val", "russianUpper");
805 assertXPath(pXmlDoc
, "/w:numbering/w:abstractNum[2]/w:lvl[6]/w:numFmt", "val", "russianLower");
806 assertXPath(pXmlDoc
, "/w:numbering/w:abstractNum[2]/w:lvl[7]/w:numFmt", "val", "russianUpper");
807 assertXPath(pXmlDoc
, "/w:numbering/w:abstractNum[2]/w:lvl[8]/w:numFmt", "val", "russianLower");
809 assertXPath(pXmlDoc
, "/w:numbering/w:abstractNum[3]/w:lvl[1]/w:numFmt", "val", "decimal");
810 assertXPath(pXmlDoc
, "/w:numbering/w:abstractNum[3]/w:lvl[2]/w:numFmt", "val", "decimal");
811 assertXPath(pXmlDoc
, "/w:numbering/w:abstractNum[3]/w:lvl[3]/w:numFmt", "val", "decimal");
812 assertXPath(pXmlDoc
, "/w:numbering/w:abstractNum[3]/w:lvl[4]/w:numFmt", "val", "decimal");
813 assertXPath(pXmlDoc
, "/w:numbering/w:abstractNum[3]/w:lvl[5]/w:numFmt", "val", "decimal");
814 assertXPath(pXmlDoc
, "/w:numbering/w:abstractNum[3]/w:lvl[6]/w:numFmt", "val", "decimal");
815 assertXPath(pXmlDoc
, "/w:numbering/w:abstractNum[3]/w:lvl[7]/w:numFmt", "val", "decimal");
819 DECLARE_OOXMLEXPORT_TEST(testNumParentStyle
, "num-parent-style.docx")
821 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1),
822 getProperty
<sal_Int32
>(getParagraph(1), "OutlineLevel"));
823 CPPUNIT_ASSERT_EQUAL(OUString("1"), getProperty
<OUString
>(getParagraph(1), "ListLabelString"));
824 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2),
825 getProperty
<sal_Int32
>(getParagraph(2), "OutlineLevel"));
826 CPPUNIT_ASSERT_EQUAL(OUString("1.1"), getProperty
<OUString
>(getParagraph(2), "ListLabelString"));
827 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1),
828 getProperty
<sal_Int32
>(getParagraph(3), "OutlineLevel"));
829 CPPUNIT_ASSERT_EQUAL(OUString("2"), getProperty
<OUString
>(getParagraph(3), "ListLabelString"));
830 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2),
831 getProperty
<sal_Int32
>(getParagraph(4), "OutlineLevel"));
832 CPPUNIT_ASSERT_EQUAL(OUString("2.1"), getProperty
<OUString
>(getParagraph(4), "ListLabelString"));
835 DECLARE_OOXMLEXPORT_TEST(testNumOverrideLvltext
, "num-override-lvltext.docx")
837 uno::Reference
<container::XIndexAccess
> xRules
= getProperty
< uno::Reference
<container::XIndexAccess
> >(getStyles("NumberingStyles")->getByName("WWNum1"), "NumberingRules");
838 // This was 1, i.e. the numbering on the second level was "1", not "1.1".
839 // Check the paragraph properties, not the list ones, since they can differ due to overrides
840 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(1), uno::UNO_QUERY
);
841 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(1), getProperty
<sal_Int16
>(xPara
, "NumberingLevel"));
842 CPPUNIT_ASSERT_EQUAL(OUString("1.1"), getProperty
<OUString
>(xPara
, "ListLabelString"));
844 // The paragraph marker's red font color was inherited by the number portion, this was ff0000.
845 CPPUNIT_ASSERT_EQUAL(OUString("ffffffff"), parseDump("//SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']/SwFont", "color"));
848 DECLARE_OOXMLEXPORT_TEST(testNumOverrideStart
, "num-override-start.docx")
850 uno::Reference
<container::XIndexAccess
> xRules
= getProperty
< uno::Reference
<container::XIndexAccess
> >(getStyles("NumberingStyles")->getByName("WWNum1"), "NumberingRules");
851 // List starts with "1.1"
852 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), comphelper::SequenceAsHashMap(xRules
->getByIndex(1))["StartWith"].get
<sal_Int16
>());
853 // But paragraph starts with "1.3"
854 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(1), uno::UNO_QUERY
);
855 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(1), getProperty
<sal_Int16
>(xPara
, "NumberingLevel"));
857 CPPUNIT_ASSERT(xPara
->getPropertyValue("ListId") >>= listId
);
858 CPPUNIT_ASSERT_EQUAL(OUString("1.3"), getProperty
<OUString
>(xPara
, "ListLabelString"));
861 DECLARE_OOXMLEXPORT_TEST(testTextboxRightEdge
, "textbox-right-edge.docx")
863 // I'm fairly sure this is not specific to DOCX, but the doc model created
864 // by the ODF import doesn't trigger this bug, so let's test this here
865 // instead of uiwriter.
866 int nShapeLeft
= parseDump("//anchored/SwAnchoredDrawObject/bounds", "left").toInt32();
867 int nShapeWidth
= parseDump("//anchored/SwAnchoredDrawObject/bounds", "width").toInt32();
868 int nTextboxLeft
= parseDump("//anchored/fly/infos/bounds", "left").toInt32();
869 int nTextboxWidth
= parseDump("//anchored/fly/infos/bounds", "width").toInt32();
870 // This is a rectangle, make sure the right edge of the textbox is still
871 // inside the draw shape.
872 CPPUNIT_ASSERT(nShapeLeft
+ nShapeWidth
>= nTextboxLeft
+ nTextboxWidth
);
875 DECLARE_OOXMLEXPORT_TEST(testEffectExtentMargin
, "effectextent-margin.docx")
877 // This was 318, i.e. oox::drawingml::convertEmuToHmm(114300), effectExtent
878 // wasn't part of the margin, leading to the fly not taking enough space
880 CPPUNIT_ASSERT_EQUAL(oox::drawingml::convertEmuToHmm(114300+95250), getProperty
<sal_Int32
>(getShape(1), "LeftMargin"));
883 CPPUNIT_TEST_FIXTURE(Test
, testTdf88583
)
885 loadAndReload("tdf88583.odt");
886 CPPUNIT_ASSERT_EQUAL(1, getPages());
887 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, getProperty
<drawing::FillStyle
>(getParagraph(1), "FillStyle"));
888 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(0x00cc00), getProperty
<sal_Int32
>(getParagraph(1), "FillColor"));
891 DECLARE_OOXMLEXPORT_TEST(testTdf97090
, "tdf97090.docx")
893 uno::Reference
<text::XTextTablesSupplier
> xTablesSupplier(mxComponent
, uno::UNO_QUERY
);
894 uno::Reference
<container::XIndexAccess
> xTables(xTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
895 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
896 CPPUNIT_ASSERT_EQUAL(Color(0x95B3D7), getProperty
<Color
>(xTable
->getCellByName("A1"), "BackColor"));
898 uno::Reference
<container::XEnumerationAccess
> paraEnumAccess(xTable
->getCellByName("A1"), uno::UNO_QUERY
);
899 assert( paraEnumAccess
.is() );
900 uno::Reference
<container::XEnumeration
> paraEnum
= paraEnumAccess
->createEnumeration();
902 assert( paraEnum
.is() );
903 uno::Reference
<beans::XPropertySet
> paragraphProperties(paraEnum
->nextElement(), uno::UNO_QUERY
);
904 assert( paragraphProperties
.is() );
905 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE
, getProperty
<drawing::FillStyle
>(paragraphProperties
, "FillStyle"));
906 CPPUNIT_ASSERT_EQUAL(Color(0xffffff), getProperty
<Color
>(paragraphProperties
, "FillColor"));
909 DECLARE_OOXMLEXPORT_TEST(testTdf89791
, "tdf89791.docx")
913 uno::Reference
<packages::zip::XZipFileAccess2
> xNameAccess
= packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory
), maTempFile
.GetURL());
914 CPPUNIT_ASSERT_EQUAL(false, bool(xNameAccess
->hasByName("docProps/custom.xml")));
917 //tdf#102619 - setting FollowStyle with a not-yet-created style was failing. (Titre is created before Corps de texte).
918 uno::Reference
< beans::XPropertySet
> properties(getStyles("ParagraphStyles")->getByName("Titre"), uno::UNO_QUERY
);
919 CPPUNIT_ASSERT_EQUAL(OUString("Corps de texte"), getProperty
<OUString
>(properties
, "FollowStyle"));
922 DECLARE_OOXMLEXPORT_TEST(testTdf91261
, "tdf91261.docx")
924 bool snapToGrid
= true;
925 uno::Reference
< text::XTextRange
> xPara
= getParagraph( 2 );
926 uno::Reference
< beans::XPropertySet
> properties( xPara
, uno::UNO_QUERY
);
927 properties
->getPropertyValue("SnapToGrid") >>= snapToGrid
;
928 CPPUNIT_ASSERT_EQUAL(false, snapToGrid
);
930 uno::Reference
< beans::XPropertySet
> xStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY
);
932 xStyle
->getPropertyValue("GridMode") >>= nGridMode
;
933 CPPUNIT_ASSERT_EQUAL( sal_Int16(2), nGridMode
);
935 bool bGridSnapToChars
;
936 xStyle
->getPropertyValue("GridSnapToChars") >>= bGridSnapToChars
;
937 CPPUNIT_ASSERT_EQUAL(true, bGridSnapToChars
);
941 DECLARE_OOXMLEXPORT_TEST(testTdf79639
, "tdf79639.docx")
943 // This was 0, floating table in header wasn't converted to a TextFrame.
944 CPPUNIT_ASSERT_EQUAL(1, getShapes());
947 DECLARE_OOXMLEXPORT_TEST(testTdf89890
, "tdf89890.docx")
949 // Numbering picture bullet was too large.
950 uno::Reference
<beans::XPropertySet
> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY
);
951 uno::Reference
<container::XIndexAccess
> xLevels(xPropertySet
->getPropertyValue("NumberingRules"), uno::UNO_QUERY
);
952 uno::Sequence
<beans::PropertyValue
> aProps
;
953 xLevels
->getByIndex(0) >>= aProps
; // 1st level
956 for (beans::PropertyValue
const & rProp
: std::as_const(aProps
))
958 if (rProp
.Name
== "GraphicSize")
960 // Height of the graphic was too large: 4382 after import, then 2485 after roundtrip.
961 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(279), rProp
.Value
.get
<awt::Size
>().Height
);
965 CPPUNIT_ASSERT(bFound
);
968 DECLARE_OOXMLEXPORT_TEST(testTdf91594
, "tdf91594.docx")
970 uno::Reference
<text::XTextRange
> xPara1(getParagraph(1));
971 CPPUNIT_ASSERT_EQUAL(u
'\xf0fb', xPara1
->getString()[0] );
972 uno::Reference
<text::XTextRange
> xPara2(getParagraph(2));
973 CPPUNIT_ASSERT_EQUAL(u
'\xf0fc', xPara2
->getString()[0] );
974 uno::Reference
<text::XTextRange
> xPara3(getParagraph(3));
975 CPPUNIT_ASSERT_EQUAL(u
'\xf0fd', xPara3
->getString()[0] );
976 uno::Reference
<text::XTextRange
> xPara4(getParagraph(4));
977 CPPUNIT_ASSERT_EQUAL(u
'\xf0fe', xPara4
->getString()[0] );
979 uno::Reference
<beans::XPropertySet
> xRun(getRun(xPara1
,1), uno::UNO_QUERY
);
980 CPPUNIT_ASSERT_EQUAL(OUString("Wingdings"), getProperty
<OUString
>(xRun
, "CharFontName"));
981 CPPUNIT_ASSERT_EQUAL(OUString("Wingdings"), getProperty
<OUString
>(xRun
, "CharFontNameAsian"));
982 CPPUNIT_ASSERT_EQUAL(OUString("Wingdings"), getProperty
<OUString
>(xRun
, "CharFontNameComplex"));
984 DECLARE_OOXMLEXPORT_TEST(testTDF99434
, "protectedform.docx")
986 css::uno::Reference
<css::lang::XMultiServiceFactory
> m_xTextFactory(mxComponent
, uno::UNO_QUERY
);
987 uno::Reference
< beans::XPropertySet
> xSettings(m_xTextFactory
->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY
);
988 uno::Any aProtect
= xSettings
->getPropertyValue("ProtectForm");
991 CPPUNIT_ASSERT(bProt
);
994 DECLARE_OOXMLEXPORT_TEST(testTdf44986
, "tdf44986.docx")
996 // Check that the table at the second paragraph.
997 uno::Reference
<text::XTextTable
> xTable(getParagraphOrTable(2), uno::UNO_QUERY
);
998 uno::Reference
<table::XTableRows
> xTableRows
= xTable
->getRows();
999 // Check the first row of the table, it should have two cells (one separator).
1000 // This was 0: the first row had no separators, so it had only one cell, which was too wide.
1001 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty
< uno::Sequence
<text::TableColumnSeparator
> >(xTableRows
->getByIndex(0), "TableColumnSeparators").getLength());
1002 // Check content of cells, including the newly added gridAfter cell
1003 CPPUNIT_ASSERT_EQUAL(OUString("A1"), uno::Reference
<text::XTextRange
>(xTable
->getCellByName("A1"), uno::UNO_QUERY_THROW
)->getString());
1004 CPPUNIT_ASSERT_EQUAL(OUString("A2"), uno::Reference
<text::XTextRange
>(xTable
->getCellByName("A2"), uno::UNO_QUERY_THROW
)->getString());
1005 CPPUNIT_ASSERT_EQUAL(OUString(""), uno::Reference
<text::XTextRange
>(xTable
->getCellByName("B1"), uno::UNO_QUERY_THROW
)->getString());
1008 CPPUNIT_TEST_FIXTURE(Test
, testTdf118682
)
1010 loadAndSave("tdf118682.fodt");
1011 // Support cell references in table formulas
1012 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1014 // Formula fields were completely missing.
1015 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:p/w:r/w:fldChar", 3);
1016 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[4]/w:tc/w:p/w:r/w:fldChar", 3);
1018 // Cell references were parenthesized: <A1>+<A2> and SUM(<A1:A3>)
1019 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:p/w:r[2]/w:instrText", " =A1+A2");
1020 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[4]/w:tc/w:p/w:r[2]/w:instrText", " =SUM(A1:A3)");
1023 CPPUNIT_TEST_FIXTURE(Test
, testTdf133163
)
1025 loadAndSave("tdf133163.fodt");
1026 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1028 // Formula cells were completely missing.
1029 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:p/w:r/w:fldChar", 3);
1030 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[4]/w:tc/w:p/w:r/w:fldChar", 3);
1032 // Cell references were parenthesized: <A1>+<A2> and SUM(<A1:A3>)
1033 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:p/w:r[2]/w:instrText", " =A1+A2");
1034 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[4]/w:tc/w:p/w:r[2]/w:instrText", " =SUM(A1:A3)");
1037 CPPUNIT_TEST_FIXTURE(Test
, testTdf133647
)
1039 loadAndSave("tdf133647.docx");
1040 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1042 // Keep original formula during round-trip
1043 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[4]/w:tc[4]/w:p/w:r[2]/w:instrText", " =SUM(A1,B1)");
1044 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[5]/w:tc[4]/w:p/w:r[2]/w:instrText", " =SUM(C1:D1)");
1045 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[6]/w:tc[4]/w:p/w:r[2]/w:instrText", " =SUM(A1,5,B1:C1,6)");
1046 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[7]/w:tc[4]/w:p/w:r[2]/w:instrText", " =(1+2)*SUM(C1,D1)");
1047 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[8]/w:tc[4]/w:p/w:r[2]/w:instrText", " =3*(2+SUM(A1:C1)+7)");
1048 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[9]/w:tc[4]/w:p/w:r[2]/w:instrText", " =1+(SUM(1,2))");
1049 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[10]/w:tc[4]/w:p/w:r[2]/w:instrText", " =(SUM(C1,5)*(2+7))*(3+SUM(1,B1))");
1050 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[11]/w:tc[4]/w:p/w:r[2]/w:instrText", " =sum(a1,b1)");
1053 CPPUNIT_TEST_FIXTURE(Test
, testTdf123386
)
1055 loadAndSave("tdf123386.docx");
1056 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1058 // Keep original formula during round-trip
1059 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[3]/w:tc[4]/w:p/w:r[2]/w:instrText", " =A1 < 2");
1060 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[4]/w:tc[4]/w:p/w:r[2]/w:instrText", " =B1 > 1");
1061 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[5]/w:tc[4]/w:p/w:r[2]/w:instrText", " =C1=3");
1062 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[6]/w:tc[4]/w:p/w:r[2]/w:instrText", " =D1 <> 3");
1063 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[7]/w:tc[4]/w:p/w:r[2]/w:instrText", " =AND(A1=1,B1=2)");
1064 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[8]/w:tc[4]/w:p/w:r[2]/w:instrText", " =AND((A1<1),(B1<>2))");
1065 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[9]/w:tc[4]/w:p/w:r[2]/w:instrText", " =OR(A1=1,B1=2)");
1066 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[10]/w:tc[4]/w:p/w:r[2]/w:instrText", " =OR(TRUE,FALSE)");
1067 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[11]/w:tc[4]/w:p/w:r[2]/w:instrText", " =NOT(TRUE)");
1068 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[12]/w:tc[4]/w:p/w:r[2]/w:instrText", " =AND(1,DEFINED(ABC1))");
1071 CPPUNIT_TEST_FIXTURE(Test
, testTdf123389
)
1073 loadAndSave("tdf123389.docx");
1074 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1076 // Keep original formula during round-trip
1077 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[3]/w:tc[4]/w:p/w:r[2]/w:instrText", " =ROUND(2.345,1)");
1078 assertXPathContent(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr[4]/w:tc[4]/w:p/w:r[2]/w:instrText", " =ROUND(A1,2)");
1081 DECLARE_OOXMLEXPORT_TEST(testTdf106953
, "tdf106953.docx")
1083 uno::Reference
<container::XIndexAccess
> xRules
= getProperty
< uno::Reference
<container::XIndexAccess
> >(getStyles("NumberingStyles")->getByName("WWNum1"), "NumberingRules");
1084 // This was -635, so the tab of the numbering expanded to a small value instead of matching Word's larger value.
1085 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(0), comphelper::SequenceAsHashMap(xRules
->getByIndex(0))["FirstLineIndent"].get
<sal_Int32
>());
1088 CPPUNIT_TEST_FIXTURE(Test
, testTdf115094v3
)
1090 createSwDoc("tdf115094v3.docx");
1092 SwDoc
* pDoc
= getSwDoc();
1093 auto& rSpzFormats
= *pDoc
->GetSpzFrameFormats();
1094 auto pFormat
= rSpzFormats
[0];
1095 // Without the fix, this has failed with:
1098 // i.e. some unwanted ~-2mm left margin appeared.
1099 CPPUNIT_ASSERT_EQUAL(static_cast<SwTwips
>(1991), pFormat
->GetHoriOrient().GetPos());
1102 // floating table is now exported directly without surrounding frame
1103 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1105 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tblPr/w:tblpPr", "tblpX", "1996");
1106 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tblPr/w:tblpPr", "tblpY", "1064");
1109 CPPUNIT_PLUGIN_IMPLEMENT();
1111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */