diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-24 16:31:20 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-25 07:33:17 +0200 |
commit | 244677ccf72cfbd778e297f2b464df8df56027c6 (patch) | |
tree | ca22b6a9407c9b54981c6cefc279714673f5b8c8 /sw | |
parent | b4adb0c533cc99633f360cb12014aa35599d943a (diff) |
use rtl::Reference in SwChartDataSequence
instead of storing both a raw pointer and an uno::Reference
Change-Id: I828ad411c989f14a9175ab173f1a4fe75fed535f
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/unochart.hxx | 8 | ||||
-rw-r--r-- | sw/source/core/unocore/unochart.cxx | 19 |
2 files changed, 11 insertions, 16 deletions
diff --git a/sw/inc/unochart.hxx b/sw/inc/unochart.hxx index 24523ce388da..944c869b48b6 100644 --- a/sw/inc/unochart.hxx +++ b/sw/inc/unochart.hxx @@ -46,6 +46,7 @@ #include <cppuhelper/implbase.hxx> #include <cppuhelper/weakref.hxx> +#include <rtl/ref.hxx> #include <tools/link.hxx> #include <vcl/timer.hxx> @@ -250,15 +251,12 @@ class SwChartDataSequence : { ::comphelper::OInterfaceContainerHelper2 m_aEvtListeners; ::comphelper::OInterfaceContainerHelper2 m_aModifyListeners; - css::chart2::data::DataSequenceRole m_aRole; + css::chart2::data::DataSequenceRole m_aRole; OUString m_aRowLabelText; OUString m_aColLabelText; - // holds a reference to the data-provider to guarantee its lifetime last as - // long as the pointer may be used. - css::uno::Reference< css::chart2::data::XDataProvider > m_xDataProvider; - SwChartDataProvider * m_pDataProvider; + rtl::Reference<SwChartDataProvider> m_xDataProvider; sw::UnoCursorPointer m_pTableCursor; // cursor spanned over cells to use diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx index 11e8fdb57068..786f12ad0ca4 100644 --- a/sw/source/core/unocore/unochart.cxx +++ b/sw/source/core/unocore/unochart.cxx @@ -1889,7 +1889,6 @@ SwChartDataSequence::SwChartDataSequence( m_aRowLabelText( SW_RES( STR_CHART2_ROW_LABEL_TEXT ) ), m_aColLabelText( SW_RES( STR_CHART2_COL_LABEL_TEXT ) ), m_xDataProvider( &rProvider ), - m_pDataProvider( &rProvider ), m_pTableCursor( pTableCursor ), m_pPropSet( aSwMapProvider.GetPropertySet( PROPERTY_MAP_CHART2_DATA_SEQUENCE ) ) { @@ -1902,8 +1901,8 @@ SwChartDataSequence::SwChartDataSequence( if (pTable) { uno::Reference< chart2::data::XDataSequence > xRef( dynamic_cast< chart2::data::XDataSequence * >(this), uno::UNO_QUERY ); - m_pDataProvider->AddDataSequence( *pTable, xRef ); - m_pDataProvider->addEventListener( dynamic_cast< lang::XEventListener * >(this) ); + m_xDataProvider->AddDataSequence( *pTable, xRef ); + m_xDataProvider->addEventListener( dynamic_cast< lang::XEventListener * >(this) ); } else { OSL_FAIL( "table missing" ); @@ -1936,8 +1935,7 @@ SwChartDataSequence::SwChartDataSequence( const SwChartDataSequence &rObj ) : m_aRole( rObj.m_aRole ), m_aRowLabelText( SW_RES(STR_CHART2_ROW_LABEL_TEXT) ), m_aColLabelText( SW_RES(STR_CHART2_COL_LABEL_TEXT) ), - m_xDataProvider( rObj.m_pDataProvider ), - m_pDataProvider( rObj.m_pDataProvider ), + m_xDataProvider( rObj.m_xDataProvider ), m_pTableCursor( rObj.m_pTableCursor ), m_pPropSet( rObj.m_pPropSet ) { @@ -1950,8 +1948,8 @@ SwChartDataSequence::SwChartDataSequence( const SwChartDataSequence &rObj ) : if (pTable) { uno::Reference< chart2::data::XDataSequence > xRef( dynamic_cast< chart2::data::XDataSequence * >(this), uno::UNO_QUERY ); - m_pDataProvider->AddDataSequence( *pTable, xRef ); - m_pDataProvider->addEventListener( dynamic_cast< lang::XEventListener * >(this) ); + m_xDataProvider->AddDataSequence( *pTable, xRef ); + m_xDataProvider->addEventListener( dynamic_cast< lang::XEventListener * >(this) ); } else { OSL_FAIL( "table missing" ); @@ -2358,9 +2356,8 @@ void SAL_CALL SwChartDataSequence::disposing( const lang::EventObject& rSource ) { if (m_bDisposed) throw lang::DisposedException(); - if (rSource.Source == m_xDataProvider) + if (rSource.Source == static_cast<cppu::OWeakObject*>(m_xDataProvider.get())) { - m_pDataProvider = nullptr; m_xDataProvider.clear(); } } @@ -2378,13 +2375,13 @@ void SAL_CALL SwChartDataSequence::dispose( ) if (bMustDispose) { m_bDisposed = true; - if (m_pDataProvider) + if (m_xDataProvider.is()) { const SwTable* pTable = SwTable::FindTable( GetFrameFormat() ); if (pTable) { uno::Reference< chart2::data::XDataSequence > xRef( dynamic_cast< chart2::data::XDataSequence * >(this), uno::UNO_QUERY ); - m_pDataProvider->RemoveDataSequence( *pTable, xRef ); + m_xDataProvider->RemoveDataSequence( *pTable, xRef ); } else { OSL_FAIL( "table missing" ); |