diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-01-29 13:10:30 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-01-29 13:20:15 +0000 |
commit | 363aa5dbb2c223b6cc3a109bd654f39772e310fa (patch) | |
tree | e383f7c3ff73fcbe740d7ea4c70d0137b264bee0 /sw | |
parent | da45a1686088d0b05fd694e0b413527a89027b6e (diff) |
sw: refactor SwPageFrame::HandleWhitespaceHiddenDiff()
As suggested at <https://gerrit.libreoffice.org/21445>.
Change-Id: Id1e7a6381954c6d56a2593a064c37cc185475a56
Reviewed-on: https://gerrit.libreoffice.org/21899
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/inc/pagefrm.hxx | 5 | ||||
-rw-r--r-- | sw/source/core/layout/calcmove.cxx | 8 | ||||
-rw-r--r-- | sw/source/core/layout/pagechg.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/text/widorp.cxx | 3 |
4 files changed, 14 insertions, 8 deletions
diff --git a/sw/source/core/inc/pagefrm.hxx b/sw/source/core/inc/pagefrm.hxx index 2df4c1d58a37..3fae2a30bbc8 100644 --- a/sw/source/core/inc/pagefrm.hxx +++ b/sw/source/core/inc/pagefrm.hxx @@ -335,8 +335,9 @@ public: static SwTwips GetSidebarBorderWidth( const SwViewShell* ); - /// Adjust a bottom-of-page-frame - bottom-of-text-frame difference in case whitespace is hidden. - void HandleWhitespaceHiddenDiff(SwTwips& nDiff); + /// Is bottom-of-page-frame - bottom-of-text-frame difference valid in case whitespace is hidden? + /// If false is returned, then the caller should handle negative difference as (at least) zero difference instead. + bool CheckPageHeightValidForHideWhitespace(SwTwips nDiff); }; inline SwContentFrame *SwPageFrame::FindFirstBodyContent() diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx index aa4e4a5106da..a5fd16c971b4 100644 --- a/sw/source/core/layout/calcmove.cxx +++ b/sw/source/core/layout/calcmove.cxx @@ -1525,10 +1525,12 @@ void SwContentFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/) // Hide whitespace may require not to insert a new page. SwPageFrame* pPageFrame = FindPageFrame(); - long nOldBottomDist = nBottomDist; - pPageFrame->HandleWhitespaceHiddenDiff(nBottomDist); - if (nOldBottomDist != nBottomDist) + const bool bHeightValid = pPageFrame->CheckPageHeightValidForHideWhitespace(nBottomDist); + if (!bHeightValid) + { pPageFrame->InvalidateSize(); + nBottomDist = 0; + } if( nBottomDist >= 0 ) { diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx index 967ee2fe5305..42ae8acbe5d9 100644 --- a/sw/source/core/layout/pagechg.cxx +++ b/sw/source/core/layout/pagechg.cxx @@ -2287,7 +2287,7 @@ bool SwPageFrame::IsOverHeaderFooterArea( const Point& rPt, FrameControlType &rC return false; } -void SwPageFrame::HandleWhitespaceHiddenDiff(SwTwips& nDiff) +bool SwPageFrame::CheckPageHeightValidForHideWhitespace(SwTwips nDiff) { SwViewShell* pShell = getRootFrame()->GetCurrShell(); if (pShell && pShell->GetViewOptions()->IsWhitespaceHidden()) @@ -2309,10 +2309,12 @@ void SwPageFrame::HandleWhitespaceHiddenDiff(SwTwips& nDiff) { // It does: don't move it and invalidate our page frame so // that it gets a larger height. - nDiff = 0; + return false; } } } + + return true; } SwTextGridItem const* GetGridItem(SwPageFrame const*const pPage) diff --git a/sw/source/core/text/widorp.cxx b/sw/source/core/text/widorp.cxx index c75a9586ef19..7c22b120d3a4 100644 --- a/sw/source/core/text/widorp.cxx +++ b/sw/source/core/text/widorp.cxx @@ -131,7 +131,8 @@ bool SwTextFrameBreak::IsInside( SwTextMargin &rLine ) const // Hide whitespace may require not to insert a new page. SwPageFrame* pPageFrame = m_pFrame->FindPageFrame(); - pPageFrame->HandleWhitespaceHiddenDiff(nDiff); + if (!pPageFrame->CheckPageHeightValidForHideWhitespace(nDiff)) + nDiff = 0; // If everything is inside the existing frame the result is true; bFit = nDiff >= 0; |