summaryrefslogtreecommitdiffstats
path: root/chart2/source/tools
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-02-07 12:32:49 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-02-07 18:28:05 +0100
commitd9ff5556e7b24c7548a476862726b4bd54425047 (patch)
tree9ff52d13e4a937e2eaccf45b46f0e9a2fde0f12f /chart2/source/tools
parentUpdate git submodules (diff)
downloadcore-d9ff5556e7b24c7548a476862726b4bd54425047.tar.gz
core-d9ff5556e7b24c7548a476862726b4bd54425047.zip
use more concrete types in chart2, DataSeries
Change-Id: If92f6ff6f90d53a9dc6211fd9f071d4d3fce2997 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129535 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2/source/tools')
-rw-r--r--chart2/source/tools/DataSeriesHelper.cxx78
-rw-r--r--chart2/source/tools/DiagramHelper.cxx8
2 files changed, 78 insertions, 8 deletions
diff --git a/chart2/source/tools/DataSeriesHelper.cxx b/chart2/source/tools/DataSeriesHelper.cxx
index 8ba8c3529f25..5f7ae4fcef5b 100644
--- a/chart2/source/tools/DataSeriesHelper.cxx
+++ b/chart2/source/tools/DataSeriesHelper.cxx
@@ -517,6 +517,69 @@ void setStackModeAtSeries(
}
}
+void setStackModeAtSeries(
+ const std::vector< rtl::Reference< DataSeries > > & aSeries,
+ const rtl::Reference< BaseCoordinateSystem > & xCorrespondingCoordinateSystem,
+ StackMode eStackMode )
+{
+ const uno::Any aPropValue(
+ ( (eStackMode == StackMode::YStacked) ||
+ (eStackMode == StackMode::YStackedPercent) )
+ ? chart2::StackingDirection_Y_STACKING
+ : (eStackMode == StackMode::ZStacked )
+ ? chart2::StackingDirection_Z_STACKING
+ : chart2::StackingDirection_NO_STACKING );
+
+ std::set< sal_Int32 > aAxisIndexSet;
+ for( rtl::Reference< DataSeries > const & dataSeries : aSeries )
+ {
+ try
+ {
+ if( dataSeries.is() )
+ {
+ dataSeries->setPropertyValue( "StackingDirection", aPropValue );
+
+ sal_Int32 nAxisIndex;
+ dataSeries->getPropertyValue( "AttachedAxisIndex" ) >>= nAxisIndex;
+ aAxisIndexSet.insert(nAxisIndex);
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+
+ if( !(xCorrespondingCoordinateSystem.is() &&
+ 1 < xCorrespondingCoordinateSystem->getDimension()) )
+ return;
+
+ if( aAxisIndexSet.empty() )
+ {
+ aAxisIndexSet.insert(0);
+ }
+
+ for (auto const& axisIndex : aAxisIndexSet)
+ {
+ rtl::Reference< Axis > xAxis =
+ xCorrespondingCoordinateSystem->getAxisByDimension2(1, axisIndex);
+ if( xAxis.is())
+ {
+ bool bPercent = (eStackMode == StackMode::YStackedPercent);
+ chart2::ScaleData aScaleData = xAxis->getScaleData();
+
+ if( bPercent != (aScaleData.AxisType==chart2::AxisType::PERCENT) )
+ {
+ if( bPercent )
+ aScaleData.AxisType = chart2::AxisType::PERCENT;
+ else
+ aScaleData.AxisType = chart2::AxisType::REALNUMBER;
+ xAxis->setScaleData( aScaleData );
+ }
+ }
+ }
+}
+
sal_Int32 getAttachedAxisIndex( const Reference< chart2::XDataSeries > & xSeries )
{
sal_Int32 nRet = 0;
@@ -661,13 +724,20 @@ void makeLinesThickOrThin( const Reference< beans::XPropertySet > & xSeriesPrope
void setPropertyAlsoToAllAttributedDataPoints( const Reference< chart2::XDataSeries >& xSeries,
const OUString& rPropertyName, const uno::Any& rPropertyValue )
{
- Reference< beans::XPropertySet > xSeriesProperties( xSeries, uno::UNO_QUERY );
- if( !xSeriesProperties.is() )
+ rtl::Reference<DataSeries> pSeries = dynamic_cast<DataSeries*>(xSeries.get());
+ assert(!xSeries || pSeries);
+ setPropertyAlsoToAllAttributedDataPoints(pSeries, rPropertyName, rPropertyValue);
+}
+
+void setPropertyAlsoToAllAttributedDataPoints( const rtl::Reference< ::chart::DataSeries >& xSeries,
+ const OUString& rPropertyName, const uno::Any& rPropertyValue )
+{
+ if( !xSeries.is() )
return;
- xSeriesProperties->setPropertyValue( rPropertyName, rPropertyValue );
+ xSeries->setPropertyValue( rPropertyName, rPropertyValue );
uno::Sequence< sal_Int32 > aAttributedDataPointIndexList;
- if( xSeriesProperties->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList )
+ if( xSeries->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList )
{
for(sal_Int32 nN=aAttributedDataPointIndexList.getLength();nN--;)
{
diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx
index 53c530810b7b..463e059c7b9a 100644
--- a/chart2/source/tools/DiagramHelper.cxx
+++ b/chart2/source/tools/DiagramHelper.cxx
@@ -630,13 +630,13 @@ std::vector< rtl::Reference< ::chart::DataSeries > >
return aResult;
}
-Sequence< Sequence< Reference< XDataSeries > > >
+std::vector< std::vector< rtl::Reference< DataSeries > > >
DiagramHelper::getDataSeriesGroups( const rtl::Reference< Diagram > & xDiagram )
{
if (!xDiagram)
return {};
- vector< Sequence< Reference< XDataSeries > > > aResult;
+ vector< std::vector< rtl::Reference< DataSeries > > > aResult;
//iterate through all coordinate systems
for( rtl::Reference< BaseCoordinateSystem > const & coords : xDiagram->getBaseCoordinateSystems() )
@@ -644,10 +644,10 @@ Sequence< Sequence< Reference< XDataSeries > > >
//iterate through all chart types in the current coordinate system
for( rtl::Reference< ChartType > const & chartType : coords->getChartTypes2() )
{
- aResult.push_back( chartType->getDataSeries() );
+ aResult.push_back( chartType->getDataSeries2() );
}
}
- return comphelper::containerToSequence( aResult );
+ return aResult;
}
rtl::Reference< ChartType >