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

sw: replace SwEventListenerContainer in SwXTextField,SwXFieldMaster

Change-Id: I554ca3455ebddf6a4595175e8d71ae38b8b43e59
üst 080dc03a
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include <tools/string.hxx> #include <tools/string.hxx>
#include <calbck.hxx> #include <calbck.hxx>
#include <unoevtlstnr.hxx> #include <unobaseclass.hxx>
class SwFieldType; class SwFieldType;
...@@ -52,7 +52,11 @@ class SwXFieldMaster : public cppu::WeakImplHelper4 ...@@ -52,7 +52,11 @@ class SwXFieldMaster : public cppu::WeakImplHelper4
>, >,
public SwClient public SwClient
{ {
SwEventListenerContainer aLstnrCntnr;
private:
class Impl;
::sw::UnoImplPtr<Impl> m_pImpl;
sal_uInt16 nResTypeId; sal_uInt16 nResTypeId;
SwDoc* m_pDoc; SwDoc* m_pDoc;
...@@ -126,7 +130,11 @@ class SwXTextField : public cppu::WeakImplHelper5 ...@@ -126,7 +130,11 @@ class SwXTextField : public cppu::WeakImplHelper5
>, >,
public SwClient public SwClient
{ {
SwEventListenerContainer aLstnrCntnr;
private:
class Impl;
::sw::UnoImplPtr<Impl> m_pImpl;
const SwFmtFld* pFmtFld; const SwFmtFld* pFmtFld;
SwDoc* m_pDoc; SwDoc* m_pDoc;
SwTextAPIObject* m_pTextObject; SwTextAPIObject* m_pTextObject;
......
...@@ -386,6 +386,18 @@ static sal_uInt16 lcl_GetPropertyMapOfService( sal_uInt16 nServiceId ) ...@@ -386,6 +386,18 @@ static sal_uInt16 lcl_GetPropertyMapOfService( sal_uInt16 nServiceId )
/****************************************************************** /******************************************************************
* SwXFieldMaster * SwXFieldMaster
******************************************************************/ ******************************************************************/
class SwXFieldMaster::Impl
{
private:
::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper
public:
::cppu::OInterfaceContainerHelper m_EventListeners;
Impl() : m_EventListeners(m_Mutex) { }
};
TYPEINIT1(SwXFieldMaster, SwClient); TYPEINIT1(SwXFieldMaster, SwClient);
namespace namespace
...@@ -469,8 +481,9 @@ uno::Sequence< OUString > SwXFieldMaster::getSupportedServiceNames(void) throw( ...@@ -469,8 +481,9 @@ uno::Sequence< OUString > SwXFieldMaster::getSupportedServiceNames(void) throw(
return aRet; return aRet;
} }
SwXFieldMaster::SwXFieldMaster(SwDoc* pDoc, sal_uInt16 nResId) : SwXFieldMaster::SwXFieldMaster(SwDoc* pDoc, sal_uInt16 nResId)
aLstnrCntnr( (XPropertySet*)this), : m_pImpl(new Impl)
,
nResTypeId(nResId), nResTypeId(nResId),
m_pDoc(pDoc), m_pDoc(pDoc),
m_bIsDescriptor(sal_True), m_bIsDescriptor(sal_True),
...@@ -482,9 +495,10 @@ SwXFieldMaster::SwXFieldMaster(SwDoc* pDoc, sal_uInt16 nResId) : ...@@ -482,9 +495,10 @@ SwXFieldMaster::SwXFieldMaster(SwDoc* pDoc, sal_uInt16 nResId) :
pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this); pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
} }
SwXFieldMaster::SwXFieldMaster(SwFieldType& rType, SwDoc* pDoc) : SwXFieldMaster::SwXFieldMaster(SwFieldType& rType, SwDoc* pDoc)
SwClient(&rType), : SwClient(&rType)
aLstnrCntnr( (XPropertySet*)this), , m_pImpl(new Impl)
,
nResTypeId(rType.Which()), nResTypeId(rType.Which()),
m_pDoc(pDoc), m_pDoc(pDoc),
m_bIsDescriptor(sal_False), m_bIsDescriptor(sal_False),
...@@ -932,19 +946,20 @@ void SwXFieldMaster::dispose(void) throw( uno::RuntimeException ) ...@@ -932,19 +946,20 @@ void SwXFieldMaster::dispose(void) throw( uno::RuntimeException )
throw uno::RuntimeException(); throw uno::RuntimeException();
} }
void SwXFieldMaster::addEventListener(const uno::Reference< lang::XEventListener > & aListener) void SAL_CALL SwXFieldMaster::addEventListener(
throw( uno::RuntimeException ) 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 SwXFieldMaster::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) void SAL_CALL SwXFieldMaster::removeEventListener(
throw( uno::RuntimeException ) 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 SwXFieldMaster::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) void SwXFieldMaster::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
...@@ -952,8 +967,9 @@ void SwXFieldMaster::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) ...@@ -952,8 +967,9 @@ void SwXFieldMaster::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
ClientModify(this, pOld, pNew); ClientModify(this, pOld, pNew);
if(!GetRegisteredIn()) if(!GetRegisteredIn())
{ {
aLstnrCntnr.Disposing();
m_pDoc = 0; m_pDoc = 0;
lang::EventObject const ev(static_cast< ::cppu::OWeakObject&>(*this));
m_pImpl->m_EventListeners.disposeAndClear(ev);
} }
} }
OUString SwXFieldMaster::GetProgrammaticName(const SwFieldType& rType, SwDoc& rDoc) OUString SwXFieldMaster::GetProgrammaticName(const SwFieldType& rType, SwDoc& rDoc)
...@@ -1064,6 +1080,17 @@ struct SwFieldProperties_Impl ...@@ -1064,6 +1080,17 @@ struct SwFieldProperties_Impl
}; };
class SwXTextField::Impl
{
private:
::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper
public:
::cppu::OInterfaceContainerHelper m_EventListeners;
Impl() : m_EventListeners(m_Mutex) { }
};
TYPEINIT1(SwXTextField, SwClient); TYPEINIT1(SwXTextField, SwClient);
namespace namespace
...@@ -1088,8 +1115,9 @@ sal_Int64 SAL_CALL SwXTextField::getSomething( const uno::Sequence< sal_Int8 >& ...@@ -1088,8 +1115,9 @@ sal_Int64 SAL_CALL SwXTextField::getSomething( const uno::Sequence< sal_Int8 >&
return 0; return 0;
} }
SwXTextField::SwXTextField(sal_uInt16 nServiceId, SwDoc* pDoc) : SwXTextField::SwXTextField(sal_uInt16 nServiceId, SwDoc* pDoc)
aLstnrCntnr( (XTextContent*)this), : m_pImpl(new Impl)
,
pFmtFld(0), pFmtFld(0),
m_pDoc(pDoc), m_pDoc(pDoc),
m_pTextObject(0), m_pTextObject(0),
...@@ -1111,8 +1139,9 @@ SwXTextField::SwXTextField(sal_uInt16 nServiceId, SwDoc* pDoc) : ...@@ -1111,8 +1139,9 @@ SwXTextField::SwXTextField(sal_uInt16 nServiceId, SwDoc* pDoc) :
} }
SwXTextField::SwXTextField(const SwFmtFld& rFmt, SwDoc* pDc) : SwXTextField::SwXTextField(const SwFmtFld& rFmt, SwDoc* pDc)
aLstnrCntnr( (XTextContent*)this), : m_pImpl(new Impl)
,
pFmtFld(&rFmt), pFmtFld(&rFmt),
m_pDoc(pDc), m_pDoc(pDc),
m_pTextObject(0), m_pTextObject(0),
...@@ -1843,17 +1872,20 @@ void SwXTextField::dispose(void) throw( uno::RuntimeException ) ...@@ -1843,17 +1872,20 @@ void SwXTextField::dispose(void) throw( uno::RuntimeException )
} }
} }
void SwXTextField::addEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) void SAL_CALL SwXTextField::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 SwXTextField::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) void SAL_CALL SwXTextField::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);
} }
uno::Reference< beans::XPropertySetInfo > SwXTextField::getPropertySetInfo(void) uno::Reference< beans::XPropertySetInfo > SwXTextField::getPropertySetInfo(void)
...@@ -2351,9 +2383,10 @@ void SwXTextField::Invalidate() ...@@ -2351,9 +2383,10 @@ void SwXTextField::Invalidate()
if (GetRegisteredIn()) if (GetRegisteredIn())
{ {
((SwModify*)GetRegisteredIn())->Remove(this); ((SwModify*)GetRegisteredIn())->Remove(this);
aLstnrCntnr.Disposing();
pFmtFld = 0; pFmtFld = 0;
m_pDoc = 0; m_pDoc = 0;
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