include/svl/hint.hxx                          |    1 +
 sw/inc/hintids.hxx                            |    1 -
 sw/inc/hints.hxx                              |    6 ++++++
 sw/inc/ndtxt.hxx                              |    2 ++
 sw/inc/swevent.hxx                            |   10 ++++++++--
 sw/source/core/attr/calbck.cxx                |    2 +-
 sw/source/core/attr/format.cxx                |    9 +++++++--
 sw/source/core/crsr/bookmark.cxx              |    8 ++------
 sw/source/core/doc/acmplwrd.cxx               |    4 +++-
 sw/source/core/docnode/section.cxx            |   15 +++++++++------
 sw/source/core/draw/dcontact.cxx              |   10 +++++++---
 sw/source/core/layout/atrfrm.cxx              |   11 +++++++----
 sw/source/core/tox/tox.cxx                    |   13 +++++++------
 sw/source/core/txtnode/atrfld.cxx             |   17 ++++++++---------
 sw/source/core/txtnode/atrftn.cxx             |   13 +++++++------
 sw/source/core/txtnode/atrref.cxx             |   13 +++++++------
 sw/source/core/txtnode/attrcontentcontrol.cxx |   17 +++++++++--------
 sw/source/core/txtnode/attrlinebreak.cxx      |   11 ++++++-----
 sw/source/core/txtnode/fmtatr2.cxx            |   15 +++++++++------
 sw/source/core/txtnode/ndtxt.cxx              |   19 ++++++++++++++++---
 sw/source/core/unocore/unofield.cxx           |    3 ++-
 sw/source/core/unocore/unoidx.cxx             |    8 ++------
 22 files changed, 126 insertions(+), 82 deletions(-)

New commits:
commit 218023f3eacc1ca898cf07c5fc47aa5ebab10aaf
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Mon Dec 23 13:46:20 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Dec 24 10:45:31 2024 +0100

    move RES_REMOVE_UNO_OBJECT to SfxHint
    
    Change-Id: I82936e0ddb685746a714e1929fc7682a68ef4d09
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179240
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/include/svl/hint.hxx b/include/svl/hint.hxx
index 7a55b0f9de03..76749341f41b 100644
--- a/include/svl/hint.hxx
+++ b/include/svl/hint.hxx
@@ -229,6 +229,7 @@ enum class SfxHintId {
     SwGrfRereadAndInCache,
     SwFindUnoTextTableRowInstance,
     SwFindUnoCellInstance,
+    SwRemoveUnoObject,
 
     ThisIsAnSdrHint,
     ThisIsAnSfxEventHint
diff --git a/sw/inc/hintids.hxx b/sw/inc/hintids.hxx
index 546ef7019c08..dd231fa41392 100644
--- a/sw/inc/hintids.hxx
+++ b/sw/inc/hintids.hxx
@@ -432,7 +432,6 @@ inline constexpr TypedWhichId<SwFormatChg> RES_FMT_CHG(168);
 inline constexpr TypedWhichId<SwAttrSetChg> RES_ATTRSET_CHG(169);
 inline constexpr TypedWhichId<SwUpdateAttr> RES_UPDATE_ATTR(170);
 inline constexpr TypedWhichId<SwMsgPoolItem> RES_HIDDENPARA_PRINT(178);
-inline constexpr TypedWhichId<SwPtrMsgPoolItem> RES_REMOVE_UNO_OBJECT(181);
 // empty
 inline constexpr sal_uInt16 RES_FORMAT_MSG_END(190);
 
diff --git a/sw/inc/hints.hxx b/sw/inc/hints.hxx
index 11589fb827ba..b38ccae0089e 100644
--- a/sw/inc/hints.hxx
+++ b/sw/inc/hints.hxx
@@ -310,6 +310,12 @@ public:
     void SetUsed() const { m_isUsed = true; }
     void CheckNode(const SwNode*) const;
 };
+class RemoveUnoObjectHint final : public SfxHint
+{
+public:
+    const BroadcastingModify* m_pObject;
+    RemoveUnoObjectHint(const BroadcastingModify* pObject) : 
SfxHint(SfxHintId::SwRemoveUnoObject), m_pObject(pObject) {}
+};
 }
 
 class SwUpdateAttr final : public SwMsgPoolItem
diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx
index 174a88e74c53..47ecca334642 100644
--- a/sw/inc/ndtxt.hxx
+++ b/sw/inc/ndtxt.hxx
@@ -71,6 +71,7 @@ class SwField;
 
 namespace sw {
     class TextNodeNotificationSuppressor;
+    class RemoveUnoObjectHint;
     namespace mark { enum class RestoreMode; }
 }
 
@@ -241,6 +242,7 @@ public:
     void UpdateDocPos(const SwTwips nDocPos, const sal_uInt32 nIndex);
     /// for hanging TextFormatCollections somewhere else (Outline-Numbering!)
     void TriggerNodeUpdate(const sw::LegacyModifyHint&);
+    void TriggerNodeUpdate(const sw::RemoveUnoObjectHint&);
 
     const OUString& GetText() const { return m_Text; }
 
diff --git a/sw/inc/swevent.hxx b/sw/inc/swevent.hxx
index 11e33ef3ef93..f011b8cc64ea 100644
--- a/sw/inc/swevent.hxx
+++ b/sw/inc/swevent.hxx
@@ -116,6 +116,14 @@ struct SwCallMouseEvent final
 
     virtual void SwClientNotify(const SwModify& rMod, const SfxHint& rHint) 
override
     {
+        if(SfxHintId::SwRemoveUnoObject == rHint.GetId())
+        {
+            assert(EVENT_OBJECT_IMAGE == eType || EVENT_OBJECT_URLITEM == 
eType || EVENT_OBJECT_IMAGEMAP == eType);
+            SwClient::SwClientNotify(rMod, rHint);
+            if (!GetRegisteredIn() || static_cast<const 
sw::RemoveUnoObjectHint&>(rHint).m_pObject == PTR.pFormat)
+                Clear();
+            return;
+        }
         if (rHint.GetId() != SfxHintId::SwLegacyModify)
             return;
         auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
@@ -127,8 +135,6 @@ struct SwCallMouseEvent final
             case RES_FMT_CHG:
                 bClear |= 
pLegacy->m_pOld->StaticWhichCast(RES_FMT_CHG).pChangedFormat == PTR.pFormat;
                 break;
-            case RES_REMOVE_UNO_OBJECT:
-                bClear |= 
pLegacy->m_pOld->StaticWhichCast(RES_REMOVE_UNO_OBJECT).pObject == PTR.pFormat;
         }
         if(bClear)
             Clear();
