include/svl/hint.hxx                                  |    1 
 include/svl/poolitem.hxx                              |    1 
 sw/IwyuFilter_sw.yaml                                 |    1 
 sw/inc/calbck.hxx                                     |    3 
 sw/inc/deletelistener.hxx                             |    5 -
 sw/inc/fmtcol.hxx                                     |    8 --
 sw/inc/hintids.hxx                                    |    6 -
 sw/inc/hints.hxx                                      |   19 +---
 sw/inc/ndtxt.hxx                                      |    1 
 sw/inc/swevent.hxx                                    |    4 -
 sw/inc/txtatr.hxx                                     |    1 
 sw/source/core/attr/BorderCacheOwner.cxx              |    1 
 sw/source/core/attr/calbck.cxx                        |   39 +++------
 sw/source/core/attr/format.cxx                        |   71 ++++++++----------
 sw/source/core/crsr/crsrsh.cxx                        |   12 +--
 sw/source/core/doc/acmplwrd.cxx                       |   15 ---
 sw/source/core/doc/docftn.cxx                         |    6 -
 sw/source/core/doc/fmtcol.cxx                         |    8 +-
 sw/source/core/doc/lineinfo.cxx                       |    6 -
 sw/source/core/doc/notxtfrm.cxx                       |    9 +-
 sw/source/core/doc/number.cxx                         |   13 +--
 sw/source/core/docnode/node.cxx                       |   31 +++----
 sw/source/core/docnode/section.cxx                    |   40 +++++-----
 sw/source/core/draw/dcontact.cxx                      |    8 +-
 sw/source/core/fields/ddetbl.cxx                      |    3 
 sw/source/core/fields/docufld.cxx                     |    2 
 sw/source/core/fields/reffld.cxx                      |    2 
 sw/source/core/layout/atrfrm.cxx                      |   15 ++-
 sw/source/core/layout/flyincnt.cxx                    |    7 +
 sw/source/core/layout/flylay.cxx                      |    5 +
 sw/source/core/layout/pagedesc.cxx                    |    4 +
 sw/source/core/layout/tabfrm.cxx                      |    2 
 sw/source/core/table/swtable.cxx                      |   33 ++++----
 sw/source/core/text/txtfrm.cxx                        |    4 -
 sw/source/core/txtnode/atrfld.cxx                     |   11 +-
 sw/source/core/txtnode/attrcontentcontrol.cxx         |    3 
 sw/source/core/txtnode/attrlinebreak.cxx              |    3 
 sw/source/core/txtnode/fmtatr2.cxx                    |    9 ++
 sw/source/core/txtnode/ndtxt.cxx                      |   19 ++++
 sw/source/core/txtnode/txtatr2.cxx                    |   34 +++++++-
 sw/source/core/undo/unattr.cxx                        |    5 +
 sw/source/core/unocore/unochart.cxx                   |    6 +
 sw/source/core/unocore/unofield.cxx                   |   12 ---
 sw/source/filter/ww8/ww8par.cxx                       |    6 -
 sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx |    8 --
 45 files changed, 270 insertions(+), 232 deletions(-)

New commits:
commit da758c4d15569667cc3d444ba53826b0ee5d2a90
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Sun Jan 5 13:23:59 2025 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Jan 15 08:04:35 2025 +0100

    convert RES_OBJECTDYING to SfxHint
    
    and remove SwPtrMsgPoolItem, which is now unused
    
    Change-Id: Ie5bedcd9855256d3ad90189db3df1ae978977e8c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180180
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de>
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/include/svl/hint.hxx b/include/svl/hint.hxx
index 0b4c626306b5..53875a19dfa5 100644
--- a/include/svl/hint.hxx
+++ b/include/svl/hint.hxx
@@ -233,6 +233,7 @@ enum class SfxHintId {
     SwHiddenParaPrint,
     SwFormatChange,
     SwAttrSetChange,
+    SwObjectDying,
 
     ThisIsAnSdrHint,
     ThisIsAnSfxEventHint
diff --git a/include/svl/poolitem.hxx b/include/svl/poolitem.hxx
index 13afd15dd190..979a4ceccc8d 100644
--- a/include/svl/poolitem.hxx
+++ b/include/svl/poolitem.hxx
@@ -486,7 +486,6 @@ enum class SfxItemType : sal_uInt16
     SwPaMItemType,
     SwParaConnectBorderItemType,
     SwPtrItemType,
-    SwPtrMsgPoolItemType,
     SwRegisterItemType,
     SwRotationGrfType,
     SwShadowCursorItemType,
diff --git a/sw/IwyuFilter_sw.yaml b/sw/IwyuFilter_sw.yaml
index b3d5665826e8..6e67a98cd3cf 100644
--- a/sw/IwyuFilter_sw.yaml
+++ b/sw/IwyuFilter_sw.yaml
@@ -222,7 +222,6 @@ excludelist:
     - class SwFormatChg
     - class SwFormatMeta
     - class SwMsgPoolItem
-    - class SwPtrMsgPoolItem
     - class SwUpdateAttr
     - class SfxBoolItem
     - class SvxCharSetColorItem
diff --git a/sw/inc/calbck.hxx b/sw/inc/calbck.hxx
index 8979661456e2..36d1f46e3914 100644
--- a/sw/inc/calbck.hxx
+++ b/sw/inc/calbck.hxx
@@ -71,6 +71,7 @@ namespace sw
 {
     class ClientIteratorBase;
     class ListenerEntry;
+    class ObjectDyingHint;
     enum class IteratorMode { Exact, UnwrapMulti };
 }
 
@@ -175,7 +176,7 @@ namespace sw
 
         // in case an SwModify object is destroyed that itself is registered 
in another SwModify,
         // its SwClient objects can decide to get registered to the latter 
instead by calling this method
-        std::optional<sw::ModifyChangedHint> CheckRegistration( const 
SfxPoolItem* pOldValue );
+        std::optional<sw::ModifyChangedHint> CheckRegistration( const 
sw::ObjectDyingHint& rHint );
 
         const T* GetRegisteredIn() const { return m_pRegisteredIn; }
         T* GetRegisteredIn() { return m_pRegisteredIn; }
diff --git a/sw/inc/deletelistener.hxx b/sw/inc/deletelistener.hxx
index 023e5e638720..261c85763b54 100644
--- a/sw/inc/deletelistener.hxx
+++ b/sw/inc/deletelistener.hxx
@@ -20,10 +20,7 @@ private:
 
     virtual void SwClientNotify(const SwModify&, const SfxHint& rHint) override
     {
-        if (rHint.GetId() != SfxHintId::SwLegacyModify)
-            return;
-        auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
-        if (pLegacy->GetWhich() == RES_OBJECTDYING)
+        if (rHint.GetId() == SfxHintId::SwObjectDying)
         {
             m_pModify->Remove(*this);
             m_pModify = nullptr;
diff --git a/sw/inc/fmtcol.hxx b/sw/inc/fmtcol.hxx
index a966e84049ea..db39befc3d68 100644
--- a/sw/inc/fmtcol.hxx
+++ b/sw/inc/fmtcol.hxx
@@ -143,14 +143,6 @@ public:
         {
             m_bInSwFntCache = false;
         }
-        else
-        {
-            switch(nWhich)
-            {
-                case RES_OBJECTDYING:
-                    m_bInSwFntCache = false;
-            }
-        }
     };
     virtual void InvalidateInSwFntCache() override
     {
diff --git a/sw/inc/hintids.hxx b/sw/inc/hintids.hxx
index fab0a027a0aa..be104eedbeb8 100644
--- a/sw/inc/hintids.hxx
+++ b/sw/inc/hintids.hxx
@@ -34,7 +34,6 @@ class SwFormatMeta;
 class SwFormatContentControl;
 class SvXMLAttrContainerItem;
 class SwMsgPoolItem;
-class SwPtrMsgPoolItem;
 class SfxBoolItem;
 class SvxColorItem;
 class SvxLeftMarginItem;
@@ -426,10 +425,11 @@ inline constexpr sal_uInt16 RES_FMT_END(167);
 
 // ID's for Messages in the Formats
 inline constexpr sal_uInt16 RES_FORMAT_MSG_BEGIN(RES_FMT_END);
-inline constexpr TypedWhichId<SwPtrMsgPoolItem> 
RES_OBJECTDYING(RES_FORMAT_MSG_BEGIN); // 167
 inline constexpr sal_uInt16 RES_UPDATEATTR_FMT_CHG(
-    168); // used by SwUpdateAttr just as an ID to communicate what has changed
+    167); // used by SwUpdateAttr just as an ID to communicate what has changed
 inline constexpr sal_uInt16 RES_UPDATEATTR_ATTRSET_CHG(
+    168); // used by SwUpdateAttr just as an ID to communicate what has changed
+inline constexpr sal_uInt16 RES_UPDATEATTR_OBJECTDYING(
     169); // used by SwUpdateAttr just as an ID to communicate what has changed
 inline constexpr TypedWhichId<SwUpdateAttr> RES_UPDATE_ATTR(170);
 // empty
diff --git a/sw/inc/hints.hxx b/sw/inc/hints.hxx
index f2cfc1ca4166..d7a1049b12d1 100644
--- a/sw/inc/hints.hxx
+++ b/sw/inc/hints.hxx
@@ -55,19 +55,6 @@ public:
     virtual SwMsgPoolItem*  Clone( SfxItemPool* pPool = nullptr ) const 
override;
 };
 
-// SwPtrMsgPoolItem (old SwObjectDying!)
-
-class SwPtrMsgPoolItem final : public SwMsgPoolItem
-{
-public:
-    void * pObject;
-
-    DECLARE_ITEM_TYPE_FUNCTION(SwPtrMsgPoolItem)
-    SwPtrMsgPoolItem( sal_uInt16 nId, void * pObj )
-        : SwMsgPoolItem( nId ), pObject( pObj )
-    {}
-};
-
 /**
  * SwFormatChg is sent when a format has changed to another format.
  */
@@ -329,6 +316,12 @@ public:
     const SwAttrSetChg* m_pNew;
     AttrSetChangeHint(const SwAttrSetChg* pOld, const SwAttrSetChg* pNew) : 
SfxHint(SfxHintId::SwAttrSetChange), m_pOld(pOld), m_pNew(pNew) {}
 };
