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

New commits:
commit 5ea863f55c0a6221c487e5352a7101d3c8564e5f
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Fri Mar 11 21:47:43 2022 +0000
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Mon Jun 20 11:23:32 2022 +0200

    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
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131407
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    (cherry picked from commit eb7fbe1f3a37d89b97bd8976bdc006099578c204)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132860
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit 177589cb4f8ef20ff84dbfc141b145b28e57be83)
    
    Change-Id: If731163fbc5e05b813ccd21df65164fe476cba9a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133902
    Tested-by: Michael Stahl <michael.st...@allotropia.de>
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx
index a5eb9b99ce9b..776770915e2e 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