path: root/sw/source
diff options
authorMichael Stahl <>2021-05-05 12:21:42 +0200
committerMichael Stahl <>2021-05-05 16:55:23 +0200
commited12269c42f75f553bb8a8770923406f7824e473 (patch)
tree447c718baea4da603ff09c351efb1525c0a46b19 /sw/source
parentc6d0986acb50941d30257cb497466066badfcaa1 (diff)
tdf#142080 sw: layout: fix infinite loop in CalcContent()
On page 9, SwSectionFrame::Format() calls CalcContent() and that formats all its content frames, then on SwTextFrame 91 SwObjectFormatter::FormatObj() fails becuase it moved forward. With commit c799de145f7e289f31e3669646e5bd12814e6c5e this now sets the o_rbPageHasFlysAnchoredBelowThis to true, which prevents a call to SwLayouter::InsertMovedFwdFrame(), and the flys anchored in next frames aren't moved off the page at this time. Then the loop starts over at the beginning of the SwSectionFrame, and frame 91 will be formatted again because the loop tries to format the first frame on the next page to see if it will move back; now the MoveBwd() isn't prevented any more so the result is the same failure in SwObjectFormatter::FormatObj(). Fix this by ignoring the bRestartLayoutProcess in case the current frame was originally on the next page and didn't move back (or, as is the case here, moved back and then forward again); it should just be formatted again on the next page. Once that happens, it will eventually be entered into SwLayouter::InsertMovedFwdFrame() too. This happens to fix another problem with this bugdoc too: the first column of the section on page 9 is empty. This also happens in LO 6.4 but not LO 6.1. An alternative would be to move the flys anchored below off the page as is done in SwLayAction::FormatContent() now but sections can be in flys or footnotes or headers so perhaps it should be done only at the top-level. (regression from c799de145f7e289f31e3669646e5bd12814e6c5e) Change-Id: I0965aebb4e3cec687f4e70f8d5e3aa8a55da3393 Reviewed-on: Tested-by: Jenkins Reviewed-by: Michael Stahl <>
Diffstat (limited to 'sw/source')
1 files changed, 9 insertions, 5 deletions
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index 84e52c6de46c..989870bfcb92 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -1466,6 +1466,7 @@ void CalcContent( SwLayoutFrame *pLay, bool bNoColl )
pLast = pFrame;
+ bool const wasFrameLowerOfLay(pLay->IsAnLower(pFrame));
if( pFrame->IsVertical() ?
( pFrame->GetUpper()->getFramePrintArea().Height() != pFrame->getFrameArea().Height() )
: ( pFrame->GetUpper()->getFramePrintArea().Width() != pFrame->getFrameArea().Width() ) )
@@ -1607,7 +1608,10 @@ void CalcContent( SwLayoutFrame *pLay, bool bNoColl )
// #i28701# - restart layout process, if
// requested by floating screen object formatting
- if ( bRestartLayoutProcess )
+ if (bRestartLayoutProcess
+ // tdf#142080 if it was aleady on next page, and still is,
+ // ignore restart, as restart could cause infinite loop
+ && (wasFrameLowerOfLay || pLay->IsAnLower(pFrame)))
pFrame = pLay->ContainsAny();
pAgainObj1 = nullptr;
@@ -1671,10 +1675,10 @@ void CalcContent( SwLayoutFrame *pLay, bool bNoColl )
- // Stay in the pLay
- // Except for SectionFrames with Follow: the first ContentFrame of the Follow
- // will be formatted, so that it gets a chance to load in the pLay.
- // As long as these Frames are loading in pLay, we continue
+ // Stay in the pLay.
+ // Except for SectionFrames with Follow: the first ContentFrame of the
+ // Follow will be formatted, so that it gets a chance to move back
+ // into the pLay. Continue as long as these Frames land in pLay.
} while ( pFrame &&
( pLay->IsAnLower( pFrame ) ||
( pSect &&