From 337a9a454c1bc95214111578d3f9c0622c55c509 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 18 May 2020 09:17:04 +0200 Subject: 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 --- chart2/qa/extras/chart2export.cxx | 12 +-- chart2/qa/extras/charttest.hxx | 50 ++++----- .../chartapiwrapper/MinMaxLineWrapper.cxx | 20 ++-- .../controller/chartapiwrapper/TitleWrapper.cxx | 12 +-- .../chartapiwrapper/UpDownBarWrapper.cxx | 24 ++--- .../chartapiwrapper/WrappedGapwidthProperty.cxx | 6 +- .../source/controller/dialogs/DataBrowserModel.cxx | 56 +++++----- chart2/source/controller/dialogs/DialogModel.cxx | 35 +++--- .../source/controller/dialogs/tp_AxisPositions.cxx | 4 +- chart2/source/controller/dialogs/tp_DataSource.cxx | 10 +- .../itemsetwrapper/MultipleChartConverters.cxx | 11 +- .../itemsetwrapper/SeriesOptionsItemConverter.cxx | 4 +- .../itemsetwrapper/TitleItemConverter.cxx | 4 +- .../controller/main/ChartController_Insert.cxx | 12 +-- chart2/source/controller/main/ChartModelClone.cxx | 8 +- chart2/source/controller/main/ObjectHierarchy.cxx | 11 +- chart2/source/model/filter/XMLFilter.cxx | 12 +-- .../source/model/main/ChartModel_Persistence.cxx | 6 +- .../model/template/BubbleDataInterpreter.cxx | 13 ++- chart2/source/model/template/ChartType.cxx | 10 +- chart2/source/model/template/ChartTypeTemplate.cxx | 65 +++++------ .../model/template/ColumnLineChartTypeTemplate.cxx | 20 ++-- chart2/source/model/template/DataInterpreter.cxx | 32 +++--- .../source/model/template/PieChartTypeTemplate.cxx | 22 ++-- .../model/template/StockChartTypeTemplate.cxx | 20 ++-- .../source/model/template/StockDataInterpreter.cxx | 6 +- chart2/source/model/template/XYDataInterpreter.cxx | 27 +++-- chart2/source/tools/AxisHelper.cxx | 56 +++++----- chart2/source/tools/ChartModelHelper.cxx | 8 +- chart2/source/tools/ConfigColorScheme.cxx | 6 +- chart2/source/tools/DataSeriesHelper.cxx | 44 ++++---- chart2/source/tools/DataSourceHelper.cxx | 16 +-- chart2/source/tools/DiagramHelper.cxx | 120 ++++++++++----------- chart2/source/tools/ErrorBar.cxx | 6 +- chart2/source/tools/MediaDescriptorHelper.cxx | 4 +- chart2/source/tools/ObjectIdentifier.cxx | 11 +- chart2/source/tools/RangeHighlighter.cxx | 8 +- chart2/source/tools/ReferenceSizeProvider.cxx | 30 +++--- chart2/source/tools/RegressionCurveHelper.cxx | 60 +++++------ chart2/source/tools/TitleHelper.cxx | 6 +- chart2/source/tools/WrappedPropertySet.cxx | 10 +- chart2/source/view/axes/VCartesianGrid.cxx | 6 +- chart2/source/view/axes/VCoordinateSystem.cxx | 9 +- chart2/source/view/charttypes/VSeriesPlotter.cxx | 19 ++-- chart2/source/view/main/ShapeFactory.cxx | 13 ++- chart2/source/view/main/VDataSeries.cxx | 8 +- chart2/workbench/addin/sampleaddin.cxx | 2 +- 47 files changed, 450 insertions(+), 504 deletions(-) diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx index f960edf8b1a0..84a38b258733 100644 --- a/chart2/qa/extras/chart2export.cxx +++ b/chart2/qa/extras/chart2export.cxx @@ -775,15 +775,15 @@ void Chart2ExportTest::testEmbeddingsGrabBag() const char* const testEmbeddedFileNames[] {"word/embeddings/Microsoft_Excel_Worksheet3.xlsx", "word/embeddings/Microsoft_Excel_Worksheet2.xlsx", "word/embeddings/Microsoft_Excel_Worksheet1.xlsx"}; - for(int i = 0; i < aGrabBag.getLength(); ++i) + for(beans::PropertyValue const & prop : std::as_const(aGrabBag)) { - if (aGrabBag[i].Name == "OOXEmbeddings") + if (prop.Name == "OOXEmbeddings") { bEmbeddings = true; uno::Sequence aEmbeddingsList(0); uno::Reference aEmbeddingXlsxStream; OUString aEmbeddedfileName; - CPPUNIT_ASSERT(aGrabBag[i].Value >>= aEmbeddingsList); // PropertyValue of proper type + CPPUNIT_ASSERT(prop.Value >>= aEmbeddingsList); // PropertyValue of proper type sal_Int32 length = aEmbeddingsList.getLength(); CPPUNIT_ASSERT_EQUAL(sal_Int32(3), length); for(int j = 0; j < length; ++j) @@ -1513,15 +1513,15 @@ void Chart2ExportTest::testEmbeddingsOleObjectGrabBag() CPPUNIT_ASSERT(aGrabBag.hasElements()); // Grab Bag not empty bool bEmbeddings = false; const char* const testEmbeddedFileNames[] = {"word/embeddings/oleObject1.bin"}; - for(int i = 0; i < aGrabBag.getLength(); ++i) + for(beans::PropertyValue const & prop : std::as_const(aGrabBag)) { - if (aGrabBag[i].Name == "OOXEmbeddings") + if (prop.Name == "OOXEmbeddings") { bEmbeddings = true; uno::Sequence aEmbeddingsList(0); uno::Reference aEmbeddingXlsxStream; OUString aEmbeddedfileName; - CPPUNIT_ASSERT(aGrabBag[i].Value >>= aEmbeddingsList); // PropertyValue of proper type + CPPUNIT_ASSERT(prop.Value >>= aEmbeddingsList); // PropertyValue of proper type sal_Int32 length = aEmbeddingsList.getLength(); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), length); for(int j = 0; j < length; ++j) diff --git a/chart2/qa/extras/charttest.hxx b/chart2/qa/extras/charttest.hxx index ad2802773cf0..9b8e98a48f96 100644 --- a/chart2/qa/extras/charttest.hxx +++ b/chart2/qa/extras/charttest.hxx @@ -329,11 +329,11 @@ Reference< chart2::data::XDataSequence > getLabelDataSequenceFromDoc( getDataSeriesFromDoc( xChartDoc, nDataSeries, nChartType ); CPPUNIT_ASSERT(xDataSeries.is()); Reference< chart2::data::XDataSource > xDataSource( xDataSeries, uno::UNO_QUERY_THROW ); - Sequence< Reference< chart2::data::XLabeledDataSequence > > xDataSequences = + const Sequence< Reference< chart2::data::XLabeledDataSequence > > xDataSequences = xDataSource->getDataSequences(); - for(sal_Int32 i = 0; i < xDataSequences.getLength(); ++i) + for(auto const & lds : xDataSequences) { - Reference< chart2::data::XDataSequence> xLabelSeq = xDataSequences[i]->getLabel(); + Reference< chart2::data::XDataSequence> xLabelSeq = lds->getLabel(); if(!xLabelSeq.is()) continue; @@ -351,11 +351,11 @@ Reference< chart2::data::XDataSequence > getDataSequenceFromDocByRole( getDataSeriesFromDoc( xChartDoc, nDataSeries, nChartType ); CPPUNIT_ASSERT(xDataSeries.is()); Reference< chart2::data::XDataSource > xDataSource( xDataSeries, uno::UNO_QUERY_THROW ); - Sequence< Reference< chart2::data::XLabeledDataSequence > > xDataSequences = + const Sequence< Reference< chart2::data::XLabeledDataSequence > > xDataSequences = xDataSource->getDataSequences(); - for(sal_Int32 i = 0; i < xDataSequences.getLength(); ++i) + for(auto const & lds : xDataSequences) { - Reference< chart2::data::XDataSequence> xLabelSeq = xDataSequences[i]->getValues(); + Reference< chart2::data::XDataSequence> xLabelSeq = lds->getValues(); uno::Reference< beans::XPropertySet > xProps(xLabelSeq, uno::UNO_QUERY); if(!xProps.is()) continue; @@ -389,20 +389,20 @@ std::vector > getDataSeriesYValuesFromChartType( const Refer { Reference xDSCont(xCT, uno::UNO_QUERY); CPPUNIT_ASSERT(xDSCont.is()); - Sequence > aDataSeriesSeq = xDSCont->getDataSeries(); + const Sequence > aDataSeriesSeq = xDSCont->getDataSeries(); double fNan; rtl::math::setNan(&fNan); std::vector > aRet; - for (sal_Int32 i = 0; i < aDataSeriesSeq.getLength(); ++i) + for (uno::Reference const & ds : aDataSeriesSeq) { - uno::Reference xDSrc(aDataSeriesSeq[i], uno::UNO_QUERY); + uno::Reference xDSrc(ds, uno::UNO_QUERY); CPPUNIT_ASSERT(xDSrc.is()); - uno::Sequence > aDataSeqs = xDSrc->getDataSequences(); - for (sal_Int32 j = 0; j < aDataSeqs.getLength(); ++j) + const uno::Sequence > aDataSeqs = xDSrc->getDataSequences(); + for (auto const & lds : aDataSeqs) { - Reference xValues = aDataSeqs[j]->getValues(); + Reference xValues = lds->getValues(); CPPUNIT_ASSERT(xValues.is()); Reference xPropSet(xValues, uno::UNO_QUERY); if (!xPropSet.is()) @@ -412,13 +412,13 @@ std::vector > getDataSeriesYValuesFromChartType( const Refer xPropSet->getPropertyValue("Role") >>= aRoleName; if (aRoleName == "values-y") { - uno::Sequence aData = xValues->getData(); + const uno::Sequence aData = xValues->getData(); std::vector aValues; aValues.reserve(aData.getLength()); - for (sal_Int32 nVal = 0; nVal < aData.getLength(); ++nVal) + for (uno::Any const & any : aData) { double fVal; - if (aData[nVal] >>= fVal) + if (any >>= fVal) aValues.push_back(fVal); else aValues.push_back(fNan); @@ -437,17 +437,17 @@ std::vector > getDataSeriesLabelsFromChartType( const Re Reference xDSCont(xCT, uno::UNO_QUERY); CPPUNIT_ASSERT(xDSCont.is()); - Sequence > aDataSeriesSeq = xDSCont->getDataSeries(); + const Sequence > aDataSeriesSeq = xDSCont->getDataSeries(); std::vector > aRet; - for (sal_Int32 i = 0; i < aDataSeriesSeq.getLength(); ++i) + for (auto const & ds : aDataSeriesSeq) { - uno::Reference xDSrc(aDataSeriesSeq[i], uno::UNO_QUERY); + uno::Reference xDSrc(ds, uno::UNO_QUERY); CPPUNIT_ASSERT(xDSrc.is()); - uno::Sequence > aDataSeqs = xDSrc->getDataSequences(); - for (sal_Int32 j = 0; j < aDataSeqs.getLength(); ++j) + const uno::Sequence > aDataSeqs = xDSrc->getDataSequences(); + for (auto const & lds : aDataSeqs) { - Reference xValues = aDataSeqs[j]->getValues(); + Reference xValues = lds->getValues(); CPPUNIT_ASSERT(xValues.is()); Reference xPropSet(xValues, uno::UNO_QUERY); if (!xPropSet.is()) @@ -457,7 +457,7 @@ std::vector > getDataSeriesLabelsFromChartType( const Re xPropSet->getPropertyValue("Role") >>= aRoleName; if (aRoleName == aLabelRole) { - Reference xLabel = aDataSeqs[j]; + Reference xLabel = lds; CPPUNIT_ASSERT(xLabel.is()); Reference xDS2 = xLabel->getLabel(); CPPUNIT_ASSERT(xDS2.is()); @@ -544,10 +544,10 @@ OUString getTitleString( const Reference& xTitled ) { uno::Reference xTitle = xTitled->getTitleObject(); CPPUNIT_ASSERT(xTitle.is()); - uno::Sequence > aFSSeq = xTitle->getText(); + const uno::Sequence > aFSSeq = xTitle->getText(); OUString aText; - for (sal_Int32 i = 0; i < aFSSeq.getLength(); ++i) - aText += aFSSeq[i]->getString(); + for (auto const & fs : aFSSeq) + aText += fs->getString(); return aText; } diff --git a/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx b/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx index 8b6d614be1dd..a0f39774b5f1 100644 --- a/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx @@ -157,11 +157,10 @@ void SAL_CALL MinMaxLineWrapper::setPropertyValue( const OUString& rPropertyName Reference< beans::XPropertySet > xPropSet; Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); - Sequence< Reference< chart2::XChartType > > aTypes( + const Sequence< Reference< chart2::XChartType > > aTypes( ::chart::DiagramHelper::getChartTypesFromDiagram( xDiagram ) ); - for( sal_Int32 nN = 0; nN < aTypes.getLength(); nN++ ) + for( Reference< chart2::XChartType > const & xType : aTypes ) { - Reference< chart2::XChartType > xType( aTypes[nN] ); if( xType->getChartType() == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ) { Reference< chart2::XDataSeriesContainer > xSeriesContainer(xType,uno::UNO_QUERY); @@ -195,11 +194,10 @@ uno::Any SAL_CALL MinMaxLineWrapper::getPropertyValue( const OUString& rProperty Reference< beans::XPropertySet > xPropSet; Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); - Sequence< Reference< chart2::XChartType > > aTypes( + const Sequence< Reference< chart2::XChartType > > aTypes( ::chart::DiagramHelper::getChartTypesFromDiagram( xDiagram ) ); - for( sal_Int32 nN = 0; nN < aTypes.getLength(); nN++ ) + for( Reference< chart2::XChartType > const & xType : aTypes ) { - Reference< chart2::XChartType > xType( aTypes[nN] ); if( xType->getChartType() == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ) { Reference< chart2::XDataSeriesContainer > xSeriesContainer(xType,uno::UNO_QUERY); @@ -344,18 +342,16 @@ uno::Any SAL_CALL MinMaxLineWrapper::getPropertyDefault( const OUString& rProper void SAL_CALL MinMaxLineWrapper::setAllPropertiesToDefault( ) { const Sequence< beans::Property >& rPropSeq = *StaticMinMaxLineWrapperPropertyArray::get(); - for(sal_Int32 nN=0; nN& rNameSeq ) { - for(sal_Int32 nN=0; nN SAL_CALL MinMaxLineWrapper::getPropertyDefaults( const uno::Sequence< OUString >& rNameSeq ) diff --git a/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx b/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx index 5355c72150c5..7de1b376b3ef 100644 --- a/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx @@ -90,12 +90,12 @@ Any WrappedTitleStringProperty::getPropertyValue( const Reference< beans::XPrope Reference< chart2::XTitle > xTitle(xInnerPropertySet,uno::UNO_QUERY); if(xTitle.is()) { - Sequence< Reference< chart2::XFormattedString > > aStrings( xTitle->getText()); + const Sequence< Reference< chart2::XFormattedString > > aStrings( xTitle->getText()); OUStringBuffer aBuf; - for( sal_Int32 i = 0; i < aStrings.getLength(); ++i ) + for( Reference< chart2::XFormattedString > const & formattedStr : aStrings ) { - aBuf.append( aStrings[ i ]->getString()); + aBuf.append( formattedStr->getString()); } aRet <<= aBuf.makeStringAndClear(); } @@ -311,12 +311,12 @@ void TitleWrapper::setFastCharacterPropertyValue( if( !xTitle.is()) return; - Sequence< Reference< chart2::XFormattedString > > aStrings( xTitle->getText()); + const Sequence< Reference< chart2::XFormattedString > > aStrings( xTitle->getText()); const WrappedProperty* pWrappedProperty = getWrappedProperty( nHandle ); - for( sal_Int32 i = 0; i < aStrings.getLength(); ++i ) + for( Reference< chart2::XFormattedString > const & formattedStr : aStrings ) { - Reference< beans::XFastPropertySet > xFastPropertySet( aStrings[ i ], uno::UNO_QUERY ); + Reference< beans::XFastPropertySet > xFastPropertySet( formattedStr, uno::UNO_QUERY ); Reference< beans::XPropertySet > xPropSet( xFastPropertySet, uno::UNO_QUERY ); if( pWrappedProperty ) diff --git a/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx b/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx index 29c81bec0b23..ab7e5b333a2c 100644 --- a/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx @@ -162,14 +162,13 @@ void SAL_CALL UpDownBarWrapper::setPropertyValue( const OUString& rPropertyName, { Reference< beans::XPropertySet > xPropSet; - Sequence< Reference< chart2::XChartType > > aTypes( + const Sequence< Reference< chart2::XChartType > > aTypes( ::chart::DiagramHelper::getChartTypesFromDiagram( m_spChart2ModelContact->getChart2Diagram() ) ); - for( sal_Int32 nN = 0; nN < aTypes.getLength(); nN++ ) + for( Reference< chart2::XChartType > const & xType : aTypes ) { - Reference< chart2::XChartType > xType( aTypes[nN] ); if( xType->getChartType() == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ) { - Reference< beans::XPropertySet > xTypeProps( aTypes[nN], uno::UNO_QUERY ); + Reference< beans::XPropertySet > xTypeProps( xType, uno::UNO_QUERY ); if(xTypeProps.is()) { xTypeProps->getPropertyValue( m_aPropertySetName ) >>= xPropSet; @@ -185,14 +184,13 @@ uno::Any SAL_CALL UpDownBarWrapper::getPropertyValue( const OUString& rPropertyN Reference< beans::XPropertySet > xPropSet; - Sequence< Reference< chart2::XChartType > > aTypes( + const Sequence< Reference< chart2::XChartType > > aTypes( ::chart::DiagramHelper::getChartTypesFromDiagram( m_spChart2ModelContact->getChart2Diagram() ) ); - for( sal_Int32 nN = 0; nN < aTypes.getLength(); nN++ ) + for( Reference< chart2::XChartType > const & xType : aTypes ) { - Reference< chart2::XChartType > xType( aTypes[nN] ); if( xType->getChartType() == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ) { - Reference< beans::XPropertySet > xTypeProps( aTypes[nN], uno::UNO_QUERY ); + Reference< beans::XPropertySet > xTypeProps( xType, uno::UNO_QUERY ); if(xTypeProps.is()) { xTypeProps->getPropertyValue( m_aPropertySetName ) >>= xPropSet; @@ -311,18 +309,16 @@ uno::Any SAL_CALL UpDownBarWrapper::getPropertyDefault( const OUString& rPropert void SAL_CALL UpDownBarWrapper::setAllPropertiesToDefault( ) { const Sequence< beans::Property >& rPropSeq = *StaticUpDownBarWrapperPropertyArray::get(); - for(sal_Int32 nN=0; nN& rNameSeq ) { - for(sal_Int32 nN=0; nN SAL_CALL UpDownBarWrapper::getPropertyDefaults( const uno::Sequence< OUString >& rNameSeq ) diff --git a/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx index 044dcf28fd5b..63abadee1b85 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx @@ -71,12 +71,12 @@ void WrappedBarPositionProperty_Base::setPropertyValue( const Any& rOuterValue, if( m_nDimensionIndex!=1 ) return; - Sequence< Reference< chart2::XChartType > > aChartTypeList( DiagramHelper::getChartTypesFromDiagram( xDiagram ) ); - for( sal_Int32 nN = 0; nN < aChartTypeList.getLength(); nN++ ) + const Sequence< Reference< chart2::XChartType > > aChartTypeList( DiagramHelper::getChartTypesFromDiagram( xDiagram ) ); + for( Reference< chart2::XChartType > const & chartType : aChartTypeList ) { try { - Reference< beans::XPropertySet > xProp( aChartTypeList[nN], uno::UNO_QUERY ); + Reference< beans::XPropertySet > xProp( chartType, uno::UNO_QUERY ); if( xProp.is() ) { Sequence< sal_Int32 > aBarPositionSequence; diff --git a/chart2/source/controller/dialogs/DataBrowserModel.cxx b/chart2/source/controller/dialogs/DataBrowserModel.cxx index 0fad7561bdc1..c8359f74ab23 100644 --- a/chart2/source/controller/dialogs/DataBrowserModel.cxx +++ b/chart2/source/controller/dialogs/DataBrowserModel.cxx @@ -107,12 +107,12 @@ bool lcl_SequenceOfSeriesIsShared( OUString aValuesRole( lcl_getRole( xValues )); OUString aValuesRep( xValues->getSourceRangeRepresentation()); Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY_THROW ); - Sequence< Reference< chart2::data::XLabeledDataSequence > > aLSeq( xSource->getDataSequences()); - for( sal_Int32 i=0; i > aLSeq( xSource->getDataSequences()); + for( Reference< chart2::data::XLabeledDataSequence > const & labeledDataSeq : aLSeq ) + if (labeledDataSeq.is() && DataSeriesHelper::getRole(labeledDataSeq) == aValuesRole) { // getValues().is(), because lcl_getRole checked that already - bResult = (aValuesRep == aLSeq[i]->getValues()->getSourceRangeRepresentation()); + bResult = (aValuesRep == labeledDataSeq->getValues()->getSourceRangeRepresentation()); // assumption: a role appears only once in a series break; } @@ -136,10 +136,10 @@ lcl_tSharedSeqVec lcl_getSharedSequences( const Sequence< Reference< chart2::XDa return aResult; Reference< chart2::data::XDataSource > xSource( rSeries[0], uno::UNO_QUERY ); - Sequence< Reference< chart2::data::XLabeledDataSequence > > aLSeq( xSource->getDataSequences()); - for( sal_Int32 nIdx=0; nIdx > aLSeq( xSource->getDataSequences()); + for( Reference< chart2::data::XLabeledDataSequence > const & labeledDataSeq : aLSeq ) { - Reference< chart2::data::XDataSequence > xValues( aLSeq[nIdx]->getValues()); + Reference< chart2::data::XDataSequence > xValues( labeledDataSeq->getValues()); bool bShared = true; for( sal_Int32 nSeriesIdx=1; nSeriesIdx aSequenceIndexesToDelete; - Sequence > aSequencesOfDeleted = xSourceOfDeleted->getDataSequences(); - for (sal_Int32 i = 0; i < aSequencesOfDeleted.getLength(); ++i) + const Sequence > aSequencesOfDeleted = xSourceOfDeleted->getDataSequences(); + for (auto const & labeledDataSeq : aSequencesOfDeleted) { // if not used by the remaining series this sequence can be deleted if( std::none_of( aAllDataSeqs.begin(), aAllDataSeqs.end(), - lcl_RepresentationsOfLSeqMatch( aSequencesOfDeleted[i] )) ) - aSequenceIndexesToDelete.push_back( lcl_getValuesRepresentationIndex( aSequencesOfDeleted[i] ) ); + lcl_RepresentationsOfLSeqMatch( labeledDataSeq )) ) + aSequenceIndexesToDelete.push_back( lcl_getValuesRepresentationIndex( labeledDataSeq ) ); } // delete unnecessary sequences of the internal data @@ -809,12 +809,12 @@ void DataBrowserModel::updateFromModel() Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY ); if( !xCooSysCnt.is()) return; - Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems()); - for( sal_Int32 nCooSysIdx=0; nCooSysIdx > aCooSysSeq( xCooSysCnt->getCoordinateSystems()); + for( Reference< chart2::XCoordinateSystem > const & coords : aCooSysSeq ) { - Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[nCooSysIdx], uno::UNO_QUERY_THROW ); - Sequence< Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes()); - sal_Int32 nXAxisNumberFormat = DataSeriesHelper::getNumberFormatKeyFromAxis( nullptr, aCooSysSeq[nCooSysIdx], 0, 0 ); + Reference< chart2::XChartTypeContainer > xCTCnt( coords, uno::UNO_QUERY_THROW ); + const Sequence< Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes()); + sal_Int32 nXAxisNumberFormat = DataSeriesHelper::getNumberFormatKeyFromAxis( nullptr, coords, 0, 0 ); for( sal_Int32 nCTIdx=0; nCTIdx > aSeries( xSeriesCnt->getDataSeries()); + const Sequence< Reference< chart2::XDataSeries > > aSeries( xSeriesCnt->getDataSeries()); lcl_tSharedSeqVec aSharedSequences( lcl_getSharedSequences( aSeries )); for (auto const& sharedSequence : aSharedSequences) { @@ -838,10 +838,10 @@ void DataBrowserModel::updateFromModel() m_aColumns.push_back( aSharedSequence ); ++nHeaderStart; } - for( sal_Int32 nSeriesIdx=0; nSeriesIdx const & dataSeries : aSeries ) { tDataColumnVector::size_type nStartColIndex = m_aColumns.size(); - Reference< chart2::XDataSeries > xSeries( aSeries[nSeriesIdx] ); + Reference< chart2::XDataSeries > xSeries( dataSeries ); Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY ); if( xSource.is()) { @@ -853,7 +853,7 @@ void DataBrowserModel::updateFromModel() // @todo: dimension index 1 for y-values used here. This is just a guess sal_Int32 nYAxisNumberFormatKey = DataSeriesHelper::getNumberFormatKeyFromAxis( - aSeries[nSeriesIdx], aCooSysSeq[nCooSysIdx], 1 ); + dataSeries, coords, 1 ); sal_Int32 nSeqIdx=0; for( ; nSeqIdx xProp( aCooSysSeq[nCooSysIdx], uno::UNO_QUERY ); + Reference< beans::XPropertySet > xProp( coords, uno::UNO_QUERY ); xProp->getPropertyValue( "SwapXAndYAxis" ) >>= bSwapXAndYAxis; } catch( const beans::UnknownPropertyException & ) {} // add ranges for error bars if present for a series - if( StatisticsHelper::usesErrorBarRanges( aSeries[nSeriesIdx] )) - addErrorBarRanges( aSeries[nSeriesIdx], nYAxisNumberFormatKey, nSeqIdx, nHeaderEnd, true ); + if( StatisticsHelper::usesErrorBarRanges( dataSeries )) + addErrorBarRanges( dataSeries, nYAxisNumberFormatKey, nSeqIdx, nHeaderEnd, true ); - if( StatisticsHelper::usesErrorBarRanges( aSeries[nSeriesIdx], /* bYError = */ false )) - addErrorBarRanges( aSeries[nSeriesIdx], nYAxisNumberFormatKey, nSeqIdx, nHeaderEnd, false ); + if( StatisticsHelper::usesErrorBarRanges( dataSeries, /* bYError = */ false )) + addErrorBarRanges( dataSeries, nYAxisNumberFormatKey, nSeqIdx, nHeaderEnd, false ); m_aHeaders.emplace_back( - aSeries[nSeriesIdx], + dataSeries, aChartTypes[nCTIdx], bSwapXAndYAxis, nHeaderStart, diff --git a/chart2/source/controller/dialogs/DialogModel.cxx b/chart2/source/controller/dialogs/DialogModel.cxx index db50eab8b9ed..5c8678bc9f5b 100644 --- a/chart2/source/controller/dialogs/DialogModel.cxx +++ b/chart2/source/controller/dialogs/DialogModel.cxx @@ -140,17 +140,17 @@ struct lcl_DataSeriesContainerAppend { if( xVal.is()) { - Sequence< Reference< XDataSeries > > aSeq( xVal->getDataSeries()); + const Sequence< Reference< XDataSeries > > aSeq( xVal->getDataSeries()); OUString aRole( "values-y" ); Reference< XChartType > xCT( xVal, uno::UNO_QUERY ); if( xCT.is()) aRole = xCT->getRoleOfSequenceForSeriesLabel(); - for( sal_Int32 nI = 0; nI < aSeq.getLength(); ++ nI ) + for( Reference< XDataSeries > const & dataSeries : aSeq ) { m_rDestCnt->push_back( ::chart::DialogModel::tSeriesWithChartTypeByName( - ::chart::DataSeriesHelper::getDataSeriesLabel( aSeq[nI], aRole ), - std::make_pair( aSeq[nI], xCT ))); + ::chart::DataSeriesHelper::getDataSeriesLabel( dataSeries, aRole ), + std::make_pair( dataSeries, xCT ))); } } } @@ -311,16 +311,15 @@ Reference< XDataSeries > lcl_CreateNewSeries( const OUString aLabel(::chart::SchResId(STR_DATA_UNNAMED_SERIES)); const Sequence< OUString > aRoles( xChartType->getSupportedMandatoryRoles()); const Sequence< OUString > aOptRoles( xChartType->getSupportedOptionalRoles()); - sal_Int32 nI = 0; - for(nI=0; nI xSeq( ::chart::DataSourceHelper::createCachedDataSequence() ); - lcl_SetSequenceRole( xSeq, aRoles[nI] ); + lcl_SetSequenceRole( xSeq, role ); // assert that aRoleOfSeqForSeriesLabel is part of the mandatory roles - if( aRoles[nI] == aRoleOfSeqForSeriesLabel ) + if( role == aRoleOfSeqForSeriesLabel ) { Reference< data::XDataSequence > xLabel( ::chart::DataSourceHelper::createCachedDataSequence( aLabel )); lcl_SetSequenceRole( xLabel, lcl_aLabelRole ); @@ -330,12 +329,12 @@ Reference< XDataSeries > lcl_CreateNewSeries( aNewSequences.push_back( ::chart::DataSourceHelper::createLabeledDataSequence( xSeq )); } - for(nI=0; nI xSeq( ::chart::DataSourceHelper::createCachedDataSequence()); - lcl_SetSequenceRole( xSeq, aOptRoles[nI] ); + lcl_SetSequenceRole( xSeq, role ); aNewSequences.push_back( ::chart::DataSourceHelper::createLabeledDataSequence( xSeq )); } @@ -428,11 +427,11 @@ std::vector< Reference< XDataSeriesContainer > > { 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 const & coords : aCooSysSeq ) { - Reference< XChartTypeContainer > xCTCnt( aCooSysSeq[i], uno::UNO_QUERY_THROW ); + Reference< XChartTypeContainer > xCTCnt( coords, uno::UNO_QUERY_THROW ); Sequence< Reference< XChartType > > aChartTypeSeq( xCTCnt->getChartTypes()); std::transform( aChartTypeSeq.begin(), aChartTypeSeq.end(), @@ -465,10 +464,10 @@ namespace { void addMissingRoles(DialogModel::tRolesWithRanges& rResult, const uno::Sequence& rRoles) { - for(sal_Int32 i = 0, n = rRoles.getLength(); i < n; ++i) + for(OUString const & role : rRoles) { - if(rResult.find(rRoles[i]) == rResult.end()) - rResult.emplace(rRoles[i], OUString()); + if(rResult.find(role) == rResult.end()) + rResult.emplace(role, OUString()); } } diff --git a/chart2/source/controller/dialogs/tp_AxisPositions.cxx b/chart2/source/controller/dialogs/tp_AxisPositions.cxx index eeb8e19a96be..89b8c3899881 100644 --- a/chart2/source/controller/dialogs/tp_AxisPositions.cxx +++ b/chart2/source/controller/dialogs/tp_AxisPositions.cxx @@ -126,8 +126,8 @@ void AxisPositionsTabPage::Reset(const SfxItemSet* rInAttrs) m_xED_CrossesAtCategory->set_visible( m_bCrossingAxisIsCategoryAxis ); if (m_bCrossingAxisIsCategoryAxis) { - for( sal_Int32 nN=0; nNappend_text(m_aCategories[nN]); + for( auto const & cat : std::as_const(m_aCategories) ) + m_xED_CrossesAtCategory->append_text(cat); } if( m_xLB_CrossesAt->get_count() > 3 ) diff --git a/chart2/source/controller/dialogs/tp_DataSource.cxx b/chart2/source/controller/dialogs/tp_DataSource.cxx index d09fcf81ff87..b6ebe98d08d8 100644 --- a/chart2/source/controller/dialogs/tp_DataSource.cxx +++ b/chart2/source/controller/dialogs/tp_DataSource.cxx @@ -140,15 +140,15 @@ Reference< chart2::data::XLabeledDataSequence > lcl_findLSequenceWithOnlyLabel( const Reference< chart2::data::XDataSource > & xDataSource ) { Reference< chart2::data::XLabeledDataSequence > xResult; - Sequence< Reference< chart2::data::XLabeledDataSequence > > aSequences( xDataSource->getDataSequences()); + const Sequence< Reference< chart2::data::XLabeledDataSequence > > aSequences( xDataSource->getDataSequences()); - for( sal_Int32 i=0; i const & labeledDataSeq : aSequences ) { // no values are set but a label exists - if( ! aSequences[i]->getValues().is() && - aSequences[i]->getLabel().is()) + if( ! labeledDataSeq->getValues().is() && + labeledDataSeq->getLabel().is()) { - xResult.set( aSequences[i] ); + xResult.set( labeledDataSeq ); break; } } diff --git a/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx b/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx index 244cbf9a23bb..8351e5bf02ab 100644 --- a/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx +++ b/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx @@ -50,10 +50,10 @@ AllAxisItemConverter::AllAxisItemConverter( : MultipleItemConverter( rItemPool ) { Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); - Sequence< Reference< XAxis > > aElementList( AxisHelper::getAllAxesOfDiagram( xDiagram ) ); - for( sal_Int32 nA = 0; nA < aElementList.getLength(); nA++ ) + const Sequence< Reference< XAxis > > aElementList( AxisHelper::getAllAxesOfDiagram( xDiagram ) ); + for( Reference< XAxis > const & axis : aElementList ) { - uno::Reference< beans::XPropertySet > xObjectProperties(aElementList[nA], uno::UNO_QUERY); + uno::Reference< beans::XPropertySet > xObjectProperties(axis, uno::UNO_QUERY); m_aConverters.emplace_back( new ::chart::wrapper::AxisItemConverter( xObjectProperties, rItemPool, rDrawModel, uno::Reference< chart2::XChartDocument >( xChartModel, uno::UNO_QUERY ), nullptr, nullptr, @@ -79,10 +79,9 @@ AllGridItemConverter::AllGridItemConverter( : MultipleItemConverter( rItemPool ) { Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); - Sequence< Reference< beans::XPropertySet > > aElementList( AxisHelper::getAllGrids( xDiagram ) ); - for( sal_Int32 nA = 0; nA < aElementList.getLength(); nA++ ) + const Sequence< Reference< beans::XPropertySet > > aElementList( AxisHelper::getAllGrids( xDiagram ) ); + for( Reference< beans::XPropertySet > const & xObjectProperties : aElementList ) { - Reference< beans::XPropertySet > xObjectProperties(aElementList[nA]); m_aConverters.emplace_back( new ::chart::wrapper::GraphicPropertyItemConverter( xObjectProperties, rItemPool, rDrawModel, xNamedPropertyContainerFactory, ::chart::wrapper::GraphicObjectType::LineProperties ) ); diff --git a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx index e4952bbc0329..d50f39abc3bb 100644 --- a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx @@ -219,8 +219,8 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const Sf if(!bGroupBarsPerAxis) { //set the same value for all axes - for( sal_Int32 nN = 0; nN < aBarPositionSequence.getLength(); nN++ ) - aBarPositionSequence[nN] = rBarPosition; + for( auto & pos : aBarPositionSequence ) + pos = rBarPosition; } else if( nAxisIndex >= 0 && nAxisIndex < aBarPositionSequence.getLength() ) aBarPositionSequence[nAxisIndex] = rBarPosition; diff --git a/chart2/source/controller/itemsetwrapper/TitleItemConverter.cxx b/chart2/source/controller/itemsetwrapper/TitleItemConverter.cxx index 75638edfed22..dfc57623bf2d 100644 --- a/chart2/source/controller/itemsetwrapper/TitleItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/TitleItemConverter.cxx @@ -67,9 +67,9 @@ FormattedStringsConverter::FormattedStringsConverter( MultipleItemConverter( rItemPool ) { bool bHasRefSize = (pRefSize && xParentProp.is()); - for( sal_Int32 i = 0; i < aStrings.getLength(); ++i ) + for( uno::Reference< chart2::XFormattedString > const & formattedStr : aStrings ) { - uno::Reference< beans::XPropertySet > xProp( aStrings[ i ], uno::UNO_QUERY ); + uno::Reference< beans::XPropertySet > xProp( formattedStr, uno::UNO_QUERY ); if( xProp.is()) { if( bHasRefSize ) diff --git a/chart2/source/controller/main/ChartController_Insert.cxx b/chart2/source/controller/main/ChartController_Insert.cxx index 611cd3dbd613..85f7ea5c345e 100644 --- a/chart2/source/controller/main/ChartController_Insert.cxx +++ b/chart2/source/controller/main/ChartController_Insert.cxx @@ -836,9 +836,9 @@ void ChartController::executeDispatch_InsertMinorGrid() Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getModel() ); if( xAxis.is() ) { - Sequence< Reference< beans::XPropertySet > > aSubGrids( xAxis->getSubGridProperties() ); - for( sal_Int32 nN=0; nN > aSubGrids( xAxis->getSubGridProperties() ); + for( Reference< beans::XPropertySet > const & props : aSubGrids) + AxisHelper::makeGridVisible( props ); aUndoGuard.commit(); } } @@ -860,9 +860,9 @@ void ChartController::executeDispatch_DeleteMinorGrid() Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getModel() ); if( xAxis.is() ) { - Sequence< Reference< beans::XPropertySet > > aSubGrids( xAxis->getSubGridProperties() ); - for( sal_Int32 nN=0; nN > aSubGrids( xAxis->getSubGridProperties() ); + for( Reference< beans::XPropertySet > const & props : aSubGrids) + AxisHelper::makeGridInvisible( props ); aUndoGuard.commit(); } } diff --git a/chart2/source/controller/main/ChartModelClone.cxx b/chart2/source/controller/main/ChartModelClone.cxx index 456bd178c81b..6348aee6e6f9 100644 --- a/chart2/source/controller/main/ChartModelClone.cxx +++ b/chart2/source/controller/main/ChartModelClone.cxx @@ -220,11 +220,11 @@ namespace chart Reference< XDataSource > xUsedData( DataSourceHelper::getUsedData( i_model ) ); if ( xUsedData.is() && xNewDataProvider.is() ) { - Sequence< Reference< XLabeledDataSequence > > aData( xUsedData->getDataSequences() ); - for( sal_Int32 i=0; i > aData( xUsedData->getDataSequences() ); + for( Reference< XLabeledDataSequence > const & labeledDataSeq : aData ) { - xNewDataProvider->registerDataSequenceForChanges( aData[i]->getValues() ); - xNewDataProvider->registerDataSequenceForChanges( aData[i]->getLabel() ); + xNewDataProvider->registerDataSequenceForChanges( labeledDataSeq->getValues() ); + xNewDataProvider->registerDataSequenceForChanges( labeledDataSeq->getLabel() ); } } } diff --git a/chart2/source/controller/main/ObjectHierarchy.cxx b/chart2/source/controller/main/ObjectHierarchy.cxx index 15b5392153b3..32762762e827 100644 --- a/chart2/source/controller/main/ObjectHierarchy.cxx +++ b/chart2/source/controller/main/ObjectHierarchy.cxx @@ -238,9 +238,9 @@ void ImplObjectHierarchy::createTree( const Reference< XChartDocument >& xChartD if( !m_bOrderingForElementSelector ) { // Axis Titles. Note: These are interpreted of being top level - Sequence< Reference< XAxis > > aAxes( AxisHelper::getAllAxesOfDiagram( xDiagram ) ); - for( sal_Int32 i=0; i > aAxes( AxisHelper::getAllAxesOfDiagram( xDiagram ) ); + for( Reference< XAxis > const & axis : aAxes ) + lcl_addAxisTitle( axis, aTopLevelContainer, xModel ); // Diagram aTopLevelContainer.push_back( aDiaOID ); @@ -319,9 +319,8 @@ void ImplObjectHierarchy::createAxesTree( aAxes = AxisHelper::getAllAxesOfDiagram( xDiagram ); // Grids Reference< frame::XModel > xChartModel = xChartDoc; - for( sal_Int32 nA=0; nA const & xAxis : std::as_const(aAxes) ) { - Reference< XAxis > xAxis( aAxes[nA] ); if(!xAxis.is()) continue; @@ -339,7 +338,7 @@ void ImplObjectHierarchy::createAxesTree( rContainer.emplace_back( ObjectIdentifier::createClassifiedIdentifierForObject( xAxis, xChartModel ) ); // axis title - lcl_addAxisTitle( aAxes[nA], rContainer, xChartModel ); + lcl_addAxisTitle( xAxis, rContainer, xChartModel ); } Reference< beans::XPropertySet > xGridProperties( xAxis->getGridProperties() ); diff --git a/chart2/source/model/filter/XMLFilter.cxx b/chart2/source/model/filter/XMLFilter.cxx index 3126eca15a1b..a8633cc2d3d3 100644 --- a/chart2/source/model/filter/XMLFilter.cxx +++ b/chart2/source/model/filter/XMLFilter.cxx @@ -335,17 +335,17 @@ ErrCode XMLFilter::impl_Import( uno::Reference const xModel(m_xTargetDoc, uno::UNO_QUERY); if( xModel.is() ) { - uno::Sequence< beans::PropertyValue > aModProps = xModel->getArgs(); - for( sal_Int32 nInd = 0; nInd < aModProps.getLength(); nInd++ ) + const uno::Sequence< beans::PropertyValue > aModProps = xModel->getArgs(); + for( beans::PropertyValue const & prop : aModProps ) { - if( aModProps[nInd].Name == "HierarchicalDocumentName" ) + if( prop.Name == "HierarchicalDocumentName" ) { // Actually this argument only has meaning for embedded documents - aModProps[nInd].Value >>= aHierarchName; + prop.Value >>= aHierarchName; } - else if( aModProps[nInd].Name == "DocumentBaseURL" ) + else if( prop.Name == "DocumentBaseURL" ) { - aModProps[nInd].Value >>= aBaseUri; + prop.Value >>= aBaseUri; } } } diff --git a/chart2/source/model/main/ChartModel_Persistence.cxx b/chart2/source/model/main/ChartModel_Persistence.cxx index 21b61c89cdbc..b3dd7a7cfeeb 100644 --- a/chart2/source/model/main/ChartModel_Persistence.cxx +++ b/chart2/source/model/main/ChartModel_Persistence.cxx @@ -600,13 +600,13 @@ void ChartModel::impl_loadGraphics( const uno::Sequence< OUString > aElementNames( xGraphicsStorage->getElementNames() ); - for( int i = 0; i < aElementNames.getLength(); ++i ) + for( OUString const & streamName : aElementNames ) { - if( xGraphicsStorage->isStreamElement( aElementNames[ i ] ) ) + if( xGraphicsStorage->isStreamElement( streamName ) ) { uno::Reference< io::XStream > xElementStream( xGraphicsStorage->openStreamElement( - aElementNames[ i ], + streamName, embed::ElementModes::READ ) ); if( xElementStream.is() ) 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 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( 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( getDataSeries() ); + for( auto const & i : aOldSeries ) + ModifyListenerHelper::removeListener( i, m_xModifyEventForwarder ); m_aDataSeries.clear(); - for( sal_Int32 i=0; i& 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( 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= 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( 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 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 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 const & coords : aCooSysSeq ) { - Reference< XChartTypeContainer > xCTCnt( aCooSysSeq[i], uno::UNO_QUERY_THROW ); - Sequence< Reference< XChartType > > aChartTypeSeq( xCTCnt->getChartTypes()); - for( sal_Int32 j=0; j 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 > aSeries( FlattenSequence( aInterpretedData.Series )); - for( sal_Int32 i=0; i > 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( 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 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 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 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 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 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 const & coords : aCooSysSeq ) { - Reference< XChartTypeContainer > xCTCnt( aCooSysSeq[i], uno::UNO_QUERY_THROW ); - Sequence< Reference< XChartType > > aChartTypeSeq( xCTCnt->getChartTypes()); - for( sal_Int32 j=0; j 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 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 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( 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; diff --git a/chart2/source/tools/AxisHelper.cxx b/chart2/source/tools/AxisHelper.cxx index 2f9a14c0442f..1d6e57d1913c 100644 --- a/chart2/source/tools/AxisHelper.cxx +++ b/chart2/source/tools/AxisHelper.cxx @@ -243,16 +243,15 @@ sal_Int32 AxisHelper::getExplicitNumberFormatKeyForAxis( OUString aRoleToMatch; if( nDimensionIndex == 0 ) aRoleToMatch = "values-x"; - Sequence< Reference< XChartType > > aChartTypes( xCTCnt->getChartTypes()); - for( sal_Int32 nCTIdx=0; nCTIdx > aChartTypes( xCTCnt->getChartTypes()); + for( Reference< XChartType > const & chartType : aChartTypes ) { if( nDimensionIndex != 0 ) - aRoleToMatch = ChartTypeHelper::getRoleOfSequenceForYAxisNumberFormatDetection( aChartTypes[nCTIdx] ); - Reference< XDataSeriesContainer > xDSCnt( aChartTypes[nCTIdx], uno::UNO_QUERY_THROW ); - Sequence< Reference< XDataSeries > > aDataSeriesSeq( xDSCnt->getDataSeries()); - for( sal_Int32 nSeriesIdx=0; nSeriesIdx xDSCnt( chartType, uno::UNO_QUERY_THROW ); + const Sequence< Reference< XDataSeries > > aDataSeriesSeq( xDSCnt->getDataSeries()); + for( Reference< chart2::XDataSeries > const & xDataSeries : aDataSeriesSeq ) { - Reference< chart2::XDataSeries > xDataSeries(aDataSeriesSeq[nSeriesIdx]); Reference< data::XDataSource > xSource( xDataSeries, uno::UNO_QUERY_THROW ); if( nDimensionIndex == 1 ) @@ -457,9 +456,9 @@ void AxisHelper::showGrid( sal_Int32 nDimensionIndex, sal_Int32 nCooSysIndex, bo AxisHelper::makeGridVisible( xAxis->getGridProperties() ); else { - Sequence< Reference< beans::XPropertySet > > aSubGrids( xAxis->getSubGridProperties() ); - for( sal_Int32 nN=0; nN > aSubGrids( xAxis->getSubGridProperties() ); + for( auto const & i : aSubGrids ) + AxisHelper::makeGridVisible( i ); } } @@ -534,9 +533,9 @@ void AxisHelper::hideGrid( sal_Int32 nDimensionIndex, sal_Int32 nCooSysIndex, bo AxisHelper::makeGridInvisible( xAxis->getGridProperties() ); else { - Sequence< Reference< beans::XPropertySet > > aSubGrids( xAxis->getSubGridProperties() ); - for( sal_Int32 nN=0; nN > aSubGrids( xAxis->getSubGridProperties() ); + for( auto const & i : aSubGrids) + AxisHelper::makeGridInvisible( i ); } } @@ -850,11 +849,10 @@ Sequence< Reference< XAxis > > AxisHelper::getAllAxesOfDiagram( Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY ); if(xCooSysContainer.is()) { - Sequence< Reference< XCoordinateSystem > > aCooSysList = xCooSysContainer->getCoordinateSystems(); - sal_Int32 nC = 0; - for( nC=0; nC > aCooSysList = xCooSysContainer->getCoordinateSystems(); + for( Reference< XCoordinateSystem > const & coords : aCooSysList ) { - std::vector< Reference< XAxis > > aAxesPerCooSys( AxisHelper::getAllAxesOfCoordinateSystem( aCooSysList[nC], bOnlyVisible ) ); + std::vector< Reference< XAxis > > aAxesPerCooSys( AxisHelper::getAllAxesOfCoordinateSystem( coords, bOnlyVisible ) ); aAxisVector.insert( aAxisVector.end(), aAxesPerCooSys.begin(), aAxesPerCooSys.end() ); } } @@ -864,24 +862,20 @@ Sequence< Reference< XAxis > > AxisHelper::getAllAxesOfDiagram( Sequence< Reference< beans::XPropertySet > > AxisHelper::getAllGrids( const Reference< XDiagram >& xDiagram ) { - Sequence< Reference< XAxis > > aAllAxes( AxisHelper::getAllAxesOfDiagram( xDiagram ) ); + const Sequence< Reference< XAxis > > aAllAxes( AxisHelper::getAllAxesOfDiagram( xDiagram ) ); std::vector< Reference< beans::XPropertySet > > aGridVector; - sal_Int32 nA = 0; - for( nA=0; nA const & xAxis : aAllAxes ) { - Reference< XAxis > xAxis( aAllAxes[nA] ); if(!xAxis.is()) continue; Reference< beans::XPropertySet > xGridProperties( xAxis->getGridProperties() ); if( xGridProperties.is() ) aGridVector.push_back( xGridProperties ); - Sequence< Reference< beans::XPropertySet > > aSubGrids( xAxis->getSubGridProperties() ); - sal_Int32 nSubGrid = 0; - for( nSubGrid = 0; nSubGrid < aSubGrids.getLength(); ++nSubGrid ) + const Sequence< Reference< beans::XPropertySet > > aSubGrids( xAxis->getSubGridProperties() ); + for( Reference< beans::XPropertySet > const & xSubGrid : aSubGrids ) { - Reference< beans::XPropertySet > xSubGrid( aSubGrids[nSubGrid] ); if( xSubGrid.is() ) aGridVector.push_back( xSubGrid ); } @@ -914,10 +908,10 @@ bool AxisHelper::isSecondaryYAxisNeeded( const Reference< XCoordinateSystem >& x Reference< chart2::XChartTypeContainer > xCTCnt( xCooSys, uno::UNO_QUERY ); if( xCTCnt.is() ) { - Sequence< Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes() ); - for( sal_Int32 i=0; i > aChartTypes( xCTCnt->getChartTypes() ); + for( Reference< chart2::XChartType > const & chartType : aChartTypes ) { - Reference< XDataSeriesContainer > xSeriesContainer( aChartTypes[i] , uno::UNO_QUERY ); + Reference< XDataSeriesContainer > xSeriesContainer( chartType, uno::UNO_QUERY ); if( !xSeriesContainer.is() ) continue; @@ -1037,11 +1031,9 @@ Reference< XCoordinateSystem > AxisHelper::getCoordinateSystemOfAxis( Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY ); if( xCooSysContainer.is() ) { - Reference< XCoordinateSystem > xCooSys; - Sequence< Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() ); - for( sal_Int32 nCooSysIndex = 0; nCooSysIndex < aCooSysList.getLength(); ++nCooSysIndex ) + const Sequence< Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() ); + for( Reference< XCoordinateSystem > const & xCooSys : aCooSysList ) { - xCooSys = aCooSysList[nCooSysIndex]; std::vector< Reference< XAxis > > aAllAxis( AxisHelper::getAllAxesOfCoordinateSystem( xCooSys ) ); std::vector< Reference< XAxis > >::iterator aFound = diff --git a/chart2/source/tools/ChartModelHelper.cxx b/chart2/source/tools/ChartModelHelper.cxx index c6a294fe8a15..2d684b059355 100644 --- a/chart2/source/tools/ChartModelHelper.cxx +++ b/chart2/source/tools/ChartModelHelper.cxx @@ -254,13 +254,13 @@ bool ChartModelHelper::setIncludeHiddenCells( bool bIncludeHiddenCells, ChartMod if( xUsedData.is() ) { uno::Reference< beans::XPropertySet > xProp; - uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aData( xUsedData->getDataSequences()); - for( sal_Int32 i=0; i > aData( xUsedData->getDataSequences()); + for( uno::Reference< chart2::data::XLabeledDataSequence > const & labeledData : aData ) { - xProp.set( uno::Reference< beans::XPropertySet >( aData[i]->getValues(), uno::UNO_QUERY ) ); + xProp.set( uno::Reference< beans::XPropertySet >( labeledData->getValues(), uno::UNO_QUERY ) ); if(xProp.is()) xProp->setPropertyValue("IncludeHiddenCells", aNewValue ); - xProp.set( uno::Reference< beans::XPropertySet >( aData[i]->getLabel(), uno::UNO_QUERY ) ); + xProp.set( uno::Reference< beans::XPropertySet >( labeledData->getLabel(), uno::UNO_QUERY ) ); if(xProp.is()) xProp->setPropertyValue("IncludeHiddenCells", aNewValue ); } diff --git a/chart2/source/tools/ConfigColorScheme.cxx b/chart2/source/tools/ConfigColorScheme.cxx index 1618733aa15c..e3bdb20fac04 100644 --- a/chart2/source/tools/ConfigColorScheme.cxx +++ b/chart2/source/tools/ConfigColorScheme.cxx @@ -73,10 +73,10 @@ ChartConfigItem::ChartConfigItem( ConfigColorScheme & rListener ) : void ChartConfigItem::Notify( const Sequence< OUString > & aPropertyNames ) { - for( sal_Int32 nIdx=0; nIdx lcl_findLSequenceWithOnlyLabel( const Reference< chart2::data::XDataSource > & xDataSource ) { Reference< chart2::data::XLabeledDataSequence > xResult; - Sequence< Reference< chart2::data::XLabeledDataSequence > > aSequences( xDataSource->getDataSequences()); + const Sequence< Reference< chart2::data::XLabeledDataSequence > > aSequences( xDataSource->getDataSequences()); - for( sal_Int32 i=0; igetValues().is() && - aSequences[i]->getLabel().is())) + if( labeledData.is() && + ( ! labeledData->getValues().is() && + labeledData->getLabel().is())) { - xResult.set( aSequences[i] ); + xResult.set( labeledData ); break; } } @@ -115,23 +115,23 @@ void lcl_getCooSysAndChartTypeOfSeries( if( !xCooSysCnt.is()) return; - Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems()); - for( sal_Int32 nCooSysIdx=0; nCooSysIdx > aCooSysSeq( xCooSysCnt->getCoordinateSystems()); + for( Reference< chart2::XCoordinateSystem > const & coords : aCooSysSeq ) { - Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[nCooSysIdx], uno::UNO_QUERY_THROW ); - Sequence< Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes()); - for( sal_Int32 nCTIdx=0; nCTIdx xCTCnt( coords, uno::UNO_QUERY_THROW ); + const Sequence< Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes()); + for( Reference< chart2::XChartType > const & chartType : aChartTypes ) { - Reference< chart2::XDataSeriesContainer > xSeriesCnt( aChartTypes[nCTIdx], uno::UNO_QUERY ); + Reference< chart2::XDataSeriesContainer > xSeriesCnt( chartType, uno::UNO_QUERY ); if( xSeriesCnt.is()) { - Sequence< Reference< chart2::XDataSeries > > aSeries( xSeriesCnt->getDataSeries()); - for( sal_Int32 nSeriesIdx=0; nSeriesIdx > aSeries( xSeriesCnt->getDataSeries()); + for( Reference< chart2::XDataSeries > const & dataSeries : aSeries ) { - if( aSeries[nSeriesIdx] == xSeries ) + if( dataSeries == xSeries ) { - xOutCooSys.set( aCooSysSeq[nCooSysIdx] ); - xOutChartType.set( aChartTypes[nCTIdx] ); + xOutCooSys.set( coords ); + xOutChartType.set( chartType ); } } } @@ -238,9 +238,9 @@ getAllDataSequences( const uno::Sequence >& { std::vector< Reference< chart2::data::XLabeledDataSequence > > aSeqVec; - for( sal_Int32 i = 0; i < aSeries.getLength(); ++i ) + for( uno::Reference const & dataSeries : aSeries ) { - Reference< chart2::data::XDataSource > xSource( aSeries[ i ], uno::UNO_QUERY ); + Reference< chart2::data::XDataSource > xSource( dataSeries, uno::UNO_QUERY ); if( xSource.is()) { Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeq( xSource->getDataSequences()); @@ -392,11 +392,11 @@ void setStackModeAtSeries( : chart2::StackingDirection_NO_STACKING ); std::set< sal_Int32 > aAxisIndexSet; - for( sal_Int32 i=0; i const & dataSeries : aSeries ) { try { - Reference< beans::XPropertySet > xProp( aSeries[i], uno::UNO_QUERY ); + Reference< beans::XPropertySet > xProp( dataSeries, uno::UNO_QUERY ); if( xProp.is() ) { xProp->setPropertyValue( "StackingDirection", aPropValue ); diff --git a/chart2/source/tools/DataSourceHelper.cxx b/chart2/source/tools/DataSourceHelper.cxx index 3b6f08ef5420..50fd37347f09 100644 --- a/chart2/source/tools/DataSourceHelper.cxx +++ b/chart2/source/tools/DataSourceHelper.cxx @@ -239,7 +239,7 @@ uno::Reference< chart2::data::XDataSource > DataSourceHelper::pressUsedDataIntoR std::vector< Reference< chart2::XDataSeries > > aSeriesVector( DiagramHelper::getDataSeriesFromDiagram( xDiagram ) ); uno::Reference< chart2::data::XDataSource > xSeriesSource( DataSeriesHelper::getDataSource( comphelper::containerToSequence(aSeriesVector) ) ); - Sequence< Reference< chart2::data::XLabeledDataSequence > > aDataSequences( xSeriesSource->getDataSequences() ); + const Sequence< Reference< chart2::data::XLabeledDataSequence > > aDataSequences( xSeriesSource->getDataSequences() ); //the first x-values is always the next sequence //todo ... other x-values get lost for old format Reference< chart2::data::XLabeledDataSequence > xXValues( @@ -248,11 +248,11 @@ uno::Reference< chart2::data::XDataSource > DataSourceHelper::pressUsedDataIntoR aResultVector.push_back( xXValues ); //add all other sequences now without x-values - for( sal_Int32 nN=0; nN const & labeledData : aDataSequences ) { - OUString aRole = DataSeriesHelper::getRole(aDataSequences[nN]); + OUString aRole = DataSeriesHelper::getRole(labeledData); if( aRole != "values-x" ) - aResultVector.push_back( aDataSequences[nN] ); + aResultVector.push_back( labeledData ); } return new DataSource( comphelper::containerToSequence(aResultVector) ); @@ -512,11 +512,11 @@ Sequence< OUString > DataSourceHelper::getRangesFromDataSource( const Reference< std::vector< OUString > aResult; if( xSource.is()) { - Sequence< Reference< data::XLabeledDataSequence > > aLSeqSeq( xSource->getDataSequences()); - for( sal_Int32 i=0; i > aLSeqSeq( xSource->getDataSequences()); + for( Reference< data::XLabeledDataSequence > const & labeledData : aLSeqSeq ) { - Reference< data::XDataSequence > xLabel( aLSeqSeq[i]->getLabel()); - Reference< data::XDataSequence > xValues( aLSeqSeq[i]->getValues()); + Reference< data::XDataSequence > xLabel( labeledData->getLabel()); + Reference< data::XDataSequence > xValues( labeledData->getValues()); if( xLabel.is()) aResult.push_back( xLabel->getSourceRangeRepresentation()); diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx index ab93f06a8096..213d1787d1ce 100644 --- a/chart2/source/tools/DiagramHelper.cxx +++ b/chart2/source/tools/DiagramHelper.cxx @@ -117,12 +117,11 @@ void DiagramHelper::setVertical( if (!xCnt.is()) return; - Sequence< Reference > aCooSys = xCnt->getCoordinateSystems(); + const Sequence< Reference > aCooSys = xCnt->getCoordinateSystems(); uno::Any aValue; aValue <<= bVertical; - for( sal_Int32 i=0; i const & xCooSys : aCooSys ) { - uno::Reference< XCoordinateSystem > xCooSys( aCooSys[i] ); Reference< beans::XPropertySet > xProp( xCooSys, uno::UNO_QUERY ); bool bChanged = false; if (xProp.is()) @@ -196,11 +195,11 @@ bool DiagramHelper::getVertical( const uno::Reference< chart2::XDiagram > & xDia if (!xCnt.is()) return false; - Sequence< Reference > aCooSys = xCnt->getCoordinateSystems(); + const Sequence< Reference > aCooSys = xCnt->getCoordinateSystems(); - for (sal_Int32 i = 0; i < aCooSys.getLength(); ++i) + for (Reference const & coords : aCooSys) { - Reference xProp(aCooSys[i], uno::UNO_QUERY); + Reference xProp(coords, uno::UNO_QUERY); if (!xProp.is()) continue; @@ -252,10 +251,9 @@ void DiagramHelper::setStackMode( uno::Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY ); if( !xCooSysContainer.is() ) return; - 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] ); //set correct percent stacking const sal_Int32 nMaximumScaleIndex = xCooSys->getMaximumAxisIndexByDimension(1); for(sal_Int32 nI=0; nI<=nMaximumScaleIndex; ++nI) @@ -290,10 +288,10 @@ void DiagramHelper::setStackMode( 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( uno::Reference< XDataSeries > const & dataSeries : aSeriesList ) { - Reference< beans::XPropertySet > xProp( aSeriesList[nS], uno::UNO_QUERY ); + Reference< beans::XPropertySet > xProp( dataSeries, uno::UNO_QUERY ); if(xProp.is()) xProp->setPropertyValue( "StackingDirection", aNewDirection ); } @@ -316,11 +314,9 @@ StackMode DiagramHelper::getStackMode( const Reference< XDiagram > & xDiagram, b uno::Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY ); if( !xCooSysContainer.is() ) return eGlobalStackMode; - 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 ); if( !xChartTypeContainer.is() ) @@ -438,12 +434,11 @@ sal_Int32 DiagramHelper::getDimension( const Reference< XDiagram > & xDiagram ) Reference< XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY ); if( xCooSysCnt.is() ) { - Sequence< Reference< XCoordinateSystem > > aCooSysSeq( + const Sequence< Reference< XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems()); - for( sal_Int32 i=0; i const & xCooSys : aCooSysSeq ) { - Reference< XCoordinateSystem > xCooSys( aCooSysSeq[i] ); if(xCooSys.is()) { nResult = xCooSys->getDimension(); @@ -627,31 +622,27 @@ uno::Reference< XChartType > DiagramHelper::getChartTypeOfSeries( if( !xCooSysContainer.is()) return nullptr; - 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( uno::Reference< XDataSeries > const & dataSeries : aSeriesList ) { - if( xGivenDataSeries==aSeriesList[nS] ) + if( xGivenDataSeries==dataSeries ) return xChartType; } } @@ -669,15 +660,15 @@ std::vector< Reference< XDataSeries > > { 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 const & coords : aCooSysSeq ) { - Reference< XChartTypeContainer > xCTCnt( aCooSysSeq[i], uno::UNO_QUERY_THROW ); - Sequence< Reference< XChartType > > aChartTypeSeq( xCTCnt->getChartTypes()); - for( sal_Int32 j=0; j xCTCnt( coords, uno::UNO_QUERY_THROW ); + const Sequence< Reference< XChartType > > aChartTypeSeq( xCTCnt->getChartTypes()); + for( Reference< XChartType> const & chartType : aChartTypeSeq ) { - Reference< XDataSeriesContainer > xDSCnt( aChartTypeSeq[j], uno::UNO_QUERY_THROW ); + Reference< XDataSeriesContainer > xDSCnt( chartType, uno::UNO_QUERY_THROW ); Sequence< Reference< XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries() ); std::copy( aSeriesSeq.begin(), aSeriesSeq.end(), std::back_inserter( aResult )); @@ -701,17 +692,17 @@ Sequence< Sequence< Reference< XDataSeries > > > Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY ); if( xCooSysContainer.is() ) { - Sequence< Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() ); - for( sal_Int32 nCS = 0; nCS < aCooSysList.getLength(); ++nCS ) + const Sequence< Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() ); + for( Reference< XCoordinateSystem > const & coords : aCooSysList ) { //iterate through all chart types in the current coordinate system - Reference< XChartTypeContainer > xChartTypeContainer( aCooSysList[nCS], uno::UNO_QUERY ); + Reference< XChartTypeContainer > xChartTypeContainer( coords, uno::UNO_QUERY ); if( !xChartTypeContainer.is() ) continue; - Sequence< Reference< XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() ); - for( sal_Int32 nT = 0; nT < aChartTypeList.getLength(); ++nT ) + const Sequence< Reference< XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() ); + for( Reference< XChartType > const & chartType : aChartTypeList ) { - Reference< XDataSeriesContainer > xDataSeriesContainer( aChartTypeList[nT], uno::UNO_QUERY ); + Reference< XDataSeriesContainer > xDataSeriesContainer( chartType, uno::UNO_QUERY ); if( !xDataSeriesContainer.is() ) continue; aResult.push_back( xDataSeriesContainer->getDataSeries() ); @@ -731,11 +722,11 @@ Reference< XChartType > if( ! xCooSysContainer.is()) return xChartType; - Sequence< Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() ); + const Sequence< Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() ); sal_Int32 nTypesSoFar = 0; - for( sal_Int32 nCS = 0; nCS < aCooSysList.getLength(); ++nCS ) + for( Reference< XCoordinateSystem > const & coords : aCooSysList ) { - Reference< XChartTypeContainer > xChartTypeContainer( aCooSysList[nCS], uno::UNO_QUERY ); + Reference< XChartTypeContainer > xChartTypeContainer( coords, uno::UNO_QUERY ); if( !xChartTypeContainer.is() ) continue; Sequence< Reference< XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() ); @@ -764,11 +755,10 @@ std::vector< Reference< XAxis > > lcl_getAxisHoldingCategoriesFromDiagram( { 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 const & xCooSys : aCooSysSeq ) { - Reference< XCoordinateSystem > xCooSys( aCooSysSeq[i] ); OSL_ASSERT( xCooSys.is()); for( sal_Int32 nN = xCooSys->getDimension(); nN--; ) { @@ -811,11 +801,10 @@ bool DiagramHelper::isCategoryDiagram( { 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 const & xCooSys : aCooSysSeq ) { - Reference< XCoordinateSystem > xCooSys( aCooSysSeq[i] ); OSL_ASSERT( xCooSys.is()); for( sal_Int32 nN = xCooSys->getDimension(); nN--; ) { @@ -924,10 +913,10 @@ static void lcl_generateAutomaticCategoriesFromChartType( if( !xSeriesCnt.is() ) return; - Sequence< Reference< XDataSeries > > aSeriesSeq( xSeriesCnt->getDataSeries() ); - for( sal_Int32 nS = 0; nS < aSeriesSeq.getLength(); nS++ ) + const Sequence< Reference< XDataSeries > > aSeriesSeq( xSeriesCnt->getDataSeries() ); + for( Reference< XDataSeries > const & dataSeries : aSeriesSeq ) { - Reference< data::XDataSource > xDataSource( aSeriesSeq[nS], uno::UNO_QUERY ); + Reference< data::XDataSource > xDataSource( dataSeries, uno::UNO_QUERY ); if( !xDataSource.is() ) continue; Reference< chart2::data::XLabeledDataSequence > xLabeledSeq( @@ -950,10 +939,10 @@ Sequence< OUString > DiagramHelper::generateAutomaticCategoriesFromCooSys( const Reference< XChartTypeContainer > xTypeCntr( xCooSys, uno::UNO_QUERY ); if( xTypeCntr.is() ) { - Sequence< Reference< XChartType > > aChartTypes( xTypeCntr->getChartTypes() ); - for( sal_Int32 nN=0; nN > aChartTypes( xTypeCntr->getChartTypes() ); + for( Reference< XChartType > const & chartType : aChartTypes ) { - lcl_generateAutomaticCategoriesFromChartType( aRet, aChartTypes[nN] ); + lcl_generateAutomaticCategoriesFromChartType( aRet, chartType ); if( aRet.hasElements() ) return aRet; } @@ -1207,11 +1196,11 @@ Sequence< Reference< XChartType > > { 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 const & coords : aCooSysSeq ) { - Reference< XChartTypeContainer > xCTCnt( aCooSysSeq[i], uno::UNO_QUERY_THROW ); + Reference< XChartTypeContainer > xCTCnt( coords, uno::UNO_QUERY_THROW ); Sequence< Reference< XChartType > > aChartTypeSeq( xCTCnt->getChartTypes()); std::copy( aChartTypeSeq.begin(), aChartTypeSeq.end(), std::back_inserter( aResult )); @@ -1449,11 +1438,10 @@ 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 - Sequence< Reference< chart2::XChartType > > aTypes( + const Sequence< Reference< chart2::XChartType > > aTypes( ::chart::DiagramHelper::getChartTypesFromDiagram( xDiagram ) ); - for( sal_Int32 nN = 0; nN < aTypes.getLength(); nN++ ) + for( Reference< chart2::XChartType > const & xType : aTypes ) { - Reference< chart2::XChartType > xType( aTypes[nN] ); if( xType.is() && xType->getChartType().match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) ) return false; if( xType.is() && xType->getChartType().match(CHART2_SERVICE_NAME_CHARTTYPE_NET) ) @@ -1542,15 +1530,15 @@ sal_Int32 DiagramHelper::getCorrectedMissingValueTreatment( const Reference< chart2::XChartType >& xChartType ) { sal_Int32 nResult = css::chart::MissingValueTreatment::LEAVE_GAP; - uno::Sequence < sal_Int32 > aAvailableMissingValueTreatments( + const uno::Sequence < sal_Int32 > aAvailableMissingValueTreatments( ChartTypeHelper::getSupportedMissingValueTreatments( xChartType ) ); uno::Reference< beans::XPropertySet > xDiaProp( xDiagram, uno::UNO_QUERY ); if( xDiaProp.is() && (xDiaProp->getPropertyValue( "MissingValueTreatment" ) >>= nResult) ) { //ensure that the set value is supported by this charttype - for( sal_Int32 nN = 0; nN < aAvailableMissingValueTreatments.getLength(); nN++ ) - if( aAvailableMissingValueTreatments[nN] == nResult ) + for( sal_Int32 n : aAvailableMissingValueTreatments ) + if( n == nResult ) return nResult; //ok } diff --git a/chart2/source/tools/ErrorBar.cxx b/chart2/source/tools/ErrorBar.cxx index 90c686f9f672..5191e4f3d64c 100644 --- a/chart2/source/tools/ErrorBar.cxx +++ b/chart2/source/tools/ErrorBar.cxx @@ -191,13 +191,13 @@ OUString getSourceRangeStrFromLabeledSequences( const uno::Sequence< uno::Refere else aDirection = "negative"; - for( sal_Int32 nI=0; nI< aSequences.getLength(); ++nI ) + for( uno::Reference< chart2::data::XLabeledDataSequence > const & labeledData : aSequences ) { try { - if( aSequences[nI].is()) + if( labeledData.is()) { - uno::Reference< chart2::data::XDataSequence > xSequence( aSequences[nI]->getValues()); + uno::Reference< chart2::data::XDataSequence > xSequence( labeledData->getValues()); uno::Reference< beans::XPropertySet > xSeqProp( xSequence, uno::UNO_QUERY_THROW ); OUString aRole; if( ( xSeqProp->getPropertyValue( "Role" ) >>= aRole ) && diff --git a/chart2/source/tools/MediaDescriptorHelper.cxx b/chart2/source/tools/MediaDescriptorHelper.cxx index d3ff5d6ca2d9..73c326fdcb38 100644 --- a/chart2/source/tools/MediaDescriptorHelper.cxx +++ b/chart2/source/tools/MediaDescriptorHelper.cxx @@ -52,10 +52,8 @@ MediaDescriptorHelper::MediaDescriptorHelper( const uno::Sequence< }; //read given rMediaDescriptor and store in internal structures: - for( sal_Int32 i= rMediaDescriptor.getLength();i--;) + for( const beans::PropertyValue& rProp : rMediaDescriptor) { - const beans::PropertyValue& rProp = rMediaDescriptor[i]; - if (rProp.Name == "AsTemplate") { addModelProp(rProp); diff --git a/chart2/source/tools/ObjectIdentifier.cxx b/chart2/source/tools/ObjectIdentifier.cxx index b4c6632fff3c..be592b9522df 100644 --- a/chart2/source/tools/ObjectIdentifier.cxx +++ b/chart2/source/tools/ObjectIdentifier.cxx @@ -137,18 +137,17 @@ Reference lcl_getFirstStockChartType( const Reference< frame::XModel if( !xCooSysContainer.is()) return nullptr; - uno::Sequence< Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() ); - for( sal_Int32 nCS = 0; nCS < aCooSysList.getLength(); ++nCS ) + const uno::Sequence< Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() ); + for( Reference< XCoordinateSystem > const & coords : aCooSysList ) { //iterate through all chart types in the current coordinate system - Reference< XChartTypeContainer > xChartTypeContainer( aCooSysList[nCS], uno::UNO_QUERY ); + Reference< XChartTypeContainer > xChartTypeContainer( coords, uno::UNO_QUERY ); if( !xChartTypeContainer.is() ) continue; - uno::Sequence< Reference< XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() ); - for( sal_Int32 nT = 0; nT < aChartTypeList.getLength(); ++nT ) + const uno::Sequence< Reference< XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() ); + for( Reference< XChartType > const & xChartType : aChartTypeList ) { - Reference< XChartType > xChartType( aChartTypeList[nT] ); if(!xChartType.is()) continue; OUString aChartType = xChartType->getChartType(); diff --git a/chart2/source/tools/RangeHighlighter.cxx b/chart2/source/tools/RangeHighlighter.cxx index 9efdbc5d439b..b326d0bacce9 100644 --- a/chart2/source/tools/RangeHighlighter.cxx +++ b/chart2/source/tools/RangeHighlighter.cxx @@ -274,11 +274,11 @@ void RangeHighlighter::fillRangesForDataPoint( const Reference< uno::XInterface Color nPreferredColor = defaultPreferredColor; std::vector< chart2::data::HighlightedRange > aHilightedRanges; - Sequence< Reference< chart2::data::XLabeledDataSequence > > aLSeqSeq( xSource->getDataSequences()); - for( sal_Int32 i=0; i > aLSeqSeq( xSource->getDataSequences()); + for( Reference< chart2::data::XLabeledDataSequence > const & labelDataSeq : aLSeqSeq ) { - Reference< chart2::data::XDataSequence > xLabel( aLSeqSeq[i]->getLabel()); - Reference< chart2::data::XDataSequence > xValues( aLSeqSeq[i]->getValues()); + Reference< chart2::data::XDataSequence > xLabel( labelDataSeq->getLabel()); + Reference< chart2::data::XDataSequence > xValues( labelDataSeq->getValues()); if( xLabel.is()) aHilightedRanges.emplace_back( diff --git a/chart2/source/tools/ReferenceSizeProvider.cxx b/chart2/source/tools/ReferenceSizeProvider.cxx index 865acc660c08..44109500552a 100644 --- a/chart2/source/tools/ReferenceSizeProvider.cxx +++ b/chart2/source/tools/ReferenceSizeProvider.cxx @@ -71,12 +71,12 @@ void ReferenceSizeProvider::setValuesAtTitle( // set from auto-resize on to off -> adapt font sizes at XFormattedStrings if( bHasOldRefSize && ! useAutoScale()) { - uno::Sequence< uno::Reference< XFormattedString > > aStrSeq( + const uno::Sequence< uno::Reference< XFormattedString > > aStrSeq( xTitle->getText()); - for( sal_Int32 i=0; i const & formattedStr : aStrSeq ) { RelativeSizeHelper::adaptFontSizes( - Reference< beans::XPropertySet >( aStrSeq[i], uno::UNO_QUERY ), + Reference< beans::XPropertySet >( formattedStr, uno::UNO_QUERY ), aOldRefSize, getPageSize()); } } @@ -108,9 +108,9 @@ void ReferenceSizeProvider::setValuesAtAllDataSeries() { if( xSeriesProp->getPropertyValue( "AttributedDataPoints") >>= aPointIndexes ) { - for( sal_Int32 i=0; i< aPointIndexes.getLength(); ++i ) + for( sal_Int32 idx : aPointIndexes ) setValuesAtPropertySet( - elem->getDataPointByIndex( aPointIndexes[i] ) ); + elem->getDataPointByIndex( idx ) ); } } catch (const uno::Exception&) @@ -248,13 +248,13 @@ ReferenceSizeProvider::AutoResizeState ReferenceSizeProvider::getAutoResizeState return eResult; // Axes (incl. Axis Titles) - Sequence< Reference< XAxis > > aAxes( AxisHelper::getAllAxesOfDiagram( xDiagram ) ); - for( sal_Int32 i=0; i > aAxes( AxisHelper::getAllAxesOfDiagram( xDiagram ) ); + for( Reference< XAxis > const & axis : aAxes ) { - Reference< beans::XPropertySet > xProp( aAxes[i], uno::UNO_QUERY ); + Reference< beans::XPropertySet > xProp( axis, uno::UNO_QUERY ); if( xProp.is()) getAutoResizeFromPropSet( xProp, eResult ); - Reference< XTitled > xTitled( aAxes[i], uno::UNO_QUERY ); + Reference< XTitled > xTitled( axis, uno::UNO_QUERY ); if( xTitled.is()) { impl_getAutoResizeFromTitled( xTitled, eResult ); @@ -282,10 +282,10 @@ ReferenceSizeProvider::AutoResizeState ReferenceSizeProvider::getAutoResizeState { if( xSeriesProp->getPropertyValue( "AttributedDataPoints") >>= aPointIndexes ) { - for( sal_Int32 i=0; i< aPointIndexes.getLength(); ++i ) + for( sal_Int32 idx : aPointIndexes ) { getAutoResizeFromPropSet( - elem->getDataPointByIndex( aPointIndexes[i] ), eResult ); + elem->getDataPointByIndex( idx ), eResult ); if( eResult == AUTO_RESIZE_AMBIGUOUS ) return eResult; } @@ -330,13 +330,13 @@ void ReferenceSizeProvider::setAutoResizeState( ReferenceSizeProvider::AutoResiz setValuesAtPropertySet( xLegendProp ); // Axes (incl. Axis Titles) - Sequence< Reference< XAxis > > aAxes( AxisHelper::getAllAxesOfDiagram( xDiagram ) ); - for( sal_Int32 i=0; i > aAxes( AxisHelper::getAllAxesOfDiagram( xDiagram ) ); + for( Reference< XAxis > const & axis : aAxes ) { - Reference< beans::XPropertySet > xProp( aAxes[i], uno::UNO_QUERY ); + Reference< beans::XPropertySet > xProp( axis, uno::UNO_QUERY ); if( xProp.is()) setValuesAtPropertySet( xProp ); - impl_setValuesAtTitled( Reference< XTitled >( aAxes[i], uno::UNO_QUERY )); + impl_setValuesAtTitled( Reference< XTitled >( axis, uno::UNO_QUERY )); } // DataSeries/Points diff --git a/chart2/source/tools/RegressionCurveHelper.cxx b/chart2/source/tools/RegressionCurveHelper.cxx index 7e4a9dd17043..47f6a4b0ebfe 100644 --- a/chart2/source/tools/RegressionCurveHelper.cxx +++ b/chart2/source/tools/RegressionCurveHelper.cxx @@ -243,11 +243,11 @@ bool RegressionCurveHelper::hasMeanValueLine( try { - uno::Sequence< uno::Reference< XRegressionCurve > > aCurves( + const uno::Sequence< uno::Reference< XRegressionCurve > > aCurves( xRegCnt->getRegressionCurves()); - for( sal_Int32 i = 0; i < aCurves.getLength(); ++i ) + for( uno::Reference< XRegressionCurve > const & curve : aCurves ) { - if( isMeanValueLine( aCurves[i] )) + if( isMeanValueLine( curve )) return true; } } @@ -276,12 +276,12 @@ uno::Reference< chart2::XRegressionCurve > { try { - uno::Sequence< uno::Reference< XRegressionCurve > > aCurves( + const uno::Sequence< uno::Reference< XRegressionCurve > > aCurves( xRegCnt->getRegressionCurves()); - for( sal_Int32 i = 0; i < aCurves.getLength(); ++i ) + for( uno::Reference< XRegressionCurve > const & curve : aCurves ) { - if( isMeanValueLine( aCurves[i] )) - return aCurves[i]; + if( isMeanValueLine( curve )) + return curve; } } catch( const Exception & ) @@ -324,13 +324,13 @@ void RegressionCurveHelper::removeMeanValueLine( try { - Sequence< Reference< XRegressionCurve > > aCurves( + const Sequence< Reference< XRegressionCurve > > aCurves( xRegCnt->getRegressionCurves()); - for( sal_Int32 i = 0; i < aCurves.getLength(); ++i ) + for( Reference< XRegressionCurve > const & curve : aCurves ) { - if( isMeanValueLine( aCurves[i] )) + if( isMeanValueLine( curve )) { - xRegCnt->removeRegressionCurve( aCurves[i] ); + xRegCnt->removeRegressionCurve( curve ); // attention: the iterator i has become invalid now // note: assume that there is only one mean-value curve @@ -403,14 +403,14 @@ bool RegressionCurveHelper::removeAllExceptMeanValueLine( { try { - uno::Sequence< uno::Reference< chart2::XRegressionCurve > > aCurves( + const uno::Sequence< uno::Reference< chart2::XRegressionCurve > > aCurves( xRegCnt->getRegressionCurves()); std::vector< uno::Reference< chart2::XRegressionCurve > > aCurvesToDelete; - for( sal_Int32 i = 0; i < aCurves.getLength(); ++i ) + for( uno::Reference< chart2::XRegressionCurve > const & curve : aCurves ) { - if( ! isMeanValueLine( aCurves[i] )) + if( ! isMeanValueLine( curve )) { - aCurvesToDelete.push_back( aCurves[ i ] ); + aCurvesToDelete.push_back( curve ); } } @@ -436,13 +436,13 @@ void RegressionCurveHelper::removeEquations( try { - uno::Sequence< uno::Reference< chart2::XRegressionCurve > > aCurves( + const uno::Sequence< uno::Reference< chart2::XRegressionCurve > > aCurves( xRegCnt->getRegressionCurves()); - for( sal_Int32 i = 0; i < aCurves.getLength(); ++i ) + for( uno::Reference< chart2::XRegressionCurve > const & curve : aCurves ) { - if( !isMeanValueLine( aCurves[i] ) ) + if( !isMeanValueLine( curve ) ) { - uno::Reference< chart2::XRegressionCurve > xRegCurve( aCurves[ i ] ); + uno::Reference< chart2::XRegressionCurve > xRegCurve( curve ); if( xRegCurve.is() ) { uno::Reference< beans::XPropertySet > xEqProp( xRegCurve->getEquationProperties() ) ; @@ -484,13 +484,13 @@ uno::Reference< chart2::XRegressionCurve > RegressionCurveHelper::getFirstCurveN try { - uno::Sequence< uno::Reference< chart2::XRegressionCurve > > aCurves( + const uno::Sequence< uno::Reference< chart2::XRegressionCurve > > aCurves( xRegCnt->getRegressionCurves()); - for( sal_Int32 i = 0; i < aCurves.getLength(); ++i ) + for( uno::Reference< chart2::XRegressionCurve > const & curve : aCurves ) { - if( ! isMeanValueLine( aCurves[i] )) + if( ! isMeanValueLine( curve )) { - return aCurves[ i ]; + return curve; } } } @@ -583,11 +583,11 @@ SvxChartRegress RegressionCurveHelper::getFirstRegressTypeNotMeanValueLine( if( xRegCnt.is()) { - Sequence< Reference< XRegressionCurve > > aCurves( + const Sequence< Reference< XRegressionCurve > > aCurves( xRegCnt->getRegressionCurves()); - for( sal_Int32 i = 0; i < aCurves.getLength(); ++i ) + for( Reference< XRegressionCurve > const & curve : aCurves ) { - SvxChartRegress eType = getRegressionType( aCurves[i] ); + SvxChartRegress eType = getRegressionType( curve ); if( eType != SvxChartRegress::MeanValue && eType != SvxChartRegress::Unknown ) { @@ -692,11 +692,11 @@ std::vector< Reference< chart2::XRegressionCurve > > Reference< chart2::XRegressionCurveContainer > xContainer(elem, uno::UNO_QUERY); if(xContainer.is()) { - uno::Sequence< uno::Reference< chart2::XRegressionCurve > > aCurves(xContainer->getRegressionCurves()); - for( sal_Int32 i = 0; i < aCurves.getLength(); ++i ) + const uno::Sequence< uno::Reference< chart2::XRegressionCurve > > aCurves(xContainer->getRegressionCurves()); + for( Reference< XRegressionCurve > const & curve : aCurves ) { - if( ! isMeanValueLine( aCurves[i] )) - aResult.push_back( aCurves[i] ); + if( ! isMeanValueLine( curve )) + aResult.push_back( curve ); } } } diff --git a/chart2/source/tools/TitleHelper.cxx b/chart2/source/tools/TitleHelper.cxx index c384d03b08e7..3cdddbbeeb44 100644 --- a/chart2/source/tools/TitleHelper.cxx +++ b/chart2/source/tools/TitleHelper.cxx @@ -305,9 +305,9 @@ OUString TitleHelper::getCompleteString( const uno::Reference< XTitle >& xTitle if(!xTitle.is()) return OUString(); OUStringBuffer aRet; - uno::Sequence< uno::Reference< XFormattedString > > aStringList = xTitle->getText(); - for( sal_Int32 nN=0; nNgetString() ); + const uno::Sequence< uno::Reference< XFormattedString > > aStringList = xTitle->getText(); + for( uno::Reference< XFormattedString > const & formattedStr : aStringList ) + aRet.append( formattedStr->getString() ); return aRet.makeStringAndClear(); } diff --git a/chart2/source/tools/WrappedPropertySet.cxx b/chart2/source/tools/WrappedPropertySet.cxx index 959fe5ef5d70..26344a578adc 100644 --- a/chart2/source/tools/WrappedPropertySet.cxx +++ b/chart2/source/tools/WrappedPropertySet.cxx @@ -349,18 +349,16 @@ Any SAL_CALL WrappedPropertySet::getPropertyDefault( const OUString& rPropertyNa void SAL_CALL WrappedPropertySet::setAllPropertiesToDefault( ) { const Sequence< beans::Property >& rPropSeq = getPropertySequence(); - for(sal_Int32 nN=0; nN& rNameSeq ) { - for(sal_Int32 nN=0; nN SAL_CALL WrappedPropertySet::getPropertyDefaults( const Sequence< OUString >& rNameSeq ) diff --git a/chart2/source/view/axes/VCartesianGrid.cxx b/chart2/source/view/axes/VCartesianGrid.cxx index 36a143df4545..eda61d9b8e6c 100644 --- a/chart2/source/view/axes/VCartesianGrid.cxx +++ b/chart2/source/view/axes/VCartesianGrid.cxx @@ -187,12 +187,12 @@ void VCartesianGrid::fillLinePropertiesFromGridModel( std::vector VCoordinateSystem::getCoordinateSystemResolution( uno::Sequence aResolution( std::max(m_xCooSysModel->getDimension(), 2)); - sal_Int32 nN = 0; - for( nN = 0 ;nN VCoordinateSystem::getCoordinateSystemResolution( //this maybe can be optimized further ... sal_Int32 nMaxResolution = std::max( nXResolution, nYResolution ); nMaxResolution*=2; - for( nN = 0 ;nN VSeriesPlotter::createDataLabel( const uno::Re } } - for( sal_Int32 nN = 0; nN < aTextList.getLength(); ++nN ) + for( auto const & line : std::as_const(aTextList) ) { - if( !aTextList[nN].isEmpty() ) + if( !line.isEmpty() ) { ++nLineCountForSymbolsize; } @@ -864,11 +864,10 @@ double lcl_getErrorBarLogicLength( { double fMaxValue; ::rtl::math::setInf(&fMaxValue, true); - const double* pValues = rData.getConstArray(); - for(sal_Int32 i=0; i aCalculatedPoints( + const uno::Sequence< geometry::RealPoint2D > aCalculatedPoints( xCalculator->getCurveValues( fMinX, fMaxX, nPointCount, xScalingX, xScalingY, bMaySkipPoints )); @@ -1416,10 +1415,10 @@ void VSeriesPlotter::createRegressionCurvesShapes( VDataSeries const & rVDataSer sal_Int32 nRealPointCount = 0; - for(sal_Int32 nP = 0; nP < aCalculatedPoints.getLength(); ++nP) + for(geometry::RealPoint2D const & p : aCalculatedPoints) { - double fLogicX = aCalculatedPoints[nP].X; - double fLogicY = aCalculatedPoints[nP].Y; + double fLogicX = p.X; + double fLogicY = p.Y; double fLogicZ = 0.0; //dummy // fdo#51656: don't scale mean value lines diff --git a/chart2/source/view/main/ShapeFactory.cxx b/chart2/source/view/main/ShapeFactory.cxx index 1ec43352b8b6..26a598931c29 100644 --- a/chart2/source/view/main/ShapeFactory.cxx +++ b/chart2/source/view/main/ShapeFactory.cxx @@ -2438,8 +2438,8 @@ uno::Reference< drawing::XShape > if( xFormattedString.hasElements() ) { OUString aLabel; - for( sal_Int32 nN=0; nNgetString(); + for( const auto & i : std::as_const(xFormattedString) ) + aLabel += i->getString(); aLabel = ShapeFactory::getStackedString( aLabel, bStackCharacters ); xTextCursor->gotoEnd(false); @@ -2461,11 +2461,10 @@ uno::Reference< drawing::XShape > } else { - sal_Int32 nN = 0; - for( nN=0; nN& rxFS : std::as_const(xFormattedString) ) { xTextCursor->gotoEnd(false); - xText->insertString( xTextCursor, xFormattedString[nN]->getString(), false ); + xText->insertString( xTextCursor, rxFS->getString(), false ); xTextCursor->gotoEnd(true); } awt::Size aOldRefSize; @@ -2641,8 +2640,8 @@ OUString ShapeFactory::getStackedString( const OUString& rString, bool bStacked bool ShapeFactory::hasPolygonAnyLines( drawing::PolyPolygonShape3D& rPoly) { // #i67757# check all contained polygons, if at least one polygon contains 2 or more points, return true - for( sal_Int32 nIdx = 0, nCount = rPoly.SequenceX.getLength(); nIdx < nCount; ++nIdx ) - if( rPoly.SequenceX[ nIdx ].getLength() > 1 ) + for( auto const & i : std::as_const(rPoly.SequenceX) ) + if( i.getLength() > 1 ) return true; return false; } diff --git a/chart2/source/view/main/VDataSeries.cxx b/chart2/source/view/main/VDataSeries.cxx index c0d0616a090d..91388d1c2eda 100644 --- a/chart2/source/view/main/VDataSeries.cxx +++ b/chart2/source/view/main/VDataSeries.cxx @@ -608,8 +608,8 @@ sal_Int32 VDataSeries::getLabelPlacement( sal_Int32 nPointIndex, const uno::Refe uno::Sequence < sal_Int32 > aAvailablePlacements( ChartTypeHelper::getSupportedLabelPlacements( xChartType, bSwapXAndY, m_xDataSeries ) ); - for( sal_Int32 nN = 0; nN < aAvailablePlacements.getLength(); nN++ ) - if( aAvailablePlacements[nN] == nLabelPlacement ) + for( sal_Int32 n : aAvailablePlacements ) + if( n == nLabelPlacement ) return nLabelPlacement; //ok //otherwise use the first supported one @@ -910,9 +910,9 @@ bool VDataSeries::isAttributedDataPoint( sal_Int32 index ) const //returns true if the data point assigned by the given index has set its own properties if( index>=m_nPointCount || m_nPointCount==0) return false; - for(sal_Int32 nN=m_aAttributedDataPointIndexList.getLength();nN--;) + for(sal_Int32 n : m_aAttributedDataPointIndexList) { - if(index==m_aAttributedDataPointIndexList[nN]) + if(index == n) return true; } return false; diff --git a/chart2/workbench/addin/sampleaddin.cxx b/chart2/workbench/addin/sampleaddin.cxx index 44e04a6b9e3a..665a205abd9d 100644 --- a/chart2/workbench/addin/sampleaddin.cxx +++ b/chart2/workbench/addin/sampleaddin.cxx @@ -48,7 +48,7 @@ sal_Bool SAL_CALL component_writeInfo( uno::Sequence< OUString > aSequ = SampleAddIn::getSupportedServiceNames_Static(); const OUString * pArray = aSequ.getConstArray(); - for( sal_Int32 i = 0; i < aSequ.getLength(); i++ ) + for( sal_Int32 i = 0; i < aSequ.(); i++ ) xNewKey->createKey( pArray[i] ); return sal_True; -- cgit v1.2.3