From 8f35d65bf3ad781bd38477a5770d5855322e0bf6 Mon Sep 17 00:00:00 2001 From: Patrick Jaap Date: Fri, 6 Sep 2019 10:50:05 +0200 Subject: tdf#127235 break if object is larger than page We will always have an overlap if the object is larger than the whole page. Look for the next page style: if it is missing or the same as the current, we simply stop. Change-Id: I699d5146d215f17b4775dbcb32811fa5b6ebf60d Reviewed-on: https://gerrit.libreoffice.org/78696 Tested-by: Jenkins Reviewed-by: Miklos Vajna Reviewed-on: https://gerrit.libreoffice.org/79104 --- sw/source/core/text/txtfly.cxx | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'sw/source') diff --git a/sw/source/core/text/txtfly.cxx b/sw/source/core/text/txtfly.cxx index e16cd878ce75..18bec6284a57 100644 --- a/sw/source/core/text/txtfly.cxx +++ b/sw/source/core/text/txtfly.cxx @@ -998,6 +998,24 @@ bool SwTextFly::ForEach( const SwRect &rRect, SwRect* pRect, bool bAvoid ) const { SwSwapIfSwapped swap(const_cast(m_pCurrFrame)); + // Optimization + SwRectFnSet aRectFnSet(m_pCurrFrame); + + // tdf#127235 stop if the area is larger than the page + if( aRectFnSet.GetHeight(pPage->getFrameArea()) < aRectFnSet.GetHeight(rRect)) + { + // get the doc model description + const SwPageDesc* pPageDesc = pPage->GetPageDesc(); + + // if there is no next page style or it is the same as the current + // => stop trying to place the frame (it would end in an infinite loop) + if( pPageDesc && + ( !pPageDesc->GetFollow() || pPageDesc->GetFollow() == pPageDesc) ) + { + return false; + } + } + bool bRet = false; // #i68520# const SwAnchoredObjList::size_type nCount( bOn ? GetAnchoredObjList()->size() : 0 ); @@ -1010,10 +1028,9 @@ bool SwTextFly::ForEach( const SwRect &rRect, SwRect* pRect, bool bAvoid ) const SwRect aRect( pAnchoredObj->GetObjRectWithSpaces() ); - // Optimization - SwRectFnSet aRectFnSet(m_pCurrFrame); if( aRectFnSet.GetLeft(aRect) > aRectFnSet.GetRight(rRect) ) break; + // #i68520# if ( mpCurrAnchoredObj != pAnchoredObj && aRect.IsOver( rRect ) ) { -- cgit