sw/source/core/text/porfld.cxx |   14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

New commits:
commit eb7fbe1f3a37d89b97bd8976bdc006099578c204
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Fri Mar 11 21:47:43 2022 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Sat Mar 12 11:52:19 2022 +0100

    an inconsistent SwTextFormatInfo index, len, text length case
    
    seen on loading sw/qa/python/testdocuments/TESTMETA.odt
    
    maybe since:
    
    commit 2f3684b2289a8c46dc6144064a452cc529400f28
    Date:   Tue Jul 31 16:00:02 2018 +0200
    
        [API CHANGE] add some more asserts to the string functions
    
    but probably an underlying issue since conversion from UniString
    to OUString
    
    Change-Id: If731163fbc5e05b813ccd21df65164fe476cba9a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131407
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx
index 12805b33b039..47a55150ab3f 100644
--- a/sw/source/core/text/porfld.cxx
+++ b/sw/source/core/text/porfld.cxx
@@ -175,10 +175,18 @@ SwFieldSlot::SwFieldSlot( const SwTextFormatInfo* pNew, 
const SwFieldPortion *pP
         pInf->SetFakeLineStart( nIdx > pInf->GetLineStart() );
         pInf->SetIdx(TextFrameIndex(0));
     }
-    else if (nIdx < TextFrameIndex(pOldText->getLength()))
+    else
     {
-        sal_Int32 const nFieldLen(pPor->GetFieldLen());
-        aText = (*pOldText).replaceAt(sal_Int32(nIdx), nFieldLen, aText);
+        TextFrameIndex nEnd(pOldText->getLength());
+        if (nIdx < nEnd)
+        {
+            sal_Int32 const nFieldLen(pPor->GetFieldLen());
+            aText = (*pOldText).replaceAt(sal_Int32(nIdx), nFieldLen, aText);
+        }
+        else if (nIdx == nEnd)
+            aText = *pOldText + aText;
+        else
+            SAL_WARN("sw.core", "SwFieldSlot bad SwFieldPortion index.");
     }
     pInf->SetText( aText );
 }

Reply via email to