From 177589cb4f8ef20ff84dbfc141b145b28e57be83 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 11 Mar 2022 21:47:43 +0000 Subject: an inconsistent SwTextFormatInfo index, len, text length case MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 (cherry picked from commit eb7fbe1f3a37d89b97bd8976bdc006099578c204) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132860 Reviewed-by: Michael Stahl --- sw/source/core/text/porfld.cxx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx index 21ab8eecd351..4178ea35f34a 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 ); } -- cgit