diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2022-01-15 22:03:55 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-01-16 12:29:27 +0100 |
commit | 5a4b75dcb5abc2e925870614a28e1c2876df8ed9 (patch) | |
tree | 5fe1f89c70f9c6d90d3eea8f9eb9a68e91f2dec0 /chart2 | |
parent | dab0d4e1f36faace21145a51733bd3a946992624 (diff) |
use more concrete types in chart2, Diagram
Change-Id: Iae84e16b3406f4c08139764a1838e38b13cebee7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128471
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2')
20 files changed, 87 insertions, 69 deletions
diff --git a/chart2/inc/ChartModel.hxx b/chart2/inc/ChartModel.hxx index b3d1d3f42ce9..4717b30a9cbe 100644 --- a/chart2/inc/ChartModel.hxx +++ b/chart2/inc/ChartModel.hxx @@ -69,6 +69,7 @@ class SvNumberFormatter; namespace chart { +class Diagram; namespace impl { @@ -158,8 +159,7 @@ private: m_xChartTypeManager; // Diagram Access - css::uno::Reference< css::chart2::XDiagram > - m_xDiagram; + rtl::Reference< ::chart::Diagram > m_xDiagram; css::uno::Reference< css::chart2::XTitle > m_xTitle; @@ -456,6 +456,8 @@ public: ChartView* getChartView() const; + const rtl::Reference< ::chart::Diagram > & getFirstChartDiagram() { return m_xDiagram; } + bool isTimeBased() const { return mbTimeBased;} void setTimeBasedRange(sal_Int32 nStart, sal_Int32 nEnd); diff --git a/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx b/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx index 37835448d14e..db3e413ba919 100644 --- a/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx @@ -581,7 +581,7 @@ Reference< chart2::XAxis > AxisWrapper::getAxis() bool bMainAxis = true; AxisWrapper::getDimensionAndMainAxisBool( m_eType, nDimensionIndex, bMainAxis ); - Reference< XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); xAxis = AxisHelper::getAxis( nDimensionIndex, bMainAxis, xDiagram ); if( !xAxis.is() ) { diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx index 8759cc6f54b7..9ce03b9cc8a7 100644 --- a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx +++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx @@ -31,6 +31,7 @@ #include <ChartModel.hxx> #include <comphelper/servicehelper.hxx> +#include <tools/diagnose_ex.h> using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; @@ -82,9 +83,19 @@ rtl::Reference< ChartModel > Chart2ModelContact::getDocumentModel() const return m_xChartModel; } -Reference< chart2::XDiagram > Chart2ModelContact::getChart2Diagram() const +rtl::Reference< ::chart::Diagram > Chart2ModelContact::getDiagram() const { - return ChartModelHelper::findDiagram( uno::Reference<XChartDocument>(m_xChartModel.get()) ); + try + { + rtl::Reference<ChartModel> xChartModel = getDocumentModel(); + if( xChartModel) + return xChartModel->getFirstChartDiagram(); + } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); + } + return nullptr; } uno::Reference< lang::XUnoTunnel > const & Chart2ModelContact::getChartView() const diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx index 3b1cef1e2412..c0f7185fe4ed 100644 --- a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx +++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx @@ -26,6 +26,7 @@ #include <svx/unopage.hxx> #include <unotools/weakref.hxx> #include <ChartModel.hxx> +#include <Diagram.hxx> #include <map> namespace chart { struct ExplicitIncrementData; } @@ -62,7 +63,7 @@ public: rtl::Reference<ChartModel> getDocumentModel() const; - css::uno::Reference< css::chart2::XDiagram > getChart2Diagram() const; + rtl::Reference< ::chart::Diagram > getDiagram() const; rtl::Reference<SvxDrawPage> getDrawPage() const; diff --git a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx index b2c819a87874..e49239935c6d 100644 --- a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx @@ -325,7 +325,7 @@ void WrappedAttachedAxisProperty::setPropertyValue( const Any& rOuterValue, cons if( bNewAttachedToMainAxis != bOldAttachedToMainAxis) { - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( xDiagram.is() ) ::chart::DiagramHelper::attachSeriesToAxis( bNewAttachedToMainAxis, xDataSeries, xDiagram, m_spChart2ModelContact->m_xContext, false ); } @@ -537,7 +537,7 @@ void SAL_CALL DataSeriesPointWrapper::disposing( const lang::EventObject& /*Sour bool DataSeriesPointWrapper::isSupportingAreaProperties() { Reference< chart2::XDataSeries > xSeries( getDataSeries() ); - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) ); sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); @@ -549,7 +549,7 @@ Reference< chart2::XDataSeries > DataSeriesPointWrapper::getDataSeries() Reference< chart2::XDataSeries > xSeries( m_xDataSeries ); if( !xSeries.is() ) { - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); std::vector< uno::Reference< chart2::XDataSeries > > aSeriesList( ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram ) ); @@ -849,7 +849,7 @@ Any SAL_CALL DataSeriesPointWrapper::getPropertyValue( const OUString& rProperty uno::Reference< beans::XPropertyState > xPointState( DataSeriesPointWrapper::getDataPointProperties(), uno::UNO_QUERY ); if( xPointState.is() && xPointState->getPropertyState("Color") == beans::PropertyState_DEFAULT_VALUE ) { - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( xDiagram.is() ) { Reference< chart2::XColorScheme > xColorScheme( xDiagram->getDefaultColorScheme() ); diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx index cb19a9b4a578..1f1e159f23f5 100644 --- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx @@ -585,7 +585,7 @@ OUString SAL_CALL DiagramWrapper::getDiagramType() OUString aRet; rtl::Reference< ChartModel > xChartDoc( m_spChart2ModelContact->getDocumentModel() ); - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( xChartDoc.is() && xDiagram.is() ) { Reference< beans::XPropertySet > xChartDocProp( static_cast<cppu::OWeakObject*>(xChartDoc.get()), uno::UNO_QUERY ); @@ -632,7 +632,7 @@ Reference< throw lang::IndexOutOfBoundsException("DataSeries index invalid", static_cast< ::cppu::OWeakObject * >( this )); - sal_Int32 nNewAPIIndex = lcl_getNewAPIIndexForOldAPIIndex( nRow, m_spChart2ModelContact->getChart2Diagram() ); + sal_Int32 nNewAPIIndex = lcl_getNewAPIIndexForOldAPIIndex( nRow, m_spChart2ModelContact->getDiagram() ); if( nNewAPIIndex < 0 ) throw lang::IndexOutOfBoundsException("DataSeries index invalid", static_cast< ::cppu::OWeakObject * >( this )); @@ -649,7 +649,7 @@ Reference< throw lang::IndexOutOfBoundsException("DataSeries index invalid", static_cast< ::cppu::OWeakObject * >( this )); - sal_Int32 nNewAPIIndex = lcl_getNewAPIIndexForOldAPIIndex( nRow, m_spChart2ModelContact->getChart2Diagram() ); + sal_Int32 nNewAPIIndex = lcl_getNewAPIIndexForOldAPIIndex( nRow, m_spChart2ModelContact->getDiagram() ); if( nNewAPIIndex < 0 ) throw lang::IndexOutOfBoundsException("DataSeries index invalid", static_cast< ::cppu::OWeakObject * >( this )); @@ -1042,21 +1042,21 @@ Reference< // ____ X3DDefaultSetter ____ void SAL_CALL DiagramWrapper::set3DSettingsToDefault() { - Reference< X3DDefaultSetter > x3DDefaultSetter( m_spChart2ModelContact->getChart2Diagram(), uno::UNO_QUERY ); + rtl::Reference< ::chart::Diagram > x3DDefaultSetter( m_spChart2ModelContact->getDiagram() ); if( x3DDefaultSetter.is() ) x3DDefaultSetter->set3DSettingsToDefault(); } void SAL_CALL DiagramWrapper::setDefaultRotation() { - Reference< X3DDefaultSetter > x3DDefaultSetter( m_spChart2ModelContact->getChart2Diagram(), uno::UNO_QUERY ); + rtl::Reference< ::chart::Diagram > x3DDefaultSetter( m_spChart2ModelContact->getDiagram() ); if( x3DDefaultSetter.is() ) x3DDefaultSetter->setDefaultRotation(); } void SAL_CALL DiagramWrapper::setDefaultIllumination() { - Reference< X3DDefaultSetter > x3DDefaultSetter( m_spChart2ModelContact->getChart2Diagram(), uno::UNO_QUERY ); + rtl::Reference< ::chart::Diagram > x3DDefaultSetter( m_spChart2ModelContact->getDiagram() ); if( x3DDefaultSetter.is() ) x3DDefaultSetter->setDefaultIllumination(); } @@ -1238,7 +1238,7 @@ bool WrappedStackingProperty::detectInnerValue( StackMode& eStackMode ) const { bool bHasDetectableInnerValue = false; bool bIsAmbiguous = false; - eStackMode = DiagramHelper::getStackMode( m_spChart2ModelContact->getChart2Diagram() + eStackMode = DiagramHelper::getStackMode( m_spChart2ModelContact->getDiagram() , bHasDetectableInnerValue, bIsAmbiguous ); return bHasDetectableInnerValue; } @@ -1263,7 +1263,7 @@ void WrappedStackingProperty::setPropertyValue( const Any& rOuterValue, const Re if( !bNewValue && eInnerStackMode != m_eStackMode ) return; - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( xDiagram.is() ) { StackMode eNewStackMode = bNewValue ? m_eStackMode : StackMode::NONE; @@ -1325,7 +1325,7 @@ void WrappedDim3DProperty::setPropertyValue( const Any& rOuterValue, const Refer m_aOuterValue = rOuterValue; - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( !xDiagram.is() ) return; @@ -1336,7 +1336,7 @@ void WrappedDim3DProperty::setPropertyValue( const Any& rOuterValue, const Refer Any WrappedDim3DProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const { - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( xDiagram.is() ) { bool b3D = DiagramHelper::getDimension( xDiagram ) == 3; @@ -1388,7 +1388,7 @@ void WrappedVerticalProperty::setPropertyValue( const Any& rOuterValue, const Re m_aOuterValue = rOuterValue; - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( !xDiagram.is() ) return; @@ -1401,7 +1401,7 @@ void WrappedVerticalProperty::setPropertyValue( const Any& rOuterValue, const Re Any WrappedVerticalProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const { - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( xDiagram.is() ) { bool bFound = false; @@ -1455,7 +1455,7 @@ bool WrappedNumberOfLinesProperty::detectInnerValue( uno::Any& rInnerValue ) con { sal_Int32 nNumberOfLines = 0; bool bHasDetectableInnerValue = false; - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); rtl::Reference< ChartModel > xChartDoc( m_spChart2ModelContact->getDocumentModel() ); if( xDiagram.is() && xChartDoc.is() ) { @@ -1495,7 +1495,7 @@ void WrappedNumberOfLinesProperty::setPropertyValue( const Any& rOuterValue, con m_aOuterValue = rOuterValue; rtl::Reference< ChartModel > xChartDoc( m_spChart2ModelContact->getDocumentModel() ); - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); sal_Int32 nDimension = ::chart::DiagramHelper::getDimension( xDiagram ); if( !(xChartDoc.is() && xDiagram.is() && nDimension == 2) ) return; @@ -1603,10 +1603,9 @@ void WrappedAttributedDataPointsProperty::setPropertyValue( const Any& rOuterVal m_aOuterValue = rOuterValue; - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); - Reference< beans::XPropertySet > xDiaProp( xDiagram, uno::UNO_QUERY ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); - if( !(xDiagram.is() && xDiaProp.is())) + if( !xDiagram ) return; std::vector< Reference< chart2::XDataSeries > > aSeriesVector( @@ -1634,10 +1633,9 @@ void WrappedAttributedDataPointsProperty::setPropertyValue( const Any& rOuterVal Any WrappedAttributedDataPointsProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const { - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); - Reference< beans::XPropertySet > xDiaProp( xDiagram, uno::UNO_QUERY ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); - if( xDiagram.is() && xDiaProp.is()) + if( xDiagram ) { std::vector< Reference< chart2::XDataSeries > > aSeriesVector( ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram ) ); @@ -1707,7 +1705,7 @@ void WrappedSolidTypeProperty::setPropertyValue( const Any& rOuterValue, const R m_aOuterValue = rOuterValue; - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( !xDiagram.is() ) return; @@ -1720,7 +1718,7 @@ void WrappedSolidTypeProperty::setPropertyValue( const Any& rOuterValue, const R Any WrappedSolidTypeProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const { - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( xDiagram.is() ) { bool bFound = false; @@ -1842,7 +1840,7 @@ Any WrappedIncludeHiddenCellsProperty::getPropertyValue( const Reference< beans: // ____ XDiagramProvider ____ Reference< chart2::XDiagram > SAL_CALL DiagramWrapper::getDiagram() { - return m_spChart2ModelContact->getChart2Diagram(); + return m_spChart2ModelContact->getDiagram(); } void SAL_CALL DiagramWrapper::setDiagram( @@ -1854,7 +1852,7 @@ void SAL_CALL DiagramWrapper::setDiagram( Reference< beans::XPropertySet > DiagramWrapper::getInnerPropertySet() { - return Reference< beans::XPropertySet >( m_spChart2ModelContact->getChart2Diagram(), uno::UNO_QUERY ); + return m_spChart2ModelContact->getDiagram(); } const Sequence< beans::Property >& DiagramWrapper::getPropertySequence() diff --git a/chart2/source/controller/chartapiwrapper/GridWrapper.cxx b/chart2/source/controller/chartapiwrapper/GridWrapper.cxx index 649086a1a458..6c88024a7d08 100644 --- a/chart2/source/controller/chartapiwrapper/GridWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/GridWrapper.cxx @@ -131,7 +131,7 @@ Reference< beans::XPropertySet > GridWrapper::getInnerPropertySet() Reference< beans::XPropertySet > xRet; try { - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); uno::Reference< XCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 /*nCooSysIndex*/ ) ); sal_Int32 nDimensionIndex = 1; diff --git a/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx b/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx index 01dc74e7b7be..ca5a25005152 100644 --- a/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx @@ -370,7 +370,7 @@ awt::Size LegendWrapper::getCurrentSizeForReference() Reference< beans::XPropertySet > LegendWrapper::getInnerPropertySet() { Reference< beans::XPropertySet > xRet; - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( xDiagram.is() ) xRet.set( xDiagram->getLegend(), uno::UNO_QUERY ); OSL_ENSURE(xRet.is(),"LegendWrapper::getInnerPropertySet() is NULL"); diff --git a/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx b/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx index 379cc408f52e..516a96b2a042 100644 --- a/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx @@ -156,7 +156,7 @@ void SAL_CALL MinMaxLineWrapper::setPropertyValue( const OUString& rPropertyName { Reference< beans::XPropertySet > xPropSet; - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); const Sequence< Reference< chart2::XChartType > > aTypes( ::chart::DiagramHelper::getChartTypesFromDiagram( xDiagram ) ); for( Reference< chart2::XChartType > const & xType : aTypes ) @@ -193,7 +193,7 @@ uno::Any SAL_CALL MinMaxLineWrapper::getPropertyValue( const OUString& rProperty Reference< beans::XPropertySet > xPropSet; - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); const Sequence< Reference< chart2::XChartType > > aTypes( ::chart::DiagramHelper::getChartTypesFromDiagram( xDiagram ) ); for( Reference< chart2::XChartType > const & xType : aTypes ) diff --git a/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx b/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx index 33c53f89a514..2922f91c466b 100644 --- a/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx @@ -163,7 +163,7 @@ void SAL_CALL UpDownBarWrapper::setPropertyValue( const OUString& rPropertyName, Reference< beans::XPropertySet > xPropSet; const Sequence< Reference< chart2::XChartType > > aTypes( - ::chart::DiagramHelper::getChartTypesFromDiagram( m_spChart2ModelContact->getChart2Diagram() ) ); + ::chart::DiagramHelper::getChartTypesFromDiagram( m_spChart2ModelContact->getDiagram() ) ); for( Reference< chart2::XChartType > const & xType : aTypes ) { if( xType->getChartType() == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ) @@ -185,7 +185,7 @@ uno::Any SAL_CALL UpDownBarWrapper::getPropertyValue( const OUString& rPropertyN Reference< beans::XPropertySet > xPropSet; const Sequence< Reference< chart2::XChartType > > aTypes( - ::chart::DiagramHelper::getChartTypesFromDiagram( m_spChart2ModelContact->getChart2Diagram() ) ); + ::chart::DiagramHelper::getChartTypesFromDiagram( m_spChart2ModelContact->getDiagram() ) ); for( Reference< chart2::XChartType > const & xType : aTypes ) { if( xType->getChartType() == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ) diff --git a/chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx b/chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx index daa0f1de4f20..711f68201727 100644 --- a/chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx @@ -113,7 +113,7 @@ Reference< beans::XPropertySet > WallFloorWrapper::getInnerPropertySet() { Reference< beans::XPropertySet > xRet; - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( xDiagram.is() ) { if( m_bWall ) diff --git a/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.cxx index 4a43b4ccfbb1..a02ff69f2cc8 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.cxx @@ -157,7 +157,7 @@ void WrappedAxisAndGridExistenceProperty::setPropertyValue( const Any& rOuterVal if( bOldValue == bNewValue ) return; - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( bNewValue ) { if( m_bAxis ) @@ -177,7 +177,7 @@ void WrappedAxisAndGridExistenceProperty::setPropertyValue( const Any& rOuterVal Any WrappedAxisAndGridExistenceProperty::getPropertyValue( const Reference< beans::XPropertySet >& /* xInnerPropertySet */ ) const { Any aRet; - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if(m_bAxis) { bool bShown = AxisHelper::isAxisShown( m_nDimensionIndex, m_bMain, xDiagram ); @@ -370,7 +370,7 @@ void WrappedAxisLabelExistenceProperty::setPropertyValue( const Any& rOuterValue if( bOldValue == bNewValue ) return; - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); Reference< beans::XPropertySet > xProp( AxisHelper::getAxis( m_nDimensionIndex, m_bMain, xDiagram ), uno::UNO_QUERY ); if( !xProp.is() && bNewValue ) { @@ -386,7 +386,7 @@ void WrappedAxisLabelExistenceProperty::setPropertyValue( const Any& rOuterValue Any WrappedAxisLabelExistenceProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const { Any aRet; - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); Reference< beans::XPropertySet > xProp( AxisHelper::getAxis( m_nDimensionIndex, m_bMain, xDiagram ), uno::UNO_QUERY ); if( xProp.is() ) aRet = xProp->getPropertyValue( "DisplayLabels" ); diff --git a/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx index 867176e62e32..c0f100d335a7 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx @@ -65,7 +65,7 @@ void WrappedBarPositionProperty_Base::setPropertyValue( const Any& rOuterValue, m_aOuterValue = rOuterValue; - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( !xDiagram.is() ) return; @@ -107,7 +107,7 @@ void WrappedBarPositionProperty_Base::setPropertyValue( const Any& rOuterValue, Any WrappedBarPositionProperty_Base::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const { - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( xDiagram.is() ) { bool bInnerValueDetected = false; diff --git a/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.cxx index d3a883429172..2430dcba7ac6 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.cxx @@ -48,7 +48,7 @@ WrappedD3DTransformMatrixProperty::~WrappedD3DTransformMatrixProperty() void WrappedD3DTransformMatrixProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const { - if( DiagramHelper::isPieOrDonutChart( m_spChart2ModelContact->getChart2Diagram() ) ) + if( DiagramHelper::isPieOrDonutChart( m_spChart2ModelContact->getDiagram() ) ) { drawing::HomogenMatrix aHM; if( rOuterValue >>= aHM ) @@ -73,7 +73,7 @@ void WrappedD3DTransformMatrixProperty::setPropertyValue( const Any& rOuterValue Any WrappedD3DTransformMatrixProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const { - if( DiagramHelper::isPieOrDonutChart( m_spChart2ModelContact->getChart2Diagram() ) ) + if( DiagramHelper::isPieOrDonutChart( m_spChart2ModelContact->getDiagram() ) ) { uno::Any aAMatrix( WrappedProperty::getPropertyValue( xInnerPropertySet ) ); drawing::HomogenMatrix aHM; diff --git a/chart2/source/controller/chartapiwrapper/WrappedSeriesOrDiagramProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedSeriesOrDiagramProperty.hxx index 7eb90e8b932b..88dc862ea2d9 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedSeriesOrDiagramProperty.hxx +++ b/chart2/source/controller/chartapiwrapper/WrappedSeriesOrDiagramProperty.hxx @@ -64,7 +64,7 @@ public: m_spChart2ModelContact ) { std::vector< css::uno::Reference< css::chart2::XDataSeries > > aSeriesVector( - ::chart::DiagramHelper::getDataSeriesFromDiagram( m_spChart2ModelContact->getChart2Diagram() ) ); + ::chart::DiagramHelper::getDataSeriesFromDiagram( m_spChart2ModelContact->getDiagram() ) ); for (auto const& series : aSeriesVector) { PROPERTYTYPE aCurValue = getValueFromSeries( css::uno::Reference< css::beans::XPropertySet >::query(series) ); @@ -91,7 +91,7 @@ public: m_spChart2ModelContact ) { std::vector< css::uno::Reference< css::chart2::XDataSeries > > aSeriesVector( - ::chart::DiagramHelper::getDataSeriesFromDiagram( m_spChart2ModelContact->getChart2Diagram() ) ); + ::chart::DiagramHelper::getDataSeriesFromDiagram( m_spChart2ModelContact->getDiagram() ) ); for (auto const& series : aSeriesVector) { css::uno::Reference< css::beans::XPropertySet > xSeriesPropertySet(series, css::uno::UNO_QUERY); diff --git a/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx index ad07a98bcd15..6d088a50bd81 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx @@ -63,7 +63,7 @@ public: bool bHasDetectableInnerValue = false; rHasAmbiguousValue = false; Sequence< css::uno::Reference< css::chart2::XChartType > > aChartTypes( - ::chart::DiagramHelper::getChartTypesFromDiagram( m_spChart2ModelContact->getChart2Diagram() ) ); + ::chart::DiagramHelper::getChartTypesFromDiagram( m_spChart2ModelContact->getDiagram() ) ); for( sal_Int32 nN = aChartTypes.getLength(); nN--; ) { try @@ -115,7 +115,7 @@ public: return; Sequence< css::uno::Reference< css::chart2::XChartType > > aChartTypes( - ::chart::DiagramHelper::getChartTypesFromDiagram( m_spChart2ModelContact->getChart2Diagram() ) ); + ::chart::DiagramHelper::getChartTypesFromDiagram( m_spChart2ModelContact->getDiagram() ) ); for( sal_Int32 nN = aChartTypes.getLength(); nN--; ) { try diff --git a/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx index 4dc252cc5a4c..9dba30e36030 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx @@ -76,7 +76,7 @@ void WrappedStockProperty::setPropertyValue( const css::uno::Any& rOuterValue, c m_aOuterValue = rOuterValue; rtl::Reference< ChartModel > xChartDoc( m_spChart2ModelContact->getDocumentModel() ); - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); sal_Int32 nDimension = ::chart::DiagramHelper::getDimension( xDiagram ); if( !(xChartDoc.is() && xDiagram.is() && nDimension==2) ) return; @@ -130,7 +130,7 @@ WrappedVolumeProperty::WrappedVolumeProperty(const std::shared_ptr<Chart2ModelCo css::uno::Any WrappedVolumeProperty::getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& /*xInnerPropertySet*/ ) const { rtl::Reference< ChartModel > xChartDoc( m_spChart2ModelContact->getDocumentModel() ); - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( xDiagram.is() && xChartDoc.is() ) { std::vector< uno::Reference< chart2::XDataSeries > > aSeriesVector( @@ -199,7 +199,7 @@ WrappedUpDownProperty::WrappedUpDownProperty(const std::shared_ptr<Chart2ModelCo css::uno::Any WrappedUpDownProperty::getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& /*xInnerPropertySet*/ ) const { rtl::Reference< ChartModel > xChartDoc( m_spChart2ModelContact->getDocumentModel() ); - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( xDiagram.is() && xChartDoc.is() ) { std::vector< uno::Reference< chart2::XDataSeries > > aSeriesVector( diff --git a/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx index d27f05350732..484861b68338 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx @@ -284,7 +284,7 @@ beans::PropertyState WrappedSymbolTypeProperty::getPropertyState( const Referenc if( m_ePropertyType == DATA_SERIES && //single series or point m_spChart2ModelContact) { - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); Reference< chart2::XDataSeries > xSeries( xInnerPropertyState, uno::UNO_QUERY ); Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) ); if( ChartTypeHelper::isSupportingSymbolProperties( xChartType, 2 ) ) diff --git a/chart2/source/model/inc/Diagram.hxx b/chart2/source/inc/Diagram.hxx index 2fa8485f6a76..0235d52853c6 100644 --- a/chart2/source/model/inc/Diagram.hxx +++ b/chart2/source/inc/Diagram.hxx @@ -18,7 +18,7 @@ */ #pragma once -#include <OPropertySet.hxx> +#include "OPropertySet.hxx" #include <cppuhelper/basemutex.hxx> #include <cppuhelper/implbase.hxx> #include <comphelper/uno3.hxx> @@ -28,7 +28,8 @@ #include <com/sun/star/chart/X3DDefaultSetter.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/util/XCloneable.hpp> -#include <ModifyListenerHelper.hxx> +#include "ModifyListenerHelper.hxx" +#include "charttoolsdllapi.hxx" #include <vector> @@ -53,7 +54,7 @@ typedef ::cppu::WeakImplHelper< Diagram_Base; } -class Diagram final : +class OOO_DLLPUBLIC_CHARTTOOLS Diagram final : public cppu::BaseMutex, public impl::Diagram_Base, public ::property::OPropertySet @@ -72,7 +73,6 @@ public: /// merge XTypeProvider implementations DECLARE_XTYPEPROVIDER() -private: explicit Diagram( const Diagram & rOther ); // ____ OPropertySet ____ @@ -136,6 +136,8 @@ private: virtual void SAL_CALL removeModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override; +private: + // ____ XModifyListener ____ virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override; diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx index f1582aec9289..0e494311a32e 100644 --- a/chart2/source/model/main/ChartModel.cxx +++ b/chart2/source/model/main/ChartModel.cxx @@ -31,6 +31,7 @@ #include <ChartView.hxx> #include <PopupRequest.hxx> #include <ModifyListenerHelper.hxx> +#include <Diagram.hxx> #include <com/sun/star/chart/ChartDataRowSource.hpp> #include <com/sun/star/chart2/data/XPivotTableDataProvider.hpp> @@ -149,7 +150,7 @@ ChartModel::ChartModel( const ChartModel & rOther ) Reference< util::XModifyListener > xListener; Reference< chart2::XTitle > xNewTitle = CreateRefClone< chart2::XTitle >()( rOther.m_xTitle ); - Reference< chart2::XDiagram > xNewDiagram = CreateRefClone< chart2::XDiagram >()( rOther.m_xDiagram ); + rtl::Reference< ::chart::Diagram > xNewDiagram = new ::chart::Diagram( *rOther.m_xDiagram ); Reference< beans::XPropertySet > xNewPageBackground = CreateRefClone< beans::XPropertySet >()( rOther.m_xPageBackground ); Reference< chart2::XChartTypeManager > xChartTypeManager = CreateRefClone< chart2::XChartTypeManager >()( rOther.m_xChartTypeManager ); Reference< container::XNameAccess > xXMLNamespaceMap = CreateRefClone< container::XNameAccess >()( rOther.m_xXMLNamespaceMap ); @@ -165,7 +166,8 @@ ChartModel::ChartModel( const ChartModel & rOther ) } ModifyListenerHelper::addListener( xNewTitle, xListener ); - ModifyListenerHelper::addListener( xNewDiagram, xListener ); + if( xNewDiagram && xListener) + xNewDiagram->addModifyListener( xListener ); ModifyListenerHelper::addListener( xNewPageBackground, xListener ); xListener.clear(); } @@ -525,7 +527,7 @@ void SAL_CALL ChartModel::dispose() //// @todo if ( m_xDiagram.is() ) - ModifyListenerHelper::removeListener( m_xDiagram, this ); + m_xDiagram->removeModifyListener( this ); if ( m_xDataProvider.is() ) { @@ -539,7 +541,7 @@ void SAL_CALL ChartModel::dispose() m_xNumberFormatsSupplier.clear(); DisposeHelper::DisposeAndClear( m_xOwnNumberFormatsSupplier ); DisposeHelper::DisposeAndClear( m_xChartTypeManager ); - DisposeHelper::DisposeAndClear( m_xDiagram ); + m_xDiagram.clear(); DisposeHelper::DisposeAndClear( m_xTitle ); DisposeHelper::DisposeAndClear( m_xPageBackground ); DisposeHelper::DisposeAndClear( m_xXMLNamespaceMap ); @@ -670,18 +672,20 @@ uno::Reference< chart2::XDiagram > SAL_CALL ChartModel::getFirstDiagram() void SAL_CALL ChartModel::setFirstDiagram( const uno::Reference< chart2::XDiagram >& xDiagram ) { - Reference< chart2::XDiagram > xOldDiagram; + rtl::Reference< ::chart::Diagram > xOldDiagram; Reference< util::XModifyListener > xListener; { MutexGuard aGuard( m_aModelMutex ); - if( xDiagram == m_xDiagram ) + if( xDiagram.get() == m_xDiagram.get() ) return; xOldDiagram = m_xDiagram; - m_xDiagram = xDiagram; + assert(!xDiagram || dynamic_cast<::chart::Diagram*>(xDiagram.get())); + m_xDiagram = dynamic_cast<::chart::Diagram*>(xDiagram.get()); xListener = this; } //don't keep the mutex locked while calling out - ModifyListenerHelper::removeListener( xOldDiagram, xListener ); + if( xOldDiagram && xListener ) + xOldDiagram->removeModifyListener( xListener ); ModifyListenerHelper::addListener( xDiagram, xListener ); setModified( true ); } |