+class ObjectDyingHint final : public SfxHint
+{
+public:
+    SwModify* m_pDying;
+    ObjectDyingHint(SwModify* pDead) : SfxHint(SfxHintId::SwObjectDying), 
m_pDying(pDead) {}
+};
 } // namespace sw
 
 class SwUpdateAttr final : public SwMsgPoolItem
diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx
index 6e667e30be2c..95ef737cb486 100644
--- a/sw/inc/ndtxt.hxx
+++ b/sw/inc/ndtxt.hxx
@@ -246,6 +246,7 @@ public:
     void TriggerNodeUpdate(const sw::LegacyModifyHint&);
     void TriggerNodeUpdate(const sw::AttrSetChangeHint&);
     void TriggerNodeUpdate(const sw::RemoveUnoObjectHint&);
+    void TriggerNodeUpdate(const sw::ObjectDyingHint&);
     void TriggerNodeUpdate(const SwFormatChangeHint&);
 
     const OUString& GetText() const { return m_Text; }
diff --git a/sw/inc/swevent.hxx b/sw/inc/swevent.hxx
index 10d110bca664..90378efa5063 100644
--- a/sw/inc/swevent.hxx
+++ b/sw/inc/swevent.hxx
@@ -131,7 +131,9 @@ struct SwCallMouseEvent final
             if (!GetRegisteredIn() || pChgHint->m_pOldFormat == PTR.pFormat)
                 Clear();
         }
-        else if (rHint.GetId() == SfxHintId::SwLegacyModify || 
SfxHintId::SwAttrSetChange == rHint.GetId())
+        else if (rHint.GetId() == SfxHintId::SwLegacyModify
+                || SfxHintId::SwAttrSetChange == rHint.GetId()
+                || SfxHintId::SwObjectDying == rHint.GetId())
         {
             assert(EVENT_OBJECT_IMAGE == eType || EVENT_OBJECT_URLITEM == 
eType || EVENT_OBJECT_IMAGEMAP == eType);
             SwClient::SwClientNotify(rMod, rHint);
diff --git a/sw/inc/txtatr.hxx b/sw/inc/txtatr.hxx
index 15ed54683e14..cf425589387a 100644
--- a/sw/inc/txtatr.hxx
+++ b/sw/inc/txtatr.hxx
@@ -46,6 +46,7 @@ public:
     void TriggerNodeUpdate(const sw::LegacyModifyHint&);
     void TriggerNodeUpdate(const SwFormatChangeHint&);
     void TriggerNodeUpdate(const sw::AttrSetChangeHint&);
+    void TriggerNodeUpdate(const sw::ObjectDyingHint&);
 
     // get and set TextNode pointer
     void ChgTextNode( SwTextNode* pNew ) { m_pTextNode = pNew; }
diff --git a/sw/source/core/attr/BorderCacheOwner.cxx 
b/sw/source/core/attr/BorderCacheOwner.cxx
index 8673e57389b4..f1b99f5888d3 100644
--- a/sw/source/core/attr/BorderCacheOwner.cxx
+++ b/sw/source/core/attr/BorderCacheOwner.cxx
@@ -25,7 +25,6 @@ void BorderCacheOwner::InvalidateInSwCache(const sal_uInt16 
nWhich)
 {
     switch (nWhich)
     {
-        case RES_OBJECTDYING:
         case RES_UL_SPACE:
         case RES_MARGIN_FIRSTLINE:
         case RES_MARGIN_TEXTLEFT:
diff --git a/sw/source/core/attr/calbck.cxx b/sw/source/core/attr/calbck.cxx
index 440b7ccfbc89..9b03cac2192e 100644
--- a/sw/source/core/attr/calbck.cxx
+++ b/sw/source/core/attr/calbck.cxx
@@ -38,17 +38,12 @@ namespace sw
         { return m_pToTell == nullptr || m_pToTell->GetInfo( rInfo ); }
     void ListenerEntry::SwClientNotify(const SwModify& rModify, const SfxHint& 
rHint)
     {
-        if (rHint.GetId() == SfxHintId::SwLegacyModify)
+        if (rHint.GetId() == SfxHintId::SwObjectDying)
         {
-            auto pLegacyHint = static_cast<const 
sw::LegacyModifyHint*>(&rHint);
-            if (pLegacyHint->m_pNew && pLegacyHint->m_pNew->Which() == 
RES_OBJECTDYING)
-            {
-                auto pModifyChanged = CheckRegistration(pLegacyHint->m_pOld);
-                if (pModifyChanged)
-                    m_pToTell->SwClientNotify(rModify, *pModifyChanged);
-            }
-            else if (m_pToTell)
-                m_pToTell->SwClientNotify(rModify, rHint);
+            auto pDyingHint = static_cast<const sw::ObjectDyingHint*>(&rHint);
+            auto pModifyChanged = CheckRegistration(*pDyingHint);
+            if (pModifyChanged)
+                m_pToTell->SwClientNotify(rModify, *pModifyChanged);
         }
         else if (m_pToTell)
             m_pToTell->SwClientNotify(rModify, rHint);
@@ -79,16 +74,11 @@ sw::ClientBase<T>::~ClientBase()
 }
 
 template<typename T>
-std::optional<sw::ModifyChangedHint> sw::ClientBase<T>::CheckRegistration( 
const SfxPoolItem* pOld )
+std::optional<sw::ModifyChangedHint> sw::ClientBase<T>::CheckRegistration( 
const sw::ObjectDyingHint& rHint )
 {
     DBG_TESTSOLARMUTEX();
-    // this method only handles notification about dying SwModify objects
-    if( !pOld || pOld->Which() != RES_OBJECTDYING )
-        return {};
 
-    assert(dynamic_cast<const SwPtrMsgPoolItem*>(pOld));
-    const SwPtrMsgPoolItem* pDead = static_cast<const SwPtrMsgPoolItem*>(pOld);
-    if(pDead->pObject != m_pRegisteredIn)
+    if(rHint.m_pDying != m_pRegisteredIn)
     {
         // we should only care received death notes from objects we are 
following
         return {};
@@ -112,10 +102,10 @@ std::optional<sw::ModifyChangedHint> 
sw::ClientBase<T>::CheckRegistration( const
 template<typename T>
 void sw::ClientBase<T>::SwClientNotify(const SwModify&, const SfxHint& rHint)
 {
-    if (rHint.GetId() != SfxHintId::SwLegacyModify)
+    if (rHint.GetId() != SfxHintId::SwObjectDying)
         return;
-    auto pLegacyHint = static_cast<const sw::LegacyModifyHint*>(&rHint);
-    CheckRegistration(pLegacyHint->m_pOld);
+    auto pDyingHint = static_cast<const sw::ObjectDyingHint*>(&rHint);
+    CheckRegistration(*pDyingHint);
 };
 
 template<typename T>
@@ -149,15 +139,15 @@ SwModify::~SwModify()
     OSL_ENSURE( !IsModifyLocked(), "Modify destroyed but locked." );
 
     // notify all clients that they shall remove themselves
-    SwPtrMsgPoolItem aDyObject( RES_OBJECTDYING, this );
-    SwModify::SwClientNotify(*this, sw::LegacyModifyHint(&aDyObject, 
&aDyObject));
+    sw::ObjectDyingHint aDyObject( this );
+    SwModify::SwClientNotify(*this, aDyObject);
 
     const bool hasListenersOnDeath = m_pWriterListeners;
     (void)hasListenersOnDeath;
     while(m_pWriterListeners)
     {
         SAL_WARN("sw.core", "lost a client of type: " << 
typeid(*m_pWriterListeners).name() << " at " << m_pWriterListeners << " still 
registered on type: " << typeid(*this).name() << " at " << this << ".");
-        
static_cast<SwClient*>(m_pWriterListeners)->CheckRegistration(&aDyObject);
+        
static_cast<SwClient*>(m_pWriterListeners)->CheckRegistration(aDyObject);
     }
     assert(!hasListenersOnDeath);
 }
@@ -263,7 +253,8 @@ void SwModify::SwClientNotify(const SwModify&, const 
SfxHint& rHint)
 {
     if (rHint.GetId() != SfxHintId::SwLegacyModify
         && rHint.GetId() != SfxHintId::SwRemoveUnoObject
-        && rHint.GetId() != SfxHintId::SwAttrSetChange)
+        && rHint.GetId() != SfxHintId::SwAttrSetChange
+        && rHint.GetId() != SfxHintId::SwObjectDying)
         return;
 
     DBG_TESTSOLARMUTEX();
diff --git a/sw/source/core/attr/format.cxx b/sw/source/core/attr/format.cxx
index 03badef41cd2..a87a59529d4a 100644
--- a/sw/source/core/attr/format.cxx
+++ b/sw/source/core/attr/format.cxx
@@ -262,53 +262,50 @@ void SwFormat::SwClientNotify(const SwModify&, const 
SfxHint& rHint)
         }
         return;
     }
+    if (rHint.GetId() == SfxHintId::SwObjectDying)
+    {
+        auto pDyingHint = static_cast<const sw::ObjectDyingHint*>(&rHint);
+        InvalidateInSwCache();
+        // If the dying object is the parent format of this format so
+        // attach this to the parent of the parent
+
+        // do not move if this is the topmost format
+        if(GetRegisteredIn() && GetRegisteredIn() == pDyingHint->m_pDying)
+        {
+            if(pDyingHint->m_pDying->GetRegisteredIn())
+            {
+                SwFormat* pFormat = 
static_cast<SwFormat*>(pDyingHint->m_pDying);
+                // if parent so register in new parent
+                pFormat->DerivedFrom()->Add(*this);
+                m_aSet.SetParent(&DerivedFrom()->m_aSet);
+            }
+            else
+            {
+                // otherwise de-register at least from dying one
+                EndListeningAll();
+                m_aSet.SetParent(nullptr);
+            }
+        }
+        InvalidateInSwFntCache();
+        SwModify::SwClientNotify(*this, rHint);
+        return;
+    }
     if (rHint.GetId() != SfxHintId::SwLegacyModify)
         return;
     auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
 
-    std::optional<SwAttrSetChg> oOldClientChg, oNewClientChg;
     std::optional<sw::LegacyModifyHint> oDependsHint(std::in_place, 
pLegacy->m_pOld, pLegacy->m_pNew);
     const sal_uInt16 nWhich = pLegacy->GetWhich();
     InvalidateInSwCache(nWhich);
-    switch(nWhich)
+    if(nWhich != 0)
     {
-        case 0:
-            break;
-        case RES_OBJECTDYING:
+        // attribute is defined in this format
+        if(SfxItemState::SET == m_aSet.GetItemState(nWhich, false))
         {
-            // NB: this still notifies depends even if pLegacy->m_pNew is 
nullptr, which seems non-obvious
-            if(!pLegacy->m_pNew)
-                break;
-            // If the dying object is the parent format of this format so
-            // attach this to the parent of the parent
-            SwFormat* pFormat = 
static_cast<SwFormat*>(pLegacy->m_pNew->StaticWhichCast(RES_OBJECTDYING).pObject);
-
-            // do not move if this is the topmost format
-            if(GetRegisteredIn() && GetRegisteredIn() == pFormat)
-            {
-                if(pFormat->GetRegisteredIn())
-                {
-                    // if parent so register in new parent
-                    pFormat->DerivedFrom()->Add(*this);
-                    m_aSet.SetParent(&DerivedFrom()->m_aSet);
-                }
-                else
-                {
-                    // otherwise de-register at least from dying one
-                    EndListeningAll();
-                    m_aSet.SetParent(nullptr);
-                }
-            }
-            break;
+            // DropCaps might come into this block
+            SAL_WARN_IF(RES_PARATR_DROP != nWhich, "sw.core", "Hint was sent 
without sender");
+            oDependsHint.reset();
         }
-        default:
-            // attribute is defined in this format
-            if(SfxItemState::SET == m_aSet.GetItemState(nWhich, false))
-            {
-                // DropCaps might come into this block
-                SAL_WARN_IF(RES_PARATR_DROP != nWhich, "sw.core", "Hint was 
sent without sender");
-                oDependsHint.reset();
-            }
     }
     if(oDependsHint)
     {
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 162185339c47..21419732e594 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -2917,21 +2917,23 @@ void SwCursorShell::SwClientNotify(const SwModify&, 
const SfxHint& rHint)
             CallChgLnk();
         return;
     }
+    if (rHint.GetId() == SfxHintId::SwObjectDying)
+    {
+        EndListeningAll();
+        return;
+    }
     if (rHint.GetId() != SfxHintId::SwLegacyModify)
         return;
     auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
     auto nWhich = pLegacy->GetWhich();
-    if(!nWhich)
-        nWhich = RES_OBJECTDYING;
     if( m_bCallChgLnk &&
-        ( !isFormatMessage(nWhich)
-                || nWhich == RES_UPDATE_ATTR ))
+        ( nWhich == 0 || !isFormatMessage(nWhich) || nWhich == RES_UPDATE_ATTR 
))
         // messages are not forwarded
         // #i6681#: RES_UPDATE_ATTR is implicitly unset in
         // SwTextNode::Insert(SwTextHint*, sal_uInt16); we react here and thus 
do
         // not need to send the expensive RES_FMT_CHG in Insert.
         CallChgLnk();
-    if( nWhich == RES_OBJECTDYING )
+    if( nWhich == 0 )
     {
         EndListeningAll();
     }
diff --git a/sw/source/core/doc/acmplwrd.cxx b/sw/source/core/doc/acmplwrd.cxx
index ef4b0b2595da..a9fffae60772 100644
--- a/sw/source/core/doc/acmplwrd.cxx
+++ b/sw/source/core/doc/acmplwrd.cxx
@@ -148,18 +148,9 @@ void SwAutoCompleteClient::Notify(const SfxHint& rHint)
         case SfxHintId::SwRemoveUnoObject:
             DocumentDying();
             return;
-        case SfxHintId::SwLegacyModify:
-        {
-            auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
-            switch(pLegacy->GetWhich())
-            {
-                case RES_OBJECTDYING:
-                    DocumentDying();
-                    return;
-                default:
-                    return;
-            }
-        }
+        case SfxHintId::SwObjectDying:
+            DocumentDying();
+            return;
         default:
             return;
     }
diff --git a/sw/source/core/doc/docftn.cxx b/sw/source/core/doc/docftn.cxx
index b829b051248d..9e0dcbb93131 100644
--- a/sw/source/core/doc/docftn.cxx
+++ b/sw/source/core/doc/docftn.cxx
@@ -246,10 +246,10 @@ void SwEndNoteInfo::UpdateFormatOrAttr()
 
 void SwEndNoteInfo::SwClientNotify( const SwModify& rModify, const SfxHint& 
rHint)
 {
-    if (rHint.GetId() == SfxHintId::SwLegacyModify)
+    if (rHint.GetId() == SfxHintId::SwObjectDying)
     {
-        auto pLegacyHint = static_cast<const sw::LegacyModifyHint*>(&rHint);
-        CheckRegistration( pLegacyHint->m_pOld );
+        auto pDyingHint = static_cast<const sw::ObjectDyingHint*>(&rHint);
+        CheckRegistration( *pDyingHint );
     }
     else if (rHint.GetId() == SfxHintId::SwFormatChange || rHint.GetId() == 
SfxHintId::SwAttrSetChange)
     {
diff --git a/sw/source/core/doc/fmtcol.cxx b/sw/source/core/doc/fmtcol.cxx
index cb3ad58e1277..65c00b9b61ee 100644
--- a/sw/source/core/doc/fmtcol.cxx
+++ b/sw/source/core/doc/fmtcol.cxx
@@ -140,7 +140,7 @@ void SwTextFormatColl::SwClientNotify(const SwModify& 
rModify, const SfxHint& rH
         return;
     }
     else if (rHint.GetId() != SfxHintId::SwLegacyModify && rHint.GetId() != 
SfxHintId::SwFormatChange
-             && rHint.GetId() != SfxHintId::SwAttrSetChange)
+             && rHint.GetId() != SfxHintId::SwAttrSetChange && rHint.GetId() 
!= SfxHintId::SwObjectDying)
         return;
     if(GetDoc()->IsInDtor())
     {
@@ -217,7 +217,7 @@ void SwTextFormatColl::SwClientNotify(const SwModify& 
rModify, const SfxHint& rH
             pNewNumRuleItem = pNewChgSet->GetChgSet()->GetItemIfSet( 
RES_PARATR_NUMRULE, false );
         }
     }
-    else // rHint.GetId() == SfxHintId::SwFormatChange
+    else if (rHint.GetId() == SfxHintId::SwFormatChange)
     {
         if( GetAttrSet().GetParent() )
         {
@@ -362,7 +362,7 @@ void SwTextFormatColl::SwClientNotify(const SwModify& 
rModify, const SfxHint& rH
     }
 
     // if the parent changed, we can't know how many properties are involved: 
always notify a change
-    if (rHint.GetId() == SfxHintId::SwLegacyModify)
+    if (rHint.GetId() == SfxHintId::SwLegacyModify || rHint.GetId() == 
SfxHintId::SwObjectDying)
     {
         if (bNewParent || !nNoNotify)
             SwFormatColl::SwClientNotify(rModify, rHint);
@@ -375,7 +375,7 @@ void SwTextFormatColl::SwClientNotify(const SwModify& 
rModify, const SfxHint& rH
         if (bNewParent || !nNoNotify || (pOldChgSet && 
pOldChgSet->GetChgSet()->Count() > nNoNotify))
             SwFormatColl::SwClientNotify(rModify, rHint);
     }
-    else // rHint.GetId() == SfxHintId::SwFormatChange
+    else if (rHint.GetId() == SfxHintId::SwFormatChange)
     {
         if (bNewParent || !nNoNotify)
             SwFormatColl::SwClientNotify(rModify, rHint);
diff --git a/sw/source/core/doc/lineinfo.cxx b/sw/source/core/doc/lineinfo.cxx
index 8cc455b0aa82..70c2699ffd45 100644
--- a/sw/source/core/doc/lineinfo.cxx
+++ b/sw/source/core/doc/lineinfo.cxx
@@ -118,10 +118,10 @@ void SwLineNumberInfo::SwClientNotify(const SwModify&, 
const SfxHint& rHint)
         && rHint.GetId() != SfxHintId::SwFormatChange
         && rHint.GetId() != SfxHintId::SwAttrSetChange)
         return;
-    if (rHint.GetId() == SfxHintId::SwLegacyModify)
+    if (rHint.GetId() == SfxHintId::SwObjectDying)
     {
-        auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
-        CheckRegistration( pLegacy->m_pOld );
+        auto pDyingHint = static_cast<const sw::ObjectDyingHint*>(&rHint);
+        CheckRegistration( *pDyingHint );
     }
     SwDoc *pDoc = static_cast<SwCharFormat*>(GetRegisteredIn())->GetDoc();
     SwRootFrame* pRoot = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx
index affd0d7388ff..39b006670c7f 100644
--- a/sw/source/core/doc/notxtfrm.cxx
+++ b/sw/source/core/doc/notxtfrm.cxx
@@ -820,6 +820,12 @@ void SwNoTextFrame::SwClientNotify(const SwModify& 
rModify, const SfxHint& rHint
         InvalidatePrt();
         SetCompletePaint();
     }
+    else if (rHint.GetId() == SfxHintId::SwObjectDying)
+    {
+        SwContentFrame::SwClientNotify(rModify, rHint);
+        InvalidatePrt();
+        SetCompletePaint();
+    }
     else if (rHint.GetId() == SfxHintId::SwLegacyModify)
     {
         auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
@@ -829,9 +835,6 @@ void SwNoTextFrame::SwClientNotify(const SwModify& rModify, 
const SfxHint& rHint
 
         switch( nWhich )
         {
-        case RES_OBJECTDYING:
-            break;
-
         case RES_UPDATE_ATTR:
             if (GetNode()->GetNodeType() != SwNodeType::Grf) {
                 break;
diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx
index 5708fdbf1cb2..58b2bea4f8d2 100644
--- a/sw/source/core/doc/number.cxx
+++ b/sw/source/core/doc/number.cxx
@@ -306,9 +306,8 @@ void SwNumFormat::SwClientNotify(const SwModify&, const 
SfxHint& rHint)
         const SwCharFormat* pFormat = GetCharFormat();
         if(pFormat && !pFormat->GetDoc()->IsInDtor())
             UpdateNumNodes(*const_cast<SwDoc*>(pFormat->GetDoc()));
-        return;
     }
-    if (rHint.GetId() == SfxHintId::SwAttrSetChange)
+    else if (rHint.GetId() == SfxHintId::SwAttrSetChange)
     {
         // Look for the NumRules object in the Doc where this NumFormat is set.
         // The format does not need to exist!
@@ -316,12 +315,12 @@ void SwNumFormat::SwClientNotify(const SwModify&, const 
SfxHint& rHint)
 
         if(pFormat && !pFormat->GetDoc()->IsInDtor())
             UpdateNumNodes(*const_cast<SwDoc*>(pFormat->GetDoc()));
-        return;
     }
-    if (rHint.GetId() != SfxHintId::SwLegacyModify)
-        return;
-    auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
-    CheckRegistration(pLegacy->m_pOld);
+    else if (rHint.GetId() == SfxHintId::SwObjectDying)
+    {
+        auto pDyingHint = static_cast<const sw::ObjectDyingHint*>(&rHint);
+        CheckRegistration( *pDyingHint );
+    }
 }
 
 OUString SwNumFormat::GetCharFormatName() const
diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx
index a78d72477b45..fc2cc4fc18a7 100644
--- a/sw/source/core/docnode/node.cxx
+++ b/sw/source/core/docnode/node.cxx
@@ -1141,6 +1141,21 @@ void SwContentNode::SwClientNotify( const SwModify&, 
const SfxHint& rHint)
             static_cast<SwTextNode*>(this)->SetCalcHiddenCharFlags();
         CallSwClientNotify(rHint);
     }
+    else if (rHint.GetId() == SfxHintId::SwObjectDying)
+    {
+        auto pDyingHint = static_cast<const sw::ObjectDyingHint*>(&rHint);
+        InvalidateInSwCache();
+        const SwFormat* pFormat = static_cast<const 
SwFormat*>(pDyingHint->m_pDying);
+        // Do not mangle pointers if it is the upper-most format!
+        if(pFormat && GetRegisteredIn() == pFormat)
+        {
+            // As ~SwFormat calls CheckRegistrationFormat before
+            // ~SwModify, which sends the RES_OBJECTDYING, we should never
+            // reach this point.
+            assert(false);
+        }
+        CallSwClientNotify(rHint);
+    }
     else if (rHint.GetId() == SfxHintId::SwLegacyModify)
     {
         auto pLegacyHint = static_cast<const sw::LegacyModifyHint*>(&rHint);
@@ -1149,22 +1164,6 @@ void SwContentNode::SwClientNotify( const SwModify&, 
const SfxHint& rHint)
 
         switch(nWhich)
         {
-            case RES_OBJECTDYING:
-                {
-                    SwFormat* pFormat = pLegacyHint->m_pNew
-                            ? static_cast<SwFormat*>(static_cast<const 
SwPtrMsgPoolItem*>(pLegacyHint->m_pNew)->pObject)
-                            : nullptr;
-                    // Do not mangle pointers if it is the upper-most format!
-                    if(pFormat && GetRegisteredIn() == pFormat)
-                    {
-                        // As ~SwFormat calls CheckRegistrationFormat before
-                        // ~SwModify, which sends the RES_OBJECTDYING, we 
should never
-                        // reach this point.
-                        assert(false);
-                    }
-                }
-                break;
-
             case RES_UPDATE_ATTR:
                 // RES_UPDATE_ATTR _should_ always contain a SwUpdateAttr hint 
in old and new.
                 // However, faking one with just a basic SfxPoolItem setting a 
WhichId has been observed.
diff --git a/sw/source/core/docnode/section.cxx 
b/sw/source/core/docnode/section.cxx
index c6be724631df..e7ef4e8d4808 100644
--- a/sw/source/core/docnode/section.cxx
+++ b/sw/source/core/docnode/section.cxx
@@ -403,7 +403,14 @@ void SwSection::Notify(SfxHint const& rHint)
         auto rSectionHidden = static_cast<const sw::SectionHidden&>(rHint);
         m_Data.SetHiddenFlag(rSectionHidden.m_isHidden || (m_Data.IsHidden() 
&& m_Data.IsCondHidden()));
         return;
-    } else if (rHint.GetId() != SfxHintId::SwLegacyModify && rHint.GetId() != 
SfxHintId::SwAttrSetChange)
+    }
+    if (rHint.GetId() == SfxHintId::SwObjectDying)
+    {
+        auto pDyingHint = static_cast<const sw::ObjectDyingHint*>(&rHint);
+        CheckRegistration( *pDyingHint );
+        return;
+    }
+    if (rHint.GetId() != SfxHintId::SwLegacyModify && rHint.GetId() != 
SfxHintId::SwAttrSetChange)
         return;
 
     bool bUpdateFootnote = false;
@@ -445,10 +452,6 @@ void SwSection::Notify(SfxHint const& rHint)
                 bUpdateFootnote = true;
             }
             break;
-
-        default:
-            CheckRegistration( pOld );
-            break;
         }
     }
     else // rHint.GetId() == SfxHintId::SwAttrSetChange
@@ -781,6 +784,20 @@ void SwSectionFormat::SwClientNotify(const SwModify& rMod, 
const SfxHint& rHint)
         SwFrameFormat::SwClientNotify(rMod, rHint);
         return;
     }
+    else if (rHint.GetId() == SfxHintId::SwObjectDying)
+    {
+        auto pDyingHint = static_cast<const sw::ObjectDyingHint*>(&rHint);
+        if( !GetDoc()->IsInDtor() &&
+            pDyingHint->m_pDying == GetRegisteredIn() )
+        {
+            // My Parents will be destroyed, so get the Parent's Parent
+            // and update
+            SwFrameFormat::SwClientNotify(rMod, rHint);
+            UpdateParent();
+            return;
+        }
+        SwFrameFormat::SwClientNotify(rMod, rHint);
+    }
     else if (rHint.GetId() != SfxHintId::SwLegacyModify)
         return;
     auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
@@ -796,19 +813,6 @@ void SwSectionFormat::SwClientNotify(const SwModify& rMod, 
const SfxHint& rHint)
         // Pass through these Messages until the End of the tree!
         GetNotifier().Broadcast(sw::LegacyModifyHint(pOld, pNew));
         return; // That's it!
-
-    case RES_OBJECTDYING:
-        if( !GetDoc()->IsInDtor() && pOld &&
-            static_cast<const SwPtrMsgPoolItem *>(pOld)->pObject == 
static_cast<void*>(GetRegisteredIn()) )
-        {
-            // My Parents will be destroyed, so get the Parent's Parent
-            // and update
-            SwFrameFormat::SwClientNotify(rMod, rHint);
-            UpdateParent();
-            return;
-        }
-        break;
-
     }
     SwFrameFormat::SwClientNotify(rMod, rHint);
 }
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index 63dbcae0373c..6594b0ac8ddc 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -1425,7 +1425,9 @@ void SwDrawContact::SwClientNotify(const SwModify& rMod, 
const SfxHint& rHint)
         // #i51474#
         GetAnchoredObj(nullptr)->ResetLayoutProcessBools();
     }
-    else if (rHint.GetId() == SfxHintId::SwLegacyModify || rHint.GetId() == 
SfxHintId::SwAttrSetChange)
+    else if (rHint.GetId() == SfxHintId::SwLegacyModify
+            || rHint.GetId() == SfxHintId::SwAttrSetChange
+            || rHint.GetId() == SfxHintId::SwObjectDying)
     {
         SAL_WARN_IF(mbDisconnectInProgress, "sw.core", 
"<SwDrawContact::Modify(..)> called during disconnection.");
 
@@ -1439,7 +1441,7 @@ void SwDrawContact::SwClientNotify(const SwModify& rMod, 
const SfxHint& rHint)
             if (pLegacyHint->m_pOld)
                 pOldAnchorFormat = lcl_getAnchorFormat(*pLegacyHint->m_pOld);
         }
-        else // rHint.GetId() == SfxHintId::SwAttrSetChange)
+        else if (rHint.GetId() == SfxHintId::SwAttrSetChange)
         {
             auto pChangeHint = static_cast<const 
sw::AttrSetChangeHint*>(&rHint);
             if (pChangeHint->m_pNew)
@@ -1519,7 +1521,7 @@ void SwDrawContact::SwClientNotify(const SwModify& rMod, 
const SfxHint& rHint)
                         assert(!"<SwDraw Contact::Modify(..)> - unhandled 
attribute?");
                 }
             }
-            else // rHint.GetId() == SfxHintId::SwAttrSetChange)
+            else if (rHint.GetId() == SfxHintId::SwAttrSetChange)
             {
                 // #i35443#
                 auto pChangeHint = static_cast<const 
sw::AttrSetChangeHint*>(&rHint);
diff --git a/sw/source/core/fields/ddetbl.cxx b/sw/source/core/fields/ddetbl.cxx
index 5987cb3851cd..ecb1ced273bc 100644
--- a/sw/source/core/fields/ddetbl.cxx
+++ b/sw/source/core/fields/ddetbl.cxx
@@ -87,7 +87,8 @@ void SwDDETable::SwClientNotify(const SwModify& rModify, 
const SfxHint& rHint)
 {
     if (rHint.GetId() == SfxHintId::SwLegacyModify
         || rHint.GetId() == SfxHintId::SwAutoFormatUsedHint
-        || rHint.GetId() == SfxHintId::SwAttrSetChange)
+        || rHint.GetId() == SfxHintId::SwAttrSetChange
+        || rHint.GetId() == SfxHintId::SwObjectDying)
     {
         SwTable::SwClientNotify(rModify, rHint);
     }
diff --git a/sw/source/core/fields/docufld.cxx 
b/sw/source/core/fields/docufld.cxx
index c6ce1a746922..832b5177841b 100644
--- a/sw/source/core/fields/docufld.cxx
+++ b/sw/source/core/fields/docufld.cxx
@@ -2260,7 +2260,7 @@ std::unique_ptr<SwFieldType> 
SwRefPageGetFieldType::Copy() const
 
 void SwRefPageGetFieldType::SwClientNotify(const SwModify&, const SfxHint& 
rHint)
 {
-    if (rHint.GetId() == SfxHintId::SwFormatChange)
+    if (rHint.GetId() == SfxHintId::SwFormatChange || rHint.GetId() == 
SfxHintId::SwObjectDying)
     {
         // forward to text fields, they "expand" the text
         CallSwClientNotify(rHint);
diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx
index 51377978f63f..fcbb45cf539d 100644
--- a/sw/source/core/fields/reffld.cxx
+++ b/sw/source/core/fields/reffld.cxx
@@ -1159,7 +1159,7 @@ void SwGetRefFieldType::UpdateStyleReferences()
 
 void SwGetRefFieldType::SwClientNotify(const SwModify&, const SfxHint& rHint)
 {
-    if (rHint.GetId() == SfxHintId::SwFormatChange)
+    if (rHint.GetId() == SfxHintId::SwFormatChange || rHint.GetId() == 
SfxHintId::SwObjectDying)
     {
         // forward to text fields, they "expand" the text
         CallSwClientNotify(rHint);
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 88a230b11a3c..3248ac8074c4 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -760,14 +760,10 @@ void SwFormatPageDesc::SwClientNotify(const SwModify&, 
const SfxHint& rHint)
             // there could be an Undo-copy
             RegisterToPageDesc(*pDesc);
     }
-    else if (rHint.GetId() == SfxHintId::SwLegacyModify)
+    else if (rHint.GetId() == SfxHintId::SwObjectDying)
     {
-        auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
-        if(RES_OBJECTDYING == pLegacy->GetWhich())
-        {
-            m_pDefinedIn = nullptr;
-            EndListeningAll();
-        }
+        m_pDefinedIn = nullptr;
+        EndListeningAll();
     }
 }
 
@@ -2755,6 +2751,11 @@ void SwFrameFormat::SwClientNotify(const SwModify& rMod, 
const SfxHint& rHint)
         SwFormat::SwClientNotify(rMod, rHint);
         return;
     }
+    else if (rHint.GetId() == SfxHintId::SwObjectDying)
+    {
+        SwFormat::SwClientNotify(rMod, rHint);
+        return;
+    }
     else if (rHint.GetId() != SfxHintId::SwLegacyModify && rHint.GetId() != 
SfxHintId::SwAttrSetChange)
         return;
 
diff --git a/sw/source/core/layout/flyincnt.cxx 
b/sw/source/core/layout/flyincnt.cxx
index 712ee61884c0..673522376a3e 100644
--- a/sw/source/core/layout/flyincnt.cxx
+++ b/sw/source/core/layout/flyincnt.cxx
@@ -139,6 +139,13 @@ void SwFlyInContentFrame::SwClientNotify(const SwModify& 
rMod, const SfxHint& rH
         }
         return;
     }
+    if (rHint.GetId() == SfxHintId::SwObjectDying)
+    {
+        SwFlyFrame::SwClientNotify(rMod, rHint);
+        if(GetAnchorFrame())
+            AnchorFrame()->Prepare(PrepareHint::FlyFrameAttributesChanged, 
GetFormat());
+        return;
+    }
     if (rHint.GetId() != SfxHintId::SwLegacyModify)
         return;
     auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
diff --git a/sw/source/core/layout/flylay.cxx b/sw/source/core/layout/flylay.cxx
index 51e5a2b87387..0dcad35ee79a 100644
--- a/sw/source/core/layout/flylay.cxx
+++ b/sw/source/core/layout/flylay.cxx
@@ -751,6 +751,11 @@ void SwFlyLayFrame::SwClientNotify(const SwModify& rMod, 
const SfxHint& rHint)
             SwFlyFrame::SwClientNotify(rMod, rHint);
         return;
     }
+    if (rHint.GetId() == SfxHintId::SwObjectDying)
+    {
+        SwFlyFrame::SwClientNotify(rMod, rHint);
+        return;
+    }
     if (rHint.GetId() != SfxHintId::SwLegacyModify && rHint.GetId() != 
SfxHintId::SwAttrSetChange)
         return;
 
diff --git a/sw/source/core/layout/pagedesc.cxx 
b/sw/source/core/layout/pagedesc.cxx
index 24b4e8d40fa7..8b2d48f7305f 100644
--- a/sw/source/core/layout/pagedesc.cxx
+++ b/sw/source/core/layout/pagedesc.cxx
@@ -295,6 +295,10 @@ void SwPageDesc::SwClientNotify(const SwModify& rModify, 
const SfxHint& rHint)
         CallSwClientNotify(rHint);
         RegisterChange();
     }
+    else if (rHint.GetId() == SfxHintId::SwObjectDying)
+    {
+        CallSwClientNotify(rHint);
+    }
     else if (rHint.GetId() == SfxHintId::SwLegacyModify)
     {
         auto pLegacyHint = static_cast<const sw::LegacyModifyHint*>(&rHint);
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index 24225b332ef0..54db69c2e281 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -6273,7 +6273,7 @@ void SwCellFrame::SwClientNotify(const SwModify& rMod, 
const SfxHint& rHint)
         SetDerivedVert(false);
         CheckDirChange();
     }
-    else if (rHint.GetId() == SfxHintId::SwFormatChange)
+    else if (rHint.GetId() == SfxHintId::SwFormatChange || rHint.GetId() == 
SfxHintId::SwObjectDying)
     {
         SwLayoutFrame::SwClientNotify(rMod, rHint);
     }
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index 6c2484fa4f90..b5e9218ff842 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -342,25 +342,24 @@ void SwTable::SwClientNotify(const SwModify&, const 
SfxHint& rHint)
         if (pOldSize && pNewSize && !m_bModifyLocked)
             AdjustWidths(pOldSize->GetWidth(), pNewSize->GetWidth());
     }
