sw/source/core/txtnode/swfont.cxx |   20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

New commits:
commit 2330252b1b27795a57b5eea738621fda9fe1b549
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Wed Sep 13 10:39:21 2023 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Thu Sep 14 18:42:28 2023 +0200

    crashtesting: fix PDF export of forum-mso-de-118466.docx
    
    This went wrong in commit 19a559b0ec9b806519c405651d6d2b2e14712b4a (sw:
    SwSubFont::GetTextSize_() assert on presumably dead code, 2019-10-14):
    
    - as the bugdoc shows, it's not dead code after all, so downgrade the
      assert to a warning
    
    - SwDrawTextInfo::SetText/Idx/Len asserts that the index and length are
      valid for the text, so set / restore these together
    
    Change-Id: I967605324bde757ca11e6684ba6f40c578a211fb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156891
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    (cherry picked from commit 297e0b6bdd6fb682974f9e3201c7842dd76e31c8)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156885
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sw/source/core/txtnode/swfont.cxx 
b/sw/source/core/txtnode/swfont.cxx
index c0149d9a6573..c6d9c3ace26e 100644
--- a/sw/source/core/txtnode/swfont.cxx
+++ b/sw/source/core/txtnode/swfont.cxx
@@ -1061,30 +1061,26 @@ Size SwSubFont::GetTextSize_( SwDrawTextInfo& rInf )
     if (TextFrameIndex(1) == rInf.GetLen()
         && CH_TXT_ATR_FIELDSTART == rInf.GetText()[sal_Int32(rInf.GetIdx())])
     {
-        assert(!"this is presumably dead code");
+        SAL_WARN("sw", "this is meant to be dead code");
         TextFrameIndex const nOldIdx(rInf.GetIdx());
         TextFrameIndex const nOldLen(rInf.GetLen());
+        OUString aOldText(rInf.GetText());
         const OUString aNewText(CH_TXT_ATR_SUBST_FIELDSTART);
-        rInf.SetText( aNewText );
-        rInf.SetIdx( TextFrameIndex(0) );
-        rInf.SetLen( TextFrameIndex(aNewText.getLength()) );
+        rInf.SetTextIdxLen(aNewText, TextFrameIndex(0), 
TextFrameIndex(aNewText.getLength()));
         aTextSize = pLastFont->GetTextSize( rInf );
-        rInf.SetIdx( nOldIdx );
-        rInf.SetLen( nOldLen );
+        rInf.SetTextIdxLen(aOldText, nOldIdx, nOldLen);
     }
     else if (TextFrameIndex(1) == rInf.GetLen()
             && CH_TXT_ATR_FIELDEND == rInf.GetText()[sal_Int32(rInf.GetIdx())])
     {
-        assert(!"this is presumably dead code");
+        SAL_WARN("sw", "this is meant to be dead code");
         TextFrameIndex const nOldIdx(rInf.GetIdx());
         TextFrameIndex const nOldLen(rInf.GetLen());
+        OUString aOldText(rInf.GetText());
         const OUString aNewText(CH_TXT_ATR_SUBST_FIELDEND);
-        rInf.SetText( aNewText );
-        rInf.SetIdx( TextFrameIndex(0) );
-        rInf.SetLen( TextFrameIndex(aNewText.getLength()) );
+        rInf.SetTextIdxLen(aNewText, TextFrameIndex(0), 
TextFrameIndex(aNewText.getLength()));
         aTextSize = pLastFont->GetTextSize( rInf );
-        rInf.SetIdx( nOldIdx );
-        rInf.SetLen( nOldLen );
+        rInf.SetTextIdxLen(aOldText, nOldIdx, nOldLen);
     }
 
     return aTextSize;

Reply via email to