diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-01-19 15:15:28 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-01-19 20:00:25 +0100 |
commit | 2064cdb1cd908a3ee55a54f0aeb4aee15f7c12da (patch) | |
tree | 8a038421eeb3e082f3b6a0092f67c15492dc35c8 /chart2/source/tools | |
parent | b7313bc131a285056906f85b51b0c3b53b7b3560 (diff) |
use more concrete types in chart2, BaseCoordinateSystem
Change-Id: I1c246a3ea37595647ac254f492170a9e18540794
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128623
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2/source/tools')
-rw-r--r-- | chart2/source/tools/AxisHelper.cxx | 44 | ||||
-rw-r--r-- | chart2/source/tools/ChartModelHelper.cxx | 31 | ||||
-rw-r--r-- | chart2/source/tools/DataSeriesHelper.cxx | 22 | ||||
-rw-r--r-- | chart2/source/tools/DiagramHelper.cxx | 3 | ||||
-rw-r--r-- | chart2/source/tools/ExplicitCategoriesProvider.cxx | 3 | ||||
-rw-r--r-- | chart2/source/tools/InternalDataProvider.cxx | 1 | ||||
-rw-r--r-- | chart2/source/tools/ObjectIdentifier.cxx | 3 |
7 files changed, 56 insertions, 51 deletions
diff --git a/chart2/source/tools/AxisHelper.cxx b/chart2/source/tools/AxisHelper.cxx index 276abb5dbc47..d936cf59c92b 100644 --- a/chart2/source/tools/AxisHelper.cxx +++ b/chart2/source/tools/AxisHelper.cxx @@ -19,6 +19,7 @@ #include <AxisHelper.hxx> #include <DiagramHelper.hxx> +#include <Diagram.hxx> #include <ChartTypeHelper.hxx> #include <AxisIndexDefines.hxx> #include <LinePropertiesHelper.hxx> @@ -31,6 +32,7 @@ #include <ReferenceSizeProvider.hxx> #include <ExplicitCategoriesProvider.hxx> #include <unonames.hxx> +#include <BaseCoordinateSystem.hxx> #include <unotools/saveopt.hxx> @@ -569,15 +571,16 @@ bool AxisHelper::isGridShown( sal_Int32 nDimensionIndex, sal_Int32 nCooSysIndex, return bRet; } -Reference< XCoordinateSystem > AxisHelper::getCoordinateSystemByIndex( +rtl::Reference< ::chart::BaseCoordinateSystem > AxisHelper::getCoordinateSystemByIndex( const Reference< XDiagram >& xDiagram, sal_Int32 nIndex ) { - Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY ); - if(!xCooSysContainer.is()) + if(!xDiagram.is()) return nullptr; - Sequence< Reference< XCoordinateSystem > > aCooSysList = xCooSysContainer->getCoordinateSystems(); - if(0<=nIndex && nIndex<aCooSysList.getLength()) - return aCooSysList[nIndex]; + ::chart::Diagram* pDiagram = dynamic_cast<::chart::Diagram*>(xDiagram.get()); + assert(pDiagram); + auto & rCooSysList = pDiagram->getBaseCoordinateSystems(); + if(0<=nIndex && nIndex < static_cast<sal_Int32>(rCooSysList.size())) + return rCooSysList[nIndex]; return nullptr; } @@ -1021,27 +1024,26 @@ bool AxisHelper::changeVisibilityOfGrids( const Reference< XDiagram >& xDiagram return bChanged; } -Reference< XCoordinateSystem > AxisHelper::getCoordinateSystemOfAxis( +rtl::Reference< BaseCoordinateSystem > AxisHelper::getCoordinateSystemOfAxis( const Reference< XAxis >& xAxis , const Reference< XDiagram >& xDiagram ) { - Reference< XCoordinateSystem > xRet; + if (!xDiagram) + return nullptr; + ::chart::Diagram* pDiagram = dynamic_cast<::chart::Diagram*>(xDiagram.get()); + assert(pDiagram); - Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY ); - if( xCooSysContainer.is() ) + rtl::Reference< BaseCoordinateSystem > xRet; + for( rtl::Reference< BaseCoordinateSystem > const & xCooSys : pDiagram->getBaseCoordinateSystems() ) { - const Sequence< Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() ); - for( Reference< XCoordinateSystem > const & xCooSys : aCooSysList ) - { - std::vector< Reference< XAxis > > aAllAxis( AxisHelper::getAllAxesOfCoordinateSystem( xCooSys ) ); + std::vector< Reference< XAxis > > aAllAxis( AxisHelper::getAllAxesOfCoordinateSystem( xCooSys ) ); - std::vector< Reference< XAxis > >::iterator aFound = - std::find( aAllAxis.begin(), aAllAxis.end(), xAxis ); - if( aFound != aAllAxis.end()) - { - xRet.set( xCooSys ); - break; - } + std::vector< Reference< XAxis > >::iterator aFound = + std::find( aAllAxis.begin(), aAllAxis.end(), xAxis ); + if( aFound != aAllAxis.end()) + { + xRet = xCooSys; + break; } } return xRet; diff --git a/chart2/source/tools/ChartModelHelper.cxx b/chart2/source/tools/ChartModelHelper.cxx index 71f35969e5d0..fc442b8030e3 100644 --- a/chart2/source/tools/ChartModelHelper.cxx +++ b/chart2/source/tools/ChartModelHelper.cxx @@ -25,6 +25,7 @@ #include <RangeHighlighter.hxx> #include <InternalDataProvider.hxx> #include <ChartModel.hxx> +#include <BaseCoordinateSystem.hxx> #include <com/sun/star/chart/ChartDataRowSource.hpp> #include <com/sun/star/chart/XChartDocument.hpp> @@ -107,30 +108,28 @@ rtl::Reference< Diagram > ChartModelHelper::findDiagram( const uno::Reference< c return nullptr; } -uno::Reference< XCoordinateSystem > ChartModelHelper::getFirstCoordinateSystem( ChartModel& rModel ) +rtl::Reference< BaseCoordinateSystem > ChartModelHelper::getFirstCoordinateSystem( ChartModel& rModel ) { - uno::Reference< XCoordinateSystem > XCooSys; - uno::Reference< XCoordinateSystemContainer > xCooSysCnt( rModel.getFirstDiagram(), uno::UNO_QUERY ); - if( xCooSysCnt.is() ) + rtl::Reference< Diagram > xDiagram = rModel.getFirstChartDiagram(); + if( xDiagram.is() ) { - uno::Sequence< uno::Reference< XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems() ); - if( aCooSysSeq.hasElements() ) - XCooSys = aCooSysSeq[0]; + auto& rCooSysSeq( xDiagram->getBaseCoordinateSystems() ); + if( !rCooSysSeq.empty() ) + return rCooSysSeq[0]; } - return XCooSys; + return nullptr; } -uno::Reference< XCoordinateSystem > ChartModelHelper::getFirstCoordinateSystem( const uno::Reference< frame::XModel >& xModel ) +rtl::Reference< BaseCoordinateSystem > ChartModelHelper::getFirstCoordinateSystem( const uno::Reference< frame::XModel >& xModel ) { - uno::Reference< XCoordinateSystem > XCooSys; - rtl::Reference< Diagram > xCooSysCnt( ChartModelHelper::findDiagram( xModel ), uno::UNO_QUERY ); - if( xCooSysCnt.is() ) + rtl::Reference< Diagram > xDiagram = ChartModelHelper::findDiagram( xModel ); + if( xDiagram.is() ) { - uno::Sequence< uno::Reference< XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems() ); - if( aCooSysSeq.hasElements() ) - XCooSys = aCooSysSeq[0]; + auto& rCooSysSeq( xDiagram->getBaseCoordinateSystems() ); + if( !rCooSysSeq.empty() ) + return rCooSysSeq[0]; } - return XCooSys; + return nullptr; } std::vector< uno::Reference< XDataSeries > > ChartModelHelper::getDataSeries( diff --git a/chart2/source/tools/DataSeriesHelper.cxx b/chart2/source/tools/DataSeriesHelper.cxx index af3c16190633..ed90d3a8c207 100644 --- a/chart2/source/tools/DataSeriesHelper.cxx +++ b/chart2/source/tools/DataSeriesHelper.cxx @@ -20,6 +20,8 @@ #include <DataSeriesHelper.hxx> #include <DataSource.hxx> #include <unonames.hxx> +#include <Diagram.hxx> +#include <BaseCoordinateSystem.hxx> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/chart2/DataPointLabel.hpp> @@ -108,18 +110,16 @@ Reference< chart2::data::XLabeledDataSequence > lcl_findLSequenceWithOnlyLabel( void lcl_getCooSysAndChartTypeOfSeries( const Reference< chart2::XDataSeries > & xSeries, const Reference< chart2::XDiagram > & xDiagram, - Reference< chart2::XCoordinateSystem > & xOutCooSys, + rtl::Reference< ::chart::BaseCoordinateSystem > & xOutCooSys, Reference< chart2::XChartType > & xOutChartType ) { - Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY ); - if( !xCooSysCnt.is()) + if( !xDiagram.is()) return; + ::chart::Diagram* pDiagram = dynamic_cast<::chart::Diagram*>(xDiagram.get()); - const Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems()); - for( Reference< chart2::XCoordinateSystem > const & coords : aCooSysSeq ) + for( rtl::Reference< ::chart::BaseCoordinateSystem > const & coords : pDiagram->getBaseCoordinateSystems() ) { - 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()); for( Reference< chart2::XChartType > const & chartType : aChartTypes ) { Reference< chart2::XDataSeriesContainer > xSeriesCnt( chartType, uno::UNO_QUERY ); @@ -130,7 +130,7 @@ void lcl_getCooSysAndChartTypeOfSeries( { if( dataSeries == xSeries ) { - xOutCooSys.set( coords ); + xOutCooSys = coords; xOutChartType.set( chartType ); } } @@ -486,11 +486,11 @@ sal_Int32 getNumberFormatKeyFromAxis( return nResult; } -Reference< chart2::XCoordinateSystem > getCoordinateSystemOfSeries( +rtl::Reference< ::chart::BaseCoordinateSystem > getCoordinateSystemOfSeries( const Reference< chart2::XDataSeries > & xSeries, const Reference< chart2::XDiagram > & xDiagram ) { - Reference< chart2::XCoordinateSystem > xResult; + rtl::Reference< ::chart::BaseCoordinateSystem > xResult; Reference< chart2::XChartType > xDummy; lcl_getCooSysAndChartTypeOfSeries( xSeries, xDiagram, xResult, xDummy ); @@ -502,7 +502,7 @@ Reference< chart2::XChartType > getChartTypeOfSeries( const Reference< chart2::XDiagram > & xDiagram ) { Reference< chart2::XChartType > xResult; - Reference< chart2::XCoordinateSystem > xDummy; + rtl::Reference< ::chart::BaseCoordinateSystem > xDummy; lcl_getCooSysAndChartTypeOfSeries( xSeries, xDiagram, xDummy, xResult ); return xResult; diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx index d985df9dc3af..1aa9ad5cc381 100644 --- a/chart2/source/tools/DiagramHelper.cxx +++ b/chart2/source/tools/DiagramHelper.cxx @@ -32,6 +32,7 @@ #include <ControllerLockGuard.hxx> #include <NumberFormatterWrapper.hxx> #include <unonames.hxx> +#include <BaseCoordinateSystem.hxx> #include <com/sun/star/chart/MissingValueTreatment.hpp> #include <com/sun/star/chart/XDiagramPositioning.hpp> @@ -958,7 +959,7 @@ Sequence< OUString > DiagramHelper::generateAutomaticCategoriesFromCooSys( const Sequence< OUString > DiagramHelper::getExplicitSimpleCategories( ChartModel& rModel ) { - uno::Reference< chart2::XCoordinateSystem > xCooSys( ChartModelHelper::getFirstCoordinateSystem( rModel ) ); + rtl::Reference< BaseCoordinateSystem > xCooSys = ChartModelHelper::getFirstCoordinateSystem( rModel ); ExplicitCategoriesProvider aExplicitCategoriesProvider( xCooSys, rModel ); return aExplicitCategoriesProvider.getSimpleCategories(); } diff --git a/chart2/source/tools/ExplicitCategoriesProvider.cxx b/chart2/source/tools/ExplicitCategoriesProvider.cxx index 2f31b9d38dde..0f418198a08d 100644 --- a/chart2/source/tools/ExplicitCategoriesProvider.cxx +++ b/chart2/source/tools/ExplicitCategoriesProvider.cxx @@ -26,6 +26,7 @@ #include <ChartModelHelper.hxx> #include <NumberFormatterWrapper.hxx> #include <unonames.hxx> +#include <BaseCoordinateSystem.hxx> #include <com/sun/star/chart2/AxisType.hpp> #include <o3tl/safeint.hxx> @@ -173,7 +174,7 @@ void ExplicitCategoriesProvider::convertCategoryAnysToText( uno::Sequence< OUStr auto pOutTexts = rOutTexts.getArray(); sal_Int32 nAxisNumberFormat = 0; - Reference< XCoordinateSystem > xCooSysModel( ChartModelHelper::getFirstCoordinateSystem( rModel ) ); + rtl::Reference< BaseCoordinateSystem > xCooSysModel( ChartModelHelper::getFirstCoordinateSystem( rModel ) ); if( xCooSysModel.is() ) { Reference< chart2::XAxis > xAxis( xCooSysModel->getAxisByDimension(0,0) ); diff --git a/chart2/source/tools/InternalDataProvider.cxx b/chart2/source/tools/InternalDataProvider.cxx index c020313c6e35..4af0a42a684e 100644 --- a/chart2/source/tools/InternalDataProvider.cxx +++ b/chart2/source/tools/InternalDataProvider.cxx @@ -31,6 +31,7 @@ #include <DiagramHelper.hxx> #include <Diagram.hxx> #include <ExplicitCategoriesProvider.hxx> +#include <BaseCoordinateSystem.hxx> #include <com/sun/star/chart2/data/XDataSequence.hpp> #include <com/sun/star/chart/ChartDataRowSource.hpp> diff --git a/chart2/source/tools/ObjectIdentifier.cxx b/chart2/source/tools/ObjectIdentifier.cxx index 65a6581da2c2..494614e0c26d 100644 --- a/chart2/source/tools/ObjectIdentifier.cxx +++ b/chart2/source/tools/ObjectIdentifier.cxx @@ -30,6 +30,7 @@ #include <DiagramHelper.hxx> #include <Diagram.hxx> #include <unonames.hxx> +#include <BaseCoordinateSystem.hxx> #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> @@ -336,7 +337,7 @@ OUString ObjectIdentifier::createClassifiedIdentifierForObject( Reference< XAxis > xAxis( xObject, uno::UNO_QUERY ); if( xAxis.is() ) { - Reference< XCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemOfAxis( xAxis, rModel.getFirstDiagram() ) ); + rtl::Reference< BaseCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemOfAxis( xAxis, rModel.getFirstDiagram() ) ); OUString aCooSysParticle( createParticleForCoordinateSystem( xCooSys, rModel ) ); sal_Int32 nDimensionIndex=-1; sal_Int32 nAxisIndex=-1; |