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

sw: replace SwRefreshListenerContainer in SwXTextFieldTypes

... and add a pImpl while at it.

Change-Id: If91ccc330f20c691cb9f6c5b1624278d1d9d7af9
üst 503b6366
...@@ -20,10 +20,11 @@ ...@@ -20,10 +20,11 @@
#ifndef SW_UNOFIELDCOLL_HXX #ifndef SW_UNOFIELDCOLL_HXX
#define SW_UNOFIELDCOLL_HXX #define SW_UNOFIELDCOLL_HXX
#include <boost/scoped_ptr.hpp>
#include <com/sun/star/util/XRefreshable.hpp> #include <com/sun/star/util/XRefreshable.hpp>
#include <unocoll.hxx> #include <unocoll.hxx>
#include <RefreshListenerContainer.hxx>
class SwFieldType; class SwFieldType;
...@@ -84,7 +85,8 @@ class SwXTextFieldTypes ...@@ -84,7 +85,8 @@ class SwXTextFieldTypes
, public SwUnoCollection , public SwUnoCollection
{ {
private: private:
SwRefreshListenerContainer aRefreshCont; class Impl;
::boost::scoped_ptr<Impl> m_pImpl; // currently does not need UnoImplPtr
protected: protected:
virtual ~SwXTextFieldTypes(); virtual ~SwXTextFieldTypes();
......
...@@ -2609,6 +2609,21 @@ sal_Bool SwXTextFieldMasters::hasElements(void) throw( uno::RuntimeException ) ...@@ -2609,6 +2609,21 @@ sal_Bool SwXTextFieldMasters::hasElements(void) throw( uno::RuntimeException )
return sal_True; return sal_True;
} }
/******************************************************************
* SwXFieldTypes
******************************************************************/
class SwXTextFieldTypes::Impl
{
private:
::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper
public:
::cppu::OInterfaceContainerHelper m_RefreshListeners;
Impl() : m_RefreshListeners(m_Mutex) { }
};
OUString SwXTextFieldTypes::getImplementationName(void) throw( uno::RuntimeException ) OUString SwXTextFieldTypes::getImplementationName(void) throw( uno::RuntimeException )
{ {
return OUString("SwXTextFieldTypes"); return OUString("SwXTextFieldTypes");
...@@ -2627,9 +2642,9 @@ uno::Sequence< OUString > SwXTextFieldTypes::getSupportedServiceNames(void) thro ...@@ -2627,9 +2642,9 @@ uno::Sequence< OUString > SwXTextFieldTypes::getSupportedServiceNames(void) thro
return aRet; return aRet;
} }
SwXTextFieldTypes::SwXTextFieldTypes(SwDoc* _pDoc) : SwXTextFieldTypes::SwXTextFieldTypes(SwDoc* _pDoc)
SwUnoCollection (_pDoc), : SwUnoCollection (_pDoc)
aRefreshCont ( static_cast< XEnumerationAccess * >(this) ) , m_pImpl(new Impl)
{ {
} }
...@@ -2640,7 +2655,8 @@ SwXTextFieldTypes::~SwXTextFieldTypes() ...@@ -2640,7 +2655,8 @@ SwXTextFieldTypes::~SwXTextFieldTypes()
void SwXTextFieldTypes::Invalidate() void SwXTextFieldTypes::Invalidate()
{ {
SwUnoCollection::Invalidate(); SwUnoCollection::Invalidate();
aRefreshCont.Disposing(); lang::EventObject const ev(static_cast< ::cppu::OWeakObject&>(*this));
m_pImpl->m_RefreshListeners.disposeAndClear(ev);
} }
uno::Reference< container::XEnumeration > SwXTextFieldTypes::createEnumeration(void) uno::Reference< container::XEnumeration > SwXTextFieldTypes::createEnumeration(void)
...@@ -2662,38 +2678,39 @@ sal_Bool SwXTextFieldTypes::hasElements(void) throw( uno::RuntimeException ) ...@@ -2662,38 +2678,39 @@ sal_Bool SwXTextFieldTypes::hasElements(void) throw( uno::RuntimeException )
SolarMutexGuard aGuard; SolarMutexGuard aGuard;
if(!IsValid()) if(!IsValid())
throw uno::RuntimeException(); throw uno::RuntimeException();
//es gibt sie immer return sal_True; // they always exist
return sal_True;
} }
void SwXTextFieldTypes::refresh(void) throw( uno::RuntimeException ) void SAL_CALL SwXTextFieldTypes::refresh() throw (uno::RuntimeException)
{ {
SolarMutexGuard aGuard; {
if(!IsValid()) SolarMutexGuard aGuard;
throw uno::RuntimeException(); if (!IsValid())
UnoActionContext aContext(GetDoc()); throw uno::RuntimeException();
GetDoc()->UpdateDocStat(); UnoActionContext aContext(GetDoc());
GetDoc()->UpdateFlds(0, sal_False); GetDoc()->UpdateDocStat();
GetDoc()->UpdateFlds(0, sal_False);
// call refresh listeners }
aRefreshCont.Refreshed(); // call refresh listeners (without SolarMutex locked)
lang::EventObject const event(static_cast< ::cppu::OWeakObject*>(this));
m_pImpl->m_RefreshListeners.notifyEach(
& util::XRefreshListener::refreshed, event);
} }
void SwXTextFieldTypes::addRefreshListener(const uno::Reference< util::XRefreshListener > & l) void SAL_CALL SwXTextFieldTypes::addRefreshListener(
throw( uno::RuntimeException ) const uno::Reference<util::XRefreshListener> & xListener)
throw (uno::RuntimeException)
{ {
SolarMutexGuard aGuard; // no need to lock here as m_pImpl is const and container threadsafe
if ( !IsValid() ) m_pImpl->m_RefreshListeners.addInterface(xListener);
throw uno::RuntimeException();
aRefreshCont.AddListener ( reinterpret_cast < const uno::Reference < lang::XEventListener > &> ( l ));
} }
void SwXTextFieldTypes::removeRefreshListener(const uno::Reference< util::XRefreshListener > & l) void SAL_CALL SwXTextFieldTypes::removeRefreshListener(
throw( uno::RuntimeException ) const uno::Reference<util::XRefreshListener> & xListener)
throw (uno::RuntimeException)
{ {
SolarMutexGuard aGuard; // no need to lock here as m_pImpl is const and container threadsafe
if ( !IsValid() || !aRefreshCont.RemoveListener ( reinterpret_cast < const uno::Reference < lang::XEventListener > &> ( l ) ) ) m_pImpl->m_RefreshListeners.removeInterface(xListener);
throw uno::RuntimeException();
} }
/****************************************************************** /******************************************************************
......
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