1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 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 */ 9 10 #include <swmodeltestbase.hxx> 11 12 #include <com/sun/star/text/XDocumentIndex.hpp> 13 #include <com/sun/star/text/XDocumentIndexesSupplier.hpp> 14 #include <com/sun/star/text/XFootnote.hpp> 15 #include <com/sun/star/text/XTextField.hpp> 16 #include <com/sun/star/text/XTextTable.hpp> 17 #include <com/sun/star/style/LineSpacing.hpp> 18 #include <com/sun/star/style/LineSpacingMode.hpp> 19 #include <com/sun/star/table/BorderLine2.hpp> 20 #include <com/sun/star/rdf/URI.hpp> 21 #include <com/sun/star/rdf/Statement.hpp> 22 #include <o3tl/cppunittraitshelper.hxx> 23 24 #include <ndindex.hxx> 25 #include <pam.hxx> 26 27 class Test : public SwModelTestBase 28 { 29 public: 30 Test() : SwModelTestBase("/sw/qa/extras/ooxmlexport/data/", "Office Open XML Text") {} 31 32 protected: 33 /** 34 * Blacklist handling 35 */ 36 bool mustTestImportOf(const char* filename) const override { 37 const char* aBlacklist[] = { 38 "math-escape.docx", 39 "math-mso2k7.docx", 40 }; 41 std::vector<const char*> vBlacklist(aBlacklist, aBlacklist + SAL_N_ELEMENTS(aBlacklist)); 42 43 // If the testcase is stored in some other format, it's pointless to test. 44 return (OString(filename).endsWith(".docx") && std::find(vBlacklist.begin(), vBlacklist.end(), filename) == vBlacklist.end()); 45 } 46 }; 47 48 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testFDO76248, "FDO76248.docx") 49 { 50 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); 51 // In two cases the a:graphicData elements had no children, which is invalid. 52 assertXPath(pXmlDoc, "//a:graphicData[not(*)]", 0); 53 } 54 55 DECLARE_OOXMLEXPORT_TEST(testTscp, "tscp.docx") 56 { 57 uno::Reference<uno::XComponentContext> xComponentContext(comphelper::getProcessComponentContext()); 58 uno::Reference<rdf::XURI> xType = rdf::URI::create(xComponentContext, "urn:bails"); 59 uno::Reference<rdf::XDocumentMetadataAccess> xDocumentMetadataAccess(mxComponent, uno::UNO_QUERY); 60 uno::Sequence< uno::Reference<rdf::XURI> > aGraphNames = xDocumentMetadataAccess->getMetadataGraphsWithType(xType); 61 // This failed, no graphs had the urn:bails type. 62 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aGraphNames.getLength()); 63 uno::Reference<rdf::XURI> xGraphName = aGraphNames[0]; 64 uno::Reference<rdf::XNamedGraph> xGraph = xDocumentMetadataAccess->getRDFRepository()->getGraph(xGraphName); 65 66 // No RDF statement on the first paragraph. 67 uno::Reference<rdf::XResource> xParagraph(getParagraph(1), uno::UNO_QUERY); 68 uno::Reference<container::XEnumeration> xStatements = xGraph->getStatements(xParagraph, uno::Reference<rdf::XURI>(), uno::Reference<rdf::XURI>()); 69 CPPUNIT_ASSERT_EQUAL(false, static_cast<bool>(xStatements->hasMoreElements())); 70 71 // 3 RDF statements on the second paragraph. 72 xParagraph.set(getParagraph(2), uno::UNO_QUERY); 73 std::map<OUString, OUString> aExpectedStatements = 74 { 75 {"urn:bails:ExportControl:BusinessAuthorization:Identifier", "urn:example:tscp:1"}, 76 {"urn:bails:ExportControl:BusinessAuthorizationCategory:Identifier", "urn:example:tscp:1:confidential"}, 77 {"urn:bails:ExportControl:Authorization:StartValidity", "2015-11-27"} 78 }; 79 std::map<OUString, OUString> aActualStatements; 80 xStatements = xGraph->getStatements(xParagraph, uno::Reference<rdf::XURI>(), uno::Reference<rdf::XURI>()); 81 while (xStatements->hasMoreElements()) 82 { 83 rdf::Statement aStatement = xStatements->nextElement().get<rdf::Statement>(); 84 aActualStatements[aStatement.Predicate->getNamespace() + aStatement.Predicate->getLocalName()] = aStatement.Object->getStringValue(); 85 } 86 CPPUNIT_ASSERT(bool(aExpectedStatements == aActualStatements)); 87 88 // No RDF statement on the third paragraph. 89 xParagraph.set(getParagraph(3), uno::UNO_QUERY); 90 xStatements = xGraph->getStatements(xParagraph, uno::Reference<rdf::XURI>(), uno::Reference<rdf::XURI>()); 91 CPPUNIT_ASSERT_EQUAL(false, static_cast<bool>(xStatements->hasMoreElements())); 92 } 93 94 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testfdo76589 , "fdo76589.docx") 95 { 96 /* Numbered list was not preserve after RT. 97 * In numbering.xml, when NumberingType is "decimal" and level is zero, 98 * w:val of w:lvlText was empty. 99 * It should be <w:lvlText w:val="%1" /> 100 */ 101 xmlDocUniquePtr pXmlDoc = parseExport("word/numbering.xml"); 102 103 assertXPath ( pXmlDoc, "/w:numbering/w:abstractNum[1]/w:lvl[1]/w:lvlText","val","%1" ); 104 } 105 106 DECLARE_OOXMLEXPORT_TEST(testDecimalNumberingNoLeveltext, "decimal-numbering-no-leveltext.docx") 107 { 108 // This was "%1", not empty: we turned a kind-of-none numbering into a decimal one. 109 if (xmlDocUniquePtr pXmlDoc = parseExport("word/numbering.xml")) 110 assertXPath (pXmlDoc, "/w:numbering/w:abstractNum[1]/w:lvl[1]/w:lvlText","val", ""); 111 } 112 113 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testNoDuplicateAttributeExport, "duplicate-east-asia.odt") 114 { 115 CPPUNIT_ASSERT_EQUAL(1, getShapes()); 116 CPPUNIT_ASSERT_EQUAL(1, getPages()); 117 // File asserting while saving in LO. 118 parseExport("word/document.xml"); 119 } 120 121 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testfdo79008, "fdo79008.docx") 122 { 123 /* File crashing while saving in LO. 124 * Check if document.xml file is created after fix 125 */ 126 parseExport("word/document.xml"); 127 128 // Read-only is set, but it is not enforced, so it should be off... 129 SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get()); 130 CPPUNIT_ASSERT(pTextDoc); 131 CPPUNIT_ASSERT(!pTextDoc->GetDocShell()->IsSecurityOptOpenReadOnly()); 132 } 133 134 DECLARE_OOXMLEXPORT_TEST(testTdf120852_readOnlyProtection, "tdf120852_readOnlyProtection.docx") 135 { 136 if (xmlDocUniquePtr pXmlSettings = parseExport("word/settings.xml")) 137 { 138 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "enforcement", "1"); 139 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "edit", "readOnly"); 140 } 141 142 // Read-only is set, so Enforcement must enable it. 143 SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get()); 144 CPPUNIT_ASSERT(pTextDoc); 145 CPPUNIT_ASSERT(pTextDoc->GetDocShell()->IsSecurityOptOpenReadOnly()); 146 } 147 148 DECLARE_OOXMLEXPORT_TEST(testTdf120852_readOnlyUnProtected, "tdf120852_readOnlyUnProtected.docx") 149 { 150 // Readonly is not enforced, just a suggestion, 151 // so when a section is protected, the document should enable forms protection. 152 SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get()); 153 CPPUNIT_ASSERT(pTextDoc); 154 CPPUNIT_ASSERT(!pTextDoc->GetDocShell()->IsSecurityOptOpenReadOnly()); 155 156 uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY_THROW); 157 uno::Reference<container::XIndexAccess> xSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY_THROW); 158 const sal_Int32 nLastSection = xSections->getCount() - 1; 159 uno::Reference<beans::XPropertySet> xSect(xSections->getByIndex(nLastSection), uno::UNO_QUERY_THROW); 160 if ( !mbExported ) 161 { 162 CPPUNIT_ASSERT_MESSAGE("Section is not protected", !getProperty<bool>(xSect, "IsProtected")); 163 // Enable section protection. The round-trip should have forms protection enabled. 164 xSect->setPropertyValue("IsProtected", uno::makeAny(true)); 165 } 166 else 167 { 168 CPPUNIT_ASSERT_MESSAGE("Section is protected", getProperty<bool>(xSect, "IsProtected")); 169 xmlDocUniquePtr pXmlSettings = parseExport("word/settings.xml"); 170 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "edit", "forms"); 171 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "enforcement", "true"); 172 } 173 } 174 175 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testAuthorPropertySdt, "author-property.docx") 176 { 177 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); 178 179 assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:dataBinding", "xpath", "/ns1:coreProperties[1]/ns0:creator[1]"); 180 assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:dataBinding", "storeItemID","{6C3C8BC8-F283-45AE-878A-BAB7291924A1}"); 181 // FIXME: the next property doesn't match, though it's correct in theory. A bug in assertXPath? 182 // assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:dataBinding", "prefixMappings", 183 // "xmlns:ns0='http://purl.org/dc/elements/1.1/' xmlns:ns1='http://schemas.openxmlformats.org/package/2006/metadata/core-properties'"); 184 } 185 186 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testFDO76586, "fdo76586.docx") 187 { 188 /* 189 * In the test file gridCol had only one value for entire table width 190 * while there are two cells in a table row. 191 * So the table was not imported with the correct cell widths 192 */ 193 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); 194 195 // there is only one table in the test file 196 assertXPath(pXmlDoc, "//w:tblGrid/w:gridCol[1]", "w", "1601"); 197 assertXPath(pXmlDoc, "//w:tblGrid/w:gridCol[2]", "w", "7843"); 198 } 199 200 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testFDO76587 , "fdo76587.docx") 201 { 202 xmlDocUniquePtr pXmlDoc = parseExport("word/styles.xml"); 203 assertXPath(pXmlDoc, "/w:styles/w:style[8]/w:pPr/w:spacing", "line", "240"); 204 assertXPath(pXmlDoc, "/w:styles/w:style[8]/w:pPr/w:spacing", "lineRule", "auto"); 205 } 206 207 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testFDO77890 , "fdo77890.docx") 208 { 209 /* 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 213 */ 214 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); 215 assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[2]/w:br", "type", "page"); 216 } 217 218 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testNumberedList,"NumberedList.docx") 219 { 220 //fdo74150:In document.xml, for pStyle = "NumberedList1", iLvl and numId was not preserved 221 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); 222 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:p[1]/w:pPr[1]/w:pStyle", "val", "NumberedList1"); 223 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"); 224 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"); 225 226 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"); 227 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"); 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:numId","val", "0"); 229 } 230 231 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf131819, "NumberedList.docx") 232 { 233 // keep width of fixed size cells in the nested table 234 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); 235 // These were 4030 and 4249. 236 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblGrid/w:gridCol[1]", "w", "3841"); 237 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblGrid/w:gridCol[2]", "w", "4049"); 238 } 239 240 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf131959, "NumberedList.docx") 241 { 242 // import tblInd from table style 243 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); 244 // These were 0. 245 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblInd", "w", "360"); 246 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblInd", "w", "360"); 247 } 248 249 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testFDO76597, "fdo76597.docx") 250 { 251 // check XML 252 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); 253 assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:pPr/w:spacing", "before", "96"); 254 assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:pPr/w:spacing", "after", "120"); 255 } 256 257 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testContentTypeTIF, "fdo77476.docx") 258 { 259 xmlDocUniquePtr pXmlDoc = parseExport("[Content_Types].xml"); 260 261 assertXPath(pXmlDoc, "/ContentType:Types/ContentType:Override[@ContentType='image/tiff']", "PartName", "/word/media/image1.tif"); 262 } 263 264 DECLARE_OOXMLEXPORT_TEST(testFDO77117, "fdo77117.docx") 265 { 266 uno::Reference<drawing::XShapes> xGroup(getShape(1), uno::UNO_QUERY); 267 uno::Reference<text::XTextRange> xShape(xGroup->getByIndex(0), uno::UNO_QUERY); 268 // This checks textbox textrun size of font which is in group shape. 269 CPPUNIT_ASSERT_EQUAL(11.f, getProperty<float>(xShape, "CharHeight")); 270 } 271 272 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testFloatingTable, "fdo77887.docx") 273 { 274 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); 275 276 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "horzAnchor", "margin"); 277 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "leftFromText", "141"); 278 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "rightFromText", "141"); 279 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "tblpXSpec", "center"); 280 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "tblpY", "2266"); 281 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "vertAnchor", "page"); 282 283 //make sure not to write empty attributes which requires enumeration 284 assertXPathNoAttribute(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "tblpYSpec"); 285 } 286 287 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testOldComplexMergeRight, "tdf90681-1.odt") 288 { 289 CPPUNIT_ASSERT_EQUAL(1, getPages()); 290 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); 291 292 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[2]/w:tcPr/w:vMerge", "val", "restart"); 293 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[2]/w:tcPr/w:vMerge", "val", "continue"); 294 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[3]/w:tc[2]/w:tcPr/w:vMerge", "val", "continue"); 295 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[4]/w:tc[2]/w:tcPr/w:vMerge", "val", "continue"); 296 } 297 298 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testOldComplexMergeleft, "tdf90681-2.odt") 299 { 300 CPPUNIT_ASSERT_EQUAL(1, getPages()); 301 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); 302 303 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:vMerge", "val", "restart"); 304 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[1]/w:tcPr/w:vMerge", "val", "continue"); 305 } 306 307 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testOldComplexMergeTableInTable, "ooo96040-2.odt") 308 { 309 parseExport("word/document.xml"); 310 } 311 312 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testHyperlinkContainingPlaceholderField, "hyperlink-field.odt") 313 { 314 CPPUNIT_ASSERT_EQUAL(1, getShapes()); 315 parseExport("word/document.xml"); 316 } 317 318 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTablePreferredWidth, "tablePreferredWidth.docx") 319 { 320 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); 321 322 // Problem :If the table preferred width is in percent, then after RT it changes to 0 & width type changes 323 // to 'auto' instead of 'pct'. 324 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblW[1]", "w", "3000"); 325 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblW[1]", "type","pct"); 326 } 327 328 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testFDO75431, "fdo75431.docx") 329 { 330 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); 331 332 assertXPath(pXmlDoc, "//w:tbl", 2); 333 assertXPath(pXmlDoc, "//w:p/w:pPr/w:sectPr/w:type", "val", "nextPage"); 334 } 335 336 DECLARE_OOXMLEXPORT_TEST(testFDO77725, "fdo77725.docx") 337 { 338 xmlDocUniquePtr pXmlFootnotes = parseExport("word/footnotes.xml"); 339 if (!pXmlFootnotes) 340 return; 341 342 assertXPath(pXmlFootnotes, "//w:footnotes[1]/w:footnote[3]/w:p[3]/w:r[1]/w:br[1]", 0); 343 assertXPath(pXmlFootnotes, "//w:footnotes[1]/w:footnote[3]/w:p[3]/w:r[1]/w:br[2]", 0); 344 assertXPath(pXmlFootnotes, "//w:footnotes[1]/w:footnote[3]/w:p[3]/w:r[1]/w:br[3]", 0); 345 } 346 347 DECLARE_OOXMLEXPORT_TEST(testFieldRotation, "field-rotated.fodt") 348 { 349 uno::Reference<text::XTextRange> const xRun(getRun(uno::Reference<text::XTextRange>(getParagraphOrTable(1), uno::UNO_QUERY), 1)); 350 uno::Reference<text::XTextField> const xField(getProperty<uno::Reference<text::XTextField>>(xRun, "TextField")); 351 CPPUNIT_ASSERT(xField.is()); 352 CPPUNIT_ASSERT_EQUAL(OUString("DocInformation:Title"), xField->getPresentation(true)); 353 CPPUNIT_ASSERT_EQUAL(OUString("Rotationeering"), xField->getPresentation(false)); 354 // problem was that the rotation wasn't applied to all runs of the field 355 CPPUNIT_ASSERT_EQUAL(sal_Int16(900), getProperty<sal_Int16>(xRun, "CharRotation")); 356 } 357 358 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testFootnoteSeparator, "footnotesep.fodt") 359 { 360 // footnote separator definitions - taken from default page style 361 xmlDocUniquePtr pXmlFootnotes = parseExport("word/footnotes.xml"); 362 assertXPath(pXmlFootnotes, "/w:footnotes[1]/w:footnote[1]", "id", "0"); 363 assertXPath(pXmlFootnotes, "/w:footnotes[1]/w:footnote[1]", "type", "separator"); 364 assertXPath(pXmlFootnotes, "/w:footnotes[1]/w:footnote[1]/w:p[1]/w:r[1]/w:separator", 0); 365 // use paragraph font size to simulate height 366 assertXPath(pXmlFootnotes, "/w:footnotes[1]/w:footnote[1]/w:p[1]/w:pPr[1]/w:rPr[1]/w:sz", "val", "12"); 367 assertXPath(pXmlFootnotes, "/w:footnotes[1]/w:footnote[2]", "id", "1"); 368 assertXPath(pXmlFootnotes, "/w:footnotes[1]/w:footnote[2]", "type", "continuationSeparator"); 369 assertXPath(pXmlFootnotes, "/w:footnotes[1]/w:footnote[2]/w:p[1]/w:r[1]/w:continuationSeparator", 0); 370 assertXPath(pXmlFootnotes, "/w:footnotes[1]/w:footnote[2]/w:p[1]/w:pPr[1]/w:rPr[1]/w:sz", "val", "12"); 371 372 xmlDocUniquePtr pXmlSettings = parseExport("word/settings.xml"); 373 assertXPath(pXmlSettings, "/w:settings[1]/w:footnotePr[1]/w:footnote[1]", "id", "0"); 374 assertXPath(pXmlSettings, "/w:settings[1]/w:footnotePr[1]/w:footnote[2]", "id", "1"); 375 } 376 377 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf121441, "tdf121441.docx") 378 { 379 xmlDocUniquePtr pXmlFootnotes = parseExport("word/footnotes.xml"); 380 assertXPath(pXmlFootnotes, "/w:footnotes/w:footnote[3]/w:p/w:r[1]/w:rPr/w:rStyle", 1); 381 assertXPath(pXmlFootnotes, "/w:footnotes/w:footnote[3]/w:p/w:r[2]/w:rPr/w:rStyle", 0); 382 assertXPath(pXmlFootnotes, "/w:footnotes/w:footnote[3]/w:p/w:r[2]/w:rPr/w:rFonts", 0); 383 384 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); 385 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:rPr/w:rFonts", "eastAsia", "Symbol"); 386 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:rPr/w:rFonts", "cs", "Symbol"); 387 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:rPr/w:rFonts", "ascii", "Symbol"); 388 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:rPr/w:rFonts", "hAnsi", "Symbol"); 389 } 390 391 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testFDO77812, "fdo77812.docx") 392 { 393 /* Additional sectPr was getting inserted and hence Column properties 394 * were getting added into this additional sectPr instead of Default setPr. 395 */ 396 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); 397 398 // Check no additional section break is inserted. 399 assertXPath(pXmlDoc, "/w:document/w:body/w:p[6]/w:pPr/w:sectPr", 0); 400 401 // Check w:cols comes under Default sectPr 402 assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:cols", "num", "2"); 403 assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:cols/w:col[1]", 1); 404 assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:cols/w:col[2]", 1); 405 } 406 407 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testContentTypeOLE, "fdo77759.docx") 408 { 409 xmlDocUniquePtr pXmlDoc = parseExport("[Content_Types].xml"); 410 411 assertXPath(pXmlDoc, 412 "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']", 413 "PartName", 414 "/word/embeddings/oleObject1.xlsx"); 415 416 // check the rels too 417 xmlDocUniquePtr pXmlDocRels = parseExport("word/_rels/document.xml.rels"); 418 assertXPath(pXmlDocRels, 419 "/rels:Relationships/rels:Relationship[@Target='embeddings/oleObject1.xlsx']", 420 "Type", 421 "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"); 422 // check the content too 423 xmlDocUniquePtr pXmlDocContent = parseExport("word/document.xml"); 424 assertXPath(pXmlDocContent, 425 "/w:document/w:body/w:p[1]/w:r/w:object/o:OLEObject", 426 "ProgID", 427 "Excel.Sheet.12"); 428 } 429 430 DECLARE_OOXMLEXPORT_TEST(testfdo78420, "fdo78420.docx") 431 { 432 xmlDocUniquePtr pXmlHeader = parseExport("word/header2.xml"); 433 434 if (!pXmlHeader) 435 return; 436 437 xmlDocUniquePtr pXmlHeaderRels = parseExport("word/_rels/header2.xml.rels"); 438 if(!pXmlHeaderRels) 439 return; 440 441 assertXPath(pXmlHeaderRels,"/rels:Relationships/rels:Relationship[1]","Id","rId1"); 442 } 443 444 445 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testPageBreakInFirstPara,"fdo77727.docx") 446 { 447 /* Break to next page was not exported if it is in first paragraph of the section. 448 * Now after fix , LO writes Next Page Break and also preserves <w:br> tag. 449 */ 450 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); 451 452 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[2]/w:br","type","page"); 453 } 454 455 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testFDO78284, "fdo78284.docx") 456 { 457 xmlDocUniquePtr pXmlDoc = parseExport("[Content_Types].xml"); 458 assertXPath(pXmlDoc,"/ContentType:Types/ContentType:Override[@PartName='/word/media/OOXDiagramDataRels1_0.png']", 459 "ContentType", 460 "image/png"); 461 } 462 463 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testFDO78384,"fdo78384.docx") 464 { 465 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); 466 assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[1]/w:rPr/w:rFonts","ascii","Wingdings"); 467 } 468 469 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testfdo78469, "fdo78469.docx") 470 { 471 xmlDocUniquePtr pXmlDoc = parseExport("word/header1.xml"); 472 // make sure dataBinding & text tags not present in sdtcontent 473 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); 474 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); 475 } 476 477 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testFDO78887, "fdo78887.docx") 478 { 479 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); 480 481 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/w:br[1]", 1); 482 assertXPathContent(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/w:t[1]", "Lyrics: "); 483 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/w:br[2]", 1); 484 } 485 486 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testFDO78887b, "missing_newline.odt") 487 { 488 CPPUNIT_ASSERT_EQUAL(1, getPages()); 489 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); 490 491 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[2]/w:br[1]", 1); 492 assertXPathContent(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/w:t[1]", "Tab and line break"); 493 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[5]/w:br[1]", 1); 494 assertXPathContent(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[6]/w:t[1]", "New line"); 495 } 496 497 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testFdo78651, "fdo78651.docx") 498 { 499 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); 500 // ensure that there are only two tables 501 assertXPath(pXmlDoc, "//w:tbl", 2); 502 } 503 504 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testfdo78882, "fdo78882.docx") 505 { 506 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); 507 508 // Ensure that Section Break is getting written inside second paragraph 509 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[2]/w:pPr[1]/w:sectPr[1]",1); 510 511 // Ensure that no dummy paragraph gets created inside second paragraph for Section Break 512 assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[2]/w:p[1]/w:pPr[1]/w:sectPr[1]",0); 513 } 514 515 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testfdo76934, "fdo76934.docx") 516 { 517 /* Issue was, AutoSpacing property if present inside styles.xml, LO was not able to 518 * preserve it. 519 */ 520 521 xmlDocUniquePtr pXmlDoc = parseExport("word/styles.xml"); 522 523 // Ensure that after fix LO is preserving AutoSpacing property in styles.xml 524 assertXPath ( pXmlDoc, "/w:styles[1]/w:style[@w:styleId='Title']/w:pPr[1]/w:spacing[1]", "beforeAutospacing", "1" ); 525 } 526 527 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testfdo79540, "fdo79540.docx") 528 { 529 /* Issue was, <w:drawing> was getting written inside <w:drawing>. 530 * So postpone the writing of Inner Drawing tag. 531 * MS Office does not allow nesting of drawing tags. 532 */ 533 534 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); 535 536 // Ensure that two separate w:drawing tags are written and they are not nested. 537 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing", 1); 538 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing", 1); 539 } 540 541 DECLARE_OOXMLEXPORT_TEST(testFDO79062, "fdo79062.docx") 542 { 543 xmlDocUniquePtr pXmlFootNotes = parseExport("word/footnotes.xml"); 544 if (!pXmlFootNotes) 545 return; 546 assertXPath(pXmlFootNotes, "/w:footnotes", "Ignorable", "w14 wp14"); 547 548 xmlDocUniquePtr pXmlEndNotes = parseExport("word/endnotes.xml"); 549 if (!pXmlEndNotes) 550 return; 551 assertXPath(pXmlEndNotes, "/w:endnotes", "Ignorable", "w14 wp14"); 552 553 //tdf#93121 don't add fake tabs in front of extra footnote paragraphs 554 uno::Reference<text::XFootnotesSupplier> xFootnoteSupp(mxComponent, uno::UNO_QUERY); 555 uno::Reference<container::XIndexAccess> xFootnoteIdxAcc = xFootnoteSupp->getFootnotes(); 556 uno::Reference<text::XFootnote> xFootnote(xFootnoteIdxAcc->getByIndex(0), uno::UNO_QUERY); 557 uno::Reference<text::XText> xFootnoteText(xFootnote, uno::UNO_QUERY); 558 uno::Reference<container::XEnumerationAccess>xParaEnumAccess(xFootnoteText->getText(), uno::UNO_QUERY); 559 uno::Reference<container::XEnumeration>xParaEnum = xParaEnumAccess->createEnumeration(); 560 561 uno::Reference<text::XTextRange> xTextRange; 562 xParaEnum->nextElement(); 563 xParaEnum->nextElement() >>= xTextRange; 564 OUString sFootnotePara = xTextRange->getString(); 565 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Paragraph starts with W(87), not tab(9)", u'W', sFootnotePara[0] ); 566 } 567 568 DECLARE_OOXMLEXPORT_TEST(testTdf123262_textFootnoteSeparators, "tdf123262_textFootnoteSeparators.docx") 569 { 570 //Everything easily fits on one page 571 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Number of Pages", 1, getPages() ); 572 573 uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY); 574 uno::Reference<container::XIndexAccess> xFootnotes = xFootnotesSupplier->getFootnotes(); 575 uno::Reference<text::XText> xFootnoteText(xFootnotes->getByIndex(0), uno::UNO_QUERY); 576 577 // The text in the separator footnote should not be added to the footnotes 578 OUString sText = " Microsoft Office."; 579 CPPUNIT_ASSERT_EQUAL(sText, xFootnoteText->getString()); 580 581 // Ensure that paragraph markers are not lost. 582 xFootnoteText.set(xFootnotes->getByIndex(1), uno::UNO_QUERY); 583 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Number of paragraphs in second footnote", 2, getParagraphs(xFootnoteText) ); 584 } 585 586 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testfdo79668,"fdo79668.docx") 587 { 588 // fdo#79668: Document was Crashing on DebugUtil build while Saving 589 // because of repeated attribute value in same element. 590 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); 591 // w:pPr's w:shd attributes were getting added to w:pPrChange/w:pPr's w:shd hence checking 592 // w:fill for both shd elements 593 assertXPath ( pXmlDoc, "/w:document/w:body/w:p[9]/w:pPr/w:shd", "fill", "FFFFFF" ); 594 assertXPath ( pXmlDoc, "/w:document/w:body/w:p[9]/w:pPr/w:pPrChange/w:pPr/w:shd", "fill", "FFFFFF" ); 595 } 596 597 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testfdo78907,"fdo78907.docx") 598 { 599 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); 600 assertXPath ( pXmlDoc, "/w:document/w:body/w:p[1]/w:r[2]/w:br", "type", "page" ); 601 602 xmlDocUniquePtr pXmlDoc1 = parseExport("word/footer1.xml"); 603 if (!pXmlDoc1) 604 return; 605 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 ); 606 } 607 608 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(tdf118702,"tdf118702.odt") 609 { 610 CPPUNIT_ASSERT_EQUAL(2, getPages()); 611 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); 612 assertXPath ( pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:sectPr/w:type", "val", "nextPage" ); 613 assertXPath ( pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:sectPr/w:pgSz", "orient", "landscape" ); 614 } 615 616 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testfdo79822, "fdo79822.docx") 617 { 618 /* File getting crash while saving in LO. 619 * The Docx contain smartart and the file was created in ms word 2007 620 */ 621 parseExport("word/document.xml"); 622 } 623 624 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testFDO79915, "fdo79915.docx") 625 { 626 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); 627 628 assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[10]/w:t", "How much buoyancy does the water provide?"); 629 } 630 631 DECLARE_OOXMLEXPORT_TEST(testfdo79817, "fdo79817.docx") 632 { 633 if (xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml")) 634 { 635 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:dataBinding", "storeItemID", "{9222E47B-A68B-4AEB-9855-21C912B9D3D2}"); 636 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]"); 637 } 638 } 639 640 641 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testfdo79968_sldx, "fdo79968.docx") 642 { 643 // This UT for DOCX embedded with powerpoint slide 644 xmlDocUniquePtr pXmlDoc = parseExport("[Content_Types].xml"); 645 646 assertXPath(pXmlDoc, 647 "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.openxmlformats-officedocument.presentationml.slide']", 648 "PartName", 649 "/word/embeddings/oleObject1.sldx"); 650 651 // check the rels too 652 xmlDocUniquePtr pXmlDocRels = parseExport("word/_rels/document.xml.rels"); 653 assertXPath(pXmlDocRels, 654 "/rels:Relationships/rels:Relationship[@Target='embeddings/oleObject1.sldx']", 655 "Type", 656 "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"); 657 // check the content too 658 xmlDocUniquePtr pXmlDocContent = parseExport("word/document.xml"); 659 assertXPath(pXmlDocContent, 660 "/w:document/w:body/w:p[1]/w:r/w:object/o:OLEObject", 661 "ProgID", 662 "PowerPoint.Slide.12"); 663 } 664 665 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testfdo79969_xlsb, "fdo79969_xlsb.docx") 666 { 667 // This UT for DOCX embedded with binary excel work sheet. 668 xmlDocUniquePtr pXmlDoc = parseExport("[Content_Types].xml"); 669 670 assertXPath(pXmlDoc, 671 "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.ms-excel.sheet.binary.macroEnabled.12']", 672 "PartName", 673 "/word/embeddings/oleObject1.xlsb"); 674 675 // check the rels too 676 xmlDocUniquePtr pXmlDocRels = parseExport("word/_rels/document.xml.rels"); 677 assertXPath(pXmlDocRels, 678 "/rels:Relationships/rels:Relationship[@Target='embeddings/oleObject1.xlsb']", 679 "Type", 680 "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"); 681 // check the content too 682 xmlDocUniquePtr pXmlDocContent = parseExport("word/document.xml"); 683 assertXPath(pXmlDocContent, 684 "/w:document/w:body/w:p[1]/w:r/w:object/o:OLEObject", 685 "ProgID", 686 "Excel.SheetBinaryMacroEnabled.12"); 687 } 688 689 DECLARE_OOXMLEXPORT_TEST(testfdo80097, "fdo80097.docx") 690 { 691 //fdo#76635 : Table borders are not getting preserved. 692 693 xmlDocUniquePtr pXmlDocument = parseExport("word/document.xml"); 694 if (!pXmlDocument) 695 return; 696 697 //Table Cell Borders 698 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); 699 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); 700 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); 701 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); 702 703 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); 704 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); 705 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); 706 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); 707 708 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); 709 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); 710 } 711 712 DECLARE_OOXMLEXPORT_TEST(testTdf95033, "tdf95033.docx") 713 { 714 //tdf#95033 : Table borders defined by row-level tblPrEx are not getting preserved. 715 716 xmlDocUniquePtr pXmlDocument = parseExport("word/document.xml"); 717 if (!pXmlDocument) 718 return; 719 720 //Not disabled table cell borders 721 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[5]/w:tc[1]/w:tcPr/w:tcBorders/w:start[@w:val = 'nil']", 0); 722 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[5]/w:tc[2]/w:tcPr/w:tcBorders/w:end[@w:val = 'nil']", 0); 723 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[9]/w:tc[1]/w:tcPr/w:tcBorders/w:start[@w:val = 'nil']", 0); 724 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[9]/w:tc[2]/w:tcPr/w:tcBorders/w:end[@w:val = 'nil']", 0); 725 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[9]/w:tc[1]/w:tcPr/w:tcBorders/w:bottom[@w:val = 'nil']", 0); 726 assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[9]/w:tc[2]/w:tcPr/w:tcBorders/w:bottom[@w:val = 'nil']", 0); 727 } 728 729 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf128646, "tdf128646.docx") 730 { 731 // The problem was that not hidden shapes anchored to empty hidden paragraphs were imported as hidden. 732 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); 733 734 assertXPath(pXmlDoc,"/w:document/w:body/w:tbl/w:tr/w:tc/w:p[7]/w:pPr/w:rPr/w:vanish", 1); 735 if (!mbExported) 736 // originally no <w:vanish> (the same as <w:vanish val="false">) 737 assertXPath(pXmlDoc,"/w:document/w:body/w:tbl/w:tr/w:tc/w:p[7]/w:r/w:rPr/w:vanish", 0); 738 else 739 // This was hidden (<w:vanish/>) 740 assertXPath(pXmlDoc,"/w:document/w:body/w:tbl/w:tr/w:tc/w:p[7]/w:r/w:rPr/w:vanish", "val", "false"); 741 } 742 743 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf119800, "tdf119800.docx") 744 { 745 // The problem was that not hidden shapes anchored to empty hidden paragraphs were imported as hidden. 746 // (tdf#128646 solved the same only for table paragraphs) 747 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); 748 749 assertXPath(pXmlDoc,"/w:document/w:body/w:p[2]/w:pPr/w:rPr/w:vanish", 1); 750 if (!mbExported) 751 // originally no <w:vanish> (the same as <w:vanish val="false">) 752 assertXPath(pXmlDoc,"/w:document/w:body/w:p[2]/w:r/w:rPr/w:vanish", 0); 753 else 754 // This was hidden (<w:vanish/>) 755 assertXPath(pXmlDoc,"/w:document/w:body/w:p[2]/w:r/w:rPr/w:vanish", "val", "false"); 756 } 757 758 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testFdo77129, "fdo77129.docx") 759 { 760 // The problem was that text after TOC field was missing if footer reference comes in field. 761 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); 762 763 // Data was lost from this paragraph. 764 assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[4]/w:r[1]/w:t", "Abstract"); 765 } 766 767 // Test the same testdoc used for testFdo77129. 768 DECLARE_OOXMLEXPORT_TEST(testTdf129402, "fdo77129.docx") 769 { 770 // tdf#129402: ToC title must be "Contents", not "Content"; the index field must include 771 // pre-rendered element. 772 773 // Currently export drops empty paragraph after ToC, so skip getParagraphs test for now 774 // CPPUNIT_ASSERT_EQUAL(5, getParagraphs()); 775 CPPUNIT_ASSERT_EQUAL(OUString("owners."), getParagraph(1)->getString()); 776 CPPUNIT_ASSERT_EQUAL(OUString("Contents"), getParagraph(2)->getString()); 777 CPPUNIT_ASSERT_EQUAL(OUString("How\t2"), getParagraph(3)->getString()); 778 // CPPUNIT_ASSERT_EQUAL(OUString(), getParagraph(4)->getString()); 779 780 uno::Reference<text::XDocumentIndexesSupplier> xIndexSupplier(mxComponent, uno::UNO_QUERY); 781 uno::Reference<container::XIndexAccess> xIndexes = xIndexSupplier->getDocumentIndexes(); 782 uno::Reference<text::XDocumentIndex> xIndex(xIndexes->getByIndex(0), uno::UNO_QUERY); 783 uno::Reference<text::XTextRange> xTextRange = xIndex->getAnchor(); 784 uno::Reference<text::XText> xText = xTextRange->getText(); 785 uno::Reference<text::XTextCursor> xTextCursor = xText->createTextCursor(); 786 xTextCursor->gotoRange(xTextRange->getStart(), false); 787 xTextCursor->gotoRange(xTextRange->getEnd(), true); 788 OUString aTocString(xTextCursor->getString()); 789 790 // Check that the pre-rendered entry is inside the index 791 CPPUNIT_ASSERT_EQUAL(OUString("How\t2"), aTocString); 792 } 793 794 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testfdo79969_xlsm, "fdo79969_xlsm.docx") 795 { 796 // This UT for DOCX embedded with excel work sheet. 797 xmlDocUniquePtr pXmlDoc = parseExport("[Content_Types].xml"); 798 799 assertXPath(pXmlDoc, 800 "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.ms-excel.sheet.macroEnabled.12']", 801 "PartName", 802 "/word/embeddings/oleObject1.xlsm"); 803 804 // check the rels too 805 xmlDocUniquePtr pXmlDocRels = parseExport("word/_rels/document.xml.rels"); 806 assertXPath(pXmlDocRels, 807 "/rels:Relationships/rels:Relationship[@Target='embeddings/oleObject1.xlsm']", 808 "Type", 809 "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"); 810 // check the content too 811 xmlDocUniquePtr pXmlDocContent = parseExport("word/document.xml"); 812 assertXPath(pXmlDocContent, 813 "/w:document/w:body/w:p[1]/w:r/w:object/o:OLEObject", 814 "ProgID", 815 "Excel.SheetMacroEnabled.12"); 816 } 817 818 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testfdo80522,"fdo80522.docx") 819 { 820 xmlDocUniquePtr pXmlDoc = parseExport("[Content_Types].xml"); 821 822 assertXPath(pXmlDoc, 823 "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.ms-word.document.macroEnabled.12']", 824 "PartName", 825 "/word/embeddings/oleObject1.docm"); 826 827 // check the rels too 828 xmlDocUniquePtr pXmlDocRels = parseExport("word/_rels/document.xml.rels"); 829 assertXPath(pXmlDocRels, 830 "/rels:Relationships/rels:Relationship[@Target='embeddings/oleObject1.docm']", 831 "Type", 832 "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"); 833 // check the content too 834 xmlDocUniquePtr pXmlDocContent = parseExport("word/document.xml"); 835 assertXPath(pXmlDocContent, 836 "/w:document/w:body/w:p[1]/w:r/w:object/o:OLEObject", 837 "ProgID", 838 "Word.DocumentMacroEnabled.12"); 839 } 840 841 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testfdo80523_pptm,"fdo80523_pptm.docx") 842 { 843 xmlDocUniquePtr pXmlDoc = parseExport("[Content_Types].xml"); 844 845 assertXPath(pXmlDoc, 846 "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.ms-powerpoint.presentation.macroEnabled.12']", 847 "PartName", 848 "/word/embeddings/oleObject1.pptm"); 849 850 // check the rels too 851 xmlDocUniquePtr pXmlDocRels = parseExport("word/_rels/document.xml.rels"); 852 assertXPath(pXmlDocRels, 853 "/rels:Relationships/rels:Relationship[@Target='embeddings/oleObject1.pptm']", 854 "Type", 855 "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"); 856 // check the content too 857 xmlDocUniquePtr pXmlDocContent = parseExport("word/document.xml"); 858 assertXPath(pXmlDocContent, 859 "/w:document/w:body/w:p[1]/w:r/w:object/o:OLEObject", 860 "ProgID", 861 "PowerPoint.ShowMacroEnabled.12"); 862 } 863 864 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testfdo80523_sldm,"fdo80523_sldm.docx") 865 { 866 xmlDocUniquePtr pXmlDoc = parseExport("[Content_Types].xml"); 867 868 assertXPath(pXmlDoc, 869 "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.ms-powerpoint.slide.macroEnabled.12']", 870 "PartName", 871 "/word/embeddings/oleObject1.sldm"); 872 873 // check the rels too 874 xmlDocUniquePtr pXmlDocRels = parseExport("word/_rels/document.xml.rels"); 875 assertXPath(pXmlDocRels, 876 "/rels:Relationships/rels:Relationship[@Target='embeddings/oleObject1.sldm']", 877 "Type", 878 "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"); 879 // check the content too 880 xmlDocUniquePtr pXmlDocContent = parseExport("word/document.xml"); 881 assertXPath(pXmlDocContent, 882 "/w:document/w:body/w:p[1]/w:r/w:object/o:OLEObject", 883 "ProgID", 884 "PowerPoint.SlideMacroEnabled.12"); 885 } 886 887 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testfdo80898, "fdo80898.docx") 888 { 889 // This UT for DOCX embedded with binary excel work sheet. 890 xmlDocUniquePtr pXmlDoc = parseExport("[Content_Types].xml"); 891 892 assertXPath(pXmlDoc, 893 "/ContentType:Types/ContentType:Override[@ContentType='application/msword']", 894 "PartName", 895 "/word/embeddings/oleObject1.doc"); 896 897 // check the rels too 898 xmlDocUniquePtr pXmlDocRels = parseExport("word/_rels/document.xml.rels"); 899 assertXPath(pXmlDocRels, 900 "/rels:Relationships/rels:Relationship[@Target='embeddings/oleObject1.doc']", 901 "Type", 902 "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"); 903 // check the content too 904 xmlDocUniquePtr pXmlDocContent = parseExport("word/document.xml"); 905 assertXPath(pXmlDocContent, 906 "/w:document/w:body/w:p[1]/w:r/w:object/o:OLEObject", 907 "ProgID", 908 "Word.Document.8"); 909 } 910 911 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTableCellWithDirectFormatting, "fdo80800.docx") 912 { 913 // Issue was Direct Formatting for non-first Table cells was not getting preserved. 914 915 xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); 916 917 // Ensure that for Third Table cell Direct Formatting is preserved. 918 // In file, Direct Formatting used for Third Table cell is Line Spacing="1.5 lines" 919 // For Line Spacing "1.5 lines" w:line equals 360 920 assertXPath(pXmlDoc,"/w:document/w:body/w:tbl/w:tr/w:tc[3]/w:p/w:pPr/w:spacing","line","360"); 921 922 } 923 924 DECLARE_OOXMLEXPORT_TEST(testFdo80800b_tableStyle, "fdo80800b_tableStyle.docx") 925 { 926 uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY); 927 uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY); 928 uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xCell->getText(), uno::UNO_QUERY); 929 uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); 930 uno::Reference<text::XTextRange> xPara(xParaEnum->nextElement(), uno::UNO_QUERY); 931 CPPUNIT_ASSERT_EQUAL(OUString("Cell1 1.5lines"), xPara->getString()); 932 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell A1 1.5 line spacing", sal_Int16(150), getProperty<style::LineSpacing>(xPara, "ParaLineSpacing").Height); 933 934 xCell.set(xTable->getCellByName("B1"), uno::UNO_QUERY); 935 xParaEnumAccess.set(xCell->getText(), uno::UNO_QUERY); 936 xParaEnum = xParaEnumAccess->createEnumeration(); 937 xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); 938 CPPUNIT_ASSERT_EQUAL(OUString("Cell2 Implicit (Single)"), xPara->getString()); 939 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B1 single line spacing", sal_Int16(100), getProperty<style::LineSpacing>(xPara, "ParaLineSpacing").Height); 940 941 xCell.set(xTable->getCellByName("C1"), uno::UNO_QUERY); 942 xParaEnumAccess.set(xCell->getText(), uno::UNO_QUERY); 943 xParaEnum = xParaEnumAccess->createEnumeration(); 944 xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); 945 CPPUNIT_ASSERT_EQUAL(OUString("Cell3 Implicit (Single)"), xPara->getString()); 946 CPPUNIT_ASSERT_EQUAL_MESSAGE("C1 paragraph1 single line spacing", sal_Int16(100), getProperty<style::LineSpacing>(xPara, "ParaLineSpacing").Height); 947 xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); 948 xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); 949 CPPUNIT_ASSERT_EQUAL_MESSAGE("C1 paragraph3 line spacing", sal_Int16(212), getProperty<style::LineSpacing>(xPara, "ParaLineSpacing").Height); 950 } 951 952 DECLARE_OOXMLEXPORT_TEST(testTdf117297_tableStyle, "tdf117297_tableStyle.docx") 953 { 954 uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY); 955 uno::Reference<text::XTextRange> xCell(xTable->getCellByName("B1"), uno::UNO_QUERY); 956 uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xCell->getText(), uno::UNO_QUERY); 957 uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); 958 uno::Reference<text::XTextRange> xPara(xParaEnum->nextElement(), uno::UNO_QUERY); 959 uno::Reference<text::XText> xText = xPara->getText(); 960 CPPUNIT_ASSERT_EQUAL(OUString("Green text, default size (9), 1.5 spaced"), xPara->getString()); 961 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B1 Paragraph1 green font", sal_Int32(0x70AD47), getProperty<sal_Int32>(getRun(xPara, 1), "CharColor")); 962 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B1 Paragraph1 1.5 line spacing", sal_Int16(150), getProperty<style::LineSpacing>(xPara, "ParaLineSpacing").Height); 963 xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); 964 xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); 965 xText = xPara->getText(); 966 CPPUNIT_ASSERT_EQUAL(OUString("TableGrid color (blue), TableGrid size (9), double spacing"), xPara->getString()); 967 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B1 Paragraph3 blue font", sal_Int32(0x00B0F0), getProperty<sal_Int32>(getRun(xPara, 1), "CharColor")); 968 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B1 Paragraph3 double spacing", sal_Int16(200), getProperty<style::LineSpacing>(xPara, "ParaLineSpacing").Height); 969 } 970 971 DECLARE_OOXMLEXPORT_TEST(testTdf82175_noStyleInheritance, "tdf82175_noStyleInheritance.docx") 972 { 973 // The document's "Default" paragraph style is 1 inch fixed line spacing, and that is what should not be inherited. 974 style::LineSpacing aSpacing = getProperty<style::LineSpacing>(getParagraph(1), "ParaLineSpacing"); 975 // MSWord uses 115% line spacing, but LO follows the documentation and sets single spacing. 976 CPPUNIT_ASSERT_MESSAGE("Text Body style 115% line spacing", sal_Int16(120) > aSpacing.Height); 977 CPPUNIT_ASSERT_MESSAGE("THANKS for *FIXING* line spacing", sal_Int16(115) != aSpacing.Height); 978 CPPUNIT_ASSERT_EQUAL(sal_Int16(style::LineSpacingMode::PROP), aSpacing.Mode); 979 } 980 981 DECLARE_OOXMLEXPORT_TEST(test2colHeader, "2col-header.docx") 982 { 983 // Header was lost on export when the document had multiple columns. 984 uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY); 985 CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xPageStyle, "HeaderIsOn")); 986 } 987 988 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testfdo83048, "fdo83048.docx") 989 { 990 // Issue was wrong SDT properties were getting exported for Date SDT 991 xmlDocUniquePtr pXmlDoc = parseExport("word/footer1.xml"); 992 993 // Make sure Date is inside SDT tag. 994 // This will happen only if right SDT properties are exported. 995 assertXPathContent(pXmlDoc, "/w:ftr/w:sdt/w:sdtContent/w:p[1]/w:sdt/w:sdtContent/w:r[2]/w:t", 996 "1/2/2013"); 997 } 998 999 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testSdt2Run, "sdt-2-run.docx") 1000 { 1001 xmlDocUniquePtr pXmlDoc = parseExport(); 1002 1003 // The problem was that <w:sdt> was closed after "first", not after "second", so the second assert failed. 1004 assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r[1]/w:t", "first"); 1005 assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r[2]/w:t", "second"); 1006 // Make sure the third portion is still outside <w:sdt>. 1007 assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/w:t", "third"); 1008 } 1009 1010 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testFD083057, "fdo83057.docx") 1011 { 1012 xmlDocUniquePtr pXmlDoc = parseExport("word/header1.xml"); 1013 1014 // A fly frame was attached to a para which started with a hint (run) containing an SDT. 1015 // This SDT was handled while exporting the FLYFRAME and also the text of the run. 1016 // So, even though the original file had only one sdt in the header, the RT file had two; 1017 // one for a separate run as expected, and one incorrectly exported in the alternateContent (FLYFRAME) 1018 1019 // Assert that the file has only one sdt, in a separate run 1020 assertXPath(pXmlDoc, "//w:sdt", 1); 1021 assertXPath(pXmlDoc, "//mc:AlternateContent//w:sdt", 0); 1022 } 1023 1024 DECLARE_OOXMLEXPORT_TEST(testHeaderBorder, "header-border.docx") 1025 { 1026 if (xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml")) 1027 { 1028 // This was 0, as header margin was lost during import. 1029 assertXPath(pXmlDoc, "//w:pgMar", "header", "720"); 1030 // This was 33: 33 points -> 660 twips. We counted 900 - 240 (distance 1031 // of page and body frame) instead of 720 - 240 (distance of page and 1032 // header frame). 1033 assertXPath(pXmlDoc, "//w:pgBorders/w:top", "space", "24"); 1034 } 1035 } 1036 1037 DECLARE_OOXMLEXPORT_TEST(testTablepprShape, "tblppr-shape.docx") 1038 { 1039 // Unhandled exception due to unexpected w:tblpPr resulted in not importing page size, either. 1040 uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY); 1041 // This was 2000, page width wasn't large enough. 1042 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2540), getProperty<sal_Int32>(xPageStyle, "LeftMargin")); 1043 } 1044 1045 DECLARE_OOXMLEXPORT_TEST(testImageNoborder, "image-noborder.docx") 1046 { 1047 // This was 26; we exported border for an image that had no border. 1048 CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(0), getProperty<table::BorderLine2>(getShape(1), "TopBorder").LineWidth); 1049 } 1050 1051 DECLARE_OOXMLEXPORT_TEST(testTdf89774, "tdf89774.fodt") 1052 { 1053 if (xmlDocUniquePtr pXmlDoc = parseExport("docProps/app.xml")) 1054 // This was 65, as unit was seconds instead of minutes. 1055 assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:TotalTime", "1"); 1056 } 1057 1058 DECLARE_OOXMLEXPORT_TEST(testSectionProtection, "sectionprot.odt") 1059 { 1060 if (xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml")) 1061 { 1062 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:pPr/w:sectPr/w:formProt", "val", "true"); 1063 assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:formProt", "val", "false"); 1064 } 1065 1066 if (xmlDocUniquePtr pXmlSettings = parseExport("word/settings.xml")) 1067 { 1068 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "enforcement", "true"); 1069 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "edit", "forms"); 1070 } 1071 1072 uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY); 1073 uno::Reference<container::XIndexAccess> xSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY); 1074 uno::Reference<beans::XPropertySet> xSect(xSections->getByIndex(0), uno::UNO_QUERY); 1075 CPPUNIT_ASSERT_EQUAL_MESSAGE("TextSection is protected", true, getProperty<bool>(xSect, "IsProtected")); 1076 xSect.set(xSections->getByIndex(1), uno::UNO_QUERY); 1077 CPPUNIT_ASSERT_EQUAL_MESSAGE("Section1 is protected", false, getProperty<bool>(xSect, "IsProtected")); 1078 } 1079 1080 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testSectionProtection2, "sectionprot2.odt") 1081 { 1082 CPPUNIT_ASSERT_EQUAL(1, getPages()); 1083 if (xmlDocUniquePtr pXmlSettings = parseExport("word/settings.xml")) 1084 { 1085 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "enforcement", "true"); 1086 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "edit", "forms"); 1087 } 1088 1089 uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY); 1090 uno::Reference<container::XIndexAccess> xSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY); 1091 uno::Reference<beans::XPropertySet> xSect(xSections->getByIndex(0), uno::UNO_QUERY); 1092 CPPUNIT_ASSERT_EQUAL_MESSAGE("TextSection is protected", true, getProperty<bool>(xSect, "IsProtected")); 1093 } 1094 1095 DECLARE_OOXMLEXPORT_TEST(tdf66398_permissions, "tdf66398_permissions.docx") 1096 { 1097 // check document permission settings for the whole document 1098 if (xmlDocUniquePtr pXmlSettings = parseExport("word/settings.xml")) 1099 { 1100 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "edit", "readOnly"); 1101 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "enforcement", "1"); 1102 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "cryptProviderType", "rsaAES"); 1103 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "cryptAlgorithmClass","hash"); 1104 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "cryptAlgorithmType", "typeAny"); 1105 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "cryptAlgorithmSid", "14"); 1106 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "cryptSpinCount", "100000"); 1107 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "hash", "A0/Xy6KcXljJlZjP0TwJMPJuW2rc46UwXqn2ctxckc2nCECE5i89M85z2Noh3ZEA5NBQ9RJ5ycxiUH6nzmJaKw=="); 1108 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "salt", "B8k6wb1pkjUs4Nv/8QBk/w=="); 1109 } 1110 1111 // get bookmark interface 1112 uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY); 1113 uno::Reference<container::XIndexAccess> xBookmarksByIdx(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY); 1114 uno::Reference<container::XNameAccess> xBookmarksByName = xBookmarksSupplier->getBookmarks(); 1115 1116 // check: we have 2 bookmarks 1117 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xBookmarksByIdx->getCount()); 1118 CPPUNIT_ASSERT(xBookmarksByName->hasByName("_GoBack")); 1119 CPPUNIT_ASSERT(xBookmarksByName->hasByName("permission-for-group:267014232:everyone")); 1120 } 1121 1122 DECLARE_OOXMLEXPORT_TEST(tdf106843, "tdf106843.fodt") 1123 { 1124 // check Track Changes permission set in Writer/OpenDocument (password: "test", encoded by default encoding of Writer) 1125 if (xmlDocUniquePtr pXmlSettings = parseExport("word/settings.xml")) 1126 { 1127 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "edit", "trackedChanges"); 1128 assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "enforcement", "1"); 1129 1130 // LO intends to export a .docx format that is natively compatible with 2013 1131 // but this document has an implicitly added setting AddExternalLeading = false 1132 assertXPath(pXmlSettings, "/w:settings/w:compat/w:compatSetting[1]", "name", "compatibilityMode"); 1133 assertXPath(pXmlSettings, "/w:settings/w:compat/w:compatSetting[1]", "uri", "http://schemas.microsoft.com/office/word"); 1134 assertXPath(pXmlSettings, "/w:settings/w:compat/w:compatSetting[1]", "val", "14"); // compatible with 2010 1135 } 1136 } 1137 1138 DECLARE_OOXMLEXPORT_TEST(tdf89991_revisionView, "tdf89991.docx") 1139 { 1140 // check revisionView (Show Changes) import and export 1141 if (xmlDocUniquePtr pXmlSettings = parseExport("word/settings.xml")) 1142 { 1143 assertXPath(pXmlSettings, "/w:settings/w:revisionView", "insDel", "0"); 1144 assertXPath(pXmlSettings, "/w:settings/w:revisionView", "formatting", "0"); 1145 1146 // There was no compatibilityMode defined. 1147 // 12: Use word processing features specified in ECMA-376. This is the default. 1148 assertXPath(pXmlSettings, "/w:settings/w:compat/w:compatSetting[1]", "name", "compatibilityMode"); 1149 assertXPath(pXmlSettings, "/w:settings/w:compat/w:compatSetting[1]", "uri", "http://schemas.microsoft.com/office/word"); 1150 assertXPath(pXmlSettings, "/w:settings/w:compat/w:compatSetting[1]", "val", "12"); 1151 } 1152 } 1153 1154 DECLARE_OOXMLEXPORT_TEST(tdf122201_editUnprotectedText, "tdf122201_editUnprotectedText.odt") 1155 { 1156 CPPUNIT_ASSERT_EQUAL(1, getPages()); 1157 // get the document 1158 SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get()); 1159 CPPUNIT_ASSERT(pTextDoc); 1160 1161 SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); 1162 CPPUNIT_ASSERT(pDoc); 1163 1164 // get two different nodes 1165 SwNodeIndex aDocEnd(pDoc->GetNodes().GetEndOfContent()); 1166 SwNodeIndex aDocStart(*aDocEnd.GetNode().StartOfSectionNode(), 3); 1167 1168 // check protected area 1169 SwPaM aPaMPortected(aDocStart); 1170 CPPUNIT_ASSERT(aPaMPortected.HasReadonlySel(false)); 1171 1172 // check unprotected area 1173 SwPaM aPaMUnprotected(aDocEnd); 1174 CPPUNIT_ASSERT(!aPaMUnprotected.HasReadonlySel(false)); 1175 } 1176 1177 DECLARE_OOXMLEXPORT_TEST(testSectionHeader, "sectionprot.odt") 1178 { 1179 CPPUNIT_ASSERT_EQUAL(1, getPages()); 1180 if (xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml")) 1181 { 1182 // this test must not be zero 1183 assertXPath(pXmlDoc, "//w:headerReference", 2); 1184 } 1185 } 1186 1187 DECLARE_OOXMLEXPORT_TEST(testOO47778_1, "ooo47778-3.odt") 1188 { 1189 CPPUNIT_ASSERT_EQUAL(5, getShapes()); 1190 CPPUNIT_ASSERT_EQUAL(1, getPages()); 1191 if (xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml")) 1192 assertXPathContent(pXmlDoc, "(//w:t)[3]", "c"); 1193 } 1194 1195 DECLARE_OOXMLEXPORT_TEST(testOO47778_2, "ooo47778-4.odt") 1196 { 1197 CPPUNIT_ASSERT_EQUAL(1, getShapes()); 1198 CPPUNIT_ASSERT_EQUAL(1, getPages()); 1199 if (xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml")) 1200 assertXPathContent(pXmlDoc, "(//w:t)[4]", "c"); 1201 1202 // tdf116436: The problem was that the table background was undefined, not white. 1203 uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); 1204 uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); 1205 uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY); 1206 uno::Reference<table::XCell> xCell = xTable->getCellByName("A1"); 1207 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffffff), getProperty<sal_Int32>(xCell, "BackColor")); 1208 } 1209 1210 DECLARE_OOXMLEXPORT_TEST(testOO67471, "ooo67471-2.odt") 1211 { 1212 CPPUNIT_ASSERT_EQUAL(1, getPages()); 1213 if (xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml")) 1214 assertXPathContent(pXmlDoc, "(//w:t)[2]", "B"); 1215 } 1216 1217 DECLARE_OOXMLEXPORT_TEST(testKDE302504, "kde302504-1.odt") 1218 { 1219 CPPUNIT_ASSERT_EQUAL(1, getShapes()); 1220 CPPUNIT_ASSERT_EQUAL(1, getPages()); 1221 if (xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml")) 1222 assertXPath(pXmlDoc, "//v:shape", "ID", "KoPathShape"); 1223 } 1224 1225 DECLARE_OOXMLEXPORT_TEST(testKDE216114, "kde216114-1.odt") 1226 { 1227 CPPUNIT_ASSERT_EQUAL(1, getShapes()); 1228 CPPUNIT_ASSERT_EQUAL(1, getPages()); 1229 if (xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml")) 1230 assertXPath(pXmlDoc, "//w:pict", 1); 1231 } 1232 1233 DECLARE_OOXMLEXPORT_TEST(testOO72950, "ooo72950-1.odt") 1234 { 1235 CPPUNIT_ASSERT_EQUAL(1, getPages()); 1236 if (xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml")) 1237 assertXPath(pXmlDoc, "//w:tbl", 1); 1238 } 1239 1240 //There are two tables to export in this doc the second of which is inside a 1241 //frame anchored to first cell of the first table. They must not be 1242 //considered the same table 1243 DECLARE_OOXMLEXPORT_TEST(fdo60957, "fdo60957-2.docx") 1244 { 1245 if (xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml")) 1246 assertXPath(pXmlDoc, "//w:tbl", 2); 1247 } 1248 1249 //This has more cells than msword supports, we must balance the 1250 //number of cell start and ends 1251 DECLARE_OOXMLEXPORT_TEST(testOO106020, "ooo106020-1.odt") 1252 { 1253 if (xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml")) 1254 assertXPath(pXmlDoc, "//w:tbl", 1); 1255 } 1256 1257 DECLARE_OOXMLEXPORT_TEST(testNonBMPChar, "nonbmpchar.docx") 1258 { 1259 sal_uInt32 nCh = 0x24b62; 1260 OUString aExpected( &nCh, 1); 1261 // Assert that UTF8 encoded non-BMP Unicode character is correct 1262 uno::Reference<text::XTextRange> xTextRange1 = getRun(getParagraph(1), 1); 1263 CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange1->getString()); 1264 } 1265 1266 DECLARE_OOXMLEXPORT_TEST(testSpacingGroupShapeText, "tdf131775_SpacingGroupShapeText.docx") 1267 { 1268 // tdf#131775: Check if correct spacing. 1269 1270 xmlDocUniquePtr pXmlDocument = parseExport("word/document.xml"); 1271 if (!pXmlDocument) 1272 return; 1273 1274 assertXPath(pXmlDocument, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor" 1275 "/a:graphic/a:graphicData/wpg:wgp/wps:wsp[1]/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/w:spacing", "val", "71"); 1276 } 1277 1278 DECLARE_OOXMLEXPORT_TEST(testTdf112287, "tdf112287.docx") 1279 { 1280 // tdf#131775: Check if correct spacing. 1281 1282 xmlDocUniquePtr pXmlDocument = parseExport("word/document.xml"); 1283 if (!pXmlDocument) 1284 return; 1285 1286 assertXPath(pXmlDocument, "/w:document/w:body/w:p[2]/w:pPr/w:framePr","vAnchor","margin"); 1287 } 1288 1289 CPPUNIT_PLUGIN_IMPLEMENT(); 1290 1291 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 1292
