sw/source/core/txtnode/ndtxt.cxx |   48 +++++++++++++++------------------------
 1 file changed, 19 insertions(+), 29 deletions(-)

New commits:
commit e14fc683536ec2926c70ea94dfd7a549a9bc1460
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Thu Aug 8 17:39:02 2024 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Fri Aug 9 11:41:42 2024 +0200

    sw: fix SwTextNode::MoveTextAttr_To_AttrSet()
    
    ... and use it on both on the SwTextNodes after the split.
    
    The problem is that it doesn't do anything because it puts a
    RES_TXTATR_AUTOFMT directly into the node's item set, but that can
    contain only RES_CHRATR* items.
    
    Change-Id: I0274652651d1223e905cbd42f4da5458f0106d95
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171644
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 65fc7a9539c2..f71f2da5830b 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -592,6 +592,7 @@ SwTextNode *SwTextNode::SplitContentNode(const SwPosition & 
rPos,
         if ( HasHints() )
         {
             MoveTextAttr_To_AttrSet();
+            pNode->MoveTextAttr_To_AttrSet();
         }
         // in case there are frames, the RegisterToNode has set the merge flag
         pNode->MakeFramesForAdjacentContentNode(*this);
@@ -636,6 +637,7 @@ SwTextNode *SwTextNode::SplitContentNode(const SwPosition & 
rPos,
                 }
             }
             MoveTextAttr_To_AttrSet();
+            pNode->MoveTextAttr_To_AttrSet();
         }
 
         if( pList )
@@ -742,30 +744,7 @@ SwTextNode *SwTextNode::SplitContentNode(const SwPosition 
& rPos,
     {
         // We just created an empty next node: avoid unwanted superscript in 
the new node if it's
         // there.
-        for (size_t i = 0; i < m_pSwpHints->Count(); ++i)
-        {
-            SwTextAttr* pHt = m_pSwpHints->Get(i);
-            if (pHt->Which() != RES_TXTATR_AUTOFMT)
-            {
-                continue;
-            }
-
-            const sal_Int32* pEnd = pHt->GetEnd();
-            if (!pEnd || pHt->GetStart() != *pEnd)
-            {
-                continue;
-            }
-
-            const std::shared_ptr<SfxItemSet>& pSet = 
pHt->GetAutoFormat().GetStyleHandle();
-            if (!pSet || pSet->Count() != 1 || 
!pSet->HasItem(RES_CHRATR_ESCAPEMENT))
-            {
-                continue;
-            }
-
-            m_pSwpHints->DeleteAtPos(i);
-            SwTextAttr::Destroy(pHt);
-            --i;
-        }
+        ResetAttr(RES_CHRATR_ESCAPEMENT);
     }
 
 #ifndef NDEBUG
@@ -848,12 +827,23 @@ void SwTextNode::MoveTextAttr_To_AttrSet()
         if (*pHtEndIdx < m_Text.getLength() || pHt->IsCharFormatAttr())
             break;
 
-        if( !pHt->IsDontMoveAttr() &&
-            SetAttr( pHt->GetAttr() ) )
+        if (!pHt->IsDontMoveAttr())
         {
-            m_pSwpHints->DeleteAtPos(i);
-            DestroyAttr( pHt );
-            --i;
+            bool isInserted(false);
+            if (pHt->Which() == RES_TXTATR_AUTOFMT)
+            {
+                isInserted = SetAttr(*pHt->GetAutoFormat().GetStyleHandle());
+            }
+            else
+            {
+                isInserted = SetAttr(pHt->GetAttr());
+            }
+            if (isInserted)
+            {
+                m_pSwpHints->DeleteAtPos(i);
+                DestroyAttr( pHt );
+                --i;
+            }
         }
     }
 

Reply via email to