sw/qa/extras/layout/layout.cxx    |   29 ++++++++++++++++++++++++++++-
 sw/source/core/layout/pagechg.cxx |   12 ++++++++++++
 2 files changed, 40 insertions(+), 1 deletion(-)

New commits:
commit 64a45eb390ed12efefe3d1a074282d816afb51ed
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Mon May 13 21:41:40 2019 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Wed May 15 09:04:57 2019 +0200

    tdf#118719 sw Hide Whitespace: fix height of last-but-one page
    
    Regression from commit 49b67cdc36b599f865d4a6de214d901861f27196
    (tdf#96961 sw Hide Whitespace: still show whitespace on the last page,
    2016-01-08), the problem was that in case a page used to be the last one
    but no longer is, then its height was kept unchanged.
    
    Fix this by invalidating the size of the old last page after the
    insertion of the new last page, this way SwPageFrame::MakeAll() will be
    called later to resize the page.
    
    (cherry picked from commit c4589dd7141f931513827367b457f481d960b774)
    
    Conflicts:
            sw/qa/extras/layout/layout.cxx
    
    Change-Id: I672a70a77af5d306b1f8bd0b5ad6c2e375497124
    Reviewed-on: https://gerrit.libreoffice.org/72301
    Reviewed-by: Michael Stahl <michael.st...@cib.de>
    Tested-by: Jenkins

diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 8c132693e68b..c2c6d2cd5b9d 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -66,6 +66,7 @@ public:
     void testTdf120287c();
     void testTdf122878();
     void testTdf115094();
+    void testTdf118719();
 
     CPPUNIT_TEST_SUITE(SwLayoutWriter);
     CPPUNIT_TEST(testRedlineFootnotes);
@@ -104,6 +105,7 @@ public:
     CPPUNIT_TEST(testTdf120287c);
     CPPUNIT_TEST(testTdf122878);
     CPPUNIT_TEST(testTdf115094);
+    CPPUNIT_TEST(testTdf118719);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -112,7 +114,10 @@ private:
 
 SwDoc* SwLayoutWriter::createDoc(const char* pName)
 {
-    load(DATA_DIRECTORY, pName);
+    if (!pName)
+        loadURL("private:factory/swriter", nullptr);
+    else
+        load(DATA_DIRECTORY, pName);
 
     SwXTextDocument* pTextDoc = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
     CPPUNIT_ASSERT(pTextDoc);
@@ -2701,6 +2706,28 @@ void SwLayoutWriter::testTdf115094()
     CPPUNIT_ASSERT_LESS(nTopOfB2Anchored, nTopOfB2);
 }
 
+void SwLayoutWriter::testTdf118719()
+{
+    // Insert a page break.
+    SwDoc* pDoc = createDoc();
+    SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+
+    // Enable hide whitespace mode.
+    SwViewOption aViewOptions(*pWrtShell->GetViewOptions());
+    aViewOptions.SetHideWhitespaceMode(true);
+    pWrtShell->ApplyViewOptions(aViewOptions);
+
+    pWrtShell->Insert("first");
+    pWrtShell->InsertPageBreak();
+    pWrtShell->Insert("second");
+
+    // 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", 
"height").toInt32();
+    sal_Int32 nLast = parseDump("/root/page[2]/infos/bounds", 
"height").toInt32();
+    CPPUNIT_ASSERT_GREATER(nOther, nLast);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwLayoutWriter);
 CPPUNIT_PLUGIN_IMPLEMENT();
 
diff --git a/sw/source/core/layout/pagechg.cxx 
b/sw/source/core/layout/pagechg.cxx
index 6c8df71ff7ad..83b169828fe1 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -1259,6 +1259,18 @@ namespace
             SAL_INFO( "sw.pageframe", "doInsertPage - insert empty p: "
                                       << pPage << " d: " << pDesc );
         pPage->Paste( pRoot, pSibling );
+
+        SwViewShell* pViewShell = pRoot->GetCurrShell();
+        if (pViewShell && pViewShell->GetViewOptions()->IsHideWhitespaceMode())
+        {
+            // Hide-whitespace mode does not shrink the last page, so resize 
the page that used to
+            // be the last one.
+            if (SwFrame* pPrevPage = pPage->GetPrev())
+            {
+                pPrevPage->InvalidateSize();
+            }
+        }
+
         pPage->PreparePage( bFootnote );
         // If the sibling has no body text, destroy it as long as it is no 
footnote page.
         if ( pSibling && !pSibling->IsFootnotePage() &&
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to