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

sw: replace SwEventListenerContainer in SwXFootnote

Change-Id: I03c1b3ad6a774f00993279c0830029708ee966ba
üst 9652b5b7
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <osl/mutex.hxx> #include <osl/mutex.hxx>
#include <cppuhelper/interfacecontainer.h>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include <comphelper/sequence.hxx> #include <comphelper/sequence.hxx>
#include <comphelper/servicehelper.hxx> #include <comphelper/servicehelper.hxx>
...@@ -30,7 +31,6 @@ ...@@ -30,7 +31,6 @@
#include <unoparagraph.hxx> #include <unoparagraph.hxx>
#include <unomap.hxx> #include <unomap.hxx>
#include <unoprnms.hxx> #include <unoprnms.hxx>
#include <unoevtlstnr.hxx>
#include <doc.hxx> #include <doc.hxx>
#include <ftnidx.hxx> #include <ftnidx.hxx>
#include <fmtftn.hxx> #include <fmtftn.hxx>
...@@ -49,12 +49,14 @@ using ::rtl::OUString; ...@@ -49,12 +49,14 @@ using ::rtl::OUString;
class SwXFootnote::Impl class SwXFootnote::Impl
: public SwClient : public SwClient
{ {
private:
::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper
public: public:
SwXFootnote & m_rThis; SwXFootnote & m_rThis;
const bool m_bIsEndnote; const bool m_bIsEndnote;
SwEventListenerContainer m_ListenerContainer; ::cppu::OInterfaceContainerHelper m_EventListeners;
bool m_bIsDescriptor; bool m_bIsDescriptor;
const SwFmtFtn * m_pFmtFtn; const SwFmtFtn * m_pFmtFtn;
::rtl::OUString m_sLabel; ::rtl::OUString m_sLabel;
...@@ -65,7 +67,7 @@ public: ...@@ -65,7 +67,7 @@ public:
: SwClient((pDoc) ? pDoc->GetUnoCallBack() : 0) : SwClient((pDoc) ? pDoc->GetUnoCallBack() : 0)
, m_rThis(rThis) , m_rThis(rThis)
, m_bIsEndnote(bIsEndnote) , m_bIsEndnote(bIsEndnote)
, m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) , m_EventListeners(m_Mutex)
// #i111177#: unxsols4 (Sun C++ 5.9 SunOS_sparc) generates wrong code for this // #i111177#: unxsols4 (Sun C++ 5.9 SunOS_sparc) generates wrong code for this
// , m_bIsDescriptor(0 == pFootnote) // , m_bIsDescriptor(0 == pFootnote)
, m_bIsDescriptor((0 == pFootnote) ? true : false) , m_bIsDescriptor((0 == pFootnote) ? true : false)
...@@ -99,9 +101,10 @@ void SwXFootnote::Impl::Invalidate() ...@@ -99,9 +101,10 @@ void SwXFootnote::Impl::Invalidate()
{ {
const_cast<SwModify*>(GetRegisteredIn())->Remove(this); const_cast<SwModify*>(GetRegisteredIn())->Remove(this);
} }
m_ListenerContainer.Disposing();
m_pFmtFtn = 0; m_pFmtFtn = 0;
m_rThis.SetDoc(0); m_rThis.SetDoc(0);
lang::EventObject const ev(static_cast< ::cppu::OWeakObject&>(m_rThis));
m_EventListeners.disposeAndClear(ev);
} }
void SwXFootnote::Impl::Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew) void SwXFootnote::Impl::Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew)
...@@ -399,13 +402,8 @@ SwXFootnote::addEventListener( ...@@ -399,13 +402,8 @@ SwXFootnote::addEventListener(
const uno::Reference< lang::XEventListener > & xListener) const uno::Reference< lang::XEventListener > & xListener)
throw (uno::RuntimeException) throw (uno::RuntimeException)
{ {
SolarMutexGuard g; // no need to lock here as m_pImpl is const and container threadsafe
m_pImpl->m_EventListeners.addInterface(xListener);
if (!m_pImpl->GetFootnoteFormat())
{
throw uno::RuntimeException();
}
m_pImpl->m_ListenerContainer.AddListener(xListener);
} }
void SAL_CALL void SAL_CALL
...@@ -413,13 +411,8 @@ SwXFootnote::removeEventListener( ...@@ -413,13 +411,8 @@ SwXFootnote::removeEventListener(
const uno::Reference< lang::XEventListener > & xListener) const uno::Reference< lang::XEventListener > & xListener)
throw (uno::RuntimeException) throw (uno::RuntimeException)
{ {
SolarMutexGuard g; // no need to lock here as m_pImpl is const and container threadsafe
m_pImpl->m_EventListeners.removeInterface(xListener);
if (!m_pImpl->GetFootnoteFormat() ||
!m_pImpl->m_ListenerContainer.RemoveListener(xListener))
{
throw uno::RuntimeException();
}
} }
const SwStartNode *SwXFootnote::GetStartNode() const const SwStartNode *SwXFootnote::GetStartNode() const
......
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