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/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 7481fdaa5563..efe7d4a20093 100644 --- a/sw/inc/calbck.hxx +++ b/sw/inc/calbck.hxx @@ -70,6 +70,7 @@ namespace sw { class ClientIteratorBase; class ListenerEntry; + class ObjectDyingHint; enum class IteratorMode { Exact, UnwrapMulti }; } @@ -170,7 +171,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 CheckRegistration( const SfxPoolItem* pOldValue ); + std::optional CheckRegistration( const sw::ObjectDyingHint& rHint ); // SwFormat wants to die different than the rest: It wants to reparent every client to its parent // and then send a SwFormatChg hint. void CheckRegistrationFormat(SwFormat& rOld); 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(&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 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 RES_UPDATE_ATTR(170); // empty diff --git a/sw/inc/hints.hxx b/sw/inc/hints.hxx index 90eb881012d8..29b64f43ba4b 100644 --- a/sw/inc/hints.hxx +++ b/sw/inc/hints.hxx @@ -54,18 +54,6 @@ public: virtual SwMsgPoolItem* Clone( SfxItemPool* pPool = nullptr ) const override; }; -// SwPtrMsgPoolItem (old SwObjectDying!) - -class SwPtrMsgPoolItem final : public SwMsgPoolItem -{ -public: - void * pObject; - - SwPtrMsgPoolItem( sal_uInt16 nId, void * pObj ) - : SwMsgPoolItem( nId ), pObject( pObj ) - {} -}; - /** * SwFormatChg is sent when a format has changed to another format. */ @@ -327,6 +315,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 0351ea76b75f..89dbbb0f83f4 100644 --- a/sw/source/core/attr/calbck.cxx +++ b/sw/source/core/attr/calbck.cxx @@ -37,17 +37,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(&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(&rHint); + auto pModifyChanged = CheckRegistration(*pDyingHint); + if (pModifyChanged) + m_pToTell->SwClientNotify(rModify, *pModifyChanged); } else if (m_pToTell) m_pToTell->SwClientNotify(rModify, rHint); @@ -78,16 +73,11 @@ sw::ClientBase::~ClientBase() } template -std::optional sw::ClientBase::CheckRegistration( const SfxPoolItem* pOld ) +std::optional sw::ClientBase::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(pOld)); - const SwPtrMsgPoolItem* pDead = static_cast(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 {}; @@ -123,10 +113,10 @@ void sw::ClientBase::CheckRegistrationFormat(SwFormat& rOld) template void sw::ClientBase::SwClientNotify(const SwModify&, const SfxHint& rHint) { - if (rHint.GetId() != SfxHintId::SwLegacyModify) + if (rHint.GetId() != SfxHintId::SwObjectDying) return; - auto pLegacyHint = static_cast(&rHint); - CheckRegistration(pLegacyHint->m_pOld); + auto pDyingHint = static_cast(&rHint); + CheckRegistration(*pDyingHint); }; template @@ -151,15 +141,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(m_pWriterListeners)->CheckRegistration(&aDyObject); + static_cast(m_pWriterListeners)->CheckRegistration(aDyObject); } assert(!hasListenersOnDeath); } @@ -220,7 +210,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 1ec609f0748d..5d0da518118e 100644 --- a/sw/source/core/attr/format.cxx +++ b/sw/source/core/attr/format.cxx @@ -264,53 +264,50 @@ void SwFormat::SwClientNotify(const SwModify&, const SfxHint& rHint) } return; } + if (rHint.GetId() == SfxHintId::SwObjectDying) + { + auto pDyingHint = static_cast(&rHint); + InvalidateInSwCache(); + // If the dying object is the parent format of this format so + // attach this to the parent of the parent + SwFormat* pFormat = static_cast(pDyingHint->m_pDying); + + // 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); + } + } + InvalidateInSwFntCache(); + SwModify::SwClientNotify(*this, rHint); + return; + } if (rHint.GetId() != SfxHintId::SwLegacyModify) return; auto pLegacy = static_cast(&rHint); - std::optional oOldClientChg, oNewClientChg; std::optional 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(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(&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(&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(&rHint); - CheckRegistration( pLegacyHint->m_pOld ); + auto pDyingHint = static_cast(&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(&rHint); - CheckRegistration( pLegacy->m_pOld ); + auto pDyingHint = static_cast(&rHint); + CheckRegistration( *pDyingHint ); } SwDoc *pDoc = static_cast(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(&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(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(pFormat->GetDoc())); - return; } - if (rHint.GetId() != SfxHintId::SwLegacyModify) - return; - auto pLegacy = static_cast(&rHint); - CheckRegistration(pLegacy->m_pOld); + else if (rHint.GetId() == SfxHintId::SwObjectDying) + { + auto pDyingHint = static_cast(&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(this)->SetCalcHiddenCharFlags(); CallSwClientNotify(rHint); } + else if (rHint.GetId() == SfxHintId::SwObjectDying) + { + auto pDyingHint = static_cast(&rHint); + InvalidateInSwCache(); + const SwFormat* pFormat = static_cast(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(&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(static_cast(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 9d82953715a1..62bbbd2c2ed1 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(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(&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 @@ -780,6 +783,20 @@ void SwSectionFormat::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) } SwFrameFormat::SwClientNotify(rMod, rHint); } + else if (rHint.GetId() == SfxHintId::SwObjectDying) + { + auto pDyingHint = static_cast(&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(&rHint); @@ -795,19 +812,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(pOld)->pObject == static_cast(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", " 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(&rHint); if (pChangeHint->m_pNew) @@ -1519,7 +1521,7 @@ void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) assert(!" - unhandled attribute?"); } } - else // rHint.GetId() == SfxHintId::SwAttrSetChange) + else if (rHint.GetId() == SfxHintId::SwAttrSetChange) { // #i35443# auto pChangeHint = static_cast(&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 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 496aabffedb1..9441a86f0407 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 d67d2e5a4d43..086408816781 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -770,14 +770,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(&rHint); - if(RES_OBJECTDYING == pLegacy->GetWhich()) - { - m_pDefinedIn = nullptr; - EndListeningAll(); - } + m_pDefinedIn = nullptr; + EndListeningAll(); } } @@ -2765,6 +2761,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(&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(&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(&rHint); + CheckRegistration( *pDyingHint ); + } else if (rHint.GetId() == SfxHintId::SwLegacyModify) { auto pLegacy = static_cast(&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(pLegacy->m_pOld); - pNewSize = static_cast(pLegacy->m_pNew); - } - break; - default: - CheckRegistration(pLegacy->m_pOld); + const SwFormatFrameSize* pNewSize = nullptr, *pOldSize = nullptr; + pOldSize = static_cast(pLegacy->m_pOld); + pNewSize = static_cast(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 10111d661383..47259ab9b8e8 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(&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 d452b726615d..78195ba7a8ab 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 5ba26c5f4cf8..240027a39442 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 6e9eead823ab..75704a8f1a33 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(&rHint); + if(m_pTextAttribute) + m_pTextAttribute->TriggerNodeUpdate(*pDyingHint); + } else if (rHint.GetId() == SfxHintId::SwLegacyModify) { auto pLegacy = static_cast(&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(rHint)); } + else if (rHint.GetId() == SfxHintId::SwObjectDying) + { + auto pDyingHint = static_cast(&rHint); + TriggerNodeUpdate(*pDyingHint); + } else if (rHint.GetId() == SfxHintId::SwLegacyModify) { auto pLegacyHint = static_cast(&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(&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(&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(&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(&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(&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(&rModify)); + removed(const_cast(&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(rHint); - if (rLegacy.GetWhich() == RES_OBJECTDYING) - m_pShell = nullptr; - } + if (rHint.GetId() == SfxHintId::SwObjectDying) + m_pShell = nullptr; SwClient::SwClientNotify(rModify, rHint); }