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 <xiscofauli@libreoffice.org>
Tested-by: Jenkins
This commit is contained in:
Xisco Fauli
2024-07-30 13:49:32 +02:00
parent 4f0c25dda4
commit 3371a9b36f
44 changed files with 630 additions and 461 deletions
+4
View File
@@ -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);
+139 -91
View File
@@ -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());
}
+4 -3
View File
@@ -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
+16 -10
View File
@@ -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
+3 -1
View File
@@ -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:
+2 -2
View File
@@ -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
+3 -1
View File
@@ -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);
+32 -20
View File
@@ -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());
}
+16 -10
View File
@@ -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);
}
+12 -7
View File
@@ -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")
+3 -2
View File
@@ -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));
+35 -25
View File
@@ -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()
);
}
+7 -5
View File
@@ -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);
+11 -7
View File
@@ -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());
}
+5 -3
View File
@@ -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);
}
+25 -17
View File
@@ -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,
+11 -8
View File
@@ -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
+8 -6
View File
@@ -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")
+15 -14
View File
@@ -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);
}
+7 -5
View File
@@ -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".
+12 -6
View File
@@ -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
+2 -1
View File
@@ -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);
+10 -8
View File
@@ -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
+27 -26
View File
@@ -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.
+9 -6
View File
@@ -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();
CPPUNIT_ASSERT_EQUAL(u"shown footer"_ustr, getXPathContent(pXmlDoc, "/root/page[2]/footer/txt/text()"_ostr));
//tdf64372 this document should only have one page break (2 pages, not 3)
CPPUNIT_ASSERT_EQUAL(2, getPages());
@@ -683,9 +685,10 @@ DECLARE_OOXMLEXPORT_TEST(testN793262, "n793262.docx")
DECLARE_OOXMLEXPORT_TEST(testN793998, "n793998.docx")
{
sal_Int32 nTextPortion = parseDump("/root/page/body/txt/SwParaPortion/SwLineLayout/child::*[1]"_ostr, "width"_ostr).toInt32(); // Width of the first (text) portion
sal_Int32 nTabPortion = parseDump("/root/page/body/txt/SwParaPortion/SwLineLayout/child::*[2]"_ostr, "width"_ostr).toInt32(); // Width of the second (tab) portion
sal_Int32 nParagraph = parseDump("/root/page/body/txt/infos/bounds"_ostr, "width"_ostr).toInt32(); // Width of the paragraph
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
sal_Int32 nTextPortion = getXPath(pXmlDoc, "/root/page/body/txt/SwParaPortion/SwLineLayout/child::*[1]"_ostr, "width"_ostr).toInt32(); // Width of the first (text) portion
sal_Int32 nTabPortion = getXPath(pXmlDoc, "/root/page/body/txt/SwParaPortion/SwLineLayout/child::*[2]"_ostr, "width"_ostr).toInt32(); // Width of the second (tab) portion
sal_Int32 nParagraph = getXPath(pXmlDoc, "/root/page/body/txt/infos/bounds"_ostr, "width"_ostr).toInt32(); // Width of the paragraph
sal_Int32 const nRightMargin = 3000;
// The problem was that the tab portion didn't ignore the right margin, so text + tab width wasn't larger than body (paragraph - right margin) width.
CPPUNIT_ASSERT(nTextPortion + nTabPortion > nParagraph - nRightMargin);
+2 -1
View File
@@ -707,7 +707,8 @@ DECLARE_OOXMLEXPORT_TEST(testTdf84678, "tdf84678.docx")
{
// This was 0, left margin inside a shape+text wasn't imported from DOCX.
// 360000 EMU, but layout uses twips.
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(567), parseDump("/root/page/body/txt/anchored/fly/infos/prtBounds"_ostr, "left"_ostr).toInt32());
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(567), getXPath(pXmlDoc, "/root/page/body/txt/anchored/fly/infos/prtBounds"_ostr, "left"_ostr).toInt32());
}
+13 -8
View File
@@ -369,14 +369,15 @@ CPPUNIT_TEST_FIXTURE(Test, testN766477)
CPPUNIT_TEST_FIXTURE(Test, testTdf130804)
{
createSwDoc("tdf130804.docx");
OUString flyHeight = parseDump("/root/page/body/txt[1]/infos/bounds"_ostr, "height"_ostr);
OUString txtHeight = parseDump("/root/page/body/txt[1]/anchored/fly/infos/bounds"_ostr, "height"_ostr);
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
OUString flyHeight = getXPath(pXmlDoc, "/root/page/body/txt[1]/infos/bounds"_ostr, "height"_ostr);
OUString txtHeight = getXPath(pXmlDoc, "/root/page/body/txt[1]/anchored/fly/infos/bounds"_ostr, "height"_ostr);
//Without the fix in place, txtHeight would have been flyHeight + 55
CPPUNIT_ASSERT_EQUAL(flyHeight, txtHeight);
// Also check the bookmark portion is ignored in the next paragraph
OUString aTop = parseDump("/root/page/body/txt[2]/infos/prtBounds"_ostr, "top"_ostr);
OUString aTop = getXPath(pXmlDoc, "/root/page/body/txt[2]/infos/prtBounds"_ostr, "top"_ostr);
CPPUNIT_ASSERT_EQUAL(u"240"_ustr, aTop);
}
@@ -798,7 +799,8 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf105127)
CPPUNIT_TEST_FIXTURE(Test, testTdf105143)
{
createSwDoc("tdf105143.docx");
OUString aTop = parseDump("/root/page/body/txt/anchored/SwAnchoredDrawObject/bounds"_ostr, "top"_ostr);
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
OUString aTop = getXPath(pXmlDoc, "/root/page/body/txt/anchored/SwAnchoredDrawObject/bounds"_ostr, "top"_ostr);
// This was 6272, i.e. the shape was moved up (incorrect position) to be
// inside the page rectangle.
CPPUNIT_ASSERT_EQUAL(u"6731"_ustr, aTop);
@@ -1032,7 +1034,8 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf75573)
lcl_countTextFrames( mxComponent, 1 );
// the frame should be on page 1
CPPUNIT_ASSERT_EQUAL( u"lorem ipsum"_ustr, parseDump("/root/page[1]/body/section/txt/anchored/fly/txt[1]/text()"_ostr) );
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
CPPUNIT_ASSERT_EQUAL( u"lorem ipsum"_ustr, getXPathContent(pXmlDoc, "/root/page[1]/body/section/txt/anchored/fly/txt[1]/text()"_ostr) );
// the "Proprietary" style should set the vertical and horizontal anchors to the page
uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY);
@@ -1235,7 +1238,8 @@ CPPUNIT_TEST_FIXTURE(Test, testUnbalancedColumnsCompat)
CPPUNIT_TEST_FIXTURE(Test, testFloatingTableSectionColumns)
{
createSwDoc("floating-table-section-columns.docx");
OUString tableWidth = parseDump("/root/page[1]/body/section/column[2]/body/txt/anchored/fly/tab/infos/bounds"_ostr, "width"_ostr);
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
OUString tableWidth = getXPath(pXmlDoc, "/root/page[1]/body/section/column[2]/body/txt/anchored/fly/tab/infos/bounds"_ostr, "width"_ostr);
// table width was restricted by a column
CPPUNIT_ASSERT( tableWidth.toInt32() > 10000 );
}
@@ -1513,8 +1517,9 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf122717)
CPPUNIT_TEST_FIXTURE(Test, testTdf98882)
{
createSwDoc("tdf98882.docx");
sal_Int32 nFlyHeight = parseDump("//anchored/fly/infos/bounds"_ostr, "height"_ostr).toInt32();
sal_Int32 nContentHeight = parseDump("//notxt/infos/bounds"_ostr, "height"_ostr).toInt32();
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
sal_Int32 nFlyHeight = getXPath(pXmlDoc, "//anchored/fly/infos/bounds"_ostr, "height"_ostr).toInt32();
sal_Int32 nContentHeight = getXPath(pXmlDoc, "//notxt/infos/bounds"_ostr, "height"_ostr).toInt32();
// The content height was 600, not 360, so the frame and the content height did not match.
CPPUNIT_ASSERT_EQUAL(nFlyHeight, nContentHeight);
}
+15 -9
View File
@@ -303,7 +303,8 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf114212)
// Without the accompanying fix in place, this test would have failed with:
// - Expected: 1428
// - Actual : 387
OUString aTop = parseDump("//anchored/fly[1]/infos/bounds"_ostr, "top"_ostr);
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
OUString aTop = getXPath(pXmlDoc, "//anchored/fly[1]/infos/bounds"_ostr, "top"_ostr);
CPPUNIT_ASSERT_EQUAL(u"1428"_ustr, aTop);
}
@@ -452,9 +453,11 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf124600)
// Make sure that "Shape 1 text" (anchored in the header) has the same left margin as the body
// text.
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
OUString aShapeTextLeft
= parseDump("/root/page/header/txt/anchored/fly/infos/bounds"_ostr, "left"_ostr);
OUString aBodyTextLeft = parseDump("/root/page/body/txt/infos/bounds"_ostr, "left"_ostr);
= getXPath(pXmlDoc, "/root/page/header/txt/anchored/fly/infos/bounds"_ostr, "left"_ostr);
OUString aBodyTextLeft
= getXPath(pXmlDoc, "/root/page/body/txt/infos/bounds"_ostr, "left"_ostr);
// Without the accompanying fix in place, this test would have failed with:
// - Expected: 1701
// - Actual : 1815
@@ -468,9 +471,11 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf120548)
createSwDoc("tdf120548.docx");
// Without the accompanying fix in place, this test would have failed with 'Expected: 00ff0000;
// Actual: ffffffff', i.e. the numbering portion was black, not red.
CPPUNIT_ASSERT_EQUAL(
u"00ff0000"_ustr,
parseDump("//SwFieldPortion[@type='PortionType::Number']/SwFont"_ostr, "color"_ostr));
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
CPPUNIT_ASSERT_EQUAL(u"00ff0000"_ustr,
getXPath(pXmlDoc,
"//SwFieldPortion[@type='PortionType::Number']/SwFont"_ostr,
"color"_ostr));
}
CPPUNIT_TEST_FIXTURE(Test, test120551)
@@ -634,7 +639,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf112443)
getShape(1)->getSize().Width, getShape(1)->getSize().Height);
CPPUNIT_ASSERT_MESSAGE("The textframe must be off-page!", !aPageRect.Contains(aShapeRect));
//OUString aTop = parseDump("//anchored/fly[1]/infos/bounds", "top");
//OUString aTop = getXPath(pXmlDoc, "//anchored/fly[1]/infos/bounds", "top");
//CPPUNIT_ASSERT_EQUAL(sal_Int32(30624), aTop.toInt32() );
}
@@ -688,8 +693,9 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf104167)
CPPUNIT_TEST_FIXTURE(Test, testTdf113946)
{
createSwDoc("tdf113946.docx");
OUString aTop
= parseDump("/root/page/body/txt/anchored/SwAnchoredDrawObject/bounds"_ostr, "top"_ostr);
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
OUString aTop = getXPath(
pXmlDoc, "/root/page/body/txt/anchored/SwAnchoredDrawObject/bounds"_ostr, "top"_ostr);
// tdf#106792 Checked loading of tdf113946.docx. Before the change, the expected
// value of this test was "1696". Opening the file shows a single short line anchored
// at the doc start. Only diff is that in 'old' version it is slightly rotated, in 'new'
+5 -2
View File
@@ -360,8 +360,11 @@ CPPUNIT_TEST_FIXTURE(Test, testFdo44176)
// given a document with an empty first header, and a non-empty follow header,
// ensure that the body text space is equal on the first and follow page
// (since in this case the default margins are large enough to fully include the header)
const OUString sBodyHeight = parseDump("//page[1]/body/infos"_ostr, "height"_ostr);
CPPUNIT_ASSERT_EQUAL(sBodyHeight, parseDump("//page[2]/body/infos"_ostr, "height"_ostr));
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
const OUString sBodyHeight
= getXPath(pXmlDoc, "//page[1]/body/infos/bounds"_ostr, "height"_ostr);
CPPUNIT_ASSERT_EQUAL(sBodyHeight,
getXPath(pXmlDoc, "//page[2]/body/infos/bounds"_ostr, "height"_ostr));
};
createSwDoc("fdo44176.rtf");
verify();
+5 -3
View File
@@ -270,16 +270,18 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf115180)
// On export to RTF, column separator positions were written without taking base width
// into account and then arrived huge, ~64000, which resulted in wrong table and cell widths
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
sal_Int32 rowWidth
= parseDump("/root/page/body/tab/row/infos/bounds"_ostr, "width"_ostr).toInt32();
= getXPath(pXmlDoc, "/root/page/body/tab/row/infos/bounds"_ostr, "width"_ostr)
.toInt32();
CPPUNIT_ASSERT_EQUAL_MESSAGE("Row width", sal_Int32(9360), rowWidth);
sal_Int32 cell1Width
= parseDump("/root/page/body/tab/row/cell[1]/infos/bounds"_ostr, "width"_ostr)
= getXPath(pXmlDoc, "/root/page/body/tab/row/cell[1]/infos/bounds"_ostr, "width"_ostr)
.toInt32();
CPPUNIT_ASSERT_MESSAGE("First cell width", cell1Width >= 9140);
CPPUNIT_ASSERT_MESSAGE("First cell width", cell1Width <= 9142);
sal_Int32 cell2Width
= parseDump("/root/page/body/tab/row/cell[2]/infos/bounds"_ostr, "width"_ostr)
= getXPath(pXmlDoc, "/root/page/body/tab/row/cell[2]/infos/bounds"_ostr, "width"_ostr)
.toInt32();
CPPUNIT_ASSERT_MESSAGE("Second cell width", cell2Width >= 218);
CPPUNIT_ASSERT_MESSAGE("Second cell width", cell2Width <= 220);
+34 -24
View File
@@ -1006,41 +1006,51 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf103956)
// suitable width. Currently there is no good support for autofit for RTF docs, so ensure
// that table cells are somehow visible. Width for it is not clear, so here we will check
// table & cell widths are more than default minimal value of 41.
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
CPPUNIT_ASSERT_MESSAGE(
"Table #1 is too narrow!",
82 < parseDump("/root/page/body/tab[1]/row/infos/bounds"_ostr, "width"_ostr).toInt32());
CPPUNIT_ASSERT_MESSAGE(
"Table #1 cell#1 is too narrow!",
41 < parseDump("/root/page/body/tab[1]/row/cell[1]/infos/bounds"_ostr, "width"_ostr)
.toInt32());
CPPUNIT_ASSERT_MESSAGE(
"Table #1 cell#2 is too narrow!",
41 < parseDump("/root/page/body/tab[1]/row/cell[2]/infos/bounds"_ostr, "width"_ostr)
82 < getXPath(pXmlDoc, "/root/page/body/tab[1]/row/infos/bounds"_ostr, "width"_ostr)
.toInt32());
CPPUNIT_ASSERT_MESSAGE("Table #1 cell#1 is too narrow!",
41 < getXPath(pXmlDoc,
"/root/page/body/tab[1]/row/cell[1]/infos/bounds"_ostr,
"width"_ostr)
.toInt32());
CPPUNIT_ASSERT_MESSAGE("Table #1 cell#2 is too narrow!",
41 < getXPath(pXmlDoc,
"/root/page/body/tab[1]/row/cell[2]/infos/bounds"_ostr,
"width"_ostr)
.toInt32());
CPPUNIT_ASSERT_MESSAGE(
"Table #2 is too narrow!",
82 < parseDump("/root/page/body/tab[2]/row/infos/bounds"_ostr, "width"_ostr).toInt32());
CPPUNIT_ASSERT_MESSAGE(
"Table #2 cell#1 is too narrow!",
41 < parseDump("/root/page/body/tab[2]/row/cell[1]/infos/bounds"_ostr, "width"_ostr)
.toInt32());
CPPUNIT_ASSERT_MESSAGE(
"Table #2 cell#2 is too narrow!",
41 < parseDump("/root/page/body/tab[2]/row/cell[2]/infos/bounds"_ostr, "width"_ostr)
82 < getXPath(pXmlDoc, "/root/page/body/tab[2]/row/infos/bounds"_ostr, "width"_ostr)
.toInt32());
CPPUNIT_ASSERT_MESSAGE("Table #2 cell#1 is too narrow!",
41 < getXPath(pXmlDoc,
"/root/page/body/tab[2]/row/cell[1]/infos/bounds"_ostr,
"width"_ostr)
.toInt32());
CPPUNIT_ASSERT_MESSAGE("Table #2 cell#2 is too narrow!",
41 < getXPath(pXmlDoc,
"/root/page/body/tab[2]/row/cell[2]/infos/bounds"_ostr,
"width"_ostr)
.toInt32());
CPPUNIT_ASSERT_MESSAGE(
"Table #3 is too narrow!",
82 < parseDump("/root/page/body/tab[3]/row/infos/bounds"_ostr, "width"_ostr).toInt32());
CPPUNIT_ASSERT_MESSAGE(
"Table #3 cell#1 is too narrow!",
41 < parseDump("/root/page/body/tab[3]/row/cell[1]/infos/bounds"_ostr, "width"_ostr)
.toInt32());
CPPUNIT_ASSERT_MESSAGE(
"Table #3 cell#2 is too narrow!",
41 < parseDump("/root/page/body/tab[3]/row/cell[2]/infos/bounds"_ostr, "width"_ostr)
82 < getXPath(pXmlDoc, "/root/page/body/tab[3]/row/infos/bounds"_ostr, "width"_ostr)
.toInt32());
CPPUNIT_ASSERT_MESSAGE("Table #3 cell#1 is too narrow!",
41 < getXPath(pXmlDoc,
"/root/page/body/tab[3]/row/cell[1]/infos/bounds"_ostr,
"width"_ostr)
.toInt32());
CPPUNIT_ASSERT_MESSAGE("Table #3 cell#2 is too narrow!",
41 < getXPath(pXmlDoc,
"/root/page/body/tab[3]/row/cell[2]/infos/bounds"_ostr,
"width"_ostr)
.toInt32());
};
createSwDoc("tdf103956.rtf");
verify();
+15 -7
View File
@@ -133,11 +133,17 @@ CPPUNIT_TEST_FIXTURE(Test, testFdo49893_2)
{
auto verify = [this]() {
// Ensure that header text exists on each page (especially on second page)
CPPUNIT_ASSERT_EQUAL(u"HEADER"_ustr, parseDump("/root/page[1]/header/txt/text()"_ostr));
CPPUNIT_ASSERT_EQUAL(u"HEADER"_ustr, parseDump("/root/page[2]/header/txt/text()"_ostr));
CPPUNIT_ASSERT_EQUAL(u"HEADER"_ustr, parseDump("/root/page[3]/header/txt/text()"_ostr));
CPPUNIT_ASSERT_EQUAL(u"HEADER"_ustr, parseDump("/root/page[4]/header/txt/text()"_ostr));
CPPUNIT_ASSERT_EQUAL(u"HEADER"_ustr, parseDump("/root/page[5]/header/txt/text()"_ostr));
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
CPPUNIT_ASSERT_EQUAL(u"HEADER"_ustr,
getXPathContent(pXmlDoc, "/root/page[1]/header/txt/text()"_ostr));
CPPUNIT_ASSERT_EQUAL(u"HEADER"_ustr,
getXPathContent(pXmlDoc, "/root/page[2]/header/txt/text()"_ostr));
CPPUNIT_ASSERT_EQUAL(u"HEADER"_ustr,
getXPathContent(pXmlDoc, "/root/page[3]/header/txt/text()"_ostr));
CPPUNIT_ASSERT_EQUAL(u"HEADER"_ustr,
getXPathContent(pXmlDoc, "/root/page[4]/header/txt/text()"_ostr));
CPPUNIT_ASSERT_EQUAL(u"HEADER"_ustr,
getXPathContent(pXmlDoc, "/root/page[5]/header/txt/text()"_ostr));
CPPUNIT_ASSERT_EQUAL(5, getPages()); // Word has 5
};
createSwDoc("fdo49893-2.rtf");
@@ -1034,9 +1040,11 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf118047)
getProperty<sal_Int32>(getParagraph(1), u"ParaBottomMargin"_ustr));
// Same for header, it should not derive props from "Normal" style
CPPUNIT_ASSERT_EQUAL(u"Header"_ustr, parseDump("/root/page[1]/header/txt/text()"_ostr));
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
CPPUNIT_ASSERT_EQUAL(u"Header"_ustr,
getXPathContent(pXmlDoc, "/root/page[1]/header/txt/text()"_ostr));
sal_Int32 nHeight
= parseDump("/root/page[1]/header/infos/bounds"_ostr, "height"_ostr).toInt32();
= getXPath(pXmlDoc, "/root/page[1]/header/infos/bounds"_ostr, "height"_ostr).toInt32();
CPPUNIT_ASSERT_MESSAGE("Header is too large", 1000 > nHeight);
};
createSwDoc("tdf118047.rtf");
+21 -10
View File
@@ -164,7 +164,8 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf158586_lostFrame)
// The anchor and align properties are sufficient to define a frame
xmlDocUniquePtr pLayout = parseLayoutDump();
assertXPath(pLayout, "//anchored"_ostr, 1);
assertXPathContent(pLayout, "//page[1]/body//txt"_ostr, u"1st page"_ustr);
assertXPathContent(pLayout, "//page[1]/body//txt"_ostr,
u"First page textbox 1st page"_ustr);
assertXPathContent(pLayout, "//page[2]/body//txt"_ostr, u"2nd page"_ustr);
CPPUNIT_ASSERT_EQUAL(2, getPages());
@@ -423,11 +424,14 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf160976_headerFooter)
// Sanity check - always good to test when dealing with page styles and breaks.
CPPUNIT_ASSERT_EQUAL(3, getPages());
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
CPPUNIT_ASSERT_EQUAL(u"First page first footer"_ustr,
parseDump("/root/page[1]/footer/txt"_ostr));
CPPUNIT_ASSERT_EQUAL(u"First Left"_ustr, parseDump("/root/page[2]/footer/txt"_ostr));
getXPathContent(pXmlDoc, "/root/page[1]/footer/txt"_ostr));
CPPUNIT_ASSERT_EQUAL(u"First Left"_ustr,
getXPathContent(pXmlDoc, "/root/page[2]/footer/txt"_ostr));
if (!bIsExported)
CPPUNIT_ASSERT_EQUAL(u"First Right"_ustr, parseDump("/root/page[3]/footer/txt"_ostr));
CPPUNIT_ASSERT_EQUAL(u"First Right"_ustr,
getXPathContent(pXmlDoc, "/root/page[3]/footer/txt"_ostr));
};
createSwDoc("tdf160976_headerFooter.odt");
verify();
@@ -443,10 +447,13 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf160976_headerFooter2)
// Sanity check - always good to test when dealing with page styles and breaks.
CPPUNIT_ASSERT_EQUAL(3, getPages());
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
CPPUNIT_ASSERT_EQUAL(u"First page first footer"_ustr,
parseDump("/root/page[1]/footer/txt"_ostr));
CPPUNIT_ASSERT_EQUAL(u"First page footer"_ustr, parseDump("/root/page[2]/footer/txt"_ostr));
CPPUNIT_ASSERT_EQUAL(u"Default footer"_ustr, parseDump("/root/page[3]/footer/txt"_ostr));
getXPathContent(pXmlDoc, "/root/page[1]/footer/txt"_ostr));
CPPUNIT_ASSERT_EQUAL(u"First page footer"_ustr,
getXPathContent(pXmlDoc, "/root/page[2]/footer/txt"_ostr));
CPPUNIT_ASSERT_EQUAL(u"Default footer"_ustr,
getXPathContent(pXmlDoc, "/root/page[3]/footer/txt"_ostr));
};
createSwDoc("tdf160976_headerFooter2.odt");
verify();
@@ -461,9 +468,13 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf160976_headerFooter3)
// Sanity check - always good to test when dealing with page styles and breaks.
CPPUNIT_ASSERT_EQUAL(3, getPages());
CPPUNIT_ASSERT_EQUAL(u"First page footer"_ustr, parseDump("/root/page[1]/footer/txt"_ostr));
CPPUNIT_ASSERT_EQUAL(u"Default footer"_ustr, parseDump("/root/page[2]/footer/txt"_ostr));
CPPUNIT_ASSERT_EQUAL(u"Default footer"_ustr, parseDump("/root/page[3]/footer/txt"_ostr));
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
CPPUNIT_ASSERT_EQUAL(u"First page footer"_ustr,
getXPathContent(pXmlDoc, "/root/page[1]/footer/txt"_ostr));
CPPUNIT_ASSERT_EQUAL(u"Default footer"_ustr,
getXPathContent(pXmlDoc, "/root/page[2]/footer/txt"_ostr));
CPPUNIT_ASSERT_EQUAL(u"Default footer"_ustr,
getXPathContent(pXmlDoc, "/root/page[3]/footer/txt"_ostr));
};
createSwDoc("tdf160976_headerFooter3.odt");
verify();
+9 -5
View File
@@ -409,9 +409,11 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf112211_2)
createSwDoc("tdf112211-2.rtf");
// Spacing between the bullet and the actual text was too large.
// This is now around 269, large old value was 629.
int nWidth = parseDump("/root/page/body/txt[2]/SwParaPortion/SwLineLayout/"
"child::*[@type='PortionType::TabLeft']"_ostr,
"width"_ostr)
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
int nWidth = getXPath(pXmlDoc,
"/root/page/body/txt[2]/SwParaPortion/SwLineLayout/"
"child::*[@type='PortionType::TabLeft']"_ostr,
"width"_ostr)
.toInt32();
CPPUNIT_ASSERT_LESS(300, nWidth);
}
@@ -457,8 +459,10 @@ CPPUNIT_TEST_FIXTURE(Test, testFdo52052)
{
createSwDoc("fdo52052.rtf");
// Make sure the textframe containing the text "third" appears on the 3rd page.
CPPUNIT_ASSERT_EQUAL(u"third"_ustr,
parseDump("/root/page[3]/body/txt/anchored/fly/txt/text()"_ostr));
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
CPPUNIT_ASSERT_EQUAL(
u"third"_ustr,
getXPathContent(pXmlDoc, "/root/page[3]/body/txt/anchored/fly/txt/text()"_ostr));
}
CPPUNIT_TEST_FIXTURE(Test, testInk)
+16 -8
View File
@@ -507,8 +507,9 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf96536)
pWrtShell->InsertPageBreak();
pWrtShell->SttEndDoc(/*bStt=*/true);
calcLayout();
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
sal_Int32 nSingleParaPageHeight
= parseDump("/root/page[1]/infos/bounds"_ostr, "height"_ostr).toInt32();
= getXPath(pXmlDoc, "/root/page[1]/infos/bounds"_ostr, "height"_ostr).toInt32();
// Insert a 2nd paragraph at the end of the first page, so the page height grows at least twice...
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
@@ -517,15 +518,18 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf96536)
const uno::Reference<text::XTextRange> xInsertPos = getRun(getParagraph(1), 1);
xParagraphAppend->finishParagraphInsert(uno::Sequence<beans::PropertyValue>(), xInsertPos);
calcLayout();
CPPUNIT_ASSERT(parseDump("/root/page[1]/infos/bounds"_ostr, "height"_ostr).toInt32()
pXmlDoc = parseLayoutDump();
CPPUNIT_ASSERT(getXPath(pXmlDoc, "/root/page[1]/infos/bounds"_ostr, "height"_ostr).toInt32()
>= 2 * nSingleParaPageHeight);
// ... and then delete the 2nd paragraph, which shrinks the page to the previous size.
uno::Reference<lang::XComponent> xParagraph(getParagraph(2), uno::UNO_QUERY);
xParagraph->dispose();
calcLayout();
CPPUNIT_ASSERT_EQUAL(nSingleParaPageHeight,
parseDump("/root/page[1]/infos/bounds"_ostr, "height"_ostr).toInt32());
pXmlDoc = parseLayoutDump();
CPPUNIT_ASSERT_EQUAL(
nSingleParaPageHeight,
getXPath(pXmlDoc, "/root/page[1]/infos/bounds"_ostr, "height"_ostr).toInt32());
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf96479)
@@ -920,8 +924,10 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf96961)
calcLayout();
// Assert that the height of the last page is larger than the height of other pages.
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(nLast > nOther);
}
@@ -1932,7 +1938,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf107025)
if (!nWidth1)
return;
CPPUNIT_ASSERT(!parseDump("(//SwLinePortion)[2]"_ostr, "width"_ostr).isEmpty());
CPPUNIT_ASSERT(!getXPath(pXmlDoc, "(//SwLinePortion)[2]"_ostr, "width"_ostr).isEmpty());
sal_Int32 nWidth2 = getXPath(pXmlDoc, "(//SwLinePortion)[2]"_ostr, "width"_ostr).toInt32();
sal_Int32 nRatio = nWidth2 / nWidth1;
@@ -2285,9 +2291,11 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf58604)
// Allow linebreak character follows hanging punctuation immediately instead of
// breaking at the start of the next line.
createSwDoc("tdf58604.odt");
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
CPPUNIT_ASSERT_EQUAL(
OUString("PortionType::Break"),
parseDump("(/root/page/body/txt/SwParaPortion/SwLineLayout[1]/child::*)[last()]", "type"));
getXPath(pXmlDoc, "(/root/page/body/txt/SwParaPortion/SwLineLayout[1]/child::*)[last()]",
"type"));
#endif
}
+7 -4
View File
@@ -2412,10 +2412,13 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf34957)
// table with "keep with next" always started on a new page if the table was large,
// regardless of whether it was already kept with the previous paragraph,
// or whether the following paragraph actually fit on the same page (MAB 3.6 - 5.0)
CPPUNIT_ASSERT_EQUAL(u"Row 1"_ustr,
parseDump("/root/page[2]/body/tab[1]/row[2]/cell[1]/txt"_ostr));
CPPUNIT_ASSERT_EQUAL(u"Row 1"_ustr,
parseDump("/root/page[4]/body/tab[1]/row[2]/cell[1]/txt"_ostr));
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
CPPUNIT_ASSERT_EQUAL(
u"Row 1"_ustr,
getXPathContent(pXmlDoc, "/root/page[2]/body/tab[1]/row[2]/cell[1]/txt"_ostr));
CPPUNIT_ASSERT_EQUAL(
u"Row 1"_ustr,
getXPathContent(pXmlDoc, "/root/page[4]/body/tab[1]/row[2]/cell[1]/txt"_ostr));
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf89954)
+42 -29
View File
@@ -195,12 +195,13 @@ xray ThisComponent.DrawPage.getByIndex(0).BoundRect
DECLARE_WW8EXPORT_TEST(testTdf75539_relativeWidth, "tdf75539_relativeWidth.doc")
{
//divide everything by 10 to give a margin of error for rounding etc.
sal_Int32 pageWidth = parseDump("/root/page[1]/body/infos/bounds"_ostr, "width"_ostr).toInt32()/10;
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
sal_Int32 pageWidth = getXPath(pXmlDoc, "/root/page[1]/body/infos/bounds"_ostr, "width"_ostr).toInt32()/10;
CPPUNIT_ASSERT_EQUAL_MESSAGE("Page width", sal_Int32(9354/10), pageWidth);
CPPUNIT_ASSERT_EQUAL_MESSAGE("100% width line", pageWidth, parseDump("/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwLinePortion"_ostr, "width"_ostr).toInt32()/10);
CPPUNIT_ASSERT_EQUAL_MESSAGE("50% width line", pageWidth/2, parseDump("/root/page[1]/body/txt[4]/SwParaPortion/SwLineLayout/SwLinePortion"_ostr, "width"_ostr).toInt32()/10);
CPPUNIT_ASSERT_EQUAL_MESSAGE("25% width line", pageWidth/4, parseDump("/root/page[1]/body/txt[6]/SwParaPortion/SwLineLayout/SwLinePortion"_ostr, "width"_ostr).toInt32()/10);
CPPUNIT_ASSERT_EQUAL_MESSAGE("10% width line", pageWidth/10, parseDump("/root/page[1]/body/txt[8]/SwParaPortion/SwLineLayout/SwLinePortion"_ostr, "width"_ostr).toInt32()/10);
CPPUNIT_ASSERT_EQUAL_MESSAGE("100% width line", pageWidth, getXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwLinePortion"_ostr, "width"_ostr).toInt32()/10);
CPPUNIT_ASSERT_EQUAL_MESSAGE("50% width line", pageWidth/2, getXPath(pXmlDoc, "/root/page[1]/body/txt[4]/SwParaPortion/SwLineLayout/SwLinePortion"_ostr, "width"_ostr).toInt32()/10);
CPPUNIT_ASSERT_EQUAL_MESSAGE("25% width line", pageWidth/4, getXPath(pXmlDoc, "/root/page[1]/body/txt[6]/SwParaPortion/SwLineLayout/SwLinePortion"_ostr, "width"_ostr).toInt32()/10);
CPPUNIT_ASSERT_EQUAL_MESSAGE("10% width line", pageWidth/10, getXPath(pXmlDoc ,"/root/page[1]/body/txt[8]/SwParaPortion/SwLineLayout/SwLinePortion"_ostr, "width"_ostr).toInt32()/10);
}
DECLARE_WW8EXPORT_TEST(testN757905, "n757905.doc")
@@ -210,7 +211,8 @@ DECLARE_WW8EXPORT_TEST(testN757905, "n757905.doc")
// paragraph height. When in Word-compat mode, we should take the max of
// the two, not just the height of the fly.
OUString aHeight = parseDump("/root/page/body/txt/infos/bounds"_ostr, "height"_ostr);
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
OUString aHeight = getXPath(pXmlDoc, "/root/page/body/txt/infos/bounds"_ostr, "height"_ostr);
CPPUNIT_ASSERT(sal_Int32(31) < aHeight.toInt32());
}
@@ -259,7 +261,8 @@ DECLARE_WW8EXPORT_TEST(testN823651, "n823651.doc")
DECLARE_WW8EXPORT_TEST(testFdo36868, "fdo36868.doc")
{
OUString aText = parseDump("/root/page/body/txt[3]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']"_ostr, "expand"_ostr);
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
OUString aText = getXPath(pXmlDoc, "/root/page/body/txt[3]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']"_ostr, "expand"_ostr);
// This was 1.1.
CPPUNIT_ASSERT_EQUAL(u"2.1"_ustr, aText);
}
@@ -267,7 +270,8 @@ DECLARE_WW8EXPORT_TEST(testFdo36868, "fdo36868.doc")
DECLARE_WW8EXPORT_TEST(testListNolevel, "list-nolevel.doc")
{
// Similar to fdo#36868, numbering portions had wrong values.
OUString aText = parseDump("/root/page/body/txt[1]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']"_ostr, "expand"_ostr);
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
OUString aText = getXPath(pXmlDoc, "/root/page/body/txt[1]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']"_ostr, "expand"_ostr);
// PortionType::Number was completely missing.
CPPUNIT_ASSERT_EQUAL(u"1."_ustr, aText);
}
@@ -543,7 +547,8 @@ DECLARE_WW8EXPORT_TEST(testBnc787942, "bnc787942.doc")
{
// The frame ended up on the second page instead of first.
// this is on page 1 in Word
parseDump("/root/page[1]/body/txt[4]/anchored"_ostr);
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
CPPUNIT_ASSERT_EQUAL(u"Kralicek UsacekV lese 3Zviratkov 47025"_ustr, getXPathContent(pXmlDoc, "/root/page[1]/body/txt[4]/anchored"_ostr));
CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_PARALLEL, getProperty<text::WrapTextMode>(getShape(1), u"Surround"_ustr));
CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(getShape(1), u"HoriOrientRelation"_ustr));
@@ -568,10 +573,11 @@ DECLARE_WW8EXPORT_TEST(testLayoutHanging, "fdo68967.doc")
DECLARE_WW8EXPORT_TEST(testfdo68963, "fdo68963.doc")
{
// The problem was that the text was not displayed.
CPPUNIT_ASSERT ( !parseDump("/root/page/body/tab/row[2]/cell[1]/txt/SwParaPortion/SwLineLayout/SwFieldPortion"_ostr, "expand"_ostr).isEmpty() );
CPPUNIT_ASSERT_EQUAL( u"Topic 1"_ustr, parseDump("/root/page/body/tab/row[2]/cell[1]/txt/SwParaPortion/SwLineLayout/SwFieldPortion"_ostr, "expand"_ostr) );
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
CPPUNIT_ASSERT ( !getXPath(pXmlDoc, "/root/page/body/tab/row[2]/cell[1]/txt/SwParaPortion/SwLineLayout/SwFieldPortion"_ostr, "expand"_ostr).isEmpty() );
CPPUNIT_ASSERT_EQUAL( u"Topic 1"_ustr, getXPath(pXmlDoc, "/root/page/body/tab/row[2]/cell[1]/txt/SwParaPortion/SwLineLayout/SwFieldPortion"_ostr, "expand"_ostr) );
// all crossreference bookmarks should have a target. Shouldn't be any "Reference source not found" in the xml
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-1), parseDump("/root/page/body/txt[24]/SwParaPortion/SwLineLayout/SwFieldPortion[2]"_ostr,"expand"_ostr).indexOf("Reference source not found"));
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-1), getXPath(pXmlDoc, "/root/page/body/txt[24]/SwParaPortion/SwLineLayout/SwFieldPortion[2]"_ostr,"expand"_ostr).indexOf("Reference source not found"));
}
#endif
@@ -683,8 +689,9 @@ DECLARE_WW8EXPORT_TEST(testTdf112535, "tdf112535.doc")
DECLARE_WW8EXPORT_TEST(testTdf106291, "tdf106291.doc")
{
// Table cell was merged vertically instead of horizontally -> had incorrect dimensions
OUString cellWidth = parseDump("/root/page[1]/body/tab/row/cell[1]/infos/bounds"_ostr, "width"_ostr);
OUString cellHeight = parseDump("/root/page[1]/body/tab/row/cell[1]/infos/bounds"_ostr, "height"_ostr);
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
OUString cellWidth = getXPath(pXmlDoc, "/root/page[1]/body/tab/row/cell[1]/infos/bounds"_ostr, "width"_ostr);
OUString cellHeight = getXPath(pXmlDoc, "/root/page[1]/body/tab/row/cell[1]/infos/bounds"_ostr, "height"_ostr);
CPPUNIT_ASSERT_EQUAL(sal_Int32(8650), cellWidth.toInt32());
CPPUNIT_ASSERT(cellHeight.toInt32() > 200); // height might depend on font size
}
@@ -910,16 +917,18 @@ DECLARE_WW8EXPORT_TEST(testZoomType, "zoomtype.doc")
DECLARE_WW8EXPORT_TEST(test56513, "fdo56513.doc")
{
CPPUNIT_ASSERT_EQUAL(u"This is the header of the first section"_ustr, parseDump("/root/page[1]/header/txt/text()"_ostr));
CPPUNIT_ASSERT_EQUAL(u"This is the first page header of the second section"_ustr, parseDump("/root/page[2]/header/txt/text()"_ostr));
CPPUNIT_ASSERT_EQUAL(u"This is the non-first-page header of the second section"_ustr, parseDump("/root/page[3]/header/txt/text()"_ostr));
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
CPPUNIT_ASSERT_EQUAL(u"This is the header of the first section"_ustr, getXPathContent(pXmlDoc, "/root/page[1]/header/txt/text()"_ostr));
CPPUNIT_ASSERT_EQUAL(u"This is the first page header of the second section"_ustr, getXPathContent(pXmlDoc, "/root/page[2]/header/txt/text()"_ostr));
CPPUNIT_ASSERT_EQUAL(u"This is the non-first-page header of the second section"_ustr, getXPathContent(pXmlDoc, "/root/page[3]/header/txt/text()"_ostr));
}
DECLARE_WW8EXPORT_TEST(testNewPageStylesTable, "new-page-styles.doc")
{
CPPUNIT_ASSERT_EQUAL(u"Sigma Space Performance Goals and Results (Page 1)*"_ustr, parseDump("/root/page[1]/header/txt/text()"_ostr));
CPPUNIT_ASSERT_EQUAL(u"Sigma Space Performance Assessment (Page 2)****"_ustr, parseDump("/root/page[2]/header/txt/text()"_ostr));
CPPUNIT_ASSERT_EQUAL(u"Sigma Space Performance Goals: Next Year (Page 3)*******"_ustr, parseDump("/root/page[3]/header/txt/text()"_ostr));
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
CPPUNIT_ASSERT_EQUAL(u"Sigma Space Performance Goals and Results (Page 1)*"_ustr, getXPathContent(pXmlDoc, "/root/page[1]/header/txt/text()"_ostr));
CPPUNIT_ASSERT_EQUAL(u"Sigma Space Performance Assessment (Page 2)****"_ustr, getXPathContent(pXmlDoc, "/root/page[2]/header/txt/text()"_ostr));
CPPUNIT_ASSERT_EQUAL(u"Sigma Space Performance Goals: Next Year (Page 3)*******"_ustr, getXPathContent(pXmlDoc, "/root/page[3]/header/txt/text()"_ostr));
}
CPPUNIT_TEST_FIXTURE(Test, testFdo42144)
@@ -1428,8 +1437,9 @@ CPPUNIT_TEST_FIXTURE(Test, testTableKeep)
loadAndReload("tdf91083.odt");
CPPUNIT_ASSERT_EQUAL(7, getPages());
//emulate table "keep with next" -do not split table
CPPUNIT_ASSERT_EQUAL( u"Row 1"_ustr, parseDump("/root/page[3]/body/tab[1]/row[2]/cell[1]/txt[1]"_ostr) );
CPPUNIT_ASSERT_EQUAL( u"Row 1"_ustr, parseDump("/root/page[6]/body/tab[1]/row[2]/cell[1]/txt[1]"_ostr) );
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
CPPUNIT_ASSERT_EQUAL( u"Row 1"_ustr, getXPathContent(pXmlDoc, "/root/page[3]/body/tab[1]/row[2]/cell[1]/txt[1]"_ostr) );
CPPUNIT_ASSERT_EQUAL( u"Row 1"_ustr, getXPathContent(pXmlDoc, "/root/page[6]/body/tab[1]/row[2]/cell[1]/txt[1]"_ostr) );
}
#endif
@@ -1437,31 +1447,34 @@ CPPUNIT_TEST_FIXTURE(Test, tesTdf91083_tableKeep2)
{
loadAndReload("tdf91083_tableKeep2.odt");
//emulate table "keep with next" - split large row in order to keep with previous paragraph
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
CPPUNIT_ASSERT_EQUAL_MESSAGE("Table doesn't split, so it starts on page 2",
u"0"_ustr, parseDump("count(//page[1]//tab)"_ostr) );
u"0"_ustr, getXPathContent(pXmlDoc, "count(//page[1]//tab)"_ostr) );
CPPUNIT_ASSERT_EQUAL_MESSAGE("Page 2 starts with a paragraph/title, not a table",
u"KeepWithNext"_ustr, parseDump("//page[2]/body/txt[1]"_ostr) );
u"KeepWithNext"_ustr, getXPathContent(pXmlDoc, "//page[2]/body/txt[1]"_ostr) );
CPPUNIT_ASSERT_EQUAL_MESSAGE("Table sticks with previous paragraph, so it starts on page 2",
u"1"_ustr, parseDump("count(//page[2]//tab)"_ostr) );
u"1"_ustr, getXPathContent(pXmlDoc, "count(//page[2]//tab)"_ostr) );
CPPUNIT_ASSERT_MESSAGE("Row itself splits, not the table at a row boundary",
"Cell 2" != parseDump("//page[3]//tab//row[2]/cell[1]/txt[1]"_ostr) );
"Cell 2" != getXPathContent(pXmlDoc, "//page[3]//tab//row[2]/cell[1]/txt[1]"_ostr) );
}
CPPUNIT_TEST_FIXTURE(Test, tesTdf91083_tableKeep3)
{
loadAndReload("tdf91083_tableKeep3.odt");
CPPUNIT_ASSERT_EQUAL(3, getPages());
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
//emulate table "keep with next" - split single row table in order to keep with previous paragraph
CPPUNIT_ASSERT_EQUAL_MESSAGE("Table doesn't split, so it starts on page 2",
u"0"_ustr, parseDump("count(//page[1]//tab)"_ostr) );
u"0"_ustr, getXPathContent(pXmlDoc, "count(//page[1]//tab)"_ostr) );
CPPUNIT_ASSERT_EQUAL_MESSAGE("Table sticks with previous paragraph, so it starts on page 2",
u"1"_ustr, parseDump("count(//page[2]//tab)"_ostr) );
u"1"_ustr, getXPathContent(pXmlDoc, "count(//page[2]//tab)"_ostr) );
}
DECLARE_WW8EXPORT_TEST(testTdf76349_textboxMargins, "tdf76349_textboxMargins.doc")
{
// textboxes without borders were losing their spacing items in round-tripping
CPPUNIT_ASSERT( 0 < parseDump("/root/page/body/txt/anchored/fly/infos/prtBounds"_ostr, "left"_ostr).toInt32() );
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
CPPUNIT_ASSERT( 0 < getXPath(pXmlDoc, "/root/page/body/txt/anchored/fly/infos/prtBounds"_ostr, "left"_ostr).toInt32() );
uno::Reference<drawing::XShape> xShape = getShape(1);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Textbox background color", Color(0xD8, 0xD8, 0xD8), getProperty<Color>(xShape, u"BackColor"_ustr));
+7 -5
View File
@@ -50,11 +50,12 @@ public:
DECLARE_WW8EXPORT_TEST(testTdf99120, "tdf99120.doc")
{
CPPUNIT_ASSERT_EQUAL(u"Section 1, odd."_ustr, parseDump("/root/page[1]/header/txt/text()"_ostr));
CPPUNIT_ASSERT_EQUAL(u"Section 1, even."_ustr, parseDump("/root/page[2]/header/txt/text()"_ostr));
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
CPPUNIT_ASSERT_EQUAL(u"Section 1, odd."_ustr, getXPathContent(pXmlDoc, "/root/page[1]/header/txt/text()"_ostr));
CPPUNIT_ASSERT_EQUAL(u"Section 1, even."_ustr, getXPathContent(pXmlDoc, "/root/page[2]/header/txt/text()"_ostr));
// This failed: the header was empty on the 3rd page, as the first page header was shown.
CPPUNIT_ASSERT_EQUAL(u"Section 2, odd."_ustr, parseDump("/root/page[3]/header/txt/text()"_ostr));
CPPUNIT_ASSERT_EQUAL(u"Section 2, even."_ustr, parseDump("/root/page[4]/header/txt/text()"_ostr));
CPPUNIT_ASSERT_EQUAL(u"Section 2, odd."_ustr, getXPathContent(pXmlDoc, "/root/page[3]/header/txt/text()"_ostr));
CPPUNIT_ASSERT_EQUAL(u"Section 2, even."_ustr, getXPathContent(pXmlDoc, "/root/page[4]/header/txt/text()"_ostr));
}
CPPUNIT_TEST_FIXTURE(Test, testTdf41542_borderlessPadding)
@@ -137,7 +138,8 @@ DECLARE_WW8EXPORT_TEST(testTdf37153, "tdf37153_considerWrapOnObjPos.doc")
DECLARE_WW8EXPORT_TEST(testTdf49102_mergedCellNumbering, "tdf49102_mergedCellNumbering.doc")
{
CPPUNIT_ASSERT_EQUAL( u"2."_ustr, parseDump("/root/page/body/tab/row[4]/cell/txt/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']"_ostr, "expand"_ostr) );
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
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) );
}
CPPUNIT_TEST_FIXTURE(Test, testTdf55427_footnote2endnote)
+3 -2
View File
@@ -686,9 +686,10 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf94009_zeroPgMargin)
DECLARE_WW8EXPORT_TEST(testTdf108518_CRnumformatting, "tdf108518_CRnumformatting.doc")
{
CPPUNIT_ASSERT_EQUAL(u"6.2.3."_ustr, parseDump("//body/txt[4]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']"_ostr, "expand"_ostr));
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
CPPUNIT_ASSERT_EQUAL(u"6.2.3."_ustr, getXPath(pXmlDoc, "//body/txt[4]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']"_ostr, "expand"_ostr));
//Without this fix in place, it would become 200 (and non-bold).
CPPUNIT_ASSERT_EQUAL(u"220"_ustr, parseDump("//body/txt[4]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']/SwFont"_ostr, "height"_ostr));
CPPUNIT_ASSERT_EQUAL(u"220"_ustr, getXPath(pXmlDoc, "//body/txt[4]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']/SwFont"_ostr, "height"_ostr));
}
DECLARE_WW8EXPORT_TEST(testTdf120711_joinedParagraphWithChangeTracking, "tdf120711.doc")
+3 -2
View File
@@ -98,9 +98,10 @@ DECLARE_WW8EXPORT_TEST(testTdf150197_anlv2ListFormat, "tdf150197_anlv2ListFormat
DECLARE_WW8EXPORT_TEST(testTdf117994_CRnumformatting, "tdf117994_CRnumformatting.doc")
{
CPPUNIT_ASSERT_EQUAL(u"1."_ustr, parseDump("//body/txt[1]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']"_ostr, "expand"_ostr));
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
CPPUNIT_ASSERT_EQUAL(u"1."_ustr, getXPath(pXmlDoc, "//body/txt[1]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']"_ostr, "expand"_ostr));
//Without this fix in place, it would become 200 (and non-bold).
CPPUNIT_ASSERT_EQUAL(u"160"_ustr, parseDump("//body/txt[1]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']/SwFont"_ostr, "height"_ostr));
CPPUNIT_ASSERT_EQUAL(u"160"_ustr, getXPath(pXmlDoc, "//body/txt[1]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']/SwFont"_ostr, "height"_ostr));
}
DECLARE_WW8EXPORT_TEST(testTdf151548_formFieldMacros, "tdf151548_formFieldMacros.doc")
+5 -3
View File
@@ -61,7 +61,8 @@ CPPUNIT_TEST_FIXTURE(Test, testBnc875715)
CPPUNIT_TEST_FIXTURE(Test, testFloatingTableSectionColumns)
{
createSwDoc("floating-table-section-columns.doc");
OUString tableWidth = parseDump("/root/page[1]/body/section/column[2]/body/txt/anchored/fly/tab/infos/bounds"_ostr, "width"_ostr);
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
OUString tableWidth = getXPath(pXmlDoc, "/root/page[1]/body/section/column[2]/body/txt/anchored/fly/tab/infos/bounds"_ostr, "width"_ostr);
// table width was restricted by a column
CPPUNIT_ASSERT( tableWidth.toInt32() > 10000 );
}
@@ -115,13 +116,14 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf106799)
sal_Int32 const nCellWidths[3][4] = { { 9528, 0, 0, 0 },{ 2382, 2382, 2382, 2382 },{ 2382, 2382, 2382, 2382 } };
sal_Int32 const nCellTxtLns[3][4] = { { 1, 0, 0, 0 },{ 1, 0, 0, 0},{ 1, 1, 1, 1 } };
// Table was distorted because of missing sprmPFInnerTableCell at paragraph marks (0x0D) with sprmPFInnerTtp
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
for (sal_Int32 nRow : { 0, 1, 2 })
for (sal_Int32 nCell : { 0, 1, 2, 3 })
{
OString cellXPath("/root/page/body/tab/row/cell/tab/row[" + OString::number(nRow+1) + "]/cell[" + OString::number(nCell+1) + "]/");
CPPUNIT_ASSERT_EQUAL_MESSAGE(cellXPath.getStr(), nCellWidths[nRow][nCell], parseDump(cellXPath + "infos/bounds", "width"_ostr).toInt32());
CPPUNIT_ASSERT_EQUAL_MESSAGE(cellXPath.getStr(), nCellWidths[nRow][nCell], getXPath(pXmlDoc, cellXPath + "infos/bounds", "width"_ostr).toInt32());
if (nCellTxtLns[nRow][nCell] != 0)
CPPUNIT_ASSERT_EQUAL_MESSAGE(cellXPath.getStr(), nCellTxtLns[nRow][nCell], parseDump(cellXPath + "txt/SwParaPortion/SwLineLayout", "length"_ostr).toInt32());
CPPUNIT_ASSERT_EQUAL_MESSAGE(cellXPath.getStr(), nCellTxtLns[nRow][nCell], getXPath(pXmlDoc, cellXPath + "txt/SwParaPortion/SwLineLayout", "length"_ostr).toInt32());
}
}
-7
View File
@@ -139,13 +139,6 @@ protected:
/// Similar to parseExport(), but this gives the xmlDocPtr of the layout dump.
xmlDocUniquePtr parseLayoutDump(const css::uno::Reference< css::lang::XComponent >& xComponent = nullptr);
/**
* Extract a value from the layout dump using an XPath expression and an attribute name.
*
* If the attribute is omitted, the text of the node is returned.
*/
OUString parseDump(const OString& aXPath, const OString& aAttribute = OString());
template< typename T >
T getProperty( const css::uno::Any& obj, const OUString& name ) const
{
-40
View File
@@ -170,46 +170,6 @@ xmlDocUniquePtr SwModelTestBase::parseLayoutDump(const uno::Reference<lang::XCom
return pXmlDoc;
}
OUString SwModelTestBase::parseDump(const OString& aXPath, const OString& aAttribute)
{
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
xmlXPathContextPtr pXmlXpathCtx = xmlXPathNewContext(pXmlDoc.get());
xmlXPathObjectPtr pXmlXpathObj
= xmlXPathEvalExpression(BAD_CAST(aXPath.getStr()), pXmlXpathCtx);
CPPUNIT_ASSERT_MESSAGE("xpath evaluation failed", pXmlXpathObj);
xmlChar* pXpathStrResult;
if (pXmlXpathObj->type == XPATH_NODESET)
{
xmlNodeSetPtr pXmlNodes = pXmlXpathObj->nodesetval;
int nNodes = xmlXPathNodeSetGetLength(pXmlNodes);
OString aMessage("xpath ('" + aXPath + "') should match exactly 1 node");
CPPUNIT_ASSERT_EQUAL_MESSAGE(aMessage.getStr(), 1, nNodes);
CPPUNIT_ASSERT(pXmlNodes);
xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0];
if (aAttribute.getLength())
pXpathStrResult = xmlGetProp(pXmlNode, BAD_CAST(aAttribute.getStr()));
else
pXpathStrResult = xmlNodeGetContent(pXmlNode);
}
else
{
// the xpath expression evaluated to a value, not a node
CPPUNIT_ASSERT_EQUAL_MESSAGE("attr name should not be supplied when xpath evals to a value",
sal_Int32(0), aAttribute.getLength());
pXpathStrResult = xmlXPathCastToString(pXmlXpathObj);
CPPUNIT_ASSERT_MESSAGE("xpath result cannot be cast to string", pXpathStrResult);
}
OUString aRet(reinterpret_cast<char*>(pXpathStrResult), xmlStrlen(pXpathStrResult),
RTL_TEXTENCODING_UTF8);
xmlFree(pXpathStrResult);
xmlFree(pXmlXpathObj);
xmlFree(pXmlXpathCtx);
return aRet;
}
bool SwModelTestBase::hasProperty(const uno::Reference<uno::XInterface>& obj,
const OUString& name) const
{
+10 -8
View File
@@ -124,12 +124,7 @@ OUString XmlTestTools::getXPathContent(const xmlDocUniquePtr& pXmlDoc, const OSt
xmlXPathNodeSetGetLength(pXmlNodes) > 0);
xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0];
xmlNodePtr pXmlChild = pXmlNode->children;
OUString s;
while (pXmlChild && pXmlChild->type != XML_TEXT_NODE)
pXmlChild = pXmlChild->next;
if (pXmlChild && pXmlChild->type == XML_TEXT_NODE)
s = convert(pXmlChild->content);
OUString s = convert(xmlNodeGetContent(pXmlNode));
xmlXPathFreeObject(pXmlObj);
return s;
}
@@ -256,6 +251,13 @@ void XmlTestTools::assertXPathChildren(const xmlDocUniquePtr& pXmlDoc, const OSt
}
void XmlTestTools::assertXPathNoAttribute(const xmlDocUniquePtr& pXmlDoc, const OString& rXPath, const OString& rAttribute)
{
CPPUNIT_ASSERT_MESSAGE(OString(OString::Concat("In <") + pXmlDoc->name + ">, XPath '" + rXPath + "' unexpected '" + rAttribute + "' attribute").getStr(),
!hasXPathAttribute(pXmlDoc, rXPath, rAttribute));
}
bool XmlTestTools::hasXPathAttribute(const xmlDocUniquePtr& pXmlDoc, const OString& rXPath,
const OString& rAttribute)
{
xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, rXPath);
xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval;
@@ -263,9 +265,9 @@ void XmlTestTools::assertXPathNoAttribute(const xmlDocUniquePtr& pXmlDoc, const
CPPUNIT_ASSERT_EQUAL_MESSAGE(OString(OString::Concat("In <") + pXmlDoc->name + ">, XPath '" + rXPath + "' number of nodes is incorrect").getStr(),
1, xmlXPathNodeSetGetLength(pXmlNodes));
xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0];
CPPUNIT_ASSERT_MESSAGE(OString(OString::Concat("In <") + pXmlDoc->name + ">, XPath '" + rXPath + "' unexpected '" + rAttribute + "' attribute").getStr(),
!xmlGetProp(pXmlNode, BAD_CAST(rAttribute.getStr())));
bool bFound(xmlGetProp(pXmlNode, BAD_CAST(rAttribute.getStr())));
xmlXPathFreeObject(pXmlObj);
return bFound;
}
int XmlTestTools::getXPathPosition(const xmlDocUniquePtr& pXmlDoc, const OString& rXPath, std::string_view rChildName)