summaryrefslogtreecommitdiffstats
path: root/sw/qa/extras/layout/layout3.cxx
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 09:44:47 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 09:44:47 +0000
commit91fe6b97952aa6f7cef58327fd085a17db38ad95 (patch)
tree7a4412295bfb80e15a4936fe67d4bd7b96458ce8 /sw/qa/extras/layout/layout3.cxx
parentReleasing progress-linux version 4:24.2.1-4~progress7.99u1. (diff)
downloadlibreoffice-91fe6b97952aa6f7cef58327fd085a17db38ad95.tar.xz
libreoffice-91fe6b97952aa6f7cef58327fd085a17db38ad95.zip
Merging upstream version 4:24.2.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sw/qa/extras/layout/layout3.cxx')
-rw-r--r--sw/qa/extras/layout/layout3.cxx68
1 files changed, 59 insertions, 9 deletions
diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx
index 9c46d8395a..a074a35dc6 100644
--- a/sw/qa/extras/layout/layout3.cxx
+++ b/sw/qa/extras/layout/layout3.cxx
@@ -94,15 +94,25 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf119875)
{
createSwDoc("tdf119875.odt");
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
- sal_Int32 nFirstTop
- = getXPath(pXmlDoc, "/root/page[2]/body/section[1]/infos/bounds"_ostr, "top"_ostr)
- .toInt32();
- sal_Int32 nSecondTop
- = getXPath(pXmlDoc, "/root/page[2]/body/section[2]/infos/bounds"_ostr, "top"_ostr)
- .toInt32();
- // The first section had the same top value as the second one, so they
- // overlapped.
- CPPUNIT_ASSERT_LESS(nSecondTop, nFirstTop);
+
+ assertXPath(pXmlDoc, "//page[2]/body/section[1]"_ostr, "formatName"_ostr, u"S10"_ustr);
+ assertXPath(pXmlDoc, "//page[2]/body/section[2]"_ostr, "formatName"_ostr, u"S11"_ustr);
+ assertXPath(pXmlDoc, "//page[2]/body/section[3]"_ostr, "formatName"_ostr, u"S13"_ustr);
+ assertXPath(pXmlDoc, "//page[2]/body/section[4]"_ostr, "formatName"_ostr, u"S14"_ustr);
+ // Sections "S10" and "S13" are hidden -> their frames are zero-height
+ assertXPath(pXmlDoc, "//page[2]/body/section[1]/infos/bounds"_ostr, "height"_ostr, u"0"_ustr);
+ assertXPath(pXmlDoc, "//page[2]/body/section[3]/infos/bounds"_ostr, "height"_ostr, u"0"_ustr);
+
+ OUString S10Top = getXPath(pXmlDoc, "//page[2]/body/section[1]/infos/bounds"_ostr, "top"_ostr);
+ OUString S11Top = getXPath(pXmlDoc, "//page[2]/body/section[2]/infos/bounds"_ostr, "top"_ostr);
+ OUString S13Top = getXPath(pXmlDoc, "//page[2]/body/section[3]/infos/bounds"_ostr, "top"_ostr);
+ OUString S14Top = getXPath(pXmlDoc, "//page[2]/body/section[4]/infos/bounds"_ostr, "top"_ostr);
+
+ CPPUNIT_ASSERT_EQUAL(S10Top, S11Top);
+ CPPUNIT_ASSERT_EQUAL(S13Top, S14Top);
+
+ // Section "S11" had the same top value as section "S14", so they overlapped.
+ CPPUNIT_ASSERT_LESS(S14Top.toInt32(), S11Top.toInt32());
}
CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf137523)
@@ -2303,6 +2313,46 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf159259)
CPPUNIT_ASSERT_EQUAL(paraHeight, flyHeight);
}
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testLargeTopParaMarginAfterHiddenSection)
+{
+ // Given a large top margin in Standard paragraph style, and the first section hidden
+ createSwDoc("largeTopMarginAndHiddenFirstSection.fodt");
+ xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+ // Make sure there is only one page and two sections, first hidden (zero-height)
+ assertXPath(pXmlDoc, "//page"_ostr, 1);
+ assertXPath(pXmlDoc, "//page/body/section"_ostr, 2);
+ assertXPath(pXmlDoc, "//page/body/section[1]/infos/bounds"_ostr, "height"_ostr, u"0"_ustr);
+ // Check that the top margin (1 in = 1440 twip) is added to line height (12 pt = 240 twip)
+ assertXPath(pXmlDoc, "//page/body/section[2]/infos/bounds"_ostr, "height"_ostr, u"1680"_ustr);
+}
+
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testPageBreakInHiddenSection)
+{
+ // Given a paragraph with page-break-before with page style and page number
+ createSwDoc("pageBreakInHiddenSection.fodt");
+ xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+ assertXPath(pXmlDoc, "//page"_ostr, 4);
+ assertXPath(pXmlDoc, "//section"_ostr, 4);
+ assertXPath(pXmlDoc, "//page[1]/body/txt"_ostr, 1);
+ // The page break inside the hidden section is ignored (otherwise, there would be one section
+ // on the first page)
+ assertXPath(pXmlDoc, "//page[1]/body/section"_ostr, 2);
+ // The first section is hidden
+ assertXPath(pXmlDoc, "//page[1]/body/section[1]/infos/bounds"_ostr, "height"_ostr, u"0"_ustr);
+
+ // Page 2 is empty even page (generated by the next page's section with page-break-before)
+ assertXPath(pXmlDoc, "//page[2]/body"_ostr, 0);
+
+ // The section on page 3 is not hidden, only text in it is, therefore its page break works
+ assertXPath(pXmlDoc, "//page[3]/body/section"_ostr, 1);
+ assertXPath(pXmlDoc, "//page[3]/body/section/infos/bounds"_ostr, "height"_ostr, u"0"_ustr);
+
+ // The section on page 4 is hidden, thus page break in it is ignored (no further pages, where
+ // the section would be moved to otherwise)
+ assertXPath(pXmlDoc, "//page[4]/body/section"_ostr, 1);
+ assertXPath(pXmlDoc, "//page[4]/body/section/infos/bounds"_ostr, "height"_ostr, u"0"_ustr);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */