chart2/qa/extras/chart2export.cxx                                      |   12 -
 chart2/qa/extras/charttest.hxx                                         |   50 
++--
 chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx         |   20 -
 chart2/source/controller/chartapiwrapper/TitleWrapper.cxx              |   12 -
 chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx          |   24 
--
 chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx   |    6 
 chart2/source/controller/dialogs/DataBrowserModel.cxx                  |   56 
++--
 chart2/source/controller/dialogs/DialogModel.cxx                       |   35 
+-
 chart2/source/controller/dialogs/tp_AxisPositions.cxx                  |    4 
 chart2/source/controller/dialogs/tp_DataSource.cxx                     |   10 
 chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx    |   11 
 chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx |    4 
 chart2/source/controller/itemsetwrapper/TitleItemConverter.cxx         |    4 
 chart2/source/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 -
 chart2/source/model/main/ChartModel_Persistence.cxx                    |    6 
 chart2/source/model/template/BubbleDataInterpreter.cxx                 |   13 -
 chart2/source/model/template/ChartType.cxx                             |   10 
 chart2/source/model/template/ChartTypeTemplate.cxx                     |   65 
++---
 chart2/source/model/template/ColumnLineChartTypeTemplate.cxx           |   20 -
 chart2/source/model/template/DataInterpreter.cxx                       |   32 
+-
 chart2/source/model/template/PieChartTypeTemplate.cxx                  |   22 -
 chart2/source/model/template/StockChartTypeTemplate.cxx                |   20 -
 chart2/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(-)

New commits:
commit 337a9a454c1bc95214111578d3f9c0622c55c509
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Mon May 18 09:17:04 2020 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon May 18 11:28:50 2020 +0200

    use for-range on Sequence in chart2
    
    Change-Id: Ief02e5d5284b0cbad26b04c0a282dccfee577b90
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94398
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

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<beans::PropertyValue> aEmbeddingsList(0);
            uno::Reference<io::XInputStream> 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<beans::PropertyValue> aEmbeddingsList(0);
            uno::Reference<io::XInputStream> 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<std::vector<double> > 
