Kaydet (Commit) 54c08983 authored tarafından Michael Stahl's avatar Michael Stahl

sw: replace SwEventListenerContainer in SwXFrame

Change-Id: I9136d14364196810f0f64b086b9b06e5b558286d
üst 3c177e98
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
* except in compliance with the License. You may obtain a copy of * except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#ifndef _UNOFRAME_HXX #ifndef SW_UNOFRAME_HXX
#define _UNOFRAME_HXX #define SW_UNOFRAME_HXX
#include <com/sun/star/beans/XPropertyState.hpp> #include <com/sun/star/beans/XPropertyState.hpp>
#include <com/sun/star/container/XNamed.hpp> #include <com/sun/star/container/XNamed.hpp>
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
#include <flyenum.hxx> #include <flyenum.hxx>
#include <frmfmt.hxx> #include <frmfmt.hxx>
#include <unoevtlstnr.hxx>
#include <unotext.hxx> #include <unotext.hxx>
class SdrObject; class SdrObject;
...@@ -57,7 +56,10 @@ class SwXFrame : public cppu::WeakImplHelper6 ...@@ -57,7 +56,10 @@ class SwXFrame : public cppu::WeakImplHelper6
>, >,
public SwClient public SwClient
{ {
SwEventListenerContainer aLstnrCntnr; private:
class Impl;
::sw::UnoImplPtr<Impl> m_pImpl;
const SfxItemPropertySet* m_pPropSet; const SfxItemPropertySet* m_pPropSet;
SwDoc* m_pDoc; SwDoc* m_pDoc;
......
...@@ -754,6 +754,19 @@ bool SwOLEProperties_Impl::AnyToItemSet( ...@@ -754,6 +754,19 @@ bool SwOLEProperties_Impl::AnyToItemSet(
return sal_True; 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 namespace
{ {
class theSwXFrameUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXFrameUnoTunnelId > {}; class theSwXFrameUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXFrameUnoTunnelId > {};
...@@ -800,8 +813,9 @@ uno::Sequence< OUString > SwXFrame::getSupportedServiceNames(void) throw( uno::R ...@@ -800,8 +813,9 @@ uno::Sequence< OUString > SwXFrame::getSupportedServiceNames(void) throw( uno::R
return aRet; return aRet;
} }
SwXFrame::SwXFrame(FlyCntType eSet, const :: SfxItemPropertySet* pSet, SwDoc *pDoc) : SwXFrame::SwXFrame(FlyCntType eSet, const :: SfxItemPropertySet* pSet, SwDoc *pDoc)
aLstnrCntnr( (container::XNamed*)this), : m_pImpl(new Impl)
,
m_pPropSet(pSet), m_pPropSet(pSet),
m_pDoc ( pDoc ), m_pDoc ( pDoc ),
eType(eSet), eType(eSet),
...@@ -851,9 +865,10 @@ SwXFrame::SwXFrame(FlyCntType eSet, const :: SfxItemPropertySet* pSet, SwDoc *pD ...@@ -851,9 +865,10 @@ SwXFrame::SwXFrame(FlyCntType eSet, const :: SfxItemPropertySet* pSet, SwDoc *pD
} }
} }
SwXFrame::SwXFrame(SwFrmFmt& rFrmFmt, FlyCntType eSet, const :: SfxItemPropertySet* pSet) : SwXFrame::SwXFrame(SwFrmFmt& rFrmFmt, FlyCntType eSet, const :: SfxItemPropertySet* pSet)
SwClient( &rFrmFmt ), : SwClient( &rFrmFmt )
aLstnrCntnr( (container::XNamed*)this), , m_pImpl(new Impl)
,
m_pPropSet(pSet), m_pPropSet(pSet),
m_pDoc( 0 ), m_pDoc( 0 ),
eType(eSet), eType(eSet),
...@@ -1989,17 +2004,20 @@ uno::Any SwXFrame::getPropertyDefault( const OUString& rPropertyName ) ...@@ -1989,17 +2004,20 @@ uno::Any SwXFrame::getPropertyDefault( const OUString& rPropertyName )
return aRet; 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()) // no need to lock here as m_pImpl is const and container threadsafe
throw uno::RuntimeException(); m_pImpl->m_EventListeners.addInterface(xListener);
aLstnrCntnr.AddListener(aListener);
} }
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)) // no need to lock here as m_pImpl is const and container threadsafe
throw uno::RuntimeException(); m_pImpl->m_EventListeners.removeInterface(xListener);
} }
void SwXFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) void SwXFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
...@@ -2010,7 +2028,8 @@ void SwXFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) ...@@ -2010,7 +2028,8 @@ void SwXFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
mxStyleData.clear(); mxStyleData.clear();
mxStyleFamily.clear(); mxStyleFamily.clear();
m_pDoc = 0; m_pDoc = 0;
aLstnrCntnr.Disposing(); lang::EventObject const ev(static_cast< ::cppu::OWeakObject&>(*this));
m_pImpl->m_EventListeners.disposeAndClear(ev);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment