sc/source/filter/html/htmlexp.cxx            |    3 -
 sc/source/filter/html/htmlpars.cxx           |   78 +++++++++++----------------
 sc/source/filter/lotus/lotattr.cxx           |    7 +-
 sc/source/filter/lotus/tool.cxx              |   73 +++++++++++--------------
 sc/source/filter/oox/addressconverter.cxx    |    8 +-
 sc/source/filter/oox/autofilterbuffer.cxx    |   27 +++++----
 sc/source/filter/oox/condformatbuffer.cxx    |   26 +++------
 sc/source/filter/oox/connectionsbuffer.cxx   |    4 -
 sc/source/filter/oox/defnamesbuffer.cxx      |    3 -
 sc/source/filter/oox/excelchartconverter.cxx |    7 +-
 sc/source/filter/oox/externallinkbuffer.cxx  |    8 +-
 sc/source/filter/oox/formulabase.cxx         |    3 -
 sc/source/filter/oox/formulaparser.cxx       |   12 ++--
 sc/source/filter/oox/numberformatsbuffer.cxx |    8 +-
 sc/source/filter/oox/pivotcachebuffer.cxx    |   54 +++++++++++-------
 sc/source/filter/oox/pivottablebuffer.cxx    |   67 ++++++++++++-----------
 sc/source/filter/oox/querytablebuffer.cxx    |   10 +--
 sc/source/filter/oox/revisionfragment.cxx    |    6 --
 sc/source/filter/oox/richstring.cxx          |   12 ++--
 sc/source/filter/oox/scenariobuffer.cxx      |   14 ++--
 sc/source/filter/oox/sheetdatabuffer.cxx     |   74 ++++++++++++-------------
 sc/source/filter/oox/stylesbuffer.cxx        |   20 +++---
 sc/source/filter/oox/tablebuffer.cxx         |    4 -
 sc/source/filter/oox/tablecolumnsbuffer.cxx  |    6 +-
 sc/source/filter/oox/viewsettings.cxx        |    4 -
 sc/source/filter/oox/workbookfragment.cxx    |   17 ++---
 sc/source/filter/oox/worksheetfragment.cxx   |   12 ++--
 sc/source/filter/orcus/xmlcontext.cxx        |   59 +++++++-------------
 28 files changed, 303 insertions(+), 323 deletions(-)

New commits:
commit 72b8f54270877726d821d3f01225d8238c9d46ed
Author:     Arkadiy Illarionov <qar...@gmail.com>
AuthorDate: Thu Jan 24 00:27:42 2019 +0300
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Jan 24 08:35:12 2019 +0100

    Simplify containers iterations in sc/source/filter/[h-o]*
    
    Use range-based loop or replace with STL functions
    
    Change-Id: I7e024d5bf97d942b8b43465e0779cf9e30df8eb0
    Reviewed-on: https://gerrit.libreoffice.org/66827
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sc/source/filter/html/htmlexp.cxx 
b/sc/source/filter/html/htmlexp.cxx
index f669074ba372..9715fa9299ed 100644
--- a/sc/source/filter/html/htmlexp.cxx
+++ b/sc/source/filter/html/htmlexp.cxx
@@ -1209,9 +1209,8 @@ bool ScHTMLExport::WriteFieldText( const EditTextObject* 
pData )
             std::vector<sal_Int32> aPortions;
             rEngine.GetPortions( nPar, aPortions );
             sal_Int32 nStart = 0;
-            for ( std::vector<sal_Int32>::const_iterator 
it(aPortions.begin()); it != aPortions.end(); ++it )
+            for ( const sal_Int32 nEnd : aPortions )
             {
-                sal_Int32 nEnd = *it;
                 ESelection aSel( nPar, nStart, nPar, nEnd );
                 bool bUrl = false;
                 // fields are single characters
diff --git a/sc/source/filter/html/htmlpars.cxx 
b/sc/source/filter/html/htmlpars.cxx
index eb6136b89cbd..5749949006d4 100644
--- a/sc/source/filter/html/htmlpars.cxx
+++ b/sc/source/filter/html/htmlpars.cxx
@@ -231,8 +231,8 @@ ScHTMLLayoutParser::~ScHTMLLayoutParser()
     delete pLocalColOffset;
     if ( pTables )
     {
-        for( OuterMap::const_iterator it = pTables->begin(); it != 
pTables->end(); ++it)
-            delete it->second;
+        for( const auto& rEntry : *pTables)
+            delete rEntry.second;
         pTables.reset();
     }
 }
