sw/inc/fmtmeta.hxx | 1 sw/inc/unochart.hxx | 7 --- sw/source/core/txtnode/fmtatr2.cxx | 6 +-- sw/source/core/unocore/unochart.cxx | 6 --- sw/source/core/unocore/unorefmk.cxx | 70 ++++++++++++++++-------------------- 5 files changed, 38 insertions(+), 52 deletions(-)
New commits: commit 538c6219a2a347f9f601288a2dd345bf7d3c3209 Author: Bjoern Michaelsen <bjoern.michael...@libreoffice.org> Date: Thu May 10 10:51:42 2018 +0200 dont use SwClient/SwModify in unocore: Meta Change-Id: Icde1f5b9af599ca8b1ef52863c2772670659a39b Reviewed-on: https://gerrit.libreoffice.org/54648 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Björn Michaelsen <bjoern.michael...@libreoffice.org> diff --git a/sw/inc/fmtmeta.hxx b/sw/inc/fmtmeta.hxx index 9fe0fce07656..bcc93b107e77 100644 --- a/sw/inc/fmtmeta.hxx +++ b/sw/inc/fmtmeta.hxx @@ -127,6 +127,7 @@ namespace sw { class Meta : public ::sfx2::Metadatable , public SwModify + , public sw::BroadcasterMixin { protected: friend class ::SwFormatMeta; ///< SetFormatMeta, NotifyChangeTextNode diff --git a/sw/source/core/txtnode/fmtatr2.cxx b/sw/source/core/txtnode/fmtatr2.cxx index 374326f40eb6..f74696687558 100644 --- a/sw/source/core/txtnode/fmtatr2.cxx +++ b/sw/source/core/txtnode/fmtatr2.cxx @@ -664,9 +664,7 @@ void Meta::NotifyChangeTextNode(SwTextNode *const pTextNode) } if (!pTextNode) // text node gone? invalidate UNO object! { - SwPtrMsgPoolItem aMsgHint( RES_REMOVE_UNO_OBJECT, - &static_cast<SwModify&>(*this) ); // cast to base class! - Modify(&aMsgHint, &aMsgHint); + GetNotifier().Broadcast(SfxHint(SfxHintId::Deinitializing)); } } @@ -674,9 +672,11 @@ void Meta::NotifyChangeTextNode(SwTextNode *const pTextNode) void Meta::Modify( const SfxPoolItem *pOld, const SfxPoolItem *pNew ) { NotifyClients(pOld, pNew); + GetNotifier().Broadcast(SfxHint(SfxHintId::DataChanged)); if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which())) { // invalidate cached uno object SetXMeta(uno::Reference<rdf::XMetadatable>(nullptr)); + GetNotifier().Broadcast(SfxHint(SfxHintId::Deinitializing)); } } diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index b989ad8a28fe..41793c482bbe 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -607,8 +607,7 @@ SwXMetaText::createTextCursorByRange( // the Meta has a cached list of text portions for its contents // this list is created by SwXTextPortionEnumeration // the Meta listens at the SwTextNode and throws away the cache when it changes -class SwXMeta::Impl - : public SwClient +class SwXMeta::Impl : public SvtListener { private: ::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper2 @@ -622,56 +621,53 @@ public: bool m_bIsDescriptor; uno::Reference<text::XText> m_xParentText; rtl::Reference<SwXMetaText> m_xText; + sw::Meta* m_pMeta; - Impl( SwXMeta & rThis, SwDoc & rDoc, - ::sw::Meta * const pMeta, + Impl(SwXMeta& rThis, SwDoc& rDoc, + ::sw::Meta* const pMeta, uno::Reference<text::XText> const& xParentText, TextRangeList_t const * const pPortions) - : SwClient(pMeta) - , m_EventListeners(m_Mutex) - , m_pTextPortions( pPortions ) - , m_bIsDisposed( false ) + : m_EventListeners(m_Mutex) + , m_pTextPortions(pPortions) + , m_bIsDisposed(false) , m_bIsDescriptor(nullptr == pMeta) , m_xParentText(xParentText) , m_xText(new SwXMetaText(rDoc, rThis)) + , m_pMeta(pMeta) { + !m_bIsDescriptor && StartListening(m_pMeta->GetNotifier()); } - inline const ::sw::Meta * GetMeta() const; + inline const ::sw::Meta* GetMeta() const; // only for SwXMetaField! - inline const ::sw::MetaField * GetMetaField() const; + inline const ::sw::MetaField* GetMetaField() const; protected: - // SwClient - virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override; + virtual void Notify(const SfxHint& rHint) override; }; -inline const ::sw::Meta * SwXMeta::Impl::GetMeta() const +inline const ::sw::Meta* SwXMeta::Impl::GetMeta() const { - return static_cast< const ::sw::Meta * >(GetRegisteredIn()); + return m_pMeta; } // SwModify -void SwXMeta::Impl::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew ) +void SwXMeta::Impl::Notify(const SfxHint& rHint) { m_pTextPortions.reset(); // throw away cache (SwTextNode changed) - - ClientModify(this, pOld, pNew); - - if (GetRegisteredIn()) + if(rHint.GetId() == SfxHintId::Dying || rHint.GetId() == SfxHintId::Deinitializing) { - return; // core object still alive - } - - m_bIsDisposed = true; - m_xText->Invalidate(); - uno::Reference<uno::XInterface> const xThis(m_wThis); - if (!xThis.is()) - { // fdo#72695: if UNO object is already dead, don't revive it with event - return; + m_bIsDisposed = true; + m_pMeta = nullptr; + m_xText->Invalidate(); + uno::Reference<uno::XInterface> const xThis(m_wThis); + if (!xThis.is()) + { // fdo#72695: if UNO object is already dead, don't revive it with event + return; + } + lang::EventObject const ev(xThis); + m_EventListeners.disposeAndClear(ev); } - lang::EventObject const ev(xThis); - m_EventListeners.disposeAndClear(ev); } uno::Reference<text::XText> const & SwXMeta::GetParentText() const @@ -1020,7 +1016,9 @@ SwXMeta::AttachImpl(const uno::Reference< text::XTextRange > & i_xTextRange, static_cast< ::cppu::OWeakObject* >(this)); } - pMeta->Add(m_pImpl.get()); + m_pImpl->EndListeningAll(); + m_pImpl->m_pMeta = pMeta.get(); + m_pImpl->StartListening(pMeta->GetNotifier()); pMeta->SetXMeta(uno::Reference<rdf::XMetadatable>(this)); m_pImpl->m_xParentText = ::sw::CreateParentXText(*pDoc, *aPam.GetPoint()); @@ -1186,12 +1184,10 @@ SwXMeta::getElementType() return cppu::UnoType<text::XTextRange>::get(); } -sal_Bool SAL_CALL -SwXMeta::hasElements() +sal_Bool SAL_CALL SwXMeta::hasElements() { SolarMutexGuard g; - - return m_pImpl->GetRegisteredIn() != nullptr; + return m_pImpl->m_pMeta != nullptr; } // XEnumerationAccess @@ -1253,9 +1249,9 @@ uno::Reference<frame::XModel> SwXMeta::GetModel() return nullptr; } -inline const ::sw::MetaField * SwXMeta::Impl::GetMetaField() const +inline const ::sw::MetaField* SwXMeta::Impl::GetMetaField() const { - return static_cast< const ::sw::MetaField * >(GetRegisteredIn()); + return dynamic_cast<sw::MetaField*>(m_pMeta); } SwXMetaField::SwXMetaField(SwDoc *const pDoc, ::sw::Meta *const pMeta, commit 74aeeb9a6293b87df26cf6db565d50c26da2c3fe Author: Bjoern Michaelsen <bjoern.michael...@libreoffice.org> Date: Thu May 10 10:51:42 2018 +0200 dont use SwClient/SwModify in unocore: ChartDataProvider - and to the couragous person writing that comment: * yes, likely you should have come back to check if this was superfluous * no, you didnt (so far) Change-Id: I56633aee4b49979b60417f88235e9393c0bc48c8 Reviewed-on: https://gerrit.libreoffice.org/54895 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Björn Michaelsen <bjoern.michael...@libreoffice.org> diff --git a/sw/inc/unochart.hxx b/sw/inc/unochart.hxx index ff11d96a25f5..cbbe98b235cb 100644 --- a/sw/inc/unochart.hxx +++ b/sw/inc/unochart.hxx @@ -100,8 +100,7 @@ typedef cppu::WeakImplHelper SwChartDataProviderBaseClass; class SwChartDataProvider : - public SwChartDataProviderBaseClass, - public SwClient + public SwChartDataProviderBaseClass { // used to keep weak-references to all data-sequences of a single table @@ -142,10 +141,6 @@ class SwChartDataProvider : static OUString GetBrokenCellRangeForExport( const OUString &rCellRangeRepresentation ); -protected: - //SwClient - virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override; - public: SwChartDataProvider( const SwDoc* pDoc ); virtual ~SwChartDataProvider() override; diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx index 130f0fa22181..9821b5c3cba6 100644 --- a/sw/source/core/unocore/unochart.cxx +++ b/sw/source/core/unocore/unochart.cxx @@ -1455,12 +1455,6 @@ uno::Sequence< OUString > SAL_CALL SwChartDataProvider::getSupportedServiceNames return { "com.sun.star.chart2.data.DataProvider"}; } -void SwChartDataProvider::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) -{ - // actually this function should be superfluous (need to check later) - ClientModify(this, pOld, pNew ); -} - void SwChartDataProvider::AddDataSequence( const SwTable &rTable, uno::Reference< chart2::data::XDataSequence > const &rxDataSequence ) { aDataSequences[ &rTable ].insert( rxDataSequence ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits