summaryrefslogtreecommitdiff
path: root/sw/qa
diff options
context:
space:
mode:
authorLuke Deller <luke@deller.id.au>2017-07-12 20:39:50 +1000
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-09-01 10:45:43 +0200
commit14bb680949b47332d2921cc68f75340b31ad5c32 (patch)
tree66fe5b9a055956a2affe8b2a12561fcf7fbc00ab /sw/qa
parentfeb463e93f8c7beb0f6abb52812ac05c4f7724c2 (diff)
Insert blank page when first page number is even
When the page number is explicitly changed at a page break, LibreOffice will insert a blank page if necessary to ensure that even page numbers appear on "left" pages. This commit fixes a case that was missed: the case where the page number of the very first page in the document is explicitly set to be an even number. Also: - adjust a couple of unit tests which were referring to specific physical page numbers, that were not expecting this blank page to be there - enhance SwModelTestBase::parseDump to support xpath expressions evaluating to simple values rather than nodes, for use in a test case for this change Change-Id: I1f41760c3bb17bdffb868cf32a1331de87d1d0e1 Reviewed-on: https://gerrit.libreoffice.org/39858 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'sw/qa')
-rw-r--r--sw/qa/extras/inc/swmodeltestbase.hxx34
-rw-r--r--sw/qa/extras/odfimport/odfimport.cxx13
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport4.cxx2
-rw-r--r--sw/qa/extras/ww8export/ww8export.cxx7
4 files changed, 47 insertions, 9 deletions
diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx
index 80874da95810..09fe3589b9a8 100644
--- a/sw/qa/extras/inc/swmodeltestbase.hxx
+++ b/sw/qa/extras/inc/swmodeltestbase.hxx
@@ -405,15 +405,35 @@ protected:
xmlXPathContextPtr pXmlXpathCtx = xmlXPathNewContext(pXmlDoc);
xmlXPathObjectPtr pXmlXpathObj = xmlXPathEvalExpression(BAD_CAST(aXPath.getStr()), pXmlXpathCtx);
- xmlNodeSetPtr pXmlNodes = pXmlXpathObj->nodesetval;
- CPPUNIT_ASSERT_EQUAL_MESSAGE("parsing dump failed", 1, xmlXPathNodeSetGetLength(pXmlNodes));
- xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0];
- OUString aRet;
- if (aAttribute.getLength())
- aRet = OUString::createFromAscii(reinterpret_cast<char*>(xmlGetProp(pXmlNode, BAD_CAST(aAttribute.getStr()))));
+ CPPUNIT_ASSERT_MESSAGE("xpath evaluation failed", pXmlXpathObj);
+ xmlChar *pXpathStrResult;
+ if (pXmlXpathObj->type == XPATH_NODESET)
+ {
+ xmlNodeSetPtr pXmlNodes = pXmlXpathObj->nodesetval;
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("xpath should match exactly 1 node",
+ 1, xmlXPathNodeSetGetLength(pXmlNodes));
+ xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0];
+ if (aAttribute.getLength())
+ pXpathStrResult = xmlGetProp(pXmlNode, BAD_CAST(aAttribute.getStr()));
+ else
+ pXpathStrResult = xmlNodeGetContent(pXmlNode);
+ }
else
- aRet = OUString::createFromAscii(reinterpret_cast<char*>(xmlNodeGetContent(pXmlNode)));
+ {
+ // 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",
+ aAttribute.getLength(), sal_Int32(0));
+ pXpathStrResult = xmlXPathCastToString(pXmlXpathObj);
+ CPPUNIT_ASSERT_MESSAGE("xpath result cannot be cast to string",
+ pXpathStrResult);
+ }
+ OUString aRet = OUString(reinterpret_cast<char*>(pXpathStrResult),
+ xmlStrlen(pXpathStrResult), RTL_TEXTENCODING_UTF8);
+ xmlFree(pXpathStrResult);
+ xmlFree(pXmlXpathObj);
+ xmlFree(pXmlXpathCtx);
xmlFreeDoc(pXmlDoc);
return aRet;
diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx
index 66d25f1919ef..67a6873f5617 100644
--- a/sw/qa/extras/odfimport/odfimport.cxx
+++ b/sw/qa/extras/odfimport/odfimport.cxx
@@ -857,5 +857,18 @@ DECLARE_ODFIMPORT_TEST(testTdf94882, "tdf94882.odt")
CPPUNIT_ASSERT_EQUAL(OUString("This is the first page header"), headertext);
}
+DECLARE_ODFIMPORT_TEST(testBlankBeforeFirstPage, "tdf94882.odt")
+{
+ // This document starts on page 50, which is even, so it should have a
+ // blank page inserted before it to make it a left page
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be 2 pages output",
+ OUString("2"), parseDump("count(/root/page)")
+ );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("The first page should be blank",
+ OUString("0"), parseDump("count(/root/page[1]/body)")
+ );
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
index eff59b4de783..8858ffd5ade6 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
@@ -249,7 +249,7 @@ DECLARE_OOXMLEXPORT_TEST(testRelSizeRound, "rel-size-round.docx")
DECLARE_OOXMLEXPORT_TEST(testTestTitlePage, "testTitlePage.docx")
{
- CPPUNIT_ASSERT_EQUAL(OUString("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), parseDump("/root/page[2]/footer/txt/text()"));
+ CPPUNIT_ASSERT_EQUAL(OUString("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), parseDump("/root/page[last()]/footer/txt/text()"));
}
DECLARE_OOXMLEXPORT_TEST(testTableRowDataDisplayedTwice,"table-row-data-displayed-twice.docx")
diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx
index 1d2cd7b9e75c..131c8e85b329 100644
--- a/sw/qa/extras/ww8export/ww8export.cxx
+++ b/sw/qa/extras/ww8export/ww8export.cxx
@@ -591,7 +591,12 @@ DECLARE_WW8EXPORT_TEST(testFdo81102, "fdo81102.doc")
DECLARE_WW8EXPORT_TEST(testBnc787942, "bnc787942.doc")
{
// The frame ended up on the second page instead of first.
- parseDump("/root/page[1]/body/txt[4]/anchored");
+
+ // Ensure that the anchor is on the same page as the text "Zelva Mana"
+ // (Note that this can actually be the second physical page, since the
+ // page number is set to 0 which is even so LO will insert a blank page
+ // before it to make it a left page)
+ parseDump("/root/page[body/txt/text()='Zelva Mana']/body/txt[4]/anchored");
}
DECLARE_WW8EXPORT_TEST(testLayoutHanging, "fdo68967.doc")