@@ -1831,16 +1831,15 @@ ScHTMLTable::ScHTMLTable( ScHTMLTable& rParentTable, 
const HtmlImportInfo& rInfo
     {
         ProcessFormatOptions( maTableItemSet, rInfo );
         const HTMLOptions& rOptions = 
static_cast<HTMLParser*>(rInfo.pParser)->GetOptions();
-        HTMLOptions::const_iterator itr = rOptions.begin(), itrEnd = 
rOptions.end();
-        for (; itr != itrEnd; ++itr)
+        for (const auto& rOption : rOptions)
         {
-            switch( itr->GetToken() )
+            switch( rOption.GetToken() )
             {
                 case HtmlOptionId::BORDER:
-                    mbBorderOn = itr->GetString().isEmpty() || 
(itr->GetNumber() != 0);
+                    mbBorderOn = rOption.GetString().isEmpty() || 
(rOption.GetNumber() != 0);
                 break;
                 case HtmlOptionId::ID:
-                    maTableName = itr->GetString();
+                    maTableName = rOption.GetString();
                 break;
                 default: break;
             }
@@ -2055,29 +2054,28 @@ void ScHTMLTable::DataOn( const HtmlImportInfo& rInfo )
         ScHTMLSize aSpanSize( 1, 1 );
         boost::optional<OUString> pValStr, pNumStr;
         const HTMLOptions& rOptions = 
static_cast<HTMLParser*>(rInfo.pParser)->GetOptions();
-        HTMLOptions::const_iterator itr = rOptions.begin(), itrEnd = 
rOptions.end();
         sal_uInt32 nNumberFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
-        for (; itr != itrEnd; ++itr)
+        for (const auto& rOption : rOptions)
         {
-            switch (itr->GetToken())
+            switch (rOption.GetToken())
             {
                 case HtmlOptionId::COLSPAN:
-                    aSpanSize.mnCols = static_cast<SCCOL>( 
getLimitedValue<sal_Int32>( itr->GetString().toInt32(), 1, 256 ) );
+                    aSpanSize.mnCols = static_cast<SCCOL>( 
getLimitedValue<sal_Int32>( rOption.GetString().toInt32(), 1, 256 ) );
                 break;
                 case HtmlOptionId::ROWSPAN:
-                    aSpanSize.mnRows = static_cast<SCROW>( 
getLimitedValue<sal_Int32>( itr->GetString().toInt32(), 1, 256 ) );
+                    aSpanSize.mnRows = static_cast<SCROW>( 
getLimitedValue<sal_Int32>( rOption.GetString().toInt32(), 1, 256 ) );
                 break;
                 case HtmlOptionId::SDVAL:
-                    pValStr = itr->GetString();
+                    pValStr = rOption.GetString();
                 break;
                 case HtmlOptionId::SDNUM:
-                    pNumStr = itr->GetString();
+                    pNumStr = rOption.GetString();
                 break;
                 case HtmlOptionId::CLASS:
                 {
                     // Pick up the number format associated with this class (if
                     // any).
-                    OUString aClass = itr->GetString();
+                    OUString aClass = rOption.GetString();
                     const ScHTMLStyles& rStyles = mpParser->GetStyles();
                     const OUString& rVal = rStyles.getPropertyValue("td", 
aClass, "mso-number-format");
                     if (!rVal.isEmpty())
@@ -2477,15 +2475,14 @@ void ScHTMLTable::ProcessFormatOptions( SfxItemSet& 
rItemSet, const HtmlImportIn
     }
 
     const HTMLOptions& rOptions = 
static_cast<HTMLParser*>(rInfo.pParser)->GetOptions();
-    HTMLOptions::const_iterator itr = rOptions.begin(), itrEnd = 
rOptions.end();
-    for (; itr != itrEnd; ++itr)
+    for (const auto& rOption : rOptions)
     {
-        switch( itr->GetToken() )
+        switch( rOption.GetToken() )
         {
             case HtmlOptionId::ALIGN:
             {
                 SvxCellHorJustify eVal = SvxCellHorJustify::Standard;
-                const OUString& rOptVal = itr->GetString();
+                const OUString& rOptVal = rOption.GetString();
                 if( rOptVal.equalsIgnoreAsciiCase( 
OOO_STRING_SVTOOLS_HTML_AL_right ) )
                     eVal = SvxCellHorJustify::Right;
                 else if( rOptVal.equalsIgnoreAsciiCase( 
OOO_STRING_SVTOOLS_HTML_AL_center ) )
@@ -2500,7 +2497,7 @@ void ScHTMLTable::ProcessFormatOptions( SfxItemSet& 
rItemSet, const HtmlImportIn
             case HtmlOptionId::VALIGN:
             {
                 SvxCellVerJustify eVal = SvxCellVerJustify::Standard;
-                const OUString& rOptVal = itr->GetString();
+                const OUString& rOptVal = rOption.GetString();
                 if( rOptVal.equalsIgnoreAsciiCase( 
OOO_STRING_SVTOOLS_HTML_VA_top ) )
                     eVal = SvxCellVerJustify::Top;
                 else if( rOptVal.equalsIgnoreAsciiCase( 
OOO_STRING_SVTOOLS_HTML_VA_middle ) )
@@ -2515,7 +2512,7 @@ void ScHTMLTable::ProcessFormatOptions( SfxItemSet& 
rItemSet, const HtmlImportIn
             case HtmlOptionId::BGCOLOR:
             {
                 Color aColor;
-                itr->GetColor( aColor );
+                rOption.GetColor( aColor );
                 rItemSet.Put( SvxBrushItem( aColor, ATTR_BACKGROUND ) );
             }
             break;
@@ -2536,8 +2533,7 @@ void ScHTMLTable::SetDocSize( ScHTMLOrient eOrient, 
SCCOLROW nCellPos, SCCOLROW
     // #i109987# only grow, don't shrink - use the largest needed size
     SCCOLROW nDiff = nSize - ((nIndex == 0) ? rSizes.front() : (rSizes[ nIndex 
] - rSizes[ nIndex - 1 ]));
     if( nDiff > 0 )
-        for( ScSizeVec::iterator aIt = rSizes.begin() + nIndex, aEnd = 
rSizes.end(); aIt != aEnd; ++aIt )
-            *aIt += nDiff;
+        std::for_each(rSizes.begin() + nIndex, rSizes.end(), 
[&nDiff](SCCOLROW& rSize) { rSize += nDiff; });
 }
 
 void ScHTMLTable::CalcNeededDocSize(
@@ -2606,16 +2602,10 @@ void ScHTMLTable::RecalcDocSize()
     for( sal_uInt16 nPass = PASS_SINGLE; nPass <= PASS_SPANNED; ++nPass )
     {
         // iterate through every table cell
-        ScHTMLEntryMap::const_iterator aMapIterEnd = maEntryMap.end();
-        for( ScHTMLEntryMap::const_iterator aMapIter = maEntryMap.begin(); 
aMapIter != aMapIterEnd; ++aMapIter )
+        for( const auto& [rCellPos, rEntryVector] : maEntryMap )
         {
-            const ScHTMLPos& rCellPos = aMapIter->first;
             ScHTMLSize aCellSpan = GetSpan( rCellPos );
 
-            const ScHTMLEntryVector& rEntryVector = aMapIter->second;
-            ScHTMLEntryVector::const_iterator aVectorIter;
-            ScHTMLEntryVector::const_iterator aVectorIterEnd = 
rEntryVector.end();
-
             // process the dimension of the current cell in this pass?
             // (pass is single and span is 1) or (pass is not single and span 
is not 1)
             bool bProcessColWidth = ((nPass == PASS_SINGLE) == 
(aCellSpan.mnCols == 1));
@@ -2625,9 +2615,9 @@ void ScHTMLTable::RecalcDocSize()
                 ScHTMLSize aDocSize( 1, 0 );    // resulting size of the cell 
in document
 
                 // expand the cell size for each cell parse entry
-                for( aVectorIter = rEntryVector.begin(); aVectorIter != 
aVectorIterEnd; ++aVectorIter )
+                for( const auto& rpEntry : rEntryVector )
                 {
-                    ScHTMLTable* pTable = GetExistingTable( 
(*aVectorIter)->GetTableId() );
+                    ScHTMLTable* pTable = GetExistingTable( 
rpEntry->GetTableId() );
                     // find entry with maximum width
                     if( bProcessColWidth && pTable )
                         aDocSize.mnCols = std::max( aDocSize.mnCols, 
static_cast< SCCOL >( pTable->GetDocSize( tdCol ) ) );
@@ -2653,23 +2643,20 @@ void ScHTMLTable::RecalcDocPos( const ScHTMLPos& 
rBasePos )
     // after the previous assignment it is allowed to call GetDocPos() methods
 
     // iterate through every table cell
-    ScHTMLEntryMap::iterator aMapIterEnd = maEntryMap.end();
-    for( ScHTMLEntryMap::iterator aMapIter = maEntryMap.begin(); aMapIter != 
aMapIterEnd; ++aMapIter )
+    for( auto& [rCellPos, rEntryVector] : maEntryMap )
     {
         // fixed doc position of the entire cell (first entry)
-        const ScHTMLPos aCellDocPos( GetDocPos( aMapIter->first ) );
+        const ScHTMLPos aCellDocPos( GetDocPos( rCellPos ) );
         // fixed doc size of the entire cell
-        const ScHTMLSize aCellDocSize( GetDocSize( aMapIter->first ) );
+        const ScHTMLSize aCellDocSize( GetDocSize( rCellPos ) );
 
         // running doc position for single entries
         ScHTMLPos aEntryDocPos( aCellDocPos );
 
-        ScHTMLEntryVector& rEntryVector = aMapIter->second;
         ScHTMLEntry* pEntry = nullptr;
-        ScHTMLEntryVector::iterator aVectorIterEnd = rEntryVector.end();
-        for( ScHTMLEntryVector::iterator aVectorIter = rEntryVector.begin(); 
aVectorIter != aVectorIterEnd; ++aVectorIter )
+        for( const auto& rpEntry : rEntryVector )
         {
-            pEntry = *aVectorIter;
+            pEntry = rpEntry;
             if( ScHTMLTable* pTable = GetExistingTable( pEntry->GetTableId() ) 
)
             {
                 pTable->RecalcDocPos( aEntryDocPos );   // recalc nested table
@@ -2903,14 +2890,13 @@ void ScHTMLQueryParser::InsertText( const 
HtmlImportInfo& rInfo )
 void ScHTMLQueryParser::FontOn( const HtmlImportInfo& rInfo )
 {
     const HTMLOptions& rOptions = 
static_cast<HTMLParser*>(rInfo.pParser)->GetOptions();
-    HTMLOptions::const_iterator itr = rOptions.begin(), itrEnd = 
rOptions.end();
-    for (; itr != itrEnd; ++itr)
+    for (const auto& rOption : rOptions)
     {
-        switch( itr->GetToken() )
+        switch( rOption.GetToken() )
         {
             case HtmlOptionId::FACE :
             {
-                const OUString& rFace = itr->GetString();
+                const OUString& rFace = rOption.GetString();
                 OUString aFontName;
                 sal_Int32 nPos = 0;
                 while( nPos != -1 )
@@ -2927,14 +2913,14 @@ void ScHTMLQueryParser::FontOn( const HtmlImportInfo& 
rInfo )
             break;
             case HtmlOptionId::SIZE :
             {
-                sal_uInt32 nSize = getLimitedValue< sal_uInt32 >( 
itr->GetNumber(), 1, SC_HTML_FONTSIZES );
+                sal_uInt32 nSize = getLimitedValue< sal_uInt32 >( 
rOption.GetNumber(), 1, SC_HTML_FONTSIZES );
                 mpCurrTable->PutItem( SvxFontHeightItem( maFontHeights[ nSize 
- 1 ], 100, ATTR_FONT_HEIGHT ) );
             }
             break;
             case HtmlOptionId::COLOR :
             {
                 Color aColor;
-                itr->GetColor( aColor );
+                rOption.GetColor( aColor );
                 mpCurrTable->PutItem( SvxColorItem( aColor, ATTR_FONT_COLOR ) 
);
             }
             break;
diff --git a/sc/source/filter/lotus/lotattr.cxx 
b/sc/source/filter/lotus/lotattr.cxx
index 8c04bfe18ff3..2333ce127f85 100644
--- a/sc/source/filter/lotus/lotattr.cxx
+++ b/sc/source/filter/lotus/lotattr.cxx
@@ -214,11 +214,10 @@ void LotAttrCol::Apply(LOTUS_ROOT* pLotusRoot, const 
SCCOL nColNum, const SCTAB
 {
     ScDocument*     pDoc = pLotusRoot->pDoc;
 
-    std::vector<std::unique_ptr<ENTRY> >::iterator iter;
-    for (iter = aEntries.begin(); iter != aEntries.end(); ++iter)
+    for (const auto& rxEntry : aEntries)
     {
-        pDoc->ApplyPatternAreaTab(nColNum, (*iter)->nFirstRow, nColNum, 
(*iter)->nLastRow,
-                                  nTabNum, *((*iter)->pPattAttr));
+        pDoc->ApplyPatternAreaTab(nColNum, rxEntry->nFirstRow, nColNum, 
rxEntry->nLastRow,
+                                  nTabNum, *(rxEntry->pPattAttr));
     }
 }
 
diff --git a/sc/source/filter/lotus/tool.cxx b/sc/source/filter/lotus/tool.cxx
index b7082fcff900..11063f0c2bd0 100644
--- a/sc/source/filter/lotus/tool.cxx
+++ b/sc/source/filter/lotus/tool.cxx
@@ -386,19 +386,16 @@ LotusRangeList::LotusRangeList()
 
 LotusRangeList::~LotusRangeList ()
 {
-    std::vector<LotusRange*>::iterator pIter;
-    for (pIter = maRanges.begin(); pIter != maRanges.end(); ++pIter)
-        delete *pIter;
+    for (const auto& rpRange : maRanges)
+        delete rpRange;
 }
 
 LR_ID LotusRangeList::GetIndex( const LotusRange &rRef )
 {
-    std::vector<LotusRange*>::iterator pIter;
-    for (pIter = maRanges.begin(); pIter != maRanges.end(); ++pIter)
-    {
-        if (rRef == *(*pIter))
-            return (*pIter)->nId;
-    }
+    std::vector<LotusRange*>::iterator pIter = std::find_if(maRanges.begin(), 
maRanges.end(),
+        [&rRef](const LotusRange* pRange) { return rRef == *pRange; });
+    if (pIter != maRanges.end())
+        return (*pIter)->nId;
 
     return ID_FAIL;
 }
@@ -471,14 +468,12 @@ bool RangeNameBufferWK3::FindRel( const OUString& rRef, 
sal_uInt16& rIndex )
 {
     StringHashEntry     aRef( rRef );
 
-    std::vector<Entry>::const_iterator itr;
-    for ( itr = maEntries.begin(); itr != maEntries.end(); ++itr )
+    std::vector<Entry>::const_iterator itr = std::find_if(maEntries.begin(), 
maEntries.end(),
+        [&aRef](const Entry& rEntry) { return aRef == rEntry.aStrHashEntry; });
+    if (itr != maEntries.end())
     {
-        if ( aRef == itr->aStrHashEntry )
-        {
-            rIndex = itr->nRelInd;
-            return true;
-        }
+        rIndex = itr->nRelInd;
+        return true;
     }
 
     return false;
@@ -490,40 +485,38 @@ bool RangeNameBufferWK3::FindAbs( const OUString& rRef, 
sal_uInt16& rIndex )
     aTmp = aTmp.copy(1);
     StringHashEntry     aRef( aTmp ); // search w/o '$'!
 
-    std::vector<Entry>::iterator itr;
-    for ( itr = maEntries.begin(); itr != maEntries.end(); ++itr )
+    std::vector<Entry>::iterator itr = std::find_if(maEntries.begin(), 
maEntries.end(),
+        [&aRef](const Entry& rEntry) { return aRef == rEntry.aStrHashEntry; });
+    if (itr != maEntries.end())
     {
-        if ( aRef == itr->aStrHashEntry )
+        // setup new range if needed
+        if( itr->nAbsInd )
+            rIndex = itr->nAbsInd;
+        else
         {
-            // setup new range if needed
-            if( itr->nAbsInd )
-                rIndex = itr->nAbsInd;
+            ScSingleRefData*        pRef = &itr->aScComplexRefDataRel.Ref1;
+            pScTokenArray->Clear();
+
+            pRef->SetColRel( false );
+            pRef->SetRowRel( false );
+            pRef->SetTabRel( true );
+
+            if( itr->bSingleRef )
+                pScTokenArray->AddSingleReference( *pRef );
             else
             {
-                ScSingleRefData*        pRef = &itr->aScComplexRefDataRel.Ref1;
-                pScTokenArray->Clear();
-
+                pRef = &itr->aScComplexRefDataRel.Ref2;
                 pRef->SetColRel( false );
                 pRef->SetRowRel( false );
                 pRef->SetTabRel( true );
-
-                if( itr->bSingleRef )
-                    pScTokenArray->AddSingleReference( *pRef );
-                else
-                {
-                    pRef = &itr->aScComplexRefDataRel.Ref2;
-                    pRef->SetColRel( false );
-                    pRef->SetRowRel( false );
-                    pRef->SetTabRel( true );
-                    pScTokenArray->AddDoubleReference( 
itr->aScComplexRefDataRel );
-                }
-
-                rIndex = itr->nAbsInd = nIntCount;
-                nIntCount++;
+                pScTokenArray->AddDoubleReference( itr->aScComplexRefDataRel );
             }
 
-            return true;
+            rIndex = itr->nAbsInd = nIntCount;
+            nIntCount++;
         }
+
+        return true;
     }
 
     return false;
diff --git a/sc/source/filter/oox/addressconverter.cxx 
b/sc/source/filter/oox/addressconverter.cxx
index 196c6ad4d88c..2abc37307f90 100644
--- a/sc/source/filter/oox/addressconverter.cxx
+++ b/sc/source/filter/oox/addressconverter.cxx
@@ -65,8 +65,8 @@ void BinRangeList::read( SequenceInputStream& rStrm )
 {
     sal_Int32 nCount = rStrm.readInt32();
     mvRanges.resize( getLimitedValue< size_t, sal_Int64 >( nCount, 0, 
rStrm.getRemaining() / 16 ) );
-    for( ::std::vector< BinRange >::iterator aIt = mvRanges.begin(), aEnd = 
mvRanges.end(); aIt != aEnd; ++aIt )
-        aIt->read( rStrm );
+    for( auto& rRange : mvRanges )
+        rRange.read( rStrm );
 }
 
 AddressConverter::AddressConverter( const WorkbookHelper& rHelper ) :
@@ -440,8 +440,8 @@ void AddressConverter::convertToCellRangeList( ScRangeList& 
orRanges,
         const BinRangeList& rBinRanges, sal_Int16 nSheet, bool bTrackOverflow )
 {
     ScRange aRange;
-    for( ::std::vector< BinRange >::const_iterator aIt = rBinRanges.begin(), 
aEnd = rBinRanges.end(); aIt != aEnd; ++aIt )
-        if( convertToCellRange( aRange, *aIt, nSheet, true, bTrackOverflow ) )
+    for( const auto& rBinRange : rBinRanges )
+        if( convertToCellRange( aRange, rBinRange, nSheet, true, 
bTrackOverflow ) )
             orRanges.push_back( aRange );
 }
 
diff --git a/sc/source/filter/oox/autofilterbuffer.cxx 
b/sc/source/filter/oox/autofilterbuffer.cxx
index 3f9a3088bb08..9e53200092ce 100644
--- a/sc/source/filter/oox/autofilterbuffer.cxx
+++ b/sc/source/filter/oox/autofilterbuffer.cxx
@@ -423,18 +423,18 @@ ApiFilterSettings CustomFilter::finalizeImport( sal_Int32 
/*nMaxCount*/ )
 {
     ApiFilterSettings aSettings;
     OSL_ENSURE( maCriteria.size() <= 2, "CustomFilter::finalizeImport - too 
many filter criteria" );
-    for( FilterCriterionVector::iterator aIt = maCriteria.begin(), aEnd = 
maCriteria.end(); aIt != aEnd; ++aIt )
+    for( const auto& rCriterion : maCriteria )
     {
         // first extract the filter operator
         sal_Int32 nOperator = 0;
-        bool bValidOperator = lclGetApiOperatorFromToken( nOperator, 
aIt->mnOperator );
+        bool bValidOperator = lclGetApiOperatorFromToken( nOperator, 
rCriterion.mnOperator );
         if( bValidOperator )
         {
-            if( aIt->maValue.has< OUString >() )
+            if( rCriterion.maValue.has< OUString >() )
             {
                 // string argument
                 OUString aValue;
-                aIt->maValue >>= aValue;
+                rCriterion.maValue >>= aValue;
                 // check for 'empty', 'contains', 'begins with', or 'ends 
with' text filters
                 bool bEqual = nOperator == FilterOperator2::EQUAL;
                 bool bNotEqual = nOperator == FilterOperator2::NOT_EQUAL;
@@ -474,11 +474,11 @@ ApiFilterSettings CustomFilter::finalizeImport( sal_Int32 
/*nMaxCount*/ )
                     aSettings.appendField( mbAnd, nOperator, aValue );
                 }
             }
-            else if( aIt->maValue.has< double >() )
+            else if( rCriterion.maValue.has< double >() )
             {
                 // floating-point argument
                 double fValue = 0.0;
-                aIt->maValue >>= fValue;
+                rCriterion.maValue >>= fValue;
                 aSettings.appendField( mbAnd, nOperator, fValue );
             }
         }
@@ -524,8 +524,8 @@ ApiFilterSettings FilterColumn::finalizeImport( sal_Int32 
nMaxCount )
         // filter settings object creates a sequence of filter fields
         aSettings = mxSettings->finalizeImport( nMaxCount );
         // add column index to all filter fields
-        for( ApiFilterSettings::FilterFieldVector::iterator aIt = 
aSettings.maFilterFields.begin(), aEnd = aSettings.maFilterFields.end(); aIt != 
aEnd; ++aIt )
-            aIt->Field = mnColId;
+        for( auto& rFilterField : aSettings.maFilterFields )
+            rFilterField.Field = mnColId;
     }
     return aSettings;
 }
@@ -588,10 +588,10 @@ void AutoFilter::finalizeImport( const 
Reference<XSheetFilterDescriptor3>& rxFil
         bool bHasOrConnection = false;
 
         // process all filter column objects, exit when 'or' connection exists
-        for( FilterColumnVector::iterator aIt = maFilterColumns.begin(), aEnd 
= maFilterColumns.end(); !bHasOrConnection && (aIt != aEnd); ++aIt )
+        for( const auto& rxFilterColumn : maFilterColumns )
         {
             // the filter settings object creates a list of filter fields
-            ApiFilterSettings aSettings = (*aIt)->finalizeImport( nMaxCount );
+            ApiFilterSettings aSettings = rxFilterColumn->finalizeImport( 
nMaxCount );
             ApiFilterSettings::FilterFieldVector& rColumnFields = 
aSettings.maFilterFields;
 
             // new total number of filter fields
@@ -605,8 +605,8 @@ void AutoFilter::finalizeImport( const 
Reference<XSheetFilterDescriptor3>& rxFil
 
             // check whether fields are connected by 'or' (see comments above).
             if( rColumnFields.size() >= 2 )
-                for( ApiFilterSettings::FilterFieldVector::iterator aSIt = 
rColumnFields.begin() + 1, aSEnd = rColumnFields.end(); !bHasOrConnection && 
(aSIt != aSEnd); ++aSIt )
-                    bHasOrConnection = aSIt->Connection == FilterConnection_OR;
+                bHasOrConnection = std::any_of(rColumnFields.begin() + 1, 
rColumnFields.end(),
+                    [](const css::sheet::TableFilterField3& rColumnField) { 
return rColumnField.Connection == FilterConnection_OR; });
 
             /*  Skip the column filter, if no filter fields have been created,
                 if the number of new filter fields would exceed the total limit
@@ -624,6 +624,9 @@ void AutoFilter::finalizeImport( const 
Reference<XSheetFilterDescriptor3>& rxFil
                 // update the regular expressions mode
                 obNeedsRegExp.assignIfUsed( aSettings.mobNeedsRegExp );
             }
+
+            if( bHasOrConnection )
+                break;
         }
 
         // insert all filter fields to the filter descriptor
diff --git a/sc/source/filter/oox/condformatbuffer.cxx 
b/sc/source/filter/oox/condformatbuffer.cxx
index 3b8bb65d6bce..a189008afb76 100644
--- a/sc/source/filter/oox/condformatbuffer.cxx
+++ b/sc/source/filter/oox/condformatbuffer.cxx
@@ -1094,26 +1094,22 @@ ScConditionalFormat* findFormatByRange(const 
ScRangeList& rRange, const ScDocume
 
 void CondFormatBuffer::finalizeImport()
 {
-    CondFormatVec::iterator it = maCondFormats.begin();
-    CondFormatVec::iterator it_end = maCondFormats.end();
-    for( ; it != it_end; ++it )
+    for( const auto& rxCondFormat : maCondFormats )
     {
-        if ( (*it).get() )
-            (*it).get()->finalizeImport();
+        if ( rxCondFormat.get() )
+            rxCondFormat.get()->finalizeImport();
     }
-    ExtCfDataBarRuleVec::iterator ext_it = maCfRules.begin();
-    ExtCfDataBarRuleVec::iterator ext_end = maCfRules.end();
-    for ( ; ext_it != ext_end; ++ext_it )
+    for ( const auto& rxCfRule : maCfRules )
     {
-        if ( (*ext_it).get() )
-            (*ext_it).get()->finalizeImport();
+        if ( rxCfRule.get() )
+            rxCfRule.get()->finalizeImport();
     }
 
-    for (auto itr = maExtCondFormats.begin(); itr != maExtCondFormats.end(); 
++itr)
+    for (const auto& rxExtCondFormat : maExtCondFormats)
     {
         ScDocument* pDoc = &getScDocument();
 
-        const ScRangeList& rRange = (*itr)->getRange();
+        const ScRangeList& rRange = rxExtCondFormat->getRange();
         SCTAB nTab = rRange.front().aStart.Tab();
         ScConditionalFormat* pFormat = findFormatByRange(rRange, pDoc, nTab);
         if (!pFormat)
@@ -1125,10 +1121,10 @@ void CondFormatBuffer::finalizeImport()
             pDoc->AddCondFormatData(rRange, nTab, nKey);
         }
 
-        const std::vector< std::unique_ptr<ScFormatEntry> >& rEntries = 
(*itr)->getEntries();
-        for (auto i = rEntries.begin(); i != rEntries.end(); ++i)
+        const std::vector< std::unique_ptr<ScFormatEntry> >& rEntries = 
rxExtCondFormat->getEntries();
+        for (const auto& rxEntry : rEntries)
         {
-            pFormat->AddEntry((*i)->Clone(pDoc));
+            pFormat->AddEntry(rxEntry->Clone(pDoc));
         }
     }
 }
diff --git a/sc/source/filter/oox/connectionsbuffer.cxx 
b/sc/source/filter/oox/connectionsbuffer.cxx
index 4aef1f8e45de..4433b69abe71 100644
--- a/sc/source/filter/oox/connectionsbuffer.cxx
+++ b/sc/source/filter/oox/connectionsbuffer.cxx
@@ -291,8 +291,8 @@ Connection& ConnectionsBuffer::createConnection()
 
 void ConnectionsBuffer::finalizeImport()
 {
-    for( ConnectionVector::iterator aIt = maConnections.begin(), aEnd = 
maConnections.end(); aIt != aEnd; ++aIt )
-        insertConnectionToMap( *aIt );
+    for( const auto& rxConnection : maConnections )
+        insertConnectionToMap( rxConnection );
 }
 
 ConnectionRef ConnectionsBuffer::getConnection( sal_Int32 nConnId ) const
diff --git a/sc/source/filter/oox/defnamesbuffer.cxx 
b/sc/source/filter/oox/defnamesbuffer.cxx
index 1fd80b42a952..182be74080e1 100644
--- a/sc/source/filter/oox/defnamesbuffer.cxx
+++ b/sc/source/filter/oox/defnamesbuffer.cxx
@@ -351,9 +351,8 @@ void DefinedNamesBuffer::finalizeImport()
 {
     // first insert all names without formula definition into the document, 
and insert them into the maps
     int index = 0;
-    for( DefNameVector::iterator aIt = maDefNames.begin(), aEnd = 
maDefNames.end(); aIt != aEnd; ++aIt )
+    for( DefinedNameRef& xDefName : maDefNames )
     {
-        DefinedNameRef xDefName = *aIt;
         xDefName->createNameObject( ++index );
         // map by sheet index and original model name
         maModelNameMap[ SheetNameKey( xDefName->getLocalCalcSheet(), 
xDefName->getUpcaseModelName() ) ] = xDefName;
diff --git a/sc/source/filter/oox/excelchartconverter.cxx 
b/sc/source/filter/oox/excelchartconverter.cxx
index 64b318fdacd0..bc5b74690f3a 100644
--- a/sc/source/filter/oox/excelchartconverter.cxx
+++ b/sc/source/filter/oox/excelchartconverter.cxx
@@ -97,8 +97,11 @@ Reference< XDataSequence > 
ExcelChartConverter::createDataSequence(
         Matrix< Any > aMatrix( rDataSeq.maData.size(), 1 );
         Matrix< Any >::iterator aMIt = aMatrix.begin();
         // TODO: how to handle missing values in the map?
-        for( DataSequenceModel::AnyMap::const_iterator aDIt = 
rDataSeq.maData.begin(), aDEnd = rDataSeq.maData.end(); aDIt != aDEnd; ++aDIt, 
++aMIt )
-            *aMIt = aDIt->second;
+        for( const auto& rEntry : rDataSeq.maData )
+        {
+            *aMIt = rEntry.second;
+            ++aMIt;
+        }
         OUString aRangeRep = FormulaProcessorBase::generateApiArray( aMatrix );
 
         if (!aRangeRep.isEmpty())
diff --git a/sc/source/filter/oox/externallinkbuffer.cxx 
b/sc/source/filter/oox/externallinkbuffer.cxx
index 6be609eca10b..152841b2c932 100644
--- a/sc/source/filter/oox/externallinkbuffer.cxx
+++ b/sc/source/filter/oox/externallinkbuffer.cxx
@@ -400,8 +400,8 @@ ExternalLinkInfo ExternalLink::getLinkInfo() const
             aDdeLinkInfo.Topic = maTargetUrl;
             ::std::vector< DDEItemInfo > aItemInfos;
             DDEItemInfo aItemInfo;
-            for( ExternalNameVector::const_iterator aIt = maExtNames.begin(), 
aEnd = maExtNames.end(); aIt != aEnd; ++aIt )
-                if( (*aIt)->getDdeItemInfo( aItemInfo ) )
+            for( const auto& rxExtName : maExtNames )
+                if( rxExtName->getDdeItemInfo( aItemInfo ) )
                     aItemInfos.push_back( aItemInfo );
             aDdeLinkInfo.Items = ContainerHelper::vectorToSequence( aItemInfos 
);
             aLinkInfo.Data <<= aDdeLinkInfo;
@@ -623,8 +623,8 @@ Sequence< ExternalLinkInfo > 
ExternalLinkBuffer::getLinkInfos() const
     ::std::vector< ExternalLinkInfo > aLinkInfos;
     // add entry for implicit index 0 (self reference to this document)
     aLinkInfos.push_back( mxSelfRef->getLinkInfo() );
-    for( ExternalLinkVec::const_iterator aIt = maExtLinks.begin(), aEnd = 
maExtLinks.end(); aIt != aEnd; ++aIt )
-        aLinkInfos.push_back( (*aIt)->getLinkInfo() );
+    for( const auto& rxExtLink : maExtLinks )
+        aLinkInfos.push_back( rxExtLink->getLinkInfo() );
     return ContainerHelper::vectorToSequence( aLinkInfos );
 }
 
diff --git a/sc/source/filter/oox/formulabase.cxx 
b/sc/source/filter/oox/formulabase.cxx
index 7872a03529d1..62633437c1cb 100644
--- a/sc/source/filter/oox/formulabase.cxx
+++ b/sc/source/filter/oox/formulabase.cxx
@@ -1371,9 +1371,8 @@ bool OpCodeProviderImpl::initFuncOpCode( FunctionInfo& 
orFuncInfo, const ApiToke
 bool OpCodeProviderImpl::initFuncOpCodes( const ApiTokenMap& rIntFuncTokenMap, 
const ApiTokenMap& rExtFuncTokenMap, const FunctionInfoVector& rFuncInfos )
 {
     bool bIsValid = true;
-    for( FunctionInfoVector::const_iterator aIt = rFuncInfos.begin(), aEnd = 
rFuncInfos.end(); aIt != aEnd; ++aIt )
+    for( const FunctionInfoRef& xFuncInfo : rFuncInfos )
     {
-        FunctionInfoRef xFuncInfo = *aIt;
         // set API opcode from ODF function name
         if (xFuncInfo->mbExternal)
             bIsValid &= initFuncOpCode( *xFuncInfo, rExtFuncTokenMap );
diff --git a/sc/source/filter/oox/formulaparser.cxx 
b/sc/source/filter/oox/formulaparser.cxx
index 14c428105a43..4300e9cb469d 100644
--- a/sc/source/filter/oox/formulaparser.cxx
+++ b/sc/source/filter/oox/formulaparser.cxx
@@ -679,17 +679,17 @@ Any& FormulaParserImpl::insertRawToken( sal_Int32 
nOpCode, size_t nIndexFromEnd
 
 size_t FormulaParserImpl::appendWhiteSpaceTokens( const WhiteSpaceVec* pSpaces 
)
 {
-    if( pSpaces && !pSpaces->empty() )
-        for( WhiteSpaceVec::const_iterator aIt = pSpaces->begin(), aEnd = 
pSpaces->end(); aIt != aEnd; ++aIt )
-            appendRawToken( OPCODE_SPACES ) <<= aIt->first;
+    if( pSpaces )
+        for( const auto& rSpace : *pSpaces )
+            appendRawToken( OPCODE_SPACES ) <<= rSpace.first;
     return pSpaces ? pSpaces->size() : 0;
 }
 
 size_t FormulaParserImpl::insertWhiteSpaceTokens( const WhiteSpaceVec* 
pSpaces, size_t nIndexFromEnd )
 {
-    if( pSpaces && !pSpaces->empty() )
-        for( WhiteSpaceVec::const_iterator aIt = pSpaces->begin(), aEnd = 
pSpaces->end(); aIt != aEnd; ++aIt )
-            insertRawToken( OPCODE_SPACES, nIndexFromEnd ) <<= aIt->first;
+    if( pSpaces )
+        for( const auto& rSpace : *pSpaces )
+            insertRawToken( OPCODE_SPACES, nIndexFromEnd ) <<= rSpace.first;
     return pSpaces ? pSpaces->size() : 0;
 }
 
diff --git a/sc/source/filter/oox/numberformatsbuffer.cxx 
b/sc/source/filter/oox/numberformatsbuffer.cxx
index 906bfdb068fa..2ca5a3dc88f2 100644
--- a/sc/source/filter/oox/numberformatsbuffer.cxx
+++ b/sc/source/filter/oox/numberformatsbuffer.cxx
@@ -2077,11 +2077,11 @@ void NumberFormatsBuffer::insertBuiltinFormats()
     }
 
     // copy reused number formats
-    for( ReuseMap::const_iterator aRIt = aReuseMap.begin(), aREnd = 
aReuseMap.end(); aRIt != aREnd; ++aRIt )
+    for( const auto& [rNumFmtId, rReuseId] : aReuseMap )
     {
-        maNumFmts[ aRIt->first ] = maNumFmts[ aRIt->second ];
-        if ( aRIt->first > mnHighestId )
-            mnHighestId = aRIt->first;
+        maNumFmts[ rNumFmtId ] = maNumFmts[ rReuseId ];
+        if ( rNumFmtId > mnHighestId )
+            mnHighestId = rNumFmtId;
     }
 }
 
diff --git a/sc/source/filter/oox/pivotcachebuffer.cxx 
b/sc/source/filter/oox/pivotcachebuffer.cxx
index dc8366cdc65a..2adda9081355 100644
--- a/sc/source/filter/oox/pivotcachebuffer.cxx
+++ b/sc/source/filter/oox/pivotcachebuffer.cxx
@@ -303,10 +303,10 @@ const PivotCacheItem* PivotCacheItemList::getCacheItem( 
sal_Int32 nItemIdx ) con
 
 void PivotCacheItemList::applyItemCaptions( const IdCaptionPairList& vCaptions 
)
 {
-    for( IdCaptionPairList::const_iterator aIt = vCaptions.begin(), aEnd = 
vCaptions.end(); aIt != aEnd; ++aIt )
+    for( const auto& [rId, rCaption] : vCaptions )
     {
-        if ( static_cast<sal_uInt32>( aIt->first ) < maItems.size() )
-            maItems[ aIt->first ].setStringValue( aIt->second );
+        if ( static_cast<sal_uInt32>( rId ) < maItems.size() )
+            maItems[ rId ].setStringValue( rCaption );
     }
 }
 
@@ -314,8 +314,8 @@ void PivotCacheItemList::getCacheItemNames( ::std::vector< 
OUString >& orItemNam
 {
     orItemNames.clear();
     orItemNames.reserve( maItems.size() );
-    for( CacheItemVector::const_iterator aIt = maItems.begin(), aEnd = 
maItems.end(); aIt != aEnd; ++aIt )
-        orItemNames.push_back( aIt->getName() );
+    for( const auto& rItem : maItems )
+        orItemNames.push_back( rItem.getName() );
 }
 
 // private --------------------------------------------------------------------
@@ -657,26 +657,29 @@ OUString PivotCacheField::createParentGroupField( const 
Reference< XDataPilotFie
 
     // map the group item indexes from maGroupItems to all item indexes from 
maDiscreteItems
     std::vector< std::vector<sal_Int32> > aItemMap( maGroupItems.size() );
-    for( IndexVector::const_iterator aBeg = maDiscreteItems.begin(), aIt = 
aBeg, aEnd = maDiscreteItems.end(); aIt != aEnd; ++aIt )
+    sal_Int32 nIndex = -1;
+    for( const auto& rDiscreteItem : maDiscreteItems )
     {
-        if( std::vector<sal_Int32>* pItems = 
ContainerHelper::getVectorElementAccess( aItemMap, *aIt ) )
+        ++nIndex;
+        if( std::vector<sal_Int32>* pItems = 
ContainerHelper::getVectorElementAccess( aItemMap, rDiscreteItem ) )
         {
-            if ( const PivotCacheItem* pItem = 
rBaseCacheField.getCacheItems().getCacheItem( aIt - aBeg ) )
+            if ( const PivotCacheItem* pItem = 
rBaseCacheField.getCacheItems().getCacheItem( nIndex ) )
             {
                 // Skip unspecified or unused entries or errors
                 if ( pItem->isUnused() || ( pItem->getType() == XML_m ) ||  ( 
pItem->getType() == XML_e ) )
                     continue;
             }
-            pItems->push_back( static_cast< sal_Int32 >( aIt - aBeg ) );
+            pItems->push_back( nIndex );
         }
     }
 
     // process all groups
     Reference< XDataPilotField > xDPGroupField;
-    for( auto aBeg = aItemMap.begin(), aIt = aBeg, aEnd = aItemMap.end(); aIt 
!= aEnd; ++aIt )
+    nIndex = 0;
+    for( const auto& rItems : aItemMap )
     {
-        SAL_WARN_IF( aIt->empty(), "sc", 
"PivotCacheField::createParentGroupField - item/group should not be empty" );
-        if( !aIt->empty() )
+        SAL_WARN_IF( rItems.empty(), "sc", 
"PivotCacheField::createParentGroupField - item/group should not be empty" );
+        if( !rItems.empty() )
         {
             /*  Insert the names of the items that are part of this group. Calc
                 expects the names of the members of the field whose members are
@@ -686,7 +689,7 @@ OUString PivotCacheField::createParentGroupField( const 
Reference< XDataPilotFie
                 names as they are already grouped is used here to resolve the
                 item names. */
             ::std::vector< OUString > aMembers;
-            for( auto i : *aIt )
+            for( auto i : rItems )
                 if( const PivotCacheGroupItem* pName = 
ContainerHelper::getVectorElement( orItemNames, i ) )
                     if( ::std::find( aMembers.begin(), aMembers.end(), 
pName->maGroupName ) == aMembers.end() )
                         aMembers.push_back( pName->maGroupName );
@@ -717,7 +720,7 @@ OUString PivotCacheField::createParentGroupField( const 
Reference< XDataPilotFie
                     Therefore, a name from the passed list of original item
                     names is used to find the correct group. */
                 OUString aFirstItem;
-                if( const PivotCacheGroupItem* pName = 
ContainerHelper::getVectorElement( orItemNames, aIt->front() ) )
+                if( const PivotCacheGroupItem* pName = 
ContainerHelper::getVectorElement( orItemNames, rItems.front() ) )
                     aFirstItem = pName->maOrigName;
                 Reference< XNamed > xGroupName;
                 OUString aAutoName;
@@ -739,7 +742,7 @@ OUString PivotCacheField::createParentGroupField( const 
Reference< XDataPilotFie
 
                 // get the real group name from the list of group items
                 OUString aGroupName;
-                if( const PivotCacheItem* pGroupItem = 
maGroupItems.getCacheItem( static_cast< sal_Int32 >( aIt - aBeg ) ) )
+                if( const PivotCacheItem* pGroupItem = 
maGroupItems.getCacheItem( nIndex ) )
                     aGroupName = pGroupItem->getName();
                 SAL_WARN_IF( aGroupName.isEmpty(), "sc", 
"PivotCacheField::createParentGroupField - cannot find group name" );
                 if( aGroupName.isEmpty() )
@@ -754,7 +757,7 @@ OUString PivotCacheField::createParentGroupField( const 
Reference< XDataPilotFie
                         aPropSet.setProperty( PROP_GroupInfo, aGroupInfo );
                     }
                     // replace original item names in passed vector with group 
name
-                    for( auto i : *aIt )
+                    for( auto i : rItems )
                         if( PivotCacheGroupItem* pName = 
ContainerHelper::getVectorElementAccess( orItemNames, i ) )
                             pName->maGroupName = aGroupName;
                 }
@@ -764,6 +767,7 @@ OUString PivotCacheField::createParentGroupField( const 
Reference< XDataPilotFie
                 SAL_WARN("sc", "PivotCacheField::createParentGroupField - 
exception was thrown" );
             }
         }
+        ++nIndex;
     }
 
     Reference< XNamed > xFieldName( xDPGroupField, UNO_QUERY );
@@ -1051,8 +1055,13 @@ void PivotCache::writeSourceHeaderCells( const 
WorksheetHelper& rSheetHelper ) c
     SCROW nRow = maSheetSrcModel.maRange.aStart.Row();
     mnCurrRow = -1;
     updateSourceDataRow( rSheetHelper, nRow );
-    for( PivotCacheFieldVector::const_iterator aIt = maDatabaseFields.begin(), 
aEnd = maDatabaseFields.end(); (aIt != aEnd) && (nCol <= nMaxCol); ++aIt, 
++nCol )
-        (*aIt)->writeSourceHeaderCell( rSheetHelper, nCol, nRow );
+    for( const auto& rxDatabaseField : maDatabaseFields )
+    {
+        if (nCol > nMaxCol)
+            break;
+        rxDatabaseField->writeSourceHeaderCell( rSheetHelper, nCol, nRow );
+        ++nCol;
+    }
 }
 
 void PivotCache::writeSourceDataCell( const WorksheetHelper& rSheetHelper, 
sal_Int32 nColIdx, sal_Int32 nRowIdx, const PivotCacheItem& rItem ) const
@@ -1072,8 +1081,13 @@ void PivotCache::importPCRecord( SequenceInputStream& 
rStrm, const WorksheetHelp
     OSL_ENSURE( ( maSheetSrcModel.maRange.aStart.Row() < nRow ) && ( nRow <= 
maSheetSrcModel.maRange.aEnd.Row() ), "PivotCache::importPCRecord - invalid row 
index" );
     SCCOL nCol = maSheetSrcModel.maRange.aStart.Col();
     SCCOL nMaxCol = getAddressConverter().getMaxApiAddress().Col();
-    for( PivotCacheFieldVector::const_iterator aIt = maDatabaseFields.begin(), 
aEnd = maDatabaseFields.end(); !rStrm.isEof() && (aIt != aEnd) && (nCol <= 
nMaxCol); ++aIt, ++nCol )
-        (*aIt)->importPCRecordItem( rStrm, rSheetHelper, nCol, nRow );
+    for( const auto& rxDatabaseField : maDatabaseFields )
+    {
+        if( rStrm.isEof() || (nCol > nMaxCol) )
+            break;
+        rxDatabaseField->importPCRecordItem( rStrm, rSheetHelper, nCol, nRow );
+        ++nCol;
+    }
 }
 
 // private --------------------------------------------------------------------
diff --git a/sc/source/filter/oox/pivottablebuffer.cxx 
b/sc/source/filter/oox/pivottablebuffer.cxx
index 569a112d1074..b52ca269f0c9 100644
--- a/sc/source/filter/oox/pivottablebuffer.cxx
+++ b/sc/source/filter/oox/pivottablebuffer.cxx
@@ -413,8 +413,8 @@ void PivotTableField::finalizeImport( const Reference< 
XDataPilotDescriptor >& r
                 ::std::vector< OUString > aItems;
                 pCacheField->getCacheItemNames( aItems );
                 PivotCacheGroupItemVector aItemNames;
-                for( ::std::vector< OUString >::iterator aIt = aItems.begin(), 
aEnd = aItems.end(); aIt != aEnd; ++aIt )
-                    aItemNames.emplace_back( *aIt );
+                for( const auto& rItem : aItems )
+                    aItemNames.emplace_back( rItem );
                 // create all nested group fields (if any)
                 mrPivotTable.finalizeParentGroupingImport( xDPField, 
*pCacheField, aItemNames );
             }
@@ -450,10 +450,10 @@ void PivotTableField::finalizeParentGroupingImport( const 
Reference< XDataPilotF
             // data field can have user defined groupname captions, apply them
             // if they do
             IdCaptionPairList captionList;
-            for( ItemModelVector::iterator aIt = maItems.begin(), aEnd = 
maItems.end(); aIt != aEnd; ++aIt )
+            for( const auto& rItem : maItems )
             {
-                if ( aIt->mnType == XML_data  && aIt->msCaption.getLength() )
-                    captionList.emplace_back( aIt->mnCacheItem, aIt->msCaption 
);
+                if ( rItem.mnType == XML_data  && rItem.msCaption.getLength() )
+                    captionList.emplace_back( rItem.mnCacheItem, 
rItem.msCaption );
             }
             if ( !captionList.empty() )
                 pCacheField->applyItemCaptions( captionList );
@@ -528,13 +528,16 @@ void PivotTableField::convertPageField( const 
PTPageFieldModel& rPageField )
             OSL_ENSURE( rPageField.mnItem == BIFF12_PTPAGEFIELD_MULTIITEMS, 
"PivotTableField::convertPageField - unexpected cache item index" );
             // try to find a single visible item
             bool bHasMultiItems = false;
-            for( ItemModelVector::iterator aIt = maItems.begin(), aEnd = 
maItems.end(); (aIt != aEnd) && !bHasMultiItems; ++aIt )
+            for( const auto& rItem : maItems )
             {
-                if( (aIt->mnType == XML_data) && !aIt->mbHidden )
+                if( (rItem.mnType == XML_data) && !rItem.mbHidden )
                 {
                     bHasMultiItems = nCacheItem >= 0;
-                    nCacheItem = bHasMultiItems ? -1 : aIt->mnCacheItem;
+                    nCacheItem = bHasMultiItems ? -1 : rItem.mnCacheItem;
                 }
+
+                if( bHasMultiItems )
+                    break;
             }
         }
         else
@@ -743,20 +746,20 @@ Reference< XDataPilotField > 
PivotTableField::convertRowColPageField( sal_Int32
 
                 try
                 {
-                    for( ItemModelVector::iterator aIt = maItems.begin(), aEnd 
= maItems.end(); aIt != aEnd; ++aIt )
+                    for( const auto& rItem : maItems )
                     {
-                        if (aIt->mnType != XML_data)
+                        if (rItem.mnType != XML_data)
                             continue;
 
-                        const PivotCacheItem* pSharedItem = 
pCacheField->getCacheItem(aIt->mnCacheItem);
+                        const PivotCacheItem* pSharedItem = 
pCacheField->getCacheItem(rItem.mnCacheItem);
                         if (!pSharedItem)
                             continue;
 
                         try
                         {
                             ScDPSaveMember* pMem = 
pDim->GetMemberByName(pSharedItem->getFormattedName(*pDim, pDPObj, 
DateTime(getWorkbookSettings().getNullDate())));
-                            pMem->SetShowDetails(aIt->mbShowDetails);
-                            pMem->SetIsVisible(!aIt->mbHidden);
+                            pMem->SetShowDetails(rItem.mbShowDetails);
+                            pMem->SetIsVisible(!rItem.mbHidden);
                         }
                         catch( Exception& )
                         {
@@ -1230,40 +1233,44 @@ void PivotTable::finalizeImport()
                 finalizeFieldsImport();
 
                 // all row fields
-                for( IndexVector::iterator aIt = maRowFields.begin(), aEnd = 
maRowFields.end(); aIt != aEnd; ++aIt )
-                    if( PivotTableField* pField = getTableField( *aIt ) )
+                for( const auto& rRowField : maRowFields )
+                    if( PivotTableField* pField = getTableField( rRowField ) )
                         pField->convertRowField();
 
                 // all column fields
-                for( IndexVector::iterator aIt = maColFields.begin(), aEnd = 
maColFields.end(); aIt != aEnd; ++aIt )
-                    if( PivotTableField* pField = getTableField( *aIt ) )
+                for( const auto& rColField : maColFields )
+                    if( PivotTableField* pField = getTableField( rColField ) )
                         pField->convertColField();
 
                 // all page fields
-                for( PageFieldVector::iterator aIt = maPageFields.begin(), 
aEnd = maPageFields.end(); aIt != aEnd; ++aIt )
-                    if( PivotTableField* pField = getTableField( aIt->mnField 
) )
-                        pField->convertPageField( *aIt );
+                for( const auto& rPageField : maPageFields )
+                    if( PivotTableField* pField = getTableField( 
rPageField.mnField ) )
+                        pField->convertPageField( rPageField );
 
                 // all hidden fields
                 ::std::set< sal_Int32 > aVisFields;
                 aVisFields.insert( maRowFields.begin(), maRowFields.end() );
                 aVisFields.insert( maColFields.begin(), maColFields.end() );
-                for( PageFieldVector::iterator aIt = maPageFields.begin(), 
aEnd = maPageFields.end(); aIt != aEnd; ++aIt )
-                    aVisFields.insert( aIt->mnField );
-                for( PivotTableFieldVector::iterator aBeg = maFields.begin(), 
aIt = aBeg, aEnd = maFields.end(); aIt != aEnd; ++aIt )
-                    if( aVisFields.count( static_cast< sal_Int32 >( aIt - aBeg 
) ) == 0 )
-                        (*aIt)->convertHiddenField();
+                for( const auto& rPageField : maPageFields )
+                    aVisFields.insert( rPageField.mnField );
+                sal_Int32 nIndex = 0;
+                for( auto& rxField : maFields )
+                {
+                    if( aVisFields.count( nIndex ) == 0 )
+                        rxField->convertHiddenField();
+                    ++nIndex;
+                }
 
                 // all data fields
-                for( DataFieldVector::iterator aIt = maDataFields.begin(), 
aEnd = maDataFields.end(); aIt != aEnd; ++aIt )
+                for( auto& rDataField : maDataFields )
                 {
-                    if( const PivotCacheField* pCacheField = getCacheField( 
aIt->mnField  ) )
+                    if( const PivotCacheField* pCacheField = getCacheField( 
rDataField.mnField  ) )
                     {
                         if ( pCacheField-> getGroupBaseField() != -1 )
-                            aIt->mnField = pCacheField-> getGroupBaseField();
+                            rDataField.mnField = pCacheField-> 
getGroupBaseField();
                     }
-                    if( PivotTableField* pField = getTableField( aIt->mnField 
) )
-                        pField->convertDataField( *aIt );
+                    if( PivotTableField* pField = getTableField( 
rDataField.mnField ) )
+                        pField->convertDataField( rDataField );
                 }
 
                 // filters
diff --git a/sc/source/filter/oox/querytablebuffer.cxx 
b/sc/source/filter/oox/querytablebuffer.cxx
index 2c50931e35d1..437dd4e263ad 100644
--- a/sc/source/filter/oox/querytablebuffer.cxx
+++ b/sc/source/filter/oox/querytablebuffer.cxx
@@ -89,12 +89,12 @@ OUString lclBuildWebQueryTables( const 
WebPrModel::TablesVector& rTables )
         return OUString( "HTML_tables" );
 
     OUStringBuffer aTables;
-    for( WebPrModel::TablesVector::const_iterator aIt = rTables.begin(), aEnd 
= rTables.end(); aIt != aEnd; ++aIt )
+    for( const auto& rTable : rTables )
     {
-        if( aIt->has< OUString >() )
-            lclAppendWebQueryTableName( aTables, aIt->get< OUString >() );
-        else if( aIt->has< sal_Int32 >() )
-            lclAppendWebQueryTableIndex( aTables, aIt->get< sal_Int32 >() );
+        if( rTable.has< OUString >() )
+            lclAppendWebQueryTableName( aTables, rTable.get< OUString >() );
+        else if( rTable.has< sal_Int32 >() )
+            lclAppendWebQueryTableIndex( aTables, rTable.get< sal_Int32 >() );
     }
     return aTables.makeStringAndClear();
 }
diff --git a/sc/source/filter/oox/revisionfragment.cxx 
b/sc/source/filter/oox/revisionfragment.cxx
index 58d27a43f758..afbbfa1af5c2 100644
--- a/sc/source/filter/oox/revisionfragment.cxx
+++ b/sc/source/filter/oox/revisionfragment.cxx
@@ -252,15 +252,13 @@ void RevisionHeadersFragment::finalizeImport()
     pCT->SetUseFixDateTime(true);
 
     const oox::core::Relations& rRels = getRelations();
-    RevDataType::const_iterator it = mpImpl->maRevData.begin(), itEnd = 
mpImpl->maRevData.end();
-    for (; it != itEnd; ++it)
+    for (const auto& [rRelId, rData] : mpImpl->maRevData)
     {
-        OUString aPath = rRels.getFragmentPathFromRelId(it->first);
+        OUString aPath = rRels.getFragmentPathFromRelId(rRelId);
         if (aPath.isEmpty())
             continue;
 
         // Parse each revision log fragment.
-        const RevisionMetadata& rData = it->second;
         pCT->SetUser(rData.maUserName);
         pCT->SetFixDateTimeLocal(rData.maDateTime);
         std::unique_ptr<oox::core::FastParser> 
xParser(oox::core::XmlFilterBase::createParser());
diff --git a/sc/source/filter/oox/richstring.cxx 
b/sc/source/filter/oox/richstring.cxx
index 8f702d58a8b3..94cd78b474e1 100644
--- a/sc/source/filter/oox/richstring.cxx
+++ b/sc/source/filter/oox/richstring.cxx
@@ -385,9 +385,9 @@ void RichString::convert( const Reference< XText >& rxText 
) const
     }
 
     bool bReplaceOld = true;
-    for( PortionVector::const_iterator aIt = maTextPortions.begin(), aEnd = 
maTextPortions.end(); aIt != aEnd; ++aIt )
+    for( const auto& rxTextPortion : maTextPortions )
     {
-        (*aIt)->convert( rxText, bReplaceOld );
+        rxTextPortion->convert( rxText, bReplaceOld );
         bReplaceOld = false;    // do not replace first portion text with 
following portions
     }
 }
@@ -397,17 +397,17 @@ std::unique_ptr<EditTextObject> RichString::convert( 
ScEditEngineDefaulter& rEE,
     ESelection aSelection;
 
     OUStringBuffer sString;
-    for( PortionVector::const_iterator aIt = maTextPortions.begin(), aEnd = 
maTextPortions.end(); aIt != aEnd; ++aIt )
-        sString.append((*aIt)->getText());
+    for( const auto& rxTextPortion : maTextPortions )
+        sString.append(rxTextPortion->getText());
 
     // fdo#84370 - diving into editeng is not thread safe.
     SolarMutexGuard aGuard;
 
     rEE.SetText( sString.makeStringAndClear() );
 
-    for( PortionVector::const_iterator aIt = maTextPortions.begin(), aEnd = 
maTextPortions.end(); aIt != aEnd; ++aIt )
+    for( const auto& rxTextPortion : maTextPortions )
     {
-        (*aIt)->convert( rEE, aSelection, pFirstPortionFont );
+        rxTextPortion->convert( rEE, aSelection, pFirstPortionFont );
         pFirstPortionFont = nullptr;
     }
 
diff --git a/sc/source/filter/oox/scenariobuffer.cxx 
b/sc/source/filter/oox/scenariobuffer.cxx
index cb8a4ab1bd8d..1ea69343d657 100644
--- a/sc/source/filter/oox/scenariobuffer.cxx
+++ b/sc/source/filter/oox/scenariobuffer.cxx
@@ -106,9 +106,9 @@ void Scenario::finalizeImport()
 {
     AddressConverter& rAddrConv = getAddressConverter();
     ScRangeList aRanges;
-    for( ScenarioCellVector::iterator aIt = maCells.begin(), aEnd = 
maCells.end(); aIt != aEnd; ++aIt )
-        if( !aIt->mbDeleted && rAddrConv.checkCellAddress( aIt->maPos, true ) )
-            aRanges.push_back( ScRange(aIt->maPos, aIt->maPos) );
+    for( const auto& rCell : maCells )
+        if( !rCell.mbDeleted && rAddrConv.checkCellAddress( rCell.maPos, true 
) )
+            aRanges.push_back( ScRange(rCell.maPos, rCell.maPos) );
 
     if( !aRanges.empty() && !maModel.maName.isEmpty() ) try
     {
@@ -124,13 +124,13 @@ void Scenario::finalizeImport()
 
         // write scenario cell values
         Reference< XSpreadsheet > xSheet( getSheetFromDoc( aScenName ), 
UNO_SET_THROW );
-        for( ScenarioCellVector::iterator aIt = maCells.begin(), aEnd = 
maCells.end(); aIt != aEnd; ++aIt )
+        for( const auto& rCell : maCells )
         {
-            if( !aIt->mbDeleted ) try
+            if( !rCell.mbDeleted ) try
             {
                 // use XCell::setFormula to auto-detect values and strings
-                Reference< XCell > xCell( xSheet->getCellByPosition( 
aIt->maPos.Col(), aIt->maPos.Row() ), UNO_SET_THROW );
-                xCell->setFormula( aIt->maValue );
+                Reference< XCell > xCell( xSheet->getCellByPosition( 
rCell.maPos.Col(), rCell.maPos.Row() ), UNO_SET_THROW );
+                xCell->setFormula( rCell.maValue );
             }
             catch( Exception& )
             {
diff --git a/sc/source/filter/oox/sheetdatabuffer.cxx 
b/sc/source/filter/oox/sheetdatabuffer.cxx
index 9a0240ec631d..7e7077a1b894 100644
--- a/sc/source/filter/oox/sheetdatabuffer.cxx
+++ b/sc/source/filter/oox/sheetdatabuffer.cxx
@@ -326,20 +326,20 @@ static void addIfNotInMyMap( const StylesBuffer& rStyles, 
std::map< FormatKeyPai
     Xf* pXf1 = rStyles.getCellXf( nXfId ).get();
     if ( pXf1 )
     {
-        for ( std::map< FormatKeyPair, ScRangeList >::iterator it = 
rMap.begin(), it_end = rMap.end(); it != it_end; ++it )
+        auto it = std::find_if(rMap.begin(), rMap.end(),
+            [&nFormatId, &rStyles, &pXf1](const std::pair<FormatKeyPair, 
ScRangeList>& rEntry) {
+                if (rEntry.first.second != nFormatId)
+                    return false;
+                Xf* pXf2 = rStyles.getCellXf( rEntry.first.first ).get();
+                return *pXf1 == *pXf2;
+            });
+        if (it != rMap.end()) // already exists
         {
-            if ( it->first.second == nFormatId )
-            {
-                Xf* pXf2 = rStyles.getCellXf( it->first.first ).get();
-                if ( *pXf1 == *pXf2 ) // already exists
-                {
-                    // add ranges from the rangelist to the existing rangelist 
for the
-                    // matching style ( should we check if they overlap ? )
-                    for (size_t i = 0, nSize = rRangeList.size(); i < nSize; 
++i)
-                        it->second.push_back(rRangeList[i]);
-                    return;
-                }
-            }
+            // add ranges from the rangelist to the existing rangelist for the
+            // matching style ( should we check if they overlap ? )
+            for (size_t i = 0, nSize = rRangeList.size(); i < nSize; ++i)
+                it->second.push_back(rRangeList[i]);
+            return;
         }
         rMap[ FormatKeyPair( nXfId, nFormatId ) ] = rRangeList;
     }
@@ -403,50 +403,48 @@ void SheetDataBuffer::addColXfStyle( sal_Int32 nXfId, 
sal_Int32 nFormatId, const
 void SheetDataBuffer::finalizeImport()
 {
     // create all array formulas
-    for( ArrayFormulaVector::iterator aIt = maArrayFormulas.begin(), aEnd = 
maArrayFormulas.end(); aIt != aEnd; ++aIt )
-        finalizeArrayFormula( aIt->first, aIt->second );
+    for( const auto& [rRange, rTokens] : maArrayFormulas )
+        finalizeArrayFormula( rRange, rTokens );
 
     // create all table operations
-    for( TableOperationVector::iterator aIt = maTableOperations.begin(), aEnd 
= maTableOperations.end(); aIt != aEnd; ++aIt )
-        finalizeTableOperation( aIt->first, aIt->second );
+    for( const auto& [rRange, rModel] : maTableOperations )
+        finalizeTableOperation( rRange, rModel );
 
     // write default formatting of remaining row range
     maXfIdRowRangeList[ maXfIdRowRange.mnXfId ].push_back( 
maXfIdRowRange.maRowRange );
 
     std::map< FormatKeyPair, ScRangeList > rangeStyleListMap;
-    for( XfIdRangeListMap::const_iterator aIt = maXfIdRangeLists.begin(), aEnd 
= maXfIdRangeLists.end(); aIt != aEnd; ++aIt )
+    for( const auto& [rFormatKeyPair, rRangeList] : maXfIdRangeLists )
     {
-        addIfNotInMyMap( getStyles(), rangeStyleListMap, aIt->first.first, 
aIt->first.second, aIt->second );
+        addIfNotInMyMap( getStyles(), rangeStyleListMap, rFormatKeyPair.first, 
rFormatKeyPair.second, rRangeList );
     }
     // gather all ranges that have the same style and apply them in bulk
-    for (  std::map< FormatKeyPair, ScRangeList >::iterator it = 
rangeStyleListMap.begin(), it_end = rangeStyleListMap.end(); it != it_end; ++it 
)
+    for ( const auto& [rFormatKeyPair, rRanges] : rangeStyleListMap )
     {
-        const ScRangeList& rRanges( it->second );
         for (size_t i = 0, nSize = rRanges.size(); i < nSize; ++i)
-            addColXfStyle( it->first.first, it->first.second, rRanges[i]);
+            addColXfStyle( rFormatKeyPair.first, rFormatKeyPair.second, 
rRanges[i]);
     }
 
-    for ( std::map< sal_Int32, std::vector< ValueRange > >::iterator it = 
maXfIdRowRangeList.begin(), it_end =  maXfIdRowRangeList.end(); it != it_end; 
++it )
+    for ( const auto& [rXfId, rRowRangeList] : maXfIdRowRangeList )
     {
-        if ( it->first == -1 ) // it's a dud skip it
+        if ( rXfId == -1 ) // it's a dud skip it
             continue;
         AddressConverter& rAddrConv = getAddressConverter();
         // get all row ranges for id
-        for ( std::vector< ValueRange >::iterator rangeIter = 
it->second.begin(), rangeIter_end = it->second.end(); rangeIter != 
rangeIter_end; ++rangeIter )
+        for ( const auto& rRange : rRowRangeList )
         {
-            ScRange aRange( 0, rangeIter->mnFirst, getSheetIndex(),
-                            rAddrConv.getMaxApiAddress().Col(), 
rangeIter->mnLast, getSheetIndex() );
+            ScRange aRange( 0, rRange.mnFirst, getSheetIndex(),
+                            rAddrConv.getMaxApiAddress().Col(), rRange.mnLast, 
getSheetIndex() );
 
-            addColXfStyle( it->first, -1, aRange, true );
+            addColXfStyle( rXfId, -1, aRange, true );
         }
     }
 
     ScDocumentImport& rDoc = getDocImport();
     StylesBuffer& rStyles = getStyles();
-    for ( ColStyles::iterator col = maStylesPerColumn.begin(), col_end = 
maStylesPerColumn.end(); col != col_end; ++col )
+    for ( const auto& [rCol, rRowStyles] : maStylesPerColumn )
     {
-        RowStyles& rRowStyles = col->second;
-        SCCOL nScCol = static_cast< SCCOL >( col->first );
+        SCCOL nScCol = static_cast< SCCOL >( rCol );
 
         // tdf#91567 Get pattern from the first row without AutoFilter
         const ScPatternAttr* pDefPattern = nullptr;
@@ -468,12 +466,12 @@ void SheetDataBuffer::finalizeImport()
             pDefPattern = rDoc.getDoc().GetDefPattern();
 
         Xf::AttrList aAttrs(pDefPattern);
-        for ( RowStyles::iterator rRows = rRowStyles.begin(), rRows_end = 
rRowStyles.end(); rRows != rRows_end; ++rRows )
+        for ( const auto& rRowStyle : rRowStyles )
         {
-             Xf* pXf = rStyles.getCellXf( rRows->mnNumFmt.first ).get();
+             Xf* pXf = rStyles.getCellXf( rRowStyle.mnNumFmt.first ).get();
 
              if ( pXf )
-                 pXf->applyPatternToAttrList( aAttrs,  rRows->mnStartRow,  
rRows->mnEndRow,  rRows->mnNumFmt.second );
+                 pXf->applyPatternToAttrList( aAttrs,  rRowStyle.mnStartRow,  
rRowStyle.mnEndRow,  rRowStyle.mnNumFmt.second );
         }
         if (aAttrs.maAttrs.empty() || aAttrs.maAttrs.back().nEndRow != MAXROW)
         {
@@ -495,10 +493,10 @@ void SheetDataBuffer::finalizeImport()
     }
 
     // merge all cached merged ranges and update right/bottom cell borders
-    for( MergedRangeVector::iterator aIt = maMergedRanges.begin(), aEnd = 
maMergedRanges.end(); aIt != aEnd; ++aIt )
-        applyCellMerging( aIt->maRange );
-    for( MergedRangeVector::iterator aIt = maCenterFillRanges.begin(), aEnd = 
maCenterFillRanges.end(); aIt != aEnd; ++aIt )
-        applyCellMerging( aIt->maRange );
+    for( const auto& rMergedRange : maMergedRanges )
+        applyCellMerging( rMergedRange.maRange );
+    for( const auto& rCenterFillRange : maCenterFillRanges )
+        applyCellMerging( rCenterFillRange.maRange );
 }
 
 // private --------------------------------------------------------------------
diff --git a/sc/source/filter/oox/stylesbuffer.cxx 
b/sc/source/filter/oox/stylesbuffer.cxx
index eac49000ae18..ffc48e14532a 100644
--- a/sc/source/filter/oox/stylesbuffer.cxx
+++ b/sc/source/filter/oox/stylesbuffer.cxx
@@ -2571,9 +2571,9 @@ void CellStyleBuffer::finalizeImport()
 
     /*  Calculate names of built-in styles. Store styles with reserved names
         in the aConflictNameStyles list. */
-    for( CellStyleVector::iterator aIt = maBuiltinStyles.begin(), aEnd = 
maBuiltinStyles.end(); aIt != aEnd; ++aIt )
+    for( const auto& rxStyle : maBuiltinStyles )
     {
-        const CellStyleModel& rModel = (*aIt)->getModel();
+        const CellStyleModel& rModel = rxStyle->getModel();
         if (rModel.isDefaultStyle())
             continue;
 
@@ -2581,31 +2581,31 @@ void CellStyleBuffer::finalizeImport()
         /*  If a builtin style entry already exists,
             we just stick with the last definition and ignore
             the preceding ones. */
-        aCellStyles[ aStyleName ] = *aIt;
+        aCellStyles[ aStyleName ] = rxStyle;
     }
 
     /*  Calculate names of user defined styles. Store styles with reserved
         names in the aConflictNameStyles list. */
-    for( CellStyleVector::iterator aIt = maUserStyles.begin(), aEnd = 
maUserStyles.end(); aIt != aEnd; ++aIt )
+    for( const auto& rxStyle : maUserStyles )
     {
-        const CellStyleModel& rModel = (*aIt)->getModel();
+        const CellStyleModel& rModel = rxStyle->getModel();
         OUString aStyleName = lclCreateStyleName( rModel );
         // #i1624# #i1768# ignore unnamed user styles
         if( aStyleName.getLength() > 0 )
         {
             if( aCellStyles.find( aStyleName ) != aCellStyles.end() )
-                aConflictNameStyles.push_back( *aIt );
+                aConflictNameStyles.push_back( rxStyle );
             else
-                aCellStyles[ aStyleName ] = *aIt;
+                aCellStyles[ aStyleName ] = rxStyle;
         }
     }
 
     // find unused names for all styles with conflicting names
     // having the index counter outside the loop prevents performance problems 
with opening some pathological documents (tdf#62095)
     sal_Int32 nIndex = 0;
-    for( CellStyleVector::iterator aIt = aConflictNameStyles.begin(), aEnd = 
aConflictNameStyles.end(); aIt != aEnd; ++aIt )
+    for( const auto& rxStyle : aConflictNameStyles )
     {
-        const CellStyleModel& rModel = (*aIt)->getModel();
+        const CellStyleModel& rModel = rxStyle->getModel();
         OUString aStyleName = lclCreateStyleName( rModel );
         OUString aUnusedName;
         do
@@ -2613,7 +2613,7 @@ void CellStyleBuffer::finalizeImport()
             aUnusedName = aStyleName + OUStringLiteral1(' ') + 
OUString::number( ++nIndex );
         }
         while( aCellStyles.find( aUnusedName ) != aCellStyles.end() );
-        aCellStyles[ aUnusedName ] = *aIt;
+        aCellStyles[ aUnusedName ] = rxStyle;
     }
 
     // set final names and create user-defined and modified built-in cell 
styles
diff --git a/sc/source/filter/oox/tablebuffer.cxx 
b/sc/source/filter/oox/tablebuffer.cxx
index 0d50a5502332..8c8526ce9a57 100644
--- a/sc/source/filter/oox/tablebuffer.cxx
+++ b/sc/source/filter/oox/tablebuffer.cxx
@@ -165,8 +165,8 @@ Table& TableBuffer::createTable()
 void TableBuffer::finalizeImport()
 {
     // map all tables by identifier and display name
-    for( TableVector::iterator aIt = maTables.begin(), aEnd = maTables.end(); 
aIt != aEnd; ++aIt )
-        insertTableToMaps( *aIt );
+    for( const auto& rxTable : maTables )
+        insertTableToMaps( rxTable );
     // finalize all valid tables
     maIdTables.forEachMem( &Table::finalizeImport );
 }
diff --git a/sc/source/filter/oox/tablecolumnsbuffer.cxx 
b/sc/source/filter/oox/tablecolumnsbuffer.cxx
index bb35f3bd0918..0a90f72236f7 100644
--- a/sc/source/filter/oox/tablecolumnsbuffer.cxx
+++ b/sc/source/filter/oox/tablecolumnsbuffer.cxx
@@ -85,10 +85,10 @@ bool TableColumns::finalizeImport( ScDBData* pDBData )
         /* TODO: use svl::SharedString for names */
         ::std::vector< OUString > aNames( maTableColumnVector.size());
         size_t i = 0;
-        for (TableColumnVector::const_iterator aIt = 
maTableColumnVector.begin(), aEnd = maTableColumnVector.end();
-                aIt != aEnd; ++aIt, ++i)
+        for (const auto& rxTableColumn : maTableColumnVector)
         {
-            aNames[i] = (*aIt)->getName();
+            aNames[i] = rxTableColumn->getName();
+            ++i;
         }
         pDBData->SetTableColumnNames( aNames);
         return true;
diff --git a/sc/source/filter/oox/viewsettings.cxx 
b/sc/source/filter/oox/viewsettings.cxx
index e090a7b8d67a..a01c536fcac9 100644
--- a/sc/source/filter/oox/viewsettings.cxx
+++ b/sc/source/filter/oox/viewsettings.cxx
@@ -551,8 +551,8 @@ void ViewSettings::finalizeImport()
     // view settings for all sheets
     Reference< XNameContainer > xSheetsNC = NamedPropertyValues::create( 
getBaseFilter().getComponentContext() );
     if( !xSheetsNC.is() ) return;
-    for( SheetPropertiesMap::const_iterator aIt = maSheetProps.begin(), aEnd = 
maSheetProps.end(); aIt != aEnd; ++aIt )
-        ContainerHelper::insertByName( xSheetsNC, 
rWorksheets.getCalcSheetName( aIt->first ), aIt->second );
+    for( const auto& [rWorksheet, rObj] : maSheetProps )
+        ContainerHelper::insertByName( xSheetsNC, 
rWorksheets.getCalcSheetName( rWorksheet ), rObj );
 
     // use active sheet to set sheet properties that are document-global in 
Calc
     sal_Int16 nActiveSheet = getActiveCalcSheet();
diff --git a/sc/source/filter/oox/workbookfragment.cxx 
b/sc/source/filter/oox/workbookfragment.cxx
index a00d7bdfbc98..7ef19f7aef47 100644
--- a/sc/source/filter/oox/workbookfragment.cxx
+++ b/sc/source/filter/oox/workbookfragment.cxx
@@ -315,15 +315,14 @@ void importSheetFragments( WorkbookFragment& 
rWorkbookHandler, SheetFragmentVect
 
     sal_Int32 nSheetsLeft = 0;
     ProgressBarTimer aProgressUpdater;
-    SheetFragmentVector::iterator it = rSheets.begin(), itEnd = rSheets.end();
-    for( ; it != itEnd; ++it )
+    for( auto& [rxSheetGlob, rxFragment] : rSheets )
     {
          // getting at the WorksheetGlobals is rather unpleasant
-         IWorksheetProgress *pProgress = 
WorksheetHelper::getWorksheetInterface( it->first );
+         IWorksheetProgress *pProgress = 
WorksheetHelper::getWorksheetInterface( rxSheetGlob );
          pProgress->setCustomRowProgress(
                      aProgressUpdater.wrapProgress(
                              pProgress->getRowProgress() ) );
-         rSharedPool.pushTask( o3tl::make_unique<WorkerThread>( pTag, 
rWorkbookHandler, it->second,
+         rSharedPool.pushTask( o3tl::make_unique<WorkerThread>( pTag, 
rWorkbookHandler, rxFragment,
                                            /* ref */ nSheetsLeft ) );
          nSheetsLeft++;
      }
@@ -484,16 +483,16 @@ void WorkbookFragment::finalizeImport()
 
     recalcFormulaCells();
 
-    for( std::vector<WorksheetHelper*>::iterator aIt = aHelpers.begin(), aEnd 
= aHelpers.end(); aIt != aEnd; ++aIt )
+    for( WorksheetHelper* pHelper : aHelpers )
     {
-        (*aIt)->finalizeDrawingImport();
+        pHelper->finalizeDrawingImport();
     }
 
-    for( SheetFragmentVector::iterator aIt = aSheetFragments.begin(), aEnd = 
aSheetFragments.end(); aIt != aEnd; ++aIt )
+    for( auto& [rxSheetGlob, rxFragment] : aSheetFragments )
     {
         // delete fragment object and WorkbookGlobals object, will free all 
allocated sheet buffers
-        aIt->second.clear();
-        aIt->first.reset();
+        rxFragment.clear();
+        rxSheetGlob.reset();
     }
 
     OUString aRevHeadersPath = 
getFragmentPathFromFirstType(CREATE_OFFICEDOC_RELATION_TYPE("revisionHeaders"));
diff --git a/sc/source/filter/oox/worksheetfragment.cxx 
b/sc/source/filter/oox/worksheetfragment.cxx
index d542679b532e..775e9ad9a3a7 100644
--- a/sc/source/filter/oox/worksheetfragment.cxx
+++ b/sc/source/filter/oox/worksheetfragment.cxx
@@ -341,8 +341,8 @@ WorksheetFragment::WorksheetFragment( const 
WorksheetHelper& rHelper, const OUSt
 {
     // import data tables related to this worksheet
     RelationsRef xTableRels = 
getRelations().getRelationsFromTypeFromOfficeDoc( "table" );
-    for( ::std::map< OUString, Relation >::const_iterator aIt = 
xTableRels->begin(), aEnd = xTableRels->end(); aIt != aEnd; ++aIt )
-        importOoxFragment( new TableFragment( *this, 
getFragmentPathFromRelation( aIt->second ) ) );
+    for( const auto& rEntry : *xTableRels )
+        importOoxFragment( new TableFragment( *this, 
getFragmentPathFromRelation( rEntry.second ) ) );
 
     // import comments related to this worksheet
     OUString aCommentsFragmentPath = 
getFragmentPathFromFirstTypeFromOfficeDoc( "comments" );
@@ -620,13 +620,13 @@ void WorksheetFragment::initializeImport()
 
     // import query table fragments related to this worksheet
     RelationsRef xQueryRels = 
getRelations().getRelationsFromTypeFromOfficeDoc( "queryTable" );
-    for( ::std::map< OUString, Relation >::const_iterator aIt = 
xQueryRels->begin(), aEnd = xQueryRels->end(); aIt != aEnd; ++aIt )
-        importOoxFragment( new QueryTableFragment( *this, 
getFragmentPathFromRelation( aIt->second ) ) );
+    for( const auto& rEntry : *xQueryRels )
+        importOoxFragment( new QueryTableFragment( *this, 
getFragmentPathFromRelation( rEntry.second ) ) );
 
     // import pivot table fragments related to this worksheet
     RelationsRef xPivotRels = 
getRelations().getRelationsFromTypeFromOfficeDoc( "pivotTable" );
-    for( ::std::map< OUString, Relation >::const_iterator aIt = 
xPivotRels->begin(), aEnd = xPivotRels->end(); aIt != aEnd; ++aIt )
-        importOoxFragment( new PivotTableFragment( *this, 
getFragmentPathFromRelation( aIt->second ) ) );
+    for( const auto& rEntry : *xPivotRels )
+        importOoxFragment( new PivotTableFragment( *this, 
getFragmentPathFromRelation( rEntry.second ) ) );
 }
 
 void WorksheetFragment::finalizeImport()
diff --git a/sc/source/filter/orcus/xmlcontext.cxx 
b/sc/source/filter/orcus/xmlcontext.cxx
index c9fa56f516a4..4cdd3ce48412 100644
--- a/sc/source/filter/orcus/xmlcontext.cxx
+++ b/sc/source/filter/orcus/xmlcontext.cxx
@@ -98,11 +98,8 @@ void populateTree(
 
     // Insert attributes.
     rWalker.get_attributes(aNames);
-    orcus::xml_structure_tree::entity_names_type::const_iterator it = 
aNames.begin();
-    orcus::xml_structure_tree::entity_names_type::const_iterator itEnd = 
aNames.end();
-    for (; it != itEnd; ++it)
+    for (const orcus::xml_structure_tree::entity_name& rAttrName : aNames)
     {
-        const orcus::xml_structure_tree::entity_name& rAttrName = *it;
         SvTreeListEntry* pAttr = rTreeCtrl.InsertEntry(toString(rAttrName, 
rWalker), pEntry);
 
         if (!pAttr)
@@ -123,10 +120,10 @@ void populateTree(
     rEntryData.mbLeafNode = aNames.empty();
 
     // Insert child elements recursively.
-    for (it = aNames.begin(), itEnd = aNames.end(); it != itEnd; ++it)
+    for (const auto& rName : aNames)
     {
-        orcus::xml_structure_tree::element aElem = rWalker.descend(*it);
-        populateTree(rTreeCtrl, rWalker, *it, aElem.repeat, pEntry, rParam);
+        orcus::xml_structure_tree::element aElem = rWalker.descend(rName);
+        populateTree(rTreeCtrl, rWalker, rName, aElem.repeat, pEntry, rParam);
         rWalker.ascend();
     }
 }
@@ -256,39 +253,29 @@ void ScOrcusXMLContextImpl::importXML(const 
ScOrcusImportXMLParam& rParam)
         // Define all used namespaces.
         std::for_each(rParam.maNamespaces.begin(), rParam.maNamespaces.end(), 
SetNamespaceAlias(filter, maNsRepo));
 
+        // Set cell links.
+        for (const ScOrcusImportXMLParam::CellLink& rLink : rParam.maCellLinks)
         {
-            // Set cell links.
-            ScOrcusImportXMLParam::CellLinksType::const_iterator it = 
rParam.maCellLinks.begin();
-            ScOrcusImportXMLParam::CellLinksType::const_iterator itEnd = 
rParam.maCellLinks.end();
-            for (; it != itEnd; ++it)
-            {
-                const ScOrcusImportXMLParam::CellLink& rLink = *it;
-                OUString aTabName;
-                mrDoc.GetName(rLink.maPos.Tab(), aTabName);
-                filter.set_cell_link(
-                    rLink.maPath.getStr(),
-                    OUStringToOString(aTabName, 
RTL_TEXTENCODING_UTF8).getStr(),
-                    rLink.maPos.Row(), rLink.maPos.Col());
-            }
+            OUString aTabName;
+            mrDoc.GetName(rLink.maPos.Tab(), aTabName);
+            filter.set_cell_link(
+                rLink.maPath.getStr(),
+                OUStringToOString(aTabName, RTL_TEXTENCODING_UTF8).getStr(),
+                rLink.maPos.Row(), rLink.maPos.Col());
         }
 
+        // Set range links.
+        for (const ScOrcusImportXMLParam::RangeLink& rLink : 
rParam.maRangeLinks)
         {
-            // Set range links.
-            ScOrcusImportXMLParam::RangeLinksType::const_iterator it = 
rParam.maRangeLinks.begin();
-            ScOrcusImportXMLParam::RangeLinksType::const_iterator itEnd = 
rParam.maRangeLinks.end();
-            for (; it != itEnd; ++it)
-            {
-                const ScOrcusImportXMLParam::RangeLink& rLink = *it;
-                OUString aTabName;
-                mrDoc.GetName(rLink.maPos.Tab(), aTabName);
-                filter.start_range(
-                    OUStringToOString(aTabName, 
RTL_TEXTENCODING_UTF8).getStr(),
-                    rLink.maPos.Row(), rLink.maPos.Col());
-
-                std::for_each(rLink.maFieldPaths.begin(), 
rLink.maFieldPaths.end(), InsertFieldPath(filter));
-
-                filter.commit_range();
-            }
+            OUString aTabName;
+            mrDoc.GetName(rLink.maPos.Tab(), aTabName);
+            filter.start_range(
+                OUStringToOString(aTabName, RTL_TEXTENCODING_UTF8).getStr(),
+                rLink.maPos.Row(), rLink.maPos.Col());
+
+            std::for_each(rLink.maFieldPaths.begin(), 
rLink.maFieldPaths.end(), InsertFieldPath(filter));
+
+            filter.commit_range();
         }
 
         std::string content = orcus::load_file_content(path);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to