[Libreoffice-commits] core.git: xmloff/source

Arkadiy Illarionov (via logerrit) logerrit at kemper.freedesktop.org
Thu Jun 13 07:19:18 UTC 2019


 xmloff/source/chart/SchXMLChartContext.cxx           |   18 --
 xmloff/source/chart/SchXMLExport.cxx                 |  154 ++++++-------------
 xmloff/source/chart/SchXMLImport.cxx                 |   20 --
 xmloff/source/chart/SchXMLSeries2Context.cxx         |    7 
 xmloff/source/chart/SchXMLSeriesHelper.cxx           |   25 ---
 xmloff/source/chart/SchXMLTableContext.cxx           |   20 +-
 xmloff/source/chart/SchXMLTools.cxx                  |    5 
 xmloff/source/core/DocumentSettingsContext.cxx       |    5 
 xmloff/source/core/PropertySetMerger.cxx             |    7 
 xmloff/source/core/SettingsExportHelper.cxx          |   36 +---
 xmloff/source/core/XMLEmbeddedObjectExportFilter.cxx |   11 -
 xmloff/source/core/xmlexp.cxx                        |   57 +------
 xmloff/source/core/xmlictxt.cxx                      |    7 
 xmloff/source/core/xmlimp.cxx                        |    7 
 xmloff/source/core/xmluconv.cxx                      |   21 +-
 15 files changed, 144 insertions(+), 256 deletions(-)

New commits:
commit 9a18e4e0bfee4d29ee02258c70cc9edf4e7b086b
Author:     Arkadiy Illarionov <qarkai at gmail.com>
AuthorDate: Sun May 12 16:51:02 2019 +0300
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Jun 13 09:18:42 2019 +0200

    Simplify Sequence iterations in xmloff/source/{chart..core}
    
    Use range-based loops or replace with comphelper or STL functions
    
    Change-Id: I131b77ad7d68897fcfe07284edcf38397589278f
    Reviewed-on: https://gerrit.libreoffice.org/72192
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/xmloff/source/chart/SchXMLChartContext.cxx b/xmloff/source/chart/SchXMLChartContext.cxx
index 7c3d355f9c64..6cc3a29a7828 100644
--- a/xmloff/source/chart/SchXMLChartContext.cxx
+++ b/xmloff/source/chart/SchXMLChartContext.cxx
@@ -963,19 +963,17 @@ void SchXMLChartContext::MergeSeriesForStockChart()
         uno::Reference< chart2::XDataSeriesContainer > xDSContainer;
         uno::Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY_THROW );
         uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems());
-        for( sal_Int32 nCooSysIdx=0; nCooSysIdx<aCooSysSeq.getLength(); ++nCooSysIdx )
+        for( const auto& rCooSys : aCooSysSeq )
         {
-            uno::Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[nCooSysIdx], uno::UNO_QUERY_THROW );
+            uno::Reference< chart2::XChartTypeContainer > xCTCnt( rCooSys, uno::UNO_QUERY_THROW );
             uno::Sequence< uno::Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes());
-            for( sal_Int32 nCTIdx=0; nCTIdx<aChartTypes.getLength(); ++nCTIdx )
+            auto pChartType = std::find_if(aChartTypes.begin(), aChartTypes.end(),
+                [](const auto& rChartType) { return rChartType->getChartType() == "com.sun.star.chart2.CandleStickChartType"; });
+            if (pChartType != aChartTypes.end())
             {
-                if( aChartTypes[nCTIdx]->getChartType() == "com.sun.star.chart2.CandleStickChartType" )
-                {
-                    xDSContainer.set( aChartTypes[nCTIdx], uno::UNO_QUERY_THROW );
-                    uno::Reference< beans::XPropertySet > xCTProp( aChartTypes[nCTIdx], uno::UNO_QUERY_THROW );
-                    xCTProp->getPropertyValue("Japanese") >>= bHasJapaneseCandlestick;
-                    break;
-                }
+                xDSContainer.set( *pChartType, uno::UNO_QUERY_THROW );
+                uno::Reference< beans::XPropertySet > xCTProp( *pChartType, uno::UNO_QUERY_THROW );
+                xCTProp->getPropertyValue("Japanese") >>= bHasJapaneseCandlestick;
             }
         }
 
diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx
index 6507cb91b926..b1785d5330f4 100644
--- a/xmloff/source/chart/SchXMLExport.cxx
+++ b/xmloff/source/chart/SchXMLExport.cxx
@@ -53,6 +53,7 @@
 #include <algorithm>
 #include <queue>
 #include <iterator>
+#include <numeric>
 
 #include <com/sun/star/task/XStatusIndicatorSupplier.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
@@ -320,9 +321,9 @@ Reference< chart2::data::XLabeledDataSequence > lcl_getCategories( const Referen
             xDiagram, uno::UNO_QUERY_THROW );
         Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq(
             xCooSysCnt->getCoordinateSystems());
