Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / qa / extras / ooxmlexport / ooxmlexport5.cxx
blob71cea9fa29647c65264185b2ddcc717cb49403d0
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 <com/sun/star/text/XDocumentIndex.hpp>
13 #include <com/sun/star/text/XFootnote.hpp>
14 #include <com/sun/star/text/XTextField.hpp>
15 #include <com/sun/star/text/XTextTable.hpp>
16 #include <com/sun/star/style/LineSpacing.hpp>
17 #include <com/sun/star/style/LineSpacingMode.hpp>
18 #include <com/sun/star/rdf/URI.hpp>
19 #include <com/sun/star/rdf/Statement.hpp>
21 #include <comphelper/processfactory.hxx>
22 #include <o3tl/cppunittraitshelper.hxx>
24 #include <pam.hxx>
25 #include <unotxdoc.hxx>
26 #include <docsh.hxx>
28 class Test : public SwModelTestBase
30 public:
31 Test() : SwModelTestBase("/sw/qa/extras/ooxmlexport/data/", "Office Open XML Text") {}
34 CPPUNIT_TEST_FIXTURE(Test, testFDO76248)
36 loadAndSave("FDO76248.docx");
37 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
38 // In two cases the a:graphicData elements had no children, which is invalid.
39 assertXPath(pXmlDoc, "//a:graphicData[not(*)]", 0);
42 DECLARE_OOXMLEXPORT_TEST(testTscp, "tscp.docx")
44 uno::Reference<uno::XComponentContext> xComponentContext(comphelper::getProcessComponentContext());
45 uno::Reference<rdf::XURI> xType = rdf::URI::create(xComponentContext, "urn:bails");
46 uno::Reference<rdf::XDocumentMetadataAccess> xDocumentMetadataAccess(mxComponent, uno::UNO_QUERY);
47 uno::Sequence< uno::Reference<rdf::XURI> > aGraphNames = xDocumentMetadataAccess->getMetadataGraphsWithType(xType);
48 // This failed, no graphs had the urn:bails type.
49 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aGraphNames.getLength());
50 uno::Reference<rdf::XURI> xGraphName = aGraphNames[0];
51 uno::Reference<rdf::XNamedGraph> xGraph = xDocumentMetadataAccess->getRDFRepository()->getGraph(xGraphName);
53 // No RDF statement on the first paragraph.
54 uno::Reference<rdf::XResource> xParagraph(getParagraph(1), uno::UNO_QUERY);
55 uno::Reference<container::XEnumeration> xStatements = xGraph->getStatements(xParagraph, uno::Reference<rdf::XURI>(), uno::Reference<rdf::XURI>());
56 CPPUNIT_ASSERT_EQUAL(false, static_cast<bool>(xStatements->hasMoreElements()));
58 // 3 RDF statements on the second paragraph.
59 xParagraph.set(getParagraph(2), uno::UNO_QUERY);
60 std::map<OUString, OUString> aExpectedStatements =
62 {"urn:bails:ExportControl:BusinessAuthorization:Identifier", "urn:example:tscp:1"},
63 {"urn:bails:ExportControl:BusinessAuthorizationCategory:Identifier", "urn:example:tscp:1:confidential"},
64 {"urn:bails:ExportControl:Authorization:StartValidity", "2015-11-27"}
66 std::map<OUString, OUString> aActualStatements;
67 xStatements = xGraph->getStatements(xParagraph, uno::Reference<rdf::XURI>(), uno::Reference<rdf::XURI>());
68 while (xStatements->hasMoreElements())
70 rdf::Statement aStatement = xStatements->nextElement().get<rdf::Statement>();
71 aActualStatements[aStatement.Predicate->getNamespace() + aStatement.Predicate->getLocalName()] = aStatement.Object->getStringValue();
73 CPPUNIT_ASSERT(bool(aExpectedStatements == aActualStatements));
75 // No RDF statement on the third paragraph.
76 xParagraph.set(getParagraph(3), uno::UNO_QUERY);
77 xStatements = xGraph->getStatements(xParagraph, uno::Reference<rdf::XURI>(), uno::Reference<rdf::XURI>());
78 CPPUNIT_ASSERT_EQUAL(false, static_cast<bool>(xStatements->hasMoreElements()));
81 CPPUNIT_TEST_FIXTURE(Test, testfdo76589 )
83 loadAndSave("fdo76589.docx");
84 /* Numbered list was not preserve after RT.
85 * In numbering.xml, when NumberingType is "decimal" and level is zero,
86 * w:val of w:lvlText was empty.
87 * It should be <w:lvlText w:val="%1" />
89 xmlDocUniquePtr pXmlDoc = parseExport("word/numbering.xml");
91 assertXPath ( pXmlDoc, "/w:numbering/w:abstractNum[1]/w:lvl[1]/w:lvlText","val","%1" );
94 CPPUNIT_TEST_FIXTURE(Test, testDecimalNumberingNoLeveltext)
96 loadAndSave("decimal-numbering-no-leveltext.docx");
97 // This was "%1", not empty: we turned a kind-of-none numbering into a decimal one.
98 xmlDocUniquePtr pXmlDoc = parseExport("word/numbering.xml");
99 assertXPath(pXmlDoc, "/w:numbering/w:abstractNum[1]/w:lvl[1]/w:lvlText","val","");
102 CPPUNIT_TEST_FIXTURE(Test, testNoDuplicateAttributeExport)
104 loadAndSave("duplicate-east-asia.odt");
105 CPPUNIT_ASSERT_EQUAL(1, getShapes());
106 CPPUNIT_ASSERT_EQUAL(1, getPages());
107 // File asserting while saving in LO.
108 parseExport("word/document.xml");
111 CPPUNIT_TEST_FIXTURE(Test, testfdo79008)
113 loadAndReload("fdo79008.docx");
114 /* File crashing while saving in LO.
115 * Check if document.xml file is created after fix
117 parseExport("word/document.xml");
119 // tdf#134951: there is only one comment
120 xmlDocUniquePtr pXmlSettings = parseExport("word/comments.xml");
121 assertXPath(pXmlSettings, "/w:comments/w:comment", 1);
123 // Read-only is set, but it is not enforced, so it should be off...
124 SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
125 CPPUNIT_ASSERT(pTextDoc);
126 CPPUNIT_ASSERT(!pTextDoc->GetDocShell()->IsSecurityOptOpenReadOnly());
129 DECLARE_OOXMLEXPORT_TEST(testTdf120852_readOnlyProtection, "tdf120852_readOnlyProtection.docx")
131 if (isExported())
133 xmlDocUniquePtr pXmlSettings = parseExport("word/settings.xml");
134 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "enforcement", "1");
135 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "edit", "readOnly");
138 // Read-only is set, so Enforcement must enable it.
139 SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
140 CPPUNIT_ASSERT(pTextDoc);
141 CPPUNIT_ASSERT(pTextDoc->GetDocShell()->IsSecurityOptOpenReadOnly());
144 DECLARE_OOXMLEXPORT_TEST(testTdf120852_readOnlyUnProtected, "tdf120852_readOnlyUnProtected.docx")
146 // Readonly is not enforced, just a suggestion,
147 // so when a section is protected, the document should enable forms protection.
148 SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
149 CPPUNIT_ASSERT(pTextDoc);
150 CPPUNIT_ASSERT(!pTextDoc->GetDocShell()->IsSecurityOptOpenReadOnly());
152 uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY_THROW);
153 uno::Reference<container::XIndexAccess> xSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY_THROW);
154 const sal_Int32 nLastSection = xSections->getCount() - 1;
155 uno::Reference<beans::XPropertySet> xSect(xSections->getByIndex(nLastSection), uno::UNO_QUERY_THROW);
156 if ( !isExported() )
158 CPPUNIT_ASSERT_MESSAGE("Section is not protected", !getProperty<bool>(xSect, "IsProtected"));
159 // Enable section protection. The round-trip should have forms protection enabled.
160 xSect->setPropertyValue("IsProtected", uno::Any(true));
162 else
164 CPPUNIT_ASSERT_MESSAGE("Section is protected", getProperty<bool>(xSect, "IsProtected"));
165 xmlDocUniquePtr pXmlSettings = parseExport("word/settings.xml");
166 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "edit", "forms");
167 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "enforcement", "true");
171 CPPUNIT_TEST_FIXTURE(Test, testAuthorPropertySdt)
173 loadAndSave("author-property.docx");
174 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
176 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:dataBinding", "xpath", "/ns1:coreProperties[1]/ns0:creator[1]");
177 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:dataBinding", "storeItemID","{6C3C8BC8-F283-45AE-878A-BAB7291924A1}");
178 // FIXME: the next property doesn't match, though it's correct in theory. A bug in assertXPath?
179 // assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:dataBinding", "prefixMappings",
180 // "xmlns:ns0='http://purl.org/dc/elements/1.1/' xmlns:ns1='http://schemas.openxmlformats.org/package/2006/metadata/core-properties'");
183 CPPUNIT_TEST_FIXTURE(Test, testFDO76586)
185 loadAndSave("fdo76586.docx");
187 * In the test file gridCol had only one value for entire table width
188 * while there are two cells in a table row.
189 * So the table was not imported with the correct cell widths
191 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
193 // there is only one table in the test file
194 assertXPath(pXmlDoc, "//w:tblGrid/w:gridCol[1]", "w", "1601");
195 assertXPath(pXmlDoc, "//w:tblGrid/w:gridCol[2]", "w", "7843");
198 CPPUNIT_TEST_FIXTURE(Test, testFDO76587 )
200 loadAndSave("fdo76587.docx");
201 xmlDocUniquePtr pXmlDoc = parseExport("word/styles.xml");
202 assertXPath(pXmlDoc, "/w:styles/w:style[8]/w:pPr/w:spacing", "line", "240");
203 assertXPath(pXmlDoc, "/w:styles/w:style[8]/w:pPr/w:spacing", "lineRule", "auto");
206 CPPUNIT_TEST_FIXTURE(Test, testFDO77890 )
208 loadAndSave("fdo77890.docx");
210 Ensure that the page break is preserved i.e it should not be converted to a section break, in case
211 if the different first page is set for the pages in the document.
212 For additional comments please refer to https://www.libreoffice.org/bugzilla/show_bug.cgi?id=77890#c2
214 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
215 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[2]/w:br", "type", "page");
218 CPPUNIT_TEST_FIXTURE(Test, testNumberedList)
220 loadAndReload("NumberedList.docx");
221 //fdo74150:In document.xml, for pStyle = "NumberedList1", iLvl and numId was not preserved
222 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
223 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:p[1]/w:pPr[1]/w:pStyle", "val", "NumberedList1");
224 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:p[1]/w:pPr[1]/w:numPr/w:ilvl","val", "0");
225 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:p[1]/w:pPr[1]/w:numPr/w:numId","val", "0");
227 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl[1]/w:tr[1]/w:tc[1]/w:p[3]/w:pPr[1]/w:pStyle","val", "NumberedList1");
228 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl[1]/w:tr[1]/w:tc[1]/w:p[3]/w:pPr[1]/w:numPr/w:ilvl","val", "0");
229 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl[1]/w:tr[1]/w:tc[1]/w:p[3]/w:pPr[1]/w:numPr/w:numId","val", "0");
232 CPPUNIT_TEST_FIXTURE(Test, testTdf131819)
234 loadAndSave("NumberedList.docx");
235 // keep width of fixed size cells in the nested table
236 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
237 // These were 4030 and 4249.
238 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblGrid/w:gridCol[1]", "w", "3841");
239 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblGrid/w:gridCol[2]", "w", "4049");
242 CPPUNIT_TEST_FIXTURE(Test, testTdf131959)
244 loadAndSave("NumberedList.docx");
245 // import tblInd from table style
246 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
247 // These were 0.
248 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblInd", "w", "360");
249 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblInd", "w", "360");
252 CPPUNIT_TEST_FIXTURE(Test, testTdf131203)
254 loadAndSave("tdf131203.docx");
255 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
256 // loading thrown divide_by_zero()
257 assertXPath(pXmlDoc, "//w:tbl", 2);
260 CPPUNIT_TEST_FIXTURE(Test, testFDO76597)
262 loadAndSave("fdo76597.docx");
263 // check XML
264 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
265 assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:pPr/w:spacing", "before", "96");
266 assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:pPr/w:spacing", "after", "120");
269 CPPUNIT_TEST_FIXTURE(Test, testContentTypeTIF)
271 loadAndSave("fdo77476.docx");
272 xmlDocUniquePtr pXmlDoc = parseExport("[Content_Types].xml");
274 assertXPath(pXmlDoc, "/ContentType:Types/ContentType:Override[@ContentType='image/tiff']", "PartName", "/word/media/image1.tif");
277 DECLARE_OOXMLEXPORT_TEST(testFDO77117, "fdo77117.docx")
279 uno::Reference<drawing::XShapes> xGroup(getShape(1), uno::UNO_QUERY);
280 uno::Reference<text::XTextRange> xShape(xGroup->getByIndex(0), uno::UNO_QUERY);
281 // This checks textbox textrun size of font which is in group shape.
282 CPPUNIT_ASSERT_EQUAL(11.f, getProperty<float>(xShape, "CharHeight"));
285 CPPUNIT_TEST_FIXTURE(Test, testFloatingTable)
287 loadAndSave("fdo77887.docx");
288 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
290 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "horzAnchor", "margin");
291 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "leftFromText", "141");
292 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "rightFromText", "141");
293 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "tblpXSpec", "center");
294 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "tblpY", "2266");
295 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "vertAnchor", "page");
297 //make sure not to write empty attributes which requires enumeration
298 assertXPathNoAttribute(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "tblpYSpec");
301 CPPUNIT_TEST_FIXTURE(Test, testOldComplexMergeRight)
303 loadAndSave("tdf90681-1.odt");
304 CPPUNIT_ASSERT_EQUAL(1, getPages());
305 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
307 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[2]/w:tcPr/w:vMerge", "val", "restart");
308 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[2]/w:tcPr/w:vMerge", "val", "continue");
309 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[3]/w:tc[2]/w:tcPr/w:vMerge", "val", "continue");
310 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[4]/w:tc[2]/w:tcPr/w:vMerge", "val", "continue");
313 CPPUNIT_TEST_FIXTURE(Test, testOldComplexMergeleft)
315 loadAndSave("tdf90681-2.odt");
316 CPPUNIT_ASSERT_EQUAL(1, getPages());
317 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
319 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:vMerge", "val", "restart");
320 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[1]/w:tcPr/w:vMerge", "val", "continue");
323 CPPUNIT_TEST_FIXTURE(Test, testOldComplexMergeTableInTable)
325 loadAndSave("ooo96040-2.odt");
326 parseExport("word/document.xml");
329 CPPUNIT_TEST_FIXTURE(Test, testHyperlinkContainingPlaceholderField)
331 loadAndReload("hyperlink-field.odt");
332 CPPUNIT_ASSERT_EQUAL(1, getShapes());
333 parseExport("word/document.xml");
335 // tdf#148380 output unknown field's contents("") instead of field name("Sender" aka e-mail)
336 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getParagraph(1)->getString().indexOf("Sender"));
339 CPPUNIT_TEST_FIXTURE(Test, testTablePreferredWidth)
341 loadAndSave("tablePreferredWidth.docx");
342 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
344 // Problem :If the table preferred width is in percent, then after RT it changes to 0 & width type changes
345 // to 'auto' instead of 'pct'.
346 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblW[1]", "w", "3000");
347 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblW[1]", "type","pct");
350 CPPUNIT_TEST_FIXTURE(Test, testFDO75431)
352 loadAndSave("fdo75431.docx");
353 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
355 assertXPath(pXmlDoc, "//w:tbl", 2);
356 assertXPath(pXmlDoc, "//w:p/w:pPr/w:sectPr/w:type", "val", "nextPage");
359 CPPUNIT_TEST_FIXTURE(Test, testFDO77725)
361 loadAndSave("fdo77725.docx");
362 xmlDocUniquePtr pXmlFootnotes = parseExport("word/footnotes.xml");
364 assertXPath(pXmlFootnotes, "//w:footnotes[1]/w:footnote[3]/w:p[3]/w:r[1]/w:br[1]", 0);
365 assertXPath(pXmlFootnotes, "//w:footnotes[1]/w:footnote[3]/w:p[3]/w:r[1]/w:br[2]", 0);
366 assertXPath(pXmlFootnotes, "//w:footnotes[1]/w:footnote[3]/w:p[3]/w:r[1]/w:br[3]", 0);
369 CPPUNIT_TEST_FIXTURE(Test, testFieldRotation)
371 loadAndReload("field-rotated.fodt");
372 uno::Reference<text::XTextRange> const xRun(getRun(uno::Reference<text::XTextRange>(getParagraphOrTable(1), uno::UNO_QUERY), 1));
373 uno::Reference<text::XTextField> const xField(getProperty<uno::Reference<text::XTextField>>(xRun, "TextField"));
374 CPPUNIT_ASSERT(xField.is());
375 CPPUNIT_ASSERT_EQUAL(OUString("DocInformation:Title"), xField->getPresentation(true));
376 CPPUNIT_ASSERT_EQUAL(OUString("Rotationeering"), xField->getPresentation(false));
377 // problem was that the rotation wasn't applied to all runs of the field
378 CPPUNIT_ASSERT_EQUAL(sal_Int16(900), getProperty<sal_Int16>(xRun, "CharRotation"));
381 CPPUNIT_TEST_FIXTURE(Test, testFootnoteSeparator)
383 loadAndSave("footnotesep.fodt");
384 // footnote separator definitions - taken from default page style
385 xmlDocUniquePtr pXmlFootnotes = parseExport("word/footnotes.xml");
386 assertXPath(pXmlFootnotes, "/w:footnotes[1]/w:footnote[1]", "id", "0");
387 assertXPath(pXmlFootnotes, "/w:footnotes[1]/w:footnote[1]", "type", "separator");
388 assertXPath(pXmlFootnotes, "/w:footnotes[1]/w:footnote[1]/w:p[1]/w:r[1]/w:separator", 0);
389 // use paragraph font size to simulate height
390 assertXPath(pXmlFootnotes, "/w:footnotes[1]/w:footnote[1]/w:p[1]/w:pPr[1]/w:rPr[1]/w:sz", "val", "12");
391 assertXPath(pXmlFootnotes, "/w:footnotes[1]/w:footnote[2]", "id", "1");
392 assertXPath(pXmlFootnotes, "/w:footnotes[1]/w:footnote[2]", "type", "continuationSeparator");
393 assertXPath(pXmlFootnotes, "/w:footnotes[1]/w:footnote[2]/w:p[1]/w:r[1]/w:continuationSeparator", 0);
394 assertXPath(pXmlFootnotes, "/w:footnotes[1]/w:footnote[2]/w:p[1]/w:pPr[1]/w:rPr[1]/w:sz", "val", "12");
396 xmlDocUniquePtr pXmlSettings = parseExport("word/settings.xml");
397 assertXPath(pXmlSettings, "/w:settings[1]/w:footnotePr[1]/w:footnote[1]", "id", "0");
398 assertXPath(pXmlSettings, "/w:settings[1]/w:footnotePr[1]/w:footnote[2]", "id", "1");
401 CPPUNIT_TEST_FIXTURE(Test, testTdf121441)
403 loadAndSave("tdf121441.docx");
404 xmlDocUniquePtr pXmlFootnotes = parseExport("word/footnotes.xml");
405 assertXPath(pXmlFootnotes, "/w:footnotes/w:footnote[3]/w:p/w:r[1]/w:rPr/w:rStyle", 1);
406 assertXPath(pXmlFootnotes, "/w:footnotes/w:footnote[3]/w:p/w:r[2]/w:rPr/w:rStyle", 0);
407 assertXPath(pXmlFootnotes, "/w:footnotes/w:footnote[3]/w:p/w:r[2]/w:rPr/w:rFonts", 0);
409 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
410 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:rPr/w:rFonts", "eastAsia", "Symbol");
411 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:rPr/w:rFonts", "cs", "Symbol");
412 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:rPr/w:rFonts", "ascii", "Symbol");
413 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:rPr/w:rFonts", "hAnsi", "Symbol");
416 CPPUNIT_TEST_FIXTURE(Test, testFDO77812)
418 loadAndSave("fdo77812.docx");
419 /* Additional sectPr was getting inserted and hence Column properties
420 * were getting added into this additional sectPr instead of Default setPr.
422 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
424 // Check no additional section break is inserted.
425 assertXPath(pXmlDoc, "/w:document/w:body/w:p[6]/w:pPr/w:sectPr", 0);
427 // Check w:cols comes under Default sectPr
428 assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:cols", "num", "2");
429 assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:cols/w:col[1]", 1);
430 assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:cols/w:col[2]", 1);
433 CPPUNIT_TEST_FIXTURE(Test, testContentTypeOLE)
435 loadAndSave("fdo77759.docx");
436 xmlDocUniquePtr pXmlDoc = parseExport("[Content_Types].xml");
438 assertXPath(pXmlDoc,
439 "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']",
440 "PartName",
441 "/word/embeddings/oleObject1.xlsx");
443 // check the rels too
444 xmlDocUniquePtr pXmlDocRels = parseExport("word/_rels/document.xml.rels");
445 assertXPath(pXmlDocRels,
446 "/rels:Relationships/rels:Relationship[@Target='embeddings/oleObject1.xlsx']",
447 "Type",
448 "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package");
449 // check the content too
450 xmlDocUniquePtr pXmlDocContent = parseExport("word/document.xml");
451 assertXPath(pXmlDocContent,
452 "/w:document/w:body/w:p[1]/w:r/w:object/o:OLEObject",
453 "ProgID",
454 "Excel.Sheet.12");
457 CPPUNIT_TEST_FIXTURE(Test, testfdo78420)
459 loadAndSave("fdo78420.docx");
460 xmlDocUniquePtr pXmlHeader = parseExport("word/header2.xml");
462 xmlDocUniquePtr pXmlHeaderRels = parseExport("word/_rels/header2.xml.rels");
464 assertXPath(pXmlHeaderRels,"/rels:Relationships/rels:Relationship[1]","Id","rId1");
468 CPPUNIT_TEST_FIXTURE(Test, testPageBreakInFirstPara)
470 loadAndReload("fdo77727.docx");
471 /* Break to next page was not exported if it is in first paragraph of the section.
472 * Now after fix , LO writes Next Page Break and also preserves <w:br> tag.
474 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
476 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[2]/w:br","type","page");
479 CPPUNIT_TEST_FIXTURE(Test, testFDO78284)
481 loadAndSave("fdo78284.docx");
482 xmlDocUniquePtr pXmlDoc = parseExport("[Content_Types].xml");
483 assertXPath(pXmlDoc,"/ContentType:Types/ContentType:Override[@PartName='/word/media/OOXDiagramDataRels1_0.png']",
484 "ContentType",
485 "image/png");
488 CPPUNIT_TEST_FIXTURE(Test, testFDO78384)
490 loadAndReload("fdo78384.docx");
491 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
492 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[1]/w:rPr/w:rFonts","ascii","Wingdings");
495 CPPUNIT_TEST_FIXTURE(Test, testfdo78469)
497 loadAndSave("fdo78469.docx");
498 xmlDocUniquePtr pXmlDoc = parseExport("word/header1.xml");
499 // make sure dataBinding & text tags not present in sdtcontent
500 assertXPath(pXmlDoc, "/w:hdr[1]/w:tbl[1]/w:tr[1]/w:tc[2]/w:p[1]/w:sdt[2]/w:sdtPr[1]/w:dataBinding[1]",0);
501 assertXPath(pXmlDoc, "/w:hdr[1]/w:tbl[1]/w:tr[1]/w:tc[2]/w:p[1]/w:sdt[2]/w:sdtPr[1]/w:text[1]",0);
504 CPPUNIT_TEST_FIXTURE(Test, testFDO78887)
506 loadAndSave("fdo78887.docx");
507 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
509 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/w:br[1]", 1);
510 assertXPathContent(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/w:t[1]", "Lyrics: ");
511 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/w:br[2]", 1);
514 CPPUNIT_TEST_FIXTURE(Test, testFDO78887b)
516 loadAndSave("missing_newline.odt");
517 CPPUNIT_ASSERT_EQUAL(1, getPages());
518 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
520 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[2]/w:br[1]", 1);
521 assertXPathContent(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/w:t[1]", "Tab and line break");
522 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[5]/w:br[1]", 1);
523 assertXPathContent(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[6]/w:t[1]", "New line");
526 CPPUNIT_TEST_FIXTURE(Test, testFdo78651)
528 loadAndSave("fdo78651.docx");
529 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
530 // ensure that there are only two tables
531 assertXPath(pXmlDoc, "//w:tbl", 2);
534 CPPUNIT_TEST_FIXTURE(Test, testfdo78882)
536 loadAndSave("fdo78882.docx");
537 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
539 // Ensure that Section Break is getting written inside second paragraph
540 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[2]/w:pPr[1]/w:sectPr[1]",1);
542 // Ensure that no dummy paragraph gets created inside second paragraph for Section Break
543 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[2]/w:p[1]/w:pPr[1]/w:sectPr[1]",0);
546 CPPUNIT_TEST_FIXTURE(Test, testfdo76934)
548 loadAndSave("fdo76934.docx");
549 /* Issue was, AutoSpacing property if present inside styles.xml, LO was not able to
550 * preserve it.
553 xmlDocUniquePtr pXmlDoc = parseExport("word/styles.xml");
555 // Ensure that after fix LO is preserving AutoSpacing property in styles.xml
556 assertXPath ( pXmlDoc, "/w:styles[1]/w:style[@w:styleId='Title']/w:pPr[1]/w:spacing[1]", "beforeAutospacing", "1" );
559 CPPUNIT_TEST_FIXTURE(Test, testfdo79540)
561 loadAndSave("fdo79540.docx");
562 /* Issue was, <w:drawing> was getting written inside <w:drawing>.
563 * So postpone the writing of Inner Drawing tag.
564 * MS Office does not allow nesting of drawing tags.
567 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
569 // Ensure that two separate w:drawing tags are written and they are not nested.
570 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing", 1);
571 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing", 1);
574 CPPUNIT_TEST_FIXTURE(Test, testFDO79062)
576 loadAndSave("fdo79062.docx");
577 xmlDocUniquePtr pXmlFootNotes = parseExport("word/footnotes.xml");
578 assertXPath(pXmlFootNotes, "/w:footnotes", "Ignorable", "w14 wp14 w15");
580 xmlDocUniquePtr pXmlEndNotes = parseExport("word/endnotes.xml");
581 assertXPath(pXmlEndNotes, "/w:endnotes", "Ignorable", "w14 wp14 w15");
583 //tdf#93121 don't add fake tabs in front of extra footnote paragraphs
584 uno::Reference<text::XFootnotesSupplier> xFootnoteSupp(mxComponent, uno::UNO_QUERY);
585 uno::Reference<container::XIndexAccess> xFootnoteIdxAcc = xFootnoteSupp->getFootnotes();
586 uno::Reference<text::XFootnote> xFootnote(xFootnoteIdxAcc->getByIndex(0), uno::UNO_QUERY);
587 uno::Reference<text::XText> xFootnoteText(xFootnote, uno::UNO_QUERY);
588 uno::Reference<container::XEnumerationAccess>xParaEnumAccess(xFootnoteText->getText(), uno::UNO_QUERY);
589 uno::Reference<container::XEnumeration>xParaEnum = xParaEnumAccess->createEnumeration();
591 uno::Reference<text::XTextRange> xTextRange;
592 xParaEnum->nextElement();
593 xParaEnum->nextElement() >>= xTextRange;
594 OUString sFootnotePara = xTextRange->getString();
595 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Paragraph starts with W(87), not tab(9)", u'W', sFootnotePara[0] );
598 DECLARE_OOXMLEXPORT_TEST(testTdf123262_textFootnoteSeparators, "tdf123262_textFootnoteSeparators.docx")
600 //Everything easily fits on one page
601 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Number of Pages", 1, getPages() );
603 uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
604 uno::Reference<container::XIndexAccess> xFootnotes = xFootnotesSupplier->getFootnotes();
605 uno::Reference<text::XText> xFootnoteText(xFootnotes->getByIndex(0), uno::UNO_QUERY);
607 // The text in the separator footnote should not be added to the footnotes
608 CPPUNIT_ASSERT_EQUAL(OUString(" Microsoft Office."), xFootnoteText->getString());
610 // Ensure that paragraph markers are not lost.
611 xFootnoteText.set(xFootnotes->getByIndex(1), uno::UNO_QUERY);
612 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Number of paragraphs in second footnote", 2, getParagraphs(xFootnoteText) );
615 // tdf#136706: Two useless page styles were created for each of the four footnotes.
616 CPPUNIT_ASSERT( !getStyles("PageStyles")->hasByName("Converted8") );
617 CPPUNIT_ASSERT( !getStyles("PageStyles")->hasByName("Converted1") );
620 CPPUNIT_TEST_FIXTURE(Test, testfdo79668)
622 loadAndReload("fdo79668.docx");
623 // fdo#79668: Document was Crashing on DebugUtil build while Saving
624 // because of repeated attribute value in same element.
625 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
626 // w:pPr's w:shd attributes were getting added to w:pPrChange/w:pPr's w:shd hence checking
627 // w:fill for both shd elements
628 assertXPath ( pXmlDoc, "/w:document/w:body/w:p[9]/w:pPr/w:shd", "fill", "FFFFFF" );
629 assertXPath ( pXmlDoc, "/w:document/w:body/w:p[9]/w:pPr/w:pPrChange/w:pPr/w:shd", "fill", "FFFFFF" );
632 CPPUNIT_TEST_FIXTURE(Test, testfdo78907)
634 loadAndReload("fdo78907.docx");
635 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
636 assertXPath ( pXmlDoc, "/w:document/w:body/w:p[1]/w:r[2]/w:br", "type", "page" );
638 xmlDocUniquePtr pXmlDoc1 = parseExport("word/footer1.xml");
639 assertXPath ( pXmlDoc1, "/w:ftr[1]/w:tbl[1]/w:tr[1]/w:tc[1]/w:tbl[1]/w:tr[1]/w:tc[1]/w:tbl", 0 );
642 CPPUNIT_TEST_FIXTURE(Test, tdf118702)
644 loadAndReload("tdf118702.odt");
645 CPPUNIT_ASSERT_EQUAL(2, getPages());
646 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
647 assertXPath ( pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:sectPr/w:type", "val", "nextPage" );
648 assertXPath ( pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:sectPr/w:pgSz", "orient", "landscape" );
651 CPPUNIT_TEST_FIXTURE(Test, testfdo79822)
653 loadAndSave("fdo79822.docx");
654 /* File getting crash while saving in LO.
655 * The Docx contain smartart and the file was created in ms word 2007
657 parseExport("word/document.xml");
660 CPPUNIT_TEST_FIXTURE(Test, testFDO79915)
662 loadAndSave("fdo79915.docx");
663 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
665 assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[9]/w:t", "How much buoyancy does the water provide?");
668 CPPUNIT_TEST_FIXTURE(Test, testfdo79817)
670 loadAndSave("fdo79817.docx");
671 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
672 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:dataBinding", "storeItemID", "{9222E47B-A68B-4AEB-9855-21C912B9D3D2}");
673 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:dataBinding", "xpath", "/ns0:properties[1]/documentManagement[1]/ns2:Responsible_x0020_Officer_x0020_Title[1]");
677 CPPUNIT_TEST_FIXTURE(Test, testfdo79968_sldx)
679 loadAndSave("fdo79968.docx");
680 // This UT for DOCX embedded with powerpoint slide
681 xmlDocUniquePtr pXmlDoc = parseExport("[Content_Types].xml");
683 assertXPath(pXmlDoc,
684 "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.openxmlformats-officedocument.presentationml.slide']",
685 "PartName",
686 "/word/embeddings/oleObject1.sldx");
688 // check the rels too
689 xmlDocUniquePtr pXmlDocRels = parseExport("word/_rels/document.xml.rels");
690 assertXPath(pXmlDocRels,
691 "/rels:Relationships/rels:Relationship[@Target='embeddings/oleObject1.sldx']",
692 "Type",
693 "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package");
694 // check the content too
695 xmlDocUniquePtr pXmlDocContent = parseExport("word/document.xml");
696 assertXPath(pXmlDocContent,
697 "/w:document/w:body/w:p[1]/w:r/w:object/o:OLEObject",
698 "ProgID",
699 "PowerPoint.Slide.12");
702 CPPUNIT_TEST_FIXTURE(Test, testfdo79969_xlsb)
704 loadAndSave("fdo79969_xlsb.docx");
705 // This UT for DOCX embedded with binary excel work sheet.
706 xmlDocUniquePtr pXmlDoc = parseExport("[Content_Types].xml");
708 assertXPath(pXmlDoc,
709 "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.ms-excel.sheet.binary.macroEnabled.12']",
710 "PartName",
711 "/word/embeddings/oleObject1.xlsb");
713 // check the rels too
714 xmlDocUniquePtr pXmlDocRels = parseExport("word/_rels/document.xml.rels");
715 assertXPath(pXmlDocRels,
716 "/rels:Relationships/rels:Relationship[@Target='embeddings/oleObject1.xlsb']",
717 "Type",
718 "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package");
719 // check the content too
720 xmlDocUniquePtr pXmlDocContent = parseExport("word/document.xml");
721 assertXPath(pXmlDocContent,
722 "/w:document/w:body/w:p[1]/w:r/w:object/o:OLEObject",
723 "ProgID",
724 "Excel.SheetBinaryMacroEnabled.12");
727 CPPUNIT_TEST_FIXTURE(Test, testfdo80097)
729 loadAndSave("fdo80097.docx");
730 //fdo#76635 : Table borders are not getting preserved.
732 xmlDocUniquePtr pXmlDocument = parseExport("word/document.xml");
734 //Table Cell Borders
735 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:top[@w:val = 'single']",1);
736 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:top[@w:sz = 4]", 1);
737 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:top[@w:space = 0]", 1);
738 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:top[@w:color = '000000']", 1);
740 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:bottom[@w:val = 'single']",1);
741 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:bottom[@w:sz = 4]", 1);
742 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:bottom[@w:space = 0]", 1);
743 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:bottom[@w:color = '000000']", 1);
745 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:insideH",0);
746 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:insideV",0);
749 CPPUNIT_TEST_FIXTURE(Test, testTdf95033)
751 loadAndSave("tdf95033.docx");
752 //tdf#95033 : Table borders defined by row-level tblPrEx are not getting preserved.
754 xmlDocUniquePtr pXmlDocument = parseExport("word/document.xml");
756 //Not disabled table cell borders
757 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[5]/w:tc[1]/w:tcPr/w:tcBorders/w:start[@w:val = 'nil']", 0);
758 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[5]/w:tc[2]/w:tcPr/w:tcBorders/w:end[@w:val = 'nil']", 0);
759 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[9]/w:tc[1]/w:tcPr/w:tcBorders/w:start[@w:val = 'nil']", 0);
760 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[9]/w:tc[2]/w:tcPr/w:tcBorders/w:end[@w:val = 'nil']", 0);
761 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[9]/w:tc[1]/w:tcPr/w:tcBorders/w:bottom[@w:val = 'nil']", 0);
762 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[9]/w:tc[2]/w:tcPr/w:tcBorders/w:bottom[@w:val = 'nil']", 0);
765 CPPUNIT_TEST_FIXTURE(Test, testTdf133455)
767 loadAndSave("tdf133455.docx");
768 xmlDocUniquePtr pXmlDocument = parseExport("word/document.xml");
770 //Not disabled table cell borders
771 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:top[@w:val = 'nil']", 0);
772 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:start[@w:val = 'nil']", 0);
773 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:end[@w:val = 'nil']", 0);
774 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[1]/w:tcPr/w:tcBorders/w:start[@w:val = 'nil']", 0);
775 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[1]/w:tcPr/w:tcBorders/w:end[@w:val = 'nil']", 0);
776 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[11]/w:tc[1]/w:tcPr/w:tcBorders/w:start[@w:val = 'nil']", 0);
777 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[11]/w:tc[1]/w:tcPr/w:tcBorders/w:end[@w:val = 'nil']", 0);
778 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[11]/w:tc[1]/w:tcPr/w:tcBorders/w:bottom[@w:val = 'nil']", 0);
781 CPPUNIT_TEST_FIXTURE(Test, testTdf138612)
783 loadAndSave("tdf138612.docx");
784 xmlDocUniquePtr pXmlDocument = parseExport("word/document.xml");
786 // Row 5 Col 1 - vertically merged cell
787 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[5]/w:tc[1]/w:tcPr/w:vMerge", "val", "restart");
788 // Row 5 Col 2 - split cell
789 // This was w:vMerge="restart"
790 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[5]/w:tc[2]/w:tcPr/w:vMerge", 0);
792 // Row 6 Col 1 - merged with cell in Row 5 Col 1
793 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[6]/w:tc[1]/w:tcPr/w:vMerge", "val", "continue");
794 // Row 6 Col 2 - split cell
795 // This was w:vMerge="continue" (merged with cell in Row 5 Col 2)
796 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[6]/w:tc[2]/w:tcPr/w:vMerge", 0);
799 CPPUNIT_TEST_FIXTURE(Test, testTdf140597)
801 loadAndSave("tdf140597.docx");
802 xmlDocUniquePtr pXmlDocument = parseExport("word/document.xml");
804 // There were missing tblPrEx table exception borders
805 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[1]/w:tcPr/w:tcBorders/w:top");
806 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[1]/w:tcPr/w:tcBorders/w:start");
807 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[3]/w:tc[1]/w:tcPr/w:tcBorders/w:top");
808 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[3]/w:tc[1]/w:tcPr/w:tcBorders/w:start");
809 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[4]/w:tc[1]/w:tcPr/w:tcBorders/w:top");
810 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[4]/w:tc[1]/w:tcPr/w:tcBorders/w:start");
813 CPPUNIT_TEST_FIXTURE(Test, testTdf128646)
815 loadAndSave("tdf128646.docx");
816 // The problem was that not hidden shapes anchored to empty hidden paragraphs were imported as hidden.
817 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
819 assertXPath(pXmlDoc,"/w:document/w:body/w:tbl/w:tr/w:tc/w:p[7]/w:pPr/w:rPr/w:vanish", 1);
820 if (!isExported())
821 // originally no <w:vanish> (the same as <w:vanish val="false">)
822 assertXPath(pXmlDoc,"/w:document/w:body/w:tbl/w:tr/w:tc/w:p[7]/w:r/w:rPr/w:vanish", 0);
823 else
824 // This was hidden (<w:vanish/>)
825 assertXPath(pXmlDoc,"/w:document/w:body/w:tbl/w:tr/w:tc/w:p[7]/w:r/w:rPr/w:vanish", "val", "false");
828 CPPUNIT_TEST_FIXTURE(Test, testTdf119800)
830 loadAndSave("tdf119800.docx");
831 // The problem was that not hidden shapes anchored to empty hidden paragraphs were imported as hidden.
832 // (tdf#128646 solved the same only for table paragraphs)
833 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
835 assertXPath(pXmlDoc,"/w:document/w:body/w:p[2]/w:pPr/w:rPr/w:vanish", 1);
836 if (!isExported())
837 // originally no <w:vanish> (the same as <w:vanish val="false">)
838 assertXPath(pXmlDoc,"/w:document/w:body/w:p[2]/w:r/w:rPr/w:vanish", 0);
839 else
840 // This was hidden (<w:vanish/>)
841 assertXPath(pXmlDoc,"/w:document/w:body/w:p[2]/w:r/w:rPr/w:vanish", "val", "false");
844 CPPUNIT_TEST_FIXTURE(Test, testFdo77129)
846 loadAndSave("fdo77129.docx");
847 // The problem was that text after TOC field was missing if footer reference comes in field.
848 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
850 // Data was lost from this paragraph.
851 assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[4]/w:r[1]/w:t", "Abstract");
854 // Test the same testdoc used for testFdo77129.
855 DECLARE_OOXMLEXPORT_TEST(testTdf129402, "fdo77129.docx")
857 // tdf#129402: ToC title must be "Contents", not "Content"; the index field must include
858 // pre-rendered element.
860 // Currently export drops empty paragraph after ToC, so skip getParagraphs test for now
861 // CPPUNIT_ASSERT_EQUAL(5, getParagraphs());
862 CPPUNIT_ASSERT_EQUAL(OUString("owners."), getParagraph(1)->getString());
863 CPPUNIT_ASSERT_EQUAL(OUString("Contents"), getParagraph(2)->getString());
864 CPPUNIT_ASSERT_EQUAL(OUString("How\t2"), getParagraph(3)->getString());
865 // CPPUNIT_ASSERT_EQUAL(OUString(), getParagraph(4)->getString());
867 uno::Reference<text::XDocumentIndexesSupplier> xIndexSupplier(mxComponent, uno::UNO_QUERY);
868 uno::Reference<container::XIndexAccess> xIndexes = xIndexSupplier->getDocumentIndexes();
869 uno::Reference<text::XDocumentIndex> xIndex(xIndexes->getByIndex(0), uno::UNO_QUERY);
870 uno::Reference<text::XTextRange> xTextRange = xIndex->getAnchor();
871 uno::Reference<text::XText> xText = xTextRange->getText();
872 uno::Reference<text::XTextCursor> xTextCursor = xText->createTextCursor();
873 xTextCursor->gotoRange(xTextRange->getStart(), false);
874 xTextCursor->gotoRange(xTextRange->getEnd(), true);
875 OUString aTocString(xTextCursor->getString());
877 // Check that the pre-rendered entry is inside the index
878 CPPUNIT_ASSERT_EQUAL(OUString("How\t2"), aTocString);
881 CPPUNIT_TEST_FIXTURE(Test, testfdo79969_xlsm)
883 loadAndSave("fdo79969_xlsm.docx");
884 // This UT for DOCX embedded with excel work sheet.
885 xmlDocUniquePtr pXmlDoc = parseExport("[Content_Types].xml");
887 assertXPath(pXmlDoc,
888 "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.ms-excel.sheet.macroEnabled.12']",
889 "PartName",
890 "/word/embeddings/oleObject1.xlsm");
892 // check the rels too
893 xmlDocUniquePtr pXmlDocRels = parseExport("word/_rels/document.xml.rels");
894 assertXPath(pXmlDocRels,
895 "/rels:Relationships/rels:Relationship[@Target='embeddings/oleObject1.xlsm']",
896 "Type",
897 "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package");
898 // check the content too
899 xmlDocUniquePtr pXmlDocContent = parseExport("word/document.xml");
900 assertXPath(pXmlDocContent,
901 "/w:document/w:body/w:p[1]/w:r/w:object/o:OLEObject",
902 "ProgID",
903 "Excel.SheetMacroEnabled.12");
906 CPPUNIT_TEST_FIXTURE(Test, testfdo80522)
908 loadAndReload("fdo80522.docx");
909 xmlDocUniquePtr pXmlDoc = parseExport("[Content_Types].xml");
911 assertXPath(pXmlDoc,
912 "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.ms-word.document.macroEnabled.12']",
913 "PartName",
914 "/word/embeddings/oleObject1.docm");
916 // check the rels too
917 xmlDocUniquePtr pXmlDocRels = parseExport("word/_rels/document.xml.rels");
918 assertXPath(pXmlDocRels,
919 "/rels:Relationships/rels:Relationship[@Target='embeddings/oleObject1.docm']",
920 "Type",
921 "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package");
922 // check the content too
923 xmlDocUniquePtr pXmlDocContent = parseExport("word/document.xml");
924 assertXPath(pXmlDocContent,
925 "/w:document/w:body/w:p[1]/w:r/w:object/o:OLEObject",
926 "ProgID",
927 "Word.DocumentMacroEnabled.12");
930 CPPUNIT_TEST_FIXTURE(Test, testfdo80523_pptm)
932 loadAndReload("fdo80523_pptm.docx");
933 xmlDocUniquePtr pXmlDoc = parseExport("[Content_Types].xml");
935 assertXPath(pXmlDoc,
936 "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.ms-powerpoint.presentation.macroEnabled.12']",
937 "PartName",
938 "/word/embeddings/oleObject1.pptm");
940 // check the rels too
941 xmlDocUniquePtr pXmlDocRels = parseExport("word/_rels/document.xml.rels");
942 assertXPath(pXmlDocRels,
943 "/rels:Relationships/rels:Relationship[@Target='embeddings/oleObject1.pptm']",
944 "Type",
945 "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package");
946 // check the content too
947 xmlDocUniquePtr pXmlDocContent = parseExport("word/document.xml");
948 assertXPath(pXmlDocContent,
949 "/w:document/w:body/w:p[1]/w:r/w:object/o:OLEObject",
950 "ProgID",
951 "PowerPoint.ShowMacroEnabled.12");
954 CPPUNIT_TEST_FIXTURE(Test, testfdo80523_sldm)
956 loadAndReload("fdo80523_sldm.docx");
957 xmlDocUniquePtr pXmlDoc = parseExport("[Content_Types].xml");
959 assertXPath(pXmlDoc,
960 "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.ms-powerpoint.slide.macroEnabled.12']",
961 "PartName",
962 "/word/embeddings/oleObject1.sldm");
964 // check the rels too
965 xmlDocUniquePtr pXmlDocRels = parseExport("word/_rels/document.xml.rels");
966 assertXPath(pXmlDocRels,
967 "/rels:Relationships/rels:Relationship[@Target='embeddings/oleObject1.sldm']",
968 "Type",
969 "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package");
970 // check the content too
971 xmlDocUniquePtr pXmlDocContent = parseExport("word/document.xml");
972 assertXPath(pXmlDocContent,
973 "/w:document/w:body/w:p[1]/w:r/w:object/o:OLEObject",
974 "ProgID",
975 "PowerPoint.SlideMacroEnabled.12");
978 CPPUNIT_TEST_FIXTURE(Test, testfdo80898)
980 loadAndSave("fdo80898.docx");
981 // This UT for DOCX embedded with binary excel work sheet.
982 xmlDocUniquePtr pXmlDoc = parseExport("[Content_Types].xml");
984 assertXPath(pXmlDoc,
985 "/ContentType:Types/ContentType:Override[@ContentType='application/msword']",
986 "PartName",
987 "/word/embeddings/oleObject1.doc");
989 // check the rels too
990 xmlDocUniquePtr pXmlDocRels = parseExport("word/_rels/document.xml.rels");
991 assertXPath(pXmlDocRels,
992 "/rels:Relationships/rels:Relationship[@Target='embeddings/oleObject1.doc']",
993 "Type",
994 "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject");
995 // check the content too
996 xmlDocUniquePtr pXmlDocContent = parseExport("word/document.xml");
997 assertXPath(pXmlDocContent,
998 "/w:document/w:body/w:p[1]/w:r/w:object/o:OLEObject",
999 "ProgID",
1000 "Word.Document.8");
1003 CPPUNIT_TEST_FIXTURE(Test, testOleIconDrawAspect)
1005 loadAndSave("tdf131537.odt");
1006 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
1007 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/w:object/o:OLEObject",
1008 "DrawAspect", "Icon");
1011 CPPUNIT_TEST_FIXTURE(Test, testTableCellWithDirectFormatting)
1013 loadAndSave("fdo80800.docx");
1014 // Issue was Direct Formatting for non-first Table cells was not getting preserved.
1016 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
1018 // Ensure that for Third Table cell Direct Formatting is preserved.
1019 // In file, Direct Formatting used for Third Table cell is Line Spacing="1.5 lines"
1020 // For Line Spacing "1.5 lines" w:line equals 360
1021 assertXPath(pXmlDoc,"/w:document/w:body/w:tbl/w:tr/w:tc[3]/w:p/w:pPr/w:spacing","line","360");
1025 DECLARE_OOXMLEXPORT_TEST(testFdo80800b_tableStyle, "fdo80800b_tableStyle.docx")
1027 uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY);
1028 uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
1029 uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xCell->getText(), uno::UNO_QUERY);
1030 uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
1031 uno::Reference<text::XTextRange> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
1032 CPPUNIT_ASSERT_EQUAL(OUString("Cell1 1.5lines"), xPara->getString());
1033 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell A1 1.5 line spacing", sal_Int16(150), getProperty<style::LineSpacing>(xPara, "ParaLineSpacing").Height);
1035 xCell.set(xTable->getCellByName("B1"), uno::UNO_QUERY);
1036 xParaEnumAccess.set(xCell->getText(), uno::UNO_QUERY);
1037 xParaEnum = xParaEnumAccess->createEnumeration();
1038 xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
1039 CPPUNIT_ASSERT_EQUAL(OUString("Cell2 Implicit (Single)"), xPara->getString());
1040 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B1 single line spacing", sal_Int16(100), getProperty<style::LineSpacing>(xPara, "ParaLineSpacing").Height);
1042 xCell.set(xTable->getCellByName("C1"), uno::UNO_QUERY);
1043 xParaEnumAccess.set(xCell->getText(), uno::UNO_QUERY);
1044 xParaEnum = xParaEnumAccess->createEnumeration();
1045 xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
1046 CPPUNIT_ASSERT_EQUAL(OUString("Cell3 Implicit (Single)"), xPara->getString());
1047 CPPUNIT_ASSERT_EQUAL_MESSAGE("C1 paragraph1 single line spacing", sal_Int16(100), getProperty<style::LineSpacing>(xPara, "ParaLineSpacing").Height);
1048 xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
1049 xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
1050 CPPUNIT_ASSERT_EQUAL_MESSAGE("C1 paragraph3 line spacing", sal_Int16(212), getProperty<style::LineSpacing>(xPara, "ParaLineSpacing").Height);
1053 DECLARE_OOXMLEXPORT_TEST(testTdf117297_tableStyle, "tdf117297_tableStyle.docx")
1055 uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY);
1056 uno::Reference<text::XTextRange> xCell(xTable->getCellByName("B1"), uno::UNO_QUERY);
1057 uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xCell->getText(), uno::UNO_QUERY);
1058 uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
1059 uno::Reference<text::XTextRange> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
1060 uno::Reference<text::XText> xText = xPara->getText();
1061 CPPUNIT_ASSERT_EQUAL(OUString("Green text, default size (9), 1.5 spaced"), xPara->getString());
1062 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B1 Paragraph1 green font", Color(0x70AD47), getProperty<Color>(getRun(xPara, 1), "CharColor"));
1063 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B1 Paragraph1 1.5 line spacing", sal_Int16(150), getProperty<style::LineSpacing>(xPara, "ParaLineSpacing").Height);
1064 xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
1065 xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
1066 xText = xPara->getText();
1067 CPPUNIT_ASSERT_EQUAL(OUString("TableGrid color (blue), TableGrid size (9), double spacing"), xPara->getString());
1068 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B1 Paragraph3 blue font", Color(0x00B0F0), getProperty<Color>(getRun(xPara, 1), "CharColor"));
1069 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B1 Paragraph3 double spacing", sal_Int16(200), getProperty<style::LineSpacing>(xPara, "ParaLineSpacing").Height);
1072 DECLARE_OOXMLEXPORT_TEST(testTdf82175_noStyleInheritance, "tdf82175_noStyleInheritance.docx")
1074 // The document's "Default" paragraph style is 1 inch fixed line spacing, and that is what should not be inherited.
1075 style::LineSpacing aSpacing = getProperty<style::LineSpacing>(getParagraph(1), "ParaLineSpacing");
1076 // MSWord uses 115% line spacing, but LO follows the documentation and sets single spacing.
1077 CPPUNIT_ASSERT_MESSAGE("Text Body style 115% line spacing", sal_Int16(120) > aSpacing.Height);
1078 CPPUNIT_ASSERT_MESSAGE("THANKS for *FIXING* line spacing", sal_Int16(115) != aSpacing.Height);
1079 CPPUNIT_ASSERT_EQUAL(sal_Int16(style::LineSpacingMode::PROP), aSpacing.Mode);
1082 DECLARE_OOXMLEXPORT_TEST(test2colHeader, "2col-header.docx")
1084 // Header was lost on export when the document had multiple columns.
1085 uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY);
1086 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xPageStyle, "HeaderIsOn"));
1089 CPPUNIT_TEST_FIXTURE(Test, testfdo83048)
1091 loadAndSave("fdo83048.docx");
1092 // Issue was wrong SDT properties were getting exported for Date SDT
1093 xmlDocUniquePtr pXmlDoc = parseExport("word/footer2.xml");
1095 // Make sure Date is inside SDT tag.
1096 // This will happen only if right SDT properties are exported.
1097 assertXPathContent(pXmlDoc, "/w:ftr/w:sdt/w:sdtContent/w:p[1]/w:sdt/w:sdtContent/w:r[2]/w:t",
1098 "1/2/2013");
1101 CPPUNIT_TEST_FIXTURE(Test, testSdt2Run)
1103 loadAndSave("sdt-2-run.docx");
1104 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
1106 // The problem was that <w:sdt> was closed after "first", not after "second", so the second assert failed.
1107 assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r/w:t", "firstsecond");
1108 // Make sure the third portion is still outside <w:sdt>.
1109 assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/w:t", "third");
1112 CPPUNIT_TEST_FIXTURE(Test, testFD083057)
1114 loadAndSave("fdo83057.docx");
1115 xmlDocUniquePtr pXmlDoc = parseExport("word/header2.xml");
1117 // A fly frame was attached to a para which started with a hint (run) containing an SDT.
1118 // This SDT was handled while exporting the FLYFRAME and also the text of the run.
1119 // So, even though the original file had only one sdt in the header, the RT file had two;
1120 // one for a separate run as expected, and one incorrectly exported in the alternateContent (FLYFRAME)
1122 // Assert that the file has only one sdt, in a separate run
1123 assertXPath(pXmlDoc, "//w:sdt", 1);
1124 assertXPath(pXmlDoc, "//mc:AlternateContent//w:sdt", 0);
1127 CPPUNIT_TEST_FIXTURE(Test, testHeaderBorder)
1129 loadAndSave("header-border.docx");
1130 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
1131 // This was 0, as header margin was lost during import.
1132 assertXPath(pXmlDoc, "//w:pgMar", "header", "720");
1133 // This was 33: 33 points -> 660 twips. We counted 900 - 240 (distance
1134 // of page and body frame) instead of 720 - 240 (distance of page and
1135 // header frame).
1136 assertXPath(pXmlDoc, "//w:pgBorders/w:top", "space", "24");
1139 DECLARE_OOXMLEXPORT_TEST(testTablepprShape, "tblppr-shape.docx")
1141 // Unhandled exception due to unexpected w:tblpPr resulted in not importing page size, either.
1142 uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY);
1143 // This was 2000, page width wasn't large enough.
1144 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2540), getProperty<sal_Int32>(xPageStyle, "LeftMargin"));
1147 DECLARE_OOXMLEXPORT_TEST(testImageNoborder, "image-noborder.docx")
1149 // This was 26; we exported border for an image that had no border.
1150 CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(0), getProperty<table::BorderLine2>(getShape(1), "TopBorder").LineWidth);
1153 CPPUNIT_TEST_FIXTURE(Test, testTdf89774)
1155 loadAndSave("tdf89774.fodt");
1156 xmlDocUniquePtr pXmlDoc = parseExport("docProps/app.xml");
1157 // This was 65, as unit was seconds instead of minutes.
1158 assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:TotalTime", "1");
1161 CPPUNIT_TEST_FIXTURE(Test, testSectionProtection)
1163 loadAndReload("sectionprot.odt");
1164 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
1165 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:pPr/w:sectPr/w:formProt", "val", "true");
1166 assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:formProt", "val", "false");
1168 xmlDocUniquePtr pXmlSettings = parseExport("word/settings.xml");
1169 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "enforcement", "true");
1170 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "edit", "forms");
1172 uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
1173 uno::Reference<container::XIndexAccess> xSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY);
1174 uno::Reference<beans::XPropertySet> xSect(xSections->getByIndex(0), uno::UNO_QUERY);
1175 CPPUNIT_ASSERT_EQUAL_MESSAGE("TextSection is protected", true, getProperty<bool>(xSect, "IsProtected"));
1176 xSect.set(xSections->getByIndex(1), uno::UNO_QUERY);
1177 CPPUNIT_ASSERT_EQUAL_MESSAGE("Section1 is protected", false, getProperty<bool>(xSect, "IsProtected"));
1180 CPPUNIT_TEST_FIXTURE(Test, testSectionProtection2)
1182 loadAndSave("sectionprot2.odt");
1183 CPPUNIT_ASSERT_EQUAL(1, getPages());
1184 xmlDocUniquePtr pXmlSettings = parseExport("word/settings.xml");
1185 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "enforcement", "true");
1186 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "edit", "forms");
1188 uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
1189 uno::Reference<container::XIndexAccess> xSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY);
1190 uno::Reference<beans::XPropertySet> xSect(xSections->getByIndex(0), uno::UNO_QUERY);
1191 CPPUNIT_ASSERT_EQUAL_MESSAGE("TextSection is protected", true, getProperty<bool>(xSect, "IsProtected"));
1194 DECLARE_OOXMLEXPORT_TEST(tdf66398_permissions, "tdf66398_permissions.docx")
1196 // check document permission settings for the whole document
1197 if (isExported())
1199 xmlDocUniquePtr pXmlSettings = parseExport("word/settings.xml");
1200 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "edit", "readOnly");
1201 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "enforcement", "1");
1202 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "cryptProviderType", "rsaAES");
1203 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "cryptAlgorithmClass","hash");
1204 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "cryptAlgorithmType", "typeAny");
1205 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "cryptAlgorithmSid", "14");
1206 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "cryptSpinCount", "100000");
1207 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "hash", "A0/Xy6KcXljJlZjP0TwJMPJuW2rc46UwXqn2ctxckc2nCECE5i89M85z2Noh3ZEA5NBQ9RJ5ycxiUH6nzmJaKw==");
1208 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "salt", "B8k6wb1pkjUs4Nv/8QBk/w==");
1211 // get bookmark interface
1212 uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
1213 uno::Reference<container::XIndexAccess> xBookmarksByIdx(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
1214 uno::Reference<container::XNameAccess> xBookmarksByName = xBookmarksSupplier->getBookmarks();
1216 // check: we have 2 bookmarks
1217 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xBookmarksByIdx->getCount());
1218 CPPUNIT_ASSERT(xBookmarksByName->hasByName("_GoBack"));
1219 CPPUNIT_ASSERT(xBookmarksByName->hasByName("permission-for-group:267014232:everyone"));
1222 CPPUNIT_TEST_FIXTURE(Test, tdf106843)
1224 loadAndSave("tdf106843.fodt");
1225 // check Track Changes permission set in Writer/OpenDocument (password: "test", encoded by default encoding of Writer)
1226 xmlDocUniquePtr pXmlSettings = parseExport("word/settings.xml");
1227 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "edit", "trackedChanges");
1228 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "enforcement", "1");
1230 // LO intends to export a .docx format that is natively compatible with 2013
1231 // but this document has an implicitly added setting AddExternalLeading = false
1232 assertXPath(pXmlSettings, "/w:settings/w:compat/w:compatSetting[1]", "name", "compatibilityMode");
1233 assertXPath(pXmlSettings, "/w:settings/w:compat/w:compatSetting[1]", "uri", "http://schemas.microsoft.com/office/word");
1234 assertXPath(pXmlSettings, "/w:settings/w:compat/w:compatSetting[1]", "val", "14"); // compatible with 2010
1237 CPPUNIT_TEST_FIXTURE(Test, tdf89991_revisionView)
1239 loadAndSave("tdf89991.docx");
1240 // check revisionView (Show Changes) import and export
1241 xmlDocUniquePtr pXmlSettings = parseExport("word/settings.xml");
1242 assertXPath(pXmlSettings, "/w:settings/w:revisionView", "insDel", "0");
1243 assertXPath(pXmlSettings, "/w:settings/w:revisionView", "formatting", "0");
1245 // There was no compatibilityMode defined.
1246 // 12: Use word processing features specified in ECMA-376. This is the default.
1247 assertXPath(pXmlSettings, "/w:settings/w:compat/w:compatSetting[1]", "name", "compatibilityMode");
1248 assertXPath(pXmlSettings, "/w:settings/w:compat/w:compatSetting[1]", "uri", "http://schemas.microsoft.com/office/word");
1249 assertXPath(pXmlSettings, "/w:settings/w:compat/w:compatSetting[1]", "val", "12");
1252 CPPUNIT_TEST_FIXTURE(Test, tdf122201_editUnprotectedText)
1254 loadAndReload("tdf122201_editUnprotectedText.odt");
1255 CPPUNIT_ASSERT_EQUAL(1, getPages());
1256 // get the document
1257 SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
1258 CPPUNIT_ASSERT(pTextDoc);
1260 SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
1261 CPPUNIT_ASSERT(pDoc);
1263 // get two different nodes
1264 SwNodeIndex aDocEnd(pDoc->GetNodes().GetEndOfContent());
1265 SwNodeIndex aDocStart(*aDocEnd.GetNode().StartOfSectionNode(), 3);
1267 // check protected area
1268 SwPaM aPaMProtected(aDocStart);
1269 CPPUNIT_ASSERT(aPaMProtected.HasReadonlySel(false, false));
1271 // check unprotected area
1272 SwPaM aPaMUnprotected(aDocEnd);
1273 CPPUNIT_ASSERT(!aPaMUnprotected.HasReadonlySel(false, false));
1276 CPPUNIT_TEST_FIXTURE(Test, testSectionHeader)
1278 loadAndReload("sectionprot.odt");
1279 CPPUNIT_ASSERT_EQUAL(1, getPages());
1280 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
1281 // this test must not be zero
1282 assertXPath(pXmlDoc, "//w:headerReference", 1);
1285 CPPUNIT_TEST_FIXTURE(Test, testTdf146491)
1287 loadAndReload("tdf146491.odt");
1288 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
1289 // This was 12 - a page style was unnecessarily created for every section.
1290 assertXPath(pXmlDoc, "//w:footerReference", 1);
1293 CPPUNIT_TEST_FIXTURE(Test, testOO47778_1)
1295 loadAndReload("ooo47778-3.odt");
1296 CPPUNIT_ASSERT_EQUAL(5, getShapes());
1297 CPPUNIT_ASSERT_EQUAL(1, getPages());
1298 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
1299 assertXPathContent(pXmlDoc, "(//w:t)[3]", "c");
1302 CPPUNIT_TEST_FIXTURE(Test, testOO47778_2)
1304 loadAndReload("ooo47778-4.odt");
1305 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1306 CPPUNIT_ASSERT_EQUAL(1, getPages());
1307 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
1308 assertXPathContent(pXmlDoc, "(//w:t)[4]", "c");
1310 // tdf116436: The problem was that the table background was undefined, not white.
1311 uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
1312 uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
1313 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
1314 uno::Reference<table::XCell> xCell = xTable->getCellByName("A1");
1315 CPPUNIT_ASSERT_EQUAL(COL_WHITE, getProperty<Color>(xCell, "BackColor"));
1318 CPPUNIT_TEST_FIXTURE(Test, testOO67471)
1320 loadAndReload("ooo67471-2.odt");
1321 CPPUNIT_ASSERT_EQUAL(1, getPages());
1322 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
1323 assertXPathContent(pXmlDoc, "(//w:t)[2]", "B");
1326 CPPUNIT_TEST_FIXTURE(Test, testKDE302504)
1328 loadAndReload("kde302504-1.odt");
1329 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1330 CPPUNIT_ASSERT_EQUAL(1, getPages());
1331 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
1332 assertXPath(pXmlDoc, "//v:shape", "ID", "KoPathShape");
1335 CPPUNIT_TEST_FIXTURE(Test, testKDE216114)
1337 loadAndReload("kde216114-1.odt");
1338 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1339 CPPUNIT_ASSERT_EQUAL(1, getPages());
1340 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
1341 assertXPath(pXmlDoc, "//w:pict", 1);
1344 CPPUNIT_TEST_FIXTURE(Test, testOO72950)
1346 loadAndReload("ooo72950-1.odt");
1347 CPPUNIT_ASSERT_EQUAL(1, getPages());
1348 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
1349 assertXPath(pXmlDoc, "//w:tbl", 1);
1352 //There are two tables to export in this doc the second of which is inside a
1353 //frame anchored to first cell of the first table. They must not be
1354 //considered the same table
1355 CPPUNIT_TEST_FIXTURE(Test, fdo60957)
1357 loadAndSave("fdo60957-2.docx");
1358 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
1359 assertXPath(pXmlDoc, "//w:tbl", 2);
1361 //tdf#154956
1362 uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
1363 uno::Reference<container::XIndexAccess> xBookmarksByIdx(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
1364 uno::Reference<container::XNameAccess> xBookmarksByName = xBookmarksSupplier->getBookmarks();
1366 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xBookmarksByIdx->getCount());
1367 CPPUNIT_ASSERT(xBookmarksByName->hasByName("_GoBack"));
1370 //This has more cells than msword supports, we must balance the
1371 //number of cell start and ends
1372 CPPUNIT_TEST_FIXTURE(Test, testOO106020)
1374 loadAndSave("ooo106020-1.odt");
1375 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
1376 assertXPath(pXmlDoc, "//w:tbl", 1);
1379 DECLARE_OOXMLEXPORT_TEST(testNonBMPChar, "nonbmpchar.docx")
1381 // Assert that UTF8 encoded non-BMP Unicode character is correct
1382 uno::Reference<text::XTextRange> xTextRange1 = getRun(getParagraph(1), 1);
1383 CPPUNIT_ASSERT_EQUAL(OUString(u"\U00024b62"), xTextRange1->getString());
1386 CPPUNIT_TEST_FIXTURE(Test, testSpacingGroupShapeText)
1388 loadAndSave("tdf131775_SpacingGroupShapeText.docx");
1389 // tdf#131775: Check if correct spacing.
1391 xmlDocUniquePtr pXmlDocument = parseExport("word/document.xml");
1393 assertXPath(pXmlDocument, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor"
1394 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[1]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:spacing", "val", "200");
1397 CPPUNIT_TEST_FIXTURE(Test, testTdf100581)
1399 loadAndSave("tdf100581.odt");
1400 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1401 CPPUNIT_ASSERT_EQUAL(1, getPages());
1402 xmlDocUniquePtr pXmlDocument = parseExport("word/document.xml");
1404 assertXPath(pXmlDocument, "/w:document/w:body/w:p[1]/w:r[2]/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor"
1405 "/a:graphic/a:graphicData/wps:wsp/wps:txbx/w:txbxContent/w:p[1]/w:pPr/w:pStyle", "val", "FrameContents");
1407 // w:sectPr is not exported
1408 assertXPath(pXmlDocument, "/w:document/w:body/w:p[1]/w:r[2]/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor"
1409 "/a:graphic/a:graphicData/wps:wsp/wps:txbx/w:txbxContent/w:p[1]/w:pPr/w:sectPr", 0);
1411 assertXPath(pXmlDocument, "/w:document/w:body/w:p[1]/w:r[2]/mc:AlternateContent/mc:Fallback/w:pict/v:rect"
1412 "/v:textbox/w:txbxContent/w:p[1]/w:pPr/w:pStyle", "val", "FrameContents");
1414 // w:sectPr is not exported
1415 assertXPath(pXmlDocument, "/w:document/w:body/w:p[1]/w:r[2]/mc:AlternateContent/mc:Fallback/w:pict/v:rect"
1416 "/v:textbox/w:txbxContent/w:p[1]/w:pPr/w:sectPr", 0);
1419 CPPUNIT_TEST_FIXTURE(Test, testTdf112287)
1421 loadAndSave("tdf112287.docx");
1422 // tdf#131775: Check if correct spacing.
1424 xmlDocUniquePtr pXmlDocument = parseExport("word/document.xml");
1426 assertXPath(pXmlDocument, "/w:document/w:body/w:p[1]/w:pPr/w:framePr","vAnchor","margin");
1427 assertXPath(pXmlDocument, "/w:document/w:body/w:p[1]/w:pPr/w:framePr","hAnchor","text");
1428 assertXPath(pXmlDocument, "/w:document/w:body/w:p[1]/w:pPr/w:framePr","xAlign","center");
1429 assertXPath(pXmlDocument, "/w:document/w:body/w:p[1]/w:pPr/w:framePr","yAlign","bottom");
1432 CPPUNIT_TEST_FIXTURE(Test, testTdf157572_defaultVAnchor)
1434 loadAndSave("tdf157572_defaultVAnchor.docx");
1435 xmlDocUniquePtr pXmlDocument = parseExport("word/document.xml");
1437 // vAnchor wasn't defined on import. It should default to 'margin' when w:y=non-zero
1438 assertXPath(pXmlDocument, "/w:document/w:body/w:p[1]/w:pPr/w:framePr","vAnchor","margin");
1439 // yAlign=something is not compatible with w:y=non-zero" - don't write anything out
1440 // assertXPathNoAttribute(pXmlDocument, "/w:document/w:body/w:p[1]/w:pPr/w:framePr", "yAlign");
1443 CPPUNIT_TEST_FIXTURE(Test, testTdf112287B)
1445 loadAndSave("tdf112287B.docx");
1446 xmlDocUniquePtr pXmlDocument = parseExport("word/document.xml");
1448 assertXPath(pXmlDocument, "/w:document/w:body/w:p[1]/w:pPr/w:framePr","vAnchor","text");
1449 assertXPath(pXmlDocument, "/w:document/w:body/w:p[1]/w:pPr/w:framePr","hAnchor","text");
1452 CPPUNIT_TEST_FIXTURE(Test, testZOrderInHeader)
1454 loadAndSave("tdf120760_ZOrderInHeader.docx");
1455 // tdf#120760 Check that the Z-Order of the background is smaller than the front shape's.
1456 xmlDocUniquePtr pXml = parseExport("word/header2.xml");
1458 // Get the Z-Order of the background image and of the shape in front of it.
1459 sal_Int32 nBackground = getXPath(pXml, "/w:hdr/w:p[1]/w:r[1]/w:drawing/wp:anchor", "relativeHeight").toInt32();
1460 sal_Int32 nFrontShape = getXPath(pXml, "/w:hdr/w:p[1]/w:r[1]/mc:AlternateContent[2]"
1461 "/mc:Choice/w:drawing/wp:anchor", "relativeHeight").toInt32();
1463 // Assert that background is in the back.
1464 CPPUNIT_ASSERT(nBackground < nFrontShape);
1467 CPPUNIT_PLUGIN_IMPLEMENT();
1469 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */