Kaydet (Commit) c4589dd7 authored tarafından Miklos Vajna's avatar Miklos Vajna

tdf#118719 sw Hide Whitespace: fix height of last-but-one page

Regression from commit 49b67cdc
(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: 's avatarMiklos Vajna <vmiklos@collabora.com>
üst 64238976
...@@ -40,7 +40,10 @@ protected: ...@@ -40,7 +40,10 @@ protected:
SwDoc* SwLayoutWriter::createDoc(const char* pName) 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()); SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
CPPUNIT_ASSERT(pTextDoc); CPPUNIT_ASSERT(pTextDoc);
...@@ -2973,6 +2976,28 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf116501) ...@@ -2973,6 +2976,28 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf116501)
createDoc("tdf116501.odt"); 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(); CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -1261,6 +1261,18 @@ namespace ...@@ -1261,6 +1261,18 @@ namespace
SAL_INFO( "sw.pageframe", "doInsertPage - insert empty p: " SAL_INFO( "sw.pageframe", "doInsertPage - insert empty p: "
<< pPage << " d: " << pDesc ); << pPage << " d: " << pDesc );
pPage->Paste( pRoot, pSibling ); 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 ); pPage->PreparePage( bFootnote );
// If the sibling has no body text, destroy it as long as it is no footnote page. // If the sibling has no body text, destroy it as long as it is no footnote page.
if ( pSibling && !pSibling->IsFootnotePage() && if ( pSibling && !pSibling->IsFootnotePage() &&
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment