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 | |
parent | 3c177e98c01bfabbeba90a0e571734b7055afd57 (diff) |
sw: replace SwEventListenerContainer in SwXFrame
Change-Id: I9136d14364196810f0f64b086b9b06e5b558286d
-rw-r--r-- | sw/inc/unoframe.hxx | 10 | ||||
-rw-r--r-- | sw/source/core/unocore/unoframe.cxx | 45 |
2 files changed, 38 insertions, 17 deletions
diff --git a/sw/inc/unoframe.hxx b/sw/inc/unoframe.hxx index 1cbae7ef8f95..36309b86430e 100644 --- a/sw/inc/unoframe.hxx +++ b/sw/inc/unoframe.hxx @@ -16,8 +16,8 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef _UNOFRAME_HXX -#define _UNOFRAME_HXX +#ifndef SW_UNOFRAME_HXX +#define SW_UNOFRAME_HXX #include <com/sun/star/beans/XPropertyState.hpp> #include <com/sun/star/container/XNamed.hpp> @@ -37,7 +37,6 @@ #include <flyenum.hxx> #include <frmfmt.hxx> -#include <unoevtlstnr.hxx> #include <unotext.hxx> class SdrObject; @@ -57,7 +56,10 @@ class SwXFrame : public cppu::WeakImplHelper6 >, public SwClient { - SwEventListenerContainer aLstnrCntnr; +private: + class Impl; + ::sw::UnoImplPtr<Impl> m_pImpl; + const SfxItemPropertySet* m_pPropSet; SwDoc* m_pDoc; 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); } } |