+    else if (rHint.GetId() == SfxHintId::SwObjectDying)
+    {
+        auto pDyingHint = static_cast<const sw::ObjectDyingHint*>(&rHint);
+        CheckRegistration( *pDyingHint );
+    }
     else if (rHint.GetId() == SfxHintId::SwLegacyModify)
     {
         auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
         // catch SSize changes, to adjust the lines/boxes
         const sal_uInt16 nWhich = pLegacy->GetWhich();
-        const SwFormatFrameSize* pNewSize = nullptr, *pOldSize = nullptr;
-        switch(nWhich)
+        if (nWhich == RES_FRM_SIZE)
         {
-            case RES_FRM_SIZE:
-            {
-                pOldSize = static_cast<const 
SwFormatFrameSize*>(pLegacy->m_pOld);
-                pNewSize = static_cast<const 
SwFormatFrameSize*>(pLegacy->m_pNew);
-            }
-            break;
-            default:
-                CheckRegistration(pLegacy->m_pOld);
+            const SwFormatFrameSize* pNewSize = nullptr, *pOldSize = nullptr;
+            pOldSize = static_cast<const SwFormatFrameSize*>(pLegacy->m_pOld);
+            pNewSize = static_cast<const SwFormatFrameSize*>(pLegacy->m_pNew);
+            if (pOldSize && pNewSize && !m_bModifyLocked)
+                AdjustWidths(pOldSize->GetWidth(), pNewSize->GetWidth());
         }
-        if (pOldSize && pNewSize && !m_bModifyLocked)
-            AdjustWidths(pOldSize->GetWidth(), pNewSize->GetWidth());
     }
 }
 
