include/svl/hint.hxx | 1 + sw/inc/fmtftn.hxx | 4 +--- sw/inc/fmtrfmrk.hxx | 7 +------ sw/inc/hintids.hxx | 1 - sw/inc/hints.hxx | 6 ++++++ sw/inc/ndtxt.hxx | 2 ++ sw/inc/swevent.hxx | 10 ++++++++-- sw/source/core/attr/calbck.cxx | 2 +- sw/source/core/attr/format.cxx | 9 +++++++-- sw/source/core/crsr/bookmark.cxx | 8 ++------ sw/source/core/doc/acmplwrd.cxx | 4 +++- sw/source/core/docnode/section.cxx | 15 +++++++++------ sw/source/core/draw/dcontact.cxx | 10 +++++++--- sw/source/core/inc/unofootnote.hxx | 3 +++ sw/source/core/inc/unorefmark.hxx | 2 ++ sw/source/core/layout/atrfrm.cxx | 11 +++++++---- sw/source/core/tox/tox.cxx | 13 +++++++------ sw/source/core/txtnode/atrfld.cxx | 17 ++++++++--------- sw/source/core/txtnode/atrftn.cxx | 19 +++++-------------- sw/source/core/txtnode/atrref.cxx | 20 +++++--------------- sw/source/core/txtnode/attrcontentcontrol.cxx | 17 +++++++++-------- sw/source/core/txtnode/attrlinebreak.cxx | 11 ++++++----- sw/source/core/txtnode/fmtatr2.cxx | 15 +++++++++------ sw/source/core/txtnode/ndtxt.cxx | 19 ++++++++++++++++--- sw/source/core/unocore/unofield.cxx | 3 ++- sw/source/core/unocore/unoftn.cxx | 11 ++++++++--- sw/source/core/unocore/unoidx.cxx | 8 ++------ sw/source/core/unocore/unorefmk.cxx | 14 +++----------- sw/source/filter/html/swhtml.hxx | 2 +- sw/source/filter/ww8/ww8par2.cxx | 2 +- 30 files changed, 142 insertions(+), 124 deletions(-)
New commits: commit 7fbfd4e304cc7a72f81f224ba2fd0dbdc38fe07c Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Fri Dec 27 18:56:48 2024 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Mon Feb 10 11:28:42 2025 +0100 Simplify SwFormatFootnote/SwXFootnote interaction No need to use listeners here, both sides hold a pointer to a concrete class. And we only need to deal with destruction in one direction, because the other direction uses a weak reference. Change-Id: I2b1e05bcebbb7ff8b62ac1874edc91557dd6951f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179476 Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Tested-by: Jenkins Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181264 diff --git a/sw/inc/fmtftn.hxx b/sw/inc/fmtftn.hxx index 96742789d89a..689fca574af0 100644 --- a/sw/inc/fmtftn.hxx +++ b/sw/inc/fmtftn.hxx @@ -44,7 +44,7 @@ class SwXTextRange; /// for the footnote content is defined by m_pTextAttr. class SW_DLLPUBLIC SwFormatFootnote final : public SfxPoolItem - , public sw::BroadcastingModify + , public SvtBroadcaster { friend class SwTextFootnote; SwTextFootnote* m_pTextAttr; ///< My TextAttribute. @@ -66,8 +66,6 @@ public: virtual bool operator==( const SfxPoolItem& ) const override; virtual SwFormatFootnote* Clone( SfxItemPool* pPool = nullptr ) const override; - virtual void SwClientNotify(const SwModify&, const SfxHint&) override; - void InvalidateFootnote(); const OUString& GetNumStr() const { return m_aNumber; } diff --git a/sw/source/core/inc/unofootnote.hxx b/sw/source/core/inc/unofootnote.hxx index dd12ff058e29..03acbc6cacc1 100644 --- a/sw/source/core/inc/unofootnote.hxx +++ b/sw/source/core/inc/unofootnote.hxx @@ -130,6 +130,9 @@ public: virtual rtl::Reference< SwXTextCursor > createXTextCursor() override; virtual rtl::Reference< SwXTextCursor > createXTextCursorByRange( const ::css::uno::Reference< ::css::text::XTextRange >& aTextPosition ) override; + + void OnFormatFootnoteDeleted(); + private: rtl::Reference< SwXTextCursor > createXTextCursorByRangeImpl(SwUnoInternalPaM& rPam); }; diff --git a/sw/source/core/txtnode/atrftn.cxx b/sw/source/core/txtnode/atrftn.cxx index a63bde260b1d..ef2130fd1686 100644 --- a/sw/source/core/txtnode/atrftn.cxx +++ b/sw/source/core/txtnode/atrftn.cxx @@ -125,7 +125,6 @@ namespace { SwFormatFootnote::SwFormatFootnote( bool bEndNote ) : SfxPoolItem( RES_TXTATR_FTN, SfxItemType::SwFormatFootnoteType ) - , sw::BroadcastingModify() , m_pTextAttr(nullptr) , m_nNumber(0) , m_nNumberRLHidden(0) @@ -156,22 +155,13 @@ SwFormatFootnote* SwFormatFootnote::Clone( SfxItemPool* ) const return pNew; } -void SwFormatFootnote::SwClientNotify(const SwModify&, const SfxHint& rHint) +void SwFormatFootnote::InvalidateFootnote() { - if(SfxHintId::SwRemoveUnoObject == rHint.GetId()) + if (auto xUnoFootnote = m_wXFootnote.get()) { - CallSwClientNotify(rHint); - SetXFootnote(nullptr); - return; + xUnoFootnote->OnFormatFootnoteDeleted(); + m_wXFootnote.clear(); } - if (rHint.GetId() != SfxHintId::SwLegacyModify) - return; - CallSwClientNotify(rHint); -} - -void SwFormatFootnote::InvalidateFootnote() -{ - CallSwClientNotify(sw::RemoveUnoObjectHint(this)); } void SwFormatFootnote::SetEndNote( bool b ) diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx index c3f175d77681..bbfa61e62a63 100644 --- a/sw/source/core/unocore/unoftn.cxx +++ b/sw/source/core/unocore/unoftn.cxx @@ -80,7 +80,8 @@ public: , m_bIsDescriptor(nullptr == pFootnote) , m_pFormatFootnote(pFootnote) { - m_pFormatFootnote && StartListening(m_pFormatFootnote->GetNotifier()); + if (m_pFormatFootnote) + StartListening(*m_pFormatFootnote); } const SwFormatFootnote* GetFootnoteFormat() const { @@ -98,7 +99,6 @@ public: void Invalidate(); protected: void Notify(const SfxHint& rHint) override; - }; void SwXFootnote::Impl::Invalidate() @@ -122,6 +122,11 @@ void SwXFootnote::Impl::Notify(const SfxHint& rHint) Invalidate(); } +void SwXFootnote::OnFormatFootnoteDeleted() +{ + Invalidate(); +} + SwXFootnote::SwXFootnote(const bool bEndnote) : SwXText(nullptr, CursorType::Footnote) , m_pImpl( new SwXFootnote::Impl(*this, nullptr, bEndnote) ) @@ -319,7 +324,7 @@ SwXFootnote::attach(const uno::Reference< text::XTextRange > & xTextRange) m_pImpl->EndListeningAll(); SwFormatFootnote* pFootnote = const_cast<SwFormatFootnote*>(&pTextAttr->GetFootnote()); m_pImpl->m_pFormatFootnote = pFootnote; - m_pImpl->StartListening(pFootnote->GetNotifier()); + m_pImpl->StartListening(*pFootnote); // force creation of sequence id - is used for references if (pNewDoc->IsInReading()) { diff --git a/sw/source/filter/html/swhtml.hxx b/sw/source/filter/html/swhtml.hxx index 1f50803633dc..11e0fbfebc94 100644 --- a/sw/source/filter/html/swhtml.hxx +++ b/sw/source/filter/html/swhtml.hxx @@ -1041,7 +1041,7 @@ public: SwHTMLTextFootnote(OUString rName, SwTextFootnote* pInTextFootnote) : m_sName(std::move(rName)) , m_pTextFootnote(pInTextFootnote) - , m_xDeleteListener(new SvtDeleteListener(static_cast<SwFormatFootnote&>(pInTextFootnote->GetAttr()).GetNotifier())) + , m_xDeleteListener(new SvtDeleteListener(static_cast<SwFormatFootnote&>(pInTextFootnote->GetAttr()))) { } const OUString& GetName() const diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx index 246f56ad9b84..86ac1f91a202 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -251,7 +251,7 @@ sal_uInt16 SwWW8ImplReader::End_Footnote() SwFormatFootnote& rFormatFootnote = static_cast<SwFormatFootnote&>(pFN->GetAttr()); - SvtDeleteListener aDeleteListener(rFormatFootnote.GetNotifier()); + SvtDeleteListener aDeleteListener(rFormatFootnote); // read content of Ft-/End-Note Read_HdFtFootnoteText( pSttIdx, rDesc.mnStartCp, rDesc.mnLen, rDesc.meType); commit 4b54de728fd6fa19f3575f264418224a3b8cda51 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Fri Dec 27 18:45:30 2024 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Mon Feb 10 11:28:36 2025 +0100 Simplify SwFormatRefMark/SwXReferenceMark interaction No need to use listeners here, both sides hold a pointer to a concrete class. And we only need to deal with destruction in one direction, because the other direction uses a weak reference. Change-Id: Ie3a062d21f7215867ada5a9bacf1b00f0ce119f1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179474 Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Tested-by: Jenkins Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181263 diff --git a/sw/inc/fmtrfmrk.hxx b/sw/inc/fmtrfmrk.hxx index b41449fa97af..8b44a19d162a 100644 --- a/sw/inc/fmtrfmrk.hxx +++ b/sw/inc/fmtrfmrk.hxx @@ -37,9 +37,7 @@ class SwXReferenceMark; /// SwTextRefMark. /// /// It's Insert -> Cross-reference -> Cross-references -> set reference on the UI. -class SAL_DLLPUBLIC_RTTI SwFormatRefMark final - : public SfxPoolItem - , public sw::BroadcastingModify +class SAL_DLLPUBLIC_RTTI SwFormatRefMark final : public SfxPoolItem { friend class SwTextRefMark; SwTextRefMark* m_pTextAttr; @@ -58,9 +56,6 @@ public: virtual bool operator==( const SfxPoolItem& ) const override; virtual SwFormatRefMark* Clone( SfxItemPool* pPool = nullptr ) const override; - // SwClient - virtual void SwClientNotify(const SwModify&, const SfxHint&) override; - void InvalidateRefMark(); const SwTextRefMark *GetTextRefMark() const { return m_pTextAttr; } diff --git a/sw/source/core/inc/unorefmark.hxx b/sw/source/core/inc/unorefmark.hxx index 1d4ad9acec04..735350bb5c20 100644 --- a/sw/source/core/inc/unorefmark.hxx +++ b/sw/source/core/inc/unorefmark.hxx @@ -100,6 +100,8 @@ public: const css::uno::Reference< css::text::XTextRange > & xTextRange) override; virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override; + void OnFormatRefMarkDeleted(); + }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/txtnode/atrref.cxx b/sw/source/core/txtnode/atrref.cxx index 87fdaf818637..038374ae4097 100644 --- a/sw/source/core/txtnode/atrref.cxx +++ b/sw/source/core/txtnode/atrref.cxx @@ -42,7 +42,6 @@ SwFormatRefMark::~SwFormatRefMark( ) SwFormatRefMark::SwFormatRefMark( OUString aName ) : SfxPoolItem(RES_TXTATR_REFMARK, SfxItemType::SwFormatRefMarkType) - , sw::BroadcastingModify() , m_pTextAttr(nullptr) , m_aRefName(std::move(aName)) { @@ -51,7 +50,6 @@ SwFormatRefMark::SwFormatRefMark( OUString aName ) SwFormatRefMark::SwFormatRefMark( const SwFormatRefMark& rAttr ) : SfxPoolItem(RES_TXTATR_REFMARK, SfxItemType::SwFormatRefMarkType) - , sw::BroadcastingModify() , m_pTextAttr(nullptr) , m_aRefName(rAttr.m_aRefName) { @@ -72,22 +70,13 @@ SwFormatRefMark* SwFormatRefMark::Clone( SfxItemPool* ) const return new SwFormatRefMark( *this ); } -void SwFormatRefMark::SwClientNotify(const SwModify&, const SfxHint& rHint) +void SwFormatRefMark::InvalidateRefMark() { - if(SfxHintId::SwRemoveUnoObject == rHint.GetId()) + if (auto xUnoRefMark = m_wXReferenceMark.get()) { - CallSwClientNotify(rHint); - SetXRefMark(nullptr); - return; + xUnoRefMark->OnFormatRefMarkDeleted(); + m_wXReferenceMark.clear(); } - if (rHint.GetId() != SfxHintId::SwLegacyModify) - return; - CallSwClientNotify(rHint); -} - -void SwFormatRefMark::InvalidateRefMark() -{ - CallSwClientNotify(sw::RemoveUnoObjectHint(this)); } void SwFormatRefMark::dumpAsXml(xmlTextWriterPtr pWriter) const diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index ac167a11e5fc..a393d69e00f3 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -60,7 +60,6 @@ using namespace ::com::sun::star; class SwXReferenceMark::Impl - : public SvtListener { public: unotools::WeakReference<SwXReferenceMark> m_wThis; @@ -78,7 +77,6 @@ public: { if (pRefMark) { - StartListening(pRefMark->GetNotifier()); m_sMarkName = pRefMark->GetRefName(); } } @@ -86,14 +84,10 @@ public: bool IsValid() const { return m_pMarkFormat; } void InsertRefMark( SwPaM & rPam, SwXTextCursor const*const pCursor ); void Invalidate(); -protected: - virtual void Notify(const SfxHint&) override; - }; void SwXReferenceMark::Impl::Invalidate() { - EndListeningAll(); m_pDoc = nullptr; m_pMarkFormat = nullptr; uno::Reference<uno::XInterface> const xThis(m_wThis); @@ -106,10 +100,9 @@ void SwXReferenceMark::Impl::Invalidate() m_EventListeners.disposeAndClear(aGuard, ev); } -void SwXReferenceMark::Impl::Notify(const SfxHint& rHint) +void SwXReferenceMark::OnFormatRefMarkDeleted() { - if(rHint.GetId() == SfxHintId::Dying) - Invalidate(); + m_pImpl->Invalidate(); } SwXReferenceMark::SwXReferenceMark( @@ -245,8 +238,7 @@ void SwXReferenceMark::Impl::InsertRefMark(SwPaM& rPam, } m_pMarkFormat = &pTextAttr->GetRefMark(); - EndListeningAll(); - StartListening(const_cast<SwFormatRefMark*>(m_pMarkFormat)->GetNotifier()); + const_cast<SwFormatRefMark*>(m_pMarkFormat)->SetXRefMark(m_wThis.get()); } void SAL_CALL commit a041c7a6e2d910ab750e8540d8c5ad49cd4c2468 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Mon Dec 23 13:46:20 2024 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Mon Feb 10 11:28:29 2025 +0100 move RES_REMOVE_UNO_OBJECT to SfxHint Change-Id: I82936e0ddb685746a714e1929fc7682a68ef4d09 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179240 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181262 diff --git a/include/svl/hint.hxx b/include/svl/hint.hxx index 7a55b0f9de03..76749341f41b 100644 --- a/include/svl/hint.hxx +++ b/include/svl/hint.hxx @@ -229,6 +229,7 @@ enum class SfxHintId { SwGrfRereadAndInCache, SwFindUnoTextTableRowInstance, SwFindUnoCellInstance, + SwRemoveUnoObject, ThisIsAnSdrHint, ThisIsAnSfxEventHint diff --git a/sw/inc/hintids.hxx b/sw/inc/hintids.hxx index 546ef7019c08..dd231fa41392 100644 --- a/sw/inc/hintids.hxx +++ b/sw/inc/hintids.hxx @@ -432,7 +432,6 @@ inline constexpr TypedWhichId<SwFormatChg> RES_FMT_CHG(168); inline constexpr TypedWhichId<SwAttrSetChg> RES_ATTRSET_CHG(169); inline constexpr TypedWhichId<SwUpdateAttr> RES_UPDATE_ATTR(170); inline constexpr TypedWhichId<SwMsgPoolItem> RES_HIDDENPARA_PRINT(178); -inline constexpr TypedWhichId<SwPtrMsgPoolItem> RES_REMOVE_UNO_OBJECT(181); // empty inline constexpr sal_uInt16 RES_FORMAT_MSG_END(190); diff --git a/sw/inc/hints.hxx b/sw/inc/hints.hxx index 11589fb827ba..b38ccae0089e 100644 --- a/sw/inc/hints.hxx +++ b/sw/inc/hints.hxx @@ -310,6 +310,12 @@ public: void SetUsed() const { m_isUsed = true; } void CheckNode(const SwNode*) const; }; +class RemoveUnoObjectHint final : public SfxHint +{ +public: + const BroadcastingModify* m_pObject; + RemoveUnoObjectHint(const BroadcastingModify* pObject) : SfxHint(SfxHintId::SwRemoveUnoObject), m_pObject(pObject) {} +}; } class SwUpdateAttr final : public SwMsgPoolItem diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx index 174a88e74c53..47ecca334642 100644 --- a/sw/inc/ndtxt.hxx +++ b/sw/inc/ndtxt.hxx @@ -71,6 +71,7 @@ class SwField; namespace sw { class TextNodeNotificationSuppressor; + class RemoveUnoObjectHint; namespace mark { enum class RestoreMode; } } @@ -241,6 +242,7 @@ public: void UpdateDocPos(const SwTwips nDocPos, const sal_uInt32 nIndex); /// for hanging TextFormatCollections somewhere else (Outline-Numbering!) void TriggerNodeUpdate(const sw::LegacyModifyHint&); + void TriggerNodeUpdate(const sw::RemoveUnoObjectHint&); const OUString& GetText() const { return m_Text; } diff --git a/sw/inc/swevent.hxx b/sw/inc/swevent.hxx index 11e33ef3ef93..f011b8cc64ea 100644 --- a/sw/inc/swevent.hxx +++ b/sw/inc/swevent.hxx @@ -116,6 +116,14 @@ struct SwCallMouseEvent final virtual void SwClientNotify(const SwModify& rMod, const SfxHint& rHint) override { + if(SfxHintId::SwRemoveUnoObject == rHint.GetId()) + { + assert(EVENT_OBJECT_IMAGE == eType || EVENT_OBJECT_URLITEM == eType || EVENT_OBJECT_IMAGEMAP == eType); + SwClient::SwClientNotify(rMod, rHint); + if (!GetRegisteredIn() || static_cast<const sw::RemoveUnoObjectHint&>(rHint).m_pObject == PTR.pFormat) + Clear(); + return; + } if (rHint.GetId() != SfxHintId::SwLegacyModify) return; auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint); @@ -127,8 +135,6 @@ struct SwCallMouseEvent final case RES_FMT_CHG: bClear |= pLegacy->m_pOld->StaticWhichCast(RES_FMT_CHG).pChangedFormat == PTR.pFormat; break; - case RES_REMOVE_UNO_OBJECT: - bClear |= pLegacy->m_pOld->StaticWhichCast(RES_REMOVE_UNO_OBJECT).pObject == PTR.pFormat; } if(bClear) Clear(); diff --git a/sw/source/core/attr/calbck.cxx b/sw/source/core/attr/calbck.cxx index 6bd48c17d794..58a075ba6dff 100644 --- a/sw/source/core/attr/calbck.cxx +++ b/sw/source/core/attr/calbck.cxx @@ -291,7 +291,7 @@ sw::ClientIteratorBase* sw::ClientIteratorBase::s_pClientIters = nullptr; void SwModify::SwClientNotify(const SwModify&, const SfxHint& rHint) { - if (rHint.GetId() != SfxHintId::SwLegacyModify) + if (rHint.GetId() != SfxHintId::SwLegacyModify && rHint.GetId() != SfxHintId::SwRemoveUnoObject) return; DBG_TESTSOLARMUTEX(); diff --git a/sw/source/core/attr/format.cxx b/sw/source/core/attr/format.cxx index 019524a0689f..86cb2b484ad4 100644 --- a/sw/source/core/attr/format.cxx +++ b/sw/source/core/attr/format.cxx @@ -209,6 +209,11 @@ SwFormat::~SwFormat() void SwFormat::SwClientNotify(const SwModify&, const SfxHint& rHint) { + if (rHint.GetId() == SfxHintId::SwRemoveUnoObject) + { + SwModify::SwClientNotify(*this, rHint); + return; + } if (rHint.GetId() != SfxHintId::SwLegacyModify) return; auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint); @@ -743,8 +748,8 @@ drawinglayer::attribute::SdrAllFillAttributesHelperPtr SwFormat::getSdrAllFillAt void SwFormat::RemoveAllUnos() { - SwPtrMsgPoolItem aMsgHint(RES_REMOVE_UNO_OBJECT, this); - SwClientNotify(*this, sw::LegacyModifyHint(&aMsgHint, &aMsgHint)); + sw::RemoveUnoObjectHint aMsgHint(this); + SwClientNotify(*this, aMsgHint); } bool SwFormat::IsUsed() const diff --git a/sw/source/core/crsr/bookmark.cxx b/sw/source/core/crsr/bookmark.cxx index dfdff72931b6..5e62e948db5e 100644 --- a/sw/source/core/crsr/bookmark.cxx +++ b/sw/source/core/crsr/bookmark.cxx @@ -361,13 +361,9 @@ namespace sw::mark void MarkBase::SwClientNotify(const SwModify&, const SfxHint& rHint) { CallSwClientNotify(rHint); - if (rHint.GetId() != SfxHintId::SwLegacyModify) - return; - auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint); - if(RES_REMOVE_UNO_OBJECT == pLegacy->GetWhich()) - { // invalidate cached uno object + if(SfxHintId::SwRemoveUnoObject == rHint.GetId()) + // invalidate cached uno object SetXBookmark(nullptr); - } } auto MarkBase::InvalidateFrames() -> void diff --git a/sw/source/core/doc/acmplwrd.cxx b/sw/source/core/doc/acmplwrd.cxx index 09ce4abf4ad3..ef4b0b2595da 100644 --- a/sw/source/core/doc/acmplwrd.cxx +++ b/sw/source/core/doc/acmplwrd.cxx @@ -145,12 +145,14 @@ void SwAutoCompleteClient::Notify(const SfxHint& rHint) case SfxHintId::Dying: DocumentDying(); return; + case SfxHintId::SwRemoveUnoObject: + DocumentDying(); + return; case SfxHintId::SwLegacyModify: { auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint); switch(pLegacy->GetWhich()) { - case RES_REMOVE_UNO_OBJECT: case RES_OBJECTDYING: DocumentDying(); return; diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx index 4b38e8fa258a..99003c772dca 100644 --- a/sw/source/core/docnode/section.cxx +++ b/sw/source/core/docnode/section.cxx @@ -712,7 +712,15 @@ void SwSectionFormat::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) return; GetNotifier().Broadcast(rSectionHidden); return; - } else if (rHint.GetId() != SfxHintId::SwLegacyModify) + } + else if(SfxHintId::SwRemoveUnoObject == rHint.GetId()) + { + SwFrameFormat::SwClientNotify(rMod, rHint); + // invalidate cached uno object + SetXTextSection(nullptr); + return; + } + else if (rHint.GetId() != SfxHintId::SwLegacyModify) return; auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint); sal_uInt16 nWhich = pLegacy->GetWhich(); @@ -795,11 +803,6 @@ void SwSectionFormat::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) break; } SwFrameFormat::SwClientNotify(rMod, rHint); - - if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which())) - { // invalidate cached uno object - SetXTextSection(nullptr); - } } void SwSectionFormat::SetXTextSection(rtl::Reference<SwXTextSection> const& xTextSection) diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx index 73393ea67e50..ce34c1ad9338 100644 --- a/sw/source/core/draw/dcontact.cxx +++ b/sw/source/core/draw/dcontact.cxx @@ -1415,7 +1415,13 @@ void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) { SwClient::SwClientNotify(rMod, rHint); // needed as SwContact::SwClientNotify doesn't explicitly call SwClient::SwClientNotify SwContact::SwClientNotify(rMod, rHint); - if (rHint.GetId() == SfxHintId::SwLegacyModify) + if(SfxHintId::SwRemoveUnoObject == rHint.GetId()) + { + // nothing to do + // #i51474# + GetAnchoredObj(nullptr)->ResetLayoutProcessBools(); + } + else if (rHint.GetId() == SfxHintId::SwLegacyModify) { auto pLegacyHint = static_cast<const sw::LegacyModifyHint*>(&rHint); SAL_WARN_IF(mbDisconnectInProgress, "sw.core", "<SwDrawContact::Modify(..)> called during disconnection."); @@ -1464,8 +1470,6 @@ void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) else DisconnectFromLayout(); } - else if (nWhich == RES_REMOVE_UNO_OBJECT) - {} // nothing to do // --> #i62875# - no further notification, if not connected to Writer layout else if ( maAnchoredDrawObj.GetAnchorFrame() && maAnchoredDrawObj.GetDrawObj()->GetUserCall() ) diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index 7a68cda9d3b2..0caff1dd2bb9 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -2749,7 +2749,13 @@ bool SwFrameFormat::supportsFullDrawingLayerFillAttributeSet() const void SwFrameFormat::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) { - if (rHint.GetId() != SfxHintId::SwLegacyModify) + if(SfxHintId::SwRemoveUnoObject == rHint.GetId()) + { + SetXObject(nullptr); + SwFormat::SwClientNotify(rMod, rHint); + return; + } + else if (rHint.GetId() != SfxHintId::SwLegacyModify) return; auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint); const sal_uInt16 nNewWhich = pLegacy->m_pNew ? pLegacy->m_pNew->Which() : 0; @@ -2824,9 +2830,6 @@ void SwFrameFormat::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) case RES_ANCHOR: pOldAnchorNode = static_cast<const SwFormatAnchor*>(pLegacy->m_pOld)->GetAnchorNode(); break; - case RES_REMOVE_UNO_OBJECT: - SetXObject(nullptr); - break; } assert(nOldWhich == nNewWhich || !nOldWhich || !nNewWhich); diff --git a/sw/source/core/tox/tox.cxx b/sw/source/core/tox/tox.cxx index 9f1d5c90312e..d97de0af7c49 100644 --- a/sw/source/core/tox/tox.cxx +++ b/sw/source/core/tox/tox.cxx @@ -167,12 +167,14 @@ SwTOXMark* SwTOXMark::Clone( SfxItemPool* ) const void SwTOXMark::Notify(const SfxHint& rHint) { - if (rHint.GetId() == SfxHintId::SwLegacyModify) + if(SfxHintId::SwRemoveUnoObject == rHint.GetId()) + { + CallSwClientNotify(rHint); + SetXTOXMark(nullptr); + } + else if (rHint.GetId() == SfxHintId::SwLegacyModify) { - auto pLegacyHint = static_cast<const sw::LegacyModifyHint*>(&rHint); CallSwClientNotify(rHint); - if (pLegacyHint->m_pOld && (RES_REMOVE_UNO_OBJECT == pLegacyHint->m_pOld->Which())) - SetXTOXMark(nullptr); } else if (rHint.GetId() == SfxHintId::SwCollectTextMarks) { @@ -206,8 +208,7 @@ void SwTOXMark::Notify(const SfxHint& rHint) void SwTOXMark::InvalidateTOXMark() { - const SwPtrMsgPoolItem aMsgHint(RES_REMOVE_UNO_OBJECT, &static_cast<sw::BroadcastingModify&>(*this)); - CallSwClientNotify(sw::LegacyModifyHint(&aMsgHint, &aMsgHint)); + CallSwClientNotify(sw::RemoveUnoObjectHint(this)); } OUString SwTOXMark::GetText(SwRootFrame const*const pLayout) const diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx index 9974c4db6ec3..f6e8387c9879 100644 --- a/sw/source/core/txtnode/atrfld.cxx +++ b/sw/source/core/txtnode/atrfld.cxx @@ -218,8 +218,7 @@ SwFormatField* SwFormatField::Clone( SfxItemPool* ) const void SwFormatField::InvalidateField() { - const SwPtrMsgPoolItem aItem(RES_REMOVE_UNO_OBJECT, &static_cast<sw::BroadcastingModify&>(*this)); - CallSwClientNotify(sw::LegacyModifyHint{ &aItem, &aItem }); + CallSwClientNotify(sw::RemoveUnoObjectHint(this)); } void SwFormatField::SwClientNotify( const SwModify& rModify, const SfxHint& rHint ) @@ -404,6 +403,13 @@ void SwFormatField::UpdateDocPos(const SwTwips nDocPos) } void SwFormatField::UpdateTextNode(const SfxHint& rHint) { + if(SfxHintId::SwRemoveUnoObject == rHint.GetId()) + { // invalidate cached UNO object + m_wXTextField.clear(); + // ??? why does this Modify method not already do this? + CallSwClientNotify(rHint); + return; + } if(SfxHintId::SwLegacyModify != rHint.GetId()) return; auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint); @@ -414,13 +420,6 @@ void SwFormatField::UpdateTextNode(const SfxHint& rHint) ForceUpdateTextNode(); return; } - else if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which())) - { // invalidate cached UNO object - m_wXTextField.clear(); - // ??? why does this Modify method not already do this? - CallSwClientNotify(sw::LegacyModifyHint(pOld, pNew)); - return; - } if (!IsFieldInDoc()) return; diff --git a/sw/source/core/txtnode/atrftn.cxx b/sw/source/core/txtnode/atrftn.cxx index f7dfbddbe51e..a63bde260b1d 100644 --- a/sw/source/core/txtnode/atrftn.cxx +++ b/sw/source/core/txtnode/atrftn.cxx @@ -158,19 +158,20 @@ SwFormatFootnote* SwFormatFootnote::Clone( SfxItemPool* ) const void SwFormatFootnote::SwClientNotify(const SwModify&, const SfxHint& rHint) { + if(SfxHintId::SwRemoveUnoObject == rHint.GetId()) + { + CallSwClientNotify(rHint); + SetXFootnote(nullptr); + return; + } if (rHint.GetId() != SfxHintId::SwLegacyModify) return; - auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint); CallSwClientNotify(rHint); - if(RES_REMOVE_UNO_OBJECT == pLegacy->GetWhich()) - SetXFootnote(nullptr); } void SwFormatFootnote::InvalidateFootnote() { - SwPtrMsgPoolItem const item(RES_REMOVE_UNO_OBJECT, - &static_cast<sw::BroadcastingModify&>(*this)); // cast to base class (void*) - CallSwClientNotify(sw::LegacyModifyHint(&item, &item)); + CallSwClientNotify(sw::RemoveUnoObjectHint(this)); } void SwFormatFootnote::SetEndNote( bool b ) diff --git a/sw/source/core/txtnode/atrref.cxx b/sw/source/core/txtnode/atrref.cxx index 5a12e0662b4c..87fdaf818637 100644 --- a/sw/source/core/txtnode/atrref.cxx +++ b/sw/source/core/txtnode/atrref.cxx @@ -74,19 +74,20 @@ SwFormatRefMark* SwFormatRefMark::Clone( SfxItemPool* ) const void SwFormatRefMark::SwClientNotify(const SwModify&, const SfxHint& rHint) { + if(SfxHintId::SwRemoveUnoObject == rHint.GetId()) + { + CallSwClientNotify(rHint); + SetXRefMark(nullptr); + return; + } if (rHint.GetId() != SfxHintId::SwLegacyModify) return; - auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint); CallSwClientNotify(rHint); - if(RES_REMOVE_UNO_OBJECT == pLegacy->GetWhich()) - SetXRefMark(nullptr); } void SwFormatRefMark::InvalidateRefMark() { - SwPtrMsgPoolItem const item(RES_REMOVE_UNO_OBJECT, - &static_cast<sw::BroadcastingModify&>(*this)); // cast to base class (void*) - CallSwClientNotify(sw::LegacyModifyHint(&item, &item)); + CallSwClientNotify(sw::RemoveUnoObjectHint(this)); } void SwFormatRefMark::dumpAsXml(xmlTextWriterPtr pWriter) const diff --git a/sw/source/core/txtnode/attrcontentcontrol.cxx b/sw/source/core/txtnode/attrcontentcontrol.cxx index 9c6bd71a7593..065f54aeacc4 100644 --- a/sw/source/core/txtnode/attrcontentcontrol.cxx +++ b/sw/source/core/txtnode/attrcontentcontrol.cxx @@ -262,19 +262,20 @@ void SwContentControl::NotifyChangeTextNode(SwTextNode* pTextNode) void SwContentControl::SwClientNotify(const SwModify&, const SfxHint& rHint) { - if (rHint.GetId() != SfxHintId::SwLegacyModify) - return; - - auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint); - CallSwClientNotify(rHint); - GetNotifier().Broadcast(SfxHint(SfxHintId::DataChanged)); - - if (pLegacy->GetWhich() == RES_REMOVE_UNO_OBJECT) + if (SfxHintId::SwRemoveUnoObject == rHint.GetId()) { + CallSwClientNotify(rHint); + GetNotifier().Broadcast(SfxHint(SfxHintId::DataChanged)); // Invalidate cached uno object. SetXContentControl(nullptr); GetNotifier().Broadcast(SfxHint(SfxHintId::Deinitializing)); + return; } + if (rHint.GetId() != SfxHintId::SwLegacyModify) + return; + + CallSwClientNotify(rHint); + GetNotifier().Broadcast(SfxHint(SfxHintId::DataChanged)); } std::optional<size_t> SwContentControl::GetSelectedListItem(bool bCheckDocModel) const diff --git a/sw/source/core/txtnode/attrlinebreak.cxx b/sw/source/core/txtnode/attrlinebreak.cxx index 5e4fb4e69afd..0f5821cf0312 100644 --- a/sw/source/core/txtnode/attrlinebreak.cxx +++ b/sw/source/core/txtnode/attrlinebreak.cxx @@ -60,14 +60,15 @@ SwFormatLineBreak* SwFormatLineBreak::Clone(SfxItemPool*) const void SwFormatLineBreak::SwClientNotify(const SwModify&, const SfxHint& rHint) { - if (rHint.GetId() != SfxHintId::SwLegacyModify) - return; - auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint); - CallSwClientNotify(rHint); - if (RES_REMOVE_UNO_OBJECT == pLegacy->GetWhich()) + if (SfxHintId::SwRemoveUnoObject == rHint.GetId()) { + CallSwClientNotify(rHint); SetXLineBreak(nullptr); + return; } + if (rHint.GetId() != SfxHintId::SwLegacyModify) + return; + CallSwClientNotify(rHint); } sal_uInt16 SwFormatLineBreak::GetValueCount() const diff --git a/sw/source/core/txtnode/fmtatr2.cxx b/sw/source/core/txtnode/fmtatr2.cxx index d7611a187e4f..3f9b1489ea5b 100644 --- a/sw/source/core/txtnode/fmtatr2.cxx +++ b/sw/source/core/txtnode/fmtatr2.cxx @@ -718,16 +718,19 @@ void Meta::NotifyChangeTextNode(SwTextNode *const pTextNode) void Meta::SwClientNotify(const SwModify&, const SfxHint& rHint) { + if(SfxHintId::SwRemoveUnoObject == rHint.GetId()) + { + CallSwClientNotify(rHint); + GetNotifier().Broadcast(SfxHint(SfxHintId::DataChanged)); + // invalidate cached uno object + SetXMeta(nullptr); + GetNotifier().Broadcast(SfxHint(SfxHintId::Deinitializing)); + return; + } if (rHint.GetId() != SfxHintId::SwLegacyModify) return; - auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint); CallSwClientNotify(rHint); GetNotifier().Broadcast(SfxHint(SfxHintId::DataChanged)); - if(RES_REMOVE_UNO_OBJECT == pLegacy->GetWhich()) - { // invalidate cached uno object - SetXMeta(nullptr); - GetNotifier().Broadcast(SfxHint(SfxHintId::Deinitializing)); - } } // sfx2::Metadatable diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 81dcab11db24..8e15ce77e8fe 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -5587,10 +5587,19 @@ void SwTextNode::TriggerNodeUpdate(const sw::LegacyModifyHint& rHint) rDoc.GetNodes().UpdateOutlineNode(*this); } } +} + +void SwTextNode::TriggerNodeUpdate(const sw::RemoveUnoObjectHint& rHint) +{ + sw::TextNodeNotificationSuppressor(*this); + + SwContentNode::SwClientNotify(*this, rHint); - if (pOldValue && (RES_REMOVE_UNO_OBJECT == pOldValue->Which())) - { // invalidate cached uno object - SetXParagraph(nullptr); + SwDoc& rDoc = GetDoc(); + // #125329# - assure that text node is in document nodes array + if ( !rDoc.IsInDtor() && &rDoc.GetNodes() == &GetNodes() ) + { + rDoc.GetNodes().UpdateOutlineNode(*this); } } @@ -5600,6 +5609,10 @@ void SwTextNode::SwClientNotify( const SwModify& rModify, const SfxHint& rHint ) { static_cast<const sw::AutoFormatUsedHint&>(rHint).CheckNode(this); } + else if(SfxHintId::SwRemoveUnoObject == rHint.GetId()) + { + TriggerNodeUpdate(static_cast<const sw::RemoveUnoObjectHint&>(rHint)); + } else if (rHint.GetId() == SfxHintId::SwLegacyModify) { auto pLegacyHint = static_cast<const sw::LegacyModifyHint*>(&rHint); diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index da2354f29636..c564aad27449 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -2649,12 +2649,13 @@ void SwXTextField::Impl::Notify(const SfxHint& rHint) if(rHint.GetId() == SfxHintId::Dying) Invalidate(); + else if(SfxHintId::SwRemoveUnoObject == rHint.GetId()) + Invalidate(); else if (rHint.GetId() == SfxHintId::SwLegacyModify) { auto pLegacyHint = static_cast<const sw::LegacyModifyHint*>(&rHint); switch(pLegacyHint->m_pOld ? pLegacyHint->m_pOld->Which() : 0) { - case RES_REMOVE_UNO_OBJECT: case RES_OBJECTDYING: Invalidate(); break; diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index 5237380ccfab..9e47678d7a1e 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -359,12 +359,8 @@ public: void SwXDocumentIndex::Impl::Notify(const SfxHint& rHint) { - if (rHint.GetId() == SfxHintId::SwLegacyModify) - { - auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint); - if(pLegacy->m_pOld && pLegacy->m_pOld->Which() == RES_REMOVE_UNO_OBJECT) - m_pFormat = nullptr; - } + if(SfxHintId::SwRemoveUnoObject == rHint.GetId()) + m_pFormat = nullptr; else if(rHint.GetId() == SfxHintId::Dying) m_pFormat = nullptr; if(!m_pFormat)