From 928cb2963844ffd07fdbda6ec55f8de0c51581ff Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 20 Jan 2022 22:18:26 +0200 Subject: use more concrete types in chart2, BaseCoordinateSystem Change-Id: I25fc26c9c3eb861d72c44ac04e502b2f002ef951 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128711 Tested-by: Jenkins Reviewed-by: Noel Grandin --- chart2/source/controller/dialogs/DataBrowserModel.cxx | 10 ++++------ chart2/source/controller/dialogs/DialogModel.cxx | 10 +++++----- chart2/source/controller/main/ChartController.cxx | 13 +++++-------- chart2/source/controller/sidebar/ChartElementsPanel.cxx | 13 +++++-------- chart2/source/controller/sidebar/ChartSeriesPanel.cxx | 6 +++--- chart2/source/tools/ObjectIdentifier.cxx | 10 +++------- chart2/source/view/charttypes/VSeriesPlotter.cxx | 8 ++++---- chart2/source/view/main/ChartView.cxx | 9 ++++----- 8 files changed, 33 insertions(+), 46 deletions(-) diff --git a/chart2/source/controller/dialogs/DataBrowserModel.cxx b/chart2/source/controller/dialogs/DataBrowserModel.cxx index ce5acd923c89..c73781770549 100644 --- a/chart2/source/controller/dialogs/DataBrowserModel.cxx +++ b/chart2/source/controller/dialogs/DataBrowserModel.cxx @@ -803,11 +803,10 @@ void DataBrowserModel::updateFromModel() if( !xDiagram.is()) return; - const Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xDiagram->getCoordinateSystems()); - for( Reference< chart2::XCoordinateSystem > const & coords : aCooSysSeq ) + const std::vector< rtl::Reference< BaseCoordinateSystem > > aCooSysSeq( xDiagram->getBaseCoordinateSystems()); + for( rtl::Reference< BaseCoordinateSystem > const & coords : aCooSysSeq ) { - Reference< chart2::XChartTypeContainer > xCTCnt( coords, uno::UNO_QUERY_THROW ); - const Sequence< Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes()); + const Sequence< Reference< chart2::XChartType > > aChartTypes( coords->getChartTypes()); sal_Int32 nXAxisNumberFormat = DataSeriesHelper::getNumberFormatKeyFromAxis( nullptr, coords, 0, 0 ); for( sal_Int32 nCTIdx=0; nCTIdx xProp( coords, uno::UNO_QUERY ); - xProp->getPropertyValue( "SwapXAndYAxis" ) >>= bSwapXAndYAxis; + coords->getPropertyValue( "SwapXAndYAxis" ) >>= bSwapXAndYAxis; } catch( const beans::UnknownPropertyException & ) {} diff --git a/chart2/source/controller/dialogs/DialogModel.cxx b/chart2/source/controller/dialogs/DialogModel.cxx index eed859f5d948..73b438acef92 100644 --- a/chart2/source/controller/dialogs/DialogModel.cxx +++ b/chart2/source/controller/dialogs/DialogModel.cxx @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -472,12 +473,11 @@ std::vector< Reference< XDataSeriesContainer > > rtl::Reference< Diagram > xDiagram = m_xChartDocument->getFirstChartDiagram(); if( xDiagram.is()) { - const Sequence< Reference< XCoordinateSystem > > aCooSysSeq( - xDiagram->getCoordinateSystems()); - for( Reference< XCoordinateSystem > const & coords : aCooSysSeq ) + const std::vector< rtl::Reference< BaseCoordinateSystem > > & aCooSysSeq( + xDiagram->getBaseCoordinateSystems()); + for( rtl::Reference< BaseCoordinateSystem > const & coords : aCooSysSeq ) { - Reference< XChartTypeContainer > xCTCnt( coords, uno::UNO_QUERY_THROW ); - const Sequence< Reference< XChartType > > aChartTypeSeq( xCTCnt->getChartTypes()); + const Sequence< Reference< XChartType > > aChartTypeSeq( coords->getChartTypes()); std::transform( aChartTypeSeq.begin(), aChartTypeSeq.end(), std::back_inserter( aResult ), diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx index aaa8636e470e..5be9cc3fe0c3 100644 --- a/chart2/source/controller/main/ChartController.cxx +++ b/chart2/source/controller/main/ChartController.cxx @@ -53,6 +53,7 @@ #include #include +#include #include #include @@ -234,18 +235,14 @@ css::uno::Reference getChartType( const rtl::Reference& xChartDoc) { rtl::Reference xDiagram = xChartDoc->getFirstChartDiagram(); - if (!xDiagram.is()) { + if (!xDiagram.is()) return css::uno::Reference(); - } - Sequence< Reference< chart2::XCoordinateSystem > > xCooSysSequence( xDiagram->getCoordinateSystems()); - if (!xCooSysSequence.hasElements()) { + const std::vector< rtl::Reference< BaseCoordinateSystem > > xCooSysSequence( xDiagram->getBaseCoordinateSystems()); + if (xCooSysSequence.empty()) return css::uno::Reference(); - } - - Reference< chart2::XChartTypeContainer > xChartTypeContainer( xCooSysSequence[0], uno::UNO_QUERY_THROW ); - Sequence< Reference< chart2::XChartType > > xChartTypeSequence( xChartTypeContainer->getChartTypes() ); + Sequence< Reference< chart2::XChartType > > xChartTypeSequence( xCooSysSequence[0]->getChartTypes() ); return xChartTypeSequence[0]; } diff --git a/chart2/source/controller/sidebar/ChartElementsPanel.cxx b/chart2/source/controller/sidebar/ChartElementsPanel.cxx index 69931ff17303..572ea7de4bd3 100644 --- a/chart2/source/controller/sidebar/ChartElementsPanel.cxx +++ b/chart2/source/controller/sidebar/ChartElementsPanel.cxx @@ -34,8 +34,8 @@ #include #include #include - #include +#include using namespace css; @@ -409,18 +409,15 @@ namespace { css::uno::Reference getChartType(const rtl::Reference& xModel) { rtl::Reference xDiagram = xModel->getFirstChartDiagram(); - if (!xDiagram.is()) { + if (!xDiagram.is()) return css::uno::Reference(); - } - css::uno::Sequence> xCooSysSequence(xDiagram->getCoordinateSystems()); + const std::vector> & xCooSysSequence(xDiagram->getBaseCoordinateSystems()); - if (!xCooSysSequence.hasElements()) + if (xCooSysSequence.empty()) return css::uno::Reference(); - css::uno::Reference xChartTypeContainer(xCooSysSequence[0], css::uno::UNO_QUERY_THROW); - - css::uno::Sequence> xChartTypeSequence(xChartTypeContainer->getChartTypes()); + css::uno::Sequence> xChartTypeSequence(xCooSysSequence[0]->getChartTypes()); if (!xChartTypeSequence.hasElements()) return css::uno::Reference(); diff --git a/chart2/source/controller/sidebar/ChartSeriesPanel.cxx b/chart2/source/controller/sidebar/ChartSeriesPanel.cxx index dd3189350789..27878f8926cc 100644 --- a/chart2/source/controller/sidebar/ChartSeriesPanel.cxx +++ b/chart2/source/controller/sidebar/ChartSeriesPanel.cxx @@ -38,6 +38,7 @@ #include #include #include +#include #include @@ -229,9 +230,8 @@ css::uno::Reference getChartType( const rtl::Reference<::chart::ChartModel>& xModel) { rtl::Reference xDiagram = xModel->getFirstChartDiagram(); - css::uno::Sequence< css::uno::Reference< css::chart2::XCoordinateSystem > > xCooSysSequence( xDiagram->getCoordinateSystems()); - css::uno::Reference< css::chart2::XChartTypeContainer > xChartTypeContainer( xCooSysSequence[0], UNO_QUERY_THROW ); - css::uno::Sequence< css::uno::Reference< css::chart2::XChartType > > xChartTypeSequence( xChartTypeContainer->getChartTypes() ); + const std::vector< rtl::Reference< BaseCoordinateSystem > > xCooSysSequence( xDiagram->getBaseCoordinateSystems()); + css::uno::Sequence< css::uno::Reference< css::chart2::XChartType > > xChartTypeSequence( xCooSysSequence[0]->getChartTypes() ); return xChartTypeSequence[0]; } diff --git a/chart2/source/tools/ObjectIdentifier.cxx b/chart2/source/tools/ObjectIdentifier.cxx index fa538c81670d..f95022510203 100644 --- a/chart2/source/tools/ObjectIdentifier.cxx +++ b/chart2/source/tools/ObjectIdentifier.cxx @@ -136,15 +136,11 @@ Reference lcl_getFirstStockChartType( const Reference< frame::XModel //iterate through all coordinate systems - const uno::Sequence< Reference< XCoordinateSystem > > aCooSysList( xDiagram->getCoordinateSystems() ); - for( Reference< XCoordinateSystem > const & coords : aCooSysList ) + const std::vector< rtl::Reference< BaseCoordinateSystem > > & aCooSysList( xDiagram->getBaseCoordinateSystems() ); + for( rtl::Reference< BaseCoordinateSystem > const & coords : aCooSysList ) { //iterate through all chart types in the current coordinate system - Reference< XChartTypeContainer > xChartTypeContainer( coords, uno::UNO_QUERY ); - if( !xChartTypeContainer.is() ) - continue; - - const uno::Sequence< Reference< XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() ); + const uno::Sequence< Reference< XChartType > > aChartTypeList( coords->getChartTypes() ); for( Reference< XChartType > const & xChartType : aChartTypeList ) { if(!xChartType.is()) diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx index 5ffeb320478f..af54871ff49d 100644 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -2362,13 +2363,12 @@ std::vector< ViewLegendEntry > VSeriesPlotter::createLegendEntries( if( xTarget.is() ) { rtl::Reference< Diagram > xDiagram = rModel.getFirstChartDiagram(); - Reference< chart2::XCoordinateSystem > xCooSys(xDiagram->getCoordinateSystems()[0]); - Reference< beans::XPropertySet > xProp( xCooSys, uno::UNO_QUERY ); + rtl::Reference< BaseCoordinateSystem > xCooSys(xDiagram->getBaseCoordinateSystems()[0]); bool bSwapXAndY = false; - if( xProp.is()) try + try { - xProp->getPropertyValue( "SwapXAndYAxis" ) >>= bSwapXAndY; + xCooSys->getPropertyValue( "SwapXAndYAxis" ) >>= bSwapXAndY; } catch( const uno::Exception& ) { diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index fff8c6ea08d3..d1ec2a672571 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -1796,13 +1796,12 @@ bool lcl_getPropertySwapXAndYAxis( const rtl::Reference< Diagram >& xDiagram ) if( xDiagram.is() ) { - uno::Sequence< uno::Reference< XCoordinateSystem > > aCooSysList( xDiagram->getCoordinateSystems() ); - if( aCooSysList.hasElements() ) + const std::vector< rtl::Reference< BaseCoordinateSystem > > & aCooSysList( xDiagram->getBaseCoordinateSystems() ); + if( !aCooSysList.empty() ) { - uno::Reference xProp(aCooSysList[0], uno::UNO_QUERY ); - if( xProp.is()) try + try { - xProp->getPropertyValue( "SwapXAndYAxis" ) >>= bSwapXAndY; + aCooSysList[0]->getPropertyValue( "SwapXAndYAxis" ) >>= bSwapXAndY; } catch( const uno::Exception& ) { -- cgit