sw/qa/extras/layout/data/tdf152307.odt |binary
 sw/qa/extras/layout/layout3.cxx        |   45 +++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+)

New commits:
commit c05bed53174ebc6f4e82838db9c2a7fcb587d3bd
Author:     EMartinGube <martin.g...@web.de>
AuthorDate: Fri Oct 13 09:43:49 2023 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Sat Dec 2 12:38:53 2023 +0100

    tdf#152307 sw: layout: invalidate more frames when footer grows
    
    Unit test added.
    
    Change-Id: Ibcdb504c57c020cde9b76994cb54e744d1a12888
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157905
    Tested-by: Jenkins
    Tested-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/qa/extras/layout/data/tdf152307.odt 
b/sw/qa/extras/layout/data/tdf152307.odt
new file mode 100644
index 000000000000..766687d49234
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf152307.odt differ
diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx
index 5401cef9a380..27f9e0a2f59b 100644
--- a/sw/qa/extras/layout/layout3.cxx
+++ b/sw/qa/extras/layout/layout3.cxx
@@ -2071,6 +2071,51 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf155611)
     // Also must not crash on close because of a frame that accidentally fell 
off of the layout
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf152307)
+{
+    // Problem: On a given Writer document a table layout changed
+    // after doing Tools -> Update -> Update All. The last table row on page 13
+    // was bigger than the page size allowed and thus was hidden behind the 
footer.
+
+    // load the document
+    createSwDoc("tdf152307.odt");
+
+    // do Tools -> Update -> Update All
+    dispatchCommand(mxComponent, ".uno:UpdateAllIndexes", {});
+
+    // XML dump and some basic assertions
+    sal_Int32 nPage = 7, nPages = 0;
+    xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+    nPages = countXPathNodes(pXmlDoc, "/root/page");
+    CPPUNIT_ASSERT_MESSAGE("tdf152307.odt / testTdf152307: Not enough pages.", 
nPage < nPages);
+    assertXPath(pXmlDoc, "/root/page[" + OString::number(nPage) + 
"]/body/section", 1);
+
+    // Actual test procedure:
+    // On page 7, check:
+    // How much tables do we have? How much rows does the last table have?
+    int nTables
+        = countXPathNodes(pXmlDoc, "/root/page[" + OString::number(nPage) + 
"]/body/section/tab");
+    int nRowsLastTable
+        = countXPathNodes(pXmlDoc, "/root/page[" + OString::number(nPage) + 
"]/body/section/tab["
+                                       + OString::number(nTables) + "]/row");
+    // What is the bottom value of the last table row?
+    sal_Int32 nTabBottom = getXPath(pXmlDoc,
+                                    "/root/page[" + OString::number(nPage) + 
"]/body/section/tab["
+                                        + OString::number(nTables) + "]/row["
+                                        + OString::number(nRowsLastTable) + 
"]/infos/bounds",
+                                    "bottom")
+                               .toInt32();
+    // Where does the footer start (footer/info/bounds/top)?
+    sal_Int32 nFooterTop
+        = getXPath(pXmlDoc, "/root/page[" + OString::number(nPage) + 
"]/footer/infos/bounds", "top")
+              .toInt32();
+    // Is the bottom value of the last row above the top value of the footer?
+    OString aMsg = "tdf152307.odt / testTdf152307: Bottom value of last table 
row on page "
+                   + OString::number(nPage) + " is below top value of footer: "
+                   + OString::number(nTabBottom) + " > " + 
OString::number(nFooterTop);
+    CPPUNIT_ASSERT_MESSAGE(aMsg.getStr(), nTabBottom < nFooterTop);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to