@@ -2755,10 +2754,14 @@ SwTableBox* 
SwTableBoxFormat::SwTableBoxFormat::GetTableBox()
 // for detection of modifications (mainly TableBoxAttribute)
 void SwTableBoxFormat::SwClientNotify(const SwModify& rMod, const SfxHint& 
rHint)
 {
-    if(rHint.GetId() != SfxHintId::SwLegacyModify && rHint.GetId() != 
SfxHintId::SwFormatChange
-        && rHint.GetId() != SfxHintId::SwAttrSetChange)
+    if(rHint.GetId() == SfxHintId::SwFormatChange || rHint.GetId() == 
SfxHintId::SwObjectDying)
+    {
+        SwFrameFormat::SwClientNotify(rMod, rHint);
+        return;
+    }
+    if(rHint.GetId() != SfxHintId::SwLegacyModify && rHint.GetId() != 
SfxHintId::SwAttrSetChange)
         return;
-    if(IsModifyLocked() || !GetDoc() || GetDoc()->IsInDtor() || rHint.GetId() 
== SfxHintId::SwFormatChange)
+    if(IsModifyLocked() || !GetDoc() || GetDoc()->IsInDtor())
     {
         SwFrameFormat::SwClientNotify(rMod, rHint);
         return;
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index f351d2047a7e..4a3cfaf5624e 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -2711,6 +2711,8 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, 
SfxHint const& rHint)
         }
 #endif
     }
