From 8a728ac6cf7d8d032eb93f486618458b7814d42b Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 19 Jan 2022 21:02:51 +0200 Subject: use more concrete types in chart2, ChartType Change-Id: Ibd299e2e8d82169706d810af98c29d684809c320 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128741 Tested-by: Jenkins Reviewed-by: Noel Grandin --- .../chartapiwrapper/DataSeriesPointWrapper.cxx | 1 + .../controller/chartapiwrapper/DiagramWrapper.cxx | 5 +- .../chartapiwrapper/MinMaxLineWrapper.cxx | 51 ++++---- .../chartapiwrapper/UpDownBarWrapper.cxx | 21 +-- .../chartapiwrapper/WrappedGapwidthProperty.cxx | 51 ++++---- .../chartapiwrapper/WrappedSplineProperties.cxx | 21 +-- .../chartapiwrapper/WrappedSymbolProperties.cxx | 3 +- .../source/controller/dialogs/DataBrowserModel.cxx | 12 +- chart2/source/controller/dialogs/DialogModel.cxx | 13 +- .../controller/dialogs/ObjectNameProvider.cxx | 3 +- .../controller/dialogs/dlg_ObjectProperties.cxx | 3 +- .../controller/dialogs/tp_3D_SceneGeometry.cxx | 1 + .../itemsetwrapper/AxisItemConverter.cxx | 1 + .../itemsetwrapper/DataPointItemConverter.cxx | 3 +- .../itemsetwrapper/SeriesOptionsItemConverter.cxx | 39 +++--- .../itemsetwrapper/TextLabelItemConverter.cxx | 3 +- .../controller/main/ChartController_Properties.cxx | 3 +- .../controller/main/ChartController_Window.cxx | 19 ++- .../controller/main/ControllerCommandDispatch.cxx | 3 +- .../controller/main/DragMethod_RotateDiagram.cxx | 1 + chart2/source/controller/main/ObjectHierarchy.cxx | 3 +- chart2/source/inc/AxisHelper.hxx | 5 +- chart2/source/inc/BaseCoordinateSystem.hxx | 5 +- chart2/source/inc/ChartModelHelper.hxx | 4 +- chart2/source/inc/ChartType.hxx | 142 +++++++++++++++++++++ chart2/source/inc/ChartTypeHelper.hxx | 3 + chart2/source/inc/ChartTypeTemplate.hxx | 17 ++- chart2/source/inc/DiagramHelper.hxx | 8 +- chart2/source/model/main/BaseCoordinateSystem.cxx | 37 ++++-- chart2/source/model/template/AreaChartType.cxx | 5 + chart2/source/model/template/AreaChartType.hxx | 4 +- chart2/source/model/template/BarChartType.cxx | 5 + chart2/source/model/template/BarChartType.hxx | 4 +- chart2/source/model/template/BubbleChartType.cxx | 5 + chart2/source/model/template/BubbleChartType.hxx | 4 +- .../source/model/template/CandleStickChartType.cxx | 5 + .../source/model/template/CandleStickChartType.hxx | 4 +- chart2/source/model/template/ChartType.cxx | 2 +- chart2/source/model/template/ChartType.hxx | 137 -------------------- chart2/source/model/template/ChartTypeTemplate.cxx | 66 +++++++--- chart2/source/model/template/ColumnChartType.cxx | 5 + chart2/source/model/template/ColumnChartType.hxx | 4 +- .../model/template/ColumnLineChartTypeTemplate.cxx | 2 +- .../model/template/ColumnLineChartTypeTemplate.hxx | 4 +- .../source/model/template/FilledNetChartType.cxx | 5 + .../source/model/template/FilledNetChartType.hxx | 2 + chart2/source/model/template/LineChartType.cxx | 5 + chart2/source/model/template/LineChartType.hxx | 4 +- .../model/template/LineChartTypeTemplate.cxx | 12 +- chart2/source/model/template/NetChartType.cxx | 5 + chart2/source/model/template/NetChartType.hxx | 4 +- .../source/model/template/NetChartTypeTemplate.cxx | 5 +- chart2/source/model/template/PieChartType.cxx | 5 + chart2/source/model/template/PieChartType.hxx | 4 +- .../source/model/template/PieChartTypeTemplate.cxx | 7 +- .../source/model/template/PieChartTypeTemplate.hxx | 4 +- chart2/source/model/template/ScatterChartType.cxx | 5 + chart2/source/model/template/ScatterChartType.hxx | 4 +- .../model/template/ScatterChartTypeTemplate.cxx | 6 +- .../model/template/StockChartTypeTemplate.cxx | 2 +- .../model/template/StockChartTypeTemplate.hxx | 4 +- chart2/source/tools/AxisHelper.cxx | 20 +-- chart2/source/tools/ChartModelHelper.cxx | 3 +- chart2/source/tools/ChartTypeHelper.cxx | 21 +++ chart2/source/tools/DiagramHelper.cxx | 38 +++--- chart2/source/tools/ExplicitCategoriesProvider.cxx | 1 + chart2/source/tools/ObjectIdentifier.cxx | 3 +- chart2/source/tools/RegressionCurveHelper.cxx | 1 + chart2/source/tools/ThreeDHelper.cxx | 1 + chart2/source/view/diagram/VDiagram.cxx | 1 + chart2/source/view/main/ChartView.cxx | 3 +- solenv/clang-format/excludelist | 2 +- 72 files changed, 525 insertions(+), 389 deletions(-) create mode 100644 chart2/source/inc/ChartType.hxx delete mode 100644 chart2/source/model/template/ChartType.hxx diff --git a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx index e49239935c6d..e7f4129df17b 100644 --- a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx @@ -19,6 +19,7 @@ #include "DataSeriesPointWrapper.hxx" #include "Chart2ModelContact.hxx" +#include #include #include #include diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx index d9deba9857d4..cb28be651c19 100644 --- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx @@ -28,6 +28,7 @@ #include #include #include +#include #include #include "WrappedAxisAndGridExistenceProperties.hxx" #include "WrappedStatisticProperties.hxx" @@ -438,7 +439,7 @@ struct StaticDiagramWrapperPropertyArray : public rtl::StaticAggregate< Sequence bool lcl_isXYChart( const Reference< chart2::XDiagram >& rDiagram ) { bool bRet = false; - Reference< chart2::XChartType > xChartType( ::chart::DiagramHelper::getChartTypeByIndex( rDiagram, 0 ) ); + rtl::Reference< ::chart::ChartType > xChartType( ::chart::DiagramHelper::getChartTypeByIndex( rDiagram, 0 ) ); if( xChartType.is() ) { OUString aChartType( xChartType->getChartType() ); @@ -613,7 +614,7 @@ OUString SAL_CALL DiagramWrapper::getDiagramType() { // none of the standard templates matched // use first chart type - Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ); + rtl::Reference< ChartType > xChartType( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ); if( xChartType.is() ) { aRet = xChartType->getChartType(); diff --git a/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx b/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx index 516a96b2a042..e14993312dbb 100644 --- a/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx @@ -19,6 +19,7 @@ #include "MinMaxLineWrapper.hxx" #include "Chart2ModelContact.hxx" +#include #include #include #include @@ -157,31 +158,27 @@ void SAL_CALL MinMaxLineWrapper::setPropertyValue( const OUString& rPropertyName Reference< beans::XPropertySet > xPropSet; rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); - const Sequence< Reference< chart2::XChartType > > aTypes( + const std::vector< rtl::Reference< ChartType > > & aTypes( ::chart::DiagramHelper::getChartTypesFromDiagram( xDiagram ) ); - for( Reference< chart2::XChartType > const & xType : aTypes ) + for( rtl::Reference< ChartType > const & xType : aTypes ) { if( xType->getChartType() == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ) { - Reference< chart2::XDataSeriesContainer > xSeriesContainer(xType,uno::UNO_QUERY); - if( xSeriesContainer.is() ) + Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xType->getDataSeries() ); + if(aSeriesSeq.hasElements()) { - Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xSeriesContainer->getDataSeries() ); - if(aSeriesSeq.hasElements()) + xPropSet.set(aSeriesSeq[0],uno::UNO_QUERY); + if(xPropSet.is()) { - xPropSet.set(aSeriesSeq[0],uno::UNO_QUERY); - if(xPropSet.is()) - { - if( rPropertyName == "LineColor" ) - xPropSet->setPropertyValue( "Color", rValue ); - else if( rPropertyName == "LineTransparence" ) - xPropSet->setPropertyValue( "Transparency", rValue ); - else if( rPropertyName == m_aWrappedLineJointProperty.getOuterName() ) - m_aWrappedLineJointProperty.setPropertyValue( rValue, xPropSet ); - else - xPropSet->setPropertyValue( rPropertyName, rValue ); - return; - } + if( rPropertyName == "LineColor" ) + xPropSet->setPropertyValue( "Color", rValue ); + else if( rPropertyName == "LineTransparence" ) + xPropSet->setPropertyValue( "Transparency", rValue ); + else if( rPropertyName == m_aWrappedLineJointProperty.getOuterName() ) + m_aWrappedLineJointProperty.setPropertyValue( rValue, xPropSet ); + else + xPropSet->setPropertyValue( rPropertyName, rValue ); + return; } } } @@ -194,21 +191,17 @@ uno::Any SAL_CALL MinMaxLineWrapper::getPropertyValue( const OUString& rProperty Reference< beans::XPropertySet > xPropSet; rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); - const Sequence< Reference< chart2::XChartType > > aTypes( + const std::vector< rtl::Reference< ChartType > > aTypes( ::chart::DiagramHelper::getChartTypesFromDiagram( xDiagram ) ); - for( Reference< chart2::XChartType > const & xType : aTypes ) + for( rtl::Reference< ChartType > const & xType : aTypes ) { if( xType->getChartType() == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ) { - Reference< chart2::XDataSeriesContainer > xSeriesContainer(xType,uno::UNO_QUERY); - if( xSeriesContainer.is() ) + Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xType->getDataSeries() ); + if(aSeriesSeq.hasElements()) { - Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xSeriesContainer->getDataSeries() ); - if(aSeriesSeq.hasElements()) - { - xPropSet.set(aSeriesSeq[0],uno::UNO_QUERY); - break; - } + xPropSet.set(aSeriesSeq[0],uno::UNO_QUERY); + break; } } } diff --git a/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx b/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx index 2922f91c466b..6a80eae044bb 100644 --- a/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx @@ -19,6 +19,7 @@ #include "UpDownBarWrapper.hxx" #include "Chart2ModelContact.hxx" +#include #include #include #include @@ -162,17 +163,13 @@ void SAL_CALL UpDownBarWrapper::setPropertyValue( const OUString& rPropertyName, { Reference< beans::XPropertySet > xPropSet; - const Sequence< Reference< chart2::XChartType > > aTypes( + const std::vector< rtl::Reference< ChartType > > aTypes( ::chart::DiagramHelper::getChartTypesFromDiagram( m_spChart2ModelContact->getDiagram() ) ); - for( Reference< chart2::XChartType > const & xType : aTypes ) + for( rtl::Reference< ChartType > const & xType : aTypes ) { if( xType->getChartType() == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ) { - Reference< beans::XPropertySet > xTypeProps( xType, uno::UNO_QUERY ); - if(xTypeProps.is()) - { - xTypeProps->getPropertyValue( m_aPropertySetName ) >>= xPropSet; - } + xType->getPropertyValue( m_aPropertySetName ) >>= xPropSet; } } if(xPropSet.is()) @@ -184,17 +181,13 @@ uno::Any SAL_CALL UpDownBarWrapper::getPropertyValue( const OUString& rPropertyN Reference< beans::XPropertySet > xPropSet; - const Sequence< Reference< chart2::XChartType > > aTypes( + const std::vector< rtl::Reference< ChartType > > aTypes( ::chart::DiagramHelper::getChartTypesFromDiagram( m_spChart2ModelContact->getDiagram() ) ); - for( Reference< chart2::XChartType > const & xType : aTypes ) + for( rtl::Reference const & xType : aTypes ) { if( xType->getChartType() == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ) { - Reference< beans::XPropertySet > xTypeProps( xType, uno::UNO_QUERY ); - if(xTypeProps.is()) - { - xTypeProps->getPropertyValue( m_aPropertySetName ) >>= xPropSet; - } + xType->getPropertyValue( m_aPropertySetName ) >>= xPropSet; } } if(xPropSet.is()) diff --git a/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx index c0f100d335a7..e613161bf10f 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx @@ -19,6 +19,7 @@ #include "WrappedGapwidthProperty.hxx" #include "Chart2ModelContact.hxx" +#include #include #include @@ -72,29 +73,25 @@ void WrappedBarPositionProperty_Base::setPropertyValue( const Any& rOuterValue, if( m_nDimensionIndex!=1 ) return; - const Sequence< Reference< chart2::XChartType > > aChartTypeList( DiagramHelper::getChartTypesFromDiagram( xDiagram ) ); - for( Reference< chart2::XChartType > const & chartType : aChartTypeList ) + const std::vector< rtl::Reference< ChartType > > aChartTypeList( DiagramHelper::getChartTypesFromDiagram( xDiagram ) ); + for( rtl::Reference< ChartType > const & chartType : aChartTypeList ) { try { - Reference< beans::XPropertySet > xProp( chartType, uno::UNO_QUERY ); - if( xProp.is() ) + Sequence< sal_Int32 > aBarPositionSequence; + chartType->getPropertyValue( m_InnerSequencePropertyName ) >>= aBarPositionSequence; + + tools::Long nOldLength = aBarPositionSequence.getLength(); + if( nOldLength <= m_nAxisIndex ) + aBarPositionSequence.realloc( m_nAxisIndex+1 ); + auto pBarPositionSequence = aBarPositionSequence.getArray(); + for( sal_Int32 i=nOldLength; i aBarPositionSequence; - xProp->getPropertyValue( m_InnerSequencePropertyName ) >>= aBarPositionSequence; - - tools::Long nOldLength = aBarPositionSequence.getLength(); - if( nOldLength <= m_nAxisIndex ) - aBarPositionSequence.realloc( m_nAxisIndex+1 ); - auto pBarPositionSequence = aBarPositionSequence.getArray(); - for( sal_Int32 i=nOldLength; isetPropertyValue( m_InnerSequencePropertyName, uno::Any( aBarPositionSequence ) ); + pBarPositionSequence[i] = m_nDefaultValue; } + pBarPositionSequence[m_nAxisIndex] = nNewValue; + + chartType->setPropertyValue( m_InnerSequencePropertyName, uno::Any( aBarPositionSequence ) ); } catch( uno::Exception& e ) { @@ -115,21 +112,17 @@ Any WrappedBarPositionProperty_Base::getPropertyValue( const Reference< beans::X if( m_nDimensionIndex==1 ) { - Sequence< Reference< chart2::XChartType > > aChartTypeList( DiagramHelper::getChartTypesFromDiagram( xDiagram ) ); - for( sal_Int32 nN = 0; nN < aChartTypeList.getLength() && !bInnerValueDetected; nN++ ) + std::vector< rtl::Reference< ChartType > > aChartTypeList( DiagramHelper::getChartTypesFromDiagram( xDiagram ) ); + for( sal_Int32 nN = 0; nN < static_cast(aChartTypeList.size()) && !bInnerValueDetected; nN++ ) { try { - Reference< beans::XPropertySet > xProp( aChartTypeList[nN], uno::UNO_QUERY ); - if( xProp.is() ) + Sequence< sal_Int32 > aBarPositionSequence; + aChartTypeList[nN]->getPropertyValue( m_InnerSequencePropertyName ) >>= aBarPositionSequence; + if( m_nAxisIndex < aBarPositionSequence.getLength() ) { - Sequence< sal_Int32 > aBarPositionSequence; - xProp->getPropertyValue( m_InnerSequencePropertyName ) >>= aBarPositionSequence; - if( m_nAxisIndex < aBarPositionSequence.getLength() ) - { - nInnerValue = aBarPositionSequence[m_nAxisIndex]; - bInnerValueDetected = true; - } + nInnerValue = aBarPositionSequence[m_nAxisIndex]; + bInnerValueDetected = true; } } catch( uno::Exception& e ) diff --git a/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx index 6d088a50bd81..102acfb02ba2 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx @@ -20,6 +20,7 @@ #include "WrappedSplineProperties.hxx" #include "Chart2ModelContact.hxx" #include +#include #include #include #include @@ -62,17 +63,13 @@ public: { bool bHasDetectableInnerValue = false; rHasAmbiguousValue = false; - Sequence< css::uno::Reference< css::chart2::XChartType > > aChartTypes( + std::vector< rtl::Reference< ChartType > > aChartTypes( ::chart::DiagramHelper::getChartTypesFromDiagram( m_spChart2ModelContact->getDiagram() ) ); - for( sal_Int32 nN = aChartTypes.getLength(); nN--; ) + for( sal_Int32 nN = aChartTypes.size(); nN--; ) { try { - uno::Reference xChartTypePropertySet(aChartTypes[nN], uno::UNO_QUERY); - if (!xChartTypePropertySet.is()) - continue; - - Any aSingleValue = convertInnerToOuterValue( xChartTypePropertySet->getPropertyValue(m_aOwnInnerName) ); + Any aSingleValue = convertInnerToOuterValue( aChartTypes[nN]->getPropertyValue(m_aOwnInnerName) ); PROPERTYTYPE aCurValue = PROPERTYTYPE(); aSingleValue >>= aCurValue; if( !bHasDetectableInnerValue ) @@ -114,17 +111,13 @@ public: if( !(bHasAmbiguousValue || aNewValue != aOldValue) ) return; - Sequence< css::uno::Reference< css::chart2::XChartType > > aChartTypes( + std::vector< rtl::Reference< ChartType > > aChartTypes( ::chart::DiagramHelper::getChartTypesFromDiagram( m_spChart2ModelContact->getDiagram() ) ); - for( sal_Int32 nN = aChartTypes.getLength(); nN--; ) + for( sal_Int32 nN = aChartTypes.size(); nN--; ) { try { - css::uno::Reference< css::beans::XPropertySet > xChartTypePropertySet( aChartTypes[nN], css::uno::UNO_QUERY ); - if( xChartTypePropertySet.is() ) - { - xChartTypePropertySet->setPropertyValue(m_aOwnInnerName,convertOuterToInnerValue(uno::Any(aNewValue))); - } + aChartTypes[nN]->setPropertyValue(m_aOwnInnerName,convertOuterToInnerValue(uno::Any(aNewValue))); } catch( uno::Exception & ex ) { diff --git a/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx index 484861b68338..7e29348728a8 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx @@ -20,6 +20,7 @@ #include "WrappedSymbolProperties.hxx" #include "WrappedSeriesOrDiagramProperty.hxx" #include +#include #include #include #include @@ -286,7 +287,7 @@ beans::PropertyState WrappedSymbolTypeProperty::getPropertyState( const Referenc { rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); Reference< chart2::XDataSeries > xSeries( xInnerPropertyState, uno::UNO_QUERY ); - Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) ); + rtl::Reference< ChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) ); if( ChartTypeHelper::isSupportingSymbolProperties( xChartType, 2 ) ) return beans::PropertyState_DIRECT_VALUE; } diff --git a/chart2/source/controller/dialogs/DataBrowserModel.cxx b/chart2/source/controller/dialogs/DataBrowserModel.cxx index c73781770549..0455adf3212f 100644 --- a/chart2/source/controller/dialogs/DataBrowserModel.cxx +++ b/chart2/source/controller/dialogs/DataBrowserModel.cxx @@ -20,6 +20,7 @@ #include "DataBrowserModel.hxx" #include "DialogModel.hxx" #include +#include #include #include #include @@ -293,7 +294,7 @@ void DataBrowserModel::insertDataSeries( sal_Int32 nAfterColumnIndex ) sal_Int32 nStartCol = 0; rtl::Reference< Diagram > xDiagram = ChartModelHelper::findDiagram(m_xChartDocument); - Reference xChartType; + rtl::Reference xChartType; Reference xSeries; if (o3tl::make_unsigned(nAfterColumnIndex) < m_aColumns.size()) // Get the data series at specific column position (if available). @@ -303,7 +304,7 @@ void DataBrowserModel::insertDataSeries( sal_Int32 nAfterColumnIndex ) if( xSeries.is()) { // Use the chart type of the currently selected data series. - xChartType.set( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries )); + xChartType = DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ); // Find the corresponding header and determine the last column of this // data series. @@ -321,7 +322,7 @@ void DataBrowserModel::insertDataSeries( sal_Int32 nAfterColumnIndex ) else { // No data series at specified column position. Use the first chart type. - xChartType.set( DiagramHelper::getChartTypeByIndex( xDiagram, 0 )); + xChartType = DiagramHelper::getChartTypeByIndex( xDiagram, 0 ); nStartCol = nAfterColumnIndex; } @@ -330,10 +331,7 @@ void DataBrowserModel::insertDataSeries( sal_Int32 nAfterColumnIndex ) // Get shared sequences of current series. Normally multiple data series // only share "values-x" sequences. (TODO: simplify this logic). - Reference< chart2::XDataSeriesContainer > xSeriesCnt( xChartType, uno::UNO_QUERY ); - lcl_tSharedSeqVec aSharedSequences; - if( xSeriesCnt.is()) - aSharedSequences = lcl_getSharedSequences( xSeriesCnt->getDataSeries()); + lcl_tSharedSeqVec aSharedSequences = lcl_getSharedSequences( xChartType->getDataSeries()); Reference xNewSeries = m_apDialogModel->insertSeriesAfter(xSeries, xChartType, true); diff --git a/chart2/source/controller/dialogs/DialogModel.cxx b/chart2/source/controller/dialogs/DialogModel.cxx index 73b438acef92..0efd1d979afe 100644 --- a/chart2/source/controller/dialogs/DialogModel.cxx +++ b/chart2/source/controller/dialogs/DialogModel.cxx @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -290,7 +291,7 @@ Sequence< OUString > lcl_CopyExcludingValuesFirst( Reference< XDataSeries > lcl_CreateNewSeries( const Reference< uno::XComponentContext > & xContext, - const Reference< XChartType > & xChartType, + const uno::Reference< XChartType > & xChartType, sal_Int32 nNewSeriesIndex, sal_Int32 nTotalNumberOfSeriesInCTGroup, const Reference< XDiagram > & xDiagram, @@ -316,12 +317,14 @@ Reference< XDataSeries > lcl_CreateNewSeries( sal_Int32 nGroupIndex=0; if( xChartType.is()) { - Sequence< Reference< XChartType > > aCTs( + auto pChartType = dynamic_cast<::chart::ChartType*>(xChartType.get()); + assert(pChartType); + std::vector< rtl::Reference< ::chart::ChartType > > aCTs( ::chart::DiagramHelper::getChartTypesFromDiagram( xDiagram )); - for( ; nGroupIndex(aCTs.size()); ++nGroupIndex) + if( aCTs[nGroupIndex] == pChartType ) break; - if( nGroupIndex == aCTs.getLength()) + if( nGroupIndex == static_cast(aCTs.size())) nGroupIndex = 0; } xTemplate->applyStyle( xResult, nGroupIndex, nNewSeriesIndex, nTotalNumberOfSeriesInCTGroup ); diff --git a/chart2/source/controller/dialogs/ObjectNameProvider.cxx b/chart2/source/controller/dialogs/ObjectNameProvider.cxx index 201671e87bcf..4053d3a75599 100644 --- a/chart2/source/controller/dialogs/ObjectNameProvider.cxx +++ b/chart2/source/controller/dialogs/ObjectNameProvider.cxx @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -66,7 +67,7 @@ OUString lcl_getDataSeriesName( const OUString& rObjectCID, const rtl::Reference Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel ); if( xDiagram.is() && xSeries.is() ) { - Reference< XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) ); + rtl::Reference< ChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) ); if( xChartType.is() ) { aRet = ::chart::DataSeriesHelper::getDataSeriesLabel( diff --git a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx index 84740d9bf708..e1d4c0175845 100644 --- a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx +++ b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -115,7 +116,7 @@ void ObjectPropertiesDialogParameter::init( const rtl::Reference<::chart::ChartM m_xChartDocument = xChartModel; rtl::Reference< Diagram > xDiagram = ChartModelHelper::findDiagram( xChartModel ); uno::Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( m_aObjectCID, xChartModel ); - uno::Reference< XChartType > xChartType = ChartModelHelper::getChartTypeOfSeries( xChartModel, xSeries ); + rtl::Reference< ChartType > xChartType = ChartModelHelper::getChartTypeOfSeries( xChartModel, xSeries ); sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); bool bHasSeriesProperties = (m_eObjectType==OBJECTTYPE_DATA_SERIES); diff --git a/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx b/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx index 3a76aa57f6dd..3385330e913c 100644 --- a/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx +++ b/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx @@ -20,6 +20,7 @@ #include "tp_3D_SceneGeometry.hxx" #include +#include #include #include #include diff --git a/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx b/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx index cb53acb3a873..bc09b1bda1b9 100644 --- a/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include diff --git a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx index 264bdf92af3b..34d81b353bdc 100644 --- a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -237,7 +238,7 @@ DataPointItemConverter::DataPointItemConverter( } rtl::Reference< Diagram > xDiagram( ChartModelHelper::findDiagram(xChartModel) ); - uno::Reference< XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram , xSeries ) ); + rtl::Reference< ChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram , xSeries ) ); bool bFound = false; bool bAmbiguous = false; bool bSwapXAndY = DiagramHelper::getVertical( xDiagram, bFound, bAmbiguous ); diff --git a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx index 4d035c061b6c..5080b4d8be01 100644 --- a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx @@ -21,6 +21,7 @@ #include "SchWhichPairs.hxx" #include +#include #include #include #include @@ -74,7 +75,7 @@ SeriesOptionsItemConverter::SeriesOptionsItemConverter( m_bAttachToMainAxis = DiagramHelper::isSeriesAttachedToMainAxis( xDataSeries ); rtl::Reference< Diagram > xDiagram( ChartModelHelper::findDiagram(xChartModel) ); - uno::Reference< XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram , xDataSeries ) ); + rtl::Reference< ChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram , xDataSeries ) ); m_xCooSys = DataSeriesHelper::getCoordinateSystemOfSeries( xDataSeries, xDiagram ); if( m_xCooSys.is() ) @@ -93,15 +94,14 @@ SeriesOptionsItemConverter::SeriesOptionsItemConverter( sal_Int32 nAxisIndex = DataSeriesHelper::getAttachedAxisIndex(xDataSeries); uno::Sequence< sal_Int32 > aBarPositionSequence; - uno::Reference< beans::XPropertySet > xChartTypeProps( xChartType, uno::UNO_QUERY ); - if( xChartTypeProps.is() ) + if( xChartType.is() ) { - if( xChartTypeProps->getPropertyValue( "OverlapSequence" ) >>= aBarPositionSequence ) + if( xChartType->getPropertyValue( "OverlapSequence" ) >>= aBarPositionSequence ) { if( nAxisIndex >= 0 && nAxisIndex < aBarPositionSequence.getLength() ) m_nBarOverlap = aBarPositionSequence[nAxisIndex]; } - if( xChartTypeProps->getPropertyValue( "GapwidthSequence" ) >>= aBarPositionSequence ) + if( xChartType->getPropertyValue( "GapwidthSequence" ) >>= aBarPositionSequence ) { if( nAxisIndex >= 0 && nAxisIndex < aBarPositionSequence.getLength() ) m_nGapWidth = aBarPositionSequence[nAxisIndex]; @@ -206,28 +206,25 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const Sf uno::Reference< XDataSeries > xDataSeries( GetPropertySet(), uno::UNO_QUERY ); rtl::Reference< Diagram > xDiagram( ChartModelHelper::findDiagram(m_xChartModel) ); - uno::Reference< beans::XPropertySet > xChartTypeProps( DiagramHelper::getChartTypeOfSeries( xDiagram , xDataSeries ), uno::UNO_QUERY ); - if( xChartTypeProps.is() ) + rtl::Reference< ChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram , xDataSeries ) ); + if( xChartType.is() ) { sal_Int32 nAxisIndex = DataSeriesHelper::getAttachedAxisIndex(xDataSeries); uno::Sequence< sal_Int32 > aBarPositionSequence; - if( xChartTypeProps.is() ) + if( xChartType->getPropertyValue( aPropName ) >>= aBarPositionSequence ) { - if( xChartTypeProps->getPropertyValue( aPropName ) >>= aBarPositionSequence ) + bool bGroupBarsPerAxis = rItemSet.Get( SCHATTR_GROUP_BARS_PER_AXIS ).GetValue(); + if(!bGroupBarsPerAxis) { - bool bGroupBarsPerAxis = rItemSet.Get( SCHATTR_GROUP_BARS_PER_AXIS ).GetValue(); - if(!bGroupBarsPerAxis) - { - //set the same value for all axes - for( auto & pos : asNonConstRange(aBarPositionSequence) ) - pos = rBarPosition; - } - else if( nAxisIndex >= 0 && nAxisIndex < aBarPositionSequence.getLength() ) - aBarPositionSequence.getArray()[nAxisIndex] = rBarPosition; - - xChartTypeProps->setPropertyValue( aPropName, uno::Any(aBarPositionSequence) ); - bChanged = true; + //set the same value for all axes + for( auto & pos : asNonConstRange(aBarPositionSequence) ) + pos = rBarPosition; } + else if( nAxisIndex >= 0 && nAxisIndex < aBarPositionSequence.getLength() ) + aBarPositionSequence.getArray()[nAxisIndex] = rBarPosition; + + xChartType->setPropertyValue( aPropName, uno::Any(aBarPositionSequence) ); + bChanged = true; } } } diff --git a/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx b/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx index 36a0686e95f7..ea7e3b9c59fd 100644 --- a/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -210,7 +211,7 @@ TextLabelItemConverter::TextLabelItemConverter( maConverters.emplace_back(new CharacterPropertyItemConverter(rPropertySet, rItemPool, pRefSize, "ReferencePageSize")); rtl::Reference< Diagram > xDiagram(ChartModelHelper::findDiagram(xChartModel)); - uno::Reference xChartType(DiagramHelper::getChartTypeOfSeries(xDiagram, xSeries)); + rtl::Reference< ChartType > xChartType(DiagramHelper::getChartTypeOfSeries(xDiagram, xSeries)); bool bFound = false; bool bAmbiguous = false; bool bSwapXAndY = DiagramHelper::getVertical(xDiagram, bFound, bAmbiguous); diff --git a/chart2/source/controller/main/ChartController_Properties.cxx b/chart2/source/controller/main/ChartController_Properties.cxx index df0da042a218..f4d5aaa6209d 100644 --- a/chart2/source/controller/main/ChartController_Properties.cxx +++ b/chart2/source/controller/main/ChartController_Properties.cxx @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -198,7 +199,7 @@ wrapper::ItemConverter* createItemConverter( wrapper::GraphicObjectType::FilledDataPoint; uno::Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( aObjectCID, xChartModel ); - uno::Reference< XChartType > xChartType = ChartModelHelper::getChartTypeOfSeries( xChartModel, xSeries ); + rtl::Reference< ChartType > xChartType = ChartModelHelper::getChartTypeOfSeries( xChartModel, xSeries ); rtl::Reference< Diagram > xDiagram = ChartModelHelper::findDiagram( xChartModel ); sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index b8d925427736..c8aa8a694e7d 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -1100,22 +1101,18 @@ void ChartController::execute_Command( const CommandEvent& rCEvt ) lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatDataSeries" ); } - Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) ); + rtl::Reference< ChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) ); if( xChartType->getChartType() == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ) { try { - Reference< beans::XPropertySet > xChartTypeProp( xChartType, uno::UNO_QUERY ); - if( xChartTypeProp.is() ) - { - bool bJapaneseStyle = false; - xChartTypeProp->getPropertyValue( "Japanese" ) >>= bJapaneseStyle; + bool bJapaneseStyle = false; + xChartType->getPropertyValue( "Japanese" ) >>= bJapaneseStyle; - if( bJapaneseStyle ) - { - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatStockLoss" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatStockGain" ); - } + if( bJapaneseStyle ) + { + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatStockLoss" ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatStockGain" ); } } catch( const uno::Exception & ) diff --git a/chart2/source/controller/main/ControllerCommandDispatch.cxx b/chart2/source/controller/main/ControllerCommandDispatch.cxx index 9da88ea5d6c7..af549e1722bc 100644 --- a/chart2/source/controller/main/ControllerCommandDispatch.cxx +++ b/chart2/source/controller/main/ControllerCommandDispatch.cxx @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -406,7 +407,7 @@ void ModelState::update( const rtl::Reference<::chart::ChartModel> & xModel ) sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); - uno::Reference< chart2::XChartType > xFirstChartType( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ); + rtl::Reference< ChartType > xFirstChartType( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ); bSupportsStatistics = ChartTypeHelper::isSupportingStatisticProperties( xFirstChartType, nDimensionCount ); bSupportsAxes = ChartTypeHelper::isSupportingMainAxis( xFirstChartType, nDimensionCount, 0 ); diff --git a/chart2/source/controller/main/DragMethod_RotateDiagram.cxx b/chart2/source/controller/main/DragMethod_RotateDiagram.cxx index 030fcd0bf8bc..2af1c013d826 100644 --- a/chart2/source/controller/main/DragMethod_RotateDiagram.cxx +++ b/chart2/source/controller/main/DragMethod_RotateDiagram.cxx @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include diff --git a/chart2/source/controller/main/ObjectHierarchy.cxx b/chart2/source/controller/main/ObjectHierarchy.cxx index 1fb449026f3a..4649b422d79f 100644 --- a/chart2/source/controller/main/ObjectHierarchy.cxx +++ b/chart2/source/controller/main/ObjectHierarchy.cxx @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -216,7 +217,7 @@ void ObjectHierarchy::createAxesTree( { Reference< XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY_THROW ); sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); - uno::Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ); + rtl::Reference< ChartType > xChartType( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ); bool bSupportsAxesGrids = ChartTypeHelper::isSupportingMainAxis( xChartType, nDimensionCount, 0 ); if( !bSupportsAxesGrids ) return; diff --git a/chart2/source/inc/AxisHelper.hxx b/chart2/source/inc/AxisHelper.hxx index abe9ee1e257e..788ba4cf5f79 100644 --- a/chart2/source/inc/AxisHelper.hxx +++ b/chart2/source/inc/AxisHelper.hxx @@ -39,6 +39,7 @@ namespace com::sun::star::uno { class XComponentContext; } namespace chart { class BaseCoordinateSystem; +class ChartType; class OOO_DLLPUBLIC_CHARTTOOLS AxisHelper { @@ -191,13 +192,13 @@ public: static bool isSecondaryYAxisNeeded( const css::uno::Reference< css::chart2::XCoordinateSystem >& xCooSys ); - static css::uno::Reference< css::chart2::XChartType > + static rtl::Reference< ::chart::ChartType > getChartTypeByIndex( const css::uno::Reference< css::chart2::XCoordinateSystem >& xCooSys, sal_Int32 nIndex ); static void setRTLAxisLayout( const css::uno::Reference< css::chart2::XCoordinateSystem >& xCooSys ); - static css::uno::Reference< css::chart2::XChartType > + static rtl::Reference< ::chart::ChartType > getFirstChartTypeWithSeriesAttachedToAxisIndex( const css::uno::Reference< css::chart2::XDiagram >& xDiagram, const sal_Int32 nAttachedAxisIndex ); static bool isAxisPositioningEnabled(); diff --git a/chart2/source/inc/BaseCoordinateSystem.hxx b/chart2/source/inc/BaseCoordinateSystem.hxx index 4cfa7ab42c80..922d4047b02e 100644 --- a/chart2/source/inc/BaseCoordinateSystem.hxx +++ b/chart2/source/inc/BaseCoordinateSystem.hxx @@ -33,6 +33,7 @@ namespace chart { +class ChartType; namespace impl { @@ -95,6 +96,8 @@ public: virtual void SAL_CALL removeModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + const std::vector< rtl::Reference<::chart::ChartType > > & getChartTypes2() const { return m_aChartTypes; } + protected: // ____ XModifyListener ____ @@ -118,7 +121,7 @@ private: sal_Int32 m_nDimensionCount; typedef std::vector< std::vector< css::uno::Reference< css::chart2::XAxis > > > tAxisVecVecType; tAxisVecVecType m_aAllAxis; //outer sequence is the dimension; inner sequence is the axis index that indicates main or secondary axis - std::vector< css::uno::Reference< css::chart2::XChartType > > m_aChartTypes; + std::vector< rtl::Reference<::chart::ChartType > > m_aChartTypes; }; } // namespace chart diff --git a/chart2/source/inc/ChartModelHelper.hxx b/chart2/source/inc/ChartModelHelper.hxx index dfe864eeb0d4..a3ca9532d865 100644 --- a/chart2/source/inc/ChartModelHelper.hxx +++ b/chart2/source/inc/ChartModelHelper.hxx @@ -38,6 +38,7 @@ namespace com::sun::star::view { class XSelectionSupplier; } namespace chart { class BaseCoordinateSystem; +class ChartType; class Diagram; class InternalDataProvider; @@ -75,7 +76,7 @@ public: static std::vector< css::uno::Reference< css::chart2::XDataSeries > > getDataSeries( const rtl::Reference< ::chart::ChartModel > & xModel ); - static css::uno::Reference< css::chart2::XChartType > + static rtl::Reference< ChartType > getChartTypeOfSeries( const css::uno::Reference< css::frame::XModel >& xModel , const css::uno::Reference< css::chart2::XDataSeries >& xGivenDataSeries ); @@ -89,6 +90,7 @@ public: static bool isIncludeHiddenCells( const css::uno::Reference< css::frame::XModel >& xChartModel ); static bool setIncludeHiddenCells( bool bIncludeHiddenCells, ChartModel& rModel); + }; } //namespace chart diff --git a/chart2/source/inc/ChartType.hxx b/chart2/source/inc/ChartType.hxx new file mode 100644 index 000000000000..729e58109de5 --- /dev/null +++ b/chart2/source/inc/ChartType.hxx @@ -0,0 +1,142 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "OPropertySet.hxx" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include "charttoolsdllapi.hxx" + +namespace chart +{ + +namespace impl +{ +typedef ::cppu::WeakImplHelper< + css::lang::XServiceInfo, + css::chart2::XChartType, + css::chart2::XDataSeriesContainer, + css::util::XCloneable, + css::util::XModifyBroadcaster, + css::util::XModifyListener > + ChartType_Base; +} + +class OOO_DLLPUBLIC_CHARTTOOLS ChartType : + public cppu::BaseMutex, + public impl::ChartType_Base, + public ::property::OPropertySet +{ +public: + explicit ChartType(); + virtual ~ChartType() override; + + /// merge XInterface implementations + DECLARE_XINTERFACE() + + explicit ChartType( const ChartType & rOther ); + + // ____ XChartType ____ + // still abstract ! implement ! + virtual OUString SAL_CALL getChartType() override = 0; + virtual css::uno::Reference< css::chart2::XCoordinateSystem > SAL_CALL + createCoordinateSystem( ::sal_Int32 DimensionCount ) override; + virtual css::uno::Sequence< OUString > SAL_CALL + getSupportedMandatoryRoles() override; + virtual css::uno::Sequence< OUString > SAL_CALL + getSupportedOptionalRoles() override; + virtual OUString SAL_CALL getRoleOfSequenceForSeriesLabel() override; + virtual css::uno::Sequence< OUString > SAL_CALL + getSupportedPropertyRoles() override; + + // ____ XDataSeriesContainer ____ + virtual void SAL_CALL addDataSeries( + const css::uno::Reference< css::chart2::XDataSeries >& aDataSeries ) override; + virtual void SAL_CALL removeDataSeries( + const css::uno::Reference< css::chart2::XDataSeries >& aDataSeries ) override; + virtual css::uno::Sequence< css::uno::Reference< css::chart2::XDataSeries > > SAL_CALL getDataSeries() override; + virtual void SAL_CALL setDataSeries( + const css::uno::Sequence< css::uno::Reference< css::chart2::XDataSeries > >& aDataSeries ) override; + + // ____ XModifyBroadcaster ____ + virtual void SAL_CALL addModifyListener( + const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + virtual void SAL_CALL removeModifyListener( + const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + + virtual rtl::Reference cloneChartType() const = 0; + +protected: + + // ____ XModifyListener ____ + virtual void SAL_CALL modified( + const css::lang::EventObject& aEvent ) override; + + // ____ XEventListener (base of XModifyListener) ____ + virtual void SAL_CALL disposing( + const css::lang::EventObject& Source ) override; + + void fireModifyEvent(); + + // ____ OPropertySet ____ + virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override; + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override; + + virtual void firePropertyChangeEvent() override; + using OPropertySet::disposing; + + // ____ XPropertySet ____ + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() override; + + /// merge XTypeProvider implementations + DECLARE_XTYPEPROVIDER() + +protected: + css::uno::Reference< css::util::XModifyListener > + const m_xModifyEventForwarder; + +private: + void impl_addDataSeriesWithoutNotification( + const css::uno::Reference< css::chart2::XDataSeries >& aDataSeries ); + +private: + typedef + std::vector< css::uno::Reference< css::chart2::XDataSeries > > tDataSeriesContainerType; + + // --- mutable members: the following members need mutex guard --- + + tDataSeriesContainerType m_aDataSeries; + + bool m_bNotifyChanges; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/ChartTypeHelper.hxx b/chart2/source/inc/ChartTypeHelper.hxx index d4917be283fb..151df377f800 100644 --- a/chart2/source/inc/ChartTypeHelper.hxx +++ b/chart2/source/inc/ChartTypeHelper.hxx @@ -21,12 +21,14 @@ #include #include "charttoolsdllapi.hxx" +#include namespace com::sun::star::chart2 { class XChartType; } namespace com::sun::star::chart2 { class XDataSeries; } namespace chart { +class ChartType; class OOO_DLLPUBLIC_CHARTTOOLS ChartTypeHelper { @@ -47,6 +49,7 @@ public: static bool isSupportingBaseValue( const css::uno::Reference< css::chart2::XChartType >& xChartType ); static bool isSupportingAxisPositioning( const css::uno::Reference< css::chart2::XChartType >& xChartType, sal_Int32 nDimensionCount, sal_Int32 nDimensionIndex ); static bool isSupportingDateAxis( const css::uno::Reference< css::chart2::XChartType >& xChartType, sal_Int32 nDimensionIndex ); + static bool isSupportingDateAxis( const rtl::Reference< ::chart::ChartType >& xChartType, sal_Int32 nDimensionIndex ); static bool isSupportingComplexCategory( const css::uno::Reference< css::chart2::XChartType >& xChartType ); static bool isSupportingCategoryPositioning( const css::uno::Reference< css::chart2::XChartType >& xChartType, sal_Int32 nDimensionCount ); static bool shiftCategoryPosAtXAxisPerDefault( const css::uno::Reference< css::chart2::XChartType >& xChartType ); diff --git a/chart2/source/inc/ChartTypeTemplate.hxx b/chart2/source/inc/ChartTypeTemplate.hxx index 560fc32fd167..69cec8d1b1d3 100644 --- a/chart2/source/inc/ChartTypeTemplate.hxx +++ b/chart2/source/inc/ChartTypeTemplate.hxx @@ -23,6 +23,8 @@ #include #include #include "charttoolsdllapi.hxx" +#include +#include namespace com::sun::star::chart2 { class XChartType; } namespace com::sun::star::chart2 { class XCoordinateSystemContainer; } @@ -31,6 +33,7 @@ namespace com::sun::star::uno { class XComponentContext; } namespace chart { +class ChartType; /** For creating diagrams and modifying existing diagrams. A base class that implements XChartTypeTemplate and offers some tooling for classes that @@ -191,9 +194,7 @@ public: const css::uno::Sequence< css::uno::Reference< css::chart2::XCoordinateSystem > > & rCoordSys, - const css::uno::Sequence< - css::uno::Reference< - css::chart2::XChartType > > & aOldChartTypesSeq + const std::vector< rtl::Reference< ChartType > > & aOldChartTypesSeq ); /** create axes and add them to the given container. If there are already @@ -223,6 +224,9 @@ public: static void copyPropertiesFromOldToNewCoordinateSystem( const css::uno::Sequence< css::uno::Reference< css::chart2::XChartType > > & rOldChartTypesSeq, const css::uno::Reference< css::chart2::XChartType > & xNewChartType ); + static void copyPropertiesFromOldToNewCoordinateSystem( + const std::vector< rtl::Reference< ChartType > > & rOldChartTypesSeq, + const css::uno::Reference< css::chart2::XChartType > & xNewChartType ); protected: css::uno::Reference< css::uno::XComponentContext > m_xContext; @@ -242,9 +246,10 @@ private: css::chart2::XDataSeries > > > & aSeriesSeq, const css::uno::Reference< css::chart2::data::XLabeledDataSequence >& xCategories, - const css::uno::Sequence< - css::uno::Reference< - css::chart2::XChartType > > & aOldChartTypesSeq); + const std::vector< rtl::Reference< ChartType > > & aOldChartTypesSeq); + + using XChartTypeTemplate::getChartTypeForNewSeries; + rtl::Reference< ChartType > getChartTypeForNewSeries( const std::vector< rtl::Reference< ChartType > >& aFormerlyUsedChartTypes ); }; } // namespace chart diff --git a/chart2/source/inc/DiagramHelper.hxx b/chart2/source/inc/DiagramHelper.hxx index 57372a1c072e..f80d9c61ea96 100644 --- a/chart2/source/inc/DiagramHelper.hxx +++ b/chart2/source/inc/DiagramHelper.hxx @@ -40,6 +40,7 @@ namespace com::sun::star::util { class XNumberFormatsSupplier; } namespace chart { +class ChartType; class ChartTypeManager; class ChartTypeTemplate; @@ -156,7 +157,7 @@ public: const css::uno::Reference< css::chart2::XDataSeries >& xSeries, const css::uno::Reference< css::chart2::XDiagram >& xDiagram ); - static css::uno::Reference< css::chart2::XChartType > + static rtl::Reference< ChartType > getChartTypeOfSeries( const css::uno::Reference< css::chart2::XDiagram >& xDiagram, const css::uno::Reference< css::chart2::XDataSeries >& xSeries ); @@ -207,11 +208,10 @@ public: static sal_Int32 getPercentNumberFormat( const css::uno::Reference< css::util::XNumberFormatsSupplier >& xNumberFormatsSupplier ); - static css::uno::Reference< css::chart2::XChartType > + static rtl::Reference< ChartType > getChartTypeByIndex( const css::uno::Reference< css::chart2::XDiagram >& xDiagram, sal_Int32 nIndex ); - static css::uno::Sequence< - css::uno::Reference< css::chart2::XChartType > > + static std::vector< rtl::Reference< ChartType > > getChartTypesFromDiagram( const css::uno::Reference< css::chart2::XDiagram > & xDiagram ); diff --git a/chart2/source/model/main/BaseCoordinateSystem.cxx b/chart2/source/model/main/BaseCoordinateSystem.cxx index 3729c32bd281..6717c3005047 100644 --- a/chart2/source/model/main/BaseCoordinateSystem.cxx +++ b/chart2/source/model/main/BaseCoordinateSystem.cxx @@ -23,6 +23,7 @@ #include #include #include "Axis.hxx" +#include #include #include #include @@ -159,11 +160,13 @@ BaseCoordinateSystem::BaseCoordinateSystem( tAxisVecVecType::size_type nN=0; for( nN=0; nN( rSource.m_aAllAxis[nN], m_aAllAxis[nN] ); - CloneHelper::CloneRefVector( rSource.m_aChartTypes, m_aChartTypes ); + for (const auto & rxChartType : rSource.m_aChartTypes) + m_aChartTypes.push_back(rxChartType->cloneChartType()); for( nN=0; nNaddModifyListener( m_xModifyEventForwarder ); } BaseCoordinateSystem::~BaseCoordinateSystem() @@ -172,7 +175,8 @@ BaseCoordinateSystem::~BaseCoordinateSystem() { for(const tAxisVecVecType::value_type & i : m_aAllAxis) ModifyListenerHelper::removeListenerFromAllElements( i, m_xModifyEventForwarder ); - ModifyListenerHelper::removeListenerFromAllElements( m_aChartTypes, m_xModifyEventForwarder ); + for (const auto & rxChartType : m_aChartTypes) + rxChartType->removeModifyListener( m_xModifyEventForwarder ); } catch( const uno::Exception & ) { @@ -243,19 +247,23 @@ sal_Int32 SAL_CALL BaseCoordinateSystem::getMaximumAxisIndexByDimension( sal_Int // ____ XChartTypeContainer ____ void SAL_CALL BaseCoordinateSystem::addChartType( const Reference< chart2::XChartType >& aChartType ) { - if( std::find( m_aChartTypes.begin(), m_aChartTypes.end(), aChartType ) + auto pChartType = dynamic_cast(aChartType.get()); + assert(pChartType); + + if( std::find( m_aChartTypes.begin(), m_aChartTypes.end(), pChartType ) != m_aChartTypes.end()) throw lang::IllegalArgumentException("type not found", static_cast(this), 1); - m_aChartTypes.push_back( aChartType ); + m_aChartTypes.push_back( pChartType ); ModifyListenerHelper::addListener( aChartType, m_xModifyEventForwarder ); fireModifyEvent(); } void SAL_CALL BaseCoordinateSystem::removeChartType( const Reference< chart2::XChartType >& aChartType ) { - std::vector< uno::Reference< chart2::XChartType > >::iterator - aIt( std::find( m_aChartTypes.begin(), m_aChartTypes.end(), aChartType )); + auto pChartType = dynamic_cast(aChartType.get()); + assert(pChartType); + auto aIt( std::find( m_aChartTypes.begin(), m_aChartTypes.end(), pChartType )); if( aIt == m_aChartTypes.end()) throw container::NoSuchElementException( "The given chart type is no element of the container", @@ -268,14 +276,21 @@ void SAL_CALL BaseCoordinateSystem::removeChartType( const Reference< chart2::XC Sequence< Reference< chart2::XChartType > > SAL_CALL BaseCoordinateSystem::getChartTypes() { - return comphelper::containerToSequence( m_aChartTypes ); + return comphelper::containerToSequence< Reference< chart2::XChartType > >( m_aChartTypes ); } void SAL_CALL BaseCoordinateSystem::setChartTypes( const Sequence< Reference< chart2::XChartType > >& aChartTypes ) { - ModifyListenerHelper::removeListenerFromAllElements( m_aChartTypes, m_xModifyEventForwarder ); - m_aChartTypes = comphelper::sequenceToContainer >>( aChartTypes ); - ModifyListenerHelper::addListenerToAllElements( m_aChartTypes, m_xModifyEventForwarder ); + for (auto const & aChartType : m_aChartTypes) + aChartType->removeModifyListener( m_xModifyEventForwarder ); + m_aChartTypes.clear(); + for (auto const & aChartType : aChartTypes) + { + auto pChartType = dynamic_cast(aChartType.get()); + assert(pChartType); + m_aChartTypes.push_back(pChartType); + pChartType->addModifyListener( m_xModifyEventForwarder ); + } fireModifyEvent(); } diff --git a/chart2/source/model/template/AreaChartType.cxx b/chart2/source/model/template/AreaChartType.cxx index 840bdba036d7..b0581ddc8837 100644 --- a/chart2/source/model/template/AreaChartType.cxx +++ b/chart2/source/model/template/AreaChartType.cxx @@ -44,6 +44,11 @@ uno::Reference< util::XCloneable > SAL_CALL AreaChartType::createClone() return uno::Reference< util::XCloneable >( new AreaChartType( *this )); } +rtl::Reference< ChartType > AreaChartType::cloneChartType() const +{ + return new AreaChartType( *this ); +} + // ____ XChartType ____ OUString SAL_CALL AreaChartType::getChartType() { diff --git a/chart2/source/model/template/AreaChartType.hxx b/chart2/source/model/template/AreaChartType.hxx index fdd2df3a234b..8ca01e1f3afd 100644 --- a/chart2/source/model/template/AreaChartType.hxx +++ b/chart2/source/model/template/AreaChartType.hxx @@ -18,7 +18,7 @@ */ #pragma once -#include "ChartType.hxx" +#include namespace chart { @@ -36,6 +36,8 @@ public: virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + virtual rtl::Reference cloneChartType() const override; + private: explicit AreaChartType( const AreaChartType & rOther ); diff --git a/chart2/source/model/template/BarChartType.cxx b/chart2/source/model/template/BarChartType.cxx index d32aa6efeca3..2a94db82ba2a 100644 --- a/chart2/source/model/template/BarChartType.cxx +++ b/chart2/source/model/template/BarChartType.cxx @@ -45,6 +45,11 @@ uno::Reference< util::XCloneable > SAL_CALL BarChartType::createClone() return uno::Reference< util::XCloneable >( new BarChartType( *this )); } +rtl::Reference< ChartType > BarChartType::cloneChartType() const +{ + return new BarChartType( *this ); +} + // ____ XChartType ____ OUString SAL_CALL BarChartType::getChartType() { diff --git a/chart2/source/model/template/BarChartType.hxx b/chart2/source/model/template/BarChartType.hxx index 62ed9aa0c2a2..cceaf05777f0 100644 --- a/chart2/source/model/template/BarChartType.hxx +++ b/chart2/source/model/template/BarChartType.hxx @@ -18,7 +18,7 @@ */ #pragma once -#include "ChartType.hxx" +#include namespace chart { @@ -36,6 +36,8 @@ public: virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + virtual rtl::Reference cloneChartType() const override; + private: explicit BarChartType( const BarChartType & rOther ); diff --git a/chart2/source/model/template/BubbleChartType.cxx b/chart2/source/model/template/BubbleChartType.cxx index d0fc66213a97..c2d7d367ea65 100644 --- a/chart2/source/model/template/BubbleChartType.cxx +++ b/chart2/source/model/template/BubbleChartType.cxx @@ -109,6 +109,11 @@ uno::Reference< util::XCloneable > SAL_CALL BubbleChartType::createClone() return uno::Reference< util::XCloneable >( new BubbleChartType( *this )); } +rtl::Reference< ChartType > BubbleChartType::cloneChartType() const +{ + return new BubbleChartType( *this ); +} + // ____ XChartType ____ Reference< chart2::XCoordinateSystem > SAL_CALL BubbleChartType::createCoordinateSystem( ::sal_Int32 DimensionCount ) diff --git a/chart2/source/model/template/BubbleChartType.hxx b/chart2/source/model/template/BubbleChartType.hxx index 4be938b66a88..10e82ae6a662 100644 --- a/chart2/source/model/template/BubbleChartType.hxx +++ b/chart2/source/model/template/BubbleChartType.hxx @@ -18,7 +18,7 @@ */ #pragma once -#include "ChartType.hxx" +#include namespace chart { @@ -36,6 +36,8 @@ public: virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + virtual rtl::Reference cloneChartType() const override; + private: explicit BubbleChartType( const BubbleChartType & rOther ); diff --git a/chart2/source/model/template/CandleStickChartType.cxx b/chart2/source/model/template/CandleStickChartType.cxx index 065b8d8ca736..553a137486c9 100644 --- a/chart2/source/model/template/CandleStickChartType.cxx +++ b/chart2/source/model/template/CandleStickChartType.cxx @@ -206,6 +206,11 @@ uno::Reference< util::XCloneable > SAL_CALL CandleStickChartType::createClone() return uno::Reference< util::XCloneable >( new CandleStickChartType( *this )); } +rtl::Reference< ChartType > CandleStickChartType::cloneChartType() const +{ + return new CandleStickChartType( *this ); +} + // ____ XChartType ____ OUString SAL_CALL CandleStickChartType::getChartType() { diff --git a/chart2/source/model/template/CandleStickChartType.hxx b/chart2/source/model/template/CandleStickChartType.hxx index eac57a5b6496..e7610750758f 100644 --- a/chart2/source/model/template/CandleStickChartType.hxx +++ b/chart2/source/model/template/CandleStickChartType.hxx @@ -18,7 +18,7 @@ */ #pragma once -#include "ChartType.hxx" +#include namespace chart { @@ -38,6 +38,8 @@ public: virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + virtual rtl::Reference cloneChartType() const override; + private: explicit CandleStickChartType( const CandleStickChartType & rOther ); diff --git a/chart2/source/model/template/ChartType.cxx b/chart2/source/model/template/ChartType.cxx index b93c36806096..aa0a17453f25 100644 --- a/chart2/source/model/template/ChartType.cxx +++ b/chart2/source/model/template/ChartType.cxx @@ -17,7 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include "ChartType.hxx" +#include #include #include #include diff --git a/chart2/source/model/template/ChartType.hxx b/chart2/source/model/template/ChartType.hxx deleted file mode 100644 index 74e8bcb14300..000000000000 --- a/chart2/source/model/template/ChartType.hxx +++ /dev/null @@ -1,137 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace chart -{ - -namespace impl -{ -typedef ::cppu::WeakImplHelper< - css::lang::XServiceInfo, - css::chart2::XChartType, - css::chart2::XDataSeriesContainer, - css::util::XCloneable, - css::util::XModifyBroadcaster, - css::util::XModifyListener > - ChartType_Base; -} - -class ChartType : - public cppu::BaseMutex, - public impl::ChartType_Base, - public ::property::OPropertySet -{ -public: - explicit ChartType(); - virtual ~ChartType() override; - - /// merge XInterface implementations - DECLARE_XINTERFACE() - -protected: - explicit ChartType( const ChartType & rOther ); - - // ____ XChartType ____ - // still abstract ! implement ! - virtual OUString SAL_CALL getChartType() override = 0; - virtual css::uno::Reference< css::chart2::XCoordinateSystem > SAL_CALL - createCoordinateSystem( ::sal_Int32 DimensionCount ) override; - virtual css::uno::Sequence< OUString > SAL_CALL - getSupportedMandatoryRoles() override; - virtual css::uno::Sequence< OUString > SAL_CALL - getSupportedOptionalRoles() override; - virtual OUString SAL_CALL getRoleOfSequenceForSeriesLabel() override; - virtual css::uno::Sequence< OUString > SAL_CALL - getSupportedPropertyRoles() override; - - // ____ XDataSeriesContainer ____ - virtual void SAL_CALL addDataSeries( - const css::uno::Reference< css::chart2::XDataSeries >& aDataSeries ) override; - virtual void SAL_CALL removeDataSeries( - const css::uno::Reference< css::chart2::XDataSeries >& aDataSeries ) override; - virtual css::uno::Sequence< css::uno::Reference< css::chart2::XDataSeries > > SAL_CALL getDataSeries() override; - virtual void SAL_CALL setDataSeries( - const css::uno::Sequence< css::uno::Reference< css::chart2::XDataSeries > >& aDataSeries ) override; - - // ____ XModifyBroadcaster ____ - virtual void SAL_CALL addModifyListener( - const css::uno::Reference< css::util::XModifyListener >& aListener ) override; - virtual void SAL_CALL removeModifyListener( - const css::uno::Reference< css::util::XModifyListener >& aListener ) override; - - // ____ XModifyListener ____ - virtual void SAL_CALL modified( - const css::lang::EventObject& aEvent ) override; - - // ____ XEventListener (base of XModifyListener) ____ - virtual void SAL_CALL disposing( - const css::lang::EventObject& Source ) override; - - void fireModifyEvent(); - - // ____ OPropertySet ____ - virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override; - virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override; - - virtual void firePropertyChangeEvent() override; - using OPropertySet::disposing; - - // ____ XPropertySet ____ - virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL - getPropertySetInfo() override; - - /// merge XTypeProvider implementations - DECLARE_XTYPEPROVIDER() - -protected: - css::uno::Reference< css::util::XModifyListener > - const m_xModifyEventForwarder; - -private: - void impl_addDataSeriesWithoutNotification( - const css::uno::Reference< css::chart2::XDataSeries >& aDataSeries ); - -private: - typedef - std::vector< css::uno::Reference< css::chart2::XDataSeries > > tDataSeriesContainerType; - - // --- mutable members: the following members need mutex guard --- - - tDataSeriesContainerType m_aDataSeries; - - bool m_bNotifyChanges; -}; - -} // namespace chart - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/model/template/ChartTypeTemplate.cxx b/chart2/source/model/template/ChartTypeTemplate.cxx index e6eb5e27e069..eaecc8230fa2 100644 --- a/chart2/source/model/template/ChartTypeTemplate.cxx +++ b/chart2/source/model/template/ChartTypeTemplate.cxx @@ -21,6 +21,7 @@ #include "DataInterpreter.hxx" #include #include +#include #include #include @@ -161,7 +162,7 @@ uno::Reference< XDiagram > SAL_CALL ChartTypeTemplate::createDiagramByDataSource for( auto const & j : i ) lcl_applyDefaultStyle( j, nCount++, xDia ); - Sequence< Reference< XChartType > > aOldChartTypesSeq; + std::vector< rtl::Reference< ChartType > > aOldChartTypesSeq; FillDiagram( xDia, aData.Series, aData.Categories, aOldChartTypesSeq ); } catch( const uno::Exception & ) @@ -225,8 +226,8 @@ void SAL_CALL ChartTypeTemplate::changeDiagram( const uno::Reference< XDiagram > } // remove charttype groups from all coordinate systems - Sequence< Reference< XChartType > > aOldChartTypesSeq( - DiagramHelper::getChartTypesFromDiagram(xDiagram) ); + std::vector< rtl::Reference< ChartType > > aOldChartTypesSeq = + DiagramHelper::getChartTypesFromDiagram(xDiagram); Reference< XCoordinateSystemContainer > xCoordSysCnt( xDiagram, uno::UNO_QUERY ); OSL_ASSERT( xCoordSysCnt.is()); @@ -286,13 +287,12 @@ void SAL_CALL ChartTypeTemplate::changeDiagramData( // categories DiagramHelper::setCategoriesToDiagram( aData.Categories, xDiagram, true, supportsCategories() ); - Sequence< Reference< XChartType > > aChartTypes( - DiagramHelper::getChartTypesFromDiagram( xDiagram )); - sal_Int32 nMax = std::min( aChartTypes.getLength(), aSeriesSeq.getLength()); + std::vector< rtl::Reference< ChartType > > aChartTypes = + DiagramHelper::getChartTypesFromDiagram( xDiagram ); + sal_Int32 nMax = std::min( static_cast(aChartTypes.size()), aSeriesSeq.getLength()); for( i=0; i xDSCnt( aChartTypes[i], uno::UNO_QUERY_THROW ); - xDSCnt->setDataSeries( aSeriesSeq[i] ); + aChartTypes[i]->setDataSeries( aSeriesSeq[i] ); } } catch( const uno::Exception & ) @@ -748,11 +748,19 @@ sal_Int32 ChartTypeTemplate::getAxisCountByDimension( sal_Int32 nDimension ) return (nDimension < getDimension()) ? 1 : 0; } +rtl::Reference< ChartType > ChartTypeTemplate::getChartTypeForNewSeries( const std::vector< rtl::Reference< ChartType > >& aFormerlyUsedChartTypes ) +{ + uno::Reference xChartType = getChartTypeForNewSeries(comphelper::containerToSequence>(aFormerlyUsedChartTypes)); + auto pChartType = dynamic_cast(xChartType.get()); + assert(!xChartType || pChartType); + return pChartType; +} + void ChartTypeTemplate::FillDiagram( const Reference< XDiagram >& xDiagram, const Sequence< Sequence< Reference< XDataSeries > > >& aSeriesSeq, const Reference< data::XLabeledDataSequence >& xCategories, - const Sequence< Reference< XChartType > >& aOldChartTypesSeq ) + const std::vector< rtl::Reference< ChartType > >& aOldChartTypesSeq ) { adaptDiagram( xDiagram ); @@ -779,7 +787,7 @@ void ChartTypeTemplate::FillDiagram( void ChartTypeTemplate::createChartTypes( const Sequence< Sequence< Reference< XDataSeries > > > & aSeriesSeq, const Sequence< Reference< XCoordinateSystem > > & rCoordSys, - const Sequence< Reference< XChartType > >& aOldChartTypesSeq ) + const std::vector< rtl::Reference< ChartType > >& aOldChartTypesSeq ) { if( ! rCoordSys.hasElements() || ! rCoordSys[0].is() ) @@ -788,11 +796,11 @@ void ChartTypeTemplate::createChartTypes( try { sal_Int32 nCooSysIdx=0; - Reference< XChartType > xCT; + rtl::Reference< ChartType > xCT; if( !aSeriesSeq.hasElements() ) { // we need a new chart type - xCT.set( getChartTypeForNewSeries( aOldChartTypesSeq )); + xCT = getChartTypeForNewSeries( aOldChartTypesSeq ); Reference< XChartTypeContainer > xCTCnt( rCoordSys[nCooSysIdx], uno::UNO_QUERY_THROW ); xCTCnt->setChartTypes({ xCT }); } @@ -803,7 +811,7 @@ void ChartTypeTemplate::createChartTypes( if( nSeriesIdx == nCooSysIdx ) { // we need a new chart type - xCT.set( getChartTypeForNewSeries( aOldChartTypesSeq )); + xCT = getChartTypeForNewSeries( aOldChartTypesSeq ); Reference< XChartTypeContainer > xCTCnt( rCoordSys[nCooSysIdx], uno::UNO_QUERY_THROW ); Sequence< Reference< XChartType > > aCTSeq( xCTCnt->getChartTypes()); if( aCTSeq.hasElements()) @@ -814,21 +822,19 @@ void ChartTypeTemplate::createChartTypes( else xCTCnt->addChartType( xCT ); - Reference< chart2::XDataSeriesContainer > xDSCnt( xCT, uno::UNO_QUERY_THROW ); - xDSCnt->setDataSeries( aSeriesSeq[nSeriesIdx] ); + xCT->setDataSeries( aSeriesSeq[nSeriesIdx] ); } else { // reuse existing chart type OSL_ASSERT( xCT.is()); - Reference< chart2::XDataSeriesContainer > xDSCnt( xCT, uno::UNO_QUERY_THROW ); - Sequence< Reference< XDataSeries > > aNewSeriesSeq( xDSCnt->getDataSeries()); + Sequence< Reference< XDataSeries > > aNewSeriesSeq( xCT->getDataSeries()); sal_Int32 nNewStartIndex = aNewSeriesSeq.getLength(); aNewSeriesSeq.realloc( nNewStartIndex + aSeriesSeq[nSeriesIdx].getLength() ); std::copy( aSeriesSeq[nSeriesIdx].begin(), aSeriesSeq[nSeriesIdx].end(), aNewSeriesSeq.getArray() + nNewStartIndex ); - xDSCnt->setDataSeries( aNewSeriesSeq ); + xCT->setDataSeries( aNewSeriesSeq ); } // spread the series over the available coordinate systems @@ -867,6 +873,30 @@ void ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( comphelper::copyProperties( xSource, xDestination ); } +void ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( + const std::vector< rtl::Reference< ChartType > > & rOldChartTypesSeq, + const Reference< XChartType > & xNewChartType ) +{ + Reference< beans::XPropertySet > xDestination( xNewChartType, uno::UNO_QUERY ); + if( !xDestination.is() ) + return; + + OUString aNewChartType( xNewChartType->getChartType() ); + + Reference< beans::XPropertySet > xSource; + for( rtl::Reference< ChartType > const & xOldType : rOldChartTypesSeq ) + { + if( xOldType.is() && xOldType->getChartType() == aNewChartType ) + { + xSource = xOldType; + if( xSource.is() ) + break; + } + } + if( xSource.is() ) + comphelper::copyProperties( xSource, xDestination ); +} + } // namespace chart /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/model/template/ColumnChartType.cxx b/chart2/source/model/template/ColumnChartType.cxx index 3553e289985e..50fdca0e1dbc 100644 --- a/chart2/source/model/template/ColumnChartType.cxx +++ b/chart2/source/model/template/ColumnChartType.cxx @@ -139,6 +139,11 @@ uno::Reference< util::XCloneable > SAL_CALL ColumnChartType::createClone() return uno::Reference< util::XCloneable >( new ColumnChartType( *this )); } +rtl::Reference< ChartType > ColumnChartType::cloneChartType() const +{ + return new ColumnChartType( *this ); +} + // ____ XChartType ____ OUString SAL_CALL ColumnChartType::getChartType() { diff --git a/chart2/source/model/template/ColumnChartType.hxx b/chart2/source/model/template/ColumnChartType.hxx index d304092cbfc0..2c6b3d762321 100644 --- a/chart2/source/model/template/ColumnChartType.hxx +++ b/chart2/source/model/template/ColumnChartType.hxx @@ -18,7 +18,7 @@ */ #pragma once -#include "ChartType.hxx" +#include namespace chart { @@ -36,6 +36,8 @@ public: virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + virtual rtl::Reference cloneChartType() const override; + private: explicit ColumnChartType( const ColumnChartType & rOther ); diff --git a/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx b/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx index fad59386b2b3..e0ab9a713903 100644 --- a/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx +++ b/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx @@ -160,7 +160,7 @@ uno::Reference< beans::XPropertySetInfo > SAL_CALL ColumnLineChartTypeTemplate:: void ColumnLineChartTypeTemplate::createChartTypes( const Sequence< Sequence< Reference< XDataSeries > > > & aSeriesSeq, const Sequence< Reference< XCoordinateSystem > > & rCoordSys, - const Sequence< Reference< XChartType > >& aOldChartTypesSeq ) + const std::vector< rtl::Reference< ChartType > >& aOldChartTypesSeq ) { if( ! rCoordSys.hasElements() || ! rCoordSys[0].is() ) diff --git a/chart2/source/model/template/ColumnLineChartTypeTemplate.hxx b/chart2/source/model/template/ColumnLineChartTypeTemplate.hxx index d112b81f58ad..8bb28db244de 100644 --- a/chart2/source/model/template/ColumnLineChartTypeTemplate.hxx +++ b/chart2/source/model/template/ColumnLineChartTypeTemplate.hxx @@ -78,9 +78,7 @@ protected: const css::uno::Sequence< css::uno::Reference< css::chart2::XCoordinateSystem > > & rCoordSys, - const css::uno::Sequence< - css::uno::Reference< - css::chart2::XChartType > > & aOldChartTypesSeq + const std::vector< rtl::Reference< ChartType > > & aOldChartTypesSeq ) override; virtual css::uno::Reference< css::chart2::XChartType > diff --git a/chart2/source/model/template/FilledNetChartType.cxx b/chart2/source/model/template/FilledNetChartType.cxx index 3179317daee5..6ec39d983516 100644 --- a/chart2/source/model/template/FilledNetChartType.cxx +++ b/chart2/source/model/template/FilledNetChartType.cxx @@ -48,6 +48,11 @@ uno::Reference< util::XCloneable > SAL_CALL FilledNetChartType::createClone() return uno::Reference< util::XCloneable >( new FilledNetChartType( *this )); } +rtl::Reference< ChartType > FilledNetChartType::cloneChartType() const +{ + return new FilledNetChartType( *this ); +} + // ____ XChartType ____ OUString SAL_CALL FilledNetChartType::getChartType() { diff --git a/chart2/source/model/template/FilledNetChartType.hxx b/chart2/source/model/template/FilledNetChartType.hxx index 0ca41b60ba55..b2d239aeca36 100644 --- a/chart2/source/model/template/FilledNetChartType.hxx +++ b/chart2/source/model/template/FilledNetChartType.hxx @@ -32,6 +32,8 @@ public: virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; virtual css::uno::Sequence SAL_CALL getSupportedServiceNames() override; + virtual rtl::Reference cloneChartType() const override; + private: explicit FilledNetChartType(const FilledNetChartType& rOther); diff --git a/chart2/source/model/template/LineChartType.cxx b/chart2/source/model/template/LineChartType.cxx index f0d595f27102..8edccdfb858e 100644 --- a/chart2/source/model/template/LineChartType.cxx +++ b/chart2/source/model/template/LineChartType.cxx @@ -151,6 +151,11 @@ uno::Reference< util::XCloneable > SAL_CALL LineChartType::createClone() return uno::Reference< util::XCloneable >( new LineChartType( *this )); } +rtl::Reference< ChartType > LineChartType::cloneChartType() const +{ + return new LineChartType( *this ); +} + // ____ XChartType ____ OUString SAL_CALL LineChartType::getChartType() { diff --git a/chart2/source/model/template/LineChartType.hxx b/chart2/source/model/template/LineChartType.hxx index a655670d852e..4c44cca9c349 100644 --- a/chart2/source/model/template/LineChartType.hxx +++ b/chart2/source/model/template/LineChartType.hxx @@ -18,7 +18,7 @@ */ #pragma once -#include "ChartType.hxx" +#include namespace chart { @@ -36,6 +36,8 @@ public: virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + virtual rtl::Reference cloneChartType() const override; + private: explicit LineChartType( const LineChartType & rOther ); diff --git a/chart2/source/model/template/LineChartTypeTemplate.cxx b/chart2/source/model/template/LineChartTypeTemplate.cxx index bbde1bebc3f1..dc243571393f 100644 --- a/chart2/source/model/template/LineChartTypeTemplate.cxx +++ b/chart2/source/model/template/LineChartTypeTemplate.cxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -267,12 +268,11 @@ sal_Bool SAL_CALL LineChartTypeTemplate::matchesTemplate( { try { - uno::Reference< beans::XPropertySet > xChartTypeProp( - DiagramHelper::getChartTypeByIndex( xDiagram, 0 ), - uno::UNO_QUERY_THROW ); - setFastPropertyValue_NoBroadcast( PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE, xChartTypeProp->getPropertyValue(CHART_UNONAME_CURVE_STYLE) ); - setFastPropertyValue_NoBroadcast( PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION, xChartTypeProp->getPropertyValue(CHART_UNONAME_CURVE_RESOLUTION) ); - setFastPropertyValue_NoBroadcast( PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER, xChartTypeProp->getPropertyValue(CHART_UNONAME_SPLINE_ORDER) ); + rtl::Reference< ChartType > xChartType = + DiagramHelper::getChartTypeByIndex( xDiagram, 0 ); + setFastPropertyValue_NoBroadcast( PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE, xChartType->getPropertyValue(CHART_UNONAME_CURVE_STYLE) ); + setFastPropertyValue_NoBroadcast( PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION, xChartType->getPropertyValue(CHART_UNONAME_CURVE_RESOLUTION) ); + setFastPropertyValue_NoBroadcast( PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER, xChartType->getPropertyValue(CHART_UNONAME_SPLINE_ORDER) ); } catch( const uno::Exception & ) { diff --git a/chart2/source/model/template/NetChartType.cxx b/chart2/source/model/template/NetChartType.cxx index 8aecbec7b60c..971befddfca9 100644 --- a/chart2/source/model/template/NetChartType.cxx +++ b/chart2/source/model/template/NetChartType.cxx @@ -147,6 +147,11 @@ uno::Reference< util::XCloneable > SAL_CALL NetChartType::createClone() return uno::Reference< util::XCloneable >( new NetChartType( *this )); } +rtl::Reference< ChartType > NetChartType::cloneChartType() const +{ + return new NetChartType( *this ); +} + // ____ XChartType ____ OUString SAL_CALL NetChartType::getChartType() { diff --git a/chart2/source/model/template/NetChartType.hxx b/chart2/source/model/template/NetChartType.hxx index 7f1c16d60dd8..d9875be541a3 100644 --- a/chart2/source/model/template/NetChartType.hxx +++ b/chart2/source/model/template/NetChartType.hxx @@ -18,7 +18,7 @@ */ #pragma once -#include "ChartType.hxx" +#include namespace chart { @@ -59,6 +59,8 @@ public: virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + virtual rtl::Reference cloneChartType() const override; + private: explicit NetChartType( const NetChartType & rOther ); diff --git a/chart2/source/model/template/NetChartTypeTemplate.cxx b/chart2/source/model/template/NetChartTypeTemplate.cxx index fed499cb3970..880b6841a7d5 100644 --- a/chart2/source/model/template/NetChartTypeTemplate.cxx +++ b/chart2/source/model/template/NetChartTypeTemplate.cxx @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -87,8 +88,8 @@ sal_Bool SAL_CALL NetChartTypeTemplate::matchesTemplate( { bool bResult = ChartTypeTemplate::matchesTemplate( xDiagram, bAdaptProperties ); - uno::Reference< beans::XPropertySet > xChartTypeProp( - DiagramHelper::getChartTypeByIndex( xDiagram, 0 ), uno::UNO_QUERY_THROW ); + rtl::Reference< ChartType > xChartType = + DiagramHelper::getChartTypeByIndex( xDiagram, 0 ); if( bResult ) { diff --git a/chart2/source/model/template/PieChartType.cxx b/chart2/source/model/template/PieChartType.cxx index 777fb55c316d..1208283fcc1e 100644 --- a/chart2/source/model/template/PieChartType.cxx +++ b/chart2/source/model/template/PieChartType.cxx @@ -139,6 +139,11 @@ uno::Reference< util::XCloneable > SAL_CALL PieChartType::createClone() return uno::Reference< util::XCloneable >( new PieChartType( *this )); } +rtl::Reference< ChartType > PieChartType::cloneChartType() const +{ + return new PieChartType( *this ); +} + // ____ XChartType ____ OUString SAL_CALL PieChartType::getChartType() { diff --git a/chart2/source/model/template/PieChartType.hxx b/chart2/source/model/template/PieChartType.hxx index c3164d4308a6..0ecc0160393c 100644 --- a/chart2/source/model/template/PieChartType.hxx +++ b/chart2/source/model/template/PieChartType.hxx @@ -18,7 +18,7 @@ */ #pragma once -#include "ChartType.hxx" +#include namespace chart { @@ -36,6 +36,8 @@ public: virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + virtual rtl::Reference cloneChartType() const override; + private: explicit PieChartType( const PieChartType & rOther ); diff --git a/chart2/source/model/template/PieChartTypeTemplate.cxx b/chart2/source/model/template/PieChartTypeTemplate.cxx index 218ee48ff520..6d87cee6628b 100644 --- a/chart2/source/model/template/PieChartTypeTemplate.cxx +++ b/chart2/source/model/template/PieChartTypeTemplate.cxx @@ -19,6 +19,7 @@ #include "PieChartTypeTemplate.hxx" #include +#include #include #include #include @@ -274,7 +275,7 @@ void PieChartTypeTemplate::adaptScales( void PieChartTypeTemplate::createChartTypes( const Sequence< Sequence< Reference< chart2::XDataSeries > > > & aSeriesSeq, const Sequence< Reference< chart2::XCoordinateSystem > > & rCoordSys, - const Sequence< Reference< chart2::XChartType > >& /* aOldChartTypesSeq */ ) + const std::vector< rtl::Reference< ChartType > >& /* aOldChartTypesSeq */ ) { if( ! rCoordSys.hasElements() || ! rCoordSys[0].is() ) @@ -391,8 +392,8 @@ sal_Bool SAL_CALL PieChartTypeTemplate::matchesTemplate( //check UseRings if( bResult ) { - uno::Reference< beans::XPropertySet > xCTProp( - DiagramHelper::getChartTypeByIndex( xDiagram, 0 ), uno::UNO_QUERY_THROW ); + rtl::Reference< ChartType > xCTProp = + DiagramHelper::getChartTypeByIndex( xDiagram, 0 ); bool bUseRings = false; if( xCTProp->getPropertyValue( "UseRings") >>= bUseRings ) { diff --git a/chart2/source/model/template/PieChartTypeTemplate.hxx b/chart2/source/model/template/PieChartTypeTemplate.hxx index c749be57447a..b4a010b17647 100644 --- a/chart2/source/model/template/PieChartTypeTemplate.hxx +++ b/chart2/source/model/template/PieChartTypeTemplate.hxx @@ -94,9 +94,7 @@ protected: const css::uno::Sequence< css::uno::Reference< css::chart2::XCoordinateSystem > > & rCoordSys, - const css::uno::Sequence< - css::uno::Reference< - css::chart2::XChartType > > & aOldChartTypesSeq + const std::vector< rtl::Reference< ChartType > > & aOldChartTypesSeq ) override; virtual css::uno::Reference< css::chart2::XChartType > diff --git a/chart2/source/model/template/ScatterChartType.cxx b/chart2/source/model/template/ScatterChartType.cxx index 4693df06d674..63d46fed23b9 100644 --- a/chart2/source/model/template/ScatterChartType.cxx +++ b/chart2/source/model/template/ScatterChartType.cxx @@ -154,6 +154,11 @@ uno::Reference< util::XCloneable > SAL_CALL ScatterChartType::createClone() return uno::Reference< util::XCloneable >( new ScatterChartType( *this )); } +rtl::Reference< ChartType > ScatterChartType::cloneChartType() const +{ + return new ScatterChartType( *this ); +} + // ____ XChartType ____ Reference< chart2::XCoordinateSystem > SAL_CALL ScatterChartType::createCoordinateSystem( ::sal_Int32 DimensionCount ) diff --git a/chart2/source/model/template/ScatterChartType.hxx b/chart2/source/model/template/ScatterChartType.hxx index da14efb0df3f..03750e5d8f2a 100644 --- a/chart2/source/model/template/ScatterChartType.hxx +++ b/chart2/source/model/template/ScatterChartType.hxx @@ -18,7 +18,7 @@ */ #pragma once -#include "ChartType.hxx" +#include namespace chart { @@ -36,6 +36,8 @@ public: virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + virtual rtl::Reference cloneChartType() const override; + private: explicit ScatterChartType( const ScatterChartType & rOther ); diff --git a/chart2/source/model/template/ScatterChartTypeTemplate.cxx b/chart2/source/model/template/ScatterChartTypeTemplate.cxx index cf22e22c6d55..c6caa7aa4724 100644 --- a/chart2/source/model/template/ScatterChartTypeTemplate.cxx +++ b/chart2/source/model/template/ScatterChartTypeTemplate.cxx @@ -19,6 +19,7 @@ #include "ScatterChartTypeTemplate.hxx" #include "XYDataInterpreter.hxx" +#include #include #include #include @@ -297,9 +298,8 @@ sal_Bool SAL_CALL ScatterChartTypeTemplate::matchesTemplate( { try { - uno::Reference< beans::XPropertySet > xChartTypeProp( - DiagramHelper::getChartTypeByIndex( xDiagram, 0 ), - uno::UNO_QUERY_THROW ); + rtl::Reference< ChartType > xChartTypeProp = + DiagramHelper::getChartTypeByIndex( xDiagram, 0 ); setFastPropertyValue_NoBroadcast( PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_STYLE, xChartTypeProp->getPropertyValue(CHART_UNONAME_CURVE_STYLE) ); setFastPropertyValue_NoBroadcast( PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_RESOLUTION, xChartTypeProp->getPropertyValue(CHART_UNONAME_CURVE_RESOLUTION) ); setFastPropertyValue_NoBroadcast( PROP_SCATTERCHARTTYPE_TEMPLATE_SPLINE_ORDER, xChartTypeProp->getPropertyValue(CHART_UNONAME_SPLINE_ORDER) ); diff --git a/chart2/source/model/template/StockChartTypeTemplate.cxx b/chart2/source/model/template/StockChartTypeTemplate.cxx index 3cd5ec0e5c92..c1ee6d341d60 100644 --- a/chart2/source/model/template/StockChartTypeTemplate.cxx +++ b/chart2/source/model/template/StockChartTypeTemplate.cxx @@ -281,7 +281,7 @@ Reference< XChartType > StockChartTypeTemplate::getChartTypeForIndex( sal_Int32 void StockChartTypeTemplate::createChartTypes( const Sequence< Sequence< Reference< XDataSeries > > > & aSeriesSeq, const Sequence< Reference< XCoordinateSystem > > & rCoordSys, - const Sequence< Reference< XChartType > >& /* aOldChartTypesSeq */ ) + const std::vector< rtl::Reference< ChartType > >& /* aOldChartTypesSeq */ ) { if( !rCoordSys.hasElements() ) return; diff --git a/chart2/source/model/template/StockChartTypeTemplate.hxx b/chart2/source/model/template/StockChartTypeTemplate.hxx index 99eb7da8c8cf..a16fd26efbe5 100644 --- a/chart2/source/model/template/StockChartTypeTemplate.hxx +++ b/chart2/source/model/template/StockChartTypeTemplate.hxx @@ -98,9 +98,7 @@ protected: const css::uno::Sequence< css::uno::Reference< css::chart2::XCoordinateSystem > > & rCoordSys, - const css::uno::Sequence< - css::uno::Reference< - css::chart2::XChartType > > & aOldChartTypesSeq + const std::vector< rtl::Reference< ChartType > > & aOldChartTypesSeq ) override; virtual css::uno::Reference< css::chart2::XChartType > diff --git a/chart2/source/tools/AxisHelper.cxx b/chart2/source/tools/AxisHelper.cxx index 38bdb6f4f98f..36f6a84756cb 100644 --- a/chart2/source/tools/AxisHelper.cxx +++ b/chart2/source/tools/AxisHelper.cxx @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -889,7 +890,7 @@ void AxisHelper::getAxisOrGridPossibilities( Sequence< sal_Bool >& rPossibilityL //set possibilities: sal_Int32 nIndex=0; - Reference< XChartType > xChartType = DiagramHelper::getChartTypeByIndex( xDiagram, 0 ); + rtl::Reference< ChartType > xChartType = DiagramHelper::getChartTypeByIndex( xDiagram, 0 ); for(nIndex=0;nIndex<3;nIndex++) pPossibilityList[nIndex]=ChartTypeHelper::isSupportingMainAxis(xChartType,nDimensionCount,nIndex); for(nIndex=3;nIndex<6;nIndex++) @@ -1044,16 +1045,17 @@ rtl::Reference< BaseCoordinateSystem > AxisHelper::getCoordinateSystemOfAxis( return xRet; } -Reference< XChartType > AxisHelper::getChartTypeByIndex( const Reference< XCoordinateSystem >& xCooSys, sal_Int32 nIndex ) +rtl::Reference< ChartType > AxisHelper::getChartTypeByIndex( const Reference< XCoordinateSystem >& xCooSys, sal_Int32 nIndex ) { - Reference< XChartType > xChartType; + rtl::Reference< ChartType > xChartType; Reference< XChartTypeContainer > xChartTypeContainer( xCooSys, uno::UNO_QUERY ); - if( xChartTypeContainer.is() ) + if( xCooSys.is() ) { - Sequence< Reference< XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() ); - if( nIndex >= 0 && nIndex < aChartTypeList.getLength() ) - xChartType.set( aChartTypeList[nIndex] ); + auto pCooSys = dynamic_cast(xCooSys.get()); + const std::vector< rtl::Reference< ChartType > > aChartTypeList( pCooSys->getChartTypes2() ); + if( nIndex >= 0 && nIndex < static_cast(aChartTypeList.size()) ) + xChartType = aChartTypeList[nIndex]; } return xChartType; @@ -1127,9 +1129,9 @@ void AxisHelper::setRTLAxisLayout( const Reference< XCoordinateSystem >& xCooSys } } -Reference< XChartType > AxisHelper::getFirstChartTypeWithSeriesAttachedToAxisIndex( const Reference< chart2::XDiagram >& xDiagram, const sal_Int32 nAttachedAxisIndex ) +rtl::Reference< ChartType > AxisHelper::getFirstChartTypeWithSeriesAttachedToAxisIndex( const Reference< chart2::XDiagram >& xDiagram, const sal_Int32 nAttachedAxisIndex ) { - Reference< XChartType > xChartType; + rtl::Reference< ChartType > xChartType; std::vector< Reference< XDataSeries > > aSeriesVector( DiagramHelper::getDataSeriesFromDiagram( xDiagram ) ); for (auto const& series : aSeriesVector) { diff --git a/chart2/source/tools/ChartModelHelper.cxx b/chart2/source/tools/ChartModelHelper.cxx index b81d047cc39d..829c3d9ffb47 100644 --- a/chart2/source/tools/ChartModelHelper.cxx +++ b/chart2/source/tools/ChartModelHelper.cxx @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -182,7 +183,7 @@ std::vector< uno::Reference< XDataSeries > > ChartModelHelper::getDataSeries( return getDataSeries( uno::Reference< chart2::XChartDocument >( xModel, uno::UNO_QUERY )); } -uno::Reference< XChartType > ChartModelHelper::getChartTypeOfSeries( +rtl::Reference< ChartType > ChartModelHelper::getChartTypeOfSeries( const uno::Reference< frame::XModel >& xModel , const uno::Reference< XDataSeries >& xGivenDataSeries ) { diff --git a/chart2/source/tools/ChartTypeHelper.cxx b/chart2/source/tools/ChartTypeHelper.cxx index 323e68197969..e921f01c1581 100644 --- a/chart2/source/tools/ChartTypeHelper.cxx +++ b/chart2/source/tools/ChartTypeHelper.cxx @@ -18,6 +18,7 @@ */ #include +#include #include #include @@ -437,6 +438,26 @@ bool ChartTypeHelper::isSupportingDateAxis( const uno::Reference< chart2::XChart return true; } +bool ChartTypeHelper::isSupportingDateAxis( const rtl::Reference< ChartType >& xChartType, sal_Int32 nDimensionIndex ) +{ + if( nDimensionIndex!=0 ) + return false; + if( xChartType.is() ) + { + sal_Int32 nType = ChartTypeHelper::getAxisType( xChartType, nDimensionIndex ); + if( nType != AxisType::CATEGORY ) + return false; + OUString aChartTypeName = xChartType->getChartType(); + if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) ) + return false; + if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) ) + return false; + if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) ) + return false; + } + return true; +} + bool ChartTypeHelper::isSupportingComplexCategory( const uno::Reference< chart2::XChartType >& xChartType ) { if( xChartType.is() ) diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx index 7d9136e7291a..b75df5b0f29c 100644 --- a/chart2/source/tools/DiagramHelper.cxx +++ b/chart2/source/tools/DiagramHelper.cxx @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -591,7 +592,7 @@ uno::Reference< XAxis > DiagramHelper::getAttachedAxis( return AxisHelper::getAxis( 1, DiagramHelper::isSeriesAttachedToMainAxis( xSeries ), xDiagram ); } -uno::Reference< XChartType > DiagramHelper::getChartTypeOfSeries( +rtl::Reference< ChartType > DiagramHelper::getChartTypeOfSeries( const uno::Reference< chart2::XDiagram >& xDiagram , const uno::Reference< XDataSeries >& xGivenDataSeries ) { @@ -610,16 +611,11 @@ uno::Reference< XChartType > DiagramHelper::getChartTypeOfSeries( for( rtl::Reference< BaseCoordinateSystem > const & xCooSys : pDiagram->getBaseCoordinateSystems() ) { //iterate through all chart types in the current coordinate system - const uno::Sequence< uno::Reference< XChartType > > aChartTypeList( xCooSys->getChartTypes() ); - for( uno::Reference< XChartType > const & xChartType : aChartTypeList ) + const std::vector< rtl::Reference< ChartType > > & aChartTypeList( xCooSys->getChartTypes2() ); + for( rtl::Reference< ChartType > const & xChartType : aChartTypeList ) { //iterate through all series in this chart type - uno::Reference< XDataSeriesContainer > xDataSeriesContainer( xChartType, uno::UNO_QUERY ); - OSL_ASSERT( xDataSeriesContainer.is()); - if( !xDataSeriesContainer.is() ) - continue; - - const uno::Sequence< uno::Reference< XDataSeries > > aSeriesList( xDataSeriesContainer->getDataSeries() ); + const uno::Sequence< uno::Reference< XDataSeries > > aSeriesList( xChartType->getDataSeries() ); for( uno::Reference< XDataSeries > const & dataSeries : aSeriesList ) { if( xGivenDataSeries==dataSeries ) @@ -687,7 +683,7 @@ Sequence< Sequence< Reference< XDataSeries > > > return comphelper::containerToSequence( aResult ); } -Reference< XChartType > +rtl::Reference< ChartType > DiagramHelper::getChartTypeByIndex( const Reference< XDiagram >& xDiagram, sal_Int32 nIndex ) { if (!xDiagram) @@ -696,19 +692,19 @@ Reference< XChartType > Diagram* pDiagram = dynamic_cast(xDiagram.get()); assert(pDiagram); - Reference< XChartType > xChartType; + rtl::Reference< ChartType > xChartType; //iterate through all coordinate systems sal_Int32 nTypesSoFar = 0; for( rtl::Reference< BaseCoordinateSystem > const & coords : pDiagram->getBaseCoordinateSystems() ) { - Sequence< Reference< XChartType > > aChartTypeList( coords->getChartTypes() ); - if( nIndex >= 0 && nIndex < (nTypesSoFar + aChartTypeList.getLength()) ) + const std::vector< rtl::Reference< ChartType > > & aChartTypeList( coords->getChartTypes2() ); + if( nIndex >= 0 && nIndex < static_cast(nTypesSoFar + aChartTypeList.size()) ) { - xChartType.set( aChartTypeList[nIndex - nTypesSoFar] ); + xChartType = aChartTypeList[nIndex - nTypesSoFar]; break; } - nTypesSoFar += aChartTypeList.getLength(); + nTypesSoFar += aChartTypeList.size(); } return xChartType; @@ -1153,7 +1149,7 @@ sal_Int32 DiagramHelper::getPercentNumberFormat( const Reference< util::XNumberF return nRet; } -Sequence< Reference< XChartType > > +std::vector< rtl::Reference< ChartType > > DiagramHelper::getChartTypesFromDiagram( const Reference< XDiagram > & xDiagram ) { @@ -1162,12 +1158,12 @@ Sequence< Reference< XChartType > > Diagram* pDiagram = dynamic_cast(xDiagram.get()); assert(pDiagram); - std::vector< Reference< XChartType > > aResult; + std::vector< rtl::Reference< ChartType > > aResult; try { for( rtl::Reference< BaseCoordinateSystem > const & coords : pDiagram->getBaseCoordinateSystems() ) { - const Sequence< Reference< XChartType > > aChartTypeSeq( coords->getChartTypes()); + const std::vector< rtl::Reference< ChartType > > & aChartTypeSeq( coords->getChartTypes2()); aResult.insert( aResult.end(), aChartTypeSeq.begin(), aChartTypeSeq.end() ); } } @@ -1176,7 +1172,7 @@ Sequence< Reference< XChartType > > DBG_UNHANDLED_EXCEPTION("chart2"); } - return comphelper::containerToSequence( aResult ); + return aResult; } bool DiagramHelper::areChartTypesCompatible( const Reference< ::chart2::XChartType >& xFirstType, @@ -1401,9 +1397,9 @@ bool DiagramHelper::isSupportingFloorAndWall( const Reference< //todo: allow this in future again, if fileversion is available for OLE objects (metastream) //thus the wrong bottom can be removed on import - const Sequence< Reference< chart2::XChartType > > aTypes( + const std::vector< rtl::Reference< ChartType > > aTypes( ::chart::DiagramHelper::getChartTypesFromDiagram( xDiagram ) ); - for( Reference< chart2::XChartType > const & xType : aTypes ) + for( rtl::Reference< ChartType > const & xType : aTypes ) { if( xType.is() && xType->getChartType().match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) ) return false; diff --git a/chart2/source/tools/ExplicitCategoriesProvider.cxx b/chart2/source/tools/ExplicitCategoriesProvider.cxx index 0f418198a08d..95ef825f7ecc 100644 --- a/chart2/source/tools/ExplicitCategoriesProvider.cxx +++ b/chart2/source/tools/ExplicitCategoriesProvider.cxx @@ -19,6 +19,7 @@ #include #include +#include #include #include #include diff --git a/chart2/source/tools/ObjectIdentifier.cxx b/chart2/source/tools/ObjectIdentifier.cxx index f95022510203..8983e7ef427a 100644 --- a/chart2/source/tools/ObjectIdentifier.cxx +++ b/chart2/source/tools/ObjectIdentifier.cxx @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -1369,7 +1370,7 @@ Reference< XDataSeries > ObjectIdentifier::getDataSeriesForCID( sal_Int32 nPointIndex = -1; lcl_parseSeriesIndices( nChartTypeIndex, nSeriesIndex, nPointIndex, rObjectCID ); - Reference< XDataSeriesContainer > xDataSeriesContainer( DiagramHelper::getChartTypeByIndex( xDiagram, nChartTypeIndex ), uno::UNO_QUERY ); + rtl::Reference< ChartType > xDataSeriesContainer( DiagramHelper::getChartTypeByIndex( xDiagram, nChartTypeIndex ) ); if( xDataSeriesContainer.is() ) { uno::Sequence< uno::Reference< XDataSeries > > aDataSeriesSeq( xDataSeriesContainer->getDataSeries() ); diff --git a/chart2/source/tools/RegressionCurveHelper.cxx b/chart2/source/tools/RegressionCurveHelper.cxx index 1df7ac904da8..c7e231a614c2 100644 --- a/chart2/source/tools/RegressionCurveHelper.cxx +++ b/chart2/source/tools/RegressionCurveHelper.cxx @@ -28,6 +28,7 @@ #include #include "RegressionCurveModel.hxx" #include +#include #include #include #include diff --git a/chart2/source/tools/ThreeDHelper.cxx b/chart2/source/tools/ThreeDHelper.cxx index 0903459606bb..361b2f0b17a6 100644 --- a/chart2/source/tools/ThreeDHelper.cxx +++ b/chart2/source/tools/ThreeDHelper.cxx @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include diff --git a/chart2/source/view/diagram/VDiagram.cxx b/chart2/source/view/diagram/VDiagram.cxx index 8deea35e2d48..6033760e8499 100644 --- a/chart2/source/view/diagram/VDiagram.cxx +++ b/chart2/source/view/diagram/VDiagram.cxx @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index d1ec2a672571..de1dc6db0fa0 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include "VTitle.hxx" @@ -3002,7 +3003,7 @@ bool ChartView::createAxisTitleShapes2D( CreateShapeParam2D& rParam, const css:: { uno::Reference xDiagram = mrChartModel.getFirstDiagram(); - Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ); + rtl::Reference< ChartType > xChartType( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ); sal_Int32 nDimension = DiagramHelper::getDimension( xDiagram ); if( ChartTypeHelper::isSupportingMainAxis( xChartType, nDimension, 0 ) ) diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist index e470cb543941..6f3bbedafa9c 100644 --- a/solenv/clang-format/excludelist +++ b/solenv/clang-format/excludelist @@ -1013,6 +1013,7 @@ chart2/source/inc/BaseCoordinateSystem.hxx chart2/source/inc/CachedDataSequence.hxx chart2/source/inc/CharacterProperties.hxx chart2/source/inc/ChartModelHelper.hxx +chart2/source/inc/ChartType.hxx chart2/source/inc/ChartTypeHelper.hxx chart2/source/inc/ChartTypeTemplate.hxx chart2/source/inc/CloneHelper.hxx @@ -1126,7 +1127,6 @@ chart2/source/model/template/BubbleDataInterpreter.hxx chart2/source/model/template/CandleStickChartType.cxx chart2/source/model/template/CandleStickChartType.hxx chart2/source/model/template/ChartType.cxx -chart2/source/model/template/ChartType.hxx chart2/source/model/template/ChartTypeManager.cxx chart2/source/model/template/ChartTypeTemplate.cxx chart2/source/model/template/ColumnChartType.cxx -- cgit