diff options
author | Michael Stahl <mstahl@redhat.com> | 2013-02-02 22:56:20 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2013-02-03 02:14:19 +0100 |
commit | 54c08983cb615fe0474238aacd18284acbc5ec43 (patch) | |
tree | f38f12d985479242e95b156731b126cdce64f7c6 /sw/source | |
parent | 3c177e98c01bfabbeba90a0e571734b7055afd57 (diff) |
sw: replace SwEventListenerContainer in SwXFrame
Change-Id: I9136d14364196810f0f64b086b9b06e5b558286d
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/unocore/unoframe.cxx | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 2e02d0ba5470..5ca640a00be8 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -754,6 +754,19 @@ bool SwOLEProperties_Impl::AnyToItemSet( return sal_True; } + +class SwXFrame::Impl +{ +private: + ::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper + +public: + ::cppu::OInterfaceContainerHelper m_EventListeners; + + Impl() : m_EventListeners(m_Mutex) { } +}; + + namespace { class theSwXFrameUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXFrameUnoTunnelId > {}; @@ -800,8 +813,9 @@ uno::Sequence< OUString > SwXFrame::getSupportedServiceNames(void) throw( uno::R return aRet; } -SwXFrame::SwXFrame(FlyCntType eSet, const :: SfxItemPropertySet* pSet, SwDoc *pDoc) : - aLstnrCntnr( (container::XNamed*)this), +SwXFrame::SwXFrame(FlyCntType eSet, const :: SfxItemPropertySet* pSet, SwDoc *pDoc) + : m_pImpl(new Impl) + , m_pPropSet(pSet), m_pDoc ( pDoc ), eType(eSet), @@ -851,9 +865,10 @@ SwXFrame::SwXFrame(FlyCntType eSet, const :: SfxItemPropertySet* pSet, SwDoc *pD } } -SwXFrame::SwXFrame(SwFrmFmt& rFrmFmt, FlyCntType eSet, const :: SfxItemPropertySet* pSet) : - SwClient( &rFrmFmt ), - aLstnrCntnr( (container::XNamed*)this), +SwXFrame::SwXFrame(SwFrmFmt& rFrmFmt, FlyCntType eSet, const :: SfxItemPropertySet* pSet) + : SwClient( &rFrmFmt ) + , m_pImpl(new Impl) + , m_pPropSet(pSet), m_pDoc( 0 ), eType(eSet), @@ -1989,17 +2004,20 @@ uno::Any SwXFrame::getPropertyDefault( const OUString& rPropertyName ) return aRet; } -void SwXFrame::addEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) +void SAL_CALL SwXFrame::addEventListener( + const uno::Reference<lang::XEventListener> & xListener) +throw (uno::RuntimeException) { - if(!GetRegisteredIn()) - throw uno::RuntimeException(); - aLstnrCntnr.AddListener(aListener); + // no need to lock here as m_pImpl is const and container threadsafe + m_pImpl->m_EventListeners.addInterface(xListener); } -void SwXFrame::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) +void SAL_CALL SwXFrame::removeEventListener( + const uno::Reference<lang::XEventListener> & xListener) +throw (uno::RuntimeException) { - if(!GetRegisteredIn() || !aLstnrCntnr.RemoveListener(aListener)) - throw uno::RuntimeException(); + // no need to lock here as m_pImpl is const and container threadsafe + m_pImpl->m_EventListeners.removeInterface(xListener); } void SwXFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) @@ -2010,7 +2028,8 @@ void SwXFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) mxStyleData.clear(); mxStyleFamily.clear(); m_pDoc = 0; - aLstnrCntnr.Disposing(); + lang::EventObject const ev(static_cast< ::cppu::OWeakObject&>(*this)); + m_pImpl->m_EventListeners.disposeAndClear(ev); } } |