sw/qa/extras/layout/layout.cxx | 27 ++++++++++++++++++++++++++- sw/source/core/layout/pagechg.cxx | 12 ++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-)
New commits: commit c4589dd7141f931513827367b457f481d960b774 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Mon May 13 21:41:40 2019 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Tue May 14 09:12:51 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. Change-Id: I672a70a77af5d306b1f8bd0b5ad6c2e375497124 Reviewed-on: https://gerrit.libreoffice.org/72256 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index af45e6ba8db4..e06bfd84b3a3 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -40,7 +40,10 @@ protected: 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); @@ -2973,6 +2976,28 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf116501) createDoc("tdf116501.odt"); } +CPPUNIT_TEST_FIXTURE(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_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx index f77954545a50..284f92a97556 100644 --- a/sw/source/core/layout/pagechg.cxx +++ b/sw/source/core/layout/pagechg.cxx @@ -1261,6 +1261,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