summaryrefslogtreecommitdiff
path: root/chart2/source/model/template
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-05-18 09:17:04 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-05-18 11:28:50 +0200
commit337a9a454c1bc95214111578d3f9c0622c55c509 (patch)
tree4eda99edf46e45ce804fcde98197cf0d96b7ac3d /chart2/source/model/template
parent6089755d197528d071906846c58a397add0876a5 (diff)
use for-range on Sequence in chart2
Change-Id: Ief02e5d5284b0cbad26b04c0a282dccfee577b90 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94398 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2/source/model/template')
-rw-r--r--chart2/source/model/template/BubbleDataInterpreter.cxx13
-rw-r--r--chart2/source/model/template/ChartType.cxx10
-rw-r--r--chart2/source/model/template/ChartTypeTemplate.cxx65
-rw-r--r--chart2/source/model/template/ColumnLineChartTypeTemplate.cxx20
-rw-r--r--chart2/source/model/template/DataInterpreter.cxx32
-rw-r--r--chart2/source/model/template/PieChartTypeTemplate.cxx22
-rw-r--r--chart2/source/model/template/StockChartTypeTemplate.cxx20
-rw-r--r--chart2/source/model/template/StockDataInterpreter.cxx6
-rw-r--r--chart2/source/model/template/XYDataInterpreter.cxx27
9 files changed, 100 insertions, 115 deletions
diff --git a/chart2/source/model/template/BubbleDataInterpreter.cxx b/chart2/source/model/template/BubbleDataInterpreter.cxx
index cfef7f25baac..3373b9c1d911 100644
--- a/chart2/source/model/template/BubbleDataInterpreter.cxx
+++ b/chart2/source/model/template/BubbleDataInterpreter.cxx
@@ -241,14 +241,13 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::reinterpretDataSeries(
}
}
- Sequence< Reference< data::XLabeledDataSequence > > aSeqs( xSeriesSource->getDataSequences());
+ const Sequence< Reference< data::XLabeledDataSequence > > aSeqs( xSeriesSource->getDataSequences());
if( aSeqs.getLength() != aNewSequences.getLength() )
{
#if OSL_DEBUG_LEVEL > 0
- sal_Int32 j=0;
- for( ; j<aSeqs.getLength(); ++j )
+ for( auto const & j : aSeqs )
{
- assert( (aSeqs[j] == xValuesY || aSeqs[j] == xValuesX || aSeqs[j] == xValuesSize) && "All sequences should be used" );
+ assert( (j == xValuesY || j == xValuesX || j == xValuesSize) && "All sequences should be used" );
}
#endif
Reference< data::XDataSink > xSink( xSeriesSource, uno::UNO_QUERY_THROW );
@@ -267,12 +266,12 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::reinterpretDataSeries(
sal_Bool SAL_CALL BubbleDataInterpreter::isDataCompatible(
const chart2::InterpretedData& aInterpretedData )
{
- Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
- for( sal_Int32 i=0; i<aSeries.getLength(); ++i )
+ const Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
+ for( Reference< XDataSeries > const & dataSeries : aSeries )
{
try
{
- Reference< data::XDataSource > xSrc( aSeries[i], uno::UNO_QUERY_THROW );
+ Reference< data::XDataSource > xSrc( dataSeries, uno::UNO_QUERY_THROW );
Sequence< Reference< data::XLabeledDataSequence > > aSeq( xSrc->getDataSequences());
if( aSeq.getLength() != 3 )
return false;
diff --git a/chart2/source/model/template/ChartType.cxx b/chart2/source/model/template/ChartType.cxx
index 4edda932cfec..999f7c1ede96 100644
--- a/chart2/source/model/template/ChartType.cxx
+++ b/chart2/source/model/template/ChartType.cxx
@@ -173,13 +173,13 @@ void SAL_CALL ChartType::setDataSeries( const Sequence< Reference< chart2::XData
m_bNotifyChanges = false;
try
{
- Sequence< Reference< chart2::XDataSeries > > aOldSeries( getDataSeries() );
- for( sal_Int32 nN=0; nN<aOldSeries.getLength(); ++nN )
- ModifyListenerHelper::removeListener( aOldSeries[nN], m_xModifyEventForwarder );
+ const Sequence< Reference< chart2::XDataSeries > > aOldSeries( getDataSeries() );
+ for( auto const & i : aOldSeries )
+ ModifyListenerHelper::removeListener( i, m_xModifyEventForwarder );
m_aDataSeries.clear();
- for( sal_Int32 i=0; i<aDataSeries.getLength(); ++i )
- impl_addDataSeriesWithoutNotification( aDataSeries[i] );
+ for( auto const & i : aDataSeries )
+ impl_addDataSeriesWithoutNotification( i );
}
catch( ... )
{
diff --git a/chart2/source/model/template/ChartTypeTemplate.cxx b/chart2/source/model/template/ChartTypeTemplate.cxx
index 023becdd0698..8aafc1fd1d8b 100644
--- a/chart2/source/model/template/ChartTypeTemplate.cxx
+++ b/chart2/source/model/template/ChartTypeTemplate.cxx
@@ -73,9 +73,9 @@ void lcl_ensureCorrectLabelPlacement( const Reference< beans::XPropertySet >& xP
return;
bool bValid = false;
- for( sal_Int32 nN = 0; nN < rAvailablePlacements.getLength(); nN++ )
+ for( sal_Int32 i : rAvailablePlacements )
{
- if( rAvailablePlacements[nN] == nLabelPlacement )
+ if( i == nLabelPlacement )
{
bValid = true;
break;
@@ -155,13 +155,11 @@ uno::Reference< XDiagram > SAL_CALL ChartTypeTemplate::createDiagramByDataSource
xInterpreter->interpretDataSource(
xDataSource, aArguments, Sequence< Reference< XDataSeries > >() ));
- Sequence< Sequence< Reference< XDataSeries > > > aSeries( aData.Series );
- sal_Int32 i, j, nCount = 0;
- for( i=0; i<aSeries.getLength(); ++i )
- {
- for( j=0; j<aSeries[i].getLength(); ++j, ++nCount )
- lcl_applyDefaultStyle( aSeries[i][j], nCount, xDia );
- }
+ const Sequence< Sequence< Reference< XDataSeries > > > aSeries( aData.Series );
+ sal_Int32 nCount = 0;
+ for( auto const & i : aSeries )
+ for( auto const & j : i )
+ lcl_applyDefaultStyle( j, nCount++, xDia );
Sequence< Reference< XChartType > > aOldChartTypesSeq;
FillDiagram( xDia, aData.Series, aData.Categories, aOldChartTypesSeq );
@@ -219,12 +217,12 @@ void SAL_CALL ChartTypeTemplate::changeDiagram( const uno::Reference< XDiagram >
}
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 )
+ sal_Int32 nIndex = 0;
+ for( auto const & i : std::as_const(aSeriesSeq) )
+ for( auto const & j : i )
{
if( nIndex >= nFormerSeriesCount )
- lcl_applyDefaultStyle( aSeriesSeq[i][j], nIndex, xDiagram );
+ lcl_applyDefaultStyle( j, nIndex++, xDiagram );
}
// remove charttype groups from all coordinate systems
@@ -235,11 +233,11 @@ void SAL_CALL ChartTypeTemplate::changeDiagram( const uno::Reference< XDiagram >
OSL_ASSERT( xCoordSysCnt.is());
if( xCoordSysCnt.is())
{
- Sequence< Reference< XCoordinateSystem > > aCooSysSeq(
+ const Sequence< Reference< XCoordinateSystem > > aCooSysSeq(
xCoordSysCnt->getCoordinateSystems());
- for( sal_Int32 nCooSysIdx = 0; nCooSysIdx < aCooSysSeq.getLength(); ++nCooSysIdx )
+ for( Reference< XCoordinateSystem > const & coords : aCooSysSeq )
{
- Reference< XChartTypeContainer > xContainer( aCooSysSeq[nCooSysIdx], uno::UNO_QUERY );
+ Reference< XChartTypeContainer > xContainer( coords, uno::UNO_QUERY );
if( xContainer.is() )
xContainer->setChartTypes( Sequence< Reference< XChartType > >() );
}
@@ -436,12 +434,12 @@ void SAL_CALL ChartTypeTemplate::resetStyles( const Reference< chart2::XDiagram
bool bPercent = (getStackMode(0) == StackMode::YStackedPercent);
if( bPercent )
{
- Sequence< Reference< chart2::XAxis > > aAxisSeq( AxisHelper::getAllAxesOfDiagram( xDiagram ) );
- for( sal_Int32 i=0; i<aAxisSeq.getLength(); ++i )
+ const Sequence< Reference< chart2::XAxis > > aAxisSeq( AxisHelper::getAllAxesOfDiagram( xDiagram ) );
+ for( Reference< chart2::XAxis > const & axis : aAxisSeq )
{
- if( AxisHelper::getDimensionIndexOfAxis( aAxisSeq[i], xDiagram )== 1 )
+ if( AxisHelper::getDimensionIndexOfAxis( axis, xDiagram )== 1 )
{
- Reference< beans::XPropertySet > xAxisProp( aAxisSeq[i], uno::UNO_QUERY );
+ Reference< beans::XPropertySet > xAxisProp( axis, uno::UNO_QUERY );
if( xAxisProp.is())
{
// set number format to source format
@@ -457,31 +455,26 @@ void SAL_CALL ChartTypeTemplate::resetStyles( const Reference< chart2::XDiagram
uno::Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
if( xCooSysContainer.is() )
{
- uno::Sequence< uno::Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
- for( sal_Int32 nCS = 0; nCS < aCooSysList.getLength(); ++nCS )
+ const uno::Sequence< uno::Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
+ for( uno::Reference< XCoordinateSystem > const & xCooSys : aCooSysList )
{
- uno::Reference< XCoordinateSystem > xCooSys( aCooSysList[nCS] );
-
//iterate through all chart types in the current coordinate system
uno::Reference< XChartTypeContainer > xChartTypeContainer( xCooSys, uno::UNO_QUERY );
OSL_ASSERT( xChartTypeContainer.is());
if( !xChartTypeContainer.is() )
continue;
- uno::Sequence< uno::Reference< XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() );
- for( sal_Int32 nT = 0; nT < aChartTypeList.getLength(); ++nT )
+ const uno::Sequence< uno::Reference< XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() );
+ for( uno::Reference< XChartType > const & xChartType : aChartTypeList )
{
- uno::Reference< XChartType > xChartType( aChartTypeList[nT] );
-
//iterate through all series in this chart type
uno::Reference< XDataSeriesContainer > xDataSeriesContainer( xChartType, uno::UNO_QUERY );
OSL_ASSERT( xDataSeriesContainer.is());
if( !xDataSeriesContainer.is() )
continue;
- uno::Sequence< uno::Reference< XDataSeries > > aSeriesList( xDataSeriesContainer->getDataSeries() );
- for( sal_Int32 nS = 0; nS < aSeriesList.getLength(); ++nS )
+ const uno::Sequence< uno::Reference< XDataSeries > > aSeriesList( xDataSeriesContainer->getDataSeries() );
+ for( Reference< XDataSeries > const & xSeries : aSeriesList )
{
- Reference< XDataSeries > xSeries(aSeriesList[nS]);
Reference< beans::XPropertySet > xSeriesProp( xSeries, uno::UNO_QUERY );
if(!xSeries.is() || !xSeriesProp.is() )
continue;
@@ -600,11 +593,10 @@ void ChartTypeTemplate::adaptScales(
)
{
bool bSupportsCategories( supportsCategories() );
- for( sal_Int32 nCooSysIdx=0; nCooSysIdx<aCooSysSeq.getLength(); ++nCooSysIdx )
+ for( Reference< XCoordinateSystem > const & xCooSys : aCooSysSeq )
{
try
{
- Reference< XCoordinateSystem > xCooSys( aCooSysSeq[nCooSysIdx] );
if( !xCooSys.is() )
continue;
@@ -719,9 +711,8 @@ void ChartTypeTemplate::adaptAxes(
if( !rCoordSys.hasElements() )
return;
- for( sal_Int32 nCooSysIdx=0; nCooSysIdx < rCoordSys.getLength(); ++nCooSysIdx )
+ for( Reference< XCoordinateSystem > const & xCooSys : rCoordSys )
{
- Reference< XCoordinateSystem > xCooSys( rCoordSys[nCooSysIdx] );
if( !xCooSys.is() )
continue;
sal_Int32 nDimCount = xCooSys->getDimension();
@@ -868,10 +859,8 @@ void ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem(
OUString aNewChartType( xNewChartType->getChartType() );
Reference< beans::XPropertySet > xSource;
- sal_Int32 nN=0;
- for( nN=0; nN<rOldChartTypesSeq.getLength();++nN)
+ for( Reference< XChartType > const & xOldType : rOldChartTypesSeq )
{
- Reference< XChartType > xOldType( rOldChartTypesSeq[nN] );
if( xOldType.is() && xOldType->getChartType() == aNewChartType )
{
xSource.set( Reference< beans::XPropertySet >(xOldType, uno::UNO_QUERY ) );
diff --git a/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx b/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx
index 8b357a852e8b..560332b81e98 100644
--- a/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx
+++ b/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx
@@ -284,27 +284,27 @@ sal_Bool SAL_CALL ColumnLineChartTypeTemplate::matchesTemplate(
Reference< XCoordinateSystemContainer > xCooSysCnt(
xDiagram, uno::UNO_QUERY_THROW );
- Sequence< Reference< XCoordinateSystem > > aCooSysSeq(
+ const Sequence< Reference< XCoordinateSystem > > aCooSysSeq(
xCooSysCnt->getCoordinateSystems());
- for( sal_Int32 i=0; i<aCooSysSeq.getLength(); ++i )
+ for( Reference< XCoordinateSystem > const & coords : aCooSysSeq )
{
- Reference< XChartTypeContainer > xCTCnt( aCooSysSeq[i], uno::UNO_QUERY_THROW );
- Sequence< Reference< XChartType > > aChartTypeSeq( xCTCnt->getChartTypes());
- for( sal_Int32 j=0; j<aChartTypeSeq.getLength(); ++j )
+ Reference< XChartTypeContainer > xCTCnt( coords, uno::UNO_QUERY_THROW );
+ const Sequence< Reference< XChartType > > aChartTypeSeq( xCTCnt->getChartTypes());
+ for( Reference< XChartType > const & chartType : aChartTypeSeq )
{
- if( aChartTypeSeq[j].is())
+ if( chartType.is())
{
++nNumberOfChartTypes;
if( nNumberOfChartTypes > 2 )
break;
- OUString aCTService = aChartTypeSeq[j]->getChartType();
+ OUString aCTService = chartType->getChartType();
if( aCTService == CHART2_SERVICE_NAME_CHARTTYPE_COLUMN )
{
- xColumnChartType.set( aChartTypeSeq[j] );
- xColumnChartCooSys.set( aCooSysSeq[i] );
+ xColumnChartType.set( chartType );
+ xColumnChartCooSys.set( coords );
}
else if( aCTService == CHART2_SERVICE_NAME_CHARTTYPE_LINE )
- xLineChartType.set( aChartTypeSeq[j] );
+ xLineChartType.set( chartType );
}
}
if( nNumberOfChartTypes > 2 )
diff --git a/chart2/source/model/template/DataInterpreter.cxx b/chart2/source/model/template/DataInterpreter.cxx
index 5832612ba91d..7e85e0b36199 100644
--- a/chart2/source/model/template/DataInterpreter.cxx
+++ b/chart2/source/model/template/DataInterpreter.cxx
@@ -66,7 +66,7 @@ InterpretedData SAL_CALL DataInterpreter::interpretDataSource(
lcl_ShowDataSource( xSource );
#endif
- Sequence< Reference< data::XLabeledDataSequence > > aData( xSource->getDataSequences() );
+ const Sequence< Reference< data::XLabeledDataSequence > > aData( xSource->getDataSequences() );
Reference< data::XLabeledDataSequence > xCategories;
vector< Reference< data::XLabeledDataSequence > > aSequencesVec;
@@ -77,22 +77,22 @@ InterpretedData SAL_CALL DataInterpreter::interpretDataSource(
// parse data
bool bCategoriesUsed = false;
- for( sal_Int32 i=0; i < aData.getLength(); ++i )
+ for( Reference< data::XLabeledDataSequence > const & labeledData : aData )
{
try
{
if( bHasCategories && ! bCategoriesUsed )
{
- xCategories.set( aData[i] );
+ xCategories.set( labeledData );
if( xCategories.is())
SetRole( xCategories->getValues(), "categories");
bCategoriesUsed = true;
}
else
{
- aSequencesVec.push_back( aData[i] );
- if( aData[i].is())
- SetRole( aData[i]->getValues(), "values-y");
+ aSequencesVec.push_back( labeledData );
+ if( labeledData.is())
+ SetRole( labeledData->getValues(), "values-y");
}
}
catch( const uno::Exception & )
@@ -165,7 +165,7 @@ InterpretedData SAL_CALL DataInterpreter::reinterpretDataSeries(
{
#ifdef DEBUG_CHART2_TEMPLATE
sal_Int32 j=0;
- for( ; j<aSeqs.getLength(); ++j )
+ for( ; j<aSeqs.(); ++j )
{
assert( aSeqs[j] == xValuesY && "All sequences should be used" );
}
@@ -187,12 +187,12 @@ InterpretedData SAL_CALL DataInterpreter::reinterpretDataSeries(
sal_Bool SAL_CALL DataInterpreter::isDataCompatible(
const chart2::InterpretedData& aInterpretedData )
{
- Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
- for( sal_Int32 i=0; i<aSeries.getLength(); ++i )
+ const Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
+ for( Reference< XDataSeries > const & i : aSeries )
{
try
{
- Reference< data::XDataSource > xSrc( aSeries[i], uno::UNO_QUERY_THROW );
+ Reference< data::XDataSource > xSrc( i, uno::UNO_QUERY_THROW );
Sequence< Reference< data::XLabeledDataSequence > > aSeq( xSrc->getDataSequences());
if( aSeq.getLength() != 1 )
return false;
@@ -270,19 +270,17 @@ Reference< data::XDataSource > SAL_CALL DataInterpreter::mergeInterpretedData(
if( aInterpretedData.Categories.is())
aResultVec.push_back( aInterpretedData.Categories );
- Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
- for( sal_Int32 nSeriesIdx=0; nSeriesIdx<aSeries.getLength(); ++nSeriesIdx )
+ const Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
+ for( Reference< XDataSeries > const & dataSeries : aSeries )
{
try
{
- Reference< data::XDataSource > xSrc( aSeries[nSeriesIdx], uno::UNO_QUERY_THROW );
- Sequence< Reference< data::XLabeledDataSequence > > aSeq( xSrc->getDataSequences());
+ Reference< data::XDataSource > xSrc( dataSeries, uno::UNO_QUERY_THROW );
+ const Sequence< Reference< data::XLabeledDataSequence > > aSeq( xSrc->getDataSequences());
// add all sequences of data series
- for( sal_Int32 nSeqIdx=0; nSeqIdx<aSeq.getLength(); ++nSeqIdx )
+ for( Reference< data::XLabeledDataSequence > const & xAdd : aSeq )
{
- Reference< data::XLabeledDataSequence > xAdd( aSeq[nSeqIdx] );
-
// only add if sequence is not yet in the result
if( none_of( aResultVec.begin(), aResultVec.end(),
lcl_LabeledSequenceEquals( xAdd )) )
diff --git a/chart2/source/model/template/PieChartTypeTemplate.cxx b/chart2/source/model/template/PieChartTypeTemplate.cxx
index 56acc536f39e..964b5d96d5c2 100644
--- a/chart2/source/model/template/PieChartTypeTemplate.cxx
+++ b/chart2/source/model/template/PieChartTypeTemplate.cxx
@@ -226,12 +226,12 @@ void PieChartTypeTemplate::adaptScales(
//remove explicit scalings from radius axis
//and ensure correct orientation of scales for donuts
- for( sal_Int32 nCooSysIdx=0; nCooSysIdx<aCooSysSeq.getLength(); ++nCooSysIdx )
+ for( Reference< chart2::XCoordinateSystem > const & coords : aCooSysSeq )
{
try
{
Reference< chart2::XAxis > xAxis( AxisHelper::getAxis( 1 /*nDimensionIndex*/,0 /*nAxisIndex*/
- , aCooSysSeq[nCooSysIdx] ) );
+ , coords ) );
if( xAxis.is() )
{
chart2::ScaleData aScaleData( xAxis->getScaleData() );
@@ -241,7 +241,7 @@ void PieChartTypeTemplate::adaptScales(
}
xAxis = AxisHelper::getAxis( 0 /*nDimensionIndex*/,0 /*nAxisIndex*/
- , aCooSysSeq[nCooSysIdx] );
+ , coords );
if( xAxis.is() )
{
chart2::ScaleData aScaleData( xAxis->getScaleData() );
@@ -479,10 +479,10 @@ void SAL_CALL PieChartTypeTemplate::applyStyle(
{
fOffsetToSet = 0.0;
bSetOffset = true;
- for( sal_Int32 nPtIdx=0; nPtIdx<aAttributedDataPointIndexList.getLength(); ++nPtIdx )
+ for( auto const & pointIndex : std::as_const(aAttributedDataPointIndexList) )
{
uno::Reference< beans::XPropertySet > xPointProp(
- xSeries->getDataPointByIndex( aAttributedDataPointIndexList[ nPtIdx ] ));
+ xSeries->getDataPointByIndex( pointIndex ));
uno::Reference< beans::XPropertyState > xPointState( xPointProp, uno::UNO_QUERY );
double fPointOffset = 0.0;
if( xPointState.is() &&
@@ -504,10 +504,10 @@ void SAL_CALL PieChartTypeTemplate::applyStyle(
xProp->setPropertyValue( aOffsetPropName, uno::Any( fOffsetToSet ));
// remove hard attributes from data points
- for( sal_Int32 nPtIdx=0; nPtIdx<aAttributedDataPointIndexList.getLength(); ++nPtIdx )
+ for( auto const & pointIndex : std::as_const(aAttributedDataPointIndexList) )
{
uno::Reference< beans::XPropertyState > xPointState(
- xSeries->getDataPointByIndex( aAttributedDataPointIndexList[ nPtIdx ] ), uno::UNO_QUERY );
+ xSeries->getDataPointByIndex( pointIndex ), uno::UNO_QUERY );
if( xPointState.is())
xPointState->setPropertyToDefault( aOffsetPropName );
}
@@ -532,16 +532,16 @@ void SAL_CALL PieChartTypeTemplate::resetStyles( const Reference< chart2::XDiagr
Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY );
if( xCooSysCnt.is())
{
- Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems());
+ const Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems());
ChartTypeTemplate::createAxes( aCooSysSeq );
//reset scale orientation
- for( sal_Int32 nCooSysIdx=0; nCooSysIdx<aCooSysSeq.getLength(); ++nCooSysIdx )
+ for( Reference< chart2::XCoordinateSystem > const & coords : aCooSysSeq )
{
try
{
Reference< chart2::XAxis > xAxis( AxisHelper::getAxis( 0 /*nDimensionIndex*/,0 /*nAxisIndex*/
- , aCooSysSeq[nCooSysIdx] ) );
+ , coords ) );
if( xAxis.is() )
{
chart2::ScaleData aScaleData( xAxis->getScaleData() );
@@ -549,7 +549,7 @@ void SAL_CALL PieChartTypeTemplate::resetStyles( const Reference< chart2::XDiagr
xAxis->setScaleData( aScaleData );
}
- xAxis = AxisHelper::getAxis( 1, 0, aCooSysSeq[nCooSysIdx] );
+ xAxis = AxisHelper::getAxis( 1, 0, coords );
if( xAxis.is() )
{
chart2::ScaleData aScaleData( xAxis->getScaleData() );
diff --git a/chart2/source/model/template/StockChartTypeTemplate.cxx b/chart2/source/model/template/StockChartTypeTemplate.cxx
index 807cc6dd7dfd..7eb0e1ca51da 100644
--- a/chart2/source/model/template/StockChartTypeTemplate.cxx
+++ b/chart2/source/model/template/StockChartTypeTemplate.cxx
@@ -409,26 +409,26 @@ sal_Bool SAL_CALL StockChartTypeTemplate::matchesTemplate(
Reference< XCoordinateSystemContainer > xCooSysCnt(
xDiagram, uno::UNO_QUERY_THROW );
- Sequence< Reference< XCoordinateSystem > > aCooSysSeq(
+ const Sequence< Reference< XCoordinateSystem > > aCooSysSeq(
xCooSysCnt->getCoordinateSystems());
- for( sal_Int32 i=0; i<aCooSysSeq.getLength(); ++i )
+ for( Reference< XCoordinateSystem > const & coords : aCooSysSeq )
{
- Reference< XChartTypeContainer > xCTCnt( aCooSysSeq[i], uno::UNO_QUERY_THROW );
- Sequence< Reference< XChartType > > aChartTypeSeq( xCTCnt->getChartTypes());
- for( sal_Int32 j=0; j<aChartTypeSeq.getLength(); ++j )
+ Reference< XChartTypeContainer > xCTCnt( coords, uno::UNO_QUERY_THROW );
+ const Sequence< Reference< XChartType > > aChartTypeSeq( xCTCnt->getChartTypes());
+ for( Reference< XChartType > const & chartType : aChartTypeSeq )
{
- if( aChartTypeSeq[j].is())
+ if( chartType.is())
{
++nNumberOfChartTypes;
if( nNumberOfChartTypes > 3 )
break;
- OUString aCTService = aChartTypeSeq[j]->getChartType();
+ OUString aCTService = chartType->getChartType();
if( aCTService == CHART2_SERVICE_NAME_CHARTTYPE_COLUMN )
- xVolumeChartType.set( aChartTypeSeq[j] );
+ xVolumeChartType.set( chartType );
else if( aCTService == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK )
- xCandleStickChartType.set( aChartTypeSeq[j] );
+ xCandleStickChartType.set( chartType );
else if( aCTService == CHART2_SERVICE_NAME_CHARTTYPE_LINE )
- xLineChartType.set( aChartTypeSeq[j] );
+ xLineChartType.set( chartType );
}
}
if( nNumberOfChartTypes > 3 )
diff --git a/chart2/source/model/template/StockDataInterpreter.cxx b/chart2/source/model/template/StockDataInterpreter.cxx
index d2ad7b296604..15c2891975ad 100644
--- a/chart2/source/model/template/StockDataInterpreter.cxx
+++ b/chart2/source/model/template/StockDataInterpreter.cxx
@@ -282,14 +282,14 @@ sal_Bool SAL_CALL StockDataInterpreter::isDataCompatible(
// 2. b. candlestick
{
OSL_ASSERT( aInterpretedData.Series.getLength() > (bHasVolume ? 1 : 0));
- Sequence< Reference< XDataSeries > > aSeries( aInterpretedData.Series[(bHasVolume ? 1 : 0)] );
+ const Sequence< Reference< XDataSeries > > aSeries( aInterpretedData.Series[(bHasVolume ? 1 : 0)] );
if(!aSeries.hasElements())
return false;
- for( sal_Int32 i=0; i<aSeries.getLength(); ++i )
+ for( Reference< XDataSeries > const & dataSeries : aSeries )
{
try
{
- Reference< data::XDataSource > xSrc( aSeries[i], uno::UNO_QUERY_THROW );
+ Reference< data::XDataSource > xSrc( dataSeries, uno::UNO_QUERY_THROW );
Sequence< Reference< data::XLabeledDataSequence > > aSeq( xSrc->getDataSequences());
if( aSeq.getLength() != nNumberOfNecessarySequences )
return false;
diff --git a/chart2/source/model/template/XYDataInterpreter.cxx b/chart2/source/model/template/XYDataInterpreter.cxx
index a1a1ed2d329d..a3fb67fa9202 100644
--- a/chart2/source/model/template/XYDataInterpreter.cxx
+++ b/chart2/source/model/template/XYDataInterpreter.cxx
@@ -54,7 +54,7 @@ chart2::InterpretedData SAL_CALL XYDataInterpreter::interpretDataSource(
if( ! xSource.is())
return InterpretedData();
- Sequence< Reference< data::XLabeledDataSequence > > aData( xSource->getDataSequences() );
+ const Sequence< Reference< data::XLabeledDataSequence > > aData( xSource->getDataSequences() );
Reference< data::XLabeledDataSequence > xValuesX;
vector< Reference< data::XLabeledDataSequence > > aSequencesVec;
@@ -66,13 +66,13 @@ chart2::InterpretedData SAL_CALL XYDataInterpreter::interpretDataSource(
// parse data
bool bCategoriesUsed = false;
bool bSetXValues = aData.getLength()>1;
- for( sal_Int32 nDataIdx= 0; nDataIdx < aData.getLength(); ++nDataIdx )
+ for( Reference< data::XLabeledDataSequence > const & labelData : aData )
{
try
{
if( bHasCategories && ! bCategoriesUsed )
{
- xCategories.set( aData[nDataIdx] );
+ xCategories.set( labelData );
if( xCategories.is())
{
SetRole( xCategories->getValues(), "categories");
@@ -83,15 +83,15 @@ chart2::InterpretedData SAL_CALL XYDataInterpreter::interpretDataSource(
}
else if( !xValuesX.is() && bSetXValues )
{
- xValuesX.set( aData[nDataIdx] );
+ xValuesX.set( labelData );
if( xValuesX.is())
SetRole( xValuesX->getValues(), "values-x");
}
else
{
- aSequencesVec.push_back( aData[nDataIdx] );
- if( aData[nDataIdx].is())
- SetRole( aData[nDataIdx]->getValues(), "values-y");
+ aSequencesVec.push_back( labelData );
+ if( labelData.is())
+ SetRole( labelData->getValues(), "values-y");
}
}
catch( const uno::Exception & )
@@ -202,14 +202,13 @@ chart2::InterpretedData SAL_CALL XYDataInterpreter::reinterpretDataSeries(
}
}
- Sequence< Reference< data::XLabeledDataSequence > > aSeqs( xSeriesSource->getDataSequences());
+ const Sequence< Reference< data::XLabeledDataSequence > > aSeqs( xSeriesSource->getDataSequences());
if( aSeqs.getLength() != aNewSequences.getLength() )
{
#ifdef DBG_UTIL
- sal_Int32 j=0;
- for( ; j<aSeqs.getLength(); ++j )
+ for( auto const & j : aSeqs )
{
- SAL_WARN_IF((aSeqs[j] == xValuesY || aSeqs[j] == xValuesX), "chart2.template", "All sequences should be used" );
+ SAL_WARN_IF((j == xValuesY || j == xValuesX), "chart2.template", "All sequences should be used" );
}
#endif
Reference< data::XDataSink > xSink( xSeriesSource, uno::UNO_QUERY_THROW );
@@ -229,12 +228,12 @@ chart2::InterpretedData SAL_CALL XYDataInterpreter::reinterpretDataSeries(
sal_Bool SAL_CALL XYDataInterpreter::isDataCompatible(
const chart2::InterpretedData& aInterpretedData )
{
- Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
- for( sal_Int32 i=0; i<aSeries.getLength(); ++i )
+ const Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
+ for( Reference< XDataSeries > const & dataSeries : aSeries )
{
try
{
- Reference< data::XDataSource > xSrc( aSeries[i], uno::UNO_QUERY_THROW );
+ Reference< data::XDataSource > xSrc( dataSeries, uno::UNO_QUERY_THROW );
Sequence< Reference< data::XLabeledDataSequence > > aSeq( xSrc->getDataSequences());
if( aSeq.getLength() != 2 )
return false;