diff options
author | Michael Stahl <mstahl@redhat.com> | 2013-02-03 00:05:59 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2013-02-03 02:14:20 +0100 |
commit | 080dc03a1ee42ca299a7fe10c1887c819ad8926b (patch) | |
tree | da7173a5cfad940d37461a513830f19b4973c5f8 | |
parent | 54c08983cb615fe0474238aacd18284acbc5ec43 (diff) |
sw: replace SwEventListenerContainer in SwXTextTable
OMultiTypeInterfaceContainerHelper appears to be a bit verbose to use...
it needs a notifyEach method at least. But hopefully it will at least
use less memory in case there are no listeners.
Change-Id: I9f72ee8e4ad61f657f565b99cc37126d78b0c5cc
-rw-r--r-- | sw/inc/unotbl.hxx | 8 | ||||
-rw-r--r-- | sw/source/core/unocore/unoobj.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/unocore/unotbl.cxx | 69 |
3 files changed, 52 insertions, 27 deletions
diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx index 88f4bf351fe6..9ba64146e357 100644 --- a/sw/inc/unotbl.hxx +++ b/sw/inc/unotbl.hxx @@ -44,7 +44,6 @@ #include <calbck.hxx> #include <TextCursorHelper.hxx> -#include <unoevtlstnr.hxx> #include <unotext.hxx> @@ -289,9 +288,10 @@ class SwXTextTable : public cppu::WeakImplHelper10 >, public SwClient { - ::osl::Mutex m_Mutex; - ::cppu::OInterfaceContainerHelper m_ChartListeners; - SwEventListenerContainer aLstnrCntnr; +private: + class Impl; + ::sw::UnoImplPtr<Impl> m_pImpl; + const SfxItemPropertySet* m_pPropSet; // Descriptor-interface diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index 91b77471abb7..bce3278ccf5f 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -73,7 +73,7 @@ #include <unomap.hxx> #include <unosett.hxx> #include <unoprnms.hxx> -#include <unotbl.hxx> +#include <unoevtlstnr.hxx> #include <unodraw.hxx> #include <unocoll.hxx> #include <unostyle.hxx> diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 166c2e20bc6c..851a8075f1fa 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -122,6 +122,18 @@ lcl_SendChartEvent(::cppu::OWeakObject & rSource, & chart::XChartDataChangeEventListener::chartDataChanged, event); } +static void +lcl_SendChartEvent(::cppu::OWeakObject & rSource, + ::cppu::OMultiTypeInterfaceContainerHelper & rListeners) +{ + ::cppu::OInterfaceContainerHelper *const pContainer(rListeners.getContainer( + chart::XChartDataChangeEventListener::static_type())); + if (pContainer) + { + lcl_SendChartEvent(rSource, *pContainer); + } +} + static bool lcl_LineToSvxLine(const table::BorderLine& rLine, SvxBorderLine& rSvxLine) { rSvxLine.SetColor(Color(rLine.Color)); @@ -1893,9 +1905,18 @@ void SwXTextTableCursor::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNe /****************************************************************** * SwXTextTable ******************************************************************/ -/**************************************************************************** - Tabellenbeschreibung -****************************************************************************/ + +class SwXTextTable::Impl +{ +private: + ::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper + +public: + ::cppu::OMultiTypeInterfaceContainerHelper m_Listeners; + + Impl() : m_Listeners(m_Mutex) { } +}; + class SwTableProperties_Impl { SwUnoCursorHelper::SwAnyMapHelper aAnyMap; @@ -2129,9 +2150,8 @@ sal_Int64 SAL_CALL SwXTextTable::getSomething( const uno::Sequence< sal_Int8 >& TYPEINIT1(SwXTextTable, SwClient) SwXTextTable::SwXTextTable() - : m_ChartListeners(m_Mutex) + : m_pImpl(new Impl) , - aLstnrCntnr( (text::XTextTable*)this), m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE)), pTableProps(new SwTableProperties_Impl), bIsDescriptor(sal_True), @@ -2144,9 +2164,8 @@ SwXTextTable::SwXTextTable() SwXTextTable::SwXTextTable(SwFrmFmt& rFrmFmt) : SwClient( &rFrmFmt ) - , m_ChartListeners(m_Mutex) + , m_pImpl(new Impl) , - aLstnrCntnr( (text::XTextTable*)this), m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE)), pTableProps(0), bIsDescriptor(sal_False), @@ -2386,17 +2405,22 @@ void SwXTextTable::dispose(void) throw( uno::RuntimeException ) throw uno::RuntimeException(); } -void SwXTextTable::addEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) +void SAL_CALL SwXTextTable::addEventListener( + const uno::Reference<lang::XEventListener> & xListener) +throw (uno::RuntimeException) { - if(!GetRegisteredIn()) - throw uno::RuntimeException(); - aLstnrCntnr.AddListener(aListener); + // no need to lock here as m_pImpl is const and container threadsafe + m_pImpl->m_Listeners.addInterface( + lang::XEventListener::static_type(), xListener); } -void SwXTextTable::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) +void SAL_CALL SwXTextTable::removeEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!GetRegisteredIn() || !aLstnrCntnr.RemoveListener(aListener)) - throw uno::RuntimeException(); + // no need to lock here as m_pImpl is const and container threadsafe + m_pImpl->m_Listeners.removeInterface( + lang::XEventListener::static_type(), xListener); } uno::Reference< table::XCell > SwXTextTable::getCellByPosition(sal_Int32 nColumn, sal_Int32 nRow) @@ -2738,7 +2762,7 @@ void SwXTextTable::setData(const uno::Sequence< uno::Sequence< double > >& rData } if ( bChanged ) { - lcl_SendChartEvent(*this, m_ChartListeners); + lcl_SendChartEvent(*this, m_pImpl->m_Listeners); } } } @@ -2901,7 +2925,8 @@ void SAL_CALL SwXTextTable::addChartDataChangeEventListener( throw (uno::RuntimeException) { // no need to lock here as m_pImpl is const and container threadsafe - m_ChartListeners.addInterface(xListener); + m_pImpl->m_Listeners.addInterface( + chart::XChartDataChangeEventListener::static_type(), xListener); } void SAL_CALL SwXTextTable::removeChartDataChangeEventListener( @@ -2909,7 +2934,8 @@ void SAL_CALL SwXTextTable::removeChartDataChangeEventListener( throw (uno::RuntimeException) { // no need to lock here as m_pImpl is const and container threadsafe - m_ChartListeners.removeInterface(xListener); + m_pImpl->m_Listeners.removeInterface( + chart::XChartDataChangeEventListener::static_type(), xListener); } sal_Bool SwXTextTable::isNotANumber(double nNumber) throw( uno::RuntimeException ) @@ -3033,7 +3059,7 @@ void SwXTextTable::setPropertyValue(const OUString& rPropertyName, sal_Bool bTmp = *(sal_Bool*)aValue.getValue(); if(bFirstRowAsLabel != bTmp) { - lcl_SendChartEvent(*this, m_ChartListeners); + lcl_SendChartEvent(*this, m_pImpl->m_Listeners); bFirstRowAsLabel = bTmp; } } @@ -3043,7 +3069,7 @@ void SwXTextTable::setPropertyValue(const OUString& rPropertyName, sal_Bool bTmp = *(sal_Bool*)aValue.getValue(); if(bFirstColumnAsLabel != bTmp) { - lcl_SendChartEvent(*this, m_ChartListeners); + lcl_SendChartEvent(*this, m_pImpl->m_Listeners); bFirstColumnAsLabel = bTmp; } } @@ -3617,13 +3643,12 @@ void SwXTextTable::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) ClientModify(this, pOld, pNew); if(!GetRegisteredIn()) { - aLstnrCntnr.Disposing(); lang::EventObject const ev(static_cast< ::cppu::OWeakObject&>(*this)); - m_ChartListeners.disposeAndClear(ev); + m_pImpl->m_Listeners.disposeAndClear(ev); } else { - lcl_SendChartEvent(*this, m_ChartListeners); + lcl_SendChartEvent(*this, m_pImpl->m_Listeners); } } |