diff options
authorMichael Stahl <>2019-02-26 18:47:46 +0100
committerMichael Stahl <>2019-03-04 11:09:02 +0100
commitb7d4418c309c8bc4fd25485dd3a0ea6ad9edf34e (patch)
parent3abe1e83c18c5778d60252092e9cc70c4c63268b (diff)
tdf#122892 sw: fix IsPrepWidow() loop in SwTextFrame::CalcFollow()
The bugdoc loops on calculating the follow of SwTextFrame 560, the one containing "Hiermit nehme ich das Angebot an" in a cell with rowspan 3, while the table is being split and its first row (also now its last i.e. split row) is being formatted. Loop in CalcFollow() because the follow is in the same upper frame as its master and cannot move forward, so the 2nd call to pMyFollow->Calc() after pMyFollow->Prepare() always sets the SetPrepWidows() flag on the master and in that case the loop never terminates. The problem is that the check in WidowsAndOrphans::FindWidows() of GetThisLines() uses stale cached data - the value returned is 4, but the frame contains fewer lines at that point and doesn't have lines to spare for the follow; the cached value is only updated at the end of SwTextFrame::Format(). Fix it by calling ChgThisLines() here. But this fix only helps for the first SwTextFrame in a cell; the next one with id 561 loops in a similar way. The problem then is that SwTextFrame::PrepWidows() always calls SetPrepWidows(), even if the Orphan-rule of the frame prevents it from giving lines to the follow. Fix this by calling SetPrepWidows() only if lines are removed. This also helps for the 2 attachments of tdf#118104. (regression from commit 18765b9fa739337d2d891513f6e2fb7c3ce23b50 particularly the change in SwFrame::IsMoveable() in the sense that it didn't loop before but there isn't anything obviously wrong with this commit) Change-Id: Ia1e5928a6510e68520b29eb265e26ffd0627c52e Reviewed-on: Tested-by: Jenkins Reviewed-by: Michael Stahl <>
2 files changed, 2 insertions, 1 deletions
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index 2eaaaeb1afb3..85a179880780 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -2601,7 +2601,6 @@ void SwTextFrame::PrepWidows( const sal_uInt16 nNeed, bool bNotify )
SwParaPortion *pPara = GetPara();
if ( !pPara )
- pPara->SetPrepWidows();
sal_uInt16 nHave = nNeed;
@@ -2633,6 +2632,7 @@ void SwTextFrame::PrepWidows( const sal_uInt16 nNeed, bool bNotify )
if( bSplit )
+ pPara->SetPrepWidows();
GetFollow()->SetOfst( aLine.GetEnd() );
aLine.TruncLines( true );
if( pPara->IsFollowField() )
diff --git a/sw/source/core/text/widorp.cxx b/sw/source/core/text/widorp.cxx
index 1e47974f5340..d049fc79b0c0 100644
--- a/sw/source/core/text/widorp.cxx
+++ b/sw/source/core/text/widorp.cxx
@@ -459,6 +459,7 @@ bool WidowsAndOrphans::FindWidows( SwTextFrame *pFrame, SwTextMargin &rLine )
// i#91421
if ( !pMaster->GetIndPrev() )
+ pMaster->ChgThisLines();
sal_uLong nLines = pMaster->GetThisLines();
if(nLines == 0 && pMaster->HasPara())