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

sw: remove class SwChartEventListenerContainer

Change-Id: Ieb1efc28c65e7f191d61beb7f8541564f4fd3e43
üst 750a14f2
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <cppuhelper/implbase5.hxx> #include <cppuhelper/implbase5.hxx>
#include <cppuhelper/implbase7.hxx> #include <cppuhelper/implbase7.hxx>
#include <cppuhelper/implbase10.hxx> #include <cppuhelper/implbase10.hxx>
#include <cppuhelper/interfacecontainer.h>
#include <comphelper/uno3.hxx> #include <comphelper/uno3.hxx>
#include <tools/string.hxx> #include <tools/string.hxx>
...@@ -57,14 +58,6 @@ class SwChartDataProvider; ...@@ -57,14 +58,6 @@ class SwChartDataProvider;
class SwFrmFmt; class SwFrmFmt;
class SwChartEventListenerContainer : public SwEventListenerContainer
{
public:
SwChartEventListenerContainer( ::com::sun::star::uno::XInterface* pxParentL) :
SwEventListenerContainer(pxParentL){}
void ChartDataChanged();
};
typedef typedef
cppu::WeakImplHelper4 cppu::WeakImplHelper4
< <
...@@ -296,8 +289,9 @@ class SwXTextTable : public cppu::WeakImplHelper10 ...@@ -296,8 +289,9 @@ class SwXTextTable : public cppu::WeakImplHelper10
>, >,
public SwClient public SwClient
{ {
::osl::Mutex m_Mutex;
::cppu::OInterfaceContainerHelper m_ChartListeners;
SwEventListenerContainer aLstnrCntnr; SwEventListenerContainer aLstnrCntnr;
SwChartEventListenerContainer aChartLstnrCntnr;
const SfxItemPropertySet* m_pPropSet; const SfxItemPropertySet* m_pPropSet;
// Descriptor-interface // Descriptor-interface
...@@ -416,7 +410,8 @@ class SwXCellRange : public cppu::WeakImplHelper7 ...@@ -416,7 +410,8 @@ class SwXCellRange : public cppu::WeakImplHelper7
public SwClient public SwClient
{ {
SwDepend aCursorDepend; //the cursor is removed after the doc has been removed SwDepend aCursorDepend; //the cursor is removed after the doc has been removed
SwChartEventListenerContainer aChartLstnrCntnr; ::osl::Mutex m_Mutex;
::cppu::OInterfaceContainerHelper m_ChartListeners;
SwRangeDescriptor aRgDesc; SwRangeDescriptor aRgDesc;
const SfxItemPropertySet* m_pPropSet; const SfxItemPropertySet* m_pPropSet;
......
...@@ -106,6 +106,22 @@ extern void sw_GetTblBoxColStr( sal_uInt16 nCol, String& rNm ); ...@@ -106,6 +106,22 @@ extern void sw_GetTblBoxColStr( sal_uInt16 nCol, String& rNm );
#define UNO_TABLE_COLUMN_SUM 10000 #define UNO_TABLE_COLUMN_SUM 10000
static void
lcl_SendChartEvent(::cppu::OWeakObject & rSource,
::cppu::OInterfaceContainerHelper & rListeners)
{
//TODO: find appropriate settings of the Event
chart::ChartDataChangeEvent event;
event.Source = & rSource;
event.Type = chart::ChartDataChangeType_ALL;
event.StartColumn = 0;
event.EndColumn = 1;
event.StartRow = 0;
event.EndRow = 1;
rListeners.notifyEach(
& chart::XChartDataChangeEventListener::chartDataChanged, event);
}
static bool lcl_LineToSvxLine(const table::BorderLine& rLine, SvxBorderLine& rSvxLine) static bool lcl_LineToSvxLine(const table::BorderLine& rLine, SvxBorderLine& rSvxLine)
{ {
rSvxLine.SetColor(Color(rLine.Color)); rSvxLine.SetColor(Color(rLine.Color));
...@@ -2112,9 +2128,10 @@ sal_Int64 SAL_CALL SwXTextTable::getSomething( const uno::Sequence< sal_Int8 >& ...@@ -2112,9 +2128,10 @@ sal_Int64 SAL_CALL SwXTextTable::getSomething( const uno::Sequence< sal_Int8 >&
TYPEINIT1(SwXTextTable, SwClient) TYPEINIT1(SwXTextTable, SwClient)
SwXTextTable::SwXTextTable() : SwXTextTable::SwXTextTable()
: m_ChartListeners(m_Mutex)
,
aLstnrCntnr( (text::XTextTable*)this), aLstnrCntnr( (text::XTextTable*)this),
aChartLstnrCntnr( (text::XTextTable*)this),
m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE)), m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE)),
pTableProps(new SwTableProperties_Impl), pTableProps(new SwTableProperties_Impl),
bIsDescriptor(sal_True), bIsDescriptor(sal_True),
...@@ -2125,10 +2142,11 @@ SwXTextTable::SwXTextTable() : ...@@ -2125,10 +2142,11 @@ SwXTextTable::SwXTextTable() :
{ {
} }
SwXTextTable::SwXTextTable(SwFrmFmt& rFrmFmt) : SwXTextTable::SwXTextTable(SwFrmFmt& rFrmFmt)
SwClient( &rFrmFmt ), : SwClient( &rFrmFmt )
, m_ChartListeners(m_Mutex)
,
aLstnrCntnr( (text::XTextTable*)this), aLstnrCntnr( (text::XTextTable*)this),
aChartLstnrCntnr( (text::XTextTable*)this),
m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE)), m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE)),
pTableProps(0), pTableProps(0),
bIsDescriptor(sal_False), bIsDescriptor(sal_False),
...@@ -2719,7 +2737,9 @@ void SwXTextTable::setData(const uno::Sequence< uno::Sequence< double > >& rData ...@@ -2719,7 +2737,9 @@ void SwXTextTable::setData(const uno::Sequence< uno::Sequence< double > >& rData
} }
} }
if ( bChanged ) if ( bChanged )
aChartLstnrCntnr.ChartDataChanged(); {
lcl_SendChartEvent(*this, m_ChartListeners);
}
} }
} }
...@@ -2876,21 +2896,20 @@ void SwXTextTable::setColumnDescriptions(const uno::Sequence< OUString >& rColum ...@@ -2876,21 +2896,20 @@ void SwXTextTable::setColumnDescriptions(const uno::Sequence< OUString >& rColum
throw uno::RuntimeException(); throw uno::RuntimeException();
} }
void SwXTextTable::addChartDataChangeEventListener( void SAL_CALL SwXTextTable::addChartDataChangeEventListener(
const uno::Reference< chart::XChartDataChangeEventListener > & aListener) const uno::Reference<chart::XChartDataChangeEventListener> & xListener)
throw( uno::RuntimeException ) throw (uno::RuntimeException)
{ {
if(!GetRegisteredIn()) // no need to lock here as m_pImpl is const and container threadsafe
throw uno::RuntimeException(); m_ChartListeners.addInterface(xListener);
aChartLstnrCntnr.AddListener(aListener.get());
} }
void SwXTextTable::removeChartDataChangeEventListener( void SAL_CALL SwXTextTable::removeChartDataChangeEventListener(
const uno::Reference< chart::XChartDataChangeEventListener > & aListener) const uno::Reference<chart::XChartDataChangeEventListener> & xListener)
throw( uno::RuntimeException ) throw (uno::RuntimeException)
{ {
if(!GetRegisteredIn() || !aChartLstnrCntnr.RemoveListener(aListener.get())) // no need to lock here as m_pImpl is const and container threadsafe
throw uno::RuntimeException(); m_ChartListeners.removeInterface(xListener);
} }
sal_Bool SwXTextTable::isNotANumber(double nNumber) throw( uno::RuntimeException ) sal_Bool SwXTextTable::isNotANumber(double nNumber) throw( uno::RuntimeException )
...@@ -3014,7 +3033,7 @@ void SwXTextTable::setPropertyValue(const OUString& rPropertyName, ...@@ -3014,7 +3033,7 @@ void SwXTextTable::setPropertyValue(const OUString& rPropertyName,
sal_Bool bTmp = *(sal_Bool*)aValue.getValue(); sal_Bool bTmp = *(sal_Bool*)aValue.getValue();
if(bFirstRowAsLabel != bTmp) if(bFirstRowAsLabel != bTmp)
{ {
aChartLstnrCntnr.ChartDataChanged(); lcl_SendChartEvent(*this, m_ChartListeners);
bFirstRowAsLabel = bTmp; bFirstRowAsLabel = bTmp;
} }
} }
...@@ -3024,7 +3043,7 @@ void SwXTextTable::setPropertyValue(const OUString& rPropertyName, ...@@ -3024,7 +3043,7 @@ void SwXTextTable::setPropertyValue(const OUString& rPropertyName,
sal_Bool bTmp = *(sal_Bool*)aValue.getValue(); sal_Bool bTmp = *(sal_Bool*)aValue.getValue();
if(bFirstColumnAsLabel != bTmp) if(bFirstColumnAsLabel != bTmp)
{ {
aChartLstnrCntnr.ChartDataChanged(); lcl_SendChartEvent(*this, m_ChartListeners);
bFirstColumnAsLabel = bTmp; bFirstColumnAsLabel = bTmp;
} }
} }
...@@ -3599,10 +3618,13 @@ void SwXTextTable::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) ...@@ -3599,10 +3618,13 @@ void SwXTextTable::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
if(!GetRegisteredIn()) if(!GetRegisteredIn())
{ {
aLstnrCntnr.Disposing(); aLstnrCntnr.Disposing();
aChartLstnrCntnr.Disposing(); lang::EventObject const ev(static_cast< ::cppu::OWeakObject&>(*this));
m_ChartListeners.disposeAndClear(ev);
} }
else else
aChartLstnrCntnr.ChartDataChanged(); {
lcl_SendChartEvent(*this, m_ChartListeners);
}
} }
OUString SAL_CALL SwXTextTable::getImplementationName(void) throw( uno::RuntimeException ) OUString SAL_CALL SwXTextTable::getImplementationName(void) throw( uno::RuntimeException )
...@@ -3676,10 +3698,10 @@ uno::Sequence< OUString > SwXCellRange::getSupportedServiceNames(void) throw( un ...@@ -3676,10 +3698,10 @@ uno::Sequence< OUString > SwXCellRange::getSupportedServiceNames(void) throw( un
SwXCellRange::SwXCellRange(SwUnoCrsr* pCrsr, SwFrmFmt& rFrmFmt, SwXCellRange::SwXCellRange(SwUnoCrsr* pCrsr, SwFrmFmt& rFrmFmt,
SwRangeDescriptor& rDesc) SwRangeDescriptor& rDesc)
: : SwClient(&rFrmFmt)
SwClient(&rFrmFmt), , aCursorDepend(this, pCrsr)
aCursorDepend(this, pCrsr), , m_ChartListeners(m_Mutex)
aChartLstnrCntnr((cppu::OWeakObject*)this), ,
aRgDesc(rDesc), aRgDesc(rDesc),
m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TABLE_RANGE)), m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TABLE_RANGE)),
pTblCrsr(pCrsr), pTblCrsr(pCrsr),
...@@ -3880,7 +3902,7 @@ void SwXCellRange::setPropertyValue(const OUString& rPropertyName, ...@@ -3880,7 +3902,7 @@ void SwXCellRange::setPropertyValue(const OUString& rPropertyName,
sal_Bool bTmp = *(sal_Bool*)aValue.getValue(); sal_Bool bTmp = *(sal_Bool*)aValue.getValue();
if(bFirstRowAsLabel != bTmp) if(bFirstRowAsLabel != bTmp)
{ {
aChartLstnrCntnr.ChartDataChanged(); lcl_SendChartEvent(*this, m_ChartListeners);
bFirstRowAsLabel = bTmp; bFirstRowAsLabel = bTmp;
} }
} }
...@@ -3890,7 +3912,7 @@ void SwXCellRange::setPropertyValue(const OUString& rPropertyName, ...@@ -3890,7 +3912,7 @@ void SwXCellRange::setPropertyValue(const OUString& rPropertyName,
sal_Bool bTmp = *(sal_Bool*)aValue.getValue(); sal_Bool bTmp = *(sal_Bool*)aValue.getValue();
if(bFirstColumnAsLabel != bTmp) if(bFirstColumnAsLabel != bTmp)
{ {
aChartLstnrCntnr.ChartDataChanged(); lcl_SendChartEvent(*this, m_ChartListeners);
bFirstColumnAsLabel = bTmp; bFirstColumnAsLabel = bTmp;
} }
} }
...@@ -4517,17 +4539,20 @@ void SwXCellRange::setColumnDescriptions(const uno::Sequence< OUString >& Column ...@@ -4517,17 +4539,20 @@ void SwXCellRange::setColumnDescriptions(const uno::Sequence< OUString >& Column
} }
} }
void SwXCellRange::addChartDataChangeEventListener(const uno::Reference< chart::XChartDataChangeEventListener > & aListener) throw( uno::RuntimeException ) void SAL_CALL SwXCellRange::addChartDataChangeEventListener(
const uno::Reference<chart::XChartDataChangeEventListener> & xListener)
throw (uno::RuntimeException)
{ {
if(!GetRegisteredIn()) // no need to lock here as m_pImpl is const and container threadsafe
throw uno::RuntimeException(); m_ChartListeners.addInterface(xListener);
aChartLstnrCntnr.AddListener(aListener.get());
} }
void SwXCellRange::removeChartDataChangeEventListener(const uno::Reference< chart::XChartDataChangeEventListener > & aListener) throw( uno::RuntimeException ) void SAL_CALL SwXCellRange::removeChartDataChangeEventListener(
const uno::Reference<chart::XChartDataChangeEventListener> & xListener)
throw (uno::RuntimeException)
{ {
if(!GetRegisteredIn() || !aChartLstnrCntnr.RemoveListener(aListener.get())) // no need to lock here as m_pImpl is const and container threadsafe
throw uno::RuntimeException(); m_ChartListeners.removeInterface(xListener);
} }
sal_Bool SwXCellRange::isNotANumber(double /*fNumber*/) throw( uno::RuntimeException ) sal_Bool SwXCellRange::isNotANumber(double /*fNumber*/) throw( uno::RuntimeException )
...@@ -4597,10 +4622,13 @@ void SwXCellRange::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) ...@@ -4597,10 +4622,13 @@ void SwXCellRange::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
delete pTblCrsr; delete pTblCrsr;
*/ */
pTblCrsr = 0; pTblCrsr = 0;
aChartLstnrCntnr.Disposing(); lang::EventObject const ev(static_cast< ::cppu::OWeakObject&>(*this));
m_ChartListeners.disposeAndClear(ev);
} }
else else
aChartLstnrCntnr.ChartDataChanged(); {
lcl_SendChartEvent(*this, m_ChartListeners);
}
} }
/****************************************************************** /******************************************************************
...@@ -5028,33 +5056,4 @@ void SwXTableColumns::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) ...@@ -5028,33 +5056,4 @@ void SwXTableColumns::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
ClientModify(this, pOld, pNew); ClientModify(this, pOld, pNew);
} }
void SwChartEventListenerContainer::ChartDataChanged()
{
if(pListenerArr)
{
//TODO: find appropriate settings of the Event
lang::EventObject aObj(pxParent);
chart::ChartDataChangeEvent aEvent;
aEvent.Type = chart::ChartDataChangeType_ALL;
aEvent.StartColumn = 0;
aEvent.EndColumn = 1;
aEvent.StartRow = 0;
aEvent.EndRow = 1;
for(sal_uInt16 i = 0; i < pListenerArr->size(); i++)
{
try
{
XEventListenerPtr pElem = (*pListenerArr)[i];
uno::Reference<lang::XEventListener> xEventListener = *pElem;
uno::Reference<chart::XChartDataChangeEventListener> xChartEventListener = (chart::XChartDataChangeEventListener*)(*pElem).get();
xChartEventListener->chartDataChanged( aEvent );
}
catch(uno::Exception const &)
{
}
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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