include/test/xmltesttools.hxx | 4 sw/qa/core/header_footer/HeaderFooterTest.cxx | 230 +++++++++++++++----------- sw/qa/core/layout/ftnfrm.cxx | 7 sw/qa/core/layout/layout.cxx | 26 +- sw/qa/core/layout/tabfrm.cxx | 4 sw/qa/extras/README | 4 sw/qa/extras/layout/layout.cxx | 4 sw/qa/extras/layout/layout2.cxx | 52 +++-- sw/qa/extras/layout/layout3.cxx | 26 +- sw/qa/extras/odfexport/odfexport.cxx | 19 +- sw/qa/extras/odfexport/odfexport2.cxx | 5 sw/qa/extras/odfimport/odfimport.cxx | 60 +++--- sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 12 - sw/qa/extras/ooxmlexport/ooxmlexport10.cxx | 18 +- sw/qa/extras/ooxmlexport/ooxmlexport11.cxx | 8 sw/qa/extras/ooxmlexport/ooxmlexport12.cxx | 42 ++-- sw/qa/extras/ooxmlexport/ooxmlexport14.cxx | 19 +- sw/qa/extras/ooxmlexport/ooxmlexport15.cxx | 14 - sw/qa/extras/ooxmlexport/ooxmlexport16.cxx | 29 +-- sw/qa/extras/ooxmlexport/ooxmlexport18.cxx | 12 - sw/qa/extras/ooxmlexport/ooxmlexport19.cxx | 18 +- sw/qa/extras/ooxmlexport/ooxmlexport3.cxx | 3 sw/qa/extras/ooxmlexport/ooxmlexport4.cxx | 18 +- sw/qa/extras/ooxmlexport/ooxmlexport7.cxx | 53 +++-- sw/qa/extras/ooxmlexport/ooxmlexport8.cxx | 15 + sw/qa/extras/ooxmlexport/ooxmlexport9.cxx | 3 sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 21 +- sw/qa/extras/ooxmlimport/ooxmlimport2.cxx | 24 +- sw/qa/extras/rtfexport/rtfexport2.cxx | 7 sw/qa/extras/rtfexport/rtfexport3.cxx | 8 sw/qa/extras/rtfexport/rtfexport4.cxx | 58 +++--- sw/qa/extras/rtfexport/rtfexport6.cxx | 22 +- sw/qa/extras/rtfexport/rtfexport8.cxx | 31 ++- sw/qa/extras/rtfimport/rtfimport.cxx | 14 + sw/qa/extras/uiwriter/uiwriter4.cxx | 24 +- sw/qa/extras/uiwriter/uiwriter7.cxx | 11 - sw/qa/extras/ww8export/ww8export.cxx | 71 ++++---- sw/qa/extras/ww8export/ww8export2.cxx | 12 - sw/qa/extras/ww8export/ww8export3.cxx | 5 sw/qa/extras/ww8export/ww8export4.cxx | 5 sw/qa/extras/ww8import/ww8import.cxx | 8 sw/qa/inc/swmodeltestbase.hxx | 7 sw/qa/unit/swmodeltestbase.cxx | 40 ---- test/source/xmltesttools.cxx | 18 +- 44 files changed, 630 insertions(+), 461 deletions(-)
New commits: commit 3371a9b36fb455501449d6575250ff19e5ffa18b Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Mon Jul 29 20:42:44 2024 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Jul 30 13:49:32 2024 +0200 sw: get rid of parseDump So parseLayoutDump is only called once per test Change-Id: Ia199e0a7eeac26fbde94f6450d2aa49828940806 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171219 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> Tested-by: Jenkins diff --git a/include/test/xmltesttools.hxx b/include/test/xmltesttools.hxx index bf91c5b20151..aa20257ff472 100644 --- a/include/test/xmltesttools.hxx +++ b/include/test/xmltesttools.hxx @@ -104,6 +104,10 @@ protected: * Assert that rXPath exists, has exactly 1 result set nodes and does *not* have an attribute named rAttribute. */ void assertXPathNoAttribute(const xmlDocUniquePtr& pXmlDoc, const OString& rXPath, const OString& rAttribute); + /** + * Same as the assertXPathNoAttribute(), but don't assert: return the bool instead. + */ + bool hasXPathAttribute(const xmlDocUniquePtr& pXmlDoc, const OString& rXPath, const OString& rAttribute); // Assert that the node name of the single node returned by an XPath is as specified, // e.g. to check order of elements, where getXPathPosition is unapplicable void assertXPathNodeName(const xmlDocUniquePtr& pXmlDoc, const OString& rXPath, const OString& rExpectedName); diff --git a/sw/qa/core/header_footer/HeaderFooterTest.cxx b/sw/qa/core/header_footer/HeaderFooterTest.cxx index acfd77f1270e..60463965fc02 100644 --- a/sw/qa/core/header_footer/HeaderFooterTest.cxx +++ b/sw/qa/core/header_footer/HeaderFooterTest.cxx @@ -126,18 +126,31 @@ CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testHeaderFooterWithSpecialFirstPage_OOXM } // All other pages should have header/footer OUString sExpected(u"Seite * von *"_ustr); - CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[2]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[2]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[3]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[3]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[4]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[4]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[5]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[5]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[6]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[6]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[7]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[7]/footer/txt/text()"_ostr)); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + CPPUNIT_ASSERT_EQUAL(sExpected, + getXPathContent(pXmlDoc, "/root/page[2]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, + getXPathContent(pXmlDoc, "/root/page[2]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, + getXPathContent(pXmlDoc, "/root/page[3]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, + getXPathContent(pXmlDoc, "/root/page[3]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, + getXPathContent(pXmlDoc, "/root/page[4]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, + getXPathContent(pXmlDoc, "/root/page[4]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, + getXPathContent(pXmlDoc, "/root/page[5]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, + getXPathContent(pXmlDoc, "/root/page[5]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, + getXPathContent(pXmlDoc, "/root/page[6]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, + getXPathContent(pXmlDoc, "/root/page[6]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, + getXPathContent(pXmlDoc, "/root/page[7]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, + getXPathContent(pXmlDoc, "/root/page[7]/footer/txt/text()"_ostr)); } // Check for correct header/footer with special first page with TOC inside @@ -163,18 +176,31 @@ CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testHeaderFooterWithSpecialFirstPage_ODF) // All other pages should have header/footer OUString sExpected(u"Seite * von *"_ustr); - CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[2]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[2]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[3]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[3]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[4]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[4]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[5]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[5]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[6]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[6]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[7]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[7]/footer/txt/text()"_ostr)); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + CPPUNIT_ASSERT_EQUAL(sExpected, + getXPathContent(pXmlDoc, "/root/page[2]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, + getXPathContent(pXmlDoc, "/root/page[2]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, + getXPathContent(pXmlDoc, "/root/page[3]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, + getXPathContent(pXmlDoc, "/root/page[3]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, + getXPathContent(pXmlDoc, "/root/page[4]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, + getXPathContent(pXmlDoc, "/root/page[4]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, + getXPathContent(pXmlDoc, "/root/page[5]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, + getXPathContent(pXmlDoc, "/root/page[5]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, + getXPathContent(pXmlDoc, "/root/page[6]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, + getXPathContent(pXmlDoc, "/root/page[6]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, + getXPathContent(pXmlDoc, "/root/page[7]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, + getXPathContent(pXmlDoc, "/root/page[7]/footer/txt/text()"_ostr)); } CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testFloatingTableInHeader) @@ -243,14 +269,15 @@ CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testFirstPageHeadersAndEmptyFooters) // Test case where headers and footers for first page are set, but footers are empty auto verify = [this]() { + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); CPPUNIT_ASSERT_EQUAL(u"This is the FIRST page header."_ustr, - parseDump("/root/page[1]/header/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[1]/header/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"This is the header for the REST OF THE FILE."_ustr, - parseDump("/root/page[2]/header/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[2]/header/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"This is the header for the REST OF THE FILE."_ustr, - parseDump("/root/page[3]/header/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[3]/header/txt/text()"_ostr)); }; createSwDoc("fdo66145.docx"); @@ -268,30 +295,31 @@ CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testFirstHeaderFooterImport) // The document has 6 pages. Note that we don't test if 4 or just 2 page // styles are created, the point is that layout should be correct. + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); CPPUNIT_ASSERT_EQUAL(u"First page header"_ustr, - parseDump("/root/page[1]/header/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[1]/header/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"First page footer"_ustr, - parseDump("/root/page[1]/footer/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[1]/footer/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"Even page header"_ustr, - parseDump("/root/page[2]/header/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[2]/header/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"Even page footer"_ustr, - parseDump("/root/page[2]/footer/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[2]/footer/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"Odd page header"_ustr, - parseDump("/root/page[3]/header/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[3]/header/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"Odd page footer"_ustr, - parseDump("/root/page[3]/footer/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[3]/footer/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"First page header2"_ustr, - parseDump("/root/page[4]/header/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[4]/header/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"First page footer 2"_ustr, - parseDump("/root/page[4]/footer/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[4]/footer/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"Odd page header 2"_ustr, - parseDump("/root/page[5]/header/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[5]/header/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"Odd page footer 2"_ustr, - parseDump("/root/page[5]/footer/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[5]/footer/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"Even page header 2"_ustr, - parseDump("/root/page[6]/header/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[6]/header/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"Even page footer 2"_ustr, - parseDump("/root/page[6]/footer/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[6]/footer/txt/text()"_ostr)); }; createSwDoc("first-header-footer.docx"); @@ -307,30 +335,31 @@ CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testFirstHeaderFooterRoundTrip) CPPUNIT_ASSERT_EQUAL(6, getPages()); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); CPPUNIT_ASSERT_EQUAL(u"First page header"_ustr, - parseDump("/root/page[1]/header/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[1]/header/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"First page footer"_ustr, - parseDump("/root/page[1]/footer/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[1]/footer/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"Even page header"_ustr, - parseDump("/root/page[2]/header/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[2]/header/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"Even page footer"_ustr, - parseDump("/root/page[2]/footer/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[2]/footer/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"Odd page header"_ustr, - parseDump("/root/page[3]/header/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[3]/header/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"Odd page footer"_ustr, - parseDump("/root/page[3]/footer/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[3]/footer/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"First page header2"_ustr, - parseDump("/root/page[4]/header/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[4]/header/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"First page footer 2"_ustr, - parseDump("/root/page[4]/footer/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[4]/footer/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"Odd page header 2"_ustr, - parseDump("/root/page[5]/header/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[5]/header/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"Odd page footer 2"_ustr, - parseDump("/root/page[5]/footer/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[5]/footer/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"Even page header 2"_ustr, - parseDump("/root/page[6]/header/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[6]/header/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"Even page footer 2"_ustr, - parseDump("/root/page[6]/footer/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[6]/footer/txt/text()"_ostr)); } CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testFirstHeaderFooter_ODF) @@ -342,18 +371,31 @@ CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testFirstHeaderFooter_ODF) // Test import and export of the header-first token. // The document has 6 pages, two page styles for the first and second half of pages. - CPPUNIT_ASSERT_EQUAL(u"First header"_ustr, parseDump("/root/page[1]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(u"First footer"_ustr, parseDump("/root/page[1]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(u"Left header"_ustr, parseDump("/root/page[2]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(u"Left footer"_ustr, parseDump("/root/page[2]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(u"Right header"_ustr, parseDump("/root/page[3]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(u"Right footer"_ustr, parseDump("/root/page[3]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(u"First header2"_ustr, parseDump("/root/page[4]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(u"First footer2"_ustr, parseDump("/root/page[4]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(u"Right header2"_ustr, parseDump("/root/page[5]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(u"Right footer2"_ustr, parseDump("/root/page[5]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(u"Left header2"_ustr, parseDump("/root/page[6]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(u"Left footer2"_ustr, parseDump("/root/page[6]/footer/txt/text()"_ostr)); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + CPPUNIT_ASSERT_EQUAL(u"First header"_ustr, + getXPathContent(pXmlDoc, "/root/page[1]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(u"First footer"_ustr, + getXPathContent(pXmlDoc, "/root/page[1]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(u"Left header"_ustr, + getXPathContent(pXmlDoc, "/root/page[2]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(u"Left footer"_ustr, + getXPathContent(pXmlDoc, "/root/page[2]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(u"Right header"_ustr, + getXPathContent(pXmlDoc, "/root/page[3]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(u"Right footer"_ustr, + getXPathContent(pXmlDoc, "/root/page[3]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(u"First header2"_ustr, + getXPathContent(pXmlDoc, "/root/page[4]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(u"First footer2"_ustr, + getXPathContent(pXmlDoc, "/root/page[4]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(u"Right header2"_ustr, + getXPathContent(pXmlDoc, "/root/page[5]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(u"Right footer2"_ustr, + getXPathContent(pXmlDoc, "/root/page[5]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(u"Left header2"_ustr, + getXPathContent(pXmlDoc, "/root/page[6]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(u"Left footer2"_ustr, + getXPathContent(pXmlDoc, "/root/page[6]/footer/txt/text()"_ostr)); } CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testFirstHeaderFooter_DOC) @@ -365,30 +407,31 @@ CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testFirstHeaderFooter_DOC) // The document has 6 pages. Note that we don't test if 4 or just 2 page // styles are created, the point is that layout should be correct. + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); CPPUNIT_ASSERT_EQUAL(u"First page header"_ustr, - parseDump("/root/page[1]/header/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[1]/header/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"First page footer"_ustr, - parseDump("/root/page[1]/footer/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[1]/footer/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"Even page header"_ustr, - parseDump("/root/page[2]/header/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[2]/header/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"Even page footer"_ustr, - parseDump("/root/page[2]/footer/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[2]/footer/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"Odd page header"_ustr, - parseDump("/root/page[3]/header/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[3]/header/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"Odd page footer"_ustr, - parseDump("/root/page[3]/footer/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[3]/footer/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"First page header2"_ustr, - parseDump("/root/page[4]/header/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[4]/header/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"First page footer 2"_ustr, - parseDump("/root/page[4]/footer/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[4]/footer/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"Odd page header 2"_ustr, - parseDump("/root/page[5]/header/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[5]/header/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"Odd page footer 2"_ustr, - parseDump("/root/page[5]/footer/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[5]/footer/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"Even page header 2"_ustr, - parseDump("/root/page[6]/header/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[6]/header/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"Even page footer 2"_ustr, - parseDump("/root/page[6]/footer/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[6]/footer/txt/text()"_ostr)); } CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testFdo65655) @@ -469,23 +512,24 @@ CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testContSectBreakHeaderFooter) { auto verify = [this]() { // Load a document with a continuous section break on page 2. + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); CPPUNIT_ASSERT_EQUAL(u"First page header, section 1"_ustr, - parseDump("/root/page[1]/header/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[1]/header/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"First page footer, section 1"_ustr, - parseDump("/root/page[1]/footer/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[1]/footer/txt/text()"_ostr)); // Make sure the header stays like this; if we naively just update the page style name of the // first para on page 2, then this would be 'Header, section 2', which is incorrect. CPPUNIT_ASSERT_EQUAL(u"First page header, section 2"_ustr, - parseDump("/root/page[2]/header/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[2]/header/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"First page footer, section 2"_ustr, - parseDump("/root/page[2]/footer/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[2]/footer/txt/text()"_ostr)); // This is inherited from page 2. CPPUNIT_ASSERT_EQUAL(u"Header, section 2"_ustr, - parseDump("/root/page[3]/header/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[3]/header/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"Footer, section 3"_ustr, - parseDump("/root/page[3]/footer/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[3]/footer/txt/text()"_ostr)); // Without the export fix in place, the import-export-import test would have failed with: // - Expected: Header, section 2 @@ -519,10 +563,13 @@ CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testTdf145998_firstHeader) // Sanity check - always good to test when dealing with page styles and breaks. CPPUNIT_ASSERT_EQUAL(2, getPages()); - CPPUNIT_ASSERT_EQUAL(u"Very first header"_ustr, parseDump("/root/page[1]/header/txt"_ostr)); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + CPPUNIT_ASSERT_EQUAL(u"Very first header"_ustr, + getXPathContent(pXmlDoc, "/root/page[1]/header/txt"_ostr)); // Page Style is already used in prior section - this can't be the first-header - CPPUNIT_ASSERT_EQUAL(u"Normal Header"_ustr, parseDump("/root/page[2]/header/txt"_ostr)); + CPPUNIT_ASSERT_EQUAL(u"Normal Header"_ustr, + getXPathContent(pXmlDoc, "/root/page[2]/header/txt"_ostr)); } CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testEvenPageOddPageFooter_Import) @@ -628,24 +675,25 @@ CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testTdf113849_evenAndOddHeaders) createSwDoc("tdf113849_evenAndOddHeaders.odt"); saveAndReload(u"Office Open XML Text"_ustr); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); CPPUNIT_ASSERT_EQUAL_MESSAGE("Header2 text", u"L. J. Kendall"_ustr, - parseDump("/root/page[2]/header/txt"_ostr)); + getXPathContent(pXmlDoc, "/root/page[2]/header/txt"_ostr)); CPPUNIT_ASSERT_EQUAL_MESSAGE("Footer2 text", u"*"_ustr, - parseDump("/root/page[2]/footer/txt"_ostr)); + getXPathContent(pXmlDoc, "/root/page[2]/footer/txt"_ostr)); CPPUNIT_ASSERT_EQUAL_MESSAGE("Header3 text", u"Shadow Hunt"_ustr, - parseDump("/root/page[3]/header/txt"_ostr)); + getXPathContent(pXmlDoc, "/root/page[3]/header/txt"_ostr)); CPPUNIT_ASSERT_EQUAL_MESSAGE("Footer3 text", u"*"_ustr, - parseDump("/root/page[3]/footer/txt"_ostr)); + getXPathContent(pXmlDoc, "/root/page[3]/footer/txt"_ostr)); CPPUNIT_ASSERT_EQUAL_MESSAGE("Header4 text", u"L. J. Kendall"_ustr, - parseDump("/root/page[4]/header/txt"_ostr)); + getXPathContent(pXmlDoc, "/root/page[4]/header/txt"_ostr)); CPPUNIT_ASSERT_EQUAL_MESSAGE("Footer4 text", u"*"_ustr, - parseDump("/root/page[4]/footer/txt"_ostr)); + getXPathContent(pXmlDoc, "/root/page[4]/footer/txt"_ostr)); CPPUNIT_ASSERT_EQUAL_MESSAGE("Footer5 text", u""_ustr, - parseDump("/root/page[5]/footer/txt"_ostr)); + getXPathContent(pXmlDoc, "/root/page[5]/footer/txt"_ostr)); CPPUNIT_ASSERT_EQUAL_MESSAGE("Footer6 text", u""_ustr, - parseDump("/root/page[6]/footer/txt"_ostr)); + getXPathContent(pXmlDoc, "/root/page[6]/footer/txt"_ostr)); CPPUNIT_ASSERT_EQUAL_MESSAGE("Number of pages", 6, getPages()); } diff --git a/sw/qa/core/layout/ftnfrm.cxx b/sw/qa/core/layout/ftnfrm.cxx index ef72fda00516..3023ff71c9ff 100644 --- a/sw/qa/core/layout/ftnfrm.cxx +++ b/sw/qa/core/layout/ftnfrm.cxx @@ -78,10 +78,11 @@ CPPUNIT_TEST_FIXTURE(Test, testInlineEndnoteAndFootnote) // - xpath should match exactly 1 node // i.e. the endnote was also in the footnote container, not at the end of the body text. sal_Int32 nEndnoteTop - = parseDump("/root/page/body/section/column/ftncont/ftn/infos/bounds"_ostr, "top"_ostr) + = getXPath(pXmlDoc, "/root/page/body/section/column/ftncont/ftn/infos/bounds"_ostr, + "top"_ostr) .toInt32(); sal_Int32 nFootnoteTop - = parseDump("/root/page/ftncont/ftn/infos/bounds"_ostr, "top"_ostr).toInt32(); + = getXPath(pXmlDoc, "/root/page/ftncont/ftn/infos/bounds"_ostr, "top"_ostr).toInt32(); // Endnote at the end of body text, footnote at page bottom. CPPUNIT_ASSERT_LESS(nFootnoteTop, nEndnoteTop); } @@ -115,7 +116,7 @@ CPPUNIT_TEST_FIXTURE(Test, testInlineEndnotePosition) // Then make sure the endnote separator (line + spacing around it) is large enough, so the // endnote text below the separator has the correct position: sal_Int32 nEndnoteContTopMargin - = parseDump("//column/ftncont/infos/prtBounds"_ostr, "top"_ostr).toInt32(); + = getXPath(pXmlDoc, "//column/ftncont/infos/prtBounds"_ostr, "top"_ostr).toInt32(); // Without the accompanying fix in place, this test would have failed with: // - Expected: 269 // - Actual : 124 diff --git a/sw/qa/core/layout/layout.cxx b/sw/qa/core/layout/layout.cxx index 9b27151a976f..5ce929b27591 100644 --- a/sw/qa/core/layout/layout.cxx +++ b/sw/qa/core/layout/layout.cxx @@ -54,13 +54,14 @@ CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testTableFlyOverlap) // Load a document that has an image anchored in the header. // It also has a table which has the wrap around the image. createSwDoc("table-fly-overlap.docx"); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); SwTwips nFlyTop - = parseDump("//header/txt/anchored/fly/infos/bounds"_ostr, "top"_ostr).toInt32(); + = getXPath(pXmlDoc, "//header/txt/anchored/fly/infos/bounds"_ostr, "top"_ostr).toInt32(); SwTwips nFlyHeight - = parseDump("//header/txt/anchored/fly/infos/bounds"_ostr, "height"_ostr).toInt32(); + = getXPath(pXmlDoc, "//header/txt/anchored/fly/infos/bounds"_ostr, "height"_ostr).toInt32(); SwTwips nFlyBottom = nFlyTop + nFlyHeight; - SwTwips nTableFrameTop = parseDump("//tab/infos/bounds"_ostr, "top"_ostr).toInt32(); - SwTwips nTablePrintTop = parseDump("//tab/infos/prtBounds"_ostr, "top"_ostr).toInt32(); + SwTwips nTableFrameTop = getXPath(pXmlDoc, "//tab/infos/bounds"_ostr, "top"_ostr).toInt32(); + SwTwips nTablePrintTop = getXPath(pXmlDoc, "//tab/infos/prtBounds"_ostr, "top"_ostr).toInt32(); SwTwips nTableTop = nTableFrameTop + nTablePrintTop; // Without the accompanying fix in place, this test would have failed with: // - Expected greater or equal than: 3579 @@ -75,8 +76,11 @@ CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testTdf128195) // Load a document that has two paragraphs in the header. // The second paragraph should have its bottom spacing applied. createSwDoc("tdf128195.docx"); - sal_Int32 nTxtHeight = parseDump("//header/txt[2]/infos/bounds"_ostr, "height"_ostr).toInt32(); - sal_Int32 nTxtBottom = parseDump("//header/txt[2]/infos/bounds"_ostr, "bottom"_ostr).toInt32(); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + sal_Int32 nTxtHeight + = getXPath(pXmlDoc, "//header/txt[2]/infos/bounds"_ostr, "height"_ostr).toInt32(); + sal_Int32 nTxtBottom + = getXPath(pXmlDoc, "//header/txt[2]/infos/bounds"_ostr, "bottom"_ostr).toInt32(); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2269), nTxtHeight); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3529), nTxtBottom); } @@ -129,12 +133,14 @@ CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testTableFlyOverlapSpacing) { // Load a document that has an image on the right of a table. The table wraps around the image. createSwDoc("table-fly-overlap-spacing.docx"); - SwTwips nFlyTop = parseDump("//body/txt/anchored/fly/infos/bounds"_ostr, "top"_ostr).toInt32(); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + SwTwips nFlyTop + = getXPath(pXmlDoc, "//body/txt/anchored/fly/infos/bounds"_ostr, "top"_ostr).toInt32(); SwTwips nFlyHeight - = parseDump("//body/txt/anchored/fly/infos/bounds"_ostr, "height"_ostr).toInt32(); + = getXPath(pXmlDoc, "//body/txt/anchored/fly/infos/bounds"_ostr, "height"_ostr).toInt32(); SwTwips nFlyBottom = nFlyTop + nFlyHeight; - SwTwips nTableFrameTop = parseDump("//tab/infos/bounds"_ostr, "top"_ostr).toInt32(); - SwTwips nTablePrintTop = parseDump("//tab/infos/prtBounds"_ostr, "top"_ostr).toInt32(); + SwTwips nTableFrameTop = getXPath(pXmlDoc, "//tab/infos/bounds"_ostr, "top"_ostr).toInt32(); + SwTwips nTablePrintTop = getXPath(pXmlDoc, "//tab/infos/prtBounds"_ostr, "top"_ostr).toInt32(); SwTwips nTableTop = nTableFrameTop + nTablePrintTop; // Without the accompanying fix in place, this test would have failed with: // - Expected greater or equal than: 3993 diff --git a/sw/qa/core/layout/tabfrm.cxx b/sw/qa/core/layout/tabfrm.cxx index cc60c3cd4bc5..276304623f72 100644 --- a/sw/qa/core/layout/tabfrm.cxx +++ b/sw/qa/core/layout/tabfrm.cxx @@ -36,9 +36,11 @@ CPPUNIT_TEST_FIXTURE(Test, testTablePrintAreaLeft) { // Given a document with a header containing an image, and also with an overlapping table: createSwDoc("table-print-area-left.docx"); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); // When laying out that document & parsing the left margin of the table: - SwTwips nTablePrintLeft = parseDump("//tab/infos/prtBounds"_ostr, "left"_ostr).toInt32(); + SwTwips nTablePrintLeft + = getXPath(pXmlDoc, "//tab/infos/prtBounds"_ostr, "left"_ostr).toInt32(); // Then make sure it has ~no left margin: // Without the accompanying fix in place, this test would have failed with: diff --git a/sw/qa/extras/README b/sw/qa/extras/README index 66bca01e63a0..2e5df81d4751 100644 --- a/sw/qa/extras/README +++ b/sw/qa/extras/README @@ -19,8 +19,8 @@ See below for more details on writing the UNO code see below. === Direct XPath assertions on the layout dump In most cases you want to assert the document model, but sometimes asserting -the layout is easier. If you want to do so, the `parseDump()` method can be -used to parse the layout dump of the currently loaded document. If you want +the layout is easier. If you want to do so, check the methods in +test/source/xmltesttools.cxx. If you want to have a look at the XML document that can be asserted, start soffice with the `SW_DEBUG=1` environment variable, load a document, press F12, and have a look at the `layout.xml` file in the current directory. Once you find the needed diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index 523bbbd478b5..9fe696ee838d 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -2176,7 +2176,9 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf116486) createSwDoc("tdf116486.docx"); SwDoc* pDoc = getSwDoc(); CPPUNIT_ASSERT(pDoc); - OUString aTop = parseDump( + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + OUString aTop = getXPath( + pXmlDoc, "/root/page/body/txt/SwParaPortion/SwLineLayout[1]/child::*[@type='PortionType::Fly']"_ostr, "height"_ostr); CPPUNIT_ASSERT_EQUAL(u"4006"_ustr, aTop); diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx index fcda464b6928..8226c5100c78 100644 --- a/sw/qa/extras/layout/layout2.cxx +++ b/sw/qa/extras/layout/layout2.cxx @@ -2456,20 +2456,23 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf150200) createSwDoc("tdf150200.odt"); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); // dash - OUString sFirstLine - = parseDump("/root/page/body/txt[1]/SwParaPortion/SwLineLayout[1]/@portion"_ostr); + OUString sFirstLine = getXPathContent( + pXmlDoc, "/root/page/body/txt[1]/SwParaPortion/SwLineLayout[1]/@portion"_ostr); CPPUNIT_ASSERT_EQUAL(true, sFirstLine.startsWith(u"-(dash)")); CPPUNIT_ASSERT_EQUAL(sal_Int32(93), sFirstLine.getLength()); // en-dash - sFirstLine = parseDump("/root/page/body/txt[2]/SwParaPortion/SwLineLayout[1]/@portion"_ostr); + sFirstLine = getXPathContent( + pXmlDoc, "/root/page/body/txt[2]/SwParaPortion/SwLineLayout[1]/@portion"_ostr); CPPUNIT_ASSERT_EQUAL(true, sFirstLine.startsWith(u"–(en-dash)")); CPPUNIT_ASSERT_EQUAL(sal_Int32(88), sFirstLine.getLength()); // em-dash - sFirstLine = parseDump("/root/page/body/txt[3]/SwParaPortion/SwLineLayout[1]/@portion"_ostr); + sFirstLine = getXPathContent( + pXmlDoc, "/root/page/body/txt[3]/SwParaPortion/SwLineLayout[1]/@portion"_ostr); CPPUNIT_ASSERT_EQUAL(true, sFirstLine.startsWith(u"—(em-dash)")); CPPUNIT_ASSERT_EQUAL(sal_Int32(77), sFirstLine.getLength()); // figure dash - sFirstLine = parseDump("/root/page/body/txt[4]/SwParaPortion/SwLineLayout[1]/@portion"_ostr); + sFirstLine = getXPathContent( + pXmlDoc, "/root/page/body/txt[4]/SwParaPortion/SwLineLayout[1]/@portion"_ostr); CPPUNIT_ASSERT_EQUAL(true, sFirstLine.startsWith(u"‒(figure dash)")); CPPUNIT_ASSERT_EQUAL(sal_Int32(87), sFirstLine.getLength()); } @@ -2479,20 +2482,23 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf150200_DOCX) createSwDoc("tdf150200.docx"); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); // dash - OUString sFirstLine - = parseDump("/root/page/body/txt[1]/SwParaPortion/SwLineLayout[1]/@portion"_ostr); + OUString sFirstLine = getXPathContent( + pXmlDoc, "/root/page/body/txt[1]/SwParaPortion/SwLineLayout[1]/@portion"_ostr); CPPUNIT_ASSERT_EQUAL(true, sFirstLine.startsWith(u"-(dash)")); CPPUNIT_ASSERT_EQUAL(sal_Int32(93), sFirstLine.getLength()); // en-dash - sFirstLine = parseDump("/root/page/body/txt[2]/SwParaPortion/SwLineLayout[1]/@portion"_ostr); + sFirstLine = getXPathContent( + pXmlDoc, "/root/page/body/txt[2]/SwParaPortion/SwLineLayout[1]/@portion"_ostr); CPPUNIT_ASSERT_EQUAL(true, sFirstLine.startsWith(u"–(en-dash)")); CPPUNIT_ASSERT_EQUAL(sal_Int32(88), sFirstLine.getLength()); // em-dash - sFirstLine = parseDump("/root/page/body/txt[3]/SwParaPortion/SwLineLayout[1]/@portion"_ostr); + sFirstLine = getXPathContent( + pXmlDoc, "/root/page/body/txt[3]/SwParaPortion/SwLineLayout[1]/@portion"_ostr); CPPUNIT_ASSERT_EQUAL(true, sFirstLine.startsWith(u"—(em-dash)")); CPPUNIT_ASSERT_EQUAL(sal_Int32(77), sFirstLine.getLength()); // figure dash - sFirstLine = parseDump("/root/page/body/txt[4]/SwParaPortion/SwLineLayout[1]/@portion"_ostr); + sFirstLine = getXPathContent( + pXmlDoc, "/root/page/body/txt[4]/SwParaPortion/SwLineLayout[1]/@portion"_ostr); CPPUNIT_ASSERT_EQUAL(true, sFirstLine.startsWith(u"‒(figure dash)")); CPPUNIT_ASSERT_EQUAL(sal_Int32(87), sFirstLine.getLength()); } @@ -2502,20 +2508,23 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf150438) createSwDoc("tdf150438.odt"); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); // left double quotation mark - OUString sFirstLine - = parseDump("/root/page/body/txt[1]/SwParaPortion/SwLineLayout[1]/@portion"_ostr); + OUString sFirstLine = getXPathContent( + pXmlDoc, "/root/page/body/txt[1]/SwParaPortion/SwLineLayout[1]/@portion"_ostr); CPPUNIT_ASSERT_EQUAL(true, sFirstLine.startsWith(u"“Lorem ipsum")); CPPUNIT_ASSERT_EQUAL(sal_Int32(92), sFirstLine.getLength()); // right double quotation mark - sFirstLine = parseDump("/root/page/body/txt[2]/SwParaPortion/SwLineLayout[1]/@portion"_ostr); + sFirstLine = getXPathContent( + pXmlDoc, "/root/page/body/txt[2]/SwParaPortion/SwLineLayout[1]/@portion"_ostr); CPPUNIT_ASSERT_EQUAL(true, sFirstLine.startsWith(u"”Nunc viverra imperdiet enim.")); CPPUNIT_ASSERT_EQUAL(sal_Int32(97), sFirstLine.getLength()); // left single quotation mark - sFirstLine = parseDump("/root/page/body/txt[3]/SwParaPortion/SwLineLayout[1]/@portion"_ostr); + sFirstLine = getXPathContent( + pXmlDoc, "/root/page/body/txt[3]/SwParaPortion/SwLineLayout[1]/@portion"_ostr); CPPUNIT_ASSERT_EQUAL(true, sFirstLine.startsWith(u"‘Aenean nec lorem.")); CPPUNIT_ASSERT_EQUAL(sal_Int32(85), sFirstLine.getLength()); // right single quotation mark or apostrophe - sFirstLine = parseDump("/root/page/body/txt[4]/SwParaPortion/SwLineLayout[1]/@portion"_ostr); + sFirstLine = getXPathContent( + pXmlDoc, "/root/page/body/txt[4]/SwParaPortion/SwLineLayout[1]/@portion"_ostr); CPPUNIT_ASSERT_EQUAL(true, sFirstLine.startsWith(u"’Aenean nec lorem.")); CPPUNIT_ASSERT_EQUAL(sal_Int32(85), sFirstLine.getLength()); } @@ -2525,20 +2534,23 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf150438_DOCX) createSwDoc("tdf150438.docx"); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); // left double quotation mark - OUString sFirstLine - = parseDump("/root/page/body/txt[1]/SwParaPortion/SwLineLayout[1]/@portion"_ostr); + OUString sFirstLine = getXPathContent( + pXmlDoc, "/root/page/body/txt[1]/SwParaPortion/SwLineLayout[1]/@portion"_ostr); CPPUNIT_ASSERT_EQUAL(true, sFirstLine.startsWith(u"“Lorem ipsum")); CPPUNIT_ASSERT_EQUAL(sal_Int32(92), sFirstLine.getLength()); // right double quotation mark - sFirstLine = parseDump("/root/page/body/txt[2]/SwParaPortion/SwLineLayout[1]/@portion"_ostr); + sFirstLine = getXPathContent( + pXmlDoc, "/root/page/body/txt[2]/SwParaPortion/SwLineLayout[1]/@portion"_ostr); CPPUNIT_ASSERT_EQUAL(true, sFirstLine.startsWith(u"”Nunc viverra imperdiet enim.")); CPPUNIT_ASSERT_EQUAL(sal_Int32(97), sFirstLine.getLength()); // left single quotation mark - sFirstLine = parseDump("/root/page/body/txt[3]/SwParaPortion/SwLineLayout[1]/@portion"_ostr); + sFirstLine = getXPathContent( + pXmlDoc, "/root/page/body/txt[3]/SwParaPortion/SwLineLayout[1]/@portion"_ostr); CPPUNIT_ASSERT_EQUAL(true, sFirstLine.startsWith(u"‘Aenean nec lorem.")); CPPUNIT_ASSERT_EQUAL(sal_Int32(85), sFirstLine.getLength()); // right single quotation mark or apostrophe - sFirstLine = parseDump("/root/page/body/txt[4]/SwParaPortion/SwLineLayout[1]/@portion"_ostr); + sFirstLine = getXPathContent( + pXmlDoc, "/root/page/body/txt[4]/SwParaPortion/SwLineLayout[1]/@portion"_ostr); CPPUNIT_ASSERT_EQUAL(true, sFirstLine.startsWith(u"’Aenean nec lorem.")); CPPUNIT_ASSERT_EQUAL(sal_Int32(85), sFirstLine.getLength()); } diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx index 3e936abffc38..27beac4cfdb2 100644 --- a/sw/qa/extras/layout/layout3.cxx +++ b/sw/qa/extras/layout/layout3.cxx @@ -1151,8 +1151,10 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf118719) // Without the accompanying fix in place, this test would have failed, as the height of the // first page was 15840 twips, instead of the much smaller 276. - sal_Int32 nOther = parseDump("/root/page[1]/infos/bounds"_ostr, "height"_ostr).toInt32(); - sal_Int32 nLast = parseDump("/root/page[2]/infos/bounds"_ostr, "height"_ostr).toInt32(); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + sal_Int32 nOther + = getXPath(pXmlDoc, "/root/page[1]/infos/bounds"_ostr, "height"_ostr).toInt32(); + sal_Int32 nLast = getXPath(pXmlDoc, "/root/page[2]/infos/bounds"_ostr, "height"_ostr).toInt32(); CPPUNIT_ASSERT_GREATER(nOther, nLast); } @@ -2068,22 +2070,26 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf134548) // Second paragraph has two non zero width tabs in beginning of line { - OUString sNodeType = parseDump( - "/root/page/body/txt[2]/SwParaPortion/SwLineLayout/SwFixPortion[1]"_ostr, "type"_ostr); + OUString sNodeType = getXPath( + pXmlDoc, "/root/page/body/txt[2]/SwParaPortion/SwLineLayout/SwFixPortion[1]"_ostr, + "type"_ostr); CPPUNIT_ASSERT_EQUAL(u"PortionType::TabLeft"_ustr, sNodeType); sal_Int32 nWidth - = parseDump("/root/page/body/txt[2]/SwParaPortion/SwLineLayout/SwFixPortion[1]"_ostr, - "width"_ostr) + = getXPath(pXmlDoc, + "/root/page/body/txt[2]/SwParaPortion/SwLineLayout/SwFixPortion[1]"_ostr, + "width"_ostr) .toInt32(); CPPUNIT_ASSERT_GREATER(sal_Int32(0), nWidth); } { - OUString sNodeType = parseDump( - "/root/page/body/txt[2]/SwParaPortion/SwLineLayout/SwFixPortion[2]"_ostr, "type"_ostr); + OUString sNodeType = getXPath( + pXmlDoc, "/root/page/body/txt[2]/SwParaPortion/SwLineLayout/SwFixPortion[2]"_ostr, + "type"_ostr); CPPUNIT_ASSERT_EQUAL(u"PortionType::TabLeft"_ustr, sNodeType); sal_Int32 nWidth - = parseDump("/root/page/body/txt[2]/SwParaPortion/SwLineLayout/SwFixPortion[2]"_ostr, - "width"_ostr) + = getXPath(pXmlDoc, + "/root/page/body/txt[2]/SwParaPortion/SwLineLayout/SwFixPortion[2]"_ostr, + "width"_ostr) .toInt32(); CPPUNIT_ASSERT_GREATER(sal_Int32(0), nWidth); } diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index 7dfe52381293..67c1d7859d04 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -1331,7 +1331,8 @@ DECLARE_ODFEXPORT_TEST(testRelhPage, "relh-page.odt") CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME, getProperty<sal_Int16>(xTextFrame, u"RelativeWidthRelation"_ustr)); // This was 2601, 20% height was relative from margin, not page. - CPPUNIT_ASSERT_EQUAL(sal_Int32(3168), parseDump("/root/page/body/txt/anchored/fly/infos/bounds"_ostr, "height"_ostr).toInt32()); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3168), getXPath(pXmlDoc, "/root/page/body/txt/anchored/fly/infos/bounds"_ostr, "height"_ostr).toInt32()); } DECLARE_ODFEXPORT_TEST(testRelhPageTdf80282, "relh-page-tdf80282.odt") @@ -1339,8 +1340,9 @@ DECLARE_ODFEXPORT_TEST(testRelhPageTdf80282, "relh-page-tdf80282.odt") CPPUNIT_ASSERT_EQUAL(1, getShapes()); CPPUNIT_ASSERT_EQUAL(1, getPages()); uno::Reference<drawing::XShape> xTextFrame = getShape(1); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Height", sal_Int32(8391), parseDump("//anchored/fly/infos/bounds"_ostr, "height"_ostr).toInt32()); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Width", sal_Int32(5953), parseDump("//anchored/fly/infos/bounds"_ostr, "width"_ostr).toInt32()); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + assertXPath(pXmlDoc, "//anchored/fly/infos/bounds"_ostr, "height"_ostr, u"8391"_ustr); + assertXPath(pXmlDoc, "//anchored/fly/infos/bounds"_ostr, "width"_ostr, u"5953"_ustr); } DECLARE_ODFEXPORT_TEST(testRelwPage, "relw-page.odt") @@ -1354,7 +1356,8 @@ DECLARE_ODFEXPORT_TEST(testRelwPage, "relw-page.odt") CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME, getProperty<sal_Int16>(xTextFrame, u"RelativeHeightRelation"_ustr)); // This was 3762, 40% width was relative from margin, not page. - CPPUNIT_ASSERT_EQUAL(sal_Int32(4896), parseDump("/root/page/body/txt/anchored/fly/infos/bounds"_ostr, "width"_ostr).toInt32()); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4896), getXPath(pXmlDoc, "/root/page/body/txt/anchored/fly/infos/bounds"_ostr, "width"_ostr).toInt32()); } DECLARE_ODFEXPORT_TEST(testTextFrameVertAdjust, "textframe-vertadjust.odt") @@ -1750,15 +1753,16 @@ DECLARE_ODFEXPORT_TEST(testWhitespace, "whitespace.odt") DECLARE_ODFEXPORT_TEST(testTdf136645, "tdf136645.odt") { CPPUNIT_ASSERT_EQUAL(1, getPages()); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); // Without the fix in place, this would have failed with //- Expected: 2640 //- Actual : 3000 - CPPUNIT_ASSERT_EQUAL(sal_Int32(2640), parseDump("/root/page/body/section/column[1]/body/infos/bounds"_ostr, "width"_ostr).toInt32()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2640), getXPath(pXmlDoc, "/root/page/body/section/column[1]/body/infos/bounds"_ostr, "width"_ostr).toInt32()); //- Expected: 6000 //- Actual : 6360 - CPPUNIT_ASSERT_EQUAL(sal_Int32(6000), parseDump("/root/page/body/section/column[2]/body/infos/bounds"_ostr, "width"_ostr).toInt32()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(6000), getXPath(pXmlDoc, "/root/page/body/section/column[2]/body/infos/bounds"_ostr, "width"_ostr).toInt32()); } DECLARE_ODFEXPORT_TEST(testBtlrCell, "btlr-cell.odt") @@ -1862,7 +1866,8 @@ DECLARE_ODFEXPORT_TEST(testTdf135338_firstLeftPageFooter, "tdf135338_firstLeftPa CPPUNIT_ASSERT_EQUAL(6, getPages()); // The first page is a left page only style, but it should still show the first page footer // instead of the left footer text "EVEN/LEFT (Left page only)" - CPPUNIT_ASSERT_EQUAL(u"First (Left page only)"_ustr, parseDump("/root/page[2]/footer/txt/text()"_ostr)); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + assertXPathContent(pXmlDoc, "/root/page[2]/footer/txt/text()"_ostr, u"First (Left page only)"_ustr); } DECLARE_ODFEXPORT_TEST(testGerrit13858, "gerrit13858.odt") diff --git a/sw/qa/extras/odfexport/odfexport2.cxx b/sw/qa/extras/odfexport/odfexport2.cxx index 9eb4048e2b4c..debea006f068 100644 --- a/sw/qa/extras/odfexport/odfexport2.cxx +++ b/sw/qa/extras/odfexport/odfexport2.cxx @@ -831,11 +831,12 @@ DECLARE_ODFEXPORT_TEST(testGutterLeft, "gutter-left.odt") DECLARE_ODFEXPORT_TEST(testTdf52065_centerTabs, "testTdf52065_centerTabs.odt") { CPPUNIT_ASSERT_EQUAL(1, getPages()); - sal_Int32 nTabStop = parseDump("//body/txt[4]/SwParaPortion/SwLineLayout/child::*[3]"_ostr, "width"_ostr).toInt32(); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + sal_Int32 nTabStop = getXPath(pXmlDoc, "//body/txt[4]/SwParaPortion/SwLineLayout/child::*[3]"_ostr, "width"_ostr).toInt32(); // Without the fix, the text was unseen, with a tabstop width of 64057. It should be 3057 CPPUNIT_ASSERT(nTabStop < 4000); CPPUNIT_ASSERT(3000 < nTabStop); - CPPUNIT_ASSERT_EQUAL(u"Pečiatka zamestnávateľa"_ustr, parseDump("//body/txt[4]/SwParaPortion/SwLineLayout/child::*[4]"_ostr, "portion"_ostr)); + CPPUNIT_ASSERT_EQUAL(u"Pečiatka zamestnávateľa"_ustr, getXPath(pXmlDoc, "//body/txt[4]/SwParaPortion/SwLineLayout/child::*[4]"_ostr, "portion"_ostr)); // tdf#149547: __XXX___invalid CharacterStyles should not be imported/exported CPPUNIT_ASSERT(!getStyles(u"CharacterStyles"_ustr)->hasByName(u"__XXX___invalid"_ustr)); diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx index 6ce472d683e3..19258ebbe37d 100644 --- a/sw/qa/extras/odfimport/odfimport.cxx +++ b/sw/qa/extras/odfimport/odfimport.cxx @@ -920,18 +920,20 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf92586) CPPUNIT_TEST_FIXTURE(Test, testTdf103025) { createSwDoc("tdf103025.odt"); - CPPUNIT_ASSERT_EQUAL(u"2014-01"_ustr, parseDump("/root/page[1]/header/tab[2]/row[2]/cell[3]/txt/SwParaPortion/SwLineLayout/SwFieldPortion"_ostr, "expand"_ostr)); - CPPUNIT_ASSERT_EQUAL(u"2014-01"_ustr, parseDump("/root/page[2]/header/tab[2]/row[2]/cell[3]/txt/SwParaPortion/SwLineLayout/SwFieldPortion"_ostr, "expand"_ostr)); - CPPUNIT_ASSERT_EQUAL(u"2014-02"_ustr, parseDump("/root/page[3]/header/tab[2]/row[2]/cell[3]/txt/SwParaPortion/SwLineLayout/SwFieldPortion"_ostr, "expand"_ostr)); - CPPUNIT_ASSERT_EQUAL(u"2014-03"_ustr, parseDump("/root/page[4]/header/tab[2]/row[2]/cell[3]/txt/SwParaPortion/SwLineLayout/SwFieldPortion"_ostr, "expand"_ostr)); - CPPUNIT_ASSERT_EQUAL(u"2014-03"_ustr, parseDump("/root/page[5]/header/tab[2]/row[2]/cell[3]/txt/SwParaPortion/SwLineLayout/SwFieldPortion"_ostr, "expand"_ostr)); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + CPPUNIT_ASSERT_EQUAL(u"2014-01"_ustr, getXPath(pXmlDoc, "/root/page[1]/header/tab[2]/row[2]/cell[3]/txt/SwParaPortion/SwLineLayout/SwFieldPortion"_ostr, "expand"_ostr)); + CPPUNIT_ASSERT_EQUAL(u"2014-01"_ustr, getXPath(pXmlDoc, "/root/page[2]/header/tab[2]/row[2]/cell[3]/txt/SwParaPortion/SwLineLayout/SwFieldPortion"_ostr, "expand"_ostr)); + CPPUNIT_ASSERT_EQUAL(u"2014-02"_ustr, getXPath(pXmlDoc, "/root/page[3]/header/tab[2]/row[2]/cell[3]/txt/SwParaPortion/SwLineLayout/SwFieldPortion"_ostr, "expand"_ostr)); + CPPUNIT_ASSERT_EQUAL(u"2014-03"_ustr, getXPath(pXmlDoc, "/root/page[4]/header/tab[2]/row[2]/cell[3]/txt/SwParaPortion/SwLineLayout/SwFieldPortion"_ostr, "expand"_ostr)); + CPPUNIT_ASSERT_EQUAL(u"2014-03"_ustr, getXPath(pXmlDoc, "/root/page[5]/header/tab[2]/row[2]/cell[3]/txt/SwParaPortion/SwLineLayout/SwFieldPortion"_ostr, "expand"_ostr)); } CPPUNIT_TEST_FIXTURE(Test, testTdf76322_columnBreakInHeader) { createSwDoc("tdf76322_columnBreakInHeader.docx"); -// column breaks were ignored. First line should start in column 2 - CPPUNIT_ASSERT_EQUAL( u"Test1"_ustr, parseDump("/root/page[1]/header/section/column[2]/body/txt/text()"_ostr) ); + // column breaks were ignored. First line should start in column 2 + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + CPPUNIT_ASSERT_EQUAL( u"Test1"_ustr, getXPathContent(pXmlDoc, "/root/page[1]/header/section/column[2]/body/txt/text()"_ostr) ); } CPPUNIT_TEST_FIXTURE(Test, testTdf76349_1columnBreak) @@ -960,16 +962,18 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf75221) // When "Don't add space between paragraphs of the same style" setting set, // spacing between same-style paragraphs must be equal to their line spacing. // It used to be 0. - OUString top = parseDump("/root/page/body/txt[2]/infos/prtBounds"_ostr, "top"_ostr); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + OUString top = getXPath(pXmlDoc, "/root/page/body/txt[2]/infos/prtBounds"_ostr, "top"_ostr); CPPUNIT_ASSERT(top.toInt32() > 0); } CPPUNIT_TEST_FIXTURE(Test, testTdf101729) { createSwDoc("tdf101729.odt"); - sal_Int32 l = parseDump("/root/page/body/tab/row/cell[1]/infos/bounds"_ostr, "left"_ostr).toInt32(); - sal_Int32 w = parseDump("/root/page/body/tab/row/cell[1]/infos/bounds"_ostr, "width"_ostr).toInt32(); - sal_Int32 x = parseDump("/root/page/body/tab/row/cell[1]/txt/infos/bounds"_ostr, "left"_ostr).toInt32(); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + sal_Int32 l = getXPath(pXmlDoc, "/root/page/body/tab/row/cell[1]/infos/bounds"_ostr, "left"_ostr).toInt32(); + sal_Int32 w = getXPath(pXmlDoc, "/root/page/body/tab/row/cell[1]/infos/bounds"_ostr, "width"_ostr).toInt32(); + sal_Int32 x = getXPath(pXmlDoc, "/root/page/body/tab/row/cell[1]/txt/infos/bounds"_ostr, "left"_ostr).toInt32(); // Make sure the text does not go outside and verify it is centered roughly CPPUNIT_ASSERT( l + w / 4 < x ); CPPUNIT_ASSERT( x < l + 3 * w / 4); @@ -1032,15 +1036,16 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf109080_loext_ns) createSwDoc("tdf109080_loext_ns.odt"); // Test we can import <loext:header-first> and <loext:footer-first> + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); CPPUNIT_ASSERT_EQUAL(u"This is the first page header"_ustr, - parseDump("/root/page[1]/header/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[1]/header/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"This is the non-first-page header"_ustr, - parseDump("/root/page[2]/header/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[2]/header/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"This is the first page footer"_ustr, - parseDump("/root/page[1]/footer/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[1]/footer/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"This is the non-first-page footer"_ustr, - parseDump("/root/page[2]/footer/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[2]/footer/txt/text()"_ostr)); } CPPUNIT_TEST_FIXTURE(Test, testTdf109080_style_ns) @@ -1049,15 +1054,16 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf109080_style_ns) // Test we can import <style:header-first> and <style:footer-first> // (produced by LibreOffice 4.0 - 5.x) + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); CPPUNIT_ASSERT_EQUAL(u"This is the first page header"_ustr, - parseDump("/root/page[1]/header/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[1]/header/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"This is the non-first-page header"_ustr, - parseDump("/root/page[2]/header/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[2]/header/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"This is the first page footer"_ustr, - parseDump("/root/page[1]/footer/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[1]/footer/txt/text()"_ostr)); CPPUNIT_ASSERT_EQUAL(u"This is the non-first-page footer"_ustr, - parseDump("/root/page[2]/footer/txt/text()"_ostr)); + getXPathContent(pXmlDoc, "/root/page[2]/footer/txt/text()"_ostr)); } CPPUNIT_TEST_FIXTURE(Test, testTdf109228) @@ -1073,7 +1079,8 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf94882) // Get the header of the page containing our content // (done this way to skip past any blank page inserted before it // due to the page number being even) - OUString headertext = parseDump( + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + OUString headertext = getXPathContent(pXmlDoc, "/root/page[starts-with(body/txt/text(),'The paragraph style on this')]" "/header/txt/text()"_ostr ); @@ -1087,8 +1094,9 @@ CPPUNIT_TEST_FIXTURE(Test, testBlankBeforeFirstPage) // This document starts on page 50, which is even, but it should not have a // blank page inserted before it to make it a left page + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be 1 pages output", - u"1"_ustr, parseDump("count(/root/page)"_ostr) + u"1"_ustr, getXPathContent(pXmlDoc, "count(/root/page)"_ostr) ); } @@ -1101,25 +1109,27 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf115079) CPPUNIT_TEST_FIXTURE(Test, testTdf108482) { createSwDoc("tdf108482.odt"); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); CPPUNIT_ASSERT_EQUAL_MESSAGE("The table on second page must have two rows", - u"2"_ustr, parseDump("count(/root/page[2]/body/tab/row)"_ostr) + u"2"_ustr, getXPathContent(pXmlDoc, "count(/root/page[2]/body/tab/row)"_ostr) ); CPPUNIT_ASSERT_EQUAL_MESSAGE("The second page table's first row must be the repeated headline", - u"Header"_ustr, parseDump("/root/page[2]/body/tab/row[1]/cell/txt"_ostr) + u"Header"_ustr, getXPathContent(pXmlDoc, "/root/page[2]/body/tab/row[1]/cell/txt"_ostr) ); // The first (repeated headline) row with vertical text orientation must have non-zero height // (in my tests, it was 1135) CPPUNIT_ASSERT_GREATER( - sal_Int32(1000), parseDump("/root/page[2]/body/tab/row[1]/infos/bounds"_ostr, "height"_ostr).toInt32() + sal_Int32(1000), getXPath(pXmlDoc, "/root/page[2]/body/tab/row[1]/infos/bounds"_ostr, "height"_ostr).toInt32() ); } CPPUNIT_TEST_FIXTURE(Test, testTdf116195) { createSwDoc("tdf116195.odt"); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); // The image was set to zero height due to a regression CPPUNIT_ASSERT_EQUAL( - sal_Int32(12960), parseDump("/root/page/anchored/fly/notxt/infos/bounds"_ostr, "height"_ostr).toInt32() + sal_Int32(12960), getXPath(pXmlDoc, "/root/page/anchored/fly/notxt/infos/bounds"_ostr, "height"_ostr).toInt32() ); } diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 5c88371d4e7d..0a303cc05e6e 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -720,7 +720,8 @@ DECLARE_OOXMLEXPORT_TEST(testNumOverrideLvltext, "num-override-lvltext.docx") CPPUNIT_ASSERT_EQUAL(u"1.1"_ustr, getProperty<OUString>(xPara, u"ListLabelString"_ustr)); // The paragraph marker's red font color was inherited by the number portion, this was ff0000. - CPPUNIT_ASSERT_EQUAL(u"ffffffff"_ustr, parseDump("//SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']/SwFont"_ostr, "color"_ostr)); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + CPPUNIT_ASSERT_EQUAL(u"ffffffff"_ustr, getXPath(pXmlDoc, "//SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']/SwFont"_ostr, "color"_ostr)); } DECLARE_OOXMLEXPORT_TEST(testNumOverrideStart, "num-override-start.docx") @@ -741,10 +742,11 @@ DECLARE_OOXMLEXPORT_TEST(testTextboxRightEdge, "textbox-right-edge.docx") // I'm fairly sure this is not specific to DOCX, but the doc model created // by the ODF import doesn't trigger this bug, so let's test this here // instead of uiwriter. - int nShapeLeft = parseDump("//anchored/SwAnchoredDrawObject/bounds"_ostr, "left"_ostr).toInt32(); - int nShapeWidth = parseDump("//anchored/SwAnchoredDrawObject/bounds"_ostr, "width"_ostr).toInt32(); - int nTextboxLeft = parseDump("//anchored/fly/infos/bounds"_ostr, "left"_ostr).toInt32(); - int nTextboxWidth = parseDump("//anchored/fly/infos/bounds"_ostr, "width"_ostr).toInt32(); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + int nShapeLeft = getXPath(pXmlDoc, "//anchored/SwAnchoredDrawObject/bounds"_ostr, "left"_ostr).toInt32(); + int nShapeWidth = getXPath(pXmlDoc, "//anchored/SwAnchoredDrawObject/bounds"_ostr, "width"_ostr).toInt32(); + int nTextboxLeft = getXPath(pXmlDoc, "//anchored/fly/infos/bounds"_ostr, "left"_ostr).toInt32(); + int nTextboxWidth = getXPath(pXmlDoc, "//anchored/fly/infos/bounds"_ostr, "width"_ostr).toInt32(); // This is a rectangle, make sure the right edge of the textbox is still // inside the draw shape. CPPUNIT_ASSERT(nShapeLeft + nShapeWidth >= nTextboxLeft + nTextboxWidth); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx index 6c502c497896..a50c853d7713 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx @@ -600,7 +600,8 @@ DECLARE_OOXMLEXPORT_TEST(testLargeTwips, "large-twips.docx" ) { // cp#1000043: MSO seems to ignore large twips values, we didn't, which resulted in different // layout of broken documents (text not visible in this specific document). - OUString width = parseDump( "/root/page/body/tab/row[1]/cell[1]/txt/infos/bounds"_ostr, "width"_ostr ); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + OUString width = getXPath(pXmlDoc, "/root/page/body/tab/row[1]/cell[1]/txt/infos/bounds"_ostr, "width"_ostr ); CPPUNIT_ASSERT( width.toInt32() > 0 ); } @@ -608,7 +609,8 @@ DECLARE_OOXMLEXPORT_TEST(testNegativeCellMarginTwips, "negative-cell-margin-twip { // Slightly related to cp#1000043, the twips value was negative, which wrapped around somewhere, // while MSO seems to ignore that as well. - OUString width = parseDump( "/root/page/body/tab/row[1]/cell[1]/txt/infos/bounds"_ostr, "width"_ostr ); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + OUString width = getXPath(pXmlDoc, "/root/page/body/tab/row[1]/cell[1]/txt/infos/bounds"_ostr, "width"_ostr ); CPPUNIT_ASSERT( width.toInt32() > 0 ); } @@ -617,13 +619,14 @@ DECLARE_OOXMLEXPORT_TEST(testFdo38414, "fdo38414.docx") // The cells in the last (4th) column were merged properly and so the result didn't have the same height. // (Since w:gridBefore is worked around by faking another cell in the row, so column count is thus 5 // instead of 4, therefore compare height of cells 4 and 5 rather than 3 and 4.) + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY); uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY); uno::Reference<table::XTableColumns> xTableColumns = xTextTable->getColumns(); CPPUNIT_ASSERT_EQUAL( sal_Int32( 5 ), xTableColumns->getCount()); - OUString height3 = parseDump("/root/page/body/tab/row[1]/cell[4]/infos/bounds"_ostr, "height"_ostr ); - OUString height4 = parseDump("/root/page/body/tab/row[1]/cell[5]/infos/bounds"_ostr, "height"_ostr ); + OUString height3 = getXPath(pXmlDoc, "/root/page/body/tab/row[1]/cell[4]/infos/bounds"_ostr, "height"_ostr ); + OUString height4 = getXPath(pXmlDoc, "/root/page/body/tab/row[1]/cell[5]/infos/bounds"_ostr, "height"_ostr ); CPPUNIT_ASSERT_EQUAL( height3, height4 ); } @@ -659,9 +662,10 @@ DECLARE_OOXMLEXPORT_TEST(testGridBefore, "gridbefore.docx") uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY); uno::Reference<table::XTableColumns> xTableColumns = xTextTable->getColumns(); CPPUNIT_ASSERT_EQUAL( sal_Int32( 3 ), xTableColumns->getCount()); - OUString textA3 = parseDump("/root/page/body/tab/row[1]/cell[3]/txt/text()"_ostr ); - OUString leftA3 = parseDump("/root/page/body/tab/row[1]/cell[3]/infos/bounds"_ostr, "left"_ostr ); - OUString leftB2 = parseDump("/root/page/body/tab/row[2]/cell[2]/infos/bounds"_ostr, "left"_ostr ); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + OUString textA3 = getXPathContent(pXmlDoc, "/root/page/body/tab/row[1]/cell[3]/txt/text()"_ostr ); + OUString leftA3 = getXPath(pXmlDoc, "/root/page/body/tab/row[1]/cell[3]/infos/bounds"_ostr, "left"_ostr ); + OUString leftB2 = getXPath(pXmlDoc, "/root/page/body/tab/row[2]/cell[2]/infos/bounds"_ostr, "left"_ostr ); CPPUNIT_ASSERT_EQUAL( u"A3"_ustr, textA3 ); CPPUNIT_ASSERT( leftA3.toInt32() > leftB2.toInt32()); } diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx index 84f3d734e3f6..effbe02955c0 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx @@ -698,8 +698,9 @@ DECLARE_OOXMLEXPORT_TEST(testTdf82177_tblBorders, "tdf82177_tblBorders.docx") DECLARE_OOXMLEXPORT_TEST(testTdf119760_positionCellBorder, "tdf119760_positionCellBorder.docx") { //inconsistent in Word even. 2016 positions on last row, 2003 positions on first cell. - sal_Int32 nRowLeft = parseDump("/root/page/body/tab[4]/row[1]/infos/bounds"_ostr, "left"_ostr).toInt32(); - sal_Int32 nTextLeft = parseDump("/root/page/body/tab[4]/row[1]/cell[1]/txt/infos/bounds"_ostr, "left"_ostr).toInt32(); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + sal_Int32 nRowLeft = getXPath(pXmlDoc, "/root/page/body/tab[4]/row[1]/infos/bounds"_ostr, "left"_ostr).toInt32(); + sal_Int32 nTextLeft = getXPath(pXmlDoc, "/root/page/body/tab[4]/row[1]/cell[1]/txt/infos/bounds"_ostr, "left"_ostr).toInt32(); CPPUNIT_ASSERT( nRowLeft < nTextLeft ); } @@ -726,8 +727,9 @@ DECLARE_OOXMLEXPORT_TEST(testTdf116985, "tdf116985.docx") // Body frame width is 10800, 40% is the requested relative width, with 144 // spacing to text on the left/right side. So ideal width would be 4032, // was 3431. Allow one pixel tolerance, though. + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); sal_Int32 nWidth - = parseDump("/root/page[1]/body/txt[1]/anchored/fly/infos/bounds"_ostr, "width"_ostr).toInt32(); + = getXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly/infos/bounds"_ostr, "width"_ostr).toInt32(); CPPUNIT_ASSERT(nWidth > 4000); } diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx index 9ebcf1050d17..f5af7f65d8bc 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx @@ -1809,10 +1809,12 @@ DECLARE_OOXMLEXPORT_TEST(testTdf64264, "tdf64264.docx") // and it has got only a single repeating header line assertXPath(pDump, "/root/page[2]/body/tab"_ostr, 1); assertXPath(pDump, "/root/page[2]/body/tab/row"_ostr, 47); - CPPUNIT_ASSERT_EQUAL(u"Repeating Table Header"_ustr, - parseDump("/root/page[2]/body/tab/row[1]/cell[1]/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, - parseDump("/root/page[2]/body/tab/row[2]/cell[1]/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL( + u"Repeating Table Header"_ustr, + getXPathContent(pDump, "/root/page[2]/body/tab/row[1]/cell[1]/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL( + u"Text"_ustr, + getXPathContent(pDump, "/root/page[2]/body/tab/row[2]/cell[1]/txt/text()"_ostr)); } DECLARE_OOXMLEXPORT_TEST(testTdf58944RepeatingTableHeader, "tdf58944-repeating-table-header.docx") @@ -1826,10 +1828,12 @@ DECLARE_OOXMLEXPORT_TEST(testTdf58944RepeatingTableHeader, "tdf58944-repeating-t // instead of showing only a part of it on page 2 assertXPath(pDump, "/root/page[1]/body/tab"_ostr, 1); assertXPath(pDump, "/root/page[1]/body/tab/row"_ostr, 11); - CPPUNIT_ASSERT_EQUAL(u"Test1"_ustr, - parseDump("/root/page[2]/body/tab/row[1]/cell[1]/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(u"Test2"_ustr, - parseDump("/root/page[2]/body/tab/row[2]/cell[1]/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL( + u"Test1"_ustr, + getXPathContent(pDump, "/root/page[2]/body/tab/row[1]/cell[1]/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL( + u"Test2"_ustr, + getXPathContent(pDump, "/root/page[2]/body/tab/row[2]/cell[1]/txt/text()"_ostr)); } CPPUNIT_TEST_FIXTURE(Test, testTdf81100) @@ -2186,10 +2190,11 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf124678_case1) { loadAndReload("tdf124678_no_leading_paragraph.odt"); CPPUNIT_ASSERT_EQUAL(2, getPages()); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); CPPUNIT_ASSERT_EQUAL_MESSAGE("First page header text", u""_ustr, - parseDump("/root/page[1]/header/txt"_ostr)); + getXPathContent(pXmlDoc, "/root/page[1]/header/txt"_ostr)); CPPUNIT_ASSERT_EQUAL_MESSAGE("Second page header text", u"HEADER"_ustr, - parseDump("/root/page[2]/header/txt"_ostr)); + getXPathContent(pXmlDoc, "/root/page[2]/header/txt"_ostr)); } // The (tdf124678_no_leading_paragraph.odt, tdf124678_with_leading_paragraph.odt) documents are the same, @@ -2201,10 +2206,11 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf124678_case2) { loadAndReload("tdf124678_with_leading_paragraph.odt"); CPPUNIT_ASSERT_EQUAL(2, getPages()); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); CPPUNIT_ASSERT_EQUAL_MESSAGE("First page header text", u""_ustr, - parseDump("/root/page[1]/header/txt"_ostr)); + getXPathContent(pXmlDoc, "/root/page[1]/header/txt"_ostr)); CPPUNIT_ASSERT_EQUAL_MESSAGE("Second page header text", u"HEADER"_ustr, - parseDump("/root/page[2]/header/txt"_ostr)); + getXPathContent(pXmlDoc, "/root/page[2]/header/txt"_ostr)); } static bool lcl_nearEqual(const sal_Int32 nNumber1, const sal_Int32 nNumber2, @@ -2348,14 +2354,16 @@ DECLARE_OOXMLEXPORT_TEST(testTdf119952_negativeMargins, "tdf119952_negativeMargi CPPUNIT_ASSERT_EQUAL(u"f1 f2 f3 f4 f5 f6 " " f7 f8"_ustr, - parseDump("/root/page[1]/header/txt/anchored/fly"_ostr)); + getXPathContent(pDump, "/root/page[1]/header/txt/anchored/fly"_ostr)); CPPUNIT_ASSERT_EQUAL(u" f8 f7 f6 f5 " " f4 f3 f2f1"_ustr, - parseDump("/root/page[1]/footer/txt/anchored/fly"_ostr)); - CPPUNIT_ASSERT_EQUAL(u"p1"_ustr, parseDump("/root/page[2]/header/txt/anchored/fly"_ostr)); - CPPUNIT_ASSERT_EQUAL(u"p1"_ustr, parseDump("/root/page[2]/footer/txt/anchored/fly"_ostr)); + getXPathContent(pDump, "/root/page[1]/footer/txt/anchored/fly"_ostr)); + CPPUNIT_ASSERT_EQUAL(u"p1"_ustr, + getXPathContent(pDump, "/root/page[2]/header/txt/anchored/fly"_ostr)); + CPPUNIT_ASSERT_EQUAL(u"p1"_ustr, + getXPathContent(pDump, "/root/page[2]/footer/txt/anchored/fly"_ostr)); CPPUNIT_ASSERT_EQUAL(u" aaaa bbbb cccc dddd eeee"_ustr, - parseDump("/root/page[3]/header/txt/anchored/fly"_ostr)); + getXPathContent(pDump, "/root/page[3]/header/txt/anchored/fly"_ostr)); } DECLARE_OOXMLEXPORT_TEST(testTdf143384_tableInFoot_negativeMargins, diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx index 76a7c11a310e..d54ca9dd2ed8 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx @@ -564,7 +564,8 @@ DECLARE_OOXMLEXPORT_TEST(testTdf78352, "tdf78352.docx") CPPUNIT_ASSERT_EQUAL(1, getPages()); // Ensure that width of first tab is close to zero (previous value was ~1000 twips) - int nWidth = parseDump("/root/page/body/txt[1]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::TabLeft']"_ostr, "width"_ostr).toInt32(); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + int nWidth = getXPath(pXmlDoc, "/root/page/body/txt[1]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::TabLeft']"_ostr, "width"_ostr).toInt32(); CPPUNIT_ASSERT_LESS(150, nWidth); } @@ -574,26 +575,27 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf81567) CPPUNIT_ASSERT_EQUAL(1, getPages()); CPPUNIT_ASSERT_EQUAL(2, getShapes()); - int nFrameWidth = parseDump("/root/page/body/txt/anchored/fly/infos/bounds"_ostr, "width"_ostr).toInt32(); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + int nFrameWidth = getXPath(pXmlDoc, "/root/page/body/txt/anchored/fly/infos/bounds"_ostr, "width"_ostr).toInt32(); CPPUNIT_ASSERT_EQUAL(2371, nFrameWidth); - int nFrameHeight = parseDump("/root/page/body/txt/anchored/fly/infos/bounds"_ostr, "height"_ostr).toInt32(); + int nFrameHeight = getXPath(pXmlDoc, "/root/page/body/txt/anchored/fly/infos/bounds"_ostr, "height"_ostr).toInt32(); CPPUNIT_ASSERT_EQUAL(3520, nFrameHeight); - int nFrameTop = parseDump("/root/page/body/txt/anchored/fly/infos/bounds"_ostr, "top"_ostr).toInt32(); + int nFrameTop = getXPath(pXmlDoc, "/root/page/body/txt/anchored/fly/infos/bounds"_ostr, "top"_ostr).toInt32(); CPPUNIT_ASSERT_EQUAL(1518, nFrameTop); - int nImageWidth = parseDump("/root/page/body/txt/anchored/fly/txt/anchored/fly/infos/bounds"_ostr, "width"_ostr).toInt32(); + int nImageWidth = getXPath(pXmlDoc, "/root/page/body/txt/anchored/fly/txt/anchored/fly/infos/bounds"_ostr, "width"_ostr).toInt32(); CPPUNIT_ASSERT_EQUAL(2370, nImageWidth); - int nImageHeight = parseDump("/root/page/body/txt/anchored/fly/txt/anchored/fly/infos/bounds"_ostr, "height"_ostr).toInt32(); + int nImageHeight = getXPath(pXmlDoc, "/root/page/body/txt/anchored/fly/txt/anchored/fly/infos/bounds"_ostr, "height"_ostr).toInt32(); CPPUNIT_ASSERT_EQUAL(1605, nImageHeight); // Check the image is at the top of the frame // Without the fix in place, this test would have failed with: // - Expected: 1638 // - Actual : 2236 - int nImageTop = parseDump("/root/page/body/txt/anchored/fly/txt/anchored/fly/infos/bounds"_ostr, "top"_ostr).toInt32(); + int nImageTop = getXPath(pXmlDoc, "/root/page/body/txt/anchored/fly/txt/anchored/fly/infos/bounds"_ostr, "top"_ostr).toInt32(); CPPUNIT_ASSERT_EQUAL(1638, nImageTop); } @@ -744,7 +746,8 @@ DECLARE_OOXMLEXPORT_TEST(testTdf83309, "tdf83309.docx") // First paragraph does not have tab before // (same applies to all paragraphs in doc, but let's assume they are // behaving same way) - OUString sNodeType = parseDump("(/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/child::*)[1]"_ostr, "type"_ostr); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + OUString sNodeType = getXPath(pXmlDoc, "(/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/child::*)[1]"_ostr, "type"_ostr); CPPUNIT_ASSERT_EQUAL(u"PortionType::Text"_ustr, sNodeType); // tdf148380: creation-date field in header.xml was unsupported on export diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx index a717a84e8492..a37e3fdcb34b 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx @@ -479,30 +479,31 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf145998_unnecessaryPageStyles) // Sanity check - always good to test when dealing with page styles and breaks. CPPUNIT_ASSERT_EQUAL(5, getPages()); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); // Page Style should be explicitly mentioned - otherwise it would be a "follow" style uno::Reference<beans::XPropertySet> xPara(getParagraph(2, u"2"_ustr), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT(uno::Any() != xPara->getPropertyValue(u"PageDescName"_ustr)); // CPPUNIT_ASSERT_EQUAL(OUString("First Page header"), - // parseDump("/root/page[2]/header/txt")); + // getXPathContent(pXmlDoc, "/root/page[2]/header/txt")); // Page Style is converted into a page break instead. Still shows "first" header. xPara.set(getParagraph(3, u"3"_ustr), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(uno::Any(), xPara->getPropertyValue(u"PageDescName"_ustr)); // CPPUNIT_ASSERT_EQUAL(OUString("Default page style - first page style"), - // parseDump("/root/page[3]/header/txt")); - CPPUNIT_ASSERT_EQUAL(OUString(), parseDump("/root/page[3]/footer/txt"_ostr)); + // getXPathContent(pXmlDoc, "/root/page[3]/header/txt")); + CPPUNIT_ASSERT_EQUAL(OUString(), getXPathContent(pXmlDoc, "/root/page[3]/footer/txt"_ostr)); // Page Style is converted into a page break instead. Shows the "normal" header. xPara.set(getParagraph(5, u"4"_ustr), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(uno::Any(), xPara->getPropertyValue(u"PageDescName"_ustr)); CPPUNIT_ASSERT_EQUAL(u"Default page style"_ustr, - parseDump("/root/page[4]/header/txt"_ostr)); + getXPathContent(pXmlDoc, "/root/page[4]/header/txt"_ostr)); // Page Style is retained (with wrong header) in order to preserve page re-numbering. xPara.set(getParagraph(7, u"1"_ustr), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT(uno::Any() != xPara->getPropertyValue(u"PageDescName"_ustr)); - CPPUNIT_ASSERT_EQUAL(OUString(), parseDump("/root/page[5]/footer/txt"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString(), getXPathContent(pXmlDoc, "/root/page[5]/footer/txt"_ostr)); } CPPUNIT_TEST_FIXTURE(Test, testTdf136929_framesOfParagraph) @@ -510,7 +511,8 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf136929_framesOfParagraph) loadAndReload("tdf136929_framesOfParagraph.odt"); // Before this fix, the image was placed in the footer instead of in the text body - messing everything up. CPPUNIT_ASSERT_EQUAL_MESSAGE( "Number of Pages", 5, getPages() ); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Header2 text", u"* | *"_ustr, parseDump("/root/page[4]/footer/txt"_ostr)); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Header2 text", u"* | *"_ustr, getXPathContent(pXmlDoc, "/root/page[4]/footer/txt"_ostr)); } DECLARE_OOXMLEXPORT_TEST(testTdf136589_paraHadField, "tdf136589_paraHadField.docx") diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx index 9dcb9de35cbd..24835e207802 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx @@ -593,37 +593,38 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf142404_tabOverSpacingC15) // The original 3-page ODT saved as DOCX would fit on one page in MS Word 2010, but 3 in Word 2013. CPPUNIT_ASSERT_EQUAL_MESSAGE("too big for two pages", 3, getPages()); // The tab goes over the paragraph margin - CPPUNIT_ASSERT_EQUAL(u"A left tab positioned at"_ustr, parseDump("//page[1]/body/txt[2]/SwParaPortion/SwLineLayout[1]/SwLinePortion[1]"_ostr, "portion"_ostr)); - sal_Int32 nTextLen = parseDump("//page[1]/body/txt[2]/SwParaPortion/SwLineLayout[1]/SwLinePortion[1]"_ostr, "width"_ostr).toInt32(); - CPPUNIT_ASSERT_EQUAL(u"*"_ustr, parseDump("//page[1]/body/txt[2]/SwParaPortion/SwLineLayout[1]/SwFixPortion[1]"_ostr, "portion"_ostr)); - sal_Int32 nTabLen = parseDump("//page[1]/body/txt[2]/SwParaPortion/SwLineLayout[1]/SwFixPortion[1]"_ostr, "width"_ostr).toInt32(); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + CPPUNIT_ASSERT_EQUAL(u"A left tab positioned at"_ustr, getXPath(pXmlDoc, "//page[1]/body/txt[2]/SwParaPortion/SwLineLayout[1]/SwLinePortion[1]"_ostr, "portion"_ostr)); + sal_Int32 nTextLen = getXPath(pXmlDoc, "//page[1]/body/txt[2]/SwParaPortion/SwLineLayout[1]/SwLinePortion[1]"_ostr, "width"_ostr).toInt32(); + CPPUNIT_ASSERT_EQUAL(u"*"_ustr, getXPath(pXmlDoc, "//page[1]/body/txt[2]/SwParaPortion/SwLineLayout[1]/SwFixPortion[1]"_ostr, "portion"_ostr)); + sal_Int32 nTabLen = getXPath(pXmlDoc, "//page[1]/body/txt[2]/SwParaPortion/SwLineLayout[1]/SwFixPortion[1]"_ostr, "width"_ostr).toInt32(); CPPUNIT_ASSERT_MESSAGE("Large left tab", nTextLen < nTabLen); // Not 1 line high (Word 2010 DOCX), or 3 lines high (LO DOCX) or 5 lines high (ODT), but 4 lines high - sal_Int32 nHeight = parseDump("//page[1]/body/txt[2]/infos/bounds"_ostr, "height"_ostr).toInt32(); + sal_Int32 nHeight = getXPath(pXmlDoc, "//page[1]/body/txt[2]/infos/bounds"_ostr, "height"_ostr).toInt32(); CPPUNIT_ASSERT_MESSAGE("4 lines high", 1100 < nHeight); CPPUNIT_ASSERT_MESSAGE("4 lines high", nHeight < 1300); - CPPUNIT_ASSERT_EQUAL(u"TabOverflow does what?"_ustr, parseDump("//page[1]/body/txt[7]/SwParaPortion/SwLineLayout[1]/SwLinePortion[1]"_ostr, "portion"_ostr)); + CPPUNIT_ASSERT_EQUAL(u"TabOverflow does what?"_ustr, getXPath(pXmlDoc, "//page[1]/body/txt[7]/SwParaPortion/SwLineLayout[1]/SwLinePortion[1]"_ostr, "portion"_ostr)); // Not 1 line high (Word 2010 DOCX), or 4 lines high (prev LO DOCX) or 8 lines high (ODT). // but two lines high. (3 in Word 2016 because it pulls down "what?" to the second line - weird) - nHeight = parseDump("//page[1]/body/txt[7]/infos/bounds"_ostr, "height"_ostr).toInt32(); + nHeight = getXPath(pXmlDoc, "//page[1]/body/txt[7]/infos/bounds"_ostr, "height"_ostr).toInt32(); CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("2 lines high (but 3 in Word)", 242*2.5, nHeight, 242); - CPPUNIT_ASSERT_EQUAL(u"A centered tab positioned at"_ustr, parseDump("//page[1]/body/txt[3]/SwParaPortion/SwLineLayout[1]/SwLinePortion[1]"_ostr, "portion"_ostr)); - sal_Int32 nLineWidth = parseDump("//page[1]/body/txt[3]/SwParaPortion/SwLineLayout[1]/SwFixPortion[1]"_ostr, "width"_ostr).toInt32(); + CPPUNIT_ASSERT_EQUAL(u"A centered tab positioned at"_ustr, getXPath(pXmlDoc, "//page[1]/body/txt[3]/SwParaPortion/SwLineLayout[1]/SwLinePortion[1]"_ostr, "portion"_ostr)); + sal_Int32 nLineWidth = getXPath(pXmlDoc, "//page[1]/body/txt[3]/SwParaPortion/SwLineLayout[1]/SwFixPortion[1]"_ostr, "width"_ostr).toInt32(); CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Big tab: full paragraph area used", 737, nLineWidth, 100); // Pages 2/3 are TabOverMargin - in this particular case tabs should not go over margin. - CPPUNIT_ASSERT_EQUAL(u"A right tab positioned at"_ustr, parseDump("//page[2]/body/txt[6]/SwParaPortion/SwLineLayout[1]/SwLinePortion[1]"_ostr, "portion"_ostr)); - sal_Int32 nParaWidth = parseDump("//page[2]/body/txt[6]/infos/prtBounds"_ostr, "width"_ostr).toInt32(); + CPPUNIT_ASSERT_EQUAL(u"A right tab positioned at"_ustr, getXPath(pXmlDoc, "//page[2]/body/txt[6]/SwParaPortion/SwLineLayout[1]/SwLinePortion[1]"_ostr, "portion"_ostr)); + sal_Int32 nParaWidth = getXPath(pXmlDoc, "//page[2]/body/txt[6]/infos/prtBounds"_ostr, "width"_ostr).toInt32(); // the clearest non-first-line visual example is this second tab in the right-tab paragraph. - nLineWidth = parseDump("//page[2]/body/txt[6]/SwParaPortion/SwLineLayout[4]"_ostr, "width"_ostr).toInt32(); + nLineWidth = getXPath(pXmlDoc, "//page[2]/body/txt[6]/SwParaPortion/SwLineLayout[4]"_ostr, "width"_ostr).toInt32(); CPPUNIT_ASSERT_EQUAL_MESSAGE("Full paragraph area used", nLineWidth, nParaWidth); - CPPUNIT_ASSERT_EQUAL(u"TabOverflow does what?"_ustr, parseDump("//page[3]/body/txt[2]/SwParaPortion/SwLineLayout[1]/SwLinePortion[1]"_ostr, "portion"_ostr)); + CPPUNIT_ASSERT_EQUAL(u"TabOverflow does what?"_ustr, getXPath(pXmlDoc, "//page[3]/body/txt[2]/SwParaPortion/SwLineLayout[1]/SwLinePortion[1]"_ostr, "portion"_ostr)); // Not 1 line high (Word 2010 DOCX and ODT), or 4 lines high (prev LO DOCX), // but 8 lines high. - nHeight = parseDump("//page[3]/body/txt[2]/infos/bounds"_ostr, "height"_ostr).toInt32(); + nHeight = getXPath(pXmlDoc, "//page[3]/body/txt[2]/infos/bounds"_ostr, "height"_ostr).toInt32(); CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("8 lines high", 242*8, nHeight, 121); } diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx index cfc7d5fa1a16..d8854f8f1a78 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx @@ -106,11 +106,12 @@ DECLARE_OOXMLEXPORT_TEST(testTdf148956_directEndFormatting, "tdf148956_directEnd DECLARE_OOXMLEXPORT_TEST(testTdf147646, "tdf147646_mergedCellNumbering.docx") { - parseLayoutDump(); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); //Without the fix in place, it would have failed with //- Expected: 2. //- Actual : 4. - CPPUNIT_ASSERT_EQUAL(u"2."_ustr,parseDump("/root/page/body/tab/row[4]/cell/txt/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']"_ostr,"expand"_ostr)); + // + CPPUNIT_ASSERT_EQUAL(u"2."_ustr,getXPath(pXmlDoc, "/root/page/body/tab/row[4]/cell/txt/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']"_ostr,"expand"_ostr)); } DECLARE_OOXMLEXPORT_TEST(testTdf153526_commentInNumbering, "tdf153526_commentInNumbering.docx") @@ -789,8 +790,9 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf153128) { loadAndReload("tdf153128.docx"); calcLayout(); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); sal_Int32 nFirstLineHeight - = parseDump("/root/page/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion"_ostr, "height"_ostr) + = getXPath(pXmlDoc, "/root/page/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion"_ostr, "height"_ostr) .toInt32(); CPPUNIT_ASSERT_GREATER(sal_Int32(0), nFirstLineHeight); @@ -864,8 +866,8 @@ DECLARE_OOXMLEXPORT_TEST(testTdf155736, "tdf155736_PageNumbers_footer.docx") //Without the fix in place, it would have failed with //- Expected: Page * of * //- Actual : Page of - CPPUNIT_ASSERT_EQUAL(u"Page * of *"_ustr, parseDump("/root/page[1]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(u"Page * of *"_ustr, parseDump("/root/page[2]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(u"Page * of *"_ustr, getXPathContent(pXmlDoc, "/root/page[1]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(u"Page * of *"_ustr, getXPathContent(pXmlDoc, "/root/page[2]/footer/txt/text()"_ostr)); } // The following zOrder tests are checking the shapes "stacking height". diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx index dc2a291234c3..a7686d3cc000 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx @@ -153,16 +153,20 @@ DECLARE_OOXMLEXPORT_TEST(testHidemarkb, "tdf99616_hidemarkb.docx") DECLARE_OOXMLEXPORT_TEST(testBnc891663, "bnc891663.docx") { // The image should be inside a cell, so the text in the following cell should be below it. + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); int imageTop - = parseDump("/root/page/body/tab/row[1]/cell[2]/txt[1]/anchored/fly/infos/bounds"_ostr, - "top"_ostr) + = getXPath(pXmlDoc, + "/root/page/body/tab/row[1]/cell[2]/txt[1]/anchored/fly/infos/bounds"_ostr, + "top"_ostr) .toInt32(); int imageHeight - = parseDump("/root/page/body/tab/row[1]/cell[2]/txt[1]/anchored/fly/infos/bounds"_ostr, - "height"_ostr) + = getXPath(pXmlDoc, + "/root/page/body/tab/row[1]/cell[2]/txt[1]/anchored/fly/infos/bounds"_ostr, + "height"_ostr) .toInt32(); int textNextRowTop - = parseDump("/root/page/body/tab/row[2]/cell[1]/txt[1]/infos/bounds"_ostr, "top"_ostr) + = getXPath(pXmlDoc, "/root/page/body/tab/row[2]/cell[1]/txt[1]/infos/bounds"_ostr, + "top"_ostr) .toInt32(); CPPUNIT_ASSERT(textNextRowTop >= imageTop + imageHeight); } @@ -1116,8 +1120,10 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf150408_isLvl_RoundTrip) DECLARE_OOXMLEXPORT_TEST(testTdf156372, "tdf156372.doc") { + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); sal_Int32 nHeight - = parseDump("//page[1]/header/tab/row[1]/infos/bounds"_ostr, "height"_ostr).toInt32(); + = getXPath(pXmlDoc, "//page[1]/header/tab/row[1]/infos/bounds"_ostr, "height"_ostr) + .toInt32(); // Without a fix in place, this would fail with // - Expected: 847 // - Actual : 1327 diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx index 14170bf3f23f..9fd73751bfaf 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx @@ -952,7 +952,8 @@ CPPUNIT_TEST_FIXTURE(Test, testDontSplitTable) loadAndReload("tdf101589_dontSplitTable.odt"); CPPUNIT_ASSERT_EQUAL(2, getPages()); //single row tables need to prevent split by setting row to no split - CPPUNIT_ASSERT_EQUAL( u"Row 1"_ustr, parseDump("/root/page[2]/body/tab[1]/row[1]/cell[1]/txt[1]"_ostr) ); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + CPPUNIT_ASSERT_EQUAL( u"Row 1"_ustr, getXPathContent(pXmlDoc, "/root/page[2]/body/tab[1]/row[1]/cell[1]/txt[1]"_ostr) ); uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx index f962fdb7bf84..a00905cdc8e9 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx @@ -215,7 +215,8 @@ DECLARE_OOXMLEXPORT_TEST(testRelSizeRound, "rel-size-round.docx") DECLARE_OOXMLEXPORT_TEST(testTestTitlePage, "testTitlePage.docx") { // this has 2 pages in Word - CPPUNIT_ASSERT_EQUAL(u"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"_ustr, parseDump("/root/page[2]/footer/txt/text()"_ostr)); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + CPPUNIT_ASSERT_EQUAL(u"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"_ustr, getXPathContent(pXmlDoc, "/root/page[2]/footer/txt/text()"_ostr)); } DECLARE_OOXMLEXPORT_TEST(testTableRowDataDisplayedTwice, "table-row-data-displayed-twice.docx") @@ -1179,17 +1180,18 @@ DECLARE_OOXMLEXPORT_TEST(testTdf90697_continuousBreaksComplex2,"tdf92724_continu DECLARE_OOXMLEXPORT_TEST(testTdf95367_inheritFollowStyle, "tdf95367_inheritFollowStyle.docx") { - CPPUNIT_ASSERT_EQUAL(u"header"_ustr, parseDump("/root/page[2]/header/txt/text()"_ostr)); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + CPPUNIT_ASSERT_EQUAL(u"header"_ustr, getXPathContent(pXmlDoc, "/root/page[2]/header/txt/text()"_ostr)); } DECLARE_OOXMLEXPORT_TEST(testInheritFirstHeader,"inheritFirstHeader.docx") { -// First page headers always link to last used first header, never to a follow header - CPPUNIT_ASSERT_EQUAL(u"First Header"_ustr, parseDump("/root/page[1]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(u"Follow Header"_ustr, parseDump("/root/page[2]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(u"Follow Header"_ustr, parseDump("/root/page[3]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(u"First Header"_ustr, parseDump("/root/page[4]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(u"Last Header"_ustr, parseDump("/root/page[5]/header/txt/text()"_ostr)); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + CPPUNIT_ASSERT_EQUAL(u"First Header"_ustr, getXPathContent(pXmlDoc, "/root/page[1]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(u"Follow Header"_ustr, getXPathContent(pXmlDoc, "/root/page[2]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(u"Follow Header"_ustr, getXPathContent(pXmlDoc, "/root/page[3]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(u"First Header"_ustr, getXPathContent(pXmlDoc, "/root/page[4]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(u"Last Header"_ustr, getXPathContent(pXmlDoc, "/root/page[5]/header/txt/text()"_ostr)); } #if HAVE_MORE_FONTS diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx index 592853bc6910..68bb65cdca67 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx @@ -1082,57 +1082,58 @@ DECLARE_OOXMLEXPORT_TEST(testTDF87348, "tdf87348_linkedTextboxes.docx") { int followCount=0; int precedeCount=0; - if( !parseDump("/root/page/body/txt/anchored/fly[1]/txt"_ostr,"follow"_ostr).isEmpty() ) + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + if( hasXPathAttribute(pXmlDoc, "/root/page/body/txt/anchored/fly[1]/txt"_ostr,"follow"_ostr) ) followCount++; - if( !parseDump("/root/page/body/txt/anchored/fly[1]/txt"_ostr,"precede"_ostr).isEmpty() ) + if( hasXPathAttribute(pXmlDoc, "/root/page/body/txt/anchored/fly[1]/txt"_ostr,"precede"_ostr) ) precedeCount++; - if( !parseDump("/root/page/body/txt/anchored/fly[2]/txt"_ostr,"follow"_ostr).isEmpty() ) + if( hasXPathAttribute(pXmlDoc, "/root/page/body/txt/anchored/fly[2]/txt"_ostr,"follow"_ostr) ) followCount++; - if( !parseDump("/root/page/body/txt/anchored/fly[2]/txt"_ostr,"precede"_ostr).isEmpty() ) + if( hasXPathAttribute(pXmlDoc, "/root/page/body/txt/anchored/fly[2]/txt"_ostr,"precede"_ostr) ) precedeCount++; - if( !parseDump("/root/page/body/txt/anchored/fly[3]/txt"_ostr,"follow"_ostr).isEmpty() ) + if( hasXPathAttribute(pXmlDoc, "/root/page/body/txt/anchored/fly[3]/txt"_ostr,"follow"_ostr) ) followCount++; - if( !parseDump("/root/page/body/txt/anchored/fly[3]/txt"_ostr,"precede"_ostr).isEmpty() ) + if( hasXPathAttribute(pXmlDoc, "/root/page/body/txt/anchored/fly[3]/txt"_ostr,"precede"_ostr) ) precedeCount++; - if( !parseDump("/root/page/body/txt/anchored/fly[4]/txt"_ostr,"follow"_ostr).isEmpty() ) + if( hasXPathAttribute(pXmlDoc, "/root/page/body/txt/anchored/fly[4]/txt"_ostr,"follow"_ostr) ) followCount++; - if( !parseDump("/root/page/body/txt/anchored/fly[4]/txt"_ostr,"precede"_ostr).isEmpty() ) + if( hasXPathAttribute(pXmlDoc, "/root/page/body/txt/anchored/fly[4]/txt"_ostr,"precede"_ostr) ) precedeCount++; - if( !parseDump("/root/page/body/txt/anchored/fly[5]/txt"_ostr,"follow"_ostr).isEmpty() ) + if( hasXPathAttribute(pXmlDoc, "/root/page/body/txt/anchored/fly[5]/txt"_ostr,"follow"_ostr) ) followCount++; - if( !parseDump("/root/page/body/txt/anchored/fly[5]/txt"_ostr,"precede"_ostr).isEmpty() ) + if( hasXPathAttribute(pXmlDoc, "/root/page/body/txt/anchored/fly[5]/txt"_ostr,"precede"_ostr) ) precedeCount++; - if( !parseDump("/root/page/body/txt/anchored/fly[6]/txt"_ostr,"follow"_ostr).isEmpty() ) + if( hasXPathAttribute(pXmlDoc, "/root/page/body/txt/anchored/fly[6]/txt"_ostr,"follow"_ostr) ) followCount++; - if( !parseDump("/root/page/body/txt/anchored/fly[6]/txt"_ostr,"precede"_ostr).isEmpty() ) + if( hasXPathAttribute(pXmlDoc, "/root/page/body/txt/anchored/fly[6]/txt"_ostr,"precede"_ostr) ) precedeCount++; - if( !parseDump("/root/page/body/txt/anchored/fly[7]/txt"_ostr,"follow"_ostr).isEmpty() ) + if( hasXPathAttribute(pXmlDoc, "/root/page/body/txt/anchored/fly[7]/txt"_ostr,"follow"_ostr) ) followCount++; - if( !parseDump("/root/page/body/txt/anchored/fly[7]/txt"_ostr,"precede"_ostr).isEmpty() ) + if( hasXPathAttribute(pXmlDoc, "/root/page/body/txt/anchored/fly[7]/txt"_ostr,"precede"_ostr) ) precedeCount++; - if( !parseDump("/root/page/body/txt/anchored/fly[8]/txt"_ostr,"follow"_ostr).isEmpty() ) + if( hasXPathAttribute(pXmlDoc, "/root/page/body/txt/anchored/fly[8]/txt"_ostr,"follow"_ostr) ) followCount++; - if( !parseDump("/root/page/body/txt/anchored/fly[8]/txt"_ostr,"precede"_ostr).isEmpty() ) + if( hasXPathAttribute(pXmlDoc, "/root/page/body/txt/anchored/fly[8]/txt"_ostr,"precede"_ostr) ) precedeCount++; - if( !parseDump("/root/page/body/txt/anchored/fly[9]/txt"_ostr,"follow"_ostr).isEmpty() ) + if( hasXPathAttribute(pXmlDoc, "/root/page/body/txt/anchored/fly[9]/txt"_ostr,"follow"_ostr) ) followCount++; - if( !parseDump("/root/page/body/txt/anchored/fly[9]/txt"_ostr,"precede"_ostr).isEmpty() ) + if( hasXPathAttribute(pXmlDoc, "/root/page/body/txt/anchored/fly[9]/txt"_ostr,"precede"_ostr) ) precedeCount++; - if( !parseDump("/root/page/body/txt/anchored/fly[10]/txt"_ostr,"follow"_ostr).isEmpty() ) + if( hasXPathAttribute(pXmlDoc, "/root/page/body/txt/anchored/fly[10]/txt"_ostr,"follow"_ostr) ) followCount++; - if( !parseDump("/root/page/body/txt/anchored/fly[10]/txt"_ostr,"precede"_ostr).isEmpty() ) + if( hasXPathAttribute(pXmlDoc, "/root/page/body/txt/anchored/fly[10]/txt"_ostr,"precede"_ostr) ) precedeCount++; - if( !parseDump("/root/page/body/txt/anchored/fly[11]/txt"_ostr,"follow"_ostr).isEmpty() ) + if( hasXPathAttribute(pXmlDoc, "/root/page/body/txt/anchored/fly[11]/txt"_ostr,"follow"_ostr) ) followCount++; - if( !parseDump("/root/page/body/txt/anchored/fly[11]/txt"_ostr,"precede"_ostr).isEmpty() ) + if( hasXPathAttribute(pXmlDoc, "/root/page/body/txt/anchored/fly[11]/txt"_ostr,"precede"_ostr) ) precedeCount++; - if( !parseDump("/root/page/body/txt/anchored/fly[12]/txt"_ostr,"follow"_ostr).isEmpty() ) + if( hasXPathAttribute(pXmlDoc, "/root/page/body/txt/anchored/fly[12]/txt"_ostr,"follow"_ostr) ) followCount++; - if( !parseDump("/root/page/body/txt/anchored/fly[12]/txt"_ostr,"precede"_ostr).isEmpty() ) + if( hasXPathAttribute(pXmlDoc, "/root/page/body/txt/anchored/fly[12]/txt"_ostr,"precede"_ostr) ) precedeCount++; - if( !parseDump("/root/page/body/txt/anchored/fly[13]/txt"_ostr,"follow"_ostr).isEmpty() ) + if( hasXPathAttribute(pXmlDoc, "/root/page/body/txt/anchored/fly[13]/txt"_ostr,"follow"_ostr) ) followCount++; - if( !parseDump("/root/page/body/txt/anchored/fly[13]/txt"_ostr,"precede"_ostr).isEmpty() ) + if( hasXPathAttribute(pXmlDoc, "/root/page/body/txt/anchored/fly[13]/txt"_ostr,"precede"_ostr) ) precedeCount++; //there should be 4 chains/13 linked textboxes (set of 5, set of 3, set of 3, set of 2) //that means 9 NEXT links and 9 PREV links. diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx index 8e25f62f46ea..1616352d19cf 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx @@ -187,8 +187,9 @@ DECLARE_OOXMLEXPORT_TEST(testN750255, "n750255.docx") Column break without columns on the page is a page break, so check those paragraphs are on page 2 and page 3 */ - CPPUNIT_ASSERT_EQUAL( u"one"_ustr, parseDump("/root/page[2]/body/txt/text()"_ostr) ); - CPPUNIT_ASSERT_EQUAL( u"two"_ustr, parseDump("/root/page[3]/body/txt/text()"_ostr) ); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + CPPUNIT_ASSERT_EQUAL( u"one"_ustr, getXPathContent(pXmlDoc, "/root/page[2]/body/txt/text()"_ostr) ); + CPPUNIT_ASSERT_EQUAL( u"two"_ustr, getXPathContent(pXmlDoc, "/root/page[3]/body/txt/text()"_ostr) ); } DECLARE_OOXMLEXPORT_TEST(testN652364, "n652364.docx") @@ -527,7 +528,8 @@ DECLARE_OOXMLEXPORT_TEST(testN780853, "n780853.docx") DECLARE_OOXMLEXPORT_TEST(testN780843, "n780843.docx") { - CPPUNIT_ASSERT_EQUAL(u"shown footer"_ustr, parseDump("/root/page[2]/footer/txt/text()"_ostr)); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); -e ... etc. - the rest is truncated