include/svl/hint.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 | 18 +++- 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 | 60 +++++++-------- 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 +- 44 files changed, 241 insertions(+), 279 deletions(-)
New commits: commit 0d71b29e3427d2d43b45ae4cfb91bb19ec1e3158 Author: Stephan Bergmann <stephan.bergm...@allotropia.de> AuthorDate: Wed Jan 8 09:16:01 2025 +0100 Commit: Stephan Bergmann <stephan.bergm...@allotropia.de> CommitDate: Wed Jan 8 12:48:32 2025 +0100 Revert "convert RES_OBJECTDYING to SfxHint" This reverts commit cc56bf56e170492e414a975ad8c07c41ed72e1a4. Reason for revert: It causes CppunitTest_sw_uwriter CPPUNIT_TEST_NAME=SwDocTest::test64kPageDescs to fail with > /sw/source/core/attr/format.cxx:273:29: runtime error: downcast of address 0x6140000e1840 which does not point to an object of type 'SwFormat' > 0x6140000e1840: note: object is of type 'SwModify' > 00 00 00 00 b0 e1 74 97 df 7f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > ^~~~~~~~~~~~~~~~~~~~~~~ > vptr for 'SwModify' > #0 0x7fdf8a31ca65 in SwFormat::SwClientNotify(SwModify const&, SfxHint const&) /sw/source/core/attr/format.cxx:273:29 > #1 0x7fdf8d066efe in SwFrameFormat::SwClientNotify(SwModify const&, SfxHint const&) /sw/source/core/layout/atrfrm.cxx:2766:19 > #2 0x7fdf8a2d51f2 in SwModify::CallSwClientNotify(SfxHint const&) const /sw/source/core/attr/calbck.cxx:231:18 > #3 0x7fdf8a2d2c5a in SwModify::SwClientNotify(SwModify const&, SfxHint const&) /sw/source/core/attr/calbck.cxx:222:5 > #4 0x7fdf8a2d07bd in SwModify::~SwModify() /sw/source/core/attr/calbck.cxx:145:15 > #5 0x7fdf89b267c5 in sw::BroadcastingModify::~BroadcastingModify() /sw/inc/calbck.hxx:242:59 > #6 0x7fdf8a319f52 in SwFormat::~SwFormat() /sw/source/core/attr/format.cxx:208:1 > #7 0x7fdf8d064426 in SwFrameFormat::~SwFrameFormat() /sw/source/core/layout/atrfrm.cxx:2705:1 > #8 0x7fdf8d0644d8 in SwFrameFormat::~SwFrameFormat() /sw/source/core/layout/atrfrm.cxx:2677:1 > #9 0x7fdf8b42be68 in std::default_delete<SwFrameFormat>::operator()(SwFrameFormat*) const /opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/12/../../../../include/c++/12/bits/unique_ptr.h:95:2 > #10 0x7fdf8b454cc4 in std::__uniq_ptr_impl<SwFrameFormat, std::default_delete<SwFrameFormat> >::reset(SwFrameFormat*) /opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/12/../../../../include/c++/12/bits/unique_ptr.h:203:4 > #11 0x7fdf8b38aa7e in std::unique_ptr<SwFrameFormat, std::default_delete<SwFrameFormat> >::reset(SwFrameFormat*) /opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/12/../../../../include/c++/12/bits/unique_ptr.h:501:7 > #12 0x7fdf8b3434a6 in SwDoc::~SwDoc() /sw/source/core/doc/docnew.cxx:625:23 > #13 0x7fdf8abc1dd5 in SwDoc::release() /sw/source/core/doc/doc.cxx:136:9 > #14 0x7fdf8c2cbc16 in rtl::Reference<SwDoc>::clear() /include/rtl/ref.hxx:193:19 > #15 0x7fdf9102a534 in SwDocShell::RemoveLink() /sw/source/uibase/app/docshini.cxx:445:16 > #16 0x7fdf910295bd in SwDocShell::~SwDocShell() /sw/source/uibase/app/docshini.cxx:373:5 > #17 0x7fdf9102a728 in SwDocShell::~SwDocShell() /sw/source/uibase/app/docshini.cxx:363:1 > #18 0x7fdfda648fca in cppu::OWeakObject::release() /cppuhelper/source/weak.cxx:230:9 > #19 0x7fdf89b2801f in rtl::Reference<SwDocShell>::clear() /include/rtl/ref.hxx:193:19 > #20 0x7fdf89ac3f0c in SwDocTest::tearDown() /sw/qa/core/uwriter.cxx:1977:17 (<https://ci.libreoffice.org/job/lo_ubsan/3425/>) Change-Id: Ib4866bcfc71e2e3358a8f860cc19efa3f6349885 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179925 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de> diff --git a/include/svl/hint.hxx b/include/svl/hint.hxx index 53875a19dfa5..0b4c626306b5 100644 --- a/include/svl/hint.hxx +++ b/include/svl/hint.hxx @@ -233,7 +233,6 @@ enum class SfxHintId { SwHiddenParaPrint, SwFormatChange, SwAttrSetChange, - SwObjectDying, ThisIsAnSdrHint, ThisIsAnSfxEventHint diff --git a/sw/IwyuFilter_sw.yaml b/sw/IwyuFilter_sw.yaml index 6e67a98cd3cf..b3d5665826e8 100644 --- a/sw/IwyuFilter_sw.yaml +++ b/sw/IwyuFilter_sw.yaml @@ -222,6 +222,7 @@ 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 efe7d4a20093..7481fdaa5563 100644 --- a/sw/inc/calbck.hxx +++ b/sw/inc/calbck.hxx @@ -70,7 +70,6 @@ namespace sw { class ClientIteratorBase; class ListenerEntry; - class ObjectDyingHint; enum class IteratorMode { Exact, UnwrapMulti }; } @@ -171,7 +170,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 sw::ObjectDyingHint& rHint ); + std::optional<sw::ModifyChangedHint> CheckRegistration( const SfxPoolItem* pOldValue ); // 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 261c85763b54..023e5e638720 100644 --- a/sw/inc/deletelistener.hxx +++ b/sw/inc/deletelistener.hxx @@ -20,7 +20,10 @@ private: virtual void SwClientNotify(const SwModify&, const SfxHint& rHint) override { - if (rHint.GetId() == SfxHintId::SwObjectDying) + if (rHint.GetId() != SfxHintId::SwLegacyModify) + return; + auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint); + if (pLegacy->GetWhich() == RES_OBJECTDYING) { m_pModify->Remove(*this); m_pModify = nullptr; diff --git a/sw/inc/fmtcol.hxx b/sw/inc/fmtcol.hxx index db39befc3d68..a966e84049ea 100644 --- a/sw/inc/fmtcol.hxx +++ b/sw/inc/fmtcol.hxx @@ -143,6 +143,14 @@ 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 be104eedbeb8..fab0a027a0aa 100644 --- a/sw/inc/hintids.hxx +++ b/sw/inc/hintids.hxx @@ -34,6 +34,7 @@ class SwFormatMeta; class SwFormatContentControl; class SvXMLAttrContainerItem; class SwMsgPoolItem; +class SwPtrMsgPoolItem; class SfxBoolItem; class SvxColorItem; class SvxLeftMarginItem; @@ -425,11 +426,10 @@ 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( - 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( +inline constexpr sal_uInt16 RES_UPDATEATTR_ATTRSET_CHG( 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 29b64f43ba4b..90eb881012d8 100644 --- a/sw/inc/hints.hxx +++ b/sw/inc/hints.hxx @@ -54,6 +54,18 @@ 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. */ @@ -315,12 +327,6 @@ 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 95ef737cb486..6e667e30be2c 100644 --- a/sw/inc/ndtxt.hxx +++ b/sw/inc/ndtxt.hxx @@ -246,7 +246,6 @@ 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 90378efa5063..10d110bca664 100644 --- a/sw/inc/swevent.hxx +++ b/sw/inc/swevent.hxx @@ -131,9 +131,7 @@ struct SwCallMouseEvent final if (!GetRegisteredIn() || pChgHint->m_pOldFormat == PTR.pFormat) Clear(); } - else if (rHint.GetId() == SfxHintId::SwLegacyModify - || SfxHintId::SwAttrSetChange == rHint.GetId() - || SfxHintId::SwObjectDying == rHint.GetId()) + else if (rHint.GetId() == SfxHintId::SwLegacyModify || SfxHintId::SwAttrSetChange == 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 cf425589387a..15ed54683e14 100644 --- a/sw/inc/txtatr.hxx +++ b/sw/inc/txtatr.hxx @@ -46,7 +46,6 @@ 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 f1b99f5888d3..8673e57389b4 100644 --- a/sw/source/core/attr/BorderCacheOwner.cxx +++ b/sw/source/core/attr/BorderCacheOwner.cxx @@ -25,6 +25,7 @@ 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 89dbbb0f83f4..0351ea76b75f 100644 --- a/sw/source/core/attr/calbck.cxx +++ b/sw/source/core/attr/calbck.cxx @@ -37,12 +37,17 @@ namespace sw { return m_pToTell == nullptr || m_pToTell->GetInfo( rInfo ); } void ListenerEntry::SwClientNotify(const SwModify& rModify, const SfxHint& rHint) { - if (rHint.GetId() == SfxHintId::SwObjectDying) + if (rHint.GetId() == SfxHintId::SwLegacyModify) { - auto pDyingHint = static_cast<const sw::ObjectDyingHint*>(&rHint); - auto pModifyChanged = CheckRegistration(*pDyingHint); - if (pModifyChanged) - m_pToTell->SwClientNotify(rModify, *pModifyChanged); + 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); } else if (m_pToTell) m_pToTell->SwClientNotify(rModify, rHint); @@ -73,11 +78,16 @@ sw::ClientBase<T>::~ClientBase() } template<typename T> -std::optional<sw::ModifyChangedHint> sw::ClientBase<T>::CheckRegistration( const sw::ObjectDyingHint& rHint ) +std::optional<sw::ModifyChangedHint> sw::ClientBase<T>::CheckRegistration( const SfxPoolItem* pOld ) { DBG_TESTSOLARMUTEX(); + // this method only handles notification about dying SwModify objects + if( !pOld || pOld->Which() != RES_OBJECTDYING ) + return {}; - if(rHint.m_pDying != m_pRegisteredIn) + assert(dynamic_cast<const SwPtrMsgPoolItem*>(pOld)); + const SwPtrMsgPoolItem* pDead = static_cast<const SwPtrMsgPoolItem*>(pOld); + if(pDead->pObject != m_pRegisteredIn) { // we should only care received death notes from objects we are following return {}; @@ -113,10 +123,10 @@ void sw::ClientBase<T>::CheckRegistrationFormat(SwFormat& rOld) template<typename T> void sw::ClientBase<T>::SwClientNotify(const SwModify&, const SfxHint& rHint) { - if (rHint.GetId() != SfxHintId::SwObjectDying) + if (rHint.GetId() != SfxHintId::SwLegacyModify) return; - auto pDyingHint = static_cast<const sw::ObjectDyingHint*>(&rHint); - CheckRegistration(*pDyingHint); + auto pLegacyHint = static_cast<const sw::LegacyModifyHint*>(&rHint); + CheckRegistration(pLegacyHint->m_pOld); }; template<typename T> @@ -141,15 +151,15 @@ SwModify::~SwModify() OSL_ENSURE( !IsModifyLocked(), "Modify destroyed but locked." ); // notify all clients that they shall remove themselves - sw::ObjectDyingHint aDyObject( this ); - SwModify::SwClientNotify(*this, aDyObject); + SwPtrMsgPoolItem aDyObject( RES_OBJECTDYING, this ); + SwModify::SwClientNotify(*this, sw::LegacyModifyHint(&aDyObject, &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); } @@ -210,8 +220,7 @@ void SwModify::SwClientNotify(const SwModify&, const SfxHint& rHint) { if (rHint.GetId() != SfxHintId::SwLegacyModify && rHint.GetId() != SfxHintId::SwRemoveUnoObject - && rHint.GetId() != SfxHintId::SwAttrSetChange - && rHint.GetId() != SfxHintId::SwObjectDying) + && rHint.GetId() != SfxHintId::SwAttrSetChange) return; DBG_TESTSOLARMUTEX(); diff --git a/sw/source/core/attr/format.cxx b/sw/source/core/attr/format.cxx index 5d0da518118e..1ec609f0748d 100644 --- a/sw/source/core/attr/format.cxx +++ b/sw/source/core/attr/format.cxx @@ -264,50 +264,53 @@ 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 - SwFormat* pFormat = static_cast<SwFormat*>(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<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); - if(nWhich != 0) + switch(nWhich) { - // attribute is defined in this format - if(SfxItemState::SET == m_aSet.GetItemState(nWhich, false)) + case 0: + break; + case RES_OBJECTDYING: { - // DropCaps might come into this block - SAL_WARN_IF(RES_PARATR_DROP != nWhich, "sw.core", "Hint was sent without sender"); - oDependsHint.reset(); + // 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; } + 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 21419732e594..162185339c47 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -2917,23 +2917,21 @@ 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 && - ( nWhich == 0 || !isFormatMessage(nWhich) || nWhich == RES_UPDATE_ATTR )) + ( !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 == 0 ) + if( nWhich == RES_OBJECTDYING ) { EndListeningAll(); } diff --git a/sw/source/core/doc/acmplwrd.cxx b/sw/source/core/doc/acmplwrd.cxx index a9fffae60772..ef4b0b2595da 100644 --- a/sw/source/core/doc/acmplwrd.cxx +++ b/sw/source/core/doc/acmplwrd.cxx @@ -148,9 +148,18 @@ void SwAutoCompleteClient::Notify(const SfxHint& rHint) case SfxHintId::SwRemoveUnoObject: DocumentDying(); return; - case SfxHintId::SwObjectDying: - DocumentDying(); - return; + case SfxHintId::SwLegacyModify: + { + auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint); + switch(pLegacy->GetWhich()) + { + case RES_OBJECTDYING: + DocumentDying(); + return; + default: + return; + } + } default: return; } diff --git a/sw/source/core/doc/docftn.cxx b/sw/source/core/doc/docftn.cxx index 9e0dcbb93131..b829b051248d 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::SwObjectDying) + if (rHint.GetId() == SfxHintId::SwLegacyModify) { - auto pDyingHint = static_cast<const sw::ObjectDyingHint*>(&rHint); - CheckRegistration( *pDyingHint ); + auto pLegacyHint = static_cast<const sw::LegacyModifyHint*>(&rHint); + CheckRegistration( pLegacyHint->m_pOld ); } 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 65c00b9b61ee..cb3ad58e1277 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::SwObjectDying) + && rHint.GetId() != SfxHintId::SwAttrSetChange) 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 if (rHint.GetId() == SfxHintId::SwFormatChange) + else // 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 || rHint.GetId() == SfxHintId::SwObjectDying) + if (rHint.GetId() == SfxHintId::SwLegacyModify) { 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 if (rHint.GetId() == SfxHintId::SwFormatChange) + else // 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 70c2699ffd45..8cc455b0aa82 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::SwObjectDying) + if (rHint.GetId() == SfxHintId::SwLegacyModify) { - auto pDyingHint = static_cast<const sw::ObjectDyingHint*>(&rHint); - CheckRegistration( *pDyingHint ); + auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint); + CheckRegistration( pLegacy->m_pOld ); } 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 39b006670c7f..affd0d7388ff 100644 --- a/sw/source/core/doc/notxtfrm.cxx +++ b/sw/source/core/doc/notxtfrm.cxx @@ -820,12 +820,6 @@ 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); @@ -835,6 +829,9 @@ 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 58b2bea4f8d2..5708fdbf1cb2 100644 --- a/sw/source/core/doc/number.cxx +++ b/sw/source/core/doc/number.cxx @@ -306,8 +306,9 @@ void SwNumFormat::SwClientNotify(const SwModify&, const SfxHint& rHint) const SwCharFormat* pFormat = GetCharFormat(); if(pFormat && !pFormat->GetDoc()->IsInDtor()) UpdateNumNodes(*const_cast<SwDoc*>(pFormat->GetDoc())); + return; } - else if (rHint.GetId() == SfxHintId::SwAttrSetChange) + 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! @@ -315,12 +316,12 @@ void SwNumFormat::SwClientNotify(const SwModify&, const SfxHint& rHint) if(pFormat && !pFormat->GetDoc()->IsInDtor()) UpdateNumNodes(*const_cast<SwDoc*>(pFormat->GetDoc())); + return; } - else if (rHint.GetId() == SfxHintId::SwObjectDying) - { - auto pDyingHint = static_cast<const sw::ObjectDyingHint*>(&rHint); - CheckRegistration( *pDyingHint ); - } + if (rHint.GetId() != SfxHintId::SwLegacyModify) + return; + auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint); + CheckRegistration(pLegacy->m_pOld); } OUString SwNumFormat::GetCharFormatName() const diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx index fc2cc4fc18a7..a78d72477b45 100644 --- a/sw/source/core/docnode/node.cxx +++ b/sw/source/core/docnode/node.cxx @@ -1141,21 +1141,6 @@ 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); @@ -1164,6 +1149,22 @@ 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 62bbbd2c2ed1..9d82953715a1 100644 --- a/sw/source/core/docnode/section.cxx +++ b/sw/source/core/docnode/section.cxx @@ -403,14 +403,7 @@ 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; - } - 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) + } else if (rHint.GetId() != SfxHintId::SwLegacyModify && rHint.GetId() != SfxHintId::SwAttrSetChange) return; bool bUpdateFootnote = false; @@ -452,6 +445,10 @@ void SwSection::Notify(SfxHint const& rHint) bUpdateFootnote = true; } break; + + default: + CheckRegistration( pOld ); + break; } } else // rHint.GetId() == SfxHintId::SwAttrSetChange @@ -783,20 +780,6 @@ void SwSectionFormat::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) } SwFrameFormat::SwClientNotify(rMod, rHint); } - 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); @@ -812,6 +795,19 @@ 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 6594b0ac8ddc..63dbcae0373c 100644 --- a/sw/source/core/draw/dcontact.cxx +++ b/sw/source/core/draw/dcontact.cxx @@ -1425,9 +1425,7 @@ void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) // #i51474# GetAnchoredObj(nullptr)->ResetLayoutProcessBools(); } - else if (rHint.GetId() == SfxHintId::SwLegacyModify - || rHint.GetId() == SfxHintId::SwAttrSetChange - || rHint.GetId() == SfxHintId::SwObjectDying) + else if (rHint.GetId() == SfxHintId::SwLegacyModify || rHint.GetId() == SfxHintId::SwAttrSetChange) { SAL_WARN_IF(mbDisconnectInProgress, "sw.core", "<SwDrawContact::Modify(..)> called during disconnection."); @@ -1441,7 +1439,7 @@ void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) if (pLegacyHint->m_pOld) pOldAnchorFormat = lcl_getAnchorFormat(*pLegacyHint->m_pOld); } - else if (rHint.GetId() == SfxHintId::SwAttrSetChange) + else // rHint.GetId() == SfxHintId::SwAttrSetChange) { auto pChangeHint = static_cast<const sw::AttrSetChangeHint*>(&rHint); if (pChangeHint->m_pNew) @@ -1521,7 +1519,7 @@ void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) assert(!"<SwDraw Contact::Modify(..)> - unhandled attribute?"); } } - else if (rHint.GetId() == SfxHintId::SwAttrSetChange) + else // 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 ecb1ced273bc..5987cb3851cd 100644 --- a/sw/source/core/fields/ddetbl.cxx +++ b/sw/source/core/fields/ddetbl.cxx @@ -87,8 +87,7 @@ 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::SwObjectDying) + || rHint.GetId() == SfxHintId::SwAttrSetChange) { SwTable::SwClientNotify(rModify, rHint); } diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx index 832b5177841b..c6ce1a746922 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 || rHint.GetId() == SfxHintId::SwObjectDying) + if (rHint.GetId() == SfxHintId::SwFormatChange) { // 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 9441a86f0407..496aabffedb1 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 || rHint.GetId() == SfxHintId::SwObjectDying) + if (rHint.GetId() == SfxHintId::SwFormatChange) { // 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 086408816781..d67d2e5a4d43 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -770,10 +770,14 @@ void SwFormatPageDesc::SwClientNotify(const SwModify&, const SfxHint& rHint) // there could be an Undo-copy RegisterToPageDesc(*pDesc); } - else if (rHint.GetId() == SfxHintId::SwObjectDying) + else if (rHint.GetId() == SfxHintId::SwLegacyModify) { - m_pDefinedIn = nullptr; - EndListeningAll(); + auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint); + if(RES_OBJECTDYING == pLegacy->GetWhich()) + { + m_pDefinedIn = nullptr; + EndListeningAll(); + } } } @@ -2761,11 +2765,6 @@ 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 673522376a3e..712ee61884c0 100644 --- a/sw/source/core/layout/flyincnt.cxx +++ b/sw/source/core/layout/flyincnt.cxx @@ -139,13 +139,6 @@ 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 0dcad35ee79a..51e5a2b87387 100644 --- a/sw/source/core/layout/flylay.cxx +++ b/sw/source/core/layout/flylay.cxx @@ -751,11 +751,6 @@ 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 8b2d48f7305f..24b4e8d40fa7 100644 --- a/sw/source/core/layout/pagedesc.cxx +++ b/sw/source/core/layout/pagedesc.cxx @@ -295,10 +295,6 @@ 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 54db69c2e281..24225b332ef0 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 || rHint.GetId() == SfxHintId::SwObjectDying) + else if (rHint.GetId() == SfxHintId::SwFormatChange) { SwLayoutFrame::SwClientNotify(rMod, rHint); } diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index b5e9218ff842..6c2484fa4f90 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -342,24 +342,25 @@ 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(); - if (nWhich == RES_FRM_SIZE) + const SwFormatFrameSize* pNewSize = nullptr, *pOldSize = nullptr; + switch(nWhich) { - 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()); + 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); } + if (pOldSize && pNewSize && !m_bModifyLocked) + AdjustWidths(pOldSize->GetWidth(), pNewSize->GetWidth()); } } @@ -2754,14 +2755,10 @@ SwTableBox* SwTableBoxFormat::SwTableBoxFormat::GetTableBox() // for detection of modifications (mainly TableBoxAttribute) void SwTableBoxFormat::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) { - if(rHint.GetId() == SfxHintId::SwFormatChange || rHint.GetId() == SfxHintId::SwObjectDying) - { - SwFrameFormat::SwClientNotify(rMod, rHint); - return; - } - if(rHint.GetId() != SfxHintId::SwLegacyModify && rHint.GetId() != SfxHintId::SwAttrSetChange) + if(rHint.GetId() != SfxHintId::SwLegacyModify && rHint.GetId() != SfxHintId::SwFormatChange + && rHint.GetId() != SfxHintId::SwAttrSetChange) return; - if(IsModifyLocked() || !GetDoc() || GetDoc()->IsInDtor()) + if(IsModifyLocked() || !GetDoc() || GetDoc()->IsInDtor() || rHint.GetId() == SfxHintId::SwFormatChange) { SwFrameFormat::SwClientNotify(rMod, rHint); return; diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx index 4a3cfaf5624e..f351d2047a7e 100644 --- a/sw/source/core/text/txtfrm.cxx +++ b/sw/source/core/text/txtfrm.cxx @@ -2711,8 +2711,6 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint) } #endif } - else if (rHint.GetId() == SfxHintId::SwObjectDying) - ; // do nothing else switch (nWhich) { case RES_LINENUMBER: @@ -2763,6 +2761,8 @@ 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 47259ab9b8e8..10111d661383 100644 --- a/sw/source/core/txtnode/atrfld.cxx +++ b/sw/source/core/txtnode/atrfld.cxx @@ -255,8 +255,7 @@ 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::SwObjectDying) + || rHint.GetId() == SfxHintId::SwAttrSetChange) { if(!mpTextField) return; @@ -465,10 +464,6 @@ 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); @@ -483,6 +478,10 @@ 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 78195ba7a8ab..d452b726615d 100644 --- a/sw/source/core/txtnode/attrcontentcontrol.cxx +++ b/sw/source/core/txtnode/attrcontentcontrol.cxx @@ -272,8 +272,7 @@ 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::SwObjectDying) + || rHint.GetId() == SfxHintId::SwAttrSetChange) { CallSwClientNotify(rHint); GetNotifier().Broadcast(SfxHint(SfxHintId::DataChanged)); diff --git a/sw/source/core/txtnode/attrlinebreak.cxx b/sw/source/core/txtnode/attrlinebreak.cxx index 240027a39442..5ba26c5f4cf8 100644 --- a/sw/source/core/txtnode/attrlinebreak.cxx +++ b/sw/source/core/txtnode/attrlinebreak.cxx @@ -67,8 +67,7 @@ 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::SwObjectDying) + || rHint.GetId() == SfxHintId::SwAttrSetChange) CallSwClientNotify(rHint); } diff --git a/sw/source/core/txtnode/fmtatr2.cxx b/sw/source/core/txtnode/fmtatr2.cxx index 75704a8f1a33..6e9eead823ab 100644 --- a/sw/source/core/txtnode/fmtatr2.cxx +++ b/sw/source/core/txtnode/fmtatr2.cxx @@ -108,12 +108,6 @@ 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); @@ -746,8 +740,7 @@ 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::SwObjectDying) + || rHint.GetId() == SfxHintId::SwAttrSetChange) { CallSwClientNotify(rHint); GetNotifier().Broadcast(SfxHint(SfxHintId::DataChanged)); diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 9650fb75212f..87904fe92abc 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -5558,20 +5558,6 @@ 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; @@ -5683,11 +5669,6 @@ 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 cb8c20476acb..e571694fe198 100644 --- a/sw/source/core/txtnode/txtatr2.cxx +++ b/sw/source/core/txtnode/txtatr2.cxx @@ -75,7 +75,8 @@ SwTextCharFormat::~SwTextCharFormat( ) void SwTextCharFormat::TriggerNodeUpdate(const sw::LegacyModifyHint& rHint) { const auto nWhich = rHint.GetWhich(); - assert( isCHRATR(nWhich) && "SwTextCharFormat::TriggerNodeUpdate: unknown hint type"); + assert( (isCHRATR(nWhich) || + RES_OBJECTDYING == nWhich) && "SwTextCharFormat::TriggerNodeUpdate: unknown hint type"); if(m_pTextNode) { @@ -87,18 +88,6 @@ 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) @@ -227,18 +216,11 @@ 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) && "SwTextINetFormat::SwClientNotify: unknown hint."); + assert((isCHRATR(nWhich) || (RES_OBJECTDYING == nWhich)) && "SwTextINetFormat::SwClientNotify: unknown hint."); if(!m_pTextNode) return; const SwUpdateAttr aUpdateAttr(GetStart(), *GetEnd(), nWhich); @@ -286,18 +268,12 @@ 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) && "SwTextRuby::SwClientNotify(): unknown legacy hint"); + assert( (isCHRATR(nWhich) + || (RES_OBJECTDYING == 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 8e00da622fa6..5a7db042029d 100644 --- a/sw/source/core/undo/unattr.cxx +++ b/sw/source/core/undo/unattr.cxx @@ -87,15 +87,12 @@ 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 7b7a34d2aad2..0245e793c5fb 100644 --- a/sw/source/core/unocore/unochart.cxx +++ b/sw/source/core/unocore/unochart.cxx @@ -2150,10 +2150,8 @@ 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 - || rHint.GetId() == SfxHintId::SwObjectDying) + else if (rHint.GetId() == SfxHintId::SwLegacyModify || rHint.GetId() == SfxHintId::SwFormatChange + || rHint.GetId() == SfxHintId::SwAttrSetChange) { setModified( true ); } diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index afbaf1e48867..d87978919c06 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -2646,8 +2646,16 @@ void SwXTextField::Impl::Notify(const SfxHint& rHint) if(rHint.GetId() == SfxHintId::Dying) Invalidate(); - else if (rHint.GetId() == SfxHintId::SwObjectDying) - 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; + } + } } const SwField* SwXTextField::Impl::GetField() const diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index eb8515732370..3bbc855ae35e 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -4764,12 +4764,14 @@ TextNodeListener::~TextNodeListener() void TextNodeListener::SwClientNotify(const SwModify& rModify, const SfxHint& rHint) { - if (rHint.GetId() != SfxHintId::SwObjectDying) + if (rHint.GetId() != SfxHintId::SwLegacyModify) 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. - removed(const_cast<SwModify*>(&rModify)); + if (pLegacy->GetWhich() == RES_OBJECTDYING) + 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 fe1b5e58042d..b27de07e9e50 100644 --- a/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx +++ b/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx @@ -87,8 +87,12 @@ WriterInspectorTextPanel::WriterInspectorTextPanel(weld::Widget* pParent) void WriterInspectorTextPanel::SwClientNotify(const SwModify& rModify, const SfxHint& rHint) { - if (rHint.GetId() == SfxHintId::SwObjectDying) - m_pShell = nullptr; + if (rHint.GetId() == SfxHintId::SwLegacyModify) + { + const sw::LegacyModifyHint& rLegacy = static_cast<const sw::LegacyModifyHint&>(rHint); + if (rLegacy.GetWhich() == RES_OBJECTDYING) + m_pShell = nullptr; + } SwClient::SwClientNotify(rModify, rHint); } commit 0c966d6f6d455d8a05de541b0ac258ecc5bef3d8 Author: Stephan Bergmann <stephan.bergm...@allotropia.de> AuthorDate: Wed Jan 8 09:07:19 2025 +0100 Commit: Stephan Bergmann <stephan.bergm...@allotropia.de> CommitDate: Wed Jan 8 12:48:25 2025 +0100 Revert "fix ubsan failure" This reverts commit bbb53997c3a6890567ee991aed8502b397dcb7a6. Reason for revert: It conflicts with a revert of cc56bf56e170492e414a975ad8c07c41ed72e1a4 "convert RES_OBJECTDYING to SfxHint", which in turn is known broken and thus needs to be reverted for now (see comment at <https://gerrit.libreoffice.org/c/core/+/179781/6#message-65721cd380de7681cd9ade644da755e6549e23f7> "convert RES_OBJECTDYING to SfxHint") Change-Id: I8212d8ca609b45a4d9399e492727b364fa0a7b50 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179940 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de> diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx index b78c08ce8143..62bbbd2c2ed1 100644 --- a/sw/source/core/docnode/section.cxx +++ b/sw/source/core/docnode/section.cxx @@ -713,12 +713,14 @@ void SwSectionFormat::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) if(!pSect || rSectionHidden.m_isHidden == pSect->IsHiddenFlag()) // already at target state, skipping. return; GetNotifier().Broadcast(rSectionHidden); + return; } else if(SfxHintId::SwRemoveUnoObject == rHint.GetId()) { SwFrameFormat::SwClientNotify(rMod, rHint); // invalidate cached uno object SetXTextSection(nullptr); + return; } else if (rHint.GetId() == SfxHintId::SwFormatChange) { @@ -733,6 +735,7 @@ void SwSectionFormat::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) return; } SwFrameFormat::SwClientNotify(rMod, rHint); + return; } else if (rHint.GetId() == SfxHintId::SwAttrSetChange) { @@ -794,24 +797,23 @@ void SwSectionFormat::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) } SwFrameFormat::SwClientNotify(rMod, rHint); } - else if (rHint.GetId() == SfxHintId::SwLegacyModify) + else if (rHint.GetId() != SfxHintId::SwLegacyModify) + return; + auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint); + sal_uInt16 nWhich = pLegacy->GetWhich(); + auto pOld = pLegacy->m_pOld; + auto pNew = pLegacy->m_pNew; + switch( nWhich ) { - auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint); - sal_uInt16 nWhich = pLegacy->GetWhich(); - auto pOld = pLegacy->m_pOld; - auto pNew = pLegacy->m_pNew; - switch( nWhich ) - { - case RES_FTN_AT_TXTEND: - case RES_END_AT_TXTEND: - case RES_PROTECT: - case RES_EDIT_IN_READONLY: // edit in readonly sections - // Pass through these Messages until the End of the tree! - GetNotifier().Broadcast(sw::LegacyModifyHint(pOld, pNew)); - return; // That's it! - } - SwFrameFormat::SwClientNotify(rMod, rHint); + case RES_FTN_AT_TXTEND: + case RES_END_AT_TXTEND: + case RES_PROTECT: + case RES_EDIT_IN_READONLY: // edit in readonly sections + // Pass through these Messages until the End of the tree! + GetNotifier().Broadcast(sw::LegacyModifyHint(pOld, pNew)); + return; // That's it! } + SwFrameFormat::SwClientNotify(rMod, rHint); } void SwSectionFormat::SetXTextSection(rtl::Reference<SwXTextSection> const& xTextSection)