diff options
author | Michael Stahl <mstahl@redhat.com> | 2013-02-03 00:54:40 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2013-02-03 02:14:20 +0100 |
commit | f062c89e49d5028efe76a2a3f33294da0d2b32cf (patch) | |
tree | 5d366b79d69bc588b3d563bb88aacad1a40d2857 /sw/source | |
parent | c6fae31ebabf9067428d424ed5c0fc59f7c998b2 (diff) |
sw: replace SwEventListenerContainer in SwXTextPortion
Change-Id: Iac39d68388daa1a6d8e8a41e9ff59d290d5d050b
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/inc/unoport.hxx | 16 | ||||
-rw-r--r-- | sw/source/core/unocore/unoparagraph.cxx | 1 | ||||
-rw-r--r-- | sw/source/core/unocore/unoport.cxx | 42 |
3 files changed, 39 insertions, 20 deletions
diff --git a/sw/source/core/inc/unoport.hxx b/sw/source/core/inc/unoport.hxx index 27230e52c228..0eacbb0ddef3 100644 --- a/sw/source/core/inc/unoport.hxx +++ b/sw/source/core/inc/unoport.hxx @@ -19,9 +19,8 @@ #ifndef SW_UNOPORT_HXX #define SW_UNOPORT_HXX -#include <unocrsr.hxx> -#include <unoevtlstnr.hxx> -#include <calbck.hxx> +#include <memory> +#include <deque> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/text/XTextRange.hpp> @@ -35,12 +34,15 @@ #include <com/sun/star/text/XFootnote.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp> + #include <cppuhelper/implbase8.hxx> #include <cppuhelper/implbase3.hxx> + #include <svl/itemprop.hxx> -#include <memory> -#include <deque> +#include <unocrsr.hxx> +#include <calbck.hxx> +#include <unobaseclass.hxx> class SwFmtFld; @@ -92,7 +94,9 @@ class SwXTextPortion : public cppu::WeakImplHelper8 { private: - SwEventListenerContainer m_ListenerContainer; + class Impl; + ::sw::UnoImplPtr<Impl> m_pImpl; + const SfxItemPropertySet * m_pPropSet; const ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > m_xParentText; diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index 5ca68f94e528..5b3b12a36f89 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -24,6 +24,7 @@ #include <unotext.hxx> #include <unotextrange.hxx> #include <unoport.hxx> +#include <unoevtlstnr.hxx> #include <unomap.hxx> #include <unocrsr.hxx> #include <unoprnms.hxx> diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx index 56dfe2fadbf6..831ef2940b13 100644 --- a/sw/source/core/unocore/unoport.cxx +++ b/sw/source/core/unocore/unoport.cxx @@ -17,13 +17,15 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <unoport.hxx> + #include <cmdid.h> #include <osl/mutex.hxx> +#include <cppuhelper/interfacecontainer.h> #include <vcl/svapp.hxx> #include <svl/itemprop.hxx> #include <unocrsrhelper.hxx> -#include <unoport.hxx> #include <unoparaframeenum.hxx> #include <unotextrange.hxx> #include <unomap.hxx> @@ -50,6 +52,18 @@ using namespace ::com::sun::star; /****************************************************************** * SwXTextPortion ******************************************************************/ + +class SwXTextPortion::Impl +{ +private: + ::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper + +public: + ::cppu::OInterfaceContainerHelper m_EventListeners; + + Impl() : m_EventListeners(m_Mutex) { } +}; + void SwXTextPortion::init(const SwUnoCrsr* pPortionCursor) { SwUnoCrsr* pUnoCursor = @@ -65,7 +79,7 @@ void SwXTextPortion::init(const SwUnoCrsr* pPortionCursor) SwXTextPortion::SwXTextPortion(const SwUnoCrsr* pPortionCrsr, uno::Reference< text::XText > const& rParent, SwTextPortionType eType) - : m_ListenerContainer( static_cast<text::XTextRange*>(this) ) + : m_pImpl(new Impl) , m_pPropSet(aSwMapProvider.GetPropertySet( (PORTION_REDLINE_START == eType || PORTION_REDLINE_END == eType) @@ -87,7 +101,7 @@ SwXTextPortion::SwXTextPortion(const SwUnoCrsr* pPortionCrsr, SwXTextPortion::SwXTextPortion(const SwUnoCrsr* pPortionCrsr, uno::Reference< text::XText > const& rParent, SwFrmFmt& rFmt ) - : m_ListenerContainer( static_cast<text::XTextRange*>(this) ) + : m_pImpl(new Impl) , m_pPropSet(aSwMapProvider.GetPropertySet( PROPERTY_MAP_TEXTPORTION_EXTENSIONS)) , m_xParentText(rParent) @@ -107,7 +121,7 @@ SwXTextPortion::SwXTextPortion(const SwUnoCrsr* pPortionCrsr, SwTxtRuby const& rAttr, uno::Reference< text::XText > const& xParent, sal_Bool bIsEnd ) - : m_ListenerContainer( static_cast<text::XTextRange*>(this) ) + : m_pImpl(new Impl) , m_pPropSet(aSwMapProvider.GetPropertySet( PROPERTY_MAP_TEXTPORTION_EXTENSIONS)) , m_xParentText(xParent) @@ -847,20 +861,20 @@ throw( uno::RuntimeException ) pUnoCrsr->Remove(this); } -void SwXTextPortion::addEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) +void SAL_CALL SwXTextPortion::addEventListener( + const uno::Reference<lang::XEventListener> & xListener) +throw (uno::RuntimeException) { - SolarMutexGuard aGuard; - if(!GetRegisteredIn()) - throw uno::RuntimeException(); - - m_ListenerContainer.AddListener(aListener); + // no need to lock here as m_pImpl is const and container threadsafe + m_pImpl->m_EventListeners.addInterface(xListener); } -void SwXTextPortion::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) +void SAL_CALL SwXTextPortion::removeEventListener( + const uno::Reference<lang::XEventListener> & xListener) +throw (uno::RuntimeException) { - SolarMutexGuard aGuard; - if (!GetRegisteredIn() || !m_ListenerContainer.RemoveListener(aListener)) - throw uno::RuntimeException(); + // no need to lock here as m_pImpl is const and container threadsafe + m_pImpl->m_EventListeners.removeInterface(xListener); } uno::Reference< container::XEnumeration > SwXTextPortion::createContentEnumeration(const OUString& /*aServiceName*/) |