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 @@
* 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;
......
......@@ -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);
}
}
......
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