diff --git a/sw/source/core/attr/calbck.cxx b/sw/source/core/attr/calbck.cxx
index 6bd48c17d794..58a075ba6dff 100644
--- a/sw/source/core/attr/calbck.cxx
+++ b/sw/source/core/attr/calbck.cxx
@@ -291,7 +291,7 @@ sw::ClientIteratorBase* 
sw::ClientIteratorBase::s_pClientIters = nullptr;
 
 void SwModify::SwClientNotify(const SwModify&, const SfxHint& rHint)
 {
-    if (rHint.GetId() != SfxHintId::SwLegacyModify)
+    if (rHint.GetId() != SfxHintId::SwLegacyModify && rHint.GetId() != 
SfxHintId::SwRemoveUnoObject)
         return;
 
     DBG_TESTSOLARMUTEX();
diff --git a/sw/source/core/attr/format.cxx b/sw/source/core/attr/format.cxx
index 019524a0689f..86cb2b484ad4 100644
--- a/sw/source/core/attr/format.cxx
+++ b/sw/source/core/attr/format.cxx
@@ -209,6 +209,11 @@ SwFormat::~SwFormat()
 
 void SwFormat::SwClientNotify(const SwModify&, const SfxHint& rHint)
 {
+    if (rHint.GetId() == SfxHintId::SwRemoveUnoObject)
+    {
+        SwModify::SwClientNotify(*this, rHint);
+        return;
+    }
     if (rHint.GetId() != SfxHintId::SwLegacyModify)
         return;
     auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
@@ -743,8 +748,8 @@ drawinglayer::attribute::SdrAllFillAttributesHelperPtr 
SwFormat::getSdrAllFillAt
 
 void SwFormat::RemoveAllUnos()
 {
-    SwPtrMsgPoolItem aMsgHint(RES_REMOVE_UNO_OBJECT, this);
-    SwClientNotify(*this, sw::LegacyModifyHint(&aMsgHint, &aMsgHint));
+    sw::RemoveUnoObjectHint aMsgHint(this);
+    SwClientNotify(*this, aMsgHint);
 }
 
 bool SwFormat::IsUsed() const
diff --git a/sw/source/core/crsr/bookmark.cxx b/sw/source/core/crsr/bookmark.cxx
index dfdff72931b6..5e62e948db5e 100644
--- a/sw/source/core/crsr/bookmark.cxx
+++ b/sw/source/core/crsr/bookmark.cxx
@@ -361,13 +361,9 @@ namespace sw::mark
     void MarkBase::SwClientNotify(const SwModify&, const SfxHint& rHint)
     {
         CallSwClientNotify(rHint);
-        if (rHint.GetId() != SfxHintId::SwLegacyModify)
-            return;
-        auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
-        if(RES_REMOVE_UNO_OBJECT == pLegacy->GetWhich())
-        {   // invalidate cached uno object
+        if(SfxHintId::SwRemoveUnoObject == rHint.GetId())
+           // invalidate cached uno object
             SetXBookmark(nullptr);
-        }
     }
 
     auto MarkBase::InvalidateFrames() -> void
diff --git a/sw/source/core/doc/acmplwrd.cxx b/sw/source/core/doc/acmplwrd.cxx
index 09ce4abf4ad3..ef4b0b2595da 100644
--- a/sw/source/core/doc/acmplwrd.cxx
+++ b/sw/source/core/doc/acmplwrd.cxx
@@ -145,12 +145,14 @@ void SwAutoCompleteClient::Notify(const SfxHint& rHint)
         case SfxHintId::Dying:
             DocumentDying();
             return;
+        case SfxHintId::SwRemoveUnoObject:
+            DocumentDying();
+            return;
         case SfxHintId::SwLegacyModify:
         {
             auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
             switch(pLegacy->GetWhich())
             {
-                case RES_REMOVE_UNO_OBJECT:
                 case RES_OBJECTDYING:
                     DocumentDying();
                     return;
diff --git a/sw/source/core/docnode/section.cxx 
b/sw/source/core/docnode/section.cxx
index d9ac1d35ddd6..5b8dbaffef43 100644
--- a/sw/source/core/docnode/section.cxx
+++ b/sw/source/core/docnode/section.cxx
@@ -704,7 +704,15 @@ void SwSectionFormat::SwClientNotify(const SwModify& rMod, 
const SfxHint& rHint)
             return;
         GetNotifier().Broadcast(rSectionHidden);
         return;
-    } else if (rHint.GetId() != SfxHintId::SwLegacyModify)
+    }
+    else if(SfxHintId::SwRemoveUnoObject == rHint.GetId())
+    {
+        SwFrameFormat::SwClientNotify(rMod, rHint);
+        // invalidate cached uno object
+        SetXTextSection(nullptr);
+        return;
+    }
+    else if (rHint.GetId() != SfxHintId::SwLegacyModify)
         return;
     auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
     sal_uInt16 nWhich = pLegacy->GetWhich();
@@ -787,11 +795,6 @@ void SwSectionFormat::SwClientNotify(const SwModify& rMod, 
const SfxHint& rHint)
         break;
     }
     SwFrameFormat::SwClientNotify(rMod, rHint);
-
-    if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which()))
-    {   // invalidate cached uno object
-        SetXTextSection(nullptr);
-    }
 }
 
 void SwSectionFormat::SetXTextSection(rtl::Reference<SwXTextSection> const& 
xTextSection)
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index 73393ea67e50..ce34c1ad9338 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -1415,7 +1415,13 @@ void SwDrawContact::SwClientNotify(const SwModify& rMod, 
const SfxHint& rHint)
 {
     SwClient::SwClientNotify(rMod, rHint); // needed as 
SwContact::SwClientNotify doesn't explicitly call SwClient::SwClientNotify
     SwContact::SwClientNotify(rMod, rHint);
-    if (rHint.GetId() == SfxHintId::SwLegacyModify)
+    if(SfxHintId::SwRemoveUnoObject == rHint.GetId())
+    {
+        // nothing to do
+        // #i51474#
+        GetAnchoredObj(nullptr)->ResetLayoutProcessBools();
+    }
+    else if (rHint.GetId() == SfxHintId::SwLegacyModify)
     {
         auto pLegacyHint = static_cast<const sw::LegacyModifyHint*>(&rHint);
         SAL_WARN_IF(mbDisconnectInProgress, "sw.core", 
"<SwDrawContact::Modify(..)> called during disconnection.");
@@ -1464,8 +1470,6 @@ void SwDrawContact::SwClientNotify(const SwModify& rMod, 
const SfxHint& rHint)
             else
                 DisconnectFromLayout();
         }
-        else if (nWhich == RES_REMOVE_UNO_OBJECT)
-        {} // nothing to do
         // --> #i62875# - no further notification, if not connected to Writer 
layout
         else if ( maAnchoredDrawObj.GetAnchorFrame() &&
                   maAnchoredDrawObj.GetDrawObj()->GetUserCall() )
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 7a68cda9d3b2..0caff1dd2bb9 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -2749,7 +2749,13 @@ bool 
SwFrameFormat::supportsFullDrawingLayerFillAttributeSet() const
 
 void SwFrameFormat::SwClientNotify(const SwModify& rMod, const SfxHint& rHint)
 {
-    if (rHint.GetId() != SfxHintId::SwLegacyModify)
+    if(SfxHintId::SwRemoveUnoObject == rHint.GetId())
+    {
+        SetXObject(nullptr);
+        SwFormat::SwClientNotify(rMod, rHint);
+        return;
+    }
+    else if (rHint.GetId() != SfxHintId::SwLegacyModify)
         return;
     auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
     const sal_uInt16 nNewWhich = pLegacy->m_pNew ? pLegacy->m_pNew->Which() : 
0;
@@ -2824,9 +2830,6 @@ void SwFrameFormat::SwClientNotify(const SwModify& rMod, 
const SfxHint& rHint)
         case RES_ANCHOR:
             pOldAnchorNode = static_cast<const 
SwFormatAnchor*>(pLegacy->m_pOld)->GetAnchorNode();
             break;
-        case RES_REMOVE_UNO_OBJECT:
-            SetXObject(nullptr);
-            break;
     }
 
     assert(nOldWhich == nNewWhich || !nOldWhich || !nNewWhich);
diff --git a/sw/source/core/tox/tox.cxx b/sw/source/core/tox/tox.cxx
index 9f1d5c90312e..d97de0af7c49 100644
--- a/sw/source/core/tox/tox.cxx
+++ b/sw/source/core/tox/tox.cxx
@@ -167,12 +167,14 @@ SwTOXMark* SwTOXMark::Clone( SfxItemPool* ) const
 
 void SwTOXMark::Notify(const SfxHint& rHint)
 {
-    if (rHint.GetId() == SfxHintId::SwLegacyModify)
+    if(SfxHintId::SwRemoveUnoObject == rHint.GetId())
+    {
+        CallSwClientNotify(rHint);
+        SetXTOXMark(nullptr);
+    }
+    else if (rHint.GetId() == SfxHintId::SwLegacyModify)
     {
-        auto pLegacyHint = static_cast<const sw::LegacyModifyHint*>(&rHint);
         CallSwClientNotify(rHint);
-        if (pLegacyHint->m_pOld && (RES_REMOVE_UNO_OBJECT == 
pLegacyHint->m_pOld->Which()))
-            SetXTOXMark(nullptr);
     }
     else if (rHint.GetId() == SfxHintId::SwCollectTextMarks)
     {
@@ -206,8 +208,7 @@ void SwTOXMark::Notify(const SfxHint& rHint)
 
 void SwTOXMark::InvalidateTOXMark()
 {
-    const SwPtrMsgPoolItem aMsgHint(RES_REMOVE_UNO_OBJECT, 
&static_cast<sw::BroadcastingModify&>(*this));
-    CallSwClientNotify(sw::LegacyModifyHint(&aMsgHint, &aMsgHint));
+    CallSwClientNotify(sw::RemoveUnoObjectHint(this));
 }
 
 OUString SwTOXMark::GetText(SwRootFrame const*const pLayout) const
diff --git a/sw/source/core/txtnode/atrfld.cxx 
b/sw/source/core/txtnode/atrfld.cxx
index 9974c4db6ec3..f6e8387c9879 100644
--- a/sw/source/core/txtnode/atrfld.cxx
+++ b/sw/source/core/txtnode/atrfld.cxx
@@ -218,8 +218,7 @@ SwFormatField* SwFormatField::Clone( SfxItemPool* ) const
 
 void SwFormatField::InvalidateField()
 {
-    const SwPtrMsgPoolItem aItem(RES_REMOVE_UNO_OBJECT, 
&static_cast<sw::BroadcastingModify&>(*this));
-    CallSwClientNotify(sw::LegacyModifyHint{ &aItem, &aItem });
+    CallSwClientNotify(sw::RemoveUnoObjectHint(this));
 }
 
 void SwFormatField::SwClientNotify( const SwModify& rModify, const SfxHint& 
rHint )
@@ -404,6 +403,13 @@ void SwFormatField::UpdateDocPos(const SwTwips nDocPos)
 }
 void SwFormatField::UpdateTextNode(const SfxHint& rHint)
 {
+    if(SfxHintId::SwRemoveUnoObject == rHint.GetId())
+    {   // invalidate cached UNO object
+        m_wXTextField.clear();
+        // ??? why does this Modify method not already do this?
+        CallSwClientNotify(rHint);
+        return;
+    }
     if(SfxHintId::SwLegacyModify != rHint.GetId())
         return;
     auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
@@ -414,13 +420,6 @@ void SwFormatField::UpdateTextNode(const SfxHint& rHint)
         ForceUpdateTextNode();
         return;
     }
-    else if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which()))
-    {   // invalidate cached UNO object
-        m_wXTextField.clear();
-        // ??? why does this Modify method not already do this?
-        CallSwClientNotify(sw::LegacyModifyHint(pOld, pNew));
-        return;
-    }
 
     if (!IsFieldInDoc())
         return;