getDataSeriesYValuesFromChartType( const Refer
 {
     Reference<chart2::XDataSeriesContainer> xDSCont(xCT, uno::UNO_QUERY);
     CPPUNIT_ASSERT(xDSCont.is());
-    Sequence<uno::Reference<chart2::XDataSeries> > aDataSeriesSeq = 
xDSCont->getDataSeries();
+    const Sequence<uno::Reference<chart2::XDataSeries> > aDataSeriesSeq = 
xDSCont->getDataSeries();
 
     double fNan;
     rtl::math::setNan(&fNan);
 
     std::vector<std::vector<double> > aRet;
-    for (sal_Int32 i = 0; i < aDataSeriesSeq.getLength(); ++i)
+    for (uno::Reference<chart2::XDataSeries> const & ds : aDataSeriesSeq)
     {
-        uno::Reference<chart2::data::XDataSource> xDSrc(aDataSeriesSeq[i], 
uno::UNO_QUERY);
+        uno::Reference<chart2::data::XDataSource> xDSrc(ds, uno::UNO_QUERY);
         CPPUNIT_ASSERT(xDSrc.is());
-        uno::Sequence<Reference<chart2::data::XLabeledDataSequence> > 
aDataSeqs = xDSrc->getDataSequences();
-        for (sal_Int32 j = 0; j < aDataSeqs.getLength(); ++j)
+        const uno::Sequence<Reference<chart2::data::XLabeledDataSequence> > 
aDataSeqs = xDSrc->getDataSequences();
+        for (auto const & lds : aDataSeqs)
         {
-            Reference<chart2::data::XDataSequence> xValues = 
aDataSeqs[j]->getValues();
+            Reference<chart2::data::XDataSequence> xValues = lds->getValues();
             CPPUNIT_ASSERT(xValues.is());
             Reference<beans::XPropertySet> xPropSet(xValues, uno::UNO_QUERY);
             if (!xPropSet.is())
@@ -412,13 +412,13 @@ std::vector<std::vector<double> > 
getDataSeriesYValuesFromChartType( const Refer
             xPropSet->getPropertyValue("Role") >>= aRoleName;
             if (aRoleName == "values-y")
             {
-                uno::Sequence<uno::Any> aData = xValues->getData();
+                const uno::Sequence<uno::Any> aData = xValues->getData();
                 std::vector<double> 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<uno::Sequence<uno::Any> > 
getDataSeriesLabelsFromChartType( const Re
 
     Reference<chart2::XDataSeriesContainer> xDSCont(xCT, uno::UNO_QUERY);
     CPPUNIT_ASSERT(xDSCont.is());
-    Sequence<uno::Reference<chart2::XDataSeries> > aDataSeriesSeq = 
xDSCont->getDataSeries();
+    const Sequence<uno::Reference<chart2::XDataSeries> > aDataSeriesSeq = 
xDSCont->getDataSeries();
 
     std::vector<uno::Sequence<uno::Any> > aRet;
-    for (sal_Int32 i = 0; i < aDataSeriesSeq.getLength(); ++i)
+    for (auto const & ds : aDataSeriesSeq)
     {
-        uno::Reference<chart2::data::XDataSource> xDSrc(aDataSeriesSeq[i], 
uno::UNO_QUERY);
+        uno::Reference<chart2::data::XDataSource> xDSrc(ds, uno::UNO_QUERY);
         CPPUNIT_ASSERT(xDSrc.is());
-        uno::Sequence<Reference<chart2::data::XLabeledDataSequence> > 
aDataSeqs = xDSrc->getDataSequences();
-        for (sal_Int32 j = 0; j < aDataSeqs.getLength(); ++j)
+        const uno::Sequence<Reference<chart2::data::XLabeledDataSequence> > 
aDataSeqs = xDSrc->getDataSequences();
+        for (auto const & lds : aDataSeqs)
         {
-            Reference<chart2::data::XDataSequence> xValues = 
aDataSeqs[j]->getValues();
+            Reference<chart2::data::XDataSequence> xValues = lds->getValues();
             CPPUNIT_ASSERT(xValues.is());
             Reference<beans::XPropertySet> xPropSet(xValues, uno::UNO_QUERY);
             if (!xPropSet.is())
@@ -457,7 +457,7 @@ std::vector<uno::Sequence<uno::Any> > 
getDataSeriesLabelsFromChartType( const Re
             xPropSet->getPropertyValue("Role") >>= aRoleName;
             if (aRoleName == aLabelRole)
             {
-                Reference<chart2::data::XLabeledDataSequence> xLabel = 
aDataSeqs[j];
+                Reference<chart2::data::XLabeledDataSequence> xLabel = lds;
                 CPPUNIT_ASSERT(xLabel.is());
                 Reference<chart2::data::XDataSequence> xDS2 = 
xLabel->getLabel();
                 CPPUNIT_ASSERT(xDS2.is());
@@ -544,10 +544,10 @@ OUString getTitleString( const 
Reference<chart2::XTitled>& xTitled )
 {
     uno::Reference<chart2::XTitle> xTitle = xTitled->getTitleObject();
     CPPUNIT_ASSERT(xTitle.is());
-    uno::Sequence<uno::Reference<chart2::XFormattedString> > aFSSeq = 
xTitle->getText();
+    const uno::Sequence<uno::Reference<chart2::XFormattedString> > 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<rPropSeq.getLength(); nN++)
+    for(beans::Property const & prop : rPropSeq)
     {
-        OUString aPropertyName( rPropSeq[nN].Name );
-        setPropertyToDefault( aPropertyName );
+        setPropertyToDefault( prop.Name );
     }
 }
 void SAL_CALL MinMaxLineWrapper::setPropertiesToDefault( const uno::Sequence< 
OUString >& rNameSeq )
 {
-    for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++)
+    for(OUString const & s : rNameSeq)
     {
-        OUString aPropertyName( rNameSeq[nN] );
-        setPropertyToDefault( aPropertyName );
+        setPropertyToDefault( s );
     }
 }
 uno::Sequence< uno::Any > 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<rPropSeq.getLength(); nN++)
+    for(beans::Property const & prop : rPropSeq)
     {
-        OUString aPropertyName( rPropSeq[nN].Name );
-        setPropertyToDefault( aPropertyName );
+        setPropertyToDefault( prop.Name );
     }
 }
 void SAL_CALL UpDownBarWrapper::setPropertiesToDefault( const uno::Sequence< 
OUString >& rNameSeq )
 {
-    for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++)
+    for(OUString const & s : rNameSeq)
     {
-        OUString aPropertyName( rNameSeq[nN] );
-        setPropertyToDefault( aPropertyName );
+        setPropertyToDefault( s );
     }
 }
 uno::Sequence< uno::Any > 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.getLength(); ++i )
-            if (aLSeq[i].is() && DataSeriesHelper::getRole(aLSeq[i]) == 
aValuesRole)
+        const Sequence< Reference< chart2::data::XLabeledDataSequence > > 
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.getLength(); ++nIdx )
+    const Sequence< Reference< chart2::data::XLabeledDataSequence > > 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<rSeries.getLength(); 
++nSeriesIdx )
         {
@@ -148,7 +148,7 @@ lcl_tSharedSeqVec lcl_getSharedSequences( const Sequence< 
Reference< chart2::XDa
                 break;
         }
         if( bShared )
-            aResult.push_back( aLSeq[nIdx] );
+            aResult.push_back( labeledDataSeq );
     }
 
     return aResult;
@@ -480,13 +480,13 @@ void 
DataBrowserModel::removeDataSeriesOrComplexCategoryLevel( sal_Int32 nAtColu
     // Check if the sequences to be deleted are still referenced by any of
     // the other data series.  If not, mark them for deletion.
     std::vector<sal_Int32> aSequenceIndexesToDelete;
-    Sequence<Reference<chart2::data::XLabeledDataSequence> > 
aSequencesOfDeleted = xSourceOfDeleted->getDataSequences();
-    for (sal_Int32 i = 0; i < aSequencesOfDeleted.getLength(); ++i)
+    const Sequence<Reference<chart2::data::XLabeledDataSequence> > 
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.getLength(); 
++nCooSysIdx )
+    const Sequence< Reference< chart2::XCoordinateSystem > > 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<aChartTypes.getLength(); ++nCTIdx )
         {
@@ -823,7 +823,7 @@ void DataBrowserModel::updateFromModel()
             {
                 OUString aRoleForDataLabelNumberFormat = 
ChartTypeHelper::getRoleOfSequenceForDataLabelNumberFormatDetection( 
aChartTypes[nCTIdx] );
 
-                Sequence< Reference< chart2::XDataSeries > > 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<aSeries.getLength(); 
++nSeriesIdx )
+                for( Reference< chart2::XDataSeries > 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<aLSeqs.getLength(); ++nSeqIdx )
@@ -874,7 +874,7 @@ void DataBrowserModel::updateFromModel()
                             {
                                 // no shared sequence
                                 m_aColumns.emplace_back(
-                                        aSeries[nSeriesIdx],
+                                        dataSeries,
                                         lcl_getUIRoleName( aLSeqs[nSeqIdx] ),
                                         aLSeqs[nSeqIdx],
                                         NUMBER,
@@ -886,20 +886,20 @@ void DataBrowserModel::updateFromModel()
                         bool bSwapXAndYAxis = false;
                         try
                         {
-                            Reference< beans::XPropertySet > 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<aRoles.getLength(); ++nI)
+            for(OUString const & role : aRoles)
             {
-                if( aRoles[nI] == lcl_aLabelRole )
+                if( role == lcl_aLabelRole )
                     continue;
                 Reference< data::XDataSequence > 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<aOptRoles.getLength(); ++nI)
+            for(OUString const & role : aOptRoles)
             {
-                if( aOptRoles[nI] == lcl_aLabelRole )
+                if( role == lcl_aLabelRole )
                     continue;
                 Reference< data::XDataSequence > 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<aCooSysSeq.getLength(); ++i )
+            for( Reference< XCoordinateSystem > 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<OUString>& 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; nN<m_aCategories.getLength(); nN++ )
-            m_xED_CrossesAtCategory->append_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<aSequences.getLength(); ++i )
+    for( Reference< chart2::data::XLabeledDataSequence > 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.getLength(); nN++)
-                AxisHelper::makeGridVisible( aSubGrids[nN] );
+            const Sequence< Reference< beans::XPropertySet > > 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.getLength(); nN++)
-                AxisHelper::makeGridInvisible( aSubGrids[nN] );
+            const Sequence< Reference< beans::XPropertySet > > 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.getLength(); ++i )
+                    const Sequence< Reference< XLabeledDataSequence > > 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.getLength(); ++i )
-                lcl_addAxisTitle( aAxes[i], aTopLevelContainer, xModel );
+            const Sequence< Reference< XAxis > > 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<aAxes.getLength(); ++nA )
+    for( Reference< XAxis > 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<frame::XModel> 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<aSeqs.getLength(); ++j )
+                for( auto const & j : aSeqs )
                 {
-                    assert( (aSeqs[j] == xValuesY || aSeqs[j] == xValuesX || 
aSeqs[j] == xValuesSize) && "All sequences should be used" );
+                    assert( (j == xValuesY || j == xValuesX || j == 
xValuesSize) && "All sequences should be used" );
                 }
 #endif
                 Reference< data::XDataSink > xSink( xSeriesSource, 
uno::UNO_QUERY_THROW );
@@ -267,12 +266,12 @@ chart2::InterpretedData SAL_CALL 
BubbleDataInterpreter::reinterpretDataSeries(
 sal_Bool SAL_CALL BubbleDataInterpreter::isDataCompatible(
     const chart2::InterpretedData& aInterpretedData )
 {
-    Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( 
aInterpretedData.Series ));
-    for( sal_Int32 i=0; i<aSeries.getLength(); ++i )
+    const Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( 
aInterpretedData.Series ));
+    for( Reference< XDataSeries >  const & dataSeries : aSeries )
     {
         try
         {
-            Reference< data::XDataSource > xSrc( aSeries[i], 
uno::UNO_QUERY_THROW );
+            Reference< data::XDataSource > xSrc( dataSeries, 
uno::UNO_QUERY_THROW );
             Sequence< Reference< data::XLabeledDataSequence > > aSeq( 
xSrc->getDataSequences());
             if( aSeq.getLength() != 3 )
                 return false;
diff --git a/chart2/source/model/template/ChartType.cxx 
b/chart2/source/model/template/ChartType.cxx
index 4edda932cfec..999f7c1ede96 100644
--- a/chart2/source/model/template/ChartType.cxx
+++ b/chart2/source/model/template/ChartType.cxx
@@ -173,13 +173,13 @@ void SAL_CALL ChartType::setDataSeries( const Sequence< 
Reference< chart2::XData
     m_bNotifyChanges = false;
     try
     {
-        Sequence< Reference< chart2::XDataSeries > > aOldSeries( 
getDataSeries() );
-        for( sal_Int32 nN=0; nN<aOldSeries.getLength(); ++nN )
-            ModifyListenerHelper::removeListener( aOldSeries[nN], 
m_xModifyEventForwarder );
+        const Sequence< Reference< chart2::XDataSeries > > aOldSeries( 
getDataSeries() );
+        for( auto const & i : aOldSeries )
+            ModifyListenerHelper::removeListener( i, m_xModifyEventForwarder );
         m_aDataSeries.clear();
 
-        for( sal_Int32 i=0; i<aDataSeries.getLength(); ++i )
-            impl_addDataSeriesWithoutNotification( aDataSeries[i] );
+        for( auto const & i : aDataSeries )
+            impl_addDataSeriesWithoutNotification( i );
     }
     catch( ... )
     {
diff --git a/chart2/source/model/template/ChartTypeTemplate.cxx 
b/chart2/source/model/template/ChartTypeTemplate.cxx
index 023becdd0698..8aafc1fd1d8b 100644
--- a/chart2/source/model/template/ChartTypeTemplate.cxx
+++ b/chart2/source/model/template/ChartTypeTemplate.cxx
@@ -73,9 +73,9 @@ void lcl_ensureCorrectLabelPlacement( const Reference< 
beans::XPropertySet >& xP
         return;
 
     bool bValid = false;
-    for( sal_Int32 nN = 0; nN < rAvailablePlacements.getLength(); nN++ )
+    for( sal_Int32 i : rAvailablePlacements )
     {
-        if( rAvailablePlacements[nN] == nLabelPlacement )
+        if( i == nLabelPlacement )
         {
             bValid = true;
             break;
@@ -155,13 +155,11 @@ uno::Reference< XDiagram > SAL_CALL 
ChartTypeTemplate::createDiagramByDataSource
             xInterpreter->interpretDataSource(
                 xDataSource, aArguments, Sequence< Reference< XDataSeries > 
>() ));
 
-        Sequence< Sequence< Reference< XDataSeries > > > aSeries( aData.Series 
);
-        sal_Int32 i, j, nCount = 0;
-        for( i=0; i<aSeries.getLength(); ++i )
-        {
-            for( j=0; j<aSeries[i].getLength(); ++j, ++nCount )
-                lcl_applyDefaultStyle( aSeries[i][j], nCount, xDia );
-        }
+        const Sequence< Sequence< Reference< XDataSeries > > > aSeries( 
aData.Series );
+        sal_Int32 nCount = 0;
+        for( auto const & i : aSeries )
+            for( auto const & j : i )
+                lcl_applyDefaultStyle( j, nCount++, xDia );
 
         Sequence< Reference< XChartType > > aOldChartTypesSeq;
         FillDiagram( xDia, aData.Series, aData.Categories, aOldChartTypesSeq );
@@ -219,12 +217,12 @@ void SAL_CALL ChartTypeTemplate::changeDiagram( const 
uno::Reference< XDiagram >
         }
         aSeriesSeq = aData.Series;
 
-        sal_Int32 i, j, nIndex = 0;
-        for( i=0; i<aSeriesSeq.getLength(); ++i )
-            for( j=0; j<aSeriesSeq[i].getLength(); ++j, ++nIndex )
+        sal_Int32 nIndex = 0;
+        for( auto const & i : std::as_const(aSeriesSeq) )
+            for( auto const & j : i )
             {
                 if( nIndex >= nFormerSeriesCount )
-                    lcl_applyDefaultStyle( aSeriesSeq[i][j], nIndex, xDiagram 
);
+                    lcl_applyDefaultStyle( j, nIndex++, xDiagram );
             }
 
         // remove charttype groups from all coordinate systems
@@ -235,11 +233,11 @@ void SAL_CALL ChartTypeTemplate::changeDiagram( const 
uno::Reference< XDiagram >
         OSL_ASSERT( xCoordSysCnt.is());
         if( xCoordSysCnt.is())
         {
-            Sequence< Reference< XCoordinateSystem > > aCooSysSeq(
+            const Sequence< Reference< XCoordinateSystem > > aCooSysSeq(
                 xCoordSysCnt->getCoordinateSystems());
-            for( sal_Int32 nCooSysIdx = 0; nCooSysIdx < 
aCooSysSeq.getLength(); ++nCooSysIdx )
+            for( Reference< XCoordinateSystem > const & coords : aCooSysSeq )
             {
-                Reference< XChartTypeContainer > xContainer( 
aCooSysSeq[nCooSysIdx], uno::UNO_QUERY );
+                Reference< XChartTypeContainer > xContainer( coords, 
uno::UNO_QUERY );
                 if( xContainer.is() )
                     xContainer->setChartTypes( Sequence< Reference< XChartType 
> >() );
             }
@@ -436,12 +434,12 @@ void SAL_CALL ChartTypeTemplate::resetStyles( const 
Reference< chart2::XDiagram
     bool bPercent = (getStackMode(0) == StackMode::YStackedPercent);
     if( bPercent )
     {
-        Sequence< Reference< chart2::XAxis > > aAxisSeq( 
AxisHelper::getAllAxesOfDiagram( xDiagram ) );
-        for( sal_Int32 i=0; i<aAxisSeq.getLength(); ++i )
+        const Sequence< Reference< chart2::XAxis > > aAxisSeq( 
AxisHelper::getAllAxesOfDiagram( xDiagram ) );
+        for( Reference< chart2::XAxis > const & axis : aAxisSeq )
         {
-            if( AxisHelper::getDimensionIndexOfAxis( aAxisSeq[i], xDiagram )== 
1 )
+            if( AxisHelper::getDimensionIndexOfAxis( axis, xDiagram )== 1 )
             {
-                Reference< beans::XPropertySet > xAxisProp( aAxisSeq[i], 
uno::UNO_QUERY );
+                Reference< beans::XPropertySet > xAxisProp( axis, 
uno::UNO_QUERY );
                 if( xAxisProp.is())
                 {
                     // set number format to source format
@@ -457,31 +455,26 @@ void SAL_CALL ChartTypeTemplate::resetStyles( const 
Reference< chart2::XDiagram
         uno::Reference< XCoordinateSystemContainer > xCooSysContainer( 
xDiagram, uno::UNO_QUERY );
         if( xCooSysContainer.is() )
         {
-            uno::Sequence< uno::Reference< XCoordinateSystem > > aCooSysList( 
xCooSysContainer->getCoordinateSystems() );
-            for( sal_Int32 nCS = 0; nCS < aCooSysList.getLength(); ++nCS )
+            const uno::Sequence< uno::Reference< XCoordinateSystem > > 
aCooSysList( xCooSysContainer->getCoordinateSystems() );
+            for( uno::Reference< XCoordinateSystem > const & xCooSys : 
aCooSysList )
             {
-                uno::Reference< XCoordinateSystem > xCooSys( aCooSysList[nCS] 
);
-
                 //iterate through all chart types in the current coordinate 
system
                 uno::Reference< XChartTypeContainer > xChartTypeContainer( 
xCooSys, uno::UNO_QUERY );
                 OSL_ASSERT( xChartTypeContainer.is());
                 if( !xChartTypeContainer.is() )
                     continue;
-                uno::Sequence< uno::Reference< XChartType > > aChartTypeList( 
xChartTypeContainer->getChartTypes() );
-                for( sal_Int32 nT = 0; nT < aChartTypeList.getLength(); ++nT )
+                const uno::Sequence< uno::Reference< XChartType > > 
aChartTypeList( xChartTypeContainer->getChartTypes() );
+                for( uno::Reference< XChartType > const & xChartType : 
aChartTypeList )
                 {
-                    uno::Reference< XChartType > xChartType( 
aChartTypeList[nT] );
-
                     //iterate through all series in this chart type
                     uno::Reference< XDataSeriesContainer > 
xDataSeriesContainer( xChartType, uno::UNO_QUERY );
                     OSL_ASSERT( xDataSeriesContainer.is());
                     if( !xDataSeriesContainer.is() )
                         continue;
 
-                    uno::Sequence< uno::Reference< XDataSeries > > 
aSeriesList( xDataSeriesContainer->getDataSeries() );
-                    for( sal_Int32 nS = 0; nS < aSeriesList.getLength(); ++nS )
+                    const uno::Sequence< uno::Reference< XDataSeries > > 
aSeriesList( xDataSeriesContainer->getDataSeries() );
+                    for( Reference< XDataSeries > const & xSeries : 
aSeriesList )
                     {
-                        Reference< XDataSeries > xSeries(aSeriesList[nS]);
                         Reference< beans::XPropertySet > xSeriesProp( xSeries, 
uno::UNO_QUERY );
                         if(!xSeries.is() || !xSeriesProp.is() )
                             continue;
@@ -600,11 +593,10 @@ void ChartTypeTemplate::adaptScales(
     )
 {
     bool bSupportsCategories( supportsCategories() );
-    for( sal_Int32 nCooSysIdx=0; nCooSysIdx<aCooSysSeq.getLength(); 
++nCooSysIdx )
+    for( Reference< XCoordinateSystem > const & xCooSys : aCooSysSeq )
     {
         try
         {
-            Reference< XCoordinateSystem > xCooSys( aCooSysSeq[nCooSysIdx] );
             if( !xCooSys.is() )
                 continue;
 
@@ -719,9 +711,8 @@ void ChartTypeTemplate::adaptAxes(
     if( !rCoordSys.hasElements() )
         return;
 
-    for( sal_Int32 nCooSysIdx=0; nCooSysIdx < rCoordSys.getLength(); 
++nCooSysIdx )
+    for( Reference< XCoordinateSystem > const & xCooSys : rCoordSys )
     {
-        Reference< XCoordinateSystem > xCooSys( rCoordSys[nCooSysIdx] );
         if( !xCooSys.is() )
             continue;
         sal_Int32 nDimCount = xCooSys->getDimension();
@@ -868,10 +859,8 @@ void 
ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem(
     OUString aNewChartType( xNewChartType->getChartType() );
 
     Reference< beans::XPropertySet > xSource;
-    sal_Int32 nN=0;
-    for( nN=0; nN<rOldChartTypesSeq.getLength();++nN)
+    for( Reference< XChartType > const & xOldType : rOldChartTypesSeq )
     {
-        Reference< XChartType > xOldType( rOldChartTypesSeq[nN] );
         if( xOldType.is() && xOldType->getChartType() == aNewChartType )
         {
             xSource.set( Reference< beans::XPropertySet >(xOldType, 
uno::UNO_QUERY ) );
diff --git a/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx 
b/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx
index 8b357a852e8b..560332b81e98 100644
--- a/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx
+++ b/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx
@@ -284,27 +284,27 @@ sal_Bool SAL_CALL 
ColumnLineChartTypeTemplate::matchesTemplate(
 
         Reference< XCoordinateSystemContainer > xCooSysCnt(
             xDiagram, uno::UNO_QUERY_THROW );
-        Sequence< Reference< XCoordinateSystem > > aCooSysSeq(
+        const Sequence< Reference< XCoordinateSystem > > aCooSysSeq(
             xCooSysCnt->getCoordinateSystems());
-        for( sal_Int32 i=0; i<aCooSysSeq.getLength(); ++i )
+        for( Reference< XCoordinateSystem > const & coords : aCooSysSeq )
         {
-            Reference< XChartTypeContainer > xCTCnt( aCooSysSeq[i], 
uno::UNO_QUERY_THROW );
-            Sequence< Reference< XChartType > > aChartTypeSeq( 
xCTCnt->getChartTypes());
-            for( sal_Int32 j=0; j<aChartTypeSeq.getLength(); ++j )
+            Reference< XChartTypeContainer > xCTCnt( coords, 
uno::UNO_QUERY_THROW );
+            const Sequence< Reference< XChartType > > aChartTypeSeq( 
xCTCnt->getChartTypes());
+            for( Reference< XChartType > const & chartType : aChartTypeSeq )
             {
-                if( aChartTypeSeq[j].is())
+                if( chartType.is())
                 {
                     ++nNumberOfChartTypes;
                     if( nNumberOfChartTypes > 2 )
                         break;
-                    OUString aCTService = aChartTypeSeq[j]->getChartType();
+                    OUString aCTService = chartType->getChartType();
                     if( aCTService == CHART2_SERVICE_NAME_CHARTTYPE_COLUMN )
                     {
-                        xColumnChartType.set( aChartTypeSeq[j] );
-                        xColumnChartCooSys.set( aCooSysSeq[i] );
+                        xColumnChartType.set( chartType );
+                        xColumnChartCooSys.set( coords );
                     }
                     else if( aCTService == CHART2_SERVICE_NAME_CHARTTYPE_LINE )
-                        xLineChartType.set( aChartTypeSeq[j] );
+                        xLineChartType.set( chartType );
                 }
             }
             if( nNumberOfChartTypes > 2 )
diff --git a/chart2/source/model/template/DataInterpreter.cxx 
b/chart2/source/model/template/DataInterpreter.cxx
index 5832612ba91d..7e85e0b36199 100644
--- a/chart2/source/model/template/DataInterpreter.cxx
+++ b/chart2/source/model/template/DataInterpreter.cxx
@@ -66,7 +66,7 @@ InterpretedData SAL_CALL DataInterpreter::interpretDataSource(
     lcl_ShowDataSource( xSource );
 #endif
 
-    Sequence< Reference< data::XLabeledDataSequence > > aData( 
xSource->getDataSequences() );
+    const Sequence< Reference< data::XLabeledDataSequence > > aData( 
xSource->getDataSequences() );
 
     Reference< data::XLabeledDataSequence > xCategories;
     vector< Reference< data::XLabeledDataSequence > > aSequencesVec;
@@ -77,22 +77,22 @@ InterpretedData SAL_CALL 
DataInterpreter::interpretDataSource(
 
     // parse data
     bool bCategoriesUsed = false;
-    for( sal_Int32 i=0; i < aData.getLength(); ++i )
+    for( Reference< data::XLabeledDataSequence > const & labeledData : aData )
     {
         try
         {
             if( bHasCategories && ! bCategoriesUsed )
             {
-                xCategories.set( aData[i] );
+                xCategories.set( labeledData );
                 if( xCategories.is())
                     SetRole( xCategories->getValues(), "categories");
                 bCategoriesUsed = true;
             }
             else
             {
-                aSequencesVec.push_back( aData[i] );
-                if( aData[i].is())
-                    SetRole( aData[i]->getValues(), "values-y");
+                aSequencesVec.push_back( labeledData );
+                if( labeledData.is())
+                    SetRole( labeledData->getValues(), "values-y");
             }
         }
         catch( const uno::Exception & )
@@ -165,7 +165,7 @@ InterpretedData SAL_CALL 
DataInterpreter::reinterpretDataSeries(
             {
 #ifdef DEBUG_CHART2_TEMPLATE
                 sal_Int32 j=0;
-                for( ; j<aSeqs.getLength(); ++j )
+                for( ; j<aSeqs.(); ++j )
                 {
                     assert( aSeqs[j] == xValuesY && "All sequences should be 
used" );
                 }
@@ -187,12 +187,12 @@ InterpretedData SAL_CALL 
DataInterpreter::reinterpretDataSeries(
 sal_Bool SAL_CALL DataInterpreter::isDataCompatible(
     const chart2::InterpretedData& aInterpretedData )
 {
-    Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( 
aInterpretedData.Series ));
-    for( sal_Int32 i=0; i<aSeries.getLength(); ++i )
+    const Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( 
aInterpretedData.Series ));
+    for( Reference< XDataSeries > const & i : aSeries )
     {
         try
         {
-            Reference< data::XDataSource > xSrc( aSeries[i], 
uno::UNO_QUERY_THROW );
+            Reference< data::XDataSource > xSrc( i, uno::UNO_QUERY_THROW );
             Sequence< Reference< data::XLabeledDataSequence > > aSeq( 
xSrc->getDataSequences());
             if( aSeq.getLength() != 1 )
                 return false;
@@ -270,19 +270,17 @@ Reference< data::XDataSource > SAL_CALL 
DataInterpreter::mergeInterpretedData(
     if( aInterpretedData.Categories.is())
         aResultVec.push_back( aInterpretedData.Categories );
 
-    Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( 
aInterpretedData.Series ));
-    for( sal_Int32 nSeriesIdx=0; nSeriesIdx<aSeries.getLength(); ++nSeriesIdx )
+    const Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( 
aInterpretedData.Series ));
+    for( Reference< XDataSeries > const & dataSeries : aSeries )
     {
         try
         {
-            Reference< data::XDataSource > xSrc( aSeries[nSeriesIdx], 
uno::UNO_QUERY_THROW );
-            Sequence< Reference< data::XLabeledDataSequence > > aSeq( 
xSrc->getDataSequences());
+            Reference< data::XDataSource > xSrc( dataSeries, 
uno::UNO_QUERY_THROW );
+            const Sequence< Reference< data::XLabeledDataSequence > > aSeq( 
xSrc->getDataSequences());
 
             // add all sequences of data series
-            for( sal_Int32 nSeqIdx=0; nSeqIdx<aSeq.getLength(); ++nSeqIdx )
+            for( Reference< data::XLabeledDataSequence > const & xAdd : aSeq )
             {
-                Reference< data::XLabeledDataSequence > xAdd( aSeq[nSeqIdx] );
-
                 // only add if sequence is not yet in the result
                 if( none_of( aResultVec.begin(), aResultVec.end(),
                              lcl_LabeledSequenceEquals( xAdd )) )
diff --git a/chart2/source/model/template/PieChartTypeTemplate.cxx 
b/chart2/source/model/template/PieChartTypeTemplate.cxx
index 56acc536f39e..964b5d96d5c2 100644
--- a/chart2/source/model/template/PieChartTypeTemplate.cxx
+++ b/chart2/source/model/template/PieChartTypeTemplate.cxx
@@ -226,12 +226,12 @@ void PieChartTypeTemplate::adaptScales(
     //remove explicit scalings from radius axis
     //and ensure correct orientation of scales for donuts
 
-    for( sal_Int32 nCooSysIdx=0; nCooSysIdx<aCooSysSeq.getLength(); 
++nCooSysIdx )
+    for( Reference< chart2::XCoordinateSystem > const & coords : aCooSysSeq )
     {
         try
         {
             Reference< chart2::XAxis > xAxis( AxisHelper::getAxis( 1 
/*nDimensionIndex*/,0 /*nAxisIndex*/
-                    , aCooSysSeq[nCooSysIdx] ) );
+                    , coords ) );
             if( xAxis.is() )
             {
                 chart2::ScaleData aScaleData( xAxis->getScaleData() );
@@ -241,7 +241,7 @@ void PieChartTypeTemplate::adaptScales(
             }
 
             xAxis = AxisHelper::getAxis( 0 /*nDimensionIndex*/,0 /*nAxisIndex*/
-                    , aCooSysSeq[nCooSysIdx] );
+                    , coords );
             if( xAxis.is() )
             {
                 chart2::ScaleData aScaleData( xAxis->getScaleData() );
@@ -479,10 +479,10 @@ void SAL_CALL PieChartTypeTemplate::applyStyle(
                 {
                     fOffsetToSet = 0.0;
                     bSetOffset = true;
-                    for( sal_Int32 nPtIdx=0; 
nPtIdx<aAttributedDataPointIndexList.getLength(); ++nPtIdx )
+                    for( auto const & pointIndex : 
std::as_const(aAttributedDataPointIndexList) )
                     {
                         uno::Reference< beans::XPropertySet > xPointProp(
-                            xSeries->getDataPointByIndex( 
aAttributedDataPointIndexList[ nPtIdx ] ));
+                            xSeries->getDataPointByIndex( pointIndex ));
                         uno::Reference< beans::XPropertyState > xPointState( 
xPointProp, uno::UNO_QUERY );
                         double fPointOffset = 0.0;
                         if( xPointState.is() &&
@@ -504,10 +504,10 @@ void SAL_CALL PieChartTypeTemplate::applyStyle(
                 xProp->setPropertyValue( aOffsetPropName, uno::Any( 
fOffsetToSet ));
 
                 // remove hard attributes from data points
-                for( sal_Int32 nPtIdx=0; 
nPtIdx<aAttributedDataPointIndexList.getLength(); ++nPtIdx )
+                for( auto const & pointIndex : 
std::as_const(aAttributedDataPointIndexList) )
                 {
                     uno::Reference< beans::XPropertyState > xPointState(
-                        xSeries->getDataPointByIndex( 
aAttributedDataPointIndexList[ nPtIdx ] ), uno::UNO_QUERY );
+                        xSeries->getDataPointByIndex( pointIndex ), 
uno::UNO_QUERY );
                     if( xPointState.is())
                         xPointState->setPropertyToDefault( aOffsetPropName );
                 }
@@ -532,16 +532,16 @@ void SAL_CALL PieChartTypeTemplate::resetStyles( const 
Reference< chart2::XDiagr
     Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, 
uno::UNO_QUERY );
     if( xCooSysCnt.is())
     {
-        Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( 
xCooSysCnt->getCoordinateSystems());
+        const Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( 
xCooSysCnt->getCoordinateSystems());
         ChartTypeTemplate::createAxes( aCooSysSeq );
 
         //reset scale orientation
-        for( sal_Int32 nCooSysIdx=0; nCooSysIdx<aCooSysSeq.getLength(); 
++nCooSysIdx )
+        for( Reference< chart2::XCoordinateSystem > const & coords : 
aCooSysSeq )
         {
             try
             {
                 Reference< chart2::XAxis > xAxis( AxisHelper::getAxis( 0 
/*nDimensionIndex*/,0 /*nAxisIndex*/
-                        , aCooSysSeq[nCooSysIdx] ) );
+                        , coords ) );
                 if( xAxis.is() )
                 {
                     chart2::ScaleData aScaleData( xAxis->getScaleData() );
@@ -549,7 +549,7 @@ void SAL_CALL PieChartTypeTemplate::resetStyles( const 
Reference< chart2::XDiagr
                     xAxis->setScaleData( aScaleData );
                 }
 
-                xAxis = AxisHelper::getAxis( 1, 0, aCooSysSeq[nCooSysIdx] );
+                xAxis = AxisHelper::getAxis( 1, 0, coords );
                 if( xAxis.is() )
                 {
                     chart2::ScaleData aScaleData( xAxis->getScaleData() );
diff --git a/chart2/source/model/template/StockChartTypeTemplate.cxx 
b/chart2/source/model/template/StockChartTypeTemplate.cxx
index 807cc6dd7dfd..7eb0e1ca51da 100644
--- a/chart2/source/model/template/StockChartTypeTemplate.cxx
+++ b/chart2/source/model/template/StockChartTypeTemplate.cxx
@@ -409,26 +409,26 @@ sal_Bool SAL_CALL StockChartTypeTemplate::matchesTemplate(
 
         Reference< XCoordinateSystemContainer > xCooSysCnt(
             xDiagram, uno::UNO_QUERY_THROW );
-        Sequence< Reference< XCoordinateSystem > > aCooSysSeq(
+        const Sequence< Reference< XCoordinateSystem > > aCooSysSeq(
             xCooSysCnt->getCoordinateSystems());
-        for( sal_Int32 i=0; i<aCooSysSeq.getLength(); ++i )
+        for( Reference< XCoordinateSystem > const & coords : aCooSysSeq )
         {
-            Reference< XChartTypeContainer > xCTCnt( aCooSysSeq[i], 
uno::UNO_QUERY_THROW );
-            Sequence< Reference< XChartType > > aChartTypeSeq( 
xCTCnt->getChartTypes());
-            for( sal_Int32 j=0; j<aChartTypeSeq.getLength(); ++j )
+            Reference< XChartTypeContainer > xCTCnt( coords, 
uno::UNO_QUERY_THROW );
+            const Sequence< Reference< XChartType > > aChartTypeSeq( 
xCTCnt->getChartTypes());
+            for( Reference< XChartType >  const & chartType : aChartTypeSeq )
             {
-                if( aChartTypeSeq[j].is())
+                if( chartType.is())
                 {
                     ++nNumberOfChartTypes;
                     if( nNumberOfChartTypes > 3 )
                         break;
-                    OUString aCTService = aChartTypeSeq[j]->getChartType();
+                    OUString aCTService = chartType->getChartType();
                     if( aCTService == CHART2_SERVICE_NAME_CHARTTYPE_COLUMN )
-                        xVolumeChartType.set( aChartTypeSeq[j] );
+                        xVolumeChartType.set( chartType );
                     else if( aCTService == 
CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK )
-                        xCandleStickChartType.set( aChartTypeSeq[j] );
+                        xCandleStickChartType.set( chartType );
                     else if( aCTService == CHART2_SERVICE_NAME_CHARTTYPE_LINE )
-                        xLineChartType.set( aChartTypeSeq[j] );
+                        xLineChartType.set( chartType );
                 }
             }
             if( nNumberOfChartTypes > 3 )
diff --git a/chart2/source/model/template/StockDataInterpreter.cxx 
b/chart2/source/model/template/StockDataInterpreter.cxx
index d2ad7b296604..15c2891975ad 100644
--- a/chart2/source/model/template/StockDataInterpreter.cxx
+++ b/chart2/source/model/template/StockDataInterpreter.cxx
@@ -282,14 +282,14 @@ sal_Bool SAL_CALL StockDataInterpreter::isDataCompatible(
     // 2. b. candlestick
     {
         OSL_ASSERT( aInterpretedData.Series.getLength() > (bHasVolume ? 1 : 
0));
-        Sequence< Reference< XDataSeries > > aSeries( 
aInterpretedData.Series[(bHasVolume ? 1 : 0)] );
+        const Sequence< Reference< XDataSeries > > aSeries( 
aInterpretedData.Series[(bHasVolume ? 1 : 0)] );
         if(!aSeries.hasElements())
             return false;
-        for( sal_Int32 i=0; i<aSeries.getLength(); ++i )
+        for( Reference< XDataSeries > const & dataSeries : aSeries )
         {
             try
             {
-                Reference< data::XDataSource > xSrc( aSeries[i], 
uno::UNO_QUERY_THROW );
+                Reference< data::XDataSource > xSrc( dataSeries, 
uno::UNO_QUERY_THROW );
                 Sequence< Reference< data::XLabeledDataSequence > > aSeq( 
xSrc->getDataSequences());
                 if( aSeq.getLength() != nNumberOfNecessarySequences )
                     return false;
diff --git a/chart2/source/model/template/XYDataInterpreter.cxx 
b/chart2/source/model/template/XYDataInterpreter.cxx
index a1a1ed2d329d..a3fb67fa9202 100644
--- a/chart2/source/model/template/XYDataInterpreter.cxx
+++ b/chart2/source/model/template/XYDataInterpreter.cxx
@@ -54,7 +54,7 @@ chart2::InterpretedData SAL_CALL 
XYDataInterpreter::interpretDataSource(
     if( ! xSource.is())
         return InterpretedData();
 
-    Sequence< Reference< data::XLabeledDataSequence > > aData( 
xSource->getDataSequences() );
+    const Sequence< Reference< data::XLabeledDataSequence > > aData( 
xSource->getDataSequences() );
 
     Reference< data::XLabeledDataSequence > xValuesX;
     vector< Reference< data::XLabeledDataSequence > > aSequencesVec;
@@ -66,13 +66,13 @@ chart2::InterpretedData SAL_CALL 
XYDataInterpreter::interpretDataSource(
     // parse data
     bool bCategoriesUsed = false;
     bool bSetXValues = aData.getLength()>1;
-    for( sal_Int32 nDataIdx= 0; nDataIdx < aData.getLength(); ++nDataIdx )
+    for( Reference< data::XLabeledDataSequence > const & labelData : aData )
     {
         try
         {
             if( bHasCategories && ! bCategoriesUsed )
             {
-                xCategories.set( aData[nDataIdx] );
+                xCategories.set( labelData );
                 if( xCategories.is())
                 {
                     SetRole( xCategories->getValues(), "categories");
@@ -83,15 +83,15 @@ chart2::InterpretedData SAL_CALL 
XYDataInterpreter::interpretDataSource(
             }
             else if( !xValuesX.is() && bSetXValues )
             {
-                xValuesX.set( aData[nDataIdx] );
+                xValuesX.set( labelData );
                 if( xValuesX.is())
                     SetRole( xValuesX->getValues(), "values-x");
             }
             else
             {
-                aSequencesVec.push_back( aData[nDataIdx] );
-                if( aData[nDataIdx].is())
-                    SetRole( aData[nDataIdx]->getValues(), "values-y");
+                aSequencesVec.push_back( labelData );
+                if( labelData.is())
+                    SetRole( labelData->getValues(), "values-y");
             }
         }
         catch( const uno::Exception & )
@@ -202,14 +202,13 @@ chart2::InterpretedData SAL_CALL 
XYDataInterpreter::reinterpretDataSeries(
                 }
             }
 
-            Sequence< Reference< data::XLabeledDataSequence > > aSeqs( 
xSeriesSource->getDataSequences());
+            const Sequence< Reference< data::XLabeledDataSequence > > aSeqs( 
xSeriesSource->getDataSequences());
             if( aSeqs.getLength() != aNewSequences.getLength() )
             {
 #ifdef DBG_UTIL
-                sal_Int32 j=0;
-                for( ; j<aSeqs.getLength(); ++j )
+                for( auto const & j : aSeqs )
                 {
-                    SAL_WARN_IF((aSeqs[j] == xValuesY || aSeqs[j] == 
xValuesX), "chart2.template", "All sequences should be used" );
+                    SAL_WARN_IF((j == xValuesY || j == xValuesX), 
"chart2.template", "All sequences should be used" );
                 }
 #endif
                 Reference< data::XDataSink > xSink( xSeriesSource, 
uno::UNO_QUERY_THROW );
@@ -229,12 +228,12 @@ chart2::InterpretedData SAL_CALL 
XYDataInterpreter::reinterpretDataSeries(
 sal_Bool SAL_CALL XYDataInterpreter::isDataCompatible(
     const chart2::InterpretedData& aInterpretedData )
 {
-    Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( 
aInterpretedData.Series ));
-    for( sal_Int32 i=0; i<aSeries.getLength(); ++i )
+    const Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( 
aInterpretedData.Series ));
+    for( Reference< XDataSeries > const & dataSeries : aSeries )
     {
         try
         {
-            Reference< data::XDataSource > xSrc( aSeries[i], 
uno::UNO_QUERY_THROW );
+            Reference< data::XDataSource > xSrc( dataSeries, 
uno::UNO_QUERY_THROW );
             Sequence< Reference< data::XLabeledDataSequence > > aSeq( 
xSrc->getDataSequences());
             if( aSeq.getLength() != 2 )
                 return false;
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.getLength(); 
++nCTIdx )
+                const Sequence< Reference< XChartType > > 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<aDataSeriesSeq.getLength(); ++nSeriesIdx )
+                        aRoleToMatch = 
ChartTypeHelper::getRoleOfSequenceForYAxisNumberFormatDetection( chartType );
+                    Reference< XDataSeriesContainer > 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.getLength(); nN++)
-            AxisHelper::makeGridVisible( aSubGrids[nN] );
+        const Sequence< Reference< beans::XPropertySet > > 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.getLength(); nN++)
-            AxisHelper::makeGridInvisible( aSubGrids[nN] );
+        const Sequence< Reference< beans::XPropertySet > > 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.getLength(); ++nC )
+        const Sequence< Reference< XCoordinateSystem > > 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<aAllAxes.getLength(); ++nA )
+    for( Reference< XAxis > 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.getLength(); ++i )
+        const Sequence< Reference< chart2::XChartType > > 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.getLength(); ++i )
+                    const uno::Sequence< uno::Reference< 
chart2::data::XLabeledDataSequence > > 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<aPropertyNames.getLength(); ++nIdx )
+    for( OUString const & s : aPropertyNames )
     {
-        if( m_aPropertiesToNotify.find( aPropertyNames[nIdx] ) != 
m_aPropertiesToNotify.end())
-            m_rListener.notify( aPropertyNames[nIdx] );
+        if( m_aPropertiesToNotify.find( s ) != m_aPropertiesToNotify.end())
+            m_rListener.notify( s );
     }
 }
 
diff --git a/chart2/source/tools/DataSeriesHelper.cxx 
b/chart2/source/tools/DataSeriesHelper.cxx
index a772f11c5fb1..c90a356bf2ee 100644
--- a/chart2/source/tools/DataSeriesHelper.cxx
+++ b/chart2/source/tools/DataSeriesHelper.cxx
@@ -87,17 +87,17 @@ 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<aSequences.getLength(); ++i )
+    for( auto const & labeledData : aSequences )
     {
-        OSL_ENSURE( aSequences[i].is(), "empty LabeledDataSequence" );
+        OSL_ENSURE( labeledData.is(), "empty LabeledDataSequence" );
         // no values are set but a label exists
-        if( aSequences[i].is() &&
-            ( ! aSequences[i]->getValues().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.getLength(); 
++nCooSysIdx )
+    const Sequence< Reference< chart2::XCoordinateSystem > > 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<aChartTypes.getLength(); ++nCTIdx )
+        Reference< chart2::XChartTypeContainer > 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.getLength(); 
++nSeriesIdx )
+                const Sequence< Reference< chart2::XDataSeries > > 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<uno::Reference<chart2::XDataSeries> >&
 {
     std::vector< Reference< chart2::data::XLabeledDataSequence > > aSeqVec;
 
-    for( sal_Int32 i = 0; i < aSeries.getLength(); ++i )
+    for( uno::Reference<chart2::XDataSeries> 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<aSeries.getLength(); ++i )
+    for( Reference< chart2::XDataSeries > 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<aDataSequences.getLength(); nN++ )
+    for(  Reference< chart2::data::XLabeledDataSequence > 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.getLength(); ++i )
+        const Sequence< Reference< data::XLabeledDataSequence > > 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<XCoordinateSystem> > aCooSys = 
xCnt->getCoordinateSystems();
+        const Sequence< Reference<XCoordinateSystem> > aCooSys = 
xCnt->getCoordinateSystems();
         uno::Any aValue;
         aValue <<= bVertical;
-        for( sal_Int32 i=0; i<aCooSys.getLength(); ++i )
+        for( uno::Reference< XCoordinateSystem > 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<XCoordinateSystem> > aCooSys = 
xCnt->getCoordinateSystems();
+    const Sequence< Reference<XCoordinateSystem> > aCooSys = 
xCnt->getCoordinateSystems();
 
-    for (sal_Int32 i = 0; i < aCooSys.getLength(); ++i)
+    for (Reference<XCoordinateSystem> const & coords : aCooSys)
     {
-        Reference<beans::XPropertySet> xProp(aCooSys[i], uno::UNO_QUERY);
+        Reference<beans::XPropertySet> 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 )
     {

... etc. - the rest is truncated
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to