summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2013-02-02 22:31:48 +0100
committerMichael Stahl <mstahl@redhat.com>2013-02-03 02:14:19 +0100
commit9123b493e5e63fcb298a0afac2c50e6a0b5bb955 (patch)
tree3c9896701ff7afeec8c0e88e313beeda749915e9
parentc31f340083206081e546bd06358b4231fa40c133 (diff)
sw: replace SwRefreshListenerContainer in SwXTextDocument
Change-Id: I67ddeacc80b833cee26ad0d34c80b9ce52c4db95
-rw-r--r--sw/inc/unotxdoc.hxx13
-rw-r--r--sw/source/ui/shells/basesh.cxx2
-rw-r--r--sw/source/ui/uno/unotxdoc.cxx56
3 files changed, 47 insertions, 24 deletions
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index d8f3fbaa3867..dea4ea7365b9 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.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 _UNOTXDOC_HXX
-#define _UNOTXDOC_HXX
+#ifndef SW_UNOTXDOC_HXX
+#define SW_UNOTXDOC_HXX
#include "swdllapi.h"
#include <sfx2/sfxbasemodel.hxx>
@@ -67,8 +67,8 @@
#include <cppuhelper/weak.hxx>
#include <cppuhelper/implbase2.hxx> // helper for implementations
#include <cppuhelper/implbase4.hxx> // helper for implementations
-#include <RefreshListenerContainer.hxx>
+#include <unobaseclass.hxx>
#include <viewopt.hxx>
#define __IFC32 Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, Ifc13, Ifc14, Ifc15, Ifc16, \
@@ -163,8 +163,11 @@ class SW_DLLPUBLIC SwXTextDocument : public SwXTextDocumentBaseClass,
public SvxFmMSFactory,
public SfxBaseModel
{
+private:
+ class Impl;
+ ::sw::UnoImplPtr<Impl> m_pImpl;
+
ActionContextArr aActionArr;
- SwRefreshListenerContainer aRefreshCont;
const SfxItemPropertySet* pPropSet;
@@ -234,7 +237,7 @@ protected:
public:
SwXTextDocument(SwDocShell* pShell);
- inline void notifyRefreshListeners() { aRefreshCont.Refreshed(); }
+ void NotifyRefreshListeners();
virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) throw(css::uno::RuntimeException);
virtual void SAL_CALL acquire( ) throw();
virtual void SAL_CALL release( ) throw();
diff --git a/sw/source/ui/shells/basesh.cxx b/sw/source/ui/shells/basesh.cxx
index a443ea84b1be..27c99013c27d 100644
--- a/sw/source/ui/shells/basesh.cxx
+++ b/sw/source/ui/shells/basesh.cxx
@@ -586,7 +586,7 @@ void SwBaseShell::Execute(SfxRequest &rReq)
Reference < XModel > xModel = GetView().GetDocShell()->GetModel();
Reference < XUnoTunnel > xDocTunnel ( xModel, UNO_QUERY );
SwXTextDocument *pDoc = reinterpret_cast < SwXTextDocument * > ( xDocTunnel->getSomething ( SwXTextDocument::getUnoTunnelId() ) );
- pDoc->notifyRefreshListeners();
+ pDoc->NotifyRefreshListeners();
rSh.CalcLayout();
}
break;
diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx
index 9c8772eb9992..12504c3a35ad 100644
--- a/sw/source/ui/uno/unotxdoc.cxx
+++ b/sw/source/ui/uno/unotxdoc.cxx
@@ -221,6 +221,18 @@ static void lcl_DisposeView( SfxViewFrame* pToClose, SwDocShell* pDocShell )
}
}
+class SwXTextDocument::Impl
+{
+private:
+ ::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper
+
+public:
+ ::cppu::OInterfaceContainerHelper m_RefreshListeners;
+
+ Impl() : m_RefreshListeners(m_Mutex) { }
+
+};
+
namespace
{
class theSwXTextDocumentUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXTextDocumentUnoTunnelId > {};
@@ -341,11 +353,10 @@ Sequence< uno::Type > SAL_CALL SwXTextDocument::getTypes() throw(RuntimeExceptio
return aBaseTypes;
}
-SwXTextDocument::SwXTextDocument(SwDocShell* pShell) :
- SfxBaseModel(pShell),
-
- aRefreshCont ( static_cast < XTextDocument* > ( this ) ),
-
+SwXTextDocument::SwXTextDocument(SwDocShell* pShell)
+ : SfxBaseModel(pShell)
+ , m_pImpl(new Impl)
+ ,
pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_DOCUMENT)),
pDocShell(pShell),
@@ -1404,7 +1415,8 @@ void SwXTextDocument::Invalidate()
}
InitNewDoc();
pDocShell = 0;
- aRefreshCont.Disposing();
+ lang::EventObject const ev(static_cast<SwXTextDocumentBaseClass &>(*this));
+ m_pImpl->m_RefreshListeners.disposeAndClear(ev);
}
void SwXTextDocument::Reactivate(SwDocShell* pNewDocShell)
@@ -2196,32 +2208,40 @@ Reference< XEnumerationAccess > SwXTextDocument::getRedlines( ) throw(RuntimeEx
return *pxXRedlines;
}
+void SwXTextDocument::NotifyRefreshListeners()
+{
+ // why does SwBaseShell not just call refresh? maybe because it's rSh is
+ // (sometimes) a different shell than GetWrtShell()?
+ lang::EventObject const ev(static_cast<SwXTextDocumentBaseClass &>(*this));
+ m_pImpl->m_RefreshListeners.notifyEach(
+ & util::XRefreshListener::refreshed, ev);
+}
+
void SwXTextDocument::refresh(void) throw( RuntimeException )
{
SolarMutexGuard aGuard;
if(!IsValid())
throw RuntimeException();
ViewShell *pViewShell = pDocShell->GetWrtShell();
- notifyRefreshListeners();
+ NotifyRefreshListeners();
if(pViewShell)
pViewShell->CalcLayout();
}
-void SwXTextDocument::addRefreshListener(const Reference< util::XRefreshListener > & l)
- throw( RuntimeException )
+void SAL_CALL SwXTextDocument::addRefreshListener(
+ const Reference<util::XRefreshListener> & xListener)
+throw (RuntimeException)
{
- SolarMutexGuard aGuard;
- if ( !IsValid() )
- throw RuntimeException();
- aRefreshCont.AddListener ( reinterpret_cast < const Reference < lang::XEventListener > &> ( l ));
+ // no need to lock here as m_pImpl is const and container threadsafe
+ m_pImpl->m_RefreshListeners.addInterface(xListener);
}
-void SwXTextDocument::removeRefreshListener(const Reference< util::XRefreshListener > & l)
- throw( RuntimeException )
+void SAL_CALL SwXTextDocument::removeRefreshListener(
+ const Reference<util::XRefreshListener> & xListener)
+throw (RuntimeException)
{
- SolarMutexGuard aGuard;
- if ( !IsValid() || !aRefreshCont.RemoveListener ( reinterpret_cast < const Reference < lang::XEventListener > &> ( l ) ) )
- throw RuntimeException();
+ // no need to lock here as m_pImpl is const and container threadsafe
+ m_pImpl->m_RefreshListeners.removeInterface(xListener);
}
void SwXTextDocument::updateLinks( ) throw(RuntimeException)