diff --git a/sw/source/core/txtnode/atrftn.cxx 
b/sw/source/core/txtnode/atrftn.cxx
index f7dfbddbe51e..a63bde260b1d 100644
--- a/sw/source/core/txtnode/atrftn.cxx
+++ b/sw/source/core/txtnode/atrftn.cxx
@@ -158,19 +158,20 @@ SwFormatFootnote* SwFormatFootnote::Clone( SfxItemPool* ) 
const
 
 void SwFormatFootnote::SwClientNotify(const SwModify&, const SfxHint& rHint)
 {
+    if(SfxHintId::SwRemoveUnoObject == rHint.GetId())
+    {
+        CallSwClientNotify(rHint);
+        SetXFootnote(nullptr);
+        return;
+    }
     if (rHint.GetId() != SfxHintId::SwLegacyModify)
         return;
-    auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
     CallSwClientNotify(rHint);
-    if(RES_REMOVE_UNO_OBJECT == pLegacy->GetWhich())
-        SetXFootnote(nullptr);
 }
 
 void SwFormatFootnote::InvalidateFootnote()
 {
-    SwPtrMsgPoolItem const item(RES_REMOVE_UNO_OBJECT,
-            &static_cast<sw::BroadcastingModify&>(*this)); // cast to base 
class (void*)
-    CallSwClientNotify(sw::LegacyModifyHint(&item, &item));
+    CallSwClientNotify(sw::RemoveUnoObjectHint(this));
 }
 
 void SwFormatFootnote::SetEndNote( bool b )
diff --git a/sw/source/core/txtnode/atrref.cxx 
b/sw/source/core/txtnode/atrref.cxx
index 5a12e0662b4c..87fdaf818637 100644
--- a/sw/source/core/txtnode/atrref.cxx
+++ b/sw/source/core/txtnode/atrref.cxx
@@ -74,19 +74,20 @@ SwFormatRefMark* SwFormatRefMark::Clone( SfxItemPool* ) 
const
 
 void SwFormatRefMark::SwClientNotify(const SwModify&, const SfxHint& rHint)
 {
+    if(SfxHintId::SwRemoveUnoObject == rHint.GetId())
+    {
+        CallSwClientNotify(rHint);
+        SetXRefMark(nullptr);
+        return;
+    }
     if (rHint.GetId() != SfxHintId::SwLegacyModify)
         return;
-    auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
     CallSwClientNotify(rHint);
-    if(RES_REMOVE_UNO_OBJECT == pLegacy->GetWhich())
-        SetXRefMark(nullptr);
 }
 
 void SwFormatRefMark::InvalidateRefMark()
 {
-    SwPtrMsgPoolItem const item(RES_REMOVE_UNO_OBJECT,
-            &static_cast<sw::BroadcastingModify&>(*this)); // cast to base 
class (void*)
-    CallSwClientNotify(sw::LegacyModifyHint(&item, &item));
+    CallSwClientNotify(sw::RemoveUnoObjectHint(this));
 }
 
 void SwFormatRefMark::dumpAsXml(xmlTextWriterPtr pWriter) const
