[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-1+backports' - sw/source

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Tue May 7 15:05:54 UTC 2019


 sw/source/core/text/frmform.cxx |    9 ++++++++-
 sw/source/core/text/txtfrm.cxx  |    2 +-
 2 files changed, 9 insertions(+), 2 deletions(-)

New commits:
commit 6e449edb283151fa37b356a73b7bb23df0612ad0
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Mon May 6 15:40:41 2019 +0200
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Tue May 7 17:05:16 2019 +0200

    tdf#122892 tdf#124366 sw: fix loop in SwTextFrame::CalcFollow()
    
    ... differently; commit b7d4418c309c8bc4fd25485dd3a0ea6ad9edf34e
    was partially wrong because if SetPrepWidows() isn't called and the
    master and follow have fewer lines than the sum of orphans and
    widows, then the frames must be merged, i.e., master must move
    forward to the next page and follow must be deleted, but that only
    happens with SetPrepWidows().
    
    However if the SwTextFrame::PrepWidows() determines that no lines can be
    moved from the master, SwTextFrame::CalcPreps() will grow the master
    to force it to move to the next page, and then it sets SetWidow() too,
    so check this flag to break the loop in SwTextFrame::CalcFollow().
    
    Another question is what is the point of the "very cheesy" follow
    formatting fall-back, which might be removable.
    
    Change-Id: I0769a5a4f13ca4c95c2229a496207809d05576f9
    Reviewed-on: https://gerrit.libreoffice.org/71866
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>
    (cherry picked from commit 1caea03fcc6c24e38b2d1d9f6097ad84183ffefd)
    Reviewed-on: https://gerrit.libreoffice.org/71872
    Reviewed-by: Adolfo Jayme Barrientos <fitojb at ubuntu.com>
    (cherry picked from commit 1c4b53909b2a1c99dfcb5bbbb1685e5100c503c6)
    Reviewed-on: https://gerrit.libreoffice.org/71907
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/sw/source/core/text/frmform.cxx b/sw/source/core/text/frmform.cxx
index 176914b69040..a344ab23734a 100644
--- a/sw/source/core/text/frmform.cxx
+++ b/sw/source/core/text/frmform.cxx
@@ -237,7 +237,14 @@ bool SwTextFrame::CalcFollow(TextFrameIndex const nTextOfst)
         if ( !pMyFollow->GetNext() && !pMyFollow->HasFootnote() )
             nOldBottom =  aRectFnSet.IsVert() ? 0 : LONG_MAX;
 
-        while( true )
+        // tdf#122892 check flag:
+        // 1. WidowsAndOrphans::FindWidows() determines follow is a widow
+        // 2. SwTextFrame::PrepWidows() calls SetPrepWidows() on master;
+        //    if it can spare lines, master truncates one line
+        // 3. SwTextFrame::CalcPreps() on master (below);
+        //    unless IsPrepMustFit(), if master hasn't shrunk via 2., it will SetWidow()
+        // 4. loop must exit then, because the follow didn't grow so nothing will ever change
+        while (!IsWidow())
         {
             if( !FormatLevel::LastLevel() )
             {
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index 19b10d330126..cae759185a0b 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -2552,6 +2552,7 @@ void SwTextFrame::PrepWidows( const sal_uInt16 nNeed, bool bNotify )
     SwParaPortion *pPara = GetPara();
     if ( !pPara )
         return;
+    pPara->SetPrepWidows();
 
     sal_uInt16 nHave = nNeed;
 
@@ -2583,7 +2584,6 @@ void SwTextFrame::PrepWidows( const sal_uInt16 nNeed, bool bNotify )
 
         if( bSplit )
         {
-            pPara->SetPrepWidows();
             GetFollow()->SetOfst( aLine.GetEnd() );
             aLine.TruncLines( true );
             if( pPara->IsFollowField() )


More information about the Libreoffice-commits mailing list