sw/qa/extras/layout/data/ofz64109-1.fodt |binary
 sw/qa/extras/layout/layout3.cxx          |    6 ++++++
 sw/source/core/text/porfld.cxx           |   10 ++++++++++
 3 files changed, 16 insertions(+)

New commits:
commit 72928fa459f8e67c30a2e2357424ab75d3105a26
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Sat Nov 18 21:56:51 2023 +0000
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Mon Nov 20 12:36:27 2023 +0100

    ofz#64109 crash in CharClass::isLetterNumeric
    
    there appears to be an extra portion created, because HookChar is
    set, but there doesn't seem to be a reason for the HookChar so we
    get an unwanted trailing portion.
    
    It seems that the HookChar is set when processing the field, presumably
    when we restore the SwTextFormatInfo text, idx and len we should also
    restore its original HookChar state.
    
    At least for this ruby text case there the field contents are drawn over
    the body text, unlike others where the contents are drawn inline with
    the body text, where we appear to need to keep the hook char.
    
    Change-Id: Id48a3ef09cd10dcc91048f8c08207d2d105839d9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159642
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sw/qa/extras/layout/data/ofz64109-1.fodt 
b/sw/qa/extras/layout/data/ofz64109-1.fodt
new file mode 100644
index 000000000000..26a4bbbf63cf
Binary files /dev/null and b/sw/qa/extras/layout/data/ofz64109-1.fodt differ
diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx
index 11b9aec05ad2..797b41fc7baf 100644
--- a/sw/qa/extras/layout/layout3.cxx
+++ b/sw/qa/extras/layout/layout3.cxx
@@ -786,6 +786,12 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testAbi11870)
     createSwDoc("abi11870-2.odt");
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testOfz64109)
+{
+    //just care it doesn't assert
+    createSwDoc("ofz64109-1.fodt");
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf118719)
 {
     // Insert a page break.
diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx
index 580b4a2635a7..1a30a4ecd7d1 100644
--- a/sw/source/core/text/porfld.cxx
+++ b/sw/source/core/text/porfld.cxx
@@ -145,6 +145,7 @@ class SwFieldSlot
     OUString aText;
     TextFrameIndex nIdx;
     TextFrameIndex nLen;
+    sal_Unicode nOrigHookChar;
     SwTextFormatInfo *pInf;
     bool bOn;
 public:
@@ -158,6 +159,7 @@ SwFieldSlot::SwFieldSlot( const SwTextFormatInfo* pNew, 
const SwFieldPortion *pP
     : pOldText(nullptr)
     , nIdx(0)
     , nLen(0)
+    , nOrigHookChar(0)
     , pInf(nullptr)
 {
     bOn = pPor->GetExpText( *pNew, aText );
@@ -170,6 +172,7 @@ SwFieldSlot::SwFieldSlot( const SwTextFormatInfo* pNew, 
const SwFieldPortion *pP
     nIdx = pInf->GetIdx();
     nLen = pInf->GetLen();
     pOldText = &(pInf->GetText());
+    nOrigHookChar = pInf->GetHookChar();
     m_pOldCachedVclData = pInf->GetCachedVclData();
     pInf->SetLen(TextFrameIndex(aText.getLength()));
     pInf->SetCachedVclData(nullptr);
@@ -200,6 +203,13 @@ SwFieldSlot::~SwFieldSlot()
     {
         pInf->SetCachedVclData(m_pOldCachedVclData);
         pInf->SetText( *pOldText );
+        // ofz#64109 at last for ruby-text when we restore the original text to
+        // continue laying out the 'body' text of the ruby, then a tab or other
+        // 'hook char' in the text drawn above it shouldn't affect the 'body'
+        // While there are other cases, such as tdf#148360, where the tab in an
+        // inline expanded field, that should affect the body.
+        if (pInf->IsRuby())
+            pInf->SetHookChar(nOrigHookChar);
         pInf->SetIdx( nIdx );
         pInf->SetLen( nLen );
         pInf->SetFakeLineStart( false );

Reply via email to