sw/source/core/inc/pagefrm.hxx | 5 +++-- sw/source/core/layout/calcmove.cxx | 8 +++++--- sw/source/core/layout/pagechg.cxx | 6 ++++-- sw/source/core/text/widorp.cxx | 3 ++- 4 files changed, 14 insertions(+), 8 deletions(-)
New commits: commit 363aa5dbb2c223b6cc3a109bd654f39772e310fa Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Fri Jan 29 13:10:30 2016 +0100 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 <vmik...@collabora.co.uk> Tested-by: Jenkins <c...@libreoffice.org> diff --git a/sw/source/core/inc/pagefrm.hxx b/sw/source/core/inc/pagefrm.hxx index 2df4c1d..3fae2a3 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 aa4e4a5..a5fd16c 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 967ee2f..42ae8ac 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 c75a958..7c22b12 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; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits