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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Jan 21 23:33:44 UTC 2019


 sw/source/core/text/txtfrm.cxx |   38 ++++++++++++++------------------------
 1 file changed, 14 insertions(+), 24 deletions(-)

New commits:
commit 33d8302a85ec3d67f9cfbfc9cf3e6d5d7c045ec4
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Mon Jan 21 12:30:20 2019 +0100
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Tue Jan 22 00:33:21 2019 +0100

    sw_redlinehide: fix assert caused by buggy lcl_ModifyOfst
    
    converting ooo67907-1.doc to ODT asserts in fillSoftPageBreakList()
    while mapping an invalid (too large) GetOfst() of a follow frame.
    
    There are some problems with the lcl_ModifyOfst() implementation and
    usage:
    
    1. the implementation iterates over all follows; but the follows will
       get the same SwClientNotify() call as the frame itself, so in effect
       the follows' Ofsts will be modified multiple times
    
    2. the calls to lcl_ModifyOfst pass in a positive nLen whether the
       text is deleted or inserted; surely for deletions the Ofst should be
       subtracted from instead of added to
    
    3. the special-casing of RES_DEL_CHR to COMPLETE_STRING while
       RES_DEL_TXT uses the length does not appear to be justified
    
    The assert happens since b15f1ed2a1df45a57b587ac90efa90c1c18866fc
    but the lcl_ModifyOfst logic never made sense.
    
    Change-Id: Ie92628515bbee0fcc2123eb412057d8c0fd0b2f1
    Reviewed-on: https://gerrit.libreoffice.org/66679
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>
    (cherry picked from commit 0acde7514e666fc04805fd36503bd174162336ca)
    Reviewed-on: https://gerrit.libreoffice.org/66683
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    (cherry picked from commit d246374dc71ee557de5811e1971a82e0f6145509)
    Reviewed-on: https://gerrit.libreoffice.org/66710
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index ae72ea15fbc3..55190d2a75c4 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -1793,17 +1793,15 @@ static void lcl_SetScriptInval(SwTextFrame& rFrame, TextFrameIndex const nPos)
         rFrame.GetPara()->GetScriptInfo().SetInvalidityA( nPos );
 }
 
-static void lcl_ModifyOfst(SwTextFrame* pFrame, TextFrameIndex const nPos, TextFrameIndex const nLen)
+// note: SwClientNotify will be called once for every frame => just fix own Ofst
+static void lcl_ModifyOfst(SwTextFrame & rFrame,
+        TextFrameIndex const nPos, TextFrameIndex const nLen,
+        TextFrameIndex (* op)(TextFrameIndex const&, TextFrameIndex const&))
 {
-    while( pFrame && pFrame->GetOfst() <= nPos )
-        pFrame = pFrame->GetFollow();
-    while( pFrame )
+    assert(nLen != TextFrameIndex(COMPLETE_STRING));
+    if (rFrame.IsFollow() && nPos < rFrame.GetOfst())
     {
-        if (nLen == TextFrameIndex(COMPLETE_STRING))
-            pFrame->ManipOfst(TextFrameIndex(pFrame->GetText().getLength()));
-        else
-            pFrame->ManipOfst( pFrame->GetOfst() + nLen );
-        pFrame = pFrame->GetFollow();
+        rFrame.ManipOfst( op(rFrame.GetOfst(), nLen) );
     }
 }
 
@@ -1864,11 +1862,8 @@ void UpdateMergedParaForMove(sw::MergedPara & rMerged,
             {
                 // InvalidateRange/lcl_SetScriptInval was called sufficiently for SwInsText
                 lcl_SetWrong(rTextFrame, rDestNode, nStart, it.first - it.second, false);
-                if (rTextFrame.HasFollow())
-                {
-                    TextFrameIndex const nIndex(sw::MapModelToView(rMerged, &rDestNode, nStart));
-                    lcl_ModifyOfst(&rTextFrame, nIndex, nDeleted); // FIXME why positive?
-                }
+                TextFrameIndex const nIndex(sw::MapModelToView(rMerged, &rDestNode, nStart));
+                lcl_ModifyOfst(rTextFrame, nIndex, nDeleted, &o3tl::operator-<sal_Int32, Tag_TextFrameIndex>);
             }
         }
     }
@@ -1999,8 +1994,7 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint)
             {
                 lcl_SetScriptInval( *this, nPos );
                 bSetFieldsDirty = bRecalcFootnoteFlag = true;
-                if (HasFollow())
-                    lcl_ModifyOfst( this, nPos, nLen );
+                lcl_ModifyOfst(*this, nPos, nLen, &o3tl::operator-<sal_Int32, Tag_TextFrameIndex>);
             }
         }
     }
@@ -2028,8 +2022,7 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint)
             lcl_SetWrong( *this, rNode, nNPos, nNLen, false );
             lcl_SetScriptInval( *this, nPos );
             bSetFieldsDirty = true;
-            if (HasFollow())
-                lcl_ModifyOfst( this, nPos, nLen );
+            lcl_ModifyOfst(*this, nPos, nLen, &o3tl::operator+<sal_Int32, Tag_TextFrameIndex>);
         }
     }
     else if (pMoveText)
@@ -2087,8 +2080,7 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint)
             lcl_SetWrong( *this, rNode, nNPos, nNLen, true );
             lcl_SetScriptInval( *this, nPos );
             bSetFieldsDirty = true;
-            if( HasFollow() )
-                lcl_ModifyOfst( this, nPos, nLen );
+            lcl_ModifyOfst(*this, nPos, nLen, &o3tl::operator+<sal_Int32, Tag_TextFrameIndex>);
         }
         break;
         case RES_DEL_CHR:
@@ -2109,8 +2101,7 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint)
                 InvalidateRange( SwCharRange(nPos, nLen), -1 );
                 lcl_SetScriptInval( *this, nPos );
                 bSetFieldsDirty = bRecalcFootnoteFlag = true;
-                if (HasFollow())
-                    lcl_ModifyOfst(this, nPos, TextFrameIndex(COMPLETE_STRING));
+                lcl_ModifyOfst(*this, nPos, nLen, &o3tl::operator-<sal_Int32, Tag_TextFrameIndex>);
             }
         }
         break;
@@ -2140,8 +2131,7 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint)
             {
                 lcl_SetScriptInval( *this, nPos );
                 bSetFieldsDirty = bRecalcFootnoteFlag = true;
-                if (HasFollow())
-                    lcl_ModifyOfst( this, nPos, nLen );
+                lcl_ModifyOfst(*this, nPos, nLen, &o3tl::operator-<sal_Int32, Tag_TextFrameIndex>);
             }
         }
         break;


More information about the Libreoffice-commits mailing list