summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-01-08 17:10:17 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-01-08 17:38:56 +0100
commit8094e313c0d8b517c124cb86fb10ff8f911d2744 (patch)
treeb21151897d0a1889c646bbbb918102e3c396018f
parentcbf2d103a67b2a1b2a55989cca71ee99bfa4a329 (diff)
tdf#96961 sw Hide Whitespace: still show whitespace on the last page
Mainly to match Word's hide whitespace behavior. (cherry picked from commit 49b67cdc36b599f865d4a6de214d901861f27196) Conflicts: sw/qa/extras/uiwriter/uiwriter.cxx sw/source/core/layout/calcmove.cxx Change-Id: Ica09bca5004adbfa14d1c9aca04079129f8a1a68
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx22
-rw-r--r--sw/source/core/layout/calcmove.cxx5
-rw-r--r--sw/source/core/layout/wsfrm.cxx18
3 files changed, 41 insertions, 4 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 64ded0d60e0a..ce38f1ed42f7 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -108,6 +108,7 @@ public:
void testTdf96515();
void testTdf96943();
void testTdf96536();
+ void testTdf96961();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward);
@@ -153,6 +154,7 @@ public:
CPPUNIT_TEST(testTdf96515);
CPPUNIT_TEST(testTdf96943);
CPPUNIT_TEST(testTdf96536);
+ CPPUNIT_TEST(testTdf96961);
CPPUNIT_TEST_SUITE_END();
@@ -1221,6 +1223,26 @@ void SwUiWriterTest::testTdf96536()
CPPUNIT_ASSERT(parseDump("/root/page[1]/infos/bounds", "height").toInt32() <= 276);
}
+void SwUiWriterTest::testTdf96961()
+{
+ // Insert a page break.
+ SwDoc* pDoc = createDoc();
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ pWrtShell->InsertPageBreak();
+
+ // Enable hide whitespace mode.
+ SwViewOption aViewOptions(*pWrtShell->GetViewOptions());
+ aViewOptions.SetHideWhitespaceMode(true);
+ pWrtShell->ApplyViewOptions(aViewOptions);
+
+ calcLayout();
+
+ // Assert that the height of the last page is larger than the height of other pages.
+ sal_Int32 nOther = parseDump("/root/page[1]/infos/bounds", "height").toInt32();
+ sal_Int32 nLast = parseDump("/root/page[2]/infos/bounds", "height").toInt32();
+ CPPUNIT_ASSERT(nLast > nOther);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx
index 148a953d3251..62d568209284 100644
--- a/sw/source/core/layout/calcmove.cxx
+++ b/sw/source/core/layout/calcmove.cxx
@@ -738,7 +738,8 @@ void SwPageFrm::MakeAll(vcl::RenderContext* pRenderContext)
}
assert(pAttrs);
- SwViewShell *pSh = getRootFrm()->GetCurrShell();
+ SwRootFrm* pRootFrame = getRootFrm();
+ SwViewShell* pSh = pRootFrame->GetCurrShell();
if (pSh && pSh->GetViewOptions()->getBrowseMode())
{
// In BrowseView, we use fixed settings
@@ -785,7 +786,7 @@ void SwPageFrm::MakeAll(vcl::RenderContext* pRenderContext)
mbValidSize = mbValidPrtArea = true;
continue;
}
- else if (pSh && pSh->GetViewOptions()->IsWhitespaceHidden())
+ else if (pSh && pSh->GetViewOptions()->IsWhitespaceHidden() && pRootFrame->GetLastPage() != this)
{
long height = 0;
SwLayoutFrm *pBody = FindBodyCont();
diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index 205f7042f3da..297303328e8f 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -2947,11 +2947,25 @@ void SwLayoutFrm::Format( vcl::RenderContext* /*pRenderContext*/, const SwBorder
if ( mbValidPrtArea && mbValidSize )
return;
+ bool bHideWhitespace = false;
+ if (IsPageFrm())
+ {
+ SwViewShell* pShell = getRootFrm()->GetCurrShell();
+ if (pShell && pShell->GetViewOptions()->IsWhitespaceHidden())
+ {
+ // This is needed so that no space is reserved for the margin on
+ // the last page of the document. Other pages would have no margin
+ // set even without this, as their frame height is the content
+ // height already.
+ bHideWhitespace = true;
+ }
+ }
+
const sal_uInt16 nLeft = (sal_uInt16)pAttrs->CalcLeft(this);
- const sal_uInt16 nUpper = pAttrs->CalcTop();
+ const sal_uInt16 nUpper = bHideWhitespace ? 0 : pAttrs->CalcTop();
const sal_uInt16 nRight = (sal_uInt16)pAttrs->CalcRight(this);
- const sal_uInt16 nLower = pAttrs->CalcBottom();
+ const sal_uInt16 nLower = bHideWhitespace ? 0 : pAttrs->CalcBottom();
const bool bVert = IsVertical() && !IsPageFrm();
SwRectFn fnRect = bVert ? ( IsVertLR() ? fnRectVertL2R : fnRectVert ) : fnRectHori;