diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-02-07 12:32:49 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-02-07 18:28:05 +0100 |
commit | d9ff5556e7b24c7548a476862726b4bd54425047 (patch) | |
tree | 9ff52d13e4a937e2eaccf45b46f0e9a2fde0f12f /chart2/source/model/template | |
parent | 3ff7f9e50bda9e6416d0df5f3b935aae34efbb8f (diff) |
use more concrete types in chart2, DataSeries
Change-Id: If92f6ff6f90d53a9dc6211fd9f071d4d3fce2997
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129535
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2/source/model/template')
24 files changed, 164 insertions, 273 deletions
diff --git a/chart2/source/model/template/AreaChartTypeTemplate.cxx b/chart2/source/model/template/AreaChartTypeTemplate.cxx index 1812671f962b..c7dc60003099 100644 --- a/chart2/source/model/template/AreaChartTypeTemplate.cxx +++ b/chart2/source/model/template/AreaChartTypeTemplate.cxx @@ -180,7 +180,7 @@ StackMode AreaChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex */ ) // ____ ChartTypeTemplate ____ void AreaChartTypeTemplate::applyStyle( - const Reference< chart2::XDataSeries >& xSeries, + const rtl::Reference< DataSeries >& xSeries, ::sal_Int32 nChartTypeIndex, ::sal_Int32 nSeriesIndex, ::sal_Int32 nSeriesCount ) diff --git a/chart2/source/model/template/AreaChartTypeTemplate.hxx b/chart2/source/model/template/AreaChartTypeTemplate.hxx index fe2d679ec81c..e3fec3b1e457 100644 --- a/chart2/source/model/template/AreaChartTypeTemplate.hxx +++ b/chart2/source/model/template/AreaChartTypeTemplate.hxx @@ -60,7 +60,7 @@ protected: getChartTypeForNewSeries( const std::vector< rtl::Reference< ::chart::ChartType > >& aFormerlyUsedChartTypes ) override; virtual void applyStyle( - const css::uno::Reference< css::chart2::XDataSeries >& xSeries, + const rtl::Reference< ::chart::DataSeries >& xSeries, ::sal_Int32 nChartTypeGroupIndex, ::sal_Int32 nSeriesIndex, ::sal_Int32 nSeriesCount ) override; diff --git a/chart2/source/model/template/BarChartTypeTemplate.cxx b/chart2/source/model/template/BarChartTypeTemplate.cxx index 5e9ccd0c84d1..2eef1293665b 100644 --- a/chart2/source/model/template/BarChartTypeTemplate.cxx +++ b/chart2/source/model/template/BarChartTypeTemplate.cxx @@ -239,7 +239,7 @@ Reference< beans::XPropertySetInfo > SAL_CALL BarChartTypeTemplate::getPropertyS } void BarChartTypeTemplate::applyStyle( - const Reference< chart2::XDataSeries >& xSeries, + const rtl::Reference< DataSeries >& xSeries, ::sal_Int32 nChartTypeIndex, ::sal_Int32 nSeriesIndex, ::sal_Int32 nSeriesCount ) diff --git a/chart2/source/model/template/BarChartTypeTemplate.hxx b/chart2/source/model/template/BarChartTypeTemplate.hxx index 6c5f66bd9cc3..c17c5148c3c2 100644 --- a/chart2/source/model/template/BarChartTypeTemplate.hxx +++ b/chart2/source/model/template/BarChartTypeTemplate.hxx @@ -70,7 +70,7 @@ protected: getChartTypeForNewSeries( const std::vector< rtl::Reference< ::chart::ChartType > >& aFormerlyUsedChartTypes ) override; virtual void applyStyle( - const css::uno::Reference< css::chart2::XDataSeries >& xSeries, + const rtl::Reference< ::chart::DataSeries >& xSeries, ::sal_Int32 nChartTypeGroupIndex, ::sal_Int32 nSeriesIndex, ::sal_Int32 nSeriesCount ) override; diff --git a/chart2/source/model/template/BubbleChartTypeTemplate.cxx b/chart2/source/model/template/BubbleChartTypeTemplate.cxx index 4edd89886b0d..93bb598b0471 100644 --- a/chart2/source/model/template/BubbleChartTypeTemplate.cxx +++ b/chart2/source/model/template/BubbleChartTypeTemplate.cxx @@ -21,6 +21,7 @@ #include "BubbleChartType.hxx" #include "BubbleDataInterpreter.hxx" #include <servicenames_charttypes.hxx> +#include <DataSeries.hxx> #include <DataSeriesHelper.hxx> #include <com/sun/star/chart2/XChartType.hpp> #include <com/sun/star/drawing/LineStyle.hpp> @@ -142,7 +143,7 @@ StackMode BubbleChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex */ } void BubbleChartTypeTemplate::applyStyle( - const Reference< chart2::XDataSeries >& xSeries, + const rtl::Reference< DataSeries >& xSeries, ::sal_Int32 nChartTypeIndex, ::sal_Int32 nSeriesIndex, ::sal_Int32 nSeriesCount ) diff --git a/chart2/source/model/template/BubbleChartTypeTemplate.hxx b/chart2/source/model/template/BubbleChartTypeTemplate.hxx index 696bd36c60a8..0649a57bb0b5 100644 --- a/chart2/source/model/template/BubbleChartTypeTemplate.hxx +++ b/chart2/source/model/template/BubbleChartTypeTemplate.hxx @@ -58,7 +58,7 @@ protected: rtl::Reference< ::chart::ChartType > >& aFormerlyUsedChartTypes ) override; virtual rtl::Reference< ::chart::DataInterpreter > getDataInterpreter() override; virtual void applyStyle( - const css::uno::Reference< css::chart2::XDataSeries >& xSeries, + const rtl::Reference< ::chart::DataSeries >& xSeries, ::sal_Int32 nChartTypeGroupIndex, ::sal_Int32 nSeriesIndex, ::sal_Int32 nSeriesCount ) override; diff --git a/chart2/source/model/template/BubbleDataInterpreter.cxx b/chart2/source/model/template/BubbleDataInterpreter.cxx index b15e3eb80b73..5ef65c550a38 100644 --- a/chart2/source/model/template/BubbleDataInterpreter.cxx +++ b/chart2/source/model/template/BubbleDataInterpreter.cxx @@ -117,7 +117,7 @@ InterpretedData BubbleDataInterpreter::interpretDataSource( // create DataSeries sal_Int32 nSeriesIndex = 0; - vector< Reference< XDataSeries > > aSeriesVec; + vector< rtl::Reference< DataSeries > > aSeriesVec; aSeriesVec.reserve( aSizeValuesVector.size()); Reference< data::XLabeledDataSequence > xClonedXValues = xValuesX; @@ -147,7 +147,7 @@ InterpretedData BubbleDataInterpreter::interpretDataSource( aSeriesVec.push_back( xSeries ); } - return { { comphelper::containerToSequence(aSeriesVec) }, xCategories }; + return { { aSeriesVec }, xCategories }; } InterpretedData BubbleDataInterpreter::reinterpretDataSeries( @@ -156,21 +156,20 @@ InterpretedData BubbleDataInterpreter::reinterpretDataSeries( InterpretedData aResult( aInterpretedData ); sal_Int32 i=0; - Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series )); - const sal_Int32 nCount = aSeries.getLength(); + std::vector< rtl::Reference< DataSeries > > aSeries( FlattenSequence( aInterpretedData.Series )); + const sal_Int32 nCount = aSeries.size(); for( ; i<nCount; ++i ) { try { - Reference< data::XDataSource > xSeriesSource( aSeries[i], uno::UNO_QUERY_THROW ); - Sequence< Reference< data::XLabeledDataSequence > > aNewSequences; + std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aNewSequences; uno::Reference< chart2::data::XLabeledDataSequence > xValuesSize( - DataSeriesHelper::getDataSequenceByRole( xSeriesSource, "values-size" )); + DataSeriesHelper::getDataSequenceByRole( aSeries[i], "values-size" )); uno::Reference< chart2::data::XLabeledDataSequence > xValuesY( - DataSeriesHelper::getDataSequenceByRole( xSeriesSource, "values-y" )); + DataSeriesHelper::getDataSequenceByRole( aSeries[i], "values-y" )); uno::Reference< chart2::data::XLabeledDataSequence > xValuesX( - DataSeriesHelper::getDataSequenceByRole( xSeriesSource, "values-x" )); + DataSeriesHelper::getDataSequenceByRole( aSeries[i], "values-x" )); if( ! xValuesX.is() || ! xValuesY.is() || @@ -178,7 +177,7 @@ InterpretedData BubbleDataInterpreter::reinterpretDataSeries( { vector< uno::Reference< chart2::data::XLabeledDataSequence > > aValueSeqVec( DataSeriesHelper::getAllDataSequencesByRole( - xSeriesSource->getDataSequences(), "values" )); + aSeries[i]->getDataSequences2(), "values" )); if( xValuesX.is()) aValueSeqVec.erase( find( aValueSeqVec.begin(), aValueSeqVec.end(), xValuesX )); if( xValuesY.is()) @@ -231,8 +230,8 @@ InterpretedData BubbleDataInterpreter::reinterpretDataSeries( } } - const Sequence< Reference< data::XLabeledDataSequence > > aSeqs( xSeriesSource->getDataSequences()); - if( aSeqs.getLength() != aNewSequences.getLength() ) + const std::vector< uno::Reference< data::XLabeledDataSequence > > & aSeqs = aSeries[i]->getDataSequences2(); + if( aSeqs.size() != aNewSequences.size() ) { #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG for( auto const & j : aSeqs ) @@ -240,8 +239,7 @@ InterpretedData BubbleDataInterpreter::reinterpretDataSeries( assert( (j == xValuesY || j == xValuesX || j == xValuesSize) && "All sequences should be used" ); } #endif - Reference< data::XDataSink > xSink( xSeriesSource, uno::UNO_QUERY_THROW ); - xSink->setData( aNewSequences ); + aSeries[i]->setData( aNewSequences ); } } catch( const uno::Exception & ) @@ -256,14 +254,12 @@ InterpretedData BubbleDataInterpreter::reinterpretDataSeries( bool BubbleDataInterpreter::isDataCompatible( const InterpretedData& aInterpretedData ) { - const Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series )); - for( Reference< XDataSeries > const & dataSeries : aSeries ) + const std::vector< rtl::Reference< DataSeries > > aSeries( FlattenSequence( aInterpretedData.Series )); + for( rtl::Reference< DataSeries > const & dataSeries : aSeries ) { try { - Reference< data::XDataSource > xSrc( dataSeries, uno::UNO_QUERY_THROW ); - Sequence< Reference< data::XLabeledDataSequence > > aSeq( xSrc->getDataSequences()); - if( aSeq.getLength() != 3 ) + if( dataSeries->getDataSequences2().size() != 3 ) return false; } catch( const uno::Exception & ) diff --git a/chart2/source/model/template/ChartTypeTemplate.cxx b/chart2/source/model/template/ChartTypeTemplate.cxx index 190741bb01a3..126c902728b3 100644 --- a/chart2/source/model/template/ChartTypeTemplate.cxx +++ b/chart2/source/model/template/ChartTypeTemplate.cxx @@ -157,11 +157,10 @@ rtl::Reference< Diagram > ChartTypeTemplate::createDiagramByDataSource( rtl::Reference< DataInterpreter > xInterpreter( getDataInterpreter()); InterpretedData aData( xInterpreter->interpretDataSource( - xDataSource, aArguments, Sequence< Reference< XDataSeries > >() )); + xDataSource, aArguments, {} )); - const Sequence< Sequence< Reference< XDataSeries > > > aSeries( aData.Series ); sal_Int32 nCount = 0; - for( auto const & i : aSeries ) + for( auto const & i : aData.Series ) for( auto const & j : i ) lcl_applyDefaultStyle( j, nCount++, xDia ); @@ -188,10 +187,10 @@ void ChartTypeTemplate::changeDiagram( const rtl::Reference< Diagram >& xDiagram try { - Sequence< Sequence< Reference< XDataSeries > > > aSeriesSeq( - DiagramHelper::getDataSeriesGroups( xDiagram )); - Sequence< Reference< XDataSeries > > aFlatSeriesSeq( FlattenSequence( aSeriesSeq )); - const sal_Int32 nFormerSeriesCount = aFlatSeriesSeq.getLength(); + std::vector< std::vector< rtl::Reference< DataSeries > > > aSeriesSeq = + DiagramHelper::getDataSeriesGroups( xDiagram ); + std::vector< rtl::Reference< DataSeries > > aFlatSeriesSeq( FlattenSequence( aSeriesSeq )); + const sal_Int32 nFormerSeriesCount = aFlatSeriesSeq.size(); // chart-type specific interpretation of existing data series rtl::Reference< DataInterpreter > xInterpreter( getDataInterpreter()); @@ -265,16 +264,14 @@ void ChartTypeTemplate::changeDiagramData( xInterpreter->interpretDataSource( xDataSource, aArguments, aFlatSeriesSeq ); // data series - Sequence< Sequence< Reference< XDataSeries > > > aSeriesSeq( aData.Series ); - sal_Int32 i, j, nIndex = 0; - for( i=0; i<aSeriesSeq.getLength(); ++i ) - for( j=0; j<aSeriesSeq[i].getLength(); ++j, ++nIndex ) + for( i=0; i<static_cast<sal_Int32>(aData.Series.size()); ++i ) + for( j=0; j<static_cast<sal_Int32>(aData.Series[i].size()); ++j, ++nIndex ) { if( nIndex >= nFormerSeriesCount ) { - lcl_applyDefaultStyle( aSeriesSeq[i][j], nIndex, xDiagram ); - applyStyle( aSeriesSeq[i][j], i, j, aSeriesSeq[i].getLength() ); + lcl_applyDefaultStyle( aData.Series[i][j], nIndex, xDiagram ); + applyStyle( aData.Series[i][j], i, j, aData.Series[i].size() ); } } @@ -283,10 +280,10 @@ void ChartTypeTemplate::changeDiagramData( std::vector< rtl::Reference< ChartType > > aChartTypes = DiagramHelper::getChartTypesFromDiagram( xDiagram ); - sal_Int32 nMax = std::min( static_cast<sal_Int32>(aChartTypes.size()), aSeriesSeq.getLength()); + sal_Int32 nMax = std::min( aChartTypes.size(), aData.Series.size()); for( i=0; i<nMax; ++i ) { - aChartTypes[i]->setDataSeries( aSeriesSeq[i] ); + aChartTypes[i]->setDataSeries( aData.Series[i] ); } } catch( const uno::Exception & ) @@ -359,14 +356,13 @@ rtl::Reference< DataInterpreter > ChartTypeTemplate::getDataInterpreter() } void ChartTypeTemplate::applyStyle( - const Reference< chart2::XDataSeries >& xSeries, + const rtl::Reference< DataSeries >& xSeries, ::sal_Int32 nChartTypeIndex, ::sal_Int32 /* nSeriesIndex */, ::sal_Int32 /* nSeriesCount */ ) { // sset stacking mode - Reference< beans::XPropertySet > xSeriesProp( xSeries, uno::UNO_QUERY ); - if( !xSeriesProp.is()) + if( !xSeries.is()) return; try @@ -379,16 +375,16 @@ void ChartTypeTemplate::applyStyle( : (eStackMode == StackMode::ZStacked ) ? chart2::StackingDirection_Z_STACKING : chart2::StackingDirection_NO_STACKING ); - xSeriesProp->setPropertyValue( "StackingDirection", aPropValue ); + xSeries->setPropertyValue( "StackingDirection", aPropValue ); //ensure valid label placement { uno::Sequence < sal_Int32 > aAvailablePlacements( ChartTypeHelper::getSupportedLabelPlacements( getChartTypeForIndex( nChartTypeIndex ), isSwapXAndY(), xSeries ) ); - lcl_ensureCorrectLabelPlacement( xSeriesProp, aAvailablePlacements ); + lcl_ensureCorrectLabelPlacement( xSeries, aAvailablePlacements ); uno::Sequence< sal_Int32 > aAttributedDataPointIndexList; - if( xSeriesProp->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList ) + if( xSeries->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList ) for(sal_Int32 nN=aAttributedDataPointIndexList.getLength();nN--;) lcl_ensureCorrectLabelPlacement( xSeries->getDataPointByIndex(aAttributedDataPointIndexList[nN]), aAvailablePlacements ); } @@ -402,11 +398,11 @@ void ChartTypeTemplate::applyStyle( void ChartTypeTemplate::applyStyles( const rtl::Reference< ::chart::Diagram >& xDiagram ) { // apply chart-type specific styles, like "symbols on" for example - Sequence< Sequence< Reference< XDataSeries > > > aNewSeriesSeq( + std::vector< std::vector< rtl::Reference< DataSeries > > > aNewSeriesSeq( DiagramHelper::getDataSeriesGroups( xDiagram )); - for( sal_Int32 i=0; i<aNewSeriesSeq.getLength(); ++i ) + for( sal_Int32 i=0; i<static_cast<sal_Int32>(aNewSeriesSeq.size()); ++i ) { - const sal_Int32 nNumSeries = aNewSeriesSeq[i].getLength(); + const sal_Int32 nNumSeries = aNewSeriesSeq[i].size(); for( sal_Int32 j=0; j<nNumSeries; ++j ) applyStyle( aNewSeriesSeq[i][j], i, j, nNumSeries ); } @@ -714,7 +710,7 @@ sal_Int32 ChartTypeTemplate::getAxisCountByDimension( sal_Int32 nDimension ) void ChartTypeTemplate::FillDiagram( const rtl::Reference< ::chart::Diagram >& xDiagram, - const Sequence< Sequence< Reference< XDataSeries > > >& aSeriesSeq, + const std::vector< std::vector< rtl::Reference< DataSeries > > >& aSeriesSeq, const uno::Reference< chart2::data::XLabeledDataSequence >& xCategories, const std::vector< rtl::Reference< ChartType > >& aOldChartTypesSeq ) { @@ -740,7 +736,7 @@ void ChartTypeTemplate::FillDiagram( } void ChartTypeTemplate::createChartTypes( - const Sequence< Sequence< Reference< XDataSeries > > > & aSeriesSeq, + const std::vector< std::vector< rtl::Reference< DataSeries > > > & aSeriesSeq, const std::vector< rtl::Reference< BaseCoordinateSystem > > & rCoordSys, const std::vector< rtl::Reference< ChartType > >& aOldChartTypesSeq ) { @@ -751,7 +747,7 @@ void ChartTypeTemplate::createChartTypes( { sal_Int32 nCooSysIdx=0; rtl::Reference< ChartType > xCT; - if( !aSeriesSeq.hasElements() ) + if( aSeriesSeq.empty() ) { // we need a new chart type xCT = getChartTypeForNewSeries( aOldChartTypesSeq ); @@ -759,7 +755,7 @@ void ChartTypeTemplate::createChartTypes( } else { - for( sal_Int32 nSeriesIdx=0; nSeriesIdx<aSeriesSeq.getLength(); ++nSeriesIdx ) + for( sal_Int32 nSeriesIdx=0; nSeriesIdx<static_cast<sal_Int32>(aSeriesSeq.size()); ++nSeriesIdx ) { if( nSeriesIdx == nCooSysIdx ) { @@ -780,12 +776,12 @@ void ChartTypeTemplate::createChartTypes( { // reuse existing chart type OSL_ASSERT( xCT.is()); - Sequence< Reference< XDataSeries > > aNewSeriesSeq( xCT->getDataSeries()); - sal_Int32 nNewStartIndex = aNewSeriesSeq.getLength(); - aNewSeriesSeq.realloc( nNewStartIndex + aSeriesSeq[nSeriesIdx].getLength() ); + std::vector< rtl::Reference< DataSeries > > aNewSeriesSeq = xCT->getDataSeries2(); + sal_Int32 nNewStartIndex = aNewSeriesSeq.size(); + aNewSeriesSeq.resize( nNewStartIndex + aSeriesSeq[nSeriesIdx].size() ); std::copy( aSeriesSeq[nSeriesIdx].begin(), aSeriesSeq[nSeriesIdx].end(), - aNewSeriesSeq.getArray() + nNewStartIndex ); + aNewSeriesSeq.begin() + nNewStartIndex ); xCT->setDataSeries( aNewSeriesSeq ); } diff --git a/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx b/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx index 03a5f07f0fbe..460cd2a583c8 100644 --- a/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx +++ b/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx @@ -24,6 +24,7 @@ #include <BaseCoordinateSystem.hxx> #include <Diagram.hxx> #include <DiagramHelper.hxx> +#include <DataSeries.hxx> #include <DataSeriesHelper.hxx> #include <servicenames_charttypes.hxx> #include "ColumnLineDataInterpreter.hxx" @@ -163,7 +164,7 @@ uno::Reference< beans::XPropertySetInfo > SAL_CALL ColumnLineChartTypeTemplate:: } void ColumnLineChartTypeTemplate::createChartTypes( - const Sequence< Sequence< Reference< XDataSeries > > > & aSeriesSeq, + const std::vector< std::vector< rtl::Reference< DataSeries > > > & aSeriesSeq, const std::vector< rtl::Reference< BaseCoordinateSystem > > & rCoordSys, const std::vector< rtl::Reference< ChartType > >& aOldChartTypesSeq ) { @@ -172,8 +173,8 @@ void ColumnLineChartTypeTemplate::createChartTypes( try { - const Sequence< Reference< XDataSeries > > aFlatSeriesSeq( FlattenSequence( aSeriesSeq )); - sal_Int32 nNumberOfSeries = aFlatSeriesSeq.getLength(); + const std::vector< rtl::Reference< DataSeries > > aFlatSeriesSeq( FlattenSequence( aSeriesSeq )); + sal_Int32 nNumberOfSeries = aFlatSeriesSeq.size(); sal_Int32 nNumberOfLines = 0; sal_Int32 nNumberOfColumns = 0; @@ -233,7 +234,7 @@ void ColumnLineChartTypeTemplate::createChartTypes( } void ColumnLineChartTypeTemplate::applyStyle( - const Reference< chart2::XDataSeries >& xSeries, + const rtl::Reference< DataSeries >& xSeries, ::sal_Int32 nChartTypeIndex, ::sal_Int32 nSeriesIndex, ::sal_Int32 nSeriesCount ) @@ -246,13 +247,9 @@ void ColumnLineChartTypeTemplate::applyStyle( } else if( nChartTypeIndex==1 ) // lines { - Reference< beans::XPropertySet > xProp( xSeries, uno::UNO_QUERY ); - if( xProp.is() ) - { - DataSeriesHelper::switchLinesOnOrOff( xProp, true ); - DataSeriesHelper::switchSymbolsOnOrOff( xProp, false, nSeriesIndex ); - DataSeriesHelper::makeLinesThickOrThin( xProp, true ); - } + DataSeriesHelper::switchLinesOnOrOff( xSeries, true ); + DataSeriesHelper::switchSymbolsOnOrOff( xSeries, false, nSeriesIndex ); + DataSeriesHelper::makeLinesThickOrThin( xSeries, true ); } } diff --git a/chart2/source/model/template/ColumnLineChartTypeTemplate.hxx b/chart2/source/model/template/ColumnLineChartTypeTemplate.hxx index 167c63cc11fe..e28ed68d9566 100644 --- a/chart2/source/model/template/ColumnLineChartTypeTemplate.hxx +++ b/chart2/source/model/template/ColumnLineChartTypeTemplate.hxx @@ -63,7 +63,7 @@ protected: getChartTypeForNewSeries( const std::vector< rtl::Reference< ::chart::ChartType > >& aFormerlyUsedChartTypes ) override; virtual void applyStyle( - const css::uno::Reference< css::chart2::XDataSeries >& xSeries, + const rtl::Reference< ::chart::DataSeries >& xSeries, ::sal_Int32 nChartTypeGroupIndex, ::sal_Int32 nSeriesIndex, ::sal_Int32 nSeriesCount ) override; @@ -71,10 +71,10 @@ protected: // ____ ChartTypeTemplate ____ virtual void createChartTypes( - const css::uno::Sequence< - css::uno::Sequence< - css::uno::Reference< - css::chart2::XDataSeries > > > & aSeriesSeq, + const std::vector< + std::vector< + rtl::Reference< + ::chart::DataSeries > > > & aSeriesSeq, const std::vector< rtl::Reference< ::chart::BaseCoordinateSystem > > & rCoordSys, diff --git a/chart2/source/model/template/ColumnLineDataInterpreter.cxx b/chart2/source/model/template/ColumnLineDataInterpreter.cxx index c75c7818fd0b..546c65307b36 100644 --- a/chart2/source/model/template/ColumnLineDataInterpreter.cxx +++ b/chart2/source/model/template/ColumnLineDataInterpreter.cxx @@ -19,6 +19,7 @@ #include "ColumnLineDataInterpreter.hxx" #include <LabeledDataSequence.hxx> +#include <DataSeries.hxx> #include <osl/diagnose.h> #include <algorithm> @@ -51,25 +52,24 @@ InterpretedData ColumnLineDataInterpreter::interpretDataSource( InterpretedData aResult( DataInterpreter::interpretDataSource( xSource, aArguments, aSeriesToReUse )); // the base class should return one group - OSL_ASSERT( aResult.Series.getLength() == 1 ); - if( aResult.Series.getLength() == 1 ) + OSL_ASSERT( aResult.Series.size() == 1 ); + if( aResult.Series.size() == 1 ) { - sal_Int32 nNumberOfSeries = aResult.Series[0].getLength(); + sal_Int32 nNumberOfSeries = aResult.Series[0].size(); // if we have more than one series put the last nNumOfLines ones into a new group if( nNumberOfSeries > 1 && m_nNumberOfLines > 0 ) { sal_Int32 nNumOfLines = std::min( m_nNumberOfLines, nNumberOfSeries - 1 ); - aResult.Series.realloc(2); - auto pSeries = aResult.Series.getArray(); + aResult.Series.resize(2); - Sequence< Reference< XDataSeries > > & rColumnDataSeries = pSeries[0]; - Sequence< Reference< XDataSeries > > & rLineDataSeries = pSeries[1]; - rLineDataSeries.realloc( nNumOfLines ); + std::vector< rtl::Reference< DataSeries > > & rColumnDataSeries = aResult.Series[0]; + std::vector< rtl::Reference< DataSeries > > & rLineDataSeries = aResult.Series[1]; + rLineDataSeries.resize( nNumOfLines ); std::copy( std::cbegin(rColumnDataSeries) + nNumberOfSeries - nNumOfLines, std::cbegin(rColumnDataSeries) + nNumberOfSeries, - rLineDataSeries.getArray() ); - rColumnDataSeries.realloc( nNumberOfSeries - nNumOfLines ); + rLineDataSeries.begin() ); + rColumnDataSeries.resize( nNumberOfSeries - nNumOfLines ); } } diff --git a/chart2/source/model/template/DataInterpreter.cxx b/chart2/source/model/template/DataInterpreter.cxx index 2496147cce57..b374cae93cc6 100644 --- a/chart2/source/model/template/DataInterpreter.cxx +++ b/chart2/source/model/template/DataInterpreter.cxx @@ -59,78 +59,6 @@ DataInterpreter::~DataInterpreter() InterpretedData DataInterpreter::interpretDataSource( const Reference< data::XDataSource >& xSource, const Sequence< beans::PropertyValue >& aArguments, - const Sequence< Reference< XDataSeries > >& aSeriesToReUse ) -{ - if( ! xSource.is()) - return InterpretedData(); - -#ifdef DEBUG_CHART2_TEMPLATE - lcl_ShowDataSource( xSource ); -#endif - - std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aData = getDataSequences(xSource); - - uno::Reference< chart2::data::XLabeledDataSequence > xCategories; - vector< Reference< data::XLabeledDataSequence > > aSequencesVec; - - // check if we should use categories - - bool bHasCategories( HasCategories( aArguments, aData )); - - // parse data - bool bCategoriesUsed = false; - for( uno::Reference< chart2::data::XLabeledDataSequence > const & labeledData : aData ) - { - try - { - if( bHasCategories && ! bCategoriesUsed ) - { - xCategories = labeledData; - if( xCategories.is()) - SetRole( xCategories->getValues(), "categories"); - bCategoriesUsed = true; - } - else - { - aSequencesVec.push_back( labeledData ); - if( labeledData.is()) - SetRole( labeledData->getValues(), "values-y"); - } - } - catch( const uno::Exception & ) - { - DBG_UNHANDLED_EXCEPTION("chart2"); - } - } - - // create DataSeries - sal_Int32 nSeriesIndex = 0; - vector< Reference< XDataSeries > > aSeriesVec; - aSeriesVec.reserve( aSequencesVec.size()); - - for (auto const& elem : aSequencesVec) - { - Sequence< Reference< data::XLabeledDataSequence > > aNewData( &elem, 1 ); - Reference< XDataSeries > xSeries; - if( nSeriesIndex < aSeriesToReUse.getLength()) - xSeries.set( aSeriesToReUse[nSeriesIndex] ); - else - xSeries.set( new DataSeries ); - OSL_ASSERT( xSeries.is() ); - Reference< data::XDataSink > xSink( xSeries, uno::UNO_QUERY ); - OSL_ASSERT( xSink.is() ); - xSink->setData( aNewData ); - - aSeriesVec.push_back( xSeries ); - ++nSeriesIndex; - } - - return { { comphelper::containerToSequence( aSeriesVec ) }, xCategories }; -} - -InterpretedData DataInterpreter::interpretDataSource( - const Reference< data::XDataSource >& xSource, - const Sequence< beans::PropertyValue >& aArguments, const std::vector< rtl::Reference< DataSeries > >& aSeriesToReUse ) { if( ! xSource.is()) @@ -177,7 +105,7 @@ InterpretedData DataInterpreter::interpretDataSource( // create DataSeries sal_Int32 nSeriesIndex = 0; - vector< Reference< XDataSeries > > aSeriesVec; + vector< rtl::Reference< DataSeries > > aSeriesVec; aSeriesVec.reserve( aSequencesVec.size()); for (auto const& elem : aSequencesVec) @@ -195,7 +123,7 @@ InterpretedData DataInterpreter::interpretDataSource( ++nSeriesIndex; } - return { { comphelper::containerToSequence( aSeriesVec ) }, xCategories }; + return { { aSeriesVec }, xCategories }; } InterpretedData DataInterpreter::reinterpretDataSeries( @@ -204,23 +132,22 @@ InterpretedData DataInterpreter::reinterpretDataSeries( InterpretedData aResult( aInterpretedData ); sal_Int32 i=0; - Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series )); - const sal_Int32 nCount = aSeries.getLength(); + std::vector< rtl::Reference< DataSeries > > aSeries( FlattenSequence( aInterpretedData.Series )); + const sal_Int32 nCount = aSeries.size(); for( ; i<nCount; ++i ) { try { - Reference< data::XDataSource > xSeriesSource( aSeries[i], uno::UNO_QUERY_THROW ); - Sequence< Reference< data::XLabeledDataSequence > > aNewSequences; + std::vector< uno::Reference< data::XLabeledDataSequence > > aNewSequences; // values-y - Reference< data::XLabeledDataSequence > xValuesY( - DataSeriesHelper::getDataSequenceByRole( xSeriesSource, "values-y" )); + uno::Reference< data::XLabeledDataSequence > xValuesY = + DataSeriesHelper::getDataSequenceByRole( aSeries[i], "values-y" ); // re-use values-... as values-y if( ! xValuesY.is()) { - xValuesY.set( - DataSeriesHelper::getDataSequenceByRole( xSeriesSource, "values", true )); + xValuesY = + DataSeriesHelper::getDataSequenceByRole( aSeries[i], "values", true ); if( xValuesY.is()) SetRole( xValuesY->getValues(), "values-y"); } @@ -229,8 +156,8 @@ InterpretedData DataInterpreter::reinterpretDataSeries( aNewSequences = { xValuesY }; } - Sequence< Reference< data::XLabeledDataSequence > > aSeqs( xSeriesSource->getDataSequences()); - if( aSeqs.getLength() != aNewSequences.getLength() ) + const std::vector< uno::Reference< data::XLabeledDataSequence > > & aSeqs = aSeries[i]->getDataSequences2(); + if( aSeqs.size() != aNewSequences.size() ) { #ifdef DEBUG_CHART2_TEMPLATE sal_Int32 j=0; @@ -239,8 +166,7 @@ InterpretedData DataInterpreter::reinterpretDataSeries( assert( aSeqs[j] == xValuesY && "All sequences should be used" ); } #endif - Reference< data::XDataSink > xSink( xSeriesSource, uno::UNO_QUERY_THROW ); - xSink->setData( aNewSequences ); + aSeries[i]->setData( aNewSequences ); } } catch( const uno::Exception & ) @@ -256,14 +182,12 @@ InterpretedData DataInterpreter::reinterpretDataSeries( bool DataInterpreter::isDataCompatible( const InterpretedData& aInterpretedData ) { - const Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series )); - for( Reference< XDataSeries > const & i : aSeries ) + const std::vector< rtl::Reference< DataSeries > > aSeries( FlattenSequence( aInterpretedData.Series )); + for( rtl::Reference< DataSeries > const & i : aSeries ) { try { - Reference< data::XDataSource > xSrc( i, uno::UNO_QUERY_THROW ); - Sequence< Reference< data::XLabeledDataSequence > > aSeq( xSrc->getDataSequences()); - if( aSeq.getLength() != 1 ) + if( i->getDataSequences2().size() != 1 ) return false; } catch( const uno::Exception & ) @@ -332,23 +256,20 @@ rtl::Reference< DataSource > DataInterpreter::mergeInterpretedData( const InterpretedData& aInterpretedData ) { vector< Reference< data::XLabeledDataSequence > > aResultVec; - aResultVec.reserve( aInterpretedData.Series.getLength() + + aResultVec.reserve( aInterpretedData.Series.size() + 1 // categories ); if( aInterpretedData.Categories.is()) aResultVec.push_back( aInterpretedData.Categories ); - const Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series )); - for( Reference< XDataSeries > const & dataSeries : aSeries ) + const std::vector< rtl::Reference< DataSeries > > aSeries = FlattenSequence( aInterpretedData.Series ); + for( rtl::Reference< DataSeries > const & dataSeries : aSeries ) { try { - Reference< data::XDataSource > xSrc( dataSeries, uno::UNO_QUERY_THROW ); - const Sequence< Reference< data::XLabeledDataSequence > > aSeq( xSrc->getDataSequences()); - // add all sequences of data series - for( Reference< data::XLabeledDataSequence > const & xAdd : aSeq ) + for( uno::Reference< data::XLabeledDataSequence > const & xAdd : dataSeries->getDataSequences2() ) { // only add if sequence is not yet in the result if( none_of( aResultVec.begin(), aResultVec.end(), diff --git a/chart2/source/model/template/LineChartTypeTemplate.cxx b/chart2/source/model/template/LineChartTypeTemplate.cxx index 25d5226664f2..8c80699a4d21 100644 --- a/chart2/source/model/template/LineChartTypeTemplate.cxx +++ b/chart2/source/model/template/LineChartTypeTemplate.cxx @@ -337,7 +337,7 @@ rtl::Reference< ChartType > LineChartTypeTemplate::getChartTypeForNewSeries( } void LineChartTypeTemplate::applyStyle( - const Reference< chart2::XDataSeries >& xSeries, + const rtl::Reference< DataSeries >& xSeries, ::sal_Int32 nChartTypeIndex, ::sal_Int32 nSeriesIndex, ::sal_Int32 nSeriesCount ) @@ -346,11 +346,9 @@ void LineChartTypeTemplate::applyStyle( try { - Reference< beans::XPropertySet > xProp( xSeries, uno::UNO_QUERY_THROW ); - - DataSeriesHelper::switchSymbolsOnOrOff( xProp, m_bHasSymbols, nSeriesIndex ); - DataSeriesHelper::switchLinesOnOrOff( xProp, m_bHasLines ); - DataSeriesHelper::makeLinesThickOrThin( xProp, m_nDim==2 ); + DataSeriesHelper::switchSymbolsOnOrOff( xSeries, m_bHasSymbols, nSeriesIndex ); + DataSeriesHelper::switchLinesOnOrOff( xSeries, m_bHasLines ); + DataSeriesHelper::makeLinesThickOrThin( xSeries, m_nDim==2 ); } catch( const uno::Exception & ) { diff --git a/chart2/source/model/template/LineChartTypeTemplate.hxx b/chart2/source/model/template/LineChartTypeTemplate.hxx index 55d0a23c0fb3..7dc454c1e714 100644 --- a/chart2/source/model/template/LineChartTypeTemplate.hxx +++ b/chart2/source/model/template/LineChartTypeTemplate.hxx @@ -64,7 +64,7 @@ protected: getChartTypeForNewSeries( const std::vector< rtl::Reference< ::chart::ChartType > >& aFormerlyUsedChartTypes ) override; virtual void applyStyle( - const css::uno::Reference< css::chart2::XDataSeries >& xSeries, + const rtl::Reference< ::chart::DataSeries >& xSeries, ::sal_Int32 nChartTypeGroupIndex, ::sal_Int32 nSeriesIndex, ::sal_Int32 nSeriesCount ) override; diff --git a/chart2/source/model/template/NetChartTypeTemplate.cxx b/chart2/source/model/template/NetChartTypeTemplate.cxx index 49d4e7d8d5bc..5ab51abbe0f2 100644 --- a/chart2/source/model/template/NetChartTypeTemplate.cxx +++ b/chart2/source/model/template/NetChartTypeTemplate.cxx @@ -66,7 +66,7 @@ StackMode NetChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex */ ) } void NetChartTypeTemplate::applyStyle( - const Reference< chart2::XDataSeries >& xSeries, + const rtl::Reference< DataSeries >& xSeries, ::sal_Int32 nChartTypeIndex, ::sal_Int32 nSeriesIndex, ::sal_Int32 nSeriesCount ) @@ -75,11 +75,9 @@ void NetChartTypeTemplate::applyStyle( try { - Reference< beans::XPropertySet > xProp( xSeries, uno::UNO_QUERY_THROW ); - - DataSeriesHelper::switchSymbolsOnOrOff( xProp, m_bHasSymbols, nSeriesIndex ); - DataSeriesHelper::switchLinesOnOrOff( xProp, m_bHasLines ); - DataSeriesHelper::makeLinesThickOrThin( xProp, true ); + DataSeriesHelper::switchSymbolsOnOrOff( xSeries, m_bHasSymbols, nSeriesIndex ); + DataSeriesHelper::switchLinesOnOrOff( xSeries, m_bHasLines ); + DataSeriesHelper::makeLinesThickOrThin( xSeries, true ); } catch( const uno::Exception & ) { diff --git a/chart2/source/model/template/NetChartTypeTemplate.hxx b/chart2/source/model/template/NetChartTypeTemplate.hxx index 6b57e3fe0890..e7a9c407c31a 100644 --- a/chart2/source/model/template/NetChartTypeTemplate.hxx +++ b/chart2/source/model/template/NetChartTypeTemplate.hxx @@ -46,7 +46,7 @@ protected: getChartTypeForNewSeries( const std::vector< rtl::Reference< ::chart::ChartType > >& aFormerlyUsedChartTypes ) override; virtual void applyStyle( - const css::uno::Reference< css::chart2::XDataSeries >& xSeries, + const rtl::Reference< ::chart::DataSeries >& xSeries, ::sal_Int32 nChartTypeGroupIndex, ::sal_Int32 nSeriesIndex, ::sal_Int32 nSeriesCount ) override; diff --git a/chart2/source/model/template/PieChartTypeTemplate.cxx b/chart2/source/model/template/PieChartTypeTemplate.cxx index 46a3e57e2a88..9369104f5b52 100644 --- a/chart2/source/model/template/PieChartTypeTemplate.cxx +++ b/chart2/source/model/template/PieChartTypeTemplate.cxx @@ -279,7 +279,7 @@ void PieChartTypeTemplate::adaptScales( } void PieChartTypeTemplate::createChartTypes( - const Sequence< Sequence< Reference< chart2::XDataSeries > > > & aSeriesSeq, + const std::vector< std::vector< rtl::Reference< DataSeries > > > & aSeriesSeq, const std::vector< rtl::Reference< BaseCoordinateSystem > > & rCoordSys, const std::vector< rtl::Reference< ChartType > >& /* aOldChartTypesSeq */ ) { @@ -293,9 +293,9 @@ void PieChartTypeTemplate::createChartTypes( "UseRings", getFastPropertyValue( PROP_PIE_TEMPLATE_USE_RINGS )); rCoordSys[0]->setChartTypes( std::vector{xCT} ); - if( aSeriesSeq.hasElements() ) + if( !aSeriesSeq.empty() ) { - Sequence< Reference< chart2::XDataSeries > > aFlatSeriesSeq( FlattenSequence( aSeriesSeq )); + std::vector< rtl::Reference< DataSeries > > aFlatSeriesSeq = FlattenSequence( aSeriesSeq ); xCT->setDataSeries( aFlatSeriesSeq ); DataSeriesHelper::setStackModeAtSeries( @@ -437,7 +437,7 @@ rtl::Reference< ChartType > PieChartTypeTemplate::getChartTypeForNewSeries( } void PieChartTypeTemplate::applyStyle( - const Reference< chart2::XDataSeries >& xSeries, + const rtl::Reference< DataSeries >& xSeries, ::sal_Int32 nChartTypeIndex, ::sal_Int32 nSeriesIndex, ::sal_Int32 nSeriesCount ) @@ -446,8 +446,6 @@ void PieChartTypeTemplate::applyStyle( try { - uno::Reference< beans::XPropertySet > xProp( xSeries, uno::UNO_QUERY_THROW ); - bool bTemplateUsesRings = false; sal_Int32 nOuterSeriesIndex = 0; getFastPropertyValue( PROP_PIE_TEMPLATE_USE_RINGS ) >>= bTemplateUsesRings; @@ -469,7 +467,7 @@ void PieChartTypeTemplate::applyStyle( double fOffsetToSet = fDefaultOffset; uno::Sequence< sal_Int32 > aAttributedDataPointIndexList; - xProp->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList; + xSeries->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList; // determine whether to set the new offset bool bSetOffset = ( ePieOffsetMode == chart2::PieChartOffsetMode_ALL_EXPLODED ); @@ -479,7 +477,7 @@ void PieChartTypeTemplate::applyStyle( // set offset to 0 if the offset was exactly "all exploded" // before (individual offsets are kept) double fOffset = 0.0; - if( (xProp->getPropertyValue( aOffsetPropName ) >>= fOffset) && + if( (xSeries->getPropertyValue( aOffsetPropName ) >>= fOffset) && ::rtl::math::approxEqual( fOffset, fDefaultOffset )) { fOffsetToSet = 0.0; @@ -506,7 +504,7 @@ void PieChartTypeTemplate::applyStyle( if( bSetOffset ) { // set the offset to the series and to the attributed data points - xProp->setPropertyValue( aOffsetPropName, uno::Any( fOffsetToSet )); + xSeries->setPropertyValue( aOffsetPropName, uno::Any( fOffsetToSet )); // remove hard attributes from data points for( auto const & pointIndex : std::as_const(aAttributedDataPointIndexList) ) @@ -523,7 +521,7 @@ void PieChartTypeTemplate::applyStyle( DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "BorderStyle", uno::Any( drawing::LineStyle_NONE ) ); // vary colors by point - xProp->setPropertyValue( "VaryColorsByPoint", uno::Any( true )); + xSeries->setPropertyValue( "VaryColorsByPoint", uno::Any( true )); } catch( const uno::Exception & ) { diff --git a/chart2/source/model/template/PieChartTypeTemplate.hxx b/chart2/source/model/template/PieChartTypeTemplate.hxx index c18ba32803b8..425461afd35d 100644 --- a/chart2/source/model/template/PieChartTypeTemplate.hxx +++ b/chart2/source/model/template/PieChartTypeTemplate.hxx @@ -64,7 +64,7 @@ protected: getChartTypeForNewSeries( const std::vector< rtl::Reference< ::chart::ChartType > >& aFormerlyUsedChartTypes ) override; virtual void applyStyle( - const css::uno::Reference< css::chart2::XDataSeries >& xSeries, + const rtl::Reference< ::chart::DataSeries >& xSeries, ::sal_Int32 nChartTypeGroupIndex, ::sal_Int32 nSeriesIndex, ::sal_Int32 nSeriesCount ) override; @@ -87,10 +87,10 @@ protected: const css::uno::Reference< css::chart2::data::XLabeledDataSequence > & xCategories ) override; virtual void createChartTypes( - const css::uno::Sequence< - css::uno::Sequence< - css::uno::Reference< - css::chart2::XDataSeries > > >& aSeriesSeq, + const std::vector< + std::vector< + rtl::Reference< + ::chart::DataSeries > > >& aSeriesSeq, const std::vector< rtl::Reference< ::chart::BaseCoordinateSystem > > & rCoordSys, diff --git a/chart2/source/model/template/ScatterChartTypeTemplate.cxx b/chart2/source/model/template/ScatterChartTypeTemplate.cxx index d77e99e8615a..84315c79ddc9 100644 --- a/chart2/source/model/template/ScatterChartTypeTemplate.cxx +++ b/chart2/source/model/template/ScatterChartTypeTemplate.cxx @@ -202,7 +202,7 @@ StackMode ScatterChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex * } void ScatterChartTypeTemplate::applyStyle( - const Reference< chart2::XDataSeries >& xSeries, + const rtl::Reference< DataSeries >& xSeries, ::sal_Int32 nChartTypeIndex, ::sal_Int32 nSeriesIndex, ::sal_Int32 nSeriesCount ) @@ -211,11 +211,9 @@ void ScatterChartTypeTemplate::applyStyle( try { - Reference< beans::XPropertySet > xProp( xSeries, uno::UNO_QUERY_THROW ); - - DataSeriesHelper::switchSymbolsOnOrOff( xProp, m_bHasSymbols, nSeriesIndex ); - DataSeriesHelper::switchLinesOnOrOff( xProp, m_bHasLines ); - DataSeriesHelper::makeLinesThickOrThin( xProp, m_nDim==2 ); + DataSeriesHelper::switchSymbolsOnOrOff( xSeries, m_bHasSymbols, nSeriesIndex ); + DataSeriesHelper::switchLinesOnOrOff( xSeries, m_bHasLines ); + DataSeriesHelper::makeLinesThickOrThin( xSeries, m_nDim==2 ); if( m_nDim==3 ) DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "BorderStyle", uno::Any( drawing::LineStyle_NONE ) ); } diff --git a/chart2/source/model/template/ScatterChartTypeTemplate.hxx b/chart2/source/model/template/ScatterChartTypeTemplate.hxx index e72bd007d771..02f2e84f7425 100644 --- a/chart2/source/model/template/ScatterChartTypeTemplate.hxx +++ b/chart2/source/model/template/ScatterChartTypeTemplate.hxx @@ -64,7 +64,7 @@ protected: rtl::Reference< ::chart::ChartType > >& aFormerlyUsedChartTypes ) override; virtual rtl::Reference< ::chart::DataInterpreter > getDataInterpreter() override; virtual void applyStyle( - const css::uno::Reference< css::chart2::XDataSeries >& xSeries, + const rtl::Reference< ::chart::DataSeries >& xSeries, ::sal_Int32 nChartTypeGroupIndex, ::sal_Int32 nSeriesIndex, ::sal_Int32 nSeriesCount ) override; diff --git a/chart2/source/model/template/StockChartTypeTemplate.cxx b/chart2/source/model/template/StockChartTypeTemplate.cxx index 9a3fce7ca9c2..eb03a9383535 100644 --- a/chart2/source/model/template/StockChartTypeTemplate.cxx +++ b/chart2/source/model/template/StockChartTypeTemplate.cxx @@ -191,7 +191,7 @@ sal_Int32 StockChartTypeTemplate::getAxisCountByDimension( sal_Int32 nDimension } void StockChartTypeTemplate::applyStyle( - const Reference< chart2::XDataSeries >& xSeries, + const rtl::Reference< DataSeries >& xSeries, ::sal_Int32 nChartTypeIndex, ::sal_Int32 nSeriesIndex, ::sal_Int32 nSeriesCount ) @@ -206,9 +206,7 @@ void StockChartTypeTemplate::applyStyle( if( bHasVolume && nChartTypeIndex != 0 ) nNewAxisIndex = 1; - Reference< beans::XPropertySet > xProp( xSeries, uno::UNO_QUERY ); - if( xProp.is() ) - xProp->setPropertyValue( "AttachedAxisIndex", uno::Any( nNewAxisIndex ) ); + xSeries->setPropertyValue( "AttachedAxisIndex", uno::Any( nNewAxisIndex ) ); if( bHasVolume && nChartTypeIndex==0 ) { @@ -218,13 +216,10 @@ void StockChartTypeTemplate::applyStyle( else { //ensure that lines are on - if( xProp.is() ) - { - drawing::LineStyle eStyle = drawing::LineStyle_NONE; - xProp->getPropertyValue( "LineStyle" ) >>= eStyle; - if( eStyle == drawing::LineStyle_NONE ) - xProp->setPropertyValue( "LineStyle", uno::Any( drawing::LineStyle_SOLID )); - } + drawing::LineStyle eStyle = drawing::LineStyle_NONE; + xSeries->getPropertyValue( "LineStyle" ) >>= eStyle; + if( eStyle == drawing::LineStyle_NONE ) + xSeries->setPropertyValue( "LineStyle", uno::Any( drawing::LineStyle_SOLID )); } } @@ -276,7 +271,7 @@ rtl::Reference< ChartType > StockChartTypeTemplate::getChartTypeForIndex( sal_In } void StockChartTypeTemplate::createChartTypes( - const Sequence< Sequence< Reference< XDataSeries > > > & aSeriesSeq, + const std::vector< std::vector< rtl::Reference< DataSeries > > > & aSeriesSeq, const std::vector< rtl::Reference< BaseCoordinateSystem > > & rCoordSys, const std::vector< rtl::Reference< ChartType > >& /* aOldChartTypesSeq */ ) { @@ -305,8 +300,8 @@ void StockChartTypeTemplate::createChartTypes( rtl::Reference< ChartType > xCT = new ColumnChartType(); aChartTypeVec.push_back( xCT ); - if( aSeriesSeq.getLength() > nSeriesIndex && - aSeriesSeq[nSeriesIndex].hasElements() ) + if( static_cast<sal_Int32>(aSeriesSeq.size()) > nSeriesIndex && + !aSeriesSeq[nSeriesIndex].empty() ) { xCT->setDataSeries( aSeriesSeq[ nSeriesIndex ] ); } @@ -320,16 +315,16 @@ void StockChartTypeTemplate::createChartTypes( xCT->setPropertyValue( "ShowFirst", uno::Any( bShowFirst )); xCT->setPropertyValue( "ShowHighLow", uno::Any( bShowHighLow )); - if( aSeriesSeq.getLength() > nSeriesIndex && - aSeriesSeq[ nSeriesIndex ].hasElements() ) + if( static_cast<sal_Int32>(aSeriesSeq.size()) > nSeriesIndex && + !aSeriesSeq[ nSeriesIndex ].empty() ) { xCT->setDataSeries( aSeriesSeq[ nSeriesIndex ] ); } ++nSeriesIndex; // Lines (remaining series) - if( aSeriesSeq.getLength() > nSeriesIndex && - aSeriesSeq[ nSeriesIndex ].hasElements() ) + if( static_cast<sal_Int32>(aSeriesSeq.size()) > nSeriesIndex && + !aSeriesSeq[ nSeriesIndex ].empty() ) { xCT = new LineChartType(); aChartTypeVec.push_back( xCT ); diff --git a/chart2/source/model/template/StockChartTypeTemplate.hxx b/chart2/source/model/template/StockChartTypeTemplate.hxx index f09c89208df4..fe2a464f1bc4 100644 --- a/chart2/source/model/template/StockChartTypeTemplate.hxx +++ b/chart2/source/model/template/StockChartTypeTemplate.hxx @@ -78,7 +78,7 @@ protected: rtl::Reference< ::chart::ChartType > >& aFormerlyUsedChartTypes ) override; virtual rtl::Reference< ::chart::DataInterpreter > getDataInterpreter() override; virtual void applyStyle( - const css::uno::Reference< css::chart2::XDataSeries >& xSeries, + const rtl::Reference< ::chart::DataSeries >& xSeries, ::sal_Int32 nChartTypeIndex, ::sal_Int32 nSeriesIndex, ::sal_Int32 nSeriesCount ) override; @@ -90,10 +90,10 @@ protected: // ____ ChartTypeTemplate ____ virtual void createChartTypes( - const css::uno::Sequence< - css::uno::Sequence< - css::uno::Reference< - css::chart2::XDataSeries > > >& aSeriesSeq, + const std::vector< + std::vector< + rtl::Reference< + ::chart::DataSeries > > >& aSeriesSeq, const std::vector< rtl::Reference< ::chart::BaseCoordinateSystem > > & rCoordSys, diff --git a/chart2/source/model/template/StockDataInterpreter.cxx b/chart2/source/model/template/StockDataInterpreter.cxx index f96084e06dae..198ee934f4a3 100644 --- a/chart2/source/model/template/StockDataInterpreter.cxx +++ b/chart2/source/model/template/StockDataInterpreter.cxx @@ -221,14 +221,13 @@ InterpretedData StockDataInterpreter::interpretDataSource( } // create DataSeries - Sequence< Sequence< Reference< XDataSeries > > > aResultSeries( nNumberOfGroups ); - auto pResultSeries = aResultSeries.getArray(); + std::vector< std::vector< rtl::Reference< DataSeries > > > aResultSeries( nNumberOfGroups ); sal_Int32 nGroupIndex, nReUsedSeriesIdx = 0; for( nGroupIndex=0; nGroupIndex<nNumberOfGroups; ++nGroupIndex ) { const sal_Int32 nNumSeriesData = aSequences[nGroupIndex].size(); - pResultSeries[nGroupIndex].realloc( nNumSeriesData ); - auto pResultSerie = pResultSeries[nGroupIndex].getArray(); + aResultSeries[nGroupIndex].resize( nNumSeriesData ); + auto & pResultSerie = aResultSeries[nGroupIndex]; for( sal_Int32 nSeriesIdx = 0; nSeriesIdx < nNumSeriesData; ++nSeriesIdx, ++nReUsedSeriesIdx ) { try @@ -240,7 +239,7 @@ InterpretedData StockDataInterpreter::interpretDataSource( xSeries = new DataSeries; assert( xSeries.is() ); xSeries->setData( aSequences[nGroupIndex][nSeriesIdx] ); - pResultSerie[nSeriesIdx].set( xSeries ); + pResultSerie[nSeriesIdx] = xSeries; } catch( const uno::Exception & ) { @@ -272,32 +271,30 @@ bool StockDataInterpreter::isDataCompatible( ( eVar == StockChartTypeTemplate::StockVariant::VolumeOpen )); // 1. correct number of sub-types - if( aInterpretedData.Series.getLength() < (bHasVolume ? 2 : 1 )) + if( static_cast<sal_Int32>(aInterpretedData.Series.size()) < (bHasVolume ? 2 : 1 )) return false; // 2. a. volume -- use default check if( bHasVolume ) { if( ! DataInterpreter::isDataCompatible( - { Sequence< Sequence< Reference< XDataSeries > > >( - aInterpretedData.Series.getConstArray(), 1 ), + { std::vector< std::vector< rtl::Reference< DataSeries > > >{ + aInterpretedData.Series[0] }, aInterpretedData.Categories })) return false; } // 2. b. candlestick { - OSL_ASSERT( aInterpretedData.Series.getLength() > (bHasVolume ? 1 : 0)); - const Sequence< Reference< XDataSeries > > aSeries( aInterpretedData.Series[(bHasVolume ? 1 : 0)] ); - if(!aSeries.hasElements()) + OSL_ASSERT( static_cast<sal_Int32>(aInterpretedData.Series.size()) > (bHasVolume ? 1 : 0)); + const std::vector< rtl::Reference< DataSeries > > & aSeries = aInterpretedData.Series[(bHasVolume ? 1 : 0)]; + if(aSeries.empty()) return false; - for( Reference< XDataSeries > const & dataSeries : aSeries ) + for( rtl::Reference< DataSeries > const & dataSeries : aSeries ) { try { - Reference< data::XDataSource > xSrc( dataSeries, uno::UNO_QUERY_THROW ); - Sequence< Reference< data::XLabeledDataSequence > > aSeq( xSrc->getDataSequences()); - if( aSeq.getLength() != nNumberOfNecessarySequences ) + if( static_cast<sal_Int32>(dataSeries->getDataSequences2().size()) != nNumberOfNecessarySequences ) return false; } catch( const uno::Exception & ) diff --git a/chart2/source/model/template/XYDataInterpreter.cxx b/chart2/source/model/template/XYDataInterpreter.cxx index fb9d1d9c788b..93d8a032d1af 100644 --- a/chart2/source/model/template/XYDataInterpreter.cxx +++ b/chart2/source/model/template/XYDataInterpreter.cxx @@ -101,7 +101,7 @@ InterpretedData XYDataInterpreter::interpretDataSource( } // create DataSeries - vector< Reference< XDataSeries > > aSeriesVec; + vector< rtl::Reference< DataSeries > > aSeriesVec; aSeriesVec.reserve( aSequencesVec.size()); Reference< data::XLabeledDataSequence > xClonedXValues = xValuesX; @@ -131,7 +131,7 @@ InterpretedData XYDataInterpreter::interpretDataSource( ++nSeriesIndex; } - return { { comphelper::containerToSequence( aSeriesVec ) }, xCategories }; + return { { aSeriesVec }, xCategories }; } InterpretedData XYDataInterpreter::reinterpretDataSeries( @@ -140,27 +140,26 @@ InterpretedData XYDataInterpreter::reinterpretDataSeries( InterpretedData aResult( aInterpretedData ); sal_Int32 i=0; - Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series )); - const sal_Int32 nCount = aSeries.getLength(); + std::vector< rtl::Reference< DataSeries > > aSeries = FlattenSequence( aInterpretedData.Series ); + const sal_Int32 nCount = aSeries.size(); for( ; i<nCount; ++i ) { try { - Reference< data::XDataSource > xSeriesSource( aSeries[i], uno::UNO_QUERY_THROW ); - Sequence< Reference< data::XLabeledDataSequence > > aNewSequences; + std::vector< uno::Reference< data::XLabeledDataSequence > > aNewSequences; // values-y uno::Reference< chart2::data::XLabeledDataSequence > xValuesY( - DataSeriesHelper::getDataSequenceByRole( xSeriesSource, "values-y" )); + DataSeriesHelper::getDataSequenceByRole( aSeries[i], "values-y" )); uno::Reference< chart2::data::XLabeledDataSequence > xValuesX( - DataSeriesHelper::getDataSequenceByRole( xSeriesSource, "values-x" )); + DataSeriesHelper::getDataSequenceByRole( aSeries[i], "values-x" )); // re-use values-... as values-x/values-y if( ! xValuesX.is() || ! xValuesY.is()) { vector< uno::Reference< chart2::data::XLabeledDataSequence > > aValueSeqVec( DataSeriesHelper::getAllDataSequencesByRole( - xSeriesSource->getDataSequences(), "values" )); + aSeries[i]->getDataSequences2(), "values" )); if( xValuesX.is()) aValueSeqVec.erase( find( aValueSeqVec.begin(), aValueSeqVec.end(), xValuesX )); if( xValuesY.is()) @@ -195,8 +194,8 @@ InterpretedData XYDataInterpreter::reinterpretDataSeries( } } - const Sequence< Reference< data::XLabeledDataSequence > > aSeqs( xSeriesSource->getDataSequences()); - if( aSeqs.getLength() != aNewSequences.getLength() ) + const std::vector< uno::Reference< data::XLabeledDataSequence > > & aSeqs = aSeries[i]->getDataSequences2(); + if( aSeqs.size() != aNewSequences.size() ) { #ifdef DBG_UTIL for( auto const & j : aSeqs ) @@ -204,8 +203,7 @@ InterpretedData XYDataInterpreter::reinterpretDataSeries( SAL_WARN_IF((j == xValuesY || j == xValuesX), "chart2.template", "All sequences should be used" ); } #endif - Reference< data::XDataSink > xSink( xSeriesSource, uno::UNO_QUERY_THROW ); - xSink->setData( aNewSequences ); + aSeries[i]->setData( aNewSequences ); } } catch( const uno::Exception & ) @@ -221,14 +219,12 @@ InterpretedData XYDataInterpreter::reinterpretDataSeries( bool XYDataInterpreter::isDataCompatible( const InterpretedData& aInterpretedData ) { - const Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series )); - for( Reference< XDataSeries > const & dataSeries : aSeries ) + const std::vector< rtl::Reference< DataSeries > > aSeries = FlattenSequence( aInterpretedData.Series ); + for( rtl::Reference< DataSeries > const & dataSeries : aSeries ) { try { - Reference< data::XDataSource > xSrc( dataSeries, uno::UNO_QUERY_THROW ); - Sequence< Reference< data::XLabeledDataSequence > > aSeq( xSrc->getDataSequences()); - if( aSeq.getLength() != 2 ) + if( dataSeries->getDataSequences2().size() != 2 ) return false; } catch( const uno::Exception & ) |