+    else if (rHint.GetId() == SfxHintId::SwObjectDying)
+        ; // do nothing
     else switch (nWhich)
     {
         case RES_LINENUMBER:
@@ -2761,8 +2763,6 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, 
SfxHint const& rHint)
 #endif
         }
         break;
-        case RES_OBJECTDYING:
-        break;
 
         case RES_PARATR_LINESPACING:
             {
diff --git a/sw/source/core/txtnode/atrfld.cxx 
b/sw/source/core/txtnode/atrfld.cxx
index 3310c6f243ba..1d7377343274 100644
--- a/sw/source/core/txtnode/atrfld.cxx
+++ b/sw/source/core/txtnode/atrfld.cxx
@@ -255,7 +255,8 @@ void SwFormatField::SwClientNotify( const SwModify& 
rModify, const SfxHint& rHin
     }
     else if (rHint.GetId() == SfxHintId::SwLegacyModify
             || rHint.GetId() == SfxHintId::SwFormatChange
-            || rHint.GetId() == SfxHintId::SwAttrSetChange)
+            || rHint.GetId() == SfxHintId::SwAttrSetChange
+            || rHint.GetId() == SfxHintId::SwObjectDying)
     {
         if(!mpTextField)
             return;
@@ -464,6 +465,10 @@ void SwFormatField::UpdateTextNode(const SfxHint& rHint)
         if(bTriggerNode)
             pTextNd->TriggerNodeUpdate(sw::AttrSetChangeHint(pOld, pNew));
     }
+    else if(SfxHintId::SwObjectDying == rHint.GetId())
+    {
+        assert(false && "do not expect this, might need to restore some code");
+    }
     else if(SfxHintId::SwLegacyModify == rHint.GetId())
     {
         auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
@@ -478,10 +483,6 @@ void SwFormatField::UpdateTextNode(const SfxHint& rHint)
         if (!IsFieldInDoc())
             return;
 
-        // don't do anything, especially not expand!
-        if( pNew && pNew->Which() == RES_OBJECTDYING )
-            return;
-
         SwTextNode* pTextNd = &mpTextField->GetTextNode();
         OSL_ENSURE(pTextNd, "Where is my Node?");
 
diff --git a/sw/source/core/txtnode/attrcontentcontrol.cxx 
b/sw/source/core/txtnode/attrcontentcontrol.cxx
index 0e984066f2b0..449124f9dc23 100644
--- a/sw/source/core/txtnode/attrcontentcontrol.cxx
+++ b/sw/source/core/txtnode/attrcontentcontrol.cxx
@@ -272,7 +272,8 @@ void SwContentControl::SwClientNotify(const SwModify&, 
const SfxHint& rHint)
     }
     else if (rHint.GetId() == SfxHintId::SwLegacyModify
              || rHint.GetId() == SfxHintId::SwFormatChange
-             || rHint.GetId() == SfxHintId::SwAttrSetChange)
+             || rHint.GetId() == SfxHintId::SwAttrSetChange
+             || rHint.GetId() == SfxHintId::SwObjectDying)
     {
         CallSwClientNotify(rHint);
         GetNotifier().Broadcast(SfxHint(SfxHintId::DataChanged));
diff --git a/sw/source/core/txtnode/attrlinebreak.cxx 
b/sw/source/core/txtnode/attrlinebreak.cxx
index fabd14fcd4ad..1e5a1adcebca 100644
--- a/sw/source/core/txtnode/attrlinebreak.cxx
+++ b/sw/source/core/txtnode/attrlinebreak.cxx
@@ -67,7 +67,8 @@ void SwFormatLineBreak::SwClientNotify(const SwModify&, const 
SfxHint& rHint)
     }
     else if (rHint.GetId() == SfxHintId::SwLegacyModify
              || rHint.GetId() == SfxHintId::SwFormatChange
-             || rHint.GetId() == SfxHintId::SwAttrSetChange)
+             || rHint.GetId() == SfxHintId::SwAttrSetChange
+             || rHint.GetId() == SfxHintId::SwObjectDying)
         CallSwClientNotify(rHint);
 }
 
diff --git a/sw/source/core/txtnode/fmtatr2.cxx 
b/sw/source/core/txtnode/fmtatr2.cxx
index b4c03bceab1e..ee48e1e88ca9 100644
--- a/sw/source/core/txtnode/fmtatr2.cxx
+++ b/sw/source/core/txtnode/fmtatr2.cxx
@@ -108,6 +108,12 @@ void SwFormatCharFormat::SwClientNotify(const SwModify&, 
const SfxHint& rHint)
         if(m_pTextAttribute)
             m_pTextAttribute->TriggerNodeUpdate(*pChangeHint);
     }
+    else if (rHint.GetId() == SfxHintId::SwObjectDying)
+    {
+        auto pDyingHint = static_cast<const sw::ObjectDyingHint*>(&rHint);
+        if(m_pTextAttribute)
+            m_pTextAttribute->TriggerNodeUpdate(*pDyingHint);
+    }
     else if (rHint.GetId() == SfxHintId::SwLegacyModify)
     {
         auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
@@ -740,7 +746,8 @@ void Meta::SwClientNotify(const SwModify&, const SfxHint& 
rHint)
     }
     else if (rHint.GetId() == SfxHintId::SwLegacyModify
             || rHint.GetId() == SfxHintId::SwFormatChange
-            || rHint.GetId() == SfxHintId::SwAttrSetChange)
+            || rHint.GetId() == SfxHintId::SwAttrSetChange
+            || rHint.GetId() == SfxHintId::SwObjectDying)
     {
         CallSwClientNotify(rHint);
         GetNotifier().Broadcast(SfxHint(SfxHintId::DataChanged));
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 87904fe92abc..9650fb75212f 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -5558,6 +5558,20 @@ void SwTextNode::TriggerNodeUpdate(const 
sw::LegacyModifyHint& rHint)
     }
 }
 
