From 44df3bdc29445fd7a6307eee1d5f26df30f30a48 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Sun, 3 Feb 2013 01:07:48 +0100 Subject: sw: replace SwEventListenerContainer in SwXFootnote Change-Id: I03c1b3ad6a774f00993279c0830029708ee966ba --- sw/source/core/unocore/unoftn.cxx | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx index 5252202e4f41..148062bd30d7 100644 --- a/sw/source/core/unocore/unoftn.cxx +++ b/sw/source/core/unocore/unoftn.cxx @@ -19,6 +19,7 @@ #include +#include #include #include #include @@ -30,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -49,12 +49,14 @@ using ::rtl::OUString; class SwXFootnote::Impl : public SwClient { +private: + ::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper public: SwXFootnote & m_rThis; const bool m_bIsEndnote; - SwEventListenerContainer m_ListenerContainer; + ::cppu::OInterfaceContainerHelper m_EventListeners; bool m_bIsDescriptor; const SwFmtFtn * m_pFmtFtn; ::rtl::OUString m_sLabel; @@ -65,7 +67,7 @@ public: : SwClient((pDoc) ? pDoc->GetUnoCallBack() : 0) , m_rThis(rThis) , m_bIsEndnote(bIsEndnote) - , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) + , m_EventListeners(m_Mutex) // #i111177#: unxsols4 (Sun C++ 5.9 SunOS_sparc) generates wrong code for this // , m_bIsDescriptor(0 == pFootnote) , m_bIsDescriptor((0 == pFootnote) ? true : false) @@ -99,9 +101,10 @@ void SwXFootnote::Impl::Invalidate() { const_cast(GetRegisteredIn())->Remove(this); } - m_ListenerContainer.Disposing(); m_pFmtFtn = 0; m_rThis.SetDoc(0); + lang::EventObject const ev(static_cast< ::cppu::OWeakObject&>(m_rThis)); + m_EventListeners.disposeAndClear(ev); } void SwXFootnote::Impl::Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew) @@ -399,13 +402,8 @@ SwXFootnote::addEventListener( const uno::Reference< lang::XEventListener > & xListener) throw (uno::RuntimeException) { - SolarMutexGuard g; - - if (!m_pImpl->GetFootnoteFormat()) - { - throw uno::RuntimeException(); - } - m_pImpl->m_ListenerContainer.AddListener(xListener); + // no need to lock here as m_pImpl is const and container threadsafe + m_pImpl->m_EventListeners.addInterface(xListener); } void SAL_CALL @@ -413,13 +411,8 @@ SwXFootnote::removeEventListener( const uno::Reference< lang::XEventListener > & xListener) throw (uno::RuntimeException) { - SolarMutexGuard g; - - if (!m_pImpl->GetFootnoteFormat() || - !m_pImpl->m_ListenerContainer.RemoveListener(xListener)) - { - throw uno::RuntimeException(); - } + // no need to lock here as m_pImpl is const and container threadsafe + m_pImpl->m_EventListeners.removeInterface(xListener); } const SwStartNode *SwXFootnote::GetStartNode() const -- cgit v1.2.3