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

tdf#96961 sw Hide Whitespace: still show whitespace on the last page

Mainly to match Word's hide whitespace behavior.

Change-Id: Ica09bca5004adbfa14d1c9aca04079129f8a1a68
üst cd51e015
...@@ -180,6 +180,7 @@ public: ...@@ -180,6 +180,7 @@ public:
void testTdf96943(); void testTdf96943();
void testTdf96536(); void testTdf96536();
void testTdf96479(); void testTdf96479();
void testTdf96961();
CPPUNIT_TEST_SUITE(SwUiWriterTest); CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward); CPPUNIT_TEST(testReplaceForward);
...@@ -266,6 +267,7 @@ public: ...@@ -266,6 +267,7 @@ public:
CPPUNIT_TEST(testTdf96943); CPPUNIT_TEST(testTdf96943);
CPPUNIT_TEST(testTdf96536); CPPUNIT_TEST(testTdf96536);
CPPUNIT_TEST(testTdf96479); CPPUNIT_TEST(testTdf96479);
CPPUNIT_TEST(testTdf96961);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
private: private:
...@@ -3087,6 +3089,26 @@ void SwUiWriterTest::testTdf96479() ...@@ -3087,6 +3089,26 @@ void SwUiWriterTest::testTdf96479()
} }
} }
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_TEST_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
...@@ -740,7 +740,8 @@ void SwPageFrame::MakeAll(vcl::RenderContext* pRenderContext) ...@@ -740,7 +740,8 @@ void SwPageFrame::MakeAll(vcl::RenderContext* pRenderContext)
} }
assert(pAttrs); assert(pAttrs);
SwViewShell *pSh = getRootFrame()->GetCurrShell(); SwRootFrame* pRootFrame = getRootFrame();
SwViewShell* pSh = pRootFrame->GetCurrShell();
if (pSh && pSh->GetViewOptions()->getBrowseMode()) if (pSh && pSh->GetViewOptions()->getBrowseMode())
{ {
// In BrowseView, we use fixed settings // In BrowseView, we use fixed settings
...@@ -787,7 +788,7 @@ void SwPageFrame::MakeAll(vcl::RenderContext* pRenderContext) ...@@ -787,7 +788,7 @@ void SwPageFrame::MakeAll(vcl::RenderContext* pRenderContext)
mbValidSize = mbValidPrtArea = true; mbValidSize = mbValidPrtArea = true;
continue; continue;
} }
else if (pSh && pSh->GetViewOptions()->IsWhitespaceHidden()) else if (pSh && pSh->GetViewOptions()->IsWhitespaceHidden() && pRootFrame->GetLastPage() != this)
{ {
long height = 0; long height = 0;
SwLayoutFrame *pBody = FindBodyCont(); SwLayoutFrame *pBody = FindBodyCont();
......
...@@ -2947,11 +2947,25 @@ void SwLayoutFrame::Format( vcl::RenderContext* /*pRenderContext*/, const SwBord ...@@ -2947,11 +2947,25 @@ void SwLayoutFrame::Format( vcl::RenderContext* /*pRenderContext*/, const SwBord
if ( mbValidPrtArea && mbValidSize ) if ( mbValidPrtArea && mbValidSize )
return; return;
bool bHideWhitespace = false;
if (IsPageFrame())
{
SwViewShell* pShell = getRootFrame()->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 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 nRight = (sal_uInt16)pAttrs->CalcRight(this);
const sal_uInt16 nLower = pAttrs->CalcBottom(); const sal_uInt16 nLower = bHideWhitespace ? 0 : pAttrs->CalcBottom();
const bool bVert = IsVertical() && !IsPageFrame(); const bool bVert = IsVertical() && !IsPageFrame();
SwRectFn fnRect = bVert ? ( IsVertLR() ? fnRectVertL2R : fnRectVert ) : fnRectHori; SwRectFn fnRect = bVert ? ( IsVertLR() ? fnRectVertL2R : fnRectVert ) : fnRectHori;
......
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