diff --git a/sw/source/core/txtnode/attrcontentcontrol.cxx 
b/sw/source/core/txtnode/attrcontentcontrol.cxx
index 9c6bd71a7593..065f54aeacc4 100644
--- a/sw/source/core/txtnode/attrcontentcontrol.cxx
+++ b/sw/source/core/txtnode/attrcontentcontrol.cxx
@@ -262,19 +262,20 @@ void SwContentControl::NotifyChangeTextNode(SwTextNode* 
pTextNode)
 
 void SwContentControl::SwClientNotify(const SwModify&, const SfxHint& rHint)
 {
-    if (rHint.GetId() != SfxHintId::SwLegacyModify)
-        return;
-
-    auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
-    CallSwClientNotify(rHint);
-    GetNotifier().Broadcast(SfxHint(SfxHintId::DataChanged));
-
-    if (pLegacy->GetWhich() == RES_REMOVE_UNO_OBJECT)
+    if (SfxHintId::SwRemoveUnoObject == rHint.GetId())
     {
+        CallSwClientNotify(rHint);
+        GetNotifier().Broadcast(SfxHint(SfxHintId::DataChanged));
         // Invalidate cached uno object.
         SetXContentControl(nullptr);
         GetNotifier().Broadcast(SfxHint(SfxHintId::Deinitializing));
+        return;
     }
+    if (rHint.GetId() != SfxHintId::SwLegacyModify)
+        return;
+
+    CallSwClientNotify(rHint);
+    GetNotifier().Broadcast(SfxHint(SfxHintId::DataChanged));
 }
 
 std::optional<size_t> SwContentControl::GetSelectedListItem(bool 
bCheckDocModel) const
diff --git a/sw/source/core/txtnode/attrlinebreak.cxx 
b/sw/source/core/txtnode/attrlinebreak.cxx
index 5e4fb4e69afd..0f5821cf0312 100644
--- a/sw/source/core/txtnode/attrlinebreak.cxx
+++ b/sw/source/core/txtnode/attrlinebreak.cxx
@@ -60,14 +60,15 @@ SwFormatLineBreak* SwFormatLineBreak::Clone(SfxItemPool*) 
const
 
 void SwFormatLineBreak::SwClientNotify(const SwModify&, const SfxHint& rHint)
 {
-    if (rHint.GetId() != SfxHintId::SwLegacyModify)
-        return;
-    auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
-    CallSwClientNotify(rHint);
-    if (RES_REMOVE_UNO_OBJECT == pLegacy->GetWhich())
+    if (SfxHintId::SwRemoveUnoObject == rHint.GetId())
     {
+        CallSwClientNotify(rHint);
         SetXLineBreak(nullptr);
+        return;
     }
+    if (rHint.GetId() != SfxHintId::SwLegacyModify)
+        return;
+    CallSwClientNotify(rHint);
 }
 
 sal_uInt16 SwFormatLineBreak::GetValueCount() const
