diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-03-16 09:20:17 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-03-20 17:54:39 +0000 |
commit | 70595c0291e4cc137158c77f6136025b10ce6728 (patch) | |
tree | c8c8c7df0c15f3e4db749774f37081613483a2d5 /chart2/source/model | |
parent | e7d5e346677efeb7d7d14537a9151ea7a1a32809 (diff) |
move setDimension/getDimension inside chart2::Diagram
Change-Id: If52f92e152011ead81a1b25f30ba15124e6a8e75
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149151
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2/source/model')
-rw-r--r-- | chart2/source/model/main/Diagram.cxx | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/chart2/source/model/main/Diagram.cxx b/chart2/source/model/main/Diagram.cxx index b3670bc37ee6..a52713c27d93 100644 --- a/chart2/source/model/main/Diagram.cxx +++ b/chart2/source/model/main/Diagram.cxx @@ -1366,6 +1366,80 @@ void Diagram::replaceCoordinateSystem( } } +sal_Int32 Diagram::getDimension() +{ + // -1: not yet set + sal_Int32 nResult = -1; + + try + { + for( rtl::Reference< BaseCoordinateSystem > const & xCooSys : getBaseCoordinateSystems() ) + { + if(xCooSys.is()) + { + nResult = xCooSys->getDimension(); + break; + } + } + } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); + } + + return nResult; +} + +void Diagram::setDimension( sal_Int32 nNewDimensionCount ) +{ + if( getDimension() == nNewDimensionCount ) + return; + + try + { + bool rbFound = false; + bool rbAmbiguous = true; + StackMode eStackMode = DiagramHelper::getStackMode( this, rbFound, rbAmbiguous ); + bool bIsSupportingOnlyDeepStackingFor3D=false; + + //change all coordinate systems: + auto aCoordSystems = getBaseCoordinateSystems(); + for( rtl::Reference<BaseCoordinateSystem> const & xOldCooSys : aCoordSystems ) + { + rtl::Reference< BaseCoordinateSystem > xNewCooSys; + + const std::vector< rtl::Reference< ChartType > > aChartTypeList( xOldCooSys->getChartTypes2() ); + for( rtl::Reference< ChartType > const & xChartType : aChartTypeList ) + { + bIsSupportingOnlyDeepStackingFor3D = ChartTypeHelper::isSupportingOnlyDeepStackingFor3D( xChartType ); + if(!xNewCooSys.is()) + { + xNewCooSys = dynamic_cast<BaseCoordinateSystem*>(xChartType->createCoordinateSystem( nNewDimensionCount ).get()); + assert(xNewCooSys); + break; + } + //@todo make sure that all following charttypes are also capable of the new dimension + //otherwise separate them in a different group + //BM: might be done in replaceCoordinateSystem() + } + + // replace the old coordinate system at all places where it was used + replaceCoordinateSystem( xOldCooSys, xNewCooSys ); + } + + //correct stack mode if necessary + if( nNewDimensionCount==3 && eStackMode != StackMode::ZStacked && bIsSupportingOnlyDeepStackingFor3D ) + DiagramHelper::setStackMode( this, StackMode::ZStacked ); + else if( nNewDimensionCount==2 && eStackMode == StackMode::ZStacked ) + DiagramHelper::setStackMode( this, StackMode::NONE ); + } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); + } +} + + } // namespace chart extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * |