chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx | 2 chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx | 2 chart2/source/controller/inc/SeriesOptionsItemConverter.hxx | 3 - chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx | 4 + chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx | 13 ++---- chart2/source/inc/ChartModelHelper.hxx | 5 -- chart2/source/inc/Diagram.hxx | 7 --- chart2/source/inc/RegressionCurveHelper.hxx | 2 chart2/source/model/main/Diagram.cxx | 21 ---------- chart2/source/tools/ChartModelHelper.cxx | 8 --- chart2/source/tools/RegressionCurveHelper.cxx | 4 - 11 files changed, 19 insertions(+), 52 deletions(-)
New commits: commit 949c73f9c35d640c841f03d505e905aa2e1b7a3f Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Thu Mar 16 11:37:03 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Mar 22 05:57:16 2023 +0000 use more concrete types in chart2 Change-Id: I70042284e4549b3eef67866a35741b06305d720f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149229 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx index 8961c2731f71..6c0dbe7bce25 100644 --- a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx @@ -318,7 +318,7 @@ Any WrappedAttachedAxisProperty::getPropertyValue( const Reference< beans::XProp void WrappedAttachedAxisProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const { - uno::Reference< chart2::XDataSeries > xDataSeries( xInnerPropertySet, uno::UNO_QUERY ); + rtl::Reference< ::chart::DataSeries > xDataSeries( dynamic_cast<::chart::DataSeries*>(xInnerPropertySet.get()) ); sal_Int32 nChartAxisAssign = css::chart::ChartAxisAssign::PRIMARY_Y; if( ! (rOuterValue >>= nChartAxisAssign) ) diff --git a/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx index 50d4b2c0edd2..79c45ea1d888 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx @@ -286,7 +286,7 @@ beans::PropertyState WrappedSymbolTypeProperty::getPropertyState( const Referenc m_spChart2ModelContact) { rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); - Reference< chart2::XDataSeries > xSeries( xInnerPropertyState, uno::UNO_QUERY ); + rtl::Reference< ::chart::DataSeries > xSeries( dynamic_cast<DataSeries*>(xInnerPropertyState.get()) ); rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeOfSeries( xSeries ) ); if( ChartTypeHelper::isSupportingSymbolProperties( xChartType, 2 ) ) return beans::PropertyState_DIRECT_VALUE; diff --git a/chart2/source/controller/inc/SeriesOptionsItemConverter.hxx b/chart2/source/controller/inc/SeriesOptionsItemConverter.hxx index 886e6ec91b83..b55457ac5b30 100644 --- a/chart2/source/controller/inc/SeriesOptionsItemConverter.hxx +++ b/chart2/source/controller/inc/SeriesOptionsItemConverter.hxx @@ -27,6 +27,7 @@ namespace com::sun::star::frame { class XModel; } namespace com::sun::star::uno { class XComponentContext; } namespace chart { class ChartModel; } namespace chart { class BaseCoordinateSystem; } +namespace chart { class DataSeries; } namespace chart::wrapper { @@ -37,7 +38,7 @@ public: SeriesOptionsItemConverter( const rtl::Reference<::chart::ChartModel> & xChartModel, css::uno::Reference< css::uno::XComponentContext > xContext, - const css::uno::Reference< css::beans::XPropertySet > & rPropertySet, + const rtl::Reference<::chart::DataSeries> & rPropertySet, SfxItemPool& rItemPool ); virtual ~SeriesOptionsItemConverter() override; diff --git a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx index f415cd194386..e71646cf7a8f 100644 --- a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx @@ -234,8 +234,10 @@ DataPointItemConverter::DataPointItemConverter( m_aConverters.emplace_back( new CharacterPropertyItemConverter(rPropertySet, rItemPool, pRefSize, "ReferencePageSize")); if( bDataSeries ) { + assert(dynamic_cast<DataSeries*>(rPropertySet.get())); m_aConverters.emplace_back( new StatisticsItemConverter( xChartModel, rPropertySet, rItemPool )); - m_aConverters.emplace_back( new SeriesOptionsItemConverter( xChartModel, xContext, rPropertySet, rItemPool )); + m_aConverters.emplace_back( new SeriesOptionsItemConverter( xChartModel, xContext, + dynamic_cast<DataSeries*>(rPropertySet.get()), rItemPool )); } rtl::Reference< Diagram > xDiagram( ChartModelHelper::findDiagram(xChartModel) ); diff --git a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx index 946647cdf2bd..8bd32967d6f9 100644 --- a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx @@ -49,9 +49,9 @@ namespace chart::wrapper SeriesOptionsItemConverter::SeriesOptionsItemConverter( const rtl::Reference<::chart::ChartModel>& xChartModel , uno::Reference< uno::XComponentContext > xContext - , const uno::Reference< beans::XPropertySet >& xPropertySet + , const rtl::Reference< ::chart::DataSeries >& xDataSeries , SfxItemPool& rItemPool ) - : ItemConverter( xPropertySet, rItemPool ) + : ItemConverter( xDataSeries, rItemPool ) , m_xChartModel(xChartModel) , m_xCC(std::move(xContext)) , m_bAttachToMainAxis(true) @@ -72,8 +72,6 @@ SeriesOptionsItemConverter::SeriesOptionsItemConverter( { try { - uno::Reference< XDataSeries > xDataSeries( xPropertySet, uno::UNO_QUERY ); - m_bAttachToMainAxis = DiagramHelper::isSeriesAttachedToMainAxis( xDataSeries ); rtl::Reference< Diagram > xDiagram( ChartModelHelper::findDiagram(xChartModel) ); @@ -148,7 +146,7 @@ SeriesOptionsItemConverter::SeriesOptionsItemConverter( } } - m_bHideLegendEntry = !xPropertySet->getPropertyValue("ShowLegendEntry").get<bool>(); + m_bHideLegendEntry = !xDataSeries->getPropertyValue("ShowLegendEntry").get<bool>(); } catch( const uno::Exception & ) { @@ -184,7 +182,8 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const Sf if( bAttachToMainAxis != m_bAttachToMainAxis ) { //change model: - bChanged = ChartModelHelper::findDiagram(m_xChartModel)->attachSeriesToAxis( bAttachToMainAxis, uno::Reference< XDataSeries >::query( GetPropertySet() ) + rtl::Reference<DataSeries> xDataSeries = dynamic_cast<DataSeries*>( GetPropertySet().get() ); + bChanged = ChartModelHelper::findDiagram(m_xChartModel)->attachSeriesToAxis( bAttachToMainAxis, xDataSeries , m_xCC ); if( bChanged ) @@ -205,7 +204,7 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const Sf if( nWhichId == SCHATTR_BAR_OVERLAP ) aPropName = "OverlapSequence"; - uno::Reference< XDataSeries > xDataSeries( GetPropertySet(), uno::UNO_QUERY ); + rtl::Reference< DataSeries > xDataSeries( dynamic_cast<DataSeries*>(GetPropertySet().get()) ); rtl::Reference< Diagram > xDiagram( ChartModelHelper::findDiagram(m_xChartModel) ); rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeOfSeries( xDataSeries ) ); if( xChartType.is() ) diff --git a/chart2/source/inc/ChartModelHelper.hxx b/chart2/source/inc/ChartModelHelper.hxx index c15b9a95a7f9..10523dc2d3a7 100644 --- a/chart2/source/inc/ChartModelHelper.hxx +++ b/chart2/source/inc/ChartModelHelper.hxx @@ -61,11 +61,6 @@ public: static std::vector< rtl::Reference< ::chart::DataSeries > > getDataSeries( const rtl::Reference< ::chart::ChartModel > & xModel ); - static rtl::Reference< ChartType > - getChartTypeOfSeries( - const rtl::Reference<::chart::ChartModel>& xModel - , const css::uno::Reference< css::chart2::XDataSeries >& xGivenDataSeries ); - static rtl::Reference< ChartType > getChartTypeOfSeries( const rtl::Reference<::chart::ChartModel>& xModel diff --git a/chart2/source/inc/Diagram.hxx b/chart2/source/inc/Diagram.hxx index 526559d91b77..c157fe061399 100644 --- a/chart2/source/inc/Diagram.hxx +++ b/chart2/source/inc/Diagram.hxx @@ -254,19 +254,14 @@ public: std::vector< rtl::Reference< ::chart::DataSeries > > getDataSeries(); - rtl::Reference< ChartType > - getChartTypeOfSeries( const css::uno::Reference< css::chart2::XDataSeries >& xSeries ); rtl::Reference< ChartType > getChartTypeOfSeries( const rtl::Reference< DataSeries >& xSeries ); - rtl::Reference< ::chart::Axis > getAttachedAxis( - const css::uno::Reference< css::chart2::XDataSeries >& xSeries ); - rtl::Reference< ::chart::Axis > getAttachedAxis( const rtl::Reference< ::chart::DataSeries >& xSeries ); bool attachSeriesToAxis( bool bMainAxis, - const css::uno::Reference< css::chart2::XDataSeries >& xSeries, + const rtl::Reference< DataSeries >& xSeries, const css::uno::Reference< css::uno::XComponentContext > & xContext, bool bAdaptAxes=true ); diff --git a/chart2/source/inc/RegressionCurveHelper.hxx b/chart2/source/inc/RegressionCurveHelper.hxx index 6b2c4c4cc918..d8e35a25f089 100644 --- a/chart2/source/inc/RegressionCurveHelper.hxx +++ b/chart2/source/inc/RegressionCurveHelper.hxx @@ -170,7 +170,7 @@ namespace chart::RegressionCurveHelper */ OOO_DLLPUBLIC_CHARTTOOLS void initializeCurveCalculator( const css::uno::Reference<css::chart2::XRegressionCurveCalculator>& xOutCurveCalculator, - const css::uno::Reference<css::chart2::XDataSeries>& xSeries, + const rtl::Reference<::chart::DataSeries>& xSeries, const rtl::Reference<::chart::ChartModel>& xModel ); OOO_DLLPUBLIC_CHARTTOOLS OUString getUINameForRegressionCurve( diff --git a/chart2/source/model/main/Diagram.cxx b/chart2/source/model/main/Diagram.cxx index 9d7477ddd341..507cf7e895d7 100644 --- a/chart2/source/model/main/Diagram.cxx +++ b/chart2/source/model/main/Diagram.cxx @@ -1254,16 +1254,6 @@ std::vector< rtl::Reference< ::chart::DataSeries > > return aResult; } -rtl::Reference< ChartType > Diagram::getChartTypeOfSeries( - const uno::Reference< chart2::XDataSeries >& xGivenDataSeries ) -{ - if( !xGivenDataSeries.is() ) - return nullptr; - rtl::Reference pGivenDataSeries = dynamic_cast<DataSeries*>(xGivenDataSeries.get()); - assert(pGivenDataSeries); - return getChartTypeOfSeries(pGivenDataSeries); -} - rtl::Reference< ChartType > Diagram::getChartTypeOfSeries( const rtl::Reference< DataSeries >& xGivenDataSeries ) { @@ -1292,12 +1282,6 @@ rtl::Reference< ChartType > Diagram::getChartTypeOfSeries( return nullptr; } -rtl::Reference< Axis > Diagram::getAttachedAxis( - const uno::Reference< css::chart2::XDataSeries >& xSeries ) -{ - return AxisHelper::getAxis( 1, DiagramHelper::isSeriesAttachedToMainAxis( xSeries ), this ); -} - rtl::Reference< Axis > Diagram::getAttachedAxis( const rtl::Reference< DataSeries >& xSeries ) { @@ -1305,14 +1289,13 @@ rtl::Reference< Axis > Diagram::getAttachedAxis( } bool Diagram::attachSeriesToAxis( bool bAttachToMainAxis - , const uno::Reference< chart2::XDataSeries >& xDataSeries + , const rtl::Reference< DataSeries >& xDataSeries , const uno::Reference< uno::XComponentContext > & xContext , bool bAdaptAxes ) { bool bChanged = false; //set property at axis - Reference< beans::XPropertySet > xProp( xDataSeries, uno::UNO_QUERY_THROW ); sal_Int32 nNewAxisIndex = bAttachToMainAxis ? 0 : 1; sal_Int32 nOldAxisIndex = DataSeriesHelper::getAttachedAxisIndex(xDataSeries); @@ -1322,7 +1305,7 @@ bool Diagram::attachSeriesToAxis( bool bAttachToMainAxis { try { - xProp->setPropertyValue( "AttachedAxisIndex", uno::Any( nNewAxisIndex ) ); + xDataSeries->setPropertyValue( "AttachedAxisIndex", uno::Any( nNewAxisIndex ) ); bChanged = true; } catch( const uno::Exception & ) diff --git a/chart2/source/tools/ChartModelHelper.cxx b/chart2/source/tools/ChartModelHelper.cxx index c01ca7698274..0b80b6e6f925 100644 --- a/chart2/source/tools/ChartModelHelper.cxx +++ b/chart2/source/tools/ChartModelHelper.cxx @@ -121,14 +121,6 @@ std::vector< rtl::Reference< DataSeries > > ChartModelHelper::getDataSeries( return aResult; } -rtl::Reference< ChartType > ChartModelHelper::getChartTypeOfSeries( - const rtl::Reference<::chart::ChartModel>& xModel - , const uno::Reference< XDataSeries >& xGivenDataSeries ) -{ - rtl::Reference<Diagram> xDiagram = ChartModelHelper::findDiagram( xModel ); - return xDiagram ? xDiagram->getChartTypeOfSeries( xGivenDataSeries ) : nullptr; -} - rtl::Reference< ChartType > ChartModelHelper::getChartTypeOfSeries( const rtl::Reference<::chart::ChartModel>& xModel , const rtl::Reference< DataSeries >& xGivenDataSeries ) diff --git a/chart2/source/tools/RegressionCurveHelper.cxx b/chart2/source/tools/RegressionCurveHelper.cxx index 38da80f937ab..50da3958d959 100644 --- a/chart2/source/tools/RegressionCurveHelper.cxx +++ b/chart2/source/tools/RegressionCurveHelper.cxx @@ -236,14 +236,14 @@ void RegressionCurveHelper::initializeCurveCalculator( void RegressionCurveHelper::initializeCurveCalculator( const Reference< XRegressionCurveCalculator > & xOutCurveCalculator, - const Reference< XDataSeries > & xSeries, + const rtl::Reference< ::chart::DataSeries > & xSeries, const rtl::Reference<::chart::ChartModel> & xModel ) { sal_Int32 nAxisType = ChartTypeHelper::getAxisType( ChartModelHelper::getChartTypeOfSeries( xModel, xSeries ), 0 ); // x-axis initializeCurveCalculator( xOutCurveCalculator, - uno::Reference< data::XDataSource >( xSeries, uno::UNO_QUERY ), + xSeries, (nAxisType == AxisType::REALNUMBER) ); }