-        for( sal_Int32 i=0; i<aCooSysSeq.getLength(); ++i )
+        for( const auto& rCooSys : aCooSysSeq )
         {
-            Reference< chart2::XCoordinateSystem > xCooSys( aCooSysSeq[i] );
+            Reference< chart2::XCoordinateSystem > xCooSys( rCooSys );
             SAL_WARN_IF( !xCooSys.is(), "xmloff.chart", "xCooSys is NULL" );
             for( sal_Int32 nN = xCooSys->getDimension(); nN--; )
             {
@@ -426,11 +427,8 @@ Reference< chart2::data::XDataSource > lcl_pressUsedDataIntoRectangularFormat( c
 
     //add all other sequences now without x-values
     lcl_MatchesRole aHasXValues( "values-x" );
-    for( sal_Int32 nN=0; nN<aSeriesSeqVector.getLength(); nN++ )
-    {
-        if( !aHasXValues( aSeriesSeqVector[nN] ) )
-            aLabeledSeqVector.push_back( aSeriesSeqVector[nN] );
-    }
+    std::copy_if(aSeriesSeqVector.begin(), aSeriesSeqVector.end(), std::back_inserter(aLabeledSeqVector),
+                 [&aHasXValues](const auto& rSeriesSeq) { return !aHasXValues( rSeriesSeq ); });
 
     Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeq( comphelper::containerToSequence(aLabeledSeqVector) );
 
@@ -516,13 +514,13 @@ OUString lcl_flattenStringSequence( const Sequence< OUString > & rSequence )
 {
     OUStringBuffer aResult;
     bool bPrecedeWithSpace = false;
-    for( sal_Int32 nIndex=0; nIndex<rSequence.getLength(); ++nIndex )
+    for( const auto& rString : rSequence )
     {
-        if( !rSequence[nIndex].isEmpty())
+        if( !rString.isEmpty())
         {
             if( bPrecedeWithSpace )
                 aResult.append( ' ' );
-            aResult.append( rSequence[nIndex] );
+            aResult.append( rString );
             bPrecedeWithSpace = true;
         }
     }
@@ -615,37 +613,20 @@ uno::Sequence< OUString > lcl_DataSequenceToStringSequence(
         if( aRole.match("values-x") )
         {
             //lcl_clearIfNoValuesButTextIsContained - replace by indices if the values are not appropriate
-            bool bHasValue=false;
-            bool bHasText=false;
-            sal_Int32 nCount = aValuesSequence.getLength();
-            for( sal_Int32 j = 0; j < nCount; ++j )
-            {
-                if( !::rtl::math::isNan( aValuesSequence[j] ) )
-                {
-                    bHasValue=true;
-                    break;
-                }
-            }
+            bool bHasValue = std::any_of(aValuesSequence.begin(), aValuesSequence.end(),
+                [](double fValue) { return !::rtl::math::isNan( fValue ); });
             if(!bHasValue)
             {
                 //no double value is contained
                 //is there any text?
                 uno::Sequence< OUString > aStrings( lcl_DataSequenceToStringSequence( xSeq ) );
-                sal_Int32 nTextCount = aStrings.getLength();
-                for( sal_Int32 j = 0; j < nTextCount; ++j )
+                bool bHasText = std::any_of(aStrings.begin(), aStrings.end(),
+                    [](const OUString& rString) { return !rString.isEmpty(); });
+                if( bHasText )
                 {
-                    if( !aStrings[j].isEmpty() )
-                    {
-                        bHasText=true;
-                        break;
-                    }
+                    std::iota(aValuesSequence.begin(), aValuesSequence.end(), 1);
                 }
             }
-            if( !bHasValue && bHasText )
-            {
-                for( sal_Int32 j = 0; j < nCount; ++j )
-                    aValuesSequence[j] = j+1;
-            }
         }
     }
 
@@ -902,13 +883,13 @@ void lcl_exportNumberFormat( const OUString& rPropertyName, const Reference< bea
 
     Sequence< Reference< chart2::data::XLabeledDataSequence > > aSequences(
         xErrorBarDataSource->getDataSequences());
-    for( sal_Int32 nI=0; nI< aSequences.getLength(); ++nI )
+    for( const auto& rSequence : aSequences )
     {
         try
         {
-            if( aSequences[nI].is())
+            if( rSequence.is())
             {
-                Reference< chart2::data::XDataSequence > xSequence( aSequences[nI]->getValues());
+                Reference< chart2::data::XDataSequence > xSequence( rSequence->getValues());
                 Reference< beans::XPropertySet > xSeqProp( xSequence, uno::UNO_QUERY_THROW );
                 OUString aRole;
                 if( ( xSeqProp->getPropertyValue( "Role" ) >>= aRole ) &&
@@ -1062,14 +1043,10 @@ void SchXMLExportHelper_Impl::exportChart( Reference< chart::XChartDocument > co
 
 static OUString lcl_GetStringFromNumberSequence( const css::uno::Sequence< sal_Int32 >& rSequenceMapping, bool bRemoveOneFromEachIndex /*should be true if having categories*/ )
 {
-    const sal_Int32* pArray = rSequenceMapping.getConstArray();
-    const sal_Int32 nSize = rSequenceMapping.getLength();
-    sal_Int32 i = 0;
     OUStringBuffer aBuf;
     bool bHasPredecessor = false;
-    for( i = 0; i < nSize; ++i )
+    for( sal_Int32 nIndex : rSequenceMapping )
     {
-        sal_Int32 nIndex = pArray[ i ];
         if( bRemoveOneFromEachIndex )
             --nIndex;
         if(nIndex>=0)
@@ -1512,11 +1489,11 @@ static void lcl_exportComplexLabel( const Sequence< uno::Any >& rComplexLabel, S
     if( nLength<=1 )
         return;
     SvXMLElementExport aTextList( rExport, XML_NAMESPACE_TEXT, XML_LIST, true, true );
-    for(sal_Int32 nN=0; nN<nLength; nN++)
+    for(const auto& rElem : rComplexLabel)
     {
         SvXMLElementExport aListItem( rExport, XML_NAMESPACE_TEXT, XML_LIST_ITEM, true, true );
         OUString aString;
-        if( !(rComplexLabel[nN]>>=aString) )
+        if( !(rElem >>= aString) )
         {
             //todo?
         }
@@ -2459,24 +2436,17 @@ namespace
         if( xNumericalDataSequence.is() )
         {
             Sequence< double >  aDoubles( xNumericalDataSequence->getNumericalData() );
-            sal_Int32 nCount = aDoubles.getLength();
-            for( sal_Int32 i = 0; i < nCount; ++i )
-            {
-                if( !::rtl::math::isNan( aDoubles[i] ) )
-                    return false;//have double value
-            }
+            if (std::any_of(aDoubles.begin(), aDoubles.end(), [](double fDouble) { return !::rtl::math::isNan( fDouble ); }))
+                return false;//have double value
         }
         else
         {
             aData = xDataSequence->getData();
             double fDouble = 0.0;
-            sal_Int32 nCount = aData.getLength();
-            for( sal_Int32 i = 0; i < nCount; ++i )
-            {
-                if( (aData[i] >>= fDouble) && !::rtl::math::isNan( fDouble ) )
-                    return false;//have double value
-            }
-
+            bool bHaveDouble = std::any_of(aData.begin(), aData.end(),
+                [&fDouble](const uno::Any& rData) { return (rData >>= fDouble) && !::rtl::math::isNan( fDouble ); });
+            if (bHaveDouble)
+                return false;//have double value
         }
         //no values found
 
@@ -2484,24 +2454,18 @@ namespace
         if( xTextualDataSequence.is() )
         {
             uno::Sequence< OUString > aStrings( xTextualDataSequence->getTextualData() );
-            sal_Int32 nCount = aStrings.getLength();
-            for( sal_Int32 i = 0; i < nCount; ++i )
-            {
-                if( !aStrings[i].isEmpty() )
-                    return true;//have text
-            }
+            if (std::any_of(aStrings.begin(), aStrings.end(), [](const OUString& rString) { return !rString.isEmpty(); }))
+                return true;//have text
         }
         else
         {
             if( !aData.hasElements() )
                 aData = xDataSequence->getData();
             OUString aString;
-            sal_Int32 nCount = aData.getLength();
-            for( sal_Int32 i = 0; i < nCount; ++i )
-            {
-                if( (aData[i]>>=aString) && !aString.isEmpty() )
-                    return true;//have text
-            }
+            bool bHaveText = std::any_of(aData.begin(), aData.end(),
+                [&aString](const uno::Any& rData) { return (rData >>= aString) && !aString.isEmpty(); });
+            if (bHaveText)
+                return true;//have text
         }
         //no doubles and no texts
         return false;
@@ -2526,26 +2490,26 @@ void SchXMLExportHelper_Impl::exportSeries(
 
     Sequence< Reference< chart2::XCoordinateSystem > >
         aCooSysSeq( xBCooSysCnt->getCoordinateSystems());
-    for( sal_Int32 nCSIdx=0; nCSIdx<aCooSysSeq.getLength(); ++nCSIdx )
+    for( const auto& rCooSys : aCooSysSeq )
     {
-        Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[nCSIdx], uno::UNO_QUERY );
+        Reference< chart2::XChartTypeContainer > xCTCnt( rCooSys, uno::UNO_QUERY );
         if( ! xCTCnt.is())
             continue;
         Sequence< Reference< chart2::XChartType > > aCTSeq( xCTCnt->getChartTypes());
-        for( sal_Int32 nCTIdx=0; nCTIdx<aCTSeq.getLength(); ++nCTIdx )
+        for( const auto& rChartType : aCTSeq )
         {
-            Reference< chart2::XDataSeriesContainer > xDSCnt( aCTSeq[nCTIdx], uno::UNO_QUERY );
+            Reference< chart2::XDataSeriesContainer > xDSCnt( rChartType, uno::UNO_QUERY );
             if( ! xDSCnt.is())
                 continue;
             // note: if xDSCnt.is() then also aCTSeq[nCTIdx]
-            OUString aChartType( aCTSeq[nCTIdx]->getChartType());
-            OUString aLabelRole = aCTSeq[nCTIdx]->getRoleOfSequenceForSeriesLabel();
+            OUString aChartType( rChartType->getChartType());
+            OUString aLabelRole = rChartType->getRoleOfSequenceForSeriesLabel();
 
             // special export for stock charts
             if ( aChartType == "com.sun.star.chart2.CandleStickChartType" )
             {
                 bool bJapaneseCandleSticks = false;
-                Reference< beans::XPropertySet > xCTProp( aCTSeq[nCTIdx], uno::UNO_QUERY );
+                Reference< beans::XPropertySet > xCTProp( rChartType, uno::UNO_QUERY );
                 if( xCTProp.is())
                     xCTProp->getPropertyValue("Japanese") >>= bJapaneseCandleSticks;
                 exportCandleStickSeries(
@@ -2835,7 +2799,7 @@ void SchXMLExportHelper_Impl::exportSeries(
                     const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() );
                     if( bExportContent && nCurrentODFVersion > SvtSaveOptions::ODFVER_012 )//do not export to ODF 1.2 or older
                     {
-                        Sequence< OUString > aSupportedMappings = aCTSeq[nCTIdx]->getSupportedPropertyRoles();
+                        Sequence< OUString > aSupportedMappings = rChartType->getSupportedPropertyRoles();
                         exportPropertyMapping( xSource, aSupportedMappings );
                     }
 
@@ -2855,15 +2819,15 @@ void SchXMLExportHelper_Impl::exportPropertyMapping(
     Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeqCnt(
             xSource->getDataSequences());
 
-    for(sal_Int32 i = 0, n = rSupportedMappings.getLength(); i < n; ++i)
+    for(const auto& rSupportedMapping : rSupportedMappings)
     {
-        Reference< chart2::data::XLabeledDataSequence > xSequence( lcl_getDataSequenceByRole( aSeqCnt, rSupportedMappings[i] ) );
+        Reference< chart2::data::XLabeledDataSequence > xSequence( lcl_getDataSequenceByRole( aSeqCnt, rSupportedMapping ) );
         if(xSequence.is())
         {
             Reference< chart2::data::XDataSequence > xValues( xSequence->getValues() );
             if( xValues.is())
             {
-                mrExport.AddAttribute( XML_NAMESPACE_LO_EXT, XML_PROPERTY, rSupportedMappings[i]);
+                mrExport.AddAttribute( XML_NAMESPACE_LO_EXT, XML_PROPERTY, rSupportedMapping);
                 mrExport.AddAttribute( XML_NAMESPACE_LO_EXT, XML_CELL_RANGE_ADDRESS,
                         lcl_ConvertRange(
                             xValues->getSourceRangeRepresentation(),
@@ -2890,14 +2854,9 @@ void SchXMLExportHelper_Impl::exportRegressionCurve(
     {
         Sequence< Reference< chart2::XRegressionCurve > > aRegCurveSeq = xRegressionCurveContainer->getRegressionCurves();
 
-        const Reference< chart2::XRegressionCurve >* pBeg = aRegCurveSeq.getConstArray();
-        const Reference< chart2::XRegressionCurve >* pEnd = pBeg + aRegCurveSeq.getLength();
-        const Reference< chart2::XRegressionCurve >* pIt;
-
-        for( pIt = pBeg; pIt != pEnd; pIt++ )
+        for( const auto& xRegCurve : aRegCurveSeq )
         {
             std::vector< XMLPropertyState > aEquationPropertyStates;
-            Reference< chart2::XRegressionCurve > xRegCurve = *pIt;
             if (!xRegCurve.is())
                 continue;
 
@@ -3084,9 +3043,8 @@ void SchXMLExportHelper_Impl::exportCandleStickSeries(
     bool bExportContent )
 {
 
-    for( sal_Int32 nSeriesIdx=0; nSeriesIdx<aSeriesSeq.getLength(); ++nSeriesIdx )
+    for( const auto& xSeries : aSeriesSeq )
     {
-        Reference< chart2::XDataSeries > xSeries( aSeriesSeq[nSeriesIdx] );
         sal_Int32 nAttachedAxis = lcl_isSeriesAttachedToFirstAxis( xSeries )
             ? chart::ChartAxisAssign::PRIMARY_Y
             : chart::ChartAxisAssign::SECONDARY_Y;
@@ -3234,7 +3192,6 @@ void SchXMLExportHelper_Impl::exportDataPoints(
     ::std::vector< SchXMLDataPointStruct > aDataPointVector;
 
     sal_Int32 nLastIndex = -1;
-    sal_Int32 nCurrIndex = 0;
 
     // collect elements
     if( bVaryColorsByPoint && xColorScheme.is() )
@@ -3301,10 +3258,9 @@ void SchXMLExportHelper_Impl::exportDataPoints(
     }
     else
     {
-        for( nElement = 0; nElement < nSize; ++nElement )
+        for( sal_Int32 nCurrIndex : aDataPointSeq )
         {
             aPropertyStates.clear();
-            nCurrIndex = pPoints[ nElement ];
             //assuming sorted indices in pPoints
 
             if( nCurrIndex<0 || nCurrIndex>=nSeriesLength )
@@ -3641,23 +3597,23 @@ void SchXMLExportHelper_Impl::InitRangeSegmentationProperties( const Reference<
                 Sequence< beans::PropertyValue > aArgs( xDataProvider->detectArguments( xDataSource ));
                 OUString sCellRange, sBrokenRange;
                 bool bBrokenRangeAvailable = false;
-                for( sal_Int32 i=0; i<aArgs.getLength(); ++i )
+                for( const auto& rArg : aArgs )
                 {
-                    if ( aArgs[i].Name == "CellRangeRepresentation" )
-                        aArgs[i].Value >>= sCellRange;
-                    else if ( aArgs[i].Name == "BrokenCellRangeForExport" )
+                    if ( rArg.Name == "CellRangeRepresentation" )
+                        rArg.Value >>= sCellRange;
+                    else if ( rArg.Name == "BrokenCellRangeForExport" )
                     {
-                        if( aArgs[i].Value >>= sBrokenRange )
+                        if( rArg.Value >>= sBrokenRange )
                             bBrokenRangeAvailable = true;
                     }
-                    else if ( aArgs[i].Name == "DataRowSource" )
+                    else if ( rArg.Name == "DataRowSource" )
                     {
                         chart::ChartDataRowSource eRowSource;
-                        aArgs[i].Value >>= eRowSource;
+                        rArg.Value >>= eRowSource;
                         mbRowSourceColumns = ( eRowSource == chart::ChartDataRowSource_COLUMNS );
                     }
-                    else if ( aArgs[i].Name == "SequenceMapping" )
-                        aArgs[i].Value >>= maSequenceMapping;
+                    else if ( rArg.Name == "SequenceMapping" )
+                        rArg.Value >>= maSequenceMapping;
                 }
 
                 // #i79009# For Writer we have to export a broken version of the
diff --git a/xmloff/source/chart/SchXMLImport.cxx b/xmloff/source/chart/SchXMLImport.cxx
index bc3219ee0115..5d9507cf0a92 100644
--- a/xmloff/source/chart/SchXMLImport.cxx
+++ b/xmloff/source/chart/SchXMLImport.cxx
@@ -382,26 +382,20 @@ void SchXMLImportHelper::DeleteDataSeries(
         Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq(
             xCooSysCnt->getCoordinateSystems());
 
-        sal_Int32 nCooSysIndex = 0;
-        for( nCooSysIndex=0; nCooSysIndex<aCooSysSeq.getLength(); nCooSysIndex++ )
+        for( const auto& rCooSys : aCooSysSeq )
         {
-            Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[ nCooSysIndex ], uno::UNO_QUERY_THROW );
+            Reference< chart2::XChartTypeContainer > xCTCnt( rCooSys, uno::UNO_QUERY_THROW );
             Sequence< Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes());
 
-            sal_Int32 nChartTypeIndex = 0;
-            for( nChartTypeIndex=0; nChartTypeIndex<aChartTypes.getLength(); nChartTypeIndex++ )
+            for( const auto& rChartType : aChartTypes )
             {
-                Reference< chart2::XDataSeriesContainer > xSeriesCnt( aChartTypes[nChartTypeIndex], uno::UNO_QUERY_THROW );
+                Reference< chart2::XDataSeriesContainer > xSeriesCnt( rChartType, uno::UNO_QUERY_THROW );
                 Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xSeriesCnt->getDataSeries());
 
-                sal_Int32 nSeriesIndex = 0;
-                for( nSeriesIndex=0; nSeriesIndex<aSeriesSeq.getLength(); nSeriesIndex++ )
+                if (std::find(aSeriesSeq.begin(), aSeriesSeq.end(), xSeries) != aSeriesSeq.end())
                 {
-                    if( xSeries==aSeriesSeq[nSeriesIndex] )
-                    {
-                        xSeriesCnt->removeDataSeries(xSeries);
-                        return;
-                    }
+                    xSeriesCnt->removeDataSeries(xSeries);
+                    return;
                 }
             }
         }
diff --git a/xmloff/source/chart/SchXMLSeries2Context.cxx b/xmloff/source/chart/SchXMLSeries2Context.cxx
index 93c9d2120fae..c7a37c78ac00 100644
--- a/xmloff/source/chart/SchXMLSeries2Context.cxx
+++ b/xmloff/source/chart/SchXMLSeries2Context.cxx
@@ -185,11 +185,11 @@ void lcl_insertErrorBarLSequencesToMap(
     {
         Sequence< Reference< chart2::data::XLabeledDataSequence > > aLSequences(
             xErrorBarSource->getDataSequences());
-        for( sal_Int32 nIndex = 0; nIndex < aLSequences.getLength(); ++nIndex )
+        for( const auto& rLSequence : aLSequences )
         {
             // use "0" as data index. This is ok, as it is not used for error bars
             rInOutMap.emplace(
-                    tSchXMLIndexWithPart( 0, SCH_XML_PART_ERROR_BARS ), aLSequences[ nIndex ] );
+                    tSchXMLIndexWithPart( 0, SCH_XML_PART_ERROR_BARS ), rLSequence );
         }
     }
 }
@@ -222,8 +222,7 @@ Reference< chart2::data::XLabeledDataSequence2 > lcl_createAndAddSequenceToSerie
     sal_Int32 nOldCount = aOldSeq.getLength();
     Sequence< Reference< chart2::data::XLabeledDataSequence > > aNewSeq( nOldCount + 1 );
     aNewSeq[0].set(xLabeledSeq, uno::UNO_QUERY_THROW);
-    for( sal_Int32 nN=0; nN<nOldCount; nN++ )
-        aNewSeq[nN+1] = aOldSeq[nN];
+    std::copy(aOldSeq.begin(), aOldSeq.end(), std::next(aNewSeq.begin()));
     xSeriesSink->setData( aNewSeq );
 
     return xLabeledSeq;
diff --git a/xmloff/source/chart/SchXMLSeriesHelper.cxx b/xmloff/source/chart/SchXMLSeriesHelper.cxx
index 1a27fff4a1b9..18d1dc93a65e 100644
--- a/xmloff/source/chart/SchXMLSeriesHelper.cxx
+++ b/xmloff/source/chart/SchXMLSeriesHelper.cxx
@@ -48,13 +48,13 @@ using ::com::sun::star::uno::Sequence;
             xDiagram, uno::UNO_QUERY_THROW );
         Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq(
             xCooSysCnt->getCoordinateSystems());
-        for( sal_Int32 i=0; i<aCooSysSeq.getLength(); ++i )
+        for( const auto& rCooSys : aCooSysSeq )
         {
-            Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[i], uno::UNO_QUERY_THROW );
+            Reference< chart2::XChartTypeContainer > xCTCnt( rCooSys, uno::UNO_QUERY_THROW );
             Sequence< Reference< chart2::XChartType > > aChartTypeSeq( xCTCnt->getChartTypes());
-            for( sal_Int32 j=0; j<aChartTypeSeq.getLength(); ++j )
+            for( const auto& rChartType : aChartTypeSeq )
             {
-                Reference< chart2::XDataSeriesContainer > xDSCnt( aChartTypeSeq[j], uno::UNO_QUERY_THROW );
+                Reference< chart2::XDataSeriesContainer > xDSCnt( rChartType, uno::UNO_QUERY_THROW );
                 Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries() );
                 ::std::copy( aSeriesSeq.begin(), aSeriesSeq.end(),
                              ::std::back_inserter( aResult ));
@@ -106,20 +106,16 @@ uno::Reference< chart2::XChartType > lcl_getChartTypeOfSeries(
         return nullptr;
 
     uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
-    for( sal_Int32 nCS = 0; nCS < aCooSysList.getLength(); ++nCS )
+    for( const auto& xCooSys : aCooSysList )
     {
-        uno::Reference< chart2::XCoordinateSystem > xCooSys( aCooSysList[nCS] );
-
         //iterate through all chart types in the current coordinate system
         uno::Reference< chart2::XChartTypeContainer > xChartTypeContainer( xCooSys, uno::UNO_QUERY );
         SAL_WARN_IF( !xChartTypeContainer.is(), "xmloff.chart", "xChartTypeContainer is NULL");
         if( !xChartTypeContainer.is() )
             continue;
         uno::Sequence< uno::Reference< chart2::XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() );
-        for( sal_Int32 nT = 0; nT < aChartTypeList.getLength(); ++nT )
+        for( const auto& xChartType : aChartTypeList )
         {
-            uno::Reference< chart2::XChartType > xChartType( aChartTypeList[nT] );
-
             //iterate through all series in this chart type
             uno::Reference< chart2::XDataSeriesContainer > xDataSeriesContainer( xChartType, uno::UNO_QUERY );
             SAL_WARN_IF( !xDataSeriesContainer.is(), "xmloff.chart", "xDataSeriesContainer is NULL");
@@ -127,13 +123,8 @@ uno::Reference< chart2::XChartType > lcl_getChartTypeOfSeries(
                 continue;
 
             uno::Sequence< uno::Reference< chart2::XDataSeries > > aSeriesList( xDataSeriesContainer->getDataSeries() );
-            for( sal_Int32 nS = 0; nS < aSeriesList.getLength(); ++nS )
-            {
-                Reference< chart2::XDataSeries > xCurrentSeries( aSeriesList[nS] );
-
-                if( xSeries == xCurrentSeries )
-                    return xChartType;
-            }
+            if (std::find(aSeriesList.begin(), aSeriesList.end(), xSeries) != aSeriesList.end())
+                return xChartType;
         }
     }
     return nullptr;
diff --git a/xmloff/source/chart/SchXMLTableContext.cxx b/xmloff/source/chart/SchXMLTableContext.cxx
index 996f2b82c287..439f3f24c95c 100644
--- a/xmloff/source/chart/SchXMLTableContext.cxx
+++ b/xmloff/source/chart/SchXMLTableContext.cxx
@@ -951,29 +951,28 @@ void SchXMLTableHelper::switchRangesFromOuterToInternalIfNecessary(
         {
             Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xChartDoc->getFirstDiagram(), uno::UNO_QUERY_THROW );
             Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems() );
-            for( sal_Int32 nC=0; nC<aCooSysSeq.getLength(); ++nC )
+            for( const auto& rCooSys : aCooSysSeq )
             {
-                Reference< chart2::XChartTypeContainer > xCooSysContainer( aCooSysSeq[nC], uno::UNO_QUERY_THROW );
+                Reference< chart2::XChartTypeContainer > xCooSysContainer( rCooSys, uno::UNO_QUERY_THROW );
                 Sequence< Reference< chart2::XChartType > > aChartTypeSeq( xCooSysContainer->getChartTypes());
-                for( sal_Int32 nT=0; nT<aChartTypeSeq.getLength(); ++nT )
+                for( const auto& rChartType : aChartTypeSeq )
                 {
-                    Reference< chart2::XDataSeriesContainer > xSeriesContainer( aChartTypeSeq[nT], uno::UNO_QUERY );
+                    Reference< chart2::XDataSeriesContainer > xSeriesContainer( rChartType, uno::UNO_QUERY );
                     if(!xSeriesContainer.is())
                         continue;
                     Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xSeriesContainer->getDataSeries() );
                     std::vector< Reference< chart2::XDataSeries > > aRemainingSeries;
 
-                    for( sal_Int32 nS = 0; nS < aSeriesSeq.getLength(); nS++ )
+                    for( const auto& rSeries : aSeriesSeq )
                     {
-                        Reference< chart2::data::XDataSource > xDataSource( aSeriesSeq[nS], uno::UNO_QUERY );
+                        Reference< chart2::data::XDataSource > xDataSource( rSeries, uno::UNO_QUERY );
                         if( xDataSource.is() )
                         {
                             bool bHasUnhiddenColumns = false;
                             OUString aRange;
                             uno::Sequence< Reference< chart2::data::XLabeledDataSequence > > aSequences( xDataSource->getDataSequences() );
-                            for( sal_Int32 nN=0; nN< aSequences.getLength(); ++nN )
+                            for( const auto& xLabeledSequence : aSequences )
                             {
-                                Reference< chart2::data::XLabeledDataSequence > xLabeledSequence( aSequences[nN] );
                                 if(!xLabeledSequence.is())
                                     continue;
                                 Reference< chart2::data::XDataSequence > xValues( xLabeledSequence->getValues() );
@@ -996,7 +995,7 @@ void SchXMLTableHelper::switchRangesFromOuterToInternalIfNecessary(
                                 }
                             }
                             if( bHasUnhiddenColumns )
-                                aRemainingSeries.push_back( aSeriesSeq[nS] );
+                                aRemainingSeries.push_back( rSeries );
                         }
                     }
 
@@ -1013,9 +1012,8 @@ void SchXMLTableHelper::switchRangesFromOuterToInternalIfNecessary(
                             std::map< sal_Int32, bool > aUsageMap;
                             OUString aRange;
                             Sequence< Reference< chart2::data::XLabeledDataSequence > > aUsedSequences( xDataSource->getDataSequences() );
-                            for( sal_Int32 nN=0; nN< aUsedSequences.getLength(); ++nN )
+                            for( const auto& xLabeledSequence : aUsedSequences )
                             {
-                                Reference< chart2::data::XLabeledDataSequence > xLabeledSequence( aUsedSequences[nN] );
                                 if(!xLabeledSequence.is())
                                     continue;
                                 Reference< chart2::data::XDataSequence > xValues( xLabeledSequence->getValues() );
diff --git a/xmloff/source/chart/SchXMLTools.cxx b/xmloff/source/chart/SchXMLTools.cxx
index a81505752c3c..3757dfce8e22 100644
--- a/xmloff/source/chart/SchXMLTools.cxx
+++ b/xmloff/source/chart/SchXMLTools.cxx
@@ -685,10 +685,9 @@ void copyProperties(
         Reference< beans::XPropertySetInfo > xSrcInfo( xSource->getPropertySetInfo(), uno::UNO_SET_THROW );
         Reference< beans::XPropertySetInfo > xDestInfo( xDestination->getPropertySetInfo(), uno::UNO_SET_THROW );
         Sequence< beans::Property > aProperties( xSrcInfo->getProperties());
-        const sal_Int32 nLength = aProperties.getLength();
-        for( sal_Int32 i = 0; i < nLength; ++i )
+        for( const auto& rProperty : aProperties )
         {
-            OUString aName( aProperties[i].Name);
+            OUString aName( rProperty.Name);
             if( xDestInfo->hasPropertyByName( aName ))
             {
                 beans::Property aProp( xDestInfo->getPropertyByName( aName ));
diff --git a/xmloff/source/core/DocumentSettingsContext.cxx b/xmloff/source/core/DocumentSettingsContext.cxx
index 15e8d92fbc30..ec3252251e3d 100644
--- a/xmloff/source/core/DocumentSettingsContext.cxx
+++ b/xmloff/source/core/DocumentSettingsContext.cxx
@@ -504,10 +504,7 @@ void XMLConfigItemContext::Characters( const OUString& rChars )
             sal_uInt32 nStartPos(maDecoded.getLength());
             sal_uInt32 nCount(aBuffer.getLength());
             maDecoded.realloc(nStartPos + nCount);
-            sal_Int8* pDecoded = maDecoded.getArray();
-            sal_Int8* pBuffer = aBuffer.getArray();
-            for (sal_uInt32 i = 0; i < nCount; i++, pBuffer++)
-                pDecoded[nStartPos + i] = *pBuffer;
+            std::copy(aBuffer.begin(), aBuffer.end(), std::next(maDecoded.begin(), nStartPos));
             if( nCharsDecoded != sChars.getLength() )
                 msValue = sChars.copy( nCharsDecoded );
         }
diff --git a/xmloff/source/core/PropertySetMerger.cxx b/xmloff/source/core/PropertySetMerger.cxx
index 356d6d14f83f..7aeff6cc1b8f 100644
--- a/xmloff/source/core/PropertySetMerger.cxx
+++ b/xmloff/source/core/PropertySetMerger.cxx
@@ -152,12 +152,9 @@ Sequence< PropertyState > SAL_CALL PropertySetMergerImpl::getPropertyStates( con
 {
     const sal_Int32 nCount = aPropertyName.getLength();
     Sequence< PropertyState > aPropStates( nCount );
-    PropertyState* pPropStates = aPropStates.getArray();
-    const OUString* pPropNames = aPropertyName.getConstArray();
 
-    sal_Int32 nIndex;
-    for( nIndex = 0; nIndex < nCount; nIndex++ )
-        *pPropStates++ = getPropertyState( *pPropNames++ );
+    std::transform(aPropertyName.begin(), aPropertyName.end(), aPropStates.begin(),
+        [this](const OUString& rPropName) -> PropertyState { return getPropertyState(rPropName); });
 
     return aPropStates;
 }
diff --git a/xmloff/source/core/SettingsExportHelper.cxx b/xmloff/source/core/SettingsExportHelper.cxx
index 7cdc59301adf..9a5c58ab6712 100644
--- a/xmloff/source/core/SettingsExportHelper.cxx
+++ b/xmloff/source/core/SettingsExportHelper.cxx
@@ -273,13 +273,12 @@ void XMLSettingsExportHelper::exportSequencePropertyValue(
                     const OUString& rName) const
 {
     DBG_ASSERT(!rName.isEmpty(), "no name");
-    sal_Int32 nLength(aProps.getLength());
-    if(nLength)
+    if(aProps.hasElements())
     {
         m_rContext.AddAttribute( XML_NAME, rName );
         m_rContext.StartElement( XML_CONFIG_ITEM_SET );
-        for (sal_Int32 i = 0; i < nLength; i++)
-            CallTypeFunction(aProps[i].Value, aProps[i].Name);
+        for (const auto& rProp : aProps)
+            CallTypeFunction(rProp.Value, rProp.Name);
         m_rContext.EndElement( true );
     }
 }
@@ -340,11 +339,10 @@ void XMLSettingsExportHelper::exportbase64Binary(
                     const OUString& rName) const
 {
     DBG_ASSERT(!rName.isEmpty(), "no name");
-    sal_Int32 nLength(aProps.getLength());
     m_rContext.AddAttribute( XML_NAME, rName );
     m_rContext.AddAttribute( XML_TYPE, XML_BASE64BINARY );
     m_rContext.StartElement( XML_CONFIG_ITEM );
-    if(nLength)
+    if(aProps.hasElements())
     {
         OUStringBuffer sBuffer;
         ::comphelper::Base64::encode(sBuffer, aProps);
@@ -360,14 +358,13 @@ void XMLSettingsExportHelper::exportMapEntry(const uno::Any& rAny,
     DBG_ASSERT((bNameAccess && !rName.isEmpty()) || !bNameAccess, "no name");
     uno::Sequence<beans::PropertyValue> aProps;
     rAny >>= aProps;
-    sal_Int32 nLength = aProps.getLength();
-    if (nLength)
+    if (aProps.hasElements())
     {
         if (bNameAccess)
             m_rContext.AddAttribute( XML_NAME, rName );
         m_rContext.StartElement( XML_CONFIG_ITEM_MAP_ENTRY );
-        for (sal_Int32 i = 0; i < nLength; i++)
-            CallTypeFunction(aProps[i].Value, aProps[i].Name);
+        for (const auto& rProp : aProps)
+            CallTypeFunction(rProp.Value, rProp.Name);
         m_rContext.EndElement( true );
     }
 }
@@ -384,8 +381,8 @@ void XMLSettingsExportHelper::exportNameAccess(
         m_rContext.AddAttribute( XML_NAME, rName );
         m_rContext.StartElement( XML_CONFIG_ITEM_MAP_NAMED );
         uno::Sequence< OUString > aNames(aNamed->getElementNames());
-        for (sal_Int32 i = 0; i < aNames.getLength(); i++)
-            exportMapEntry(aNamed->getByName(aNames[i]), aNames[i], true);
+        for (const auto& rElementName : aNames)
+            exportMapEntry(aNamed->getByName(rElementName), rElementName, true);
         m_rContext.EndElement( true );
     }
 }
@@ -427,9 +424,6 @@ void XMLSettingsExportHelper::exportForbiddenCharacters(
 
     uno::Reference< container::XIndexContainer > xBox = document::IndexedPropertyValues::create(m_rContext.GetComponentContext());
     const uno::Sequence< lang::Locale > aLocales( xLocales->getLocales() );
-    const lang::Locale* pLocales = aLocales.getConstArray();
-
-    const sal_Int32 nCount = aLocales.getLength();
 
     /* FIXME-BCP47: this stupid and counterpart in
      * xmloff/source/core/DocumentSettingsContext.cxx
@@ -442,22 +436,22 @@ void XMLSettingsExportHelper::exportForbiddenCharacters(
     const OUString sEndLine   ( "EndLine" );
 
     sal_Int32 nPos = 0;
-    for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++, pLocales++ )
+    for( const auto& rLocale : aLocales )
     {
-        if( xForbChars->hasForbiddenCharacters( *pLocales ) )
+        if( xForbChars->hasForbiddenCharacters( rLocale ) )
         {
-            const i18n::ForbiddenCharacters aChars( xForbChars->getForbiddenCharacters( *pLocales ) );
+            const i18n::ForbiddenCharacters aChars( xForbChars->getForbiddenCharacters( rLocale ) );
 
 
             uno::Sequence < beans::PropertyValue > aSequence ( XML_FORBIDDEN_CHARACTER_MAX );
             beans::PropertyValue *pForChar = aSequence.getArray();
 
             pForChar[XML_FORBIDDEN_CHARACTER_LANGUAGE].Name    = sLanguage;
-            pForChar[XML_FORBIDDEN_CHARACTER_LANGUAGE].Value <<= pLocales->Language;
+            pForChar[XML_FORBIDDEN_CHARACTER_LANGUAGE].Value <<= rLocale.Language;
             pForChar[XML_FORBIDDEN_CHARACTER_COUNTRY].Name    = sCountry;
-            pForChar[XML_FORBIDDEN_CHARACTER_COUNTRY].Value <<= pLocales->Country;
+            pForChar[XML_FORBIDDEN_CHARACTER_COUNTRY].Value <<= rLocale.Country;
             pForChar[XML_FORBIDDEN_CHARACTER_VARIANT].Name    = sVariant;
-            pForChar[XML_FORBIDDEN_CHARACTER_VARIANT].Value <<= pLocales->Variant;
+            pForChar[XML_FORBIDDEN_CHARACTER_VARIANT].Value <<= rLocale.Variant;
             pForChar[XML_FORBIDDEN_CHARACTER_BEGIN_LINE].Name    = sBeginLine;
             pForChar[XML_FORBIDDEN_CHARACTER_BEGIN_LINE].Value <<= aChars.beginLine;
             pForChar[XML_FORBIDDEN_CHARACTER_END_LINE].Name    = sEndLine;
diff --git a/xmloff/source/core/XMLEmbeddedObjectExportFilter.cxx b/xmloff/source/core/XMLEmbeddedObjectExportFilter.cxx
index 5403ace544c7..87a1c0b45f4a 100644
--- a/xmloff/source/core/XMLEmbeddedObjectExportFilter.cxx
+++ b/xmloff/source/core/XMLEmbeddedObjectExportFilter.cxx
@@ -116,16 +116,13 @@ void SAL_CALL XMLEmbeddedObjectExportFilter::unknown( const OUString& rString )
 void SAL_CALL XMLEmbeddedObjectExportFilter::initialize(
         const Sequence< Any >& aArguments )
 {
-    const sal_Int32 nAnyCount = aArguments.getLength();
-    const Any* pAny = aArguments.getConstArray();
-
-    for( sal_Int32 nIndex = 0; nIndex < nAnyCount; nIndex++, pAny++ )
+    for( const auto& rAny : aArguments )
     {
-        if( pAny->getValueType() ==
+        if( rAny.getValueType() ==
                 cppu::UnoType<XDocumentHandler>::get())
         {
-            *pAny >>= xHandler;
-            *pAny >>= xExtHandler;
+            rAny >>= xHandler;
+            rAny >>= xExtHandler;
         }
     }
 }
diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx
index 2234f40f7c84..702d75231015 100644
--- a/xmloff/source/core/xmlexp.cxx
+++ b/xmloff/source/core/xmlexp.cxx
@@ -651,13 +651,10 @@ void SAL_CALL SvXMLExport::initialize( const uno::Sequence< uno::Any >& aArgumen
 {
     // #93186# we need to queryInterface every single Any with any expected outcome. This variable hold the queryInterface results.
 
-    const sal_Int32 nAnyCount = aArguments.getLength();
-    const uno::Any* pAny = aArguments.getConstArray();
-
-    for( sal_Int32 nIndex = 0; nIndex < nAnyCount; nIndex++, pAny++ )
+    for( const auto& rAny : aArguments )
     {
         Reference<XInterface> xValue;
-        *pAny >>= xValue;
+        rAny >>= xValue;
 
         // status indicator
         uno::Reference<task::XStatusIndicator> xTmpStatus( xValue, UNO_QUERY );
@@ -681,7 +678,7 @@ void SAL_CALL SvXMLExport::initialize( const uno::Sequence< uno::Any >& aArgumen
         if( xTmpDocHandler.is() )
         {
             mxHandler = xTmpDocHandler;
-            *pAny >>= mxExtHandler;
+            rAny >>= mxExtHandler;
 
             if (mxNumberFormatsSupplier.is() && mpNumExport == nullptr)
                 mpNumExport.reset( new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier) );
@@ -752,8 +749,6 @@ void SAL_CALL SvXMLExport::initialize( const uno::Sequence< uno::Any >& aArgumen
         uno::Any aAny = mxExportInfo->getPropertyValue( sExportTextNumberElement );
         aAny >>= mpImpl->mbExportTextNumberElement;
     }
-
-
 }
 
 // XFilter
@@ -765,8 +760,6 @@ sal_Bool SAL_CALL SvXMLExport::filter( const uno::Sequence< beans::PropertyValue
 
     try
     {
-        const sal_Int32 nPropCount = aDescriptor.getLength();
-
         const SvXMLExportFlags nTest =
             SvXMLExportFlags::META|SvXMLExportFlags::STYLES|SvXMLExportFlags::CONTENT|SvXMLExportFlags::SETTINGS;
         if( (mnExportFlags & nTest) == nTest && msOrigFileName.isEmpty() )
@@ -774,11 +767,10 @@ sal_Bool SAL_CALL SvXMLExport::filter( const uno::Sequence< beans::PropertyValue
             // evaluate descriptor only for flat files and if a base URI
             // has not been provided already
 
-            const beans::PropertyValue* pProps = aDescriptor.getConstArray();
-            for( sal_Int32 nIndex = 0; nIndex < nPropCount; nIndex++, pProps++ )
+            for( const auto& rProp : aDescriptor )
             {
-                const OUString& rPropName = pProps->Name;
-                const Any& rValue = pProps->Value;
+                const OUString& rPropName = rProp.Name;
+                const Any& rValue = rProp.Value;
 
                 if ( rPropName == "FileName" )
                 {
@@ -793,11 +785,10 @@ sal_Bool SAL_CALL SvXMLExport::filter( const uno::Sequence< beans::PropertyValue
             }
         }
 
-        const beans::PropertyValue* pProps = aDescriptor.getConstArray();
-        for (sal_Int32 nIndex = 0; nIndex < nPropCount; ++nIndex, ++pProps)
+        for( const auto& rProp : aDescriptor )
         {
-            const OUString& rPropName = pProps->Name;
-            const Any& rValue = pProps->Value;
+            const OUString& rPropName = rProp.Name;
+            const Any& rValue = rProp.Value;
 
             if (rPropName == "SourceShellID")
             {
@@ -1541,11 +1532,8 @@ void SvXMLExport::ExportStyles_( bool )
                 if( xGradient->hasElements() )
                 {
                     uno::Sequence< OUString > aNamesSeq ( xGradient->getElementNames() );
-                    sal_Int32 nCount = aNamesSeq.getLength();
-                    for( sal_Int32 i=0; i<nCount; i++ )
+                    for( const OUString& rStrName : aNamesSeq )
                     {
-                        const OUString& rStrName = aNamesSeq[ i ];
-
                         try
                         {
                             uno::Any aValue = xGradient->getByName( rStrName );
@@ -1574,11 +1562,8 @@ void SvXMLExport::ExportStyles_( bool )
                 if( xHatch->hasElements() )
                 {
                     uno::Sequence< OUString > aNamesSeq ( xHatch->getElementNames() );
-                    sal_Int32 nCount = aNamesSeq.getLength();
-                    for( sal_Int32 i=0; i<nCount; i++ )
+                    for( const OUString& rStrName : aNamesSeq )
                     {
-                        const OUString& rStrName = aNamesSeq[ i ];
-
                         try
                         {
                             uno::Any aValue = xHatch->getByName( rStrName );
@@ -1604,11 +1589,8 @@ void SvXMLExport::ExportStyles_( bool )
                 if( xBitmap->hasElements() )
                 {
                     uno::Sequence< OUString > aNamesSeq ( xBitmap->getElementNames() );
-                    sal_Int32 nCount = aNamesSeq.getLength();
-                    for( sal_Int32 i=0; i<nCount; i++ )
+                    for( const OUString& rStrName : aNamesSeq )
                     {
-                        const OUString& rStrName = aNamesSeq[ i ];
-
                         try
                         {
                             uno::Any aValue = xBitmap->getByName( rStrName );
@@ -1637,11 +1619,8 @@ void SvXMLExport::ExportStyles_( bool )
                 if( xTransGradient->hasElements() )
                 {
                     uno::Sequence< OUString > aNamesSeq ( xTransGradient->getElementNames() );
-                    sal_Int32 nCount = aNamesSeq.getLength();
-                    for( sal_Int32 i=0; i<nCount; i++ )
+                    for( const OUString& rStrName : aNamesSeq )
                     {
-                        const OUString& rStrName = aNamesSeq[ i ];
-
                         try
                         {
                             uno::Any aValue = xTransGradient->getByName( rStrName );
@@ -1670,11 +1649,8 @@ void SvXMLExport::ExportStyles_( bool )
                 if( xMarker->hasElements() )
                 {
                     uno::Sequence< OUString > aNamesSeq ( xMarker->getElementNames() );
-                    sal_Int32 nCount = aNamesSeq.getLength();
-                    for( sal_Int32 i=0; i<nCount; i++ )
+                    for( const OUString& rStrName : aNamesSeq )
                     {
-                        const OUString& rStrName = aNamesSeq[ i ];
-
                         try
                         {
                             uno::Any aValue = xMarker->getByName( rStrName );
@@ -1703,11 +1679,8 @@ void SvXMLExport::ExportStyles_( bool )
                 if( xDashes->hasElements() )
                 {
                     uno::Sequence< OUString > aNamesSeq ( xDashes->getElementNames() );
-                    sal_Int32 nCount = aNamesSeq.getLength();
-                    for( sal_Int32 i=0; i<nCount; i++ )
+                    for( const OUString& rStrName : aNamesSeq )
                     {
-                        const OUString& rStrName = aNamesSeq[ i ];
-
                         try
                         {
                             uno::Any aValue = xDashes->getByName( rStrName );
diff --git a/xmloff/source/core/xmlictxt.cxx b/xmloff/source/core/xmlictxt.cxx
index 7dcc6c13d0c2..1014b0e3e2c6 100644
--- a/xmloff/source/core/xmlictxt.cxx
+++ b/xmloff/source/core/xmlictxt.cxx
@@ -103,11 +103,10 @@ void SAL_CALL SvXMLImportContext::startUnknownElement(const OUString & /*rNamesp
         }
 
         uno::Sequence< xml::Attribute > unknownAttribs = Attribs->getUnknownAttributes();
-        sal_Int32 len = unknownAttribs.getLength();
-        for ( sal_Int32 i = 0; i < len; i++ )
+        for ( const auto& rUnknownAttrib : unknownAttribs )
         {
-            const OUString& rAttrValue = unknownAttribs[i].Value;
-            const OUString& rAttrName = unknownAttribs[i].Name;
+            const OUString& rAttrValue = rUnknownAttrib.Value;
+            const OUString& rAttrName = rUnknownAttrib.Name;
             // note: rAttrName is expected to be namespace-prefixed here
             mrImport.maAttrList->AddAttribute( rAttrName, "CDATA", rAttrValue );
         }
diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx
index 653f3d5fc017..7fac85974fd4 100644
--- a/xmloff/source/core/xmlimp.cxx
+++ b/xmloff/source/core/xmlimp.cxx
@@ -1026,13 +1026,10 @@ void SAL_CALL SvXMLImport::cancel(  )
 // XInitialize
 void SAL_CALL SvXMLImport::initialize( const uno::Sequence< uno::Any >& aArguments )
 {
-    const sal_Int32 nAnyCount = aArguments.getLength();
-    const uno::Any* pAny = aArguments.getConstArray();
-
-    for( sal_Int32 nIndex = 0; nIndex < nAnyCount; nIndex++, pAny++ )
+    for( const auto& rAny : aArguments )
     {
         Reference<XInterface> xValue;
-        *pAny >>= xValue;
+        rAny >>= xValue;
 
         uno::Reference<task::XStatusIndicator> xTmpStatusIndicator(
             xValue, UNO_QUERY );
diff --git a/xmloff/source/core/xmluconv.cxx b/xmloff/source/core/xmluconv.cxx
index c590583f85ce..7833996fc7e8 100644
--- a/xmloff/source/core/xmluconv.cxx
+++ b/xmloff/source/core/xmluconv.cxx
@@ -693,15 +693,15 @@ void SvXMLUnitConverter::convertPropertySet(uno::Sequence<beans::PropertyValue>&
     if (xPropertySetInfo.is())
     {
         uno::Sequence< beans::Property > aProps = xPropertySetInfo->getProperties();
-        const sal_Int32 nCount(aProps.getLength());
-        if (nCount)
+        if (aProps.hasElements())
         {
-            rProps.realloc(nCount);
+            rProps.realloc(aProps.getLength());
             beans::PropertyValue* pProps = rProps.getArray();
-            for (sal_Int32 i = 0; i < nCount; i++, ++pProps)
+            for (const auto& rProp : aProps)
             {
-                pProps->Name = aProps[i].Name;
-                pProps->Value = aProperties->getPropertyValue(aProps[i].Name);
+                pProps->Name = rProp.Name;
+                pProps->Value = aProperties->getPropertyValue(rProp.Name);
+                ++pProps;
             }
         }
     }
@@ -710,16 +710,15 @@ void SvXMLUnitConverter::convertPropertySet(uno::Sequence<beans::PropertyValue>&
 void SvXMLUnitConverter::convertPropertySet(uno::Reference<beans::XPropertySet> const & rProperties,
                     const uno::Sequence<beans::PropertyValue>& aProps)
 {
-    sal_Int32 nCount(aProps.getLength());
-    if (nCount)
+    if (aProps.hasElements())
     {
         uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = rProperties->getPropertySetInfo();
         if (xPropertySetInfo.is())
         {
-            for (sal_Int32 i = 0; i < nCount; i++)
+            for (const auto& rProp : aProps)
             {
-                if (xPropertySetInfo->hasPropertyByName(aProps[i].Name))
-                    rProperties->setPropertyValue(aProps[i].Name, aProps[i].Value);
+                if (xPropertySetInfo->hasPropertyByName(rProp.Name))
+                    rProperties->setPropertyValue(rProp.Name, rProp.Value);
             }
         }
     }


More information about the Libreoffice-commits mailing list