+void SwTextNode::TriggerNodeUpdate(const sw::ObjectDyingHint& rHint)
+{
+    sw::TextNodeNotificationSuppressor(*this);
+
+    SwContentNode::SwClientNotify(*this, rHint);
+
+    SwDoc& rDoc = GetDoc();
+    // #125329# - assure that text node is in document nodes array
+    if ( !rDoc.IsInDtor() && &rDoc.GetNodes() == &GetNodes() )
+    {
+        rDoc.GetNodes().UpdateOutlineNode(*this);
+    }
+}
+
 void SwTextNode::TriggerNodeUpdate(const sw::AttrSetChangeHint& rHint)
 {
     const SwAttrSetChg* pOldValue = rHint.m_pOld;
@@ -5669,6 +5683,11 @@ void SwTextNode::SwClientNotify( const SwModify& 
rModify, const SfxHint& rHint )
     {
         TriggerNodeUpdate(static_cast<const sw::RemoveUnoObjectHint&>(rHint));
     }
+    else if (rHint.GetId() == SfxHintId::SwObjectDying)
+    {
+        auto pDyingHint = static_cast<const sw::ObjectDyingHint*>(&rHint);
+        TriggerNodeUpdate(*pDyingHint);
+    }
     else if (rHint.GetId() == SfxHintId::SwLegacyModify)
     {
         auto pLegacyHint = static_cast<const sw::LegacyModifyHint*>(&rHint);
diff --git a/sw/source/core/txtnode/txtatr2.cxx 
b/sw/source/core/txtnode/txtatr2.cxx
index e571694fe198..cb8c20476acb 100644
--- a/sw/source/core/txtnode/txtatr2.cxx
+++ b/sw/source/core/txtnode/txtatr2.cxx
@@ -75,8 +75,7 @@ SwTextCharFormat::~SwTextCharFormat( )
 void SwTextCharFormat::TriggerNodeUpdate(const sw::LegacyModifyHint& rHint)
 {
     const auto nWhich = rHint.GetWhich();
-    assert( (isCHRATR(nWhich) ||
-             RES_OBJECTDYING == nWhich) && 
"SwTextCharFormat::TriggerNodeUpdate: unknown hint type");
+    assert( isCHRATR(nWhich) && "SwTextCharFormat::TriggerNodeUpdate: unknown 
hint type");
 
     if(m_pTextNode)
     {
@@ -88,6 +87,18 @@ void SwTextCharFormat::TriggerNodeUpdate(const 
sw::LegacyModifyHint& rHint)
     }
 }
 
+void SwTextCharFormat::TriggerNodeUpdate(const sw::ObjectDyingHint& /*rHint*/)
+{
+    if(m_pTextNode)
+    {
+        SwUpdateAttr aUpdateAttr(
+            GetStart(),
+            *GetEnd(),
+            RES_UPDATEATTR_OBJECTDYING);
+        m_pTextNode->TriggerNodeUpdate(sw::LegacyModifyHint(&aUpdateAttr, 
&aUpdateAttr));
+    }
+}
+
 void SwTextCharFormat::TriggerNodeUpdate(const sw::AttrSetChangeHint& 
/*rHint*/)
 {
     if(m_pTextNode)
@@ -216,11 +227,18 @@ void SwTextINetFormat::SwClientNotify(const SwModify&, 
const SfxHint& rHint)
         const SwUpdateAttr aUpdateAttr(GetStart(), *GetEnd(), 
RES_UPDATEATTR_ATTRSET_CHG);
         m_pTextNode->TriggerNodeUpdate(sw::LegacyModifyHint(&aUpdateAttr, 
&aUpdateAttr));
     }
+    else if (rHint.GetId() == SfxHintId::SwObjectDying)
+    {
+        if(!m_pTextNode)
+            return;
+        const SwUpdateAttr aUpdateAttr(GetStart(), *GetEnd(), 
RES_UPDATEATTR_OBJECTDYING);
+        m_pTextNode->TriggerNodeUpdate(sw::LegacyModifyHint(&aUpdateAttr, 
&aUpdateAttr));
+    }
     else if (rHint.GetId() == SfxHintId::SwLegacyModify)
     {
         auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
         const auto nWhich = pLegacy->GetWhich();
-        assert((isCHRATR(nWhich) || (RES_OBJECTDYING == nWhich)) && 
"SwTextINetFormat::SwClientNotify: unknown hint.");
+        assert(isCHRATR(nWhich) && "SwTextINetFormat::SwClientNotify: unknown 
hint.");
         if(!m_pTextNode)
             return;
         const SwUpdateAttr aUpdateAttr(GetStart(), *GetEnd(), nWhich);
@@ -268,12 +286,18 @@ void SwTextRuby::SwClientNotify(const SwModify&, const 
SfxHint& rHint)
         SwUpdateAttr aUpdateAttr(GetStart(), *GetEnd(), 
RES_UPDATEATTR_ATTRSET_CHG);
         m_pTextNode->TriggerNodeUpdate(sw::LegacyModifyHint(&aUpdateAttr, 
&aUpdateAttr));
     }
+    else if (rHint.GetId() == SfxHintId::SwObjectDying)
+    {
+        if(!m_pTextNode)
+            return;
+        SwUpdateAttr aUpdateAttr(GetStart(), *GetEnd(), 
RES_UPDATEATTR_OBJECTDYING);
+        m_pTextNode->TriggerNodeUpdate(sw::LegacyModifyHint(&aUpdateAttr, 
&aUpdateAttr));
+    }
     else if (rHint.GetId() == SfxHintId::SwLegacyModify)
     {
         auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
         const auto nWhich = pLegacy->GetWhich();
-        assert( (isCHRATR(nWhich)
-                 || (RES_OBJECTDYING == nWhich)) && 
"SwTextRuby::SwClientNotify(): unknown legacy hint");
+        assert( isCHRATR(nWhich) && "SwTextRuby::SwClientNotify(): unknown 
legacy hint");
         if(!m_pTextNode)
             return;
         SwUpdateAttr aUpdateAttr(GetStart(), *GetEnd(), nWhich);
diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx
index 5a7db042029d..8e00da622fa6 100644
--- a/sw/source/core/undo/unattr.cxx
+++ b/sw/source/core/undo/unattr.cxx
@@ -87,12 +87,15 @@ void SwUndoFormatAttrHelper::SwClientNotify(const 
SwModify&, const SfxHint& rHin
         }
         return;
     }
+    else if (rHint.GetId() == SfxHintId::SwObjectDying)
+    {
+        assert(false);
+    }
     if (rHint.GetId() != SfxHintId::SwLegacyModify)
         return;
     auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
     if(!pLegacy->m_pOld)
         return;
-    assert(pLegacy->m_pOld->Which() != RES_OBJECTDYING);
     if(!pLegacy->m_pNew)
         return;
     const SwDoc& rDoc = *m_rFormat.GetDoc();
diff --git a/sw/source/core/unocore/unochart.cxx 
b/sw/source/core/unocore/unochart.cxx
index 0245e793c5fb..7b7a34d2aad2 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -2150,8 +2150,10 @@ void SwChartDataSequence::Notify( const SfxHint& rHint)
         m_pTableCursor.reset(nullptr);
         dispose();
     }
-    else if (rHint.GetId() == SfxHintId::SwLegacyModify || rHint.GetId() == 
SfxHintId::SwFormatChange
-            || rHint.GetId() == SfxHintId::SwAttrSetChange)
+    else if (rHint.GetId() == SfxHintId::SwLegacyModify
+            || rHint.GetId() == SfxHintId::SwFormatChange
+            || rHint.GetId() == SfxHintId::SwAttrSetChange
+            || rHint.GetId() == SfxHintId::SwObjectDying)
     {
         setModified( true );
     }
diff --git a/sw/source/core/unocore/unofield.cxx 
b/sw/source/core/unocore/unofield.cxx
index d87978919c06..afbaf1e48867 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -2646,16 +2646,8 @@ void SwXTextField::Impl::Notify(const SfxHint& rHint)
 
     if(rHint.GetId() == SfxHintId::Dying)
         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_OBJECTDYING:
-                Invalidate();
-                break;
-        }
-    }
+    else if (rHint.GetId() == SfxHintId::SwObjectDying)
+        Invalidate();
 }
 
 const SwField* SwXTextField::Impl::GetField() const
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 3bbc855ae35e..eb8515732370 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -4764,14 +4764,12 @@ TextNodeListener::~TextNodeListener()
 
 void TextNodeListener::SwClientNotify(const SwModify& rModify, const SfxHint& 
rHint)
 {
-    if (rHint.GetId() != SfxHintId::SwLegacyModify)
+    if (rHint.GetId() != SfxHintId::SwObjectDying)
         return;
-    auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
     // ofz#41398 drop a para scheduled for deletion if something else deletes 
it
     // before wwExtraneousParas gets its chance to do so. Not the usual 
scenario,
     // indicates an underlying bug.
-    if (pLegacy->GetWhich() == RES_OBJECTDYING)
-        removed(const_cast<SwModify*>(&rModify));
+    removed(const_cast<SwModify*>(&rModify));
 }
 
 void TextNodeListener::StopListening(SwModify* pTextNode)
diff --git a/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx 
b/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx
index b27de07e9e50..fe1b5e58042d 100644
--- a/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx
+++ b/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx
@@ -87,12 +87,8 @@ 
WriterInspectorTextPanel::WriterInspectorTextPanel(weld::Widget* pParent)
 
 void WriterInspectorTextPanel::SwClientNotify(const SwModify& rModify, const 
SfxHint& rHint)
 {
-    if (rHint.GetId() == SfxHintId::SwLegacyModify)
-    {
-        const sw::LegacyModifyHint& rLegacy = static_cast<const 
sw::LegacyModifyHint&>(rHint);
-        if (rLegacy.GetWhich() == RES_OBJECTDYING)
-            m_pShell = nullptr;
-    }
+    if (rHint.GetId() == SfxHintId::SwObjectDying)
+        m_pShell = nullptr;
     SwClient::SwClientNotify(rModify, rHint);
 }
 

Reply via email to