chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx | 2 chart2/source/controller/main/ChartController_Tools.cxx | 5 - chart2/source/controller/main/ControllerCommandDispatch.cxx | 2 chart2/source/inc/DataSeriesHelper.hxx | 7 + chart2/source/tools/DataSeriesHelper.cxx | 48 ++++++---- chart2/source/view/charttypes/AreaChart.cxx | 11 +- chart2/source/view/charttypes/AreaChart.hxx | 2 chart2/source/view/charttypes/BarChart.cxx | 9 + chart2/source/view/charttypes/BarChart.hxx | 2 chart2/source/view/charttypes/BubbleChart.cxx | 3 chart2/source/view/charttypes/BubbleChart.hxx | 2 chart2/source/view/charttypes/CandleStickChart.cxx | 13 +- chart2/source/view/charttypes/CandleStickChart.hxx | 2 chart2/source/view/charttypes/NetChart.cxx | 3 chart2/source/view/charttypes/NetChart.hxx | 2 chart2/source/view/charttypes/PieChart.cxx | 13 +- chart2/source/view/charttypes/PieChart.hxx | 2 chart2/source/view/charttypes/VSeriesPlotter.cxx | 10 +- chart2/source/view/inc/VSeriesPlotter.hxx | 8 - chart2/source/view/main/ChartView.cxx | 31 ++---- 20 files changed, 98 insertions(+), 79 deletions(-)
New commits: commit 1b728994b89b1518137a538f57ee3d7e6644d8da Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Mon Jan 24 18:44:06 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Jan 25 06:54:44 2022 +0100 use more concrete types in chart2, ChartType Change-Id: Ia3d49d53548a843301449c0fea97b81ba85e71e9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128878 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/chart2/source/view/charttypes/AreaChart.cxx b/chart2/source/view/charttypes/AreaChart.cxx index e5409ce5dff1..3bb573da8538 100644 --- a/chart2/source/view/charttypes/AreaChart.cxx +++ b/chart2/source/view/charttypes/AreaChart.cxx @@ -24,6 +24,7 @@ #include <ExplicitCategoriesProvider.hxx> #include <ObjectIdentifier.hxx> #include "Splines.hxx" +#include <ChartType.hxx> #include <ChartTypeHelper.hxx> #include <LabelPositionHelper.hxx> #include <Clipping.hxx> @@ -51,7 +52,7 @@ namespace chart using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; -AreaChart::AreaChart( const uno::Reference<XChartType>& xChartTypeModel +AreaChart::AreaChart( const rtl::Reference<ChartType>& xChartTypeModel , sal_Int32 nDimensionCount , bool bCategoryXAxis , bool bNoArea @@ -73,11 +74,11 @@ AreaChart::AreaChart( const uno::Reference<XChartType>& xChartTypeModel try { - if( m_xChartTypeModelProps.is() ) + if( m_xChartTypeModel.is() ) { - m_xChartTypeModelProps->getPropertyValue(CHART_UNONAME_CURVE_STYLE) >>= m_eCurveStyle; - m_xChartTypeModelProps->getPropertyValue(CHART_UNONAME_CURVE_RESOLUTION) >>= m_nCurveResolution; - m_xChartTypeModelProps->getPropertyValue(CHART_UNONAME_SPLINE_ORDER) >>= m_nSplineOrder; + m_xChartTypeModel->getPropertyValue(CHART_UNONAME_CURVE_STYLE) >>= m_eCurveStyle; + m_xChartTypeModel->getPropertyValue(CHART_UNONAME_CURVE_RESOLUTION) >>= m_nCurveResolution; + m_xChartTypeModel->getPropertyValue(CHART_UNONAME_SPLINE_ORDER) >>= m_nSplineOrder; } } catch( uno::Exception& e ) diff --git a/chart2/source/view/charttypes/AreaChart.hxx b/chart2/source/view/charttypes/AreaChart.hxx index 23d8adb0b4f1..2f7434f3c5c3 100644 --- a/chart2/source/view/charttypes/AreaChart.hxx +++ b/chart2/source/view/charttypes/AreaChart.hxx @@ -32,7 +32,7 @@ class AreaChart : public VSeriesPlotter public: AreaChart() = delete; - AreaChart( const css::uno::Reference< css::chart2::XChartType >& xChartTypeModel + AreaChart( const rtl::Reference< ::chart::ChartType >& xChartTypeModel , sal_Int32 nDimensionCount , bool bCategoryXAxis, bool bNoArea=false ); diff --git a/chart2/source/view/charttypes/BarChart.cxx b/chart2/source/view/charttypes/BarChart.cxx index 938355192e35..f2dbf0d2422c 100644 --- a/chart2/source/view/charttypes/BarChart.cxx +++ b/chart2/source/view/charttypes/BarChart.cxx @@ -20,6 +20,7 @@ #include "BarChart.hxx" #include "BarPositionHelper.hxx" +#include <ChartType.hxx> #include <ShapeFactory.hxx> #include <CommonConverters.hxx> #include <ObjectIdentifier.hxx> @@ -44,7 +45,7 @@ using namespace ::com::sun::star; using namespace ::rtl::math; using namespace ::com::sun::star::chart2; -BarChart::BarChart( const uno::Reference<XChartType>& xChartTypeModel +BarChart::BarChart( const rtl::Reference<ChartType>& xChartTypeModel , sal_Int32 nDimensionCount ) : VSeriesPlotter( xChartTypeModel, nDimensionCount ) , m_pMainPosHelper( new BarPositionHelper() ) @@ -54,10 +55,10 @@ BarChart::BarChart( const uno::Reference<XChartType>& xChartTypeModel try { - if( m_xChartTypeModelProps.is() ) + if( m_xChartTypeModel.is() ) { - m_xChartTypeModelProps->getPropertyValue( "OverlapSequence" ) >>= m_aOverlapSequence; - m_xChartTypeModelProps->getPropertyValue( "GapwidthSequence" ) >>= m_aGapwidthSequence; + m_xChartTypeModel->getPropertyValue( "OverlapSequence" ) >>= m_aOverlapSequence; + m_xChartTypeModel->getPropertyValue( "GapwidthSequence" ) >>= m_aGapwidthSequence; } } catch( const uno::Exception& ) diff --git a/chart2/source/view/charttypes/BarChart.hxx b/chart2/source/view/charttypes/BarChart.hxx index 5e9ab5e49f48..badb65822837 100644 --- a/chart2/source/view/charttypes/BarChart.hxx +++ b/chart2/source/view/charttypes/BarChart.hxx @@ -32,7 +32,7 @@ class BarChart : public VSeriesPlotter public: BarChart() = delete; - BarChart( const css::uno::Reference< css::chart2::XChartType >& xChartTypeModel + BarChart( const rtl::Reference< ::chart::ChartType >& xChartTypeModel , sal_Int32 nDimensionCount ); virtual ~BarChart() override; diff --git a/chart2/source/view/charttypes/BubbleChart.cxx b/chart2/source/view/charttypes/BubbleChart.cxx index fc7fcdd2597b..bf97f39c5061 100644 --- a/chart2/source/view/charttypes/BubbleChart.cxx +++ b/chart2/source/view/charttypes/BubbleChart.cxx @@ -22,6 +22,7 @@ #include <ShapeFactory.hxx> #include <ObjectIdentifier.hxx> #include <LabelPositionHelper.hxx> +#include <ChartType.hxx> #include <com/sun/star/chart/DataLabelPlacement.hpp> #include <sal/log.hxx> @@ -34,7 +35,7 @@ namespace chart using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; -BubbleChart::BubbleChart( const uno::Reference<XChartType>& xChartTypeModel +BubbleChart::BubbleChart( const rtl::Reference<ChartType>& xChartTypeModel , sal_Int32 nDimensionCount ) : VSeriesPlotter( xChartTypeModel, nDimensionCount, false ) , m_fMaxLogicBubbleSize( 0.0 ) diff --git a/chart2/source/view/charttypes/BubbleChart.hxx b/chart2/source/view/charttypes/BubbleChart.hxx index 06d1d1200340..c25e5b6345bf 100644 --- a/chart2/source/view/charttypes/BubbleChart.hxx +++ b/chart2/source/view/charttypes/BubbleChart.hxx @@ -30,7 +30,7 @@ class BubbleChart : public VSeriesPlotter public: BubbleChart() = delete; - BubbleChart( const css::uno::Reference< css::chart2::XChartType >& xChartTypeModel + BubbleChart( const rtl::Reference< ::chart::ChartType >& xChartTypeModel , sal_Int32 nDimensionCount ); virtual ~BubbleChart() override; diff --git a/chart2/source/view/charttypes/CandleStickChart.cxx b/chart2/source/view/charttypes/CandleStickChart.cxx index 44fcd600bd49..f1b11492ee60 100644 --- a/chart2/source/view/charttypes/CandleStickChart.cxx +++ b/chart2/source/view/charttypes/CandleStickChart.cxx @@ -18,6 +18,7 @@ */ #include "CandleStickChart.hxx" +#include <ChartType.hxx> #include <ShapeFactory.hxx> #include <CommonConverters.hxx> #include <ExplicitCategoriesProvider.hxx> @@ -33,7 +34,7 @@ namespace chart using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; -CandleStickChart::CandleStickChart( const uno::Reference<XChartType>& xChartTypeModel +CandleStickChart::CandleStickChart( const rtl::Reference<ChartType>& xChartTypeModel , sal_Int32 nDimensionCount ) : VSeriesPlotter( xChartTypeModel, nDimensionCount ) , m_pMainPosHelper( new BarPositionHelper() ) @@ -104,15 +105,15 @@ void CandleStickChart::createShapes() tAnySequence aWhiteBox_Values, aBlackBox_Values; try { - if( m_xChartTypeModelProps.is() ) + if( m_xChartTypeModel.is() ) { - m_xChartTypeModelProps->getPropertyValue( "ShowFirst" ) >>= bShowFirst; + m_xChartTypeModel->getPropertyValue( "ShowFirst" ) >>= bShowFirst; uno::Reference< beans::XPropertySet > xWhiteDayProps; uno::Reference< beans::XPropertySet > xBlackDayProps; - m_xChartTypeModelProps->getPropertyValue( "Japanese" ) >>= bJapaneseStyle; - m_xChartTypeModelProps->getPropertyValue( "WhiteDay" ) >>= xWhiteDayProps; - m_xChartTypeModelProps->getPropertyValue( "BlackDay" ) >>= xBlackDayProps; + m_xChartTypeModel->getPropertyValue( "Japanese" ) >>= bJapaneseStyle; + m_xChartTypeModel->getPropertyValue( "WhiteDay" ) >>= xWhiteDayProps; + m_xChartTypeModel->getPropertyValue( "BlackDay" ) >>= xBlackDayProps; tPropertyNameValueMap aWhiteBox_Map; PropertyMapper::getValueMap( aWhiteBox_Map, PropertyMapper::getPropertyNameMapForFillAndLineProperties(), xWhiteDayProps ); diff --git a/chart2/source/view/charttypes/CandleStickChart.hxx b/chart2/source/view/charttypes/CandleStickChart.hxx index eddee6b72e12..93571889ee6d 100644 --- a/chart2/source/view/charttypes/CandleStickChart.hxx +++ b/chart2/source/view/charttypes/CandleStickChart.hxx @@ -32,7 +32,7 @@ class CandleStickChart : public VSeriesPlotter public: CandleStickChart() = delete; - CandleStickChart( const css::uno::Reference< css::chart2::XChartType >& xChartTypeModel + CandleStickChart( const rtl::Reference< ::chart::ChartType >& xChartTypeModel , sal_Int32 nDimensionCount ); virtual ~CandleStickChart() override; diff --git a/chart2/source/view/charttypes/NetChart.cxx b/chart2/source/view/charttypes/NetChart.cxx index 5507e30e0579..ada893b8d152 100644 --- a/chart2/source/view/charttypes/NetChart.cxx +++ b/chart2/source/view/charttypes/NetChart.cxx @@ -27,6 +27,7 @@ #include <Clipping.hxx> #include <PolarLabelPositionHelper.hxx> #include <DateHelper.hxx> +#include <ChartType.hxx> #include <com/sun/star/chart2/Symbol.hpp> #include <com/sun/star/chart/DataLabelPlacement.hpp> @@ -44,7 +45,7 @@ namespace chart using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; -NetChart::NetChart( const uno::Reference<XChartType>& xChartTypeModel +NetChart::NetChart( const rtl::Reference<ChartType>& xChartTypeModel , sal_Int32 nDimensionCount , bool bNoArea , std::unique_ptr<PlottingPositionHelper> pPlottingPositionHelper diff --git a/chart2/source/view/charttypes/NetChart.hxx b/chart2/source/view/charttypes/NetChart.hxx index 9883ba118ac2..42d06570e9f2 100644 --- a/chart2/source/view/charttypes/NetChart.hxx +++ b/chart2/source/view/charttypes/NetChart.hxx @@ -31,7 +31,7 @@ class NetChart : public VSeriesPlotter public: NetChart() = delete; - NetChart( const css::uno::Reference< css::chart2::XChartType >& xChartTypeModel + NetChart( const rtl::Reference< ::chart::ChartType >& xChartTypeModel , sal_Int32 nDimensionCount , bool bNoArea , std::unique_ptr<PlottingPositionHelper> pPlottingPositionHelper //takes ownership diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index 2fd709500d29..d05f10070598 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -25,6 +25,7 @@ #include <PolarLabelPositionHelper.hxx> #include <CommonConverters.hxx> #include <ObjectIdentifier.hxx> +#include <ChartType.hxx> #include <com/sun/star/chart/DataLabelPlacement.hpp> #include <com/sun/star/chart2/XChartType.hpp> @@ -191,7 +192,7 @@ bool PiePositionHelper::getInnerAndOuterRadius( double fCategoryX return true; } -PieChart::PieChart( const uno::Reference<XChartType>& xChartTypeModel +PieChart::PieChart( const rtl::Reference<ChartType>& xChartTypeModel , sal_Int32 nDimensionCount , bool bExcludingPositioning ) : VSeriesPlotter( xChartTypeModel, nDimensionCount ) @@ -205,13 +206,12 @@ PieChart::PieChart( const uno::Reference<XChartType>& xChartTypeModel m_pPosHelper->m_fRadiusOffset = 0.0; m_pPosHelper->m_fRingDistance = 0.0; - uno::Reference< beans::XPropertySet > xChartTypeProps( xChartTypeModel, uno::UNO_QUERY ); - if( !xChartTypeProps.is() ) + if( !xChartTypeModel.is() ) return; try { - xChartTypeProps->getPropertyValue( "UseRings") >>= m_bUseRings; + xChartTypeModel->getPropertyValue( "UseRings") >>= m_bUseRings; if( m_bUseRings ) { m_pPosHelper->m_fRadiusOffset = 1.0; @@ -704,12 +704,11 @@ void PieChart::createShapes() m_aLabelInfoList.clear(); m_fMaxOffset = std::numeric_limits<double>::quiet_NaN(); sal_Int32 n3DRelativeHeight = 100; - uno::Reference< beans::XPropertySet > xPropertySet( m_xChartTypeModel, uno::UNO_QUERY ); - if ( (m_nDimension==3) && xPropertySet.is()) + if ( (m_nDimension==3) && m_xChartTypeModel.is()) { try { - uno::Any aAny = xPropertySet->getPropertyValue( "3DRelativeHeight" ); + uno::Any aAny = m_xChartTypeModel->getPropertyValue( "3DRelativeHeight" ); aAny >>= n3DRelativeHeight; } catch (const uno::Exception&) { } diff --git a/chart2/source/view/charttypes/PieChart.hxx b/chart2/source/view/charttypes/PieChart.hxx index 5bd25eed53e6..cb6b92dddae7 100644 --- a/chart2/source/view/charttypes/PieChart.hxx +++ b/chart2/source/view/charttypes/PieChart.hxx @@ -35,7 +35,7 @@ class PieChart : public VSeriesPlotter public: PieChart() = delete; - PieChart( const css::uno::Reference< css::chart2::XChartType >& xChartTypeModel + PieChart( const rtl::Reference< ::chart::ChartType >& xChartTypeModel , sal_Int32 nDimensionCount, bool bExcludingPositioning ); virtual ~PieChart() override; diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx index 8f0c19e83078..5eab49ee6d4a 100644 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -32,6 +32,7 @@ #include <StatisticsHelper.hxx> #include <PlottingPositionHelper.hxx> #include <LabelPositionHelper.hxx> +#include <ChartType.hxx> #include <ChartTypeHelper.hxx> #include <Clipping.hxx> #include <servicenames_charttypes.hxx> @@ -138,12 +139,11 @@ sal_Int32 VDataSeriesGroup::getSeriesCount() const return m_aSeriesVector.size(); } -VSeriesPlotter::VSeriesPlotter( const uno::Reference<XChartType>& xChartTypeModel +VSeriesPlotter::VSeriesPlotter( const rtl::Reference<ChartType>& xChartTypeModel , sal_Int32 nDimensionCount, bool bCategoryXAxis ) : PlotterBase( nDimensionCount ) , m_pMainPosHelper( nullptr ) , m_xChartTypeModel(xChartTypeModel) - , m_xChartTypeModelProps( uno::Reference< beans::XPropertySet >::query( xChartTypeModel )) , m_bCategoryXAxis(bCategoryXAxis) , m_nTimeResolution(css::chart::TimeUnit::DAY) , m_aNullDate(30,12,1899) @@ -2647,10 +2647,10 @@ std::vector< ViewLegendEntry > VSeriesPlotter::createLegendEntriesForSeries( CHART2_SERVICE_NAME_CHARTTYPE_PIE); try { - if (bIsPie && m_xChartTypeModelProps.is()) + if (bIsPie) { bool bDonut = false; - if ((m_xChartTypeModelProps->getPropertyValue("UseRings") >>= bDonut) && bDonut) + if ((m_xChartTypeModel->getPropertyValue("UseRings") >>= bDonut) && bDonut) bIsPie = false; } } @@ -2792,7 +2792,7 @@ std::vector< ViewLegendEntry > VSeriesPlotter::createLegendEntriesForSeries( } VSeriesPlotter* VSeriesPlotter::createSeriesPlotter( - const uno::Reference<XChartType>& xChartTypeModel + const rtl::Reference<ChartType>& xChartTypeModel , sal_Int32 nDimensionCount , bool bExcludingPositioning ) { diff --git a/chart2/source/view/inc/VSeriesPlotter.hxx b/chart2/source/view/inc/VSeriesPlotter.hxx index 83d97bc8b671..2182be97dcdb 100644 --- a/chart2/source/view/inc/VSeriesPlotter.hxx +++ b/chart2/source/view/inc/VSeriesPlotter.hxx @@ -49,6 +49,7 @@ namespace com::sun::star { namespace chart { +class ChartType; class NumberFormatterWrapper; class AxesNumberFormats @@ -218,7 +219,7 @@ public: std::vector< VDataSeries* > getAllSeries(); // This method creates a series plotter of the requested type; e.g. : return new PieChart... - static VSeriesPlotter* createSeriesPlotter( const css::uno::Reference< css::chart2::XChartType >& xChartTypeModel + static VSeriesPlotter* createSeriesPlotter( const rtl::Reference< ::chart::ChartType >& xChartTypeModel , sal_Int32 nDimensionCount , bool bExcludingPositioning /*for pie and donut charts labels and exploded segments are excluded from the given size*/); @@ -254,7 +255,7 @@ public: protected: - VSeriesPlotter( const css::uno::Reference< css::chart2::XChartType >& xChartTypeModel + VSeriesPlotter( const rtl::Reference< ::chart::ChartType >& xChartTypeModel , sal_Int32 nDimensionCount , bool bCategoryXAxis=true ); @@ -398,8 +399,7 @@ protected: protected: PlottingPositionHelper* m_pMainPosHelper; - css::uno::Reference< css::chart2::XChartType > m_xChartTypeModel; - css::uno::Reference< css::beans::XPropertySet > m_xChartTypeModelProps; + rtl::Reference< ::chart::ChartType > m_xChartTypeModel; std::vector< std::vector< VDataSeriesGroup > > m_aZSlots; diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 792ebd6fa3cd..d2a6c8ef797d 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -492,25 +492,21 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter( TOOLS_WARN_EXCEPTION("chart2", "" ); } //iterate through all chart types in the current coordinate system - uno::Sequence< uno::Reference< XChartType > > aChartTypeList( xCooSys->getChartTypes() ); - for( sal_Int32 nT = 0; nT < aChartTypeList.getLength(); ++nT ) + std::vector< rtl::Reference< ChartType > > aChartTypeList( xCooSys->getChartTypes2() ); + for( sal_Int32 nT = 0; nT < static_cast<sal_Int32>(aChartTypeList.size()); ++nT ) { - uno::Reference< XChartType > xChartType( aChartTypeList[nT] ); + rtl::Reference< ChartType > xChartType( aChartTypeList[nT] ); if(nDimensionCount == 3 && xChartType->getChartType().equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_PIE)) { - uno::Reference< beans::XPropertySet > xPropertySet( xChartType, uno::UNO_QUERY ); - if (xPropertySet.is()) + try { - try - { - sal_Int32 n3DRelativeHeightOldValue(100); - uno::Any aAny = xPropertySet->getPropertyValue( "3DRelativeHeight" ); - aAny >>= n3DRelativeHeightOldValue; - if (n3DRelativeHeightOldValue != n3DRelativeHeight) - xPropertySet->setPropertyValue( "3DRelativeHeight", uno::Any(n3DRelativeHeight) ); - } - catch (const uno::Exception&) { } + sal_Int32 n3DRelativeHeightOldValue(100); + uno::Any aAny = xChartType->getPropertyValue( "3DRelativeHeight" ); + aAny >>= n3DRelativeHeightOldValue; + if (n3DRelativeHeightOldValue != n3DRelativeHeight) + xChartType->setPropertyValue( "3DRelativeHeight", uno::Any(n3DRelativeHeight) ); } + catch (const uno::Exception&) { } } if(nT==0) @@ -531,15 +527,10 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter( if(pVCooSys) pVCooSys->addMinimumAndMaximumSupplier(pPlotter); - uno::Reference< XDataSeriesContainer > xDataSeriesContainer( xChartType, uno::UNO_QUERY ); - OSL_ASSERT( xDataSeriesContainer.is()); - if( !xDataSeriesContainer.is() ) - continue; - sal_Int32 zSlot=-1; sal_Int32 xSlot=-1; sal_Int32 ySlot=-1; - uno::Sequence< uno::Reference< XDataSeries > > aSeriesList( xDataSeriesContainer->getDataSeries() ); + uno::Sequence< uno::Reference< XDataSeries > > aSeriesList( xChartType->getDataSeries() ); for( sal_Int32 nS = 0; nS < aSeriesList.getLength(); ++nS ) { uno::Reference< XDataSeries > const & xDataSeries = aSeriesList[nS]; commit bf691e4598ae51b534d004ce21f839081dcd3df9 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Mon Jan 24 18:39:12 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Jan 25 06:54:28 2022 +0100 use more concrete types in chart2, ChartType Change-Id: I91acfea8bbac90fe505aae587299fae2b709ca86 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128877 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx index a048fa820759..8d49237ddcaa 100644 --- a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx @@ -540,7 +540,7 @@ bool DataSeriesPointWrapper::isSupportingAreaProperties() { Reference< chart2::XDataSeries > xSeries( getDataSeries() ); rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); - Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) ); + rtl::Reference< ::chart::ChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) ); sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); return ChartTypeHelper::isSupportingAreaProperties( xChartType, nDimensionCount ); diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx index 7b9c28de63e5..7e98471060a3 100644 --- a/chart2/source/controller/main/ChartController_Tools.cxx +++ b/chart2/source/controller/main/ChartController_Tools.cxx @@ -21,6 +21,7 @@ #include <ChartWindow.hxx> #include <ChartModel.hxx> #include <ChartModelHelper.hxx> +#include <ChartType.hxx> #include <TitleHelper.hxx> #include <ThreeDHelper.hxx> #include <DataSeriesHelper.hxx> @@ -100,8 +101,8 @@ bool lcl_deleteDataSeries( uno::Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( rCID, xModel )); if( xSeries.is() && xModel.is()) { - uno::Reference< chart2::XChartType > xChartType( - DataSeriesHelper::getChartTypeOfSeries( xSeries, xModel->getFirstDiagram())); + rtl::Reference< ::chart::ChartType > xChartType = + DataSeriesHelper::getChartTypeOfSeries( xSeries, xModel->getFirstDiagram()); if( xChartType.is()) { UndoGuard aUndoGuard( diff --git a/chart2/source/controller/main/ControllerCommandDispatch.cxx b/chart2/source/controller/main/ControllerCommandDispatch.cxx index 91d3dfe3e558..e1e2c946cf0f 100644 --- a/chart2/source/controller/main/ControllerCommandDispatch.cxx +++ b/chart2/source/controller/main/ControllerCommandDispatch.cxx @@ -242,7 +242,7 @@ void ControllerState::update( { bMayAddMenuTrendline = true; sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); - uno::Reference< chart2::XChartType > xFirstChartType( + rtl::Reference< ::chart::ChartType > xFirstChartType( DataSeriesHelper::getChartTypeOfSeries( xGivenDataSeries, xDiagram )); // trend lines/mean value line diff --git a/chart2/source/inc/DataSeriesHelper.hxx b/chart2/source/inc/DataSeriesHelper.hxx index bda6d4f0796c..512fe85f431e 100644 --- a/chart2/source/inc/DataSeriesHelper.hxx +++ b/chart2/source/inc/DataSeriesHelper.hxx @@ -37,6 +37,7 @@ namespace com::sun::star::chart2::data { class XLabeledDataSequence; } namespace com::sun::star::uno { class Any; } namespace com::sun::star::uno { template <class E> class Sequence; } namespace chart { class BaseCoordinateSystem; } +namespace chart { class ChartType; } namespace chart::DataSeriesHelper { @@ -122,7 +123,7 @@ rtl::Reference< ::chart::BaseCoordinateSystem > const css::uno::Reference< css::chart2::XDiagram > & xDiagram ); OOO_DLLPUBLIC_CHARTTOOLS -css::uno::Reference< css::chart2::XChartType > +rtl::Reference< ::chart::ChartType > getChartTypeOfSeries( const css::uno::Reference< css::chart2::XDataSeries > & xSeries, const css::uno::Reference< css::chart2::XDiagram > & xDiagram ); @@ -131,6 +132,10 @@ OOO_DLLPUBLIC_CHARTTOOLS void deleteSeries( const css::uno::Reference< css::chart2::XDataSeries > & xSeries, const css::uno::Reference< css::chart2::XChartType > & xChartType ); +OOO_DLLPUBLIC_CHARTTOOLS void deleteSeries( + const css::uno::Reference< css::chart2::XDataSeries > & xSeries, + const rtl::Reference< ::chart::ChartType > & xChartType ); + OOO_DLLPUBLIC_CHARTTOOLS void switchSymbolsOnOrOff( const css::uno::Reference< css::beans::XPropertySet > & xSeriesProperties, bool bSymbolsOn, sal_Int32 nSeriesIndex ); diff --git a/chart2/source/tools/DataSeriesHelper.cxx b/chart2/source/tools/DataSeriesHelper.cxx index ed90d3a8c207..ca87ca29773e 100644 --- a/chart2/source/tools/DataSeriesHelper.cxx +++ b/chart2/source/tools/DataSeriesHelper.cxx @@ -19,6 +19,7 @@ #include <DataSeriesHelper.hxx> #include <DataSource.hxx> +#include <ChartType.hxx> #include <unonames.hxx> #include <Diagram.hxx> #include <BaseCoordinateSystem.hxx> @@ -111,7 +112,7 @@ void lcl_getCooSysAndChartTypeOfSeries( const Reference< chart2::XDataSeries > & xSeries, const Reference< chart2::XDiagram > & xDiagram, rtl::Reference< ::chart::BaseCoordinateSystem > & xOutCooSys, - Reference< chart2::XChartType > & xOutChartType ) + rtl::Reference< ::chart::ChartType > & xOutChartType ) { if( !xDiagram.is()) return; @@ -119,20 +120,15 @@ void lcl_getCooSysAndChartTypeOfSeries( for( rtl::Reference< ::chart::BaseCoordinateSystem > const & coords : pDiagram->getBaseCoordinateSystems() ) { - const Sequence< Reference< chart2::XChartType > > aChartTypes( coords->getChartTypes()); - for( Reference< chart2::XChartType > const & chartType : aChartTypes ) + for( rtl::Reference< ::chart::ChartType > const & chartType : coords->getChartTypes2() ) { - Reference< chart2::XDataSeriesContainer > xSeriesCnt( chartType, uno::UNO_QUERY ); - if( xSeriesCnt.is()) + const Sequence< Reference< chart2::XDataSeries > > aSeries( chartType->getDataSeries()); + for( Reference< chart2::XDataSeries > const & dataSeries : aSeries ) { - const Sequence< Reference< chart2::XDataSeries > > aSeries( xSeriesCnt->getDataSeries()); - for( Reference< chart2::XDataSeries > const & dataSeries : aSeries ) + if( dataSeries == xSeries ) { - if( dataSeries == xSeries ) - { - xOutCooSys = coords; - xOutChartType.set( chartType ); - } + xOutCooSys = coords; + xOutChartType = chartType; } } } @@ -491,17 +487,17 @@ rtl::Reference< ::chart::BaseCoordinateSystem > getCoordinateSystemOfSeries( const Reference< chart2::XDiagram > & xDiagram ) { rtl::Reference< ::chart::BaseCoordinateSystem > xResult; - Reference< chart2::XChartType > xDummy; + rtl::Reference< ::chart::ChartType > xDummy; lcl_getCooSysAndChartTypeOfSeries( xSeries, xDiagram, xResult, xDummy ); return xResult; } -Reference< chart2::XChartType > getChartTypeOfSeries( +rtl::Reference< ::chart::ChartType > getChartTypeOfSeries( const Reference< chart2::XDataSeries > & xSeries, const Reference< chart2::XDiagram > & xDiagram ) { - Reference< chart2::XChartType > xResult; + rtl::Reference< ::chart::ChartType > xResult; rtl::Reference< ::chart::BaseCoordinateSystem > xDummy; lcl_getCooSysAndChartTypeOfSeries( xSeries, xDiagram, xDummy, xResult ); @@ -531,6 +527,28 @@ void deleteSeries( } } +void deleteSeries( + const Reference< chart2::XDataSeries > & xSeries, + const rtl::Reference< ::chart::ChartType > & xChartType ) +{ + try + { + auto aSeries( + comphelper::sequenceToContainer<std::vector< Reference< chart2::XDataSeries > > >( xChartType->getDataSeries())); + std::vector< Reference< chart2::XDataSeries > >::iterator aIt = + std::find( aSeries.begin(), aSeries.end(), xSeries ); + if( aIt != aSeries.end()) + { + aSeries.erase( aIt ); + xChartType->setDataSeries( comphelper::containerToSequence( aSeries )); + } + } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); + } +} + void switchSymbolsOnOrOff( const Reference< beans::XPropertySet > & xSeriesProperties, bool bSymbolsOn, sal_Int32 nSeriesIndex ) {