diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2022-02-02 18:40:05 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-02-04 12:20:00 +0100 |
commit | fc03ef1e02da261073994e7478b08fa57b3ea962 (patch) | |
tree | d87507a55da82763b88cd6844471a895d8bf9ea8 /chart2/source/tools | |
parent | Revert typo fix, 'stringly typed' is the intended form (diff) | |
download | core-fc03ef1e02da261073994e7478b08fa57b3ea962.tar.gz core-fc03ef1e02da261073994e7478b08fa57b3ea962.zip |
use more concrete types in chart2, LabeledDataSequence
Change-Id: I88d5b7e045814cbd40750ebe927e6a76d5a463d1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129456
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 | 3 | ||||
-rw-r--r-- | chart2/source/tools/DataSourceHelper.cxx | 6 | ||||
-rw-r--r-- | chart2/source/tools/DiagramHelper.cxx | 39 | ||||
-rw-r--r-- | chart2/source/tools/InternalDataProvider.cxx | 6 |
4 files changed, 43 insertions, 11 deletions
diff --git a/chart2/source/tools/AxisHelper.cxx b/chart2/source/tools/AxisHelper.cxx index 76204c7e3a5a..c15b6f18a5f8 100644 --- a/chart2/source/tools/AxisHelper.cxx +++ b/chart2/source/tools/AxisHelper.cxx @@ -23,6 +23,7 @@ #include <ChartTypeHelper.hxx> #include <ChartType.hxx> #include <AxisIndexDefines.hxx> +#include <LabeledDataSequence.hxx> #include <LinePropertiesHelper.hxx> #include <servicenames_coosystems.hxx> #include <DataSeries.hxx> @@ -197,7 +198,7 @@ sal_Int32 AxisHelper::getExplicitNumberFormatKeyForAxis( DataSeriesHelper::getAllDataSequencesByRole( xSource->getDataSequences(), "values-x" ) ); if( aXValues.empty() ) { - Reference< data::XLabeledDataSequence > xCategories( DiagramHelper::getCategoriesFromDiagram( xDiagram ) ); + rtl::Reference< LabeledDataSequence > xCategories( DiagramHelper::getCategoriesFromDiagram( xDiagram ) ); if( xCategories.is() ) { Reference< data::XDataSequence > xSeq( xCategories->getValues()); diff --git a/chart2/source/tools/DataSourceHelper.cxx b/chart2/source/tools/DataSourceHelper.cxx index cb71316c87cd..33d613e6f25b 100644 --- a/chart2/source/tools/DataSourceHelper.cxx +++ b/chart2/source/tools/DataSourceHelper.cxx @@ -134,20 +134,20 @@ Reference< chart2::data::XDataSequence > DataSourceHelper::createCachedDataSeque return new ::chart::CachedDataSequence( rSingleText ); } -Reference< chart2::data::XLabeledDataSequence > DataSourceHelper::createLabeledDataSequence( +rtl::Reference< LabeledDataSequence > DataSourceHelper::createLabeledDataSequence( const Reference< chart2::data::XDataSequence >& xValues , const Reference< chart2::data::XDataSequence >& xLabels ) { return new ::chart::LabeledDataSequence( xValues, xLabels ); } -Reference< chart2::data::XLabeledDataSequence > DataSourceHelper::createLabeledDataSequence( +rtl::Reference< LabeledDataSequence > DataSourceHelper::createLabeledDataSequence( const Reference< chart2::data::XDataSequence >& xValues ) { return new ::chart::LabeledDataSequence( xValues ); } -Reference< chart2::data::XLabeledDataSequence > DataSourceHelper::createLabeledDataSequence() +rtl::Reference< LabeledDataSequence > DataSourceHelper::createLabeledDataSequence() { return new ::chart::LabeledDataSequence; } diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx index 15075593360c..a20c8bbd7510 100644 --- a/chart2/source/tools/DiagramHelper.cxx +++ b/chart2/source/tools/DiagramHelper.cxx @@ -29,6 +29,7 @@ #include <ChartModel.hxx> #include <ChartModelHelper.hxx> #include <ExplicitCategoriesProvider.hxx> +#include <LabeledDataSequence.hxx> #include <servicenames_charttypes.hxx> #include <RelativePositionHelper.hxx> #include <ControllerLockGuard.hxx> @@ -492,7 +493,7 @@ void DiagramHelper::replaceCoordinateSystem( try { - Reference< chart2::data::XLabeledDataSequence > xCategories = DiagramHelper::getCategoriesFromDiagram( xDiagram ); + rtl::Reference< LabeledDataSequence > xCategories = DiagramHelper::getCategoriesFromDiagram( xDiagram ); // move chart types of xCooSysToReplace to xReplacement xReplacement->setChartTypes( xCooSysToReplace->getChartTypes()); @@ -784,11 +785,38 @@ void DiagramHelper::setCategoriesToDiagram( } } -Reference< data::XLabeledDataSequence > +void DiagramHelper::setCategoriesToDiagram( + const rtl::Reference< LabeledDataSequence >& xCategories, + const rtl::Reference< Diagram >& xDiagram, + bool bSetAxisType /* = false */, + bool bCategoryAxis /* = true */ ) +{ + std::vector< Reference< chart2::XAxis > > aCatAxes( + lcl_getAxisHoldingCategoriesFromDiagram( xDiagram )); + + for (const Reference< chart2::XAxis >& xCatAxis : aCatAxes) + { + if( xCatAxis.is()) + { + ScaleData aScaleData( xCatAxis->getScaleData()); + aScaleData.Categories = xCategories; + if( bSetAxisType ) + { + if( bCategoryAxis ) + aScaleData.AxisType = AxisType::CATEGORY; + else if( aScaleData.AxisType == AxisType::CATEGORY || aScaleData.AxisType == AxisType::DATE ) + aScaleData.AxisType = AxisType::REALNUMBER; + } + xCatAxis->setScaleData( aScaleData ); + } + } +} + +rtl::Reference< LabeledDataSequence > DiagramHelper::getCategoriesFromDiagram( const rtl::Reference< Diagram > & xDiagram ) { - Reference< data::XLabeledDataSequence > xResult; + rtl::Reference< LabeledDataSequence > xResult; try { @@ -803,8 +831,9 @@ Reference< data::XLabeledDataSequence > ScaleData aScaleData( xCatAxis->getScaleData()); if( aScaleData.Categories.is() ) { - xResult.set( aScaleData.Categories ); - uno::Reference<beans::XPropertySet> xProp(aScaleData.Categories->getValues(), uno::UNO_QUERY ); + xResult = dynamic_cast<LabeledDataSequence*>(aScaleData.Categories.get()); + assert(!aScaleData.Categories || xResult); + uno::Reference<beans::XPropertySet> xProp(xResult->getValues(), uno::UNO_QUERY ); if( xProp.is() ) { try diff --git a/chart2/source/tools/InternalDataProvider.cxx b/chart2/source/tools/InternalDataProvider.cxx index a93003c6d7af..13f9bca3786c 100644 --- a/chart2/source/tools/InternalDataProvider.cxx +++ b/chart2/source/tools/InternalDataProvider.cxx @@ -377,8 +377,10 @@ InternalDataProvider::InternalDataProvider( else m_aInternalData.setComplexColumnLabels( std::move(aNewCategories) ); if( bConnectToModel ) - DiagramHelper::setCategoriesToDiagram( new LabeledDataSequence( - createDataSequenceByRangeRepresentation( lcl_aCategoriesRangeName )), xDiagram ); + DiagramHelper::setCategoriesToDiagram( + rtl::Reference< LabeledDataSequence >(new LabeledDataSequence( + createDataSequenceByRangeRepresentation( lcl_aCategoriesRangeName ))), + xDiagram ); } // data series |