diff --git a/sw/source/core/txtnode/fmtatr2.cxx 
b/sw/source/core/txtnode/fmtatr2.cxx
index d7611a187e4f..3f9b1489ea5b 100644
--- a/sw/source/core/txtnode/fmtatr2.cxx
+++ b/sw/source/core/txtnode/fmtatr2.cxx
@@ -718,16 +718,19 @@ void Meta::NotifyChangeTextNode(SwTextNode *const 
pTextNode)
 
 void Meta::SwClientNotify(const SwModify&, const SfxHint& rHint)
 {
+    if(SfxHintId::SwRemoveUnoObject == rHint.GetId())
+    {
+        CallSwClientNotify(rHint);
+        GetNotifier().Broadcast(SfxHint(SfxHintId::DataChanged));
+        // invalidate cached uno object
+        SetXMeta(nullptr);
+        GetNotifier().Broadcast(SfxHint(SfxHintId::Deinitializing));
+        return;
+    }
     if (rHint.GetId() != SfxHintId::SwLegacyModify)
         return;
-    auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
     CallSwClientNotify(rHint);
     GetNotifier().Broadcast(SfxHint(SfxHintId::DataChanged));
-    if(RES_REMOVE_UNO_OBJECT == pLegacy->GetWhich())
-    {   // invalidate cached uno object
-        SetXMeta(nullptr);
-        GetNotifier().Broadcast(SfxHint(SfxHintId::Deinitializing));
-    }
 }
 
 // sfx2::Metadatable
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 81dcab11db24..8e15ce77e8fe 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -5587,10 +5587,19 @@ void SwTextNode::TriggerNodeUpdate(const 
sw::LegacyModifyHint& rHint)
             rDoc.GetNodes().UpdateOutlineNode(*this);
         }
     }
+}
+
+void SwTextNode::TriggerNodeUpdate(const sw::RemoveUnoObjectHint& rHint)
+{
+    sw::TextNodeNotificationSuppressor(*this);
+
+    SwContentNode::SwClientNotify(*this, rHint);
 
-    if (pOldValue && (RES_REMOVE_UNO_OBJECT == pOldValue->Which()))
-    {   // invalidate cached uno object
-        SetXParagraph(nullptr);
+    SwDoc& rDoc = GetDoc();
+    // #125329# - assure that text node is in document nodes array
+    if ( !rDoc.IsInDtor() && &rDoc.GetNodes() == &GetNodes() )
+    {
+        rDoc.GetNodes().UpdateOutlineNode(*this);
     }
 }
 
@@ -5600,6 +5609,10 @@ void SwTextNode::SwClientNotify( const SwModify& 
rModify, const SfxHint& rHint )
     {
         static_cast<const sw::AutoFormatUsedHint&>(rHint).CheckNode(this);
     }
+    else if(SfxHintId::SwRemoveUnoObject == rHint.GetId())
+    {
+        TriggerNodeUpdate(static_cast<const sw::RemoveUnoObjectHint&>(rHint));
+    }
     else if (rHint.GetId() == SfxHintId::SwLegacyModify)
     {
         auto pLegacyHint = static_cast<const sw::LegacyModifyHint*>(&rHint);
diff --git a/sw/source/core/unocore/unofield.cxx 
b/sw/source/core/unocore/unofield.cxx
index 81f2b436d081..ed08b1d52525 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -2649,12 +2649,13 @@ void SwXTextField::Impl::Notify(const SfxHint& rHint)
 
     if(rHint.GetId() == SfxHintId::Dying)
         Invalidate();
+    else if(SfxHintId::SwRemoveUnoObject == rHint.GetId())
+        Invalidate();
     else if (rHint.GetId() == SfxHintId::SwLegacyModify)
     {
         auto pLegacyHint = static_cast<const sw::LegacyModifyHint*>(&rHint);
         switch(pLegacyHint->m_pOld ? pLegacyHint->m_pOld->Which() : 0)
         {
-            case RES_REMOVE_UNO_OBJECT:
             case RES_OBJECTDYING:
                 Invalidate();
                 break;
diff --git a/sw/source/core/unocore/unoidx.cxx 
b/sw/source/core/unocore/unoidx.cxx
index 5237380ccfab..9e47678d7a1e 100644
--- a/sw/source/core/unocore/unoidx.cxx
+++ b/sw/source/core/unocore/unoidx.cxx
@@ -359,12 +359,8 @@ public:
 
 void SwXDocumentIndex::Impl::Notify(const SfxHint& rHint)
 {
-    if (rHint.GetId() == SfxHintId::SwLegacyModify)
-    {
-        auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
-        if(pLegacy->m_pOld && pLegacy->m_pOld->Which() == 
RES_REMOVE_UNO_OBJECT)
-            m_pFormat = nullptr;
-    }
+    if(SfxHintId::SwRemoveUnoObject == rHint.GetId())
+        m_pFormat = nullptr;
     else if(rHint.GetId() == SfxHintId::Dying)
         m_pFormat = nullptr;
     if(!m_pFormat)

Reply via email to