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

Noel Grandin noel at peralex.com
Sat May 7 12:24:57 UTC 2016


 sc/source/core/data/bcaslot.cxx                    |    6 -
 sc/source/core/data/colorscale.cxx                 |   10 +-
 sc/source/core/data/documen3.cxx                   |    3 
 sc/source/core/data/documen5.cxx                   |    4 
 sc/source/core/data/documen8.cxx                   |    8 -
 sc/source/core/data/document.cxx                   |   18 +--
 sc/source/core/data/document10.cxx                 |    3 
 sc/source/core/data/funcdesc.cxx                   |    8 -
 sc/source/core/data/table2.cxx                     |    8 -
 sc/source/core/data/table4.cxx                     |    4 
 sc/source/core/opencl/formulagroupcl.cxx           |   20 ++--
 sc/source/core/opencl/op_logical.cxx               |   16 +--
 sc/source/core/opencl/op_math.cxx                  |   28 ++---
 sc/source/core/opencl/op_statistical.cxx           |   25 ++---
 sc/source/core/tool/callform.cxx                   |    4 
 sc/source/core/tool/compiler.cxx                   |    7 -
 sc/source/core/tool/interpr1.cxx                   |    4 
 sc/source/core/tool/interpr2.cxx                   |    9 -
 sc/source/core/tool/interpr3.cxx                   |   16 +--
 sc/source/core/tool/parclass.cxx                   |    8 -
 sc/source/core/tool/rangelst.cxx                   |   13 +-
 sc/source/filter/excel/excform.cxx                 |    4 
 sc/source/filter/excel/xepivot.cxx                 |    4 
 sc/source/filter/excel/xepivotxml.cxx              |   13 +-
 sc/source/filter/excel/xestyle.cxx                 |    4 
 sc/source/filter/excel/xetable.cxx                 |    4 
 sc/source/filter/excel/xiescher.cxx                |    7 -
 sc/source/filter/html/htmlpars.cxx                 |   35 ++-----
 sc/source/filter/lotus/lotattr.cxx                 |    4 
 sc/source/filter/lotus/tool.cxx                    |    8 -
 sc/source/filter/oox/condformatbuffer.cxx          |    8 -
 sc/source/filter/oox/formulabuffer.cxx             |    6 -
 sc/source/filter/oox/workbookfragment.cxx          |    4 
 sc/source/filter/rtf/eeimpars.cxx                  |   20 ++--
 sc/source/filter/rtf/rtfparse.cxx                  |    4 
 sc/source/filter/xml/xmlexprt.cxx                  |    4 
 sc/source/filter/xml/xmlfonte.cxx                  |    3 
 sc/source/filter/xml/xmlimprt.cxx                  |    4 
 sc/source/ui/dbgui/dpgroupdlg.cxx                  |    4 
 sc/source/ui/docshell/datastream.cxx               |    3 
 sc/source/ui/docshell/docfunc.cxx                  |    6 -
 sc/source/ui/docshell/documentlinkmgr.cxx          |   24 ++--
 sc/source/ui/docshell/externalrefmgr.cxx           |    3 
 sc/source/ui/miscdlgs/optsolver.cxx                |    4 
 sc/source/ui/pagedlg/areasdlg.cxx                  |    6 -
 sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx |    4 
 sc/source/ui/undo/undocell.cxx                     |   25 ++---
 sc/source/ui/unoobj/cellsuno.cxx                   |   14 +-
 sc/source/ui/unoobj/chart2uno.cxx                  |    4 
 sc/source/ui/unoobj/condformatuno.cxx              |  102 ++++++++++-----------
 sc/source/ui/unoobj/dapiuno.cxx                    |    4 
 sc/source/ui/unoobj/datauno.cxx                    |    8 -
 sc/source/ui/unoobj/dispuno.cxx                    |    8 -
 sc/source/ui/unoobj/docuno.cxx                     |    6 -
 sc/source/ui/unoobj/linkuno.cxx                    |   12 +-
 sc/source/ui/unoobj/servuno.cxx                    |   14 +-
 sc/source/ui/unoobj/targuno.cxx                    |    4 
 sc/source/ui/view/gridwin.cxx                      |   17 +--
 sc/source/ui/view/tabview.cxx                      |   54 +++++------
 sc/source/ui/view/tabview2.cxx                     |   36 +++----
 sc/source/ui/view/tabview3.cxx                     |   48 ++++-----
 sc/source/ui/view/tabview5.cxx                     |    6 -
 sc/source/ui/view/viewfun2.cxx                     |    4 
 sc/source/ui/view/viewfunc.cxx                     |   18 +--
 64 files changed, 382 insertions(+), 414 deletions(-)

New commits:
commit 9613b493172fe9aa8efd9c9c090f82ca2e89cf21
Author: Noel Grandin <noel at peralex.com>
Date:   Fri May 6 10:14:38 2016 +0200

    clang-tidy modernize-loop-convert in sc
    
    Change-Id: I620028d69b11ea0469efd7b02ac7bbc7edab1066
    Reviewed-on: https://gerrit.libreoffice.org/24690
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Jochen Nitschke <j.nitschke+logerrit at ok.de>

diff --git a/sc/source/core/data/bcaslot.cxx b/sc/source/core/data/bcaslot.cxx
index 5a09764..0e64aa5 100644
--- a/sc/source/core/data/bcaslot.cxx
+++ b/sc/source/core/data/bcaslot.cxx
@@ -680,11 +680,11 @@ inline SCSIZE ScBroadcastAreaSlotMachine::ComputeSlotOffset(
         OSL_FAIL( "Row/Col invalid, using first slot!" );
         return 0;
     }
-    for (size_t i=0; i < aSlotDistribution.size(); ++i)
+    for (ScSlotData & i : aSlotDistribution)
     {
-        if (nRow < aSlotDistribution[i].nStopRow)
+        if (nRow < i.nStopRow)
         {
-            const ScSlotData& rSD = aSlotDistribution[i];
+            const ScSlotData& rSD = i;
             return rSD.nCumulated +
                 (static_cast<SCSIZE>(nRow - rSD.nStartRow)) / rSD.nSlice +
                 static_cast<SCSIZE>(nCol) / BCA_SLOT_COLS * nBcaSlotsRow;
diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx
index 71ffe74..fd5c203 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -1316,11 +1316,11 @@ BitmapEx& ScIconSetFormat::getBitmap(sc::IconSetBitmapMap & rIconSetBitmapMap,
 {
     sal_Int32 nBitmap = -1;
 
-    for(size_t i = 0; i < SAL_N_ELEMENTS(aBitmapMap); ++i)
+    for(const ScIconSetBitmapMap & i : aBitmapMap)
     {
-        if(aBitmapMap[i].eType == eType)
+        if(i.eType == eType)
         {
-            nBitmap = *(aBitmapMap[i].nBitmaps + nIndex);
+            nBitmap = *(i.nBitmaps + nIndex);
             break;
         }
     }
@@ -1341,9 +1341,9 @@ BitmapEx& ScIconSetFormat::getBitmap(sc::IconSetBitmapMap & rIconSetBitmapMap,
 void ScIconSetFormat::EnsureSize()
 {
     ScIconSetType eType = mpFormatData->eIconSetType;
-    for (size_t i = 0; i < SAL_N_ELEMENTS(aIconSetMap); ++i)
+    for (ScIconSetMap & i : aIconSetMap)
     {
-        if (aIconSetMap[i].eType == eType)
+        if (i.eType == eType)
         {
             // size_t nElements = aIconSetMap[i].nElements;
             // TODO: implement
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index 9eac83d..2618eb1 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -1625,9 +1625,8 @@ void ScDocument::GetFormulaEntries( ScTypedCaseStrSet& rStrings )
     ScRangePairList* pLists[2];
     pLists[0] = GetColNameRanges();
     pLists[1] = GetRowNameRanges();
-    for (sal_uInt16 nListNo=0; nListNo<2; nListNo++)
+    for (ScRangePairList* pList : pLists)
     {
-        ScRangePairList* pList = pLists[ nListNo ];
         if (!pList)
             continue;
 
diff --git a/sc/source/core/data/documen5.cxx b/sc/source/core/data/documen5.cxx
index c88a619..66d8dcd 100644
--- a/sc/source/core/data/documen5.cxx
+++ b/sc/source/core/data/documen5.cxx
@@ -261,10 +261,10 @@ void ScDocument::GetChartRanges( const OUString& rChartName, ::std::vector< ScRa
     {
         std::vector< OUString > aRangeStrings;
         ScChartHelper::GetChartRanges( xChartDoc, aRangeStrings );
-        for( size_t nN=0; nN<aRangeStrings.size(); nN++ )
+        for(const OUString & aRangeString : aRangeStrings)
         {
             ScRangeList aRanges;
-            aRanges.Parse( aRangeStrings[nN], pSheetNameDoc, ScRefFlags::VALID, pSheetNameDoc->GetAddressConvention() );
+            aRanges.Parse( aRangeString, pSheetNameDoc, ScRefFlags::VALID, pSheetNameDoc->GetAddressConvention() );
             rRangesVector.push_back(aRanges);
         }
     }
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index 6e049c1..40cac04 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -887,9 +887,9 @@ void ScDocument::CopyDdeLinks( ScDocument* pDestDoc ) const
         return;
 
     const sfx2::SvBaseLinks& rLinks = pMgr->GetLinks();
-    for (size_t i = 0, n = rLinks.size(); i < n; ++i)
+    for (const auto & rLink : rLinks)
     {
-        const sfx2::SvBaseLink* pBase = rLinks[i].get();
+        const sfx2::SvBaseLink* pBase = rLink.get();
         if (const ScDdeLink* p = dynamic_cast<const ScDdeLink*>(pBase))
         {
             ScDdeLink* pNew = new ScDdeLink(pDestDoc, *p);
@@ -1055,9 +1055,9 @@ void ScDocument::UpdateAreaLinks()
         return;
 
     const ::sfx2::SvBaseLinks& rLinks = pMgr->GetLinks();
-    for (size_t i=0; i<rLinks.size(); i++)
+    for (const auto & rLink : rLinks)
     {
-        ::sfx2::SvBaseLink* pBase = rLinks[i].get();
+        ::sfx2::SvBaseLink* pBase = rLink.get();
         if (dynamic_cast<const ScAreaLink*>( pBase) !=  nullptr)
             pBase->Update();
     }
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 1483aea..75d2336 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -722,9 +722,9 @@ bool ScDocument::DeleteTab( SCTAB nTab )
                 if ( pUnoBroadcaster )
                     pUnoBroadcaster->Broadcast( ScUpdateRefHint( URM_INSDEL, aRange, 0,0,-1 ) );
 
-                for (SCTAB i = 0, n = static_cast<SCTAB>(maTabs.size()); i < n; ++i)
-                    if (maTabs[i])
-                        maTabs[i]->UpdateDeleteTab(aCxt);
+                for (ScTable* pTab : maTabs)
+                    if (pTab)
+                        pTab->UpdateDeleteTab(aCxt);
 
                 TableContainer::iterator it = maTabs.begin() + nTab;
                 delete *it;
@@ -811,9 +811,9 @@ bool ScDocument::DeleteTabs( SCTAB nTab, SCTAB nSheets )
                 if ( pUnoBroadcaster )
                     pUnoBroadcaster->Broadcast( ScUpdateRefHint( URM_INSDEL, aRange, 0,0,-1*nSheets ) );
 
-                for (SCTAB i = 0, n = static_cast<SCTAB>(maTabs.size()); i < n; ++i)
-                    if (maTabs[i])
-                        maTabs[i]->UpdateDeleteTab(aCxt);
+                for (ScTable* pTab : maTabs)
+                    if (pTab)
+                        pTab->UpdateDeleteTab(aCxt);
 
                 TableContainer::iterator it = maTabs.begin() + nTab;
                 TableContainer::iterator itEnd = it + nSheets;
@@ -2876,9 +2876,8 @@ void ScDocument::CopyFromClip( const ScRange& rDestRange, const ScMarkData& rMar
             if (bPreallocatePattern && (nR2+1) <= nRow2)
             {
                 SCROW nR3 = nR2 + 1;
-                for (size_t j = 0; j < vTables.size(); ++j)
+                for (SCTAB nTab : vTables)
                 {
-                    SCTAB nTab = vTables[j];
                     for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
                     {
                         // Pattern count of the first chunk pasted.
@@ -6541,9 +6540,8 @@ SCROW ScDocument::GetNotePosition( SCTAB nTab, SCCOL nCol, size_t nIndex ) const
 
 void ScDocument::GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const
 {
-    for (size_t nTab = 0; nTab < maTabs.size(); ++nTab)
+    for (ScTable* pTab : maTabs)
     {
-        const ScTable* pTab = maTabs[nTab];
         if (!pTab)
             continue;
 
diff --git a/sc/source/core/data/document10.cxx b/sc/source/core/data/document10.cxx
index 4690f9b..59aff13 100644
--- a/sc/source/core/data/document10.cxx
+++ b/sc/source/core/data/document10.cxx
@@ -162,9 +162,8 @@ std::set<Color> ScDocument::GetDocColors()
     std::set<Color> aDocColors;
     ScDocumentPool *pPool = GetPool();
     const sal_uInt16 pAttribs[] = {ATTR_BACKGROUND, ATTR_FONT_COLOR};
-    for (size_t i=0; i<SAL_N_ELEMENTS( pAttribs ); i++)
+    for (sal_uInt16 nAttrib : pAttribs)
     {
-        const sal_uInt16 nAttrib = pAttribs[i];
         const sal_uInt32 nCount = pPool->GetItemCount2(nAttrib);
         for (sal_uInt32 j=0; j<nCount; j++)
         {
diff --git a/sc/source/core/data/funcdesc.cxx b/sc/source/core/data/funcdesc.cxx
index acb3c66..8784ae3 100644
--- a/sc/source/core/data/funcdesc.cxx
+++ b/sc/source/core/data/funcdesc.cxx
@@ -405,9 +405,9 @@ ScFunctionList::ScFunctionList() :
         RID_SC_FUNCTION_DESCRIPTIONS2
     };
 
-    for (sal_uInt16 k = 0; k < SAL_N_ELEMENTS(nDescBlock); ++k)
+    for (sal_uInt16 k : nDescBlock)
     {
-        std::unique_ptr<ScResourcePublisher> pBlock( new ScResourcePublisher( ScResId( nDescBlock[k] ) ) );
+        std::unique_ptr<ScResourcePublisher> pBlock( new ScResourcePublisher( ScResId( k ) ) );
         // Browse for all possible OpCodes. This is not the fastest method, but
         // otherwise the sub resources within the resource blocks and the
         // resource blocks themselves would had to be ordered according to
@@ -693,8 +693,8 @@ ScFunctionMgr::ScFunctionMgr() :
 
 ScFunctionMgr::~ScFunctionMgr()
 {
-    for (sal_uInt16 i = 0; i < MAX_FUNCCAT; ++i)
-        delete aCatLists[i];
+    for (std::vector<const ScFuncDesc*> * pCatList : aCatLists)
+        delete pCatList;
 }
 
 
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index e76aaa3..c677ce1 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1909,9 +1909,9 @@ bool ScTable::HasAttribSelection( const ScMarkData& rMark, sal_uInt16 nMask ) co
 {
     std::vector<sc::ColRowSpan> aSpans = rMark.GetMarkedColSpans();
 
-    for (size_t i = 0; i < aSpans.size(); ++i)
+    for (sc::ColRowSpan & aSpan : aSpans)
     {
-        for (SCCOLROW j = aSpans[i].mnStart; j < aSpans[i].mnEnd; ++j)
+        for (SCCOLROW j = aSpan.mnStart; j < aSpan.mnEnd; ++j)
         {
             if (aCol[j].HasAttribSelection(rMark, nMask))
               return true;
@@ -2187,9 +2187,9 @@ bool ScTable::HasSelectionMatrixFragment( const ScMarkData& rMark ) const
 {
     std::vector<sc::ColRowSpan> aSpans = rMark.GetMarkedColSpans();
 
-    for ( size_t i=0; i<aSpans.size(); i++ )
+    for (sc::ColRowSpan & aSpan : aSpans)
     {
-        for ( SCCOLROW j=aSpans[i].mnStart; j<aSpans[i].mnEnd; j++ )
+        for ( SCCOLROW j=aSpan.mnStart; j<aSpan.mnEnd; j++ )
         {
             if ( aCol[j].HasSelectionMatrixFragment(rMark) )
                 return true;
diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index f576ff5..79cf4b4 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -1997,8 +1997,8 @@ void ScTable::AutoFormat( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW
                 } // if not equal Column
             } // if not all equal
 
-            for (sal_uInt8 j = 0; j < 16; ++j)
-                delete pPatternAttrs[j];
+            for (ScPatternAttr* pPatternAttr : pPatternAttrs)
+                delete pPatternAttr;
         } // if AutoFormatData != NULL
     } // if ValidColRow
 }
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 3b1bd76..55a714e 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -2432,8 +2432,8 @@ public:
 
     virtual void GenSlidingWindowFunction( std::stringstream& ss ) override
     {
-        for (size_t i = 0; i < mvSubArguments.size(); i++)
-            mvSubArguments[i]->GenSlidingWindowFunction(ss);
+        for (DynamicKernelArgumentRef & rArg : mvSubArguments)
+            rArg->GenSlidingWindowFunction(ss);
         mpCodeGen->GenSlidingWindowFunction(ss, mSymName, mvSubArguments);
     }
     virtual void GenDeclRef( std::stringstream& ss ) const override
@@ -2459,9 +2459,9 @@ public:
     virtual size_t GetWindowSize() const override
     {
         size_t nCurWindowSize = 0;
-        for (size_t i = 0; i < mvSubArguments.size(); i++)
+        for (const auto & rSubArgument : mvSubArguments)
         {
-            size_t nCurChildWindowSize = mvSubArguments[i]->GetWindowSize();
+            size_t nCurChildWindowSize = rSubArgument->GetWindowSize();
             nCurWindowSize = (nCurWindowSize < nCurChildWindowSize) ?
                 nCurChildWindowSize : nCurWindowSize;
         }
@@ -2518,16 +2518,16 @@ public:
     virtual std::string DumpOpName() const override
     {
         std::string t = "_" + mpCodeGen->BinFuncName();
-        for (size_t i = 0; i < mvSubArguments.size(); i++)
-            t = t + mvSubArguments[i]->DumpOpName();
+        for (const auto & rSubArgument : mvSubArguments)
+            t = t + rSubArgument->DumpOpName();
         return t;
     }
     virtual void DumpInlineFun( std::set<std::string>& decls,
         std::set<std::string>& funs ) const override
     {
         mpCodeGen->BinInlineFun(decls, funs);
-        for (size_t i = 0; i < mvSubArguments.size(); i++)
-            mvSubArguments[i]->DumpInlineFun(decls, funs);
+        for (const auto & rSubArgument : mvSubArguments)
+            rSubArgument->DumpInlineFun(decls, funs);
     }
     virtual ~DynamicKernelSoPArguments()
     {
@@ -3790,9 +3790,9 @@ std::string DynamicKernel::GetMD5()
             mFullProgramSrc.c_str(),
             mFullProgramSrc.length(), result,
             RTL_DIGEST_LENGTH_MD5);
-        for (int i = 0; i < RTL_DIGEST_LENGTH_MD5; i++)
+        for (sal_uInt8 i : result)
         {
-            md5s << std::hex << (int)result[i];
+            md5s << std::hex << (int)i;
         }
         mKernelHash = md5s.str();
     }
diff --git a/sc/source/core/opencl/op_logical.cxx b/sc/source/core/opencl/op_logical.cxx
index 61a4bba..698b040 100644
--- a/sc/source/core/opencl/op_logical.cxx
+++ b/sc/source/core/opencl/op_logical.cxx
@@ -237,26 +237,26 @@ void OpXor::GenSlidingWindowFunction(std::stringstream &ss,
     ss << "    int gid0 = get_global_id(0);\n";
     ss << "    int t = 0,tmp0 = 0;\n";
     ss << "    double tmp = 0;\n";
-    for(size_t j = 0; j< vSubArguments.size(); j++)
+    for(DynamicKernelArgumentRef & rArg : vSubArguments)
     {
-        FormulaToken *tmpCur0 = vSubArguments[j]->GetFormulaToken();
+        FormulaToken *tmpCur0 = rArg->GetFormulaToken();
         if(tmpCur0->GetType() == formula::svSingleVectorRef)
         {
             const formula::SingleVectorRefToken*pCurDVR= static_cast<const
                 formula::SingleVectorRefToken *>(tmpCur0);
             ss <<"    if(gid0 >= "<<pCurDVR->GetArrayLength()<<" || isNan(";
-            ss <<vSubArguments[j]->GenSlidingWindowDeclRef();
+            ss <<rArg->GenSlidingWindowDeclRef();
             ss <<"))\n";
             ss <<"        tmp = 0;\n    else\n";
             ss <<"        tmp = ";
-            ss <<vSubArguments[j]->GenSlidingWindowDeclRef()<<";\n";
+            ss <<rArg->GenSlidingWindowDeclRef()<<";\n";
             ss <<"    tmp0 = (tmp != 0);\n";
             ss <<"    t = t ^tmp0;\n";
         }
         else if(tmpCur0->GetType() == formula::svDouble)
         {
             ss <<"        tmp = ";
-            ss <<vSubArguments[j]->GenSlidingWindowDeclRef()<<";\n";
+            ss <<rArg->GenSlidingWindowDeclRef()<<";\n";
             ss <<"    tmp0 = (tmp != 0);\n";
             ss <<"    t = t ^tmp0;\n";
         }
@@ -279,20 +279,20 @@ void OpXor::GenSlidingWindowFunction(std::stringstream &ss,
             }
             if(!pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed())
                 {
-            ss <<"    if(isNan("<<vSubArguments[j]->GenSlidingWindowDeclRef();
+            ss <<"    if(isNan("<<rArg->GenSlidingWindowDeclRef();
             ss <<")||i+gid0>="<<pCurDVR->GetArrayLength();
             ss <<")\n";
             ss <<"        tmp = 0;\n    else\n";
                 }
             else
                 {
-            ss <<"    if(isNan("<<vSubArguments[j]->GenSlidingWindowDeclRef();
+            ss <<"    if(isNan("<<rArg->GenSlidingWindowDeclRef();
             ss <<")||i>="<<pCurDVR->GetArrayLength();
             ss <<")\n";
             ss <<"        tmp = 0;\n    else\n";
                 }
             ss <<"        tmp = ";
-            ss <<vSubArguments[j]->GenSlidingWindowDeclRef()<<";\n";
+            ss <<rArg->GenSlidingWindowDeclRef()<<";\n";
             ss <<"    tmp0 = (tmp != 0);\n";
             ss <<"    t = t ^tmp0;\n";
             ss <<"    }\n";
diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx
index b6525f2..f37ec30 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -2369,11 +2369,11 @@ void OpSumSQ::GenSlidingWindowFunction(std::stringstream &ss,
     ss << "{\n";
     ss << "    int gid0=get_global_id(0);\n";
     ss << "    double sum = 0.0f, arg;\n";
-    for( size_t i=0; i < vSubArguments.size(); ++i)
+    for(DynamicKernelArgumentRef & rArg : vSubArguments)
     {
-        FormulaToken *tmpCur = vSubArguments[i]->GetFormulaToken();
+        FormulaToken *tmpCur = rArg->GetFormulaToken();
         assert(tmpCur);
-        if(ocPush == vSubArguments[i]->GetFormulaToken()->GetOpCode())
+        if(ocPush == rArg->GetFormulaToken()->GetOpCode())
         {
             if (tmpCur->GetType() == formula::svDoubleVectorRef)
             {
@@ -2405,7 +2405,7 @@ void OpSumSQ::GenSlidingWindowFunction(std::stringstream &ss,
                     ss << "    {\n";
                 }
                 ss << "        arg = ";
-                ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+                ss << rArg->GenSlidingWindowDeclRef();
                 ss << ";\n";
                 ss << "        if (isNan(arg))\n";
                 ss << "            continue;\n";
@@ -2418,7 +2418,7 @@ void OpSumSQ::GenSlidingWindowFunction(std::stringstream &ss,
                       static_cast<
                       const formula::SingleVectorRefToken *>(tmpCur);
                 ss << "    arg = ";
-                ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+                ss << rArg->GenSlidingWindowDeclRef();
                 ss << ";\n";
                 ss << "    if(isNan(arg)||(gid0>=";
                 ss << tmpCurDVR->GetArrayLength();
@@ -2436,7 +2436,7 @@ void OpSumSQ::GenSlidingWindowFunction(std::stringstream &ss,
         else
         {
             ss << "        arg = ";
-            ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+            ss << rArg->GenSlidingWindowDeclRef();
             ss << ";\n";
             ss << "        sum += pown(arg, 2);\n";
         }
@@ -2720,9 +2720,9 @@ void OpProduct::GenSlidingWindowFunction(std::stringstream &ss,
     ss << "    int gid0 = get_global_id(0);\n";
     ss << "    int i = 0;\n";
     ss << "    double product=1.0;\n\n";
-    for (size_t i = 0; i < vSubArguments.size(); i++)
+    for (DynamicKernelArgumentRef & rArg : vSubArguments)
     {
-        FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
+        FormulaToken *pCur = rArg->GetFormulaToken();
         assert(pCur);
         if (pCur->GetType() == formula::svDoubleVectorRef)
         {
@@ -2755,23 +2755,23 @@ void OpProduct::GenSlidingWindowFunction(std::stringstream &ss,
                  ss << "0; i < " << pDVR->GetArrayLength() << "; i++)\n";
                  ss << "    {\n";
               }
-              ss << "if(!isNan("<<vSubArguments[i]->GenSlidingWindowDeclRef()<<"))\n";
+              ss << "if(!isNan("<<rArg->GenSlidingWindowDeclRef()<<"))\n";
               ss << "product = product*";
-              ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
+              ss << rArg->GenSlidingWindowDeclRef()<<";\n";
               ss << "    }\n";
             }
             else if (pCur->GetType() == formula::svSingleVectorRef)
             {
-                ss << "if(!isNan("<<vSubArguments[i]->GenSlidingWindowDeclRef()<<"))\n";
+                ss << "if(!isNan("<<rArg->GenSlidingWindowDeclRef()<<"))\n";
                 ss << "product = product*";
-                ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
+                ss << rArg->GenSlidingWindowDeclRef()<<";\n";
 
             }
             else
             {
-                ss << "if(!isNan("<<vSubArguments[i]->GenSlidingWindowDeclRef()<<"))\n";
+                ss << "if(!isNan("<<rArg->GenSlidingWindowDeclRef()<<"))\n";
                 ss << "product = product*";
-                ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
+                ss << rArg->GenSlidingWindowDeclRef()<<";\n";
             }
         }
         ss << "    return product;\n";
diff --git a/sc/source/core/opencl/op_statistical.cxx b/sc/source/core/opencl/op_statistical.cxx
index b543300..7a59167 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -3440,14 +3440,14 @@ void OpGeoMean::GenSlidingWindowFunction(
     ss << "    int offset;\n";
     ss << "    barrier(CLK_LOCAL_MEM_FENCE);\n";
 
-    for(size_t i=0;i<vSubArguments.size();i++)
+    for(DynamicKernelArgumentRef & rArg : vSubArguments)
     {
-        assert(vSubArguments[i]->GetFormulaToken());
+        assert(rArg->GetFormulaToken());
 
-        if(vSubArguments[i]->GetFormulaToken()->GetType() ==
+        if(rArg->GetFormulaToken()->GetType() ==
         formula::svDoubleVectorRef)
         {
-            FormulaToken *tmpCur = vSubArguments[i]->GetFormulaToken();
+            FormulaToken *tmpCur = rArg->GetFormulaToken();
                 const formula::DoubleVectorRefToken*pCurDVR= static_cast<const
                      formula::DoubleVectorRefToken *>(tmpCur);
                 size_t nCurWindowSize = pCurDVR->GetArrayLength() <
@@ -3478,7 +3478,7 @@ void OpGeoMean::GenSlidingWindowFunction(
             std::string p2 = "p2";
 
             ss << "        tmp0 =";
-            vSubArguments[i]->GenDeclRef(ss);
+            rArg->GenDeclRef(ss);
             ss << "["<<p1.c_str()<<"];\n";
             ss << "        if(!isNan(tmp0))\n";
             ss << "       {\n";
@@ -3487,7 +3487,7 @@ void OpGeoMean::GenSlidingWindowFunction(
             ss << "       }\n";
 
             ss << "        tmp0 =";
-            vSubArguments[i]->GenDeclRef(ss);
+            rArg->GenDeclRef(ss);
             ss << "["<<p2.c_str()<<"];\n";
             ss << "        if(!isNan(tmp0))\n";
             ss << "       {\n";
@@ -3499,7 +3499,7 @@ void OpGeoMean::GenSlidingWindowFunction(
             ss << "        else if (p1 < min(arrayLength, offset + windowSize)) {\n";
 
             ss << "        tmp0 =";
-            vSubArguments[i]->GenDeclRef(ss);
+            rArg->GenDeclRef(ss);
             ss << "["<<p1.c_str()<<"];\n";
             ss << "        if(!isNan(tmp0))\n";
             ss << "        {\n";
@@ -3534,15 +3534,14 @@ void OpGeoMean::GenSlidingWindowFunction(
             ss << "    if (lidx == 0)\n";
             ss << "    {\n";
             ss << "        tmp0 =";
-            if(vSubArguments[i]->GetFormulaToken()->GetType() ==
-     formula::svSingleVectorRef)
+            if(rArg->GetFormulaToken()->GetType() == formula::svSingleVectorRef)
             {
-                vSubArguments[i]->GenDeclRef(ss);
+                rArg->GenDeclRef(ss);
                 ss << "[writePos];\n";
             }
             else
             {
-                vSubArguments[i]->GenDeclRef(ss);
+                rArg->GenDeclRef(ss);
                 ss <<";\n";
                 //ss <<"printf(\"\\n********************tmp0 is %f\",tmp0);\n";
             }
@@ -4777,9 +4776,9 @@ void OpMedian::GenSlidingWindowFunction(
     ss << "    unsigned int startFlag = 0;\n";
     ss << "    unsigned int endFlag = 0;\n";
     ss << "    double dataIna;\n";
-    for (size_t i = 0; i < vSubArguments.size(); i++)
+    for (DynamicKernelArgumentRef & rArg : vSubArguments)
     {
-        FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
+        FormulaToken *pCur = rArg->GetFormulaToken();
         assert(pCur);
         if (const formula::DoubleVectorRefToken* pCurDVR =
             dynamic_cast<const formula::DoubleVectorRefToken *>(pCur))
diff --git a/sc/source/core/tool/callform.cxx b/sc/source/core/tool/callform.cxx
index 075f3f3..d79e98f 100644
--- a/sc/source/core/tool/callform.cxx
+++ b/sc/source/core/tool/callform.cxx
@@ -213,9 +213,9 @@ bool InitExternalFunc(const OUString& rModuleName)
         cFuncName[0] = 0;
         cInternalName[0] = 0;
         nParamCount = 0;
-        for ( sal_uInt16 j=0; j<MAXFUNCPARAM; j++ )
+        for (ParamType & rParamType : eParamType)
         {
-            eParamType[j] = ParamType::NONE;
+            rParamType = ParamType::NONE;
         }
         (*reinterpret_cast<GetFuncDataPtr>(fpGetData))(i, cFuncName, nParamCount,
                                        eParamType, cInternalName);
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index c50174b..10ec0ca 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -2669,12 +2669,11 @@ bool ScCompiler::IsOpCode( const OUString& rName, bool bInArray )
             // Renamed new names, prepare to read future names:
             //{ "ORG.OPENOFFICE.XXX", ocXXX }         // XXX -> ORG.OPENOFFICE.XXX
         };
-        static const size_t nOdffAliases = SAL_N_ELEMENTS(aOdffAliases);
-        for (size_t i=0; i<nOdffAliases; ++i)
+        for (const FunctionName& rOdffAlias : aOdffAliases)
         {
-            if (rName.equalsIgnoreAsciiCaseAscii( aOdffAliases[i].pName))
+            if (rName.equalsIgnoreAsciiCaseAscii( rOdffAlias.pName))
             {
-                maRawToken.SetOpCode( aOdffAliases[i].eOp);
+                maRawToken.SetOpCode( rOdffAlias.eOp);
                 bFound = true;
                 break;  // for
             }
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 94eeda8..b95c867 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -7039,8 +7039,8 @@ void ScInterpreter::GetDBStVarParams( double& rVal, double& rValCount )
 
     vMean = fSum / values.size();
 
-    for (size_t i = 0; i < values.size(); i++)
-        vSum += (values[i] - vMean) * (values[i] - vMean);
+    for (double v : values)
+        vSum += (v - vMean) * (v - vMean);
 
     rVal = vSum;
 }
diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx
index c1a812a..4a51f95 100644
--- a/sc/source/core/tool/interpr2.cxx
+++ b/sc/source/core/tool/interpr2.cxx
@@ -3002,12 +3002,11 @@ static bool lclConvertMoney( const OUString& aSearchUnit, double& rfRate, int& r
         { "LTL", 3.45280,  2 }
     };
 
-    static const size_t nConversionCount = SAL_N_ELEMENTS( aConvertTable );
-    for ( size_t i = 0; i < nConversionCount; ++i )
-        if ( aSearchUnit.equalsIgnoreAsciiCaseAscii( aConvertTable[i].pCurrText ) )
+    for (const auto & i : aConvertTable)
+        if ( aSearchUnit.equalsIgnoreAsciiCaseAscii( i.pCurrText ) )
         {
-            rfRate = aConvertTable[i].fRate;
-            rnDec  = aConvertTable[i].nDec;
+            rfRate = i.fRate;
+            rnDec  = i.nDec;
             return true;
         }
     return false;
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index 4dc2530..5a98900 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -2879,8 +2879,8 @@ void ScInterpreter::ScKurt()
 
     double fMean = fSum / fCount;
 
-    for (size_t i = 0; i < values.size(); i++)
-        vSum += (values[i] - fMean) * (values[i] - fMean);
+    for (double v : values)
+        vSum += (v - fMean) * (v - fMean);
 
     double fStdDev = sqrt(vSum / (fCount - 1.0));
     double xpower4 = 0.0;
@@ -2891,9 +2891,9 @@ void ScInterpreter::ScKurt()
         return;
     }
 
-    for (size_t i = 0; i < values.size(); i++)
+    for (double v : values)
     {
-        double dx = (values[i] - fMean) / fStdDev;
+        double dx = (v - fMean) / fStdDev;
         xpower4 = xpower4 + (dx * dx * dx * dx);
     }
 
@@ -3277,8 +3277,8 @@ void ScInterpreter::CalculateSkewOrSkewp( bool bSkewp )
 
     double fMean = fSum / fCount;
 
-    for (size_t i = 0; i < values.size(); ++i)
-        vSum += (values[i] - fMean) * (values[i] - fMean);
+    for (double v : values)
+        vSum += (v - fMean) * (v - fMean);
 
     double fStdDev = sqrt( vSum / (bSkewp ? fCount : (fCount - 1.0)));
     double xcube = 0.0;
@@ -3289,9 +3289,9 @@ void ScInterpreter::CalculateSkewOrSkewp( bool bSkewp )
         return;
     }
 
-    for (size_t i = 0; i < values.size(); ++i)
+    for (double v : values)
     {
-        double dx = (values[i] - fMean) / fStdDev;
+        double dx = (v - fMean) / fStdDev;
         xcube = xcube + (dx * dx * dx);
     }
 
diff --git a/sc/source/core/tool/parclass.cxx b/sc/source/core/tool/parclass.cxx
index d30c311..bd8ca55 100644
--- a/sc/source/core/tool/parclass.cxx
+++ b/sc/source/core/tool/parclass.cxx
@@ -242,9 +242,9 @@ void ScParameterClassification::Init()
     memset( pData, 0, sizeof(RunData) * (SC_OPCODE_LAST_OPCODE_ID + 1));
 
     // init from specified static data above
-    for ( size_t i=0; i < SAL_N_ELEMENTS(pRawData); ++i )
+    for (const auto & i : pRawData)
     {
-        const RawData* pRaw = &pRawData[i];
+        const RawData* pRaw = &i;
         if ( pRaw->eOp > SC_OPCODE_LAST_OPCODE_ID )
         {
             OSL_ENSURE( pRaw->eOp == ocNone, "RawData OpCode error");
@@ -289,9 +289,9 @@ void ScParameterClassification::Init()
                         pRun->aData.nParam[CommonData::nMaxParams-1] != Bounds)
                     pRun->nMinParams = CommonData::nMaxParams;
             }
-            for ( sal_Int32 j=0; j < CommonData::nMaxParams; ++j )
+            for (ScParameterClassification::Type & j : pRun->aData.nParam)
             {
-                if ( pRun->aData.nParam[j] == ForceArray || pRun->aData.nParam[j] == ReferenceOrForceArray )
+                if ( j == ForceArray || j == ReferenceOrForceArray )
                 {
                     pRun->bHasForceArray = true;
                     break;  // for
diff --git a/sc/source/core/tool/rangelst.cxx b/sc/source/core/tool/rangelst.cxx
index 924bd0b..daa2ffe 100644
--- a/sc/source/core/tool/rangelst.cxx
+++ b/sc/source/core/tool/rangelst.cxx
@@ -1270,9 +1270,8 @@ void ScRangePairList::UpdateReference( UpdateRefMode eUpdateRefMode,
         SCROW nRow2;
         SCTAB nTab2;
         rWhere.GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
-        for ( size_t i = 0, nPairs = maPairs.size(); i < nPairs; ++i )
+        for (ScRangePair* pR : maPairs)
         {
-            ScRangePair* pR = maPairs[ i ];
             for ( sal_uInt16 j=0; j<2; j++ )
             {
                 ScRange& rRange = pR->GetRange(j);
@@ -1319,9 +1318,8 @@ void ScRangePairList::DeleteOnTab( SCTAB nTab )
 
 ScRangePair* ScRangePairList::Find( const ScAddress& rAdr ) const
 {
-    for ( size_t j = 0, nListCount = maPairs.size(); j < nListCount; j++ )
+    for (ScRangePair* pR : maPairs)
     {
-        ScRangePair* pR = maPairs[ j ];
         if ( pR->GetRange(0).In( rAdr ) )
             return pR;
     }
@@ -1330,9 +1328,8 @@ ScRangePair* ScRangePairList::Find( const ScAddress& rAdr ) const
 
 ScRangePair* ScRangePairList::Find( const ScRange& rRange ) const
 {
-    for ( size_t j = 0, nListCount = maPairs.size(); j < nListCount; j++ )
+    for (ScRangePair* pR : maPairs)
     {
-        ScRangePair* pR = maPairs[ j ];
         if ( pR->GetRange(0) == rRange )
             return pR;
     }
@@ -1342,9 +1339,9 @@ ScRangePair* ScRangePairList::Find( const ScRange& rRange ) const
 ScRangePairList* ScRangePairList::Clone() const
 {
     ScRangePairList* pNew = new ScRangePairList;
-    for ( size_t j = 0, nListCount = maPairs.size(); j < nListCount; j++ )
+    for (const ScRangePair* pR : maPairs)
     {
-        pNew->Append( *maPairs[ j ] );
+        pNew->Append( *pR );
     }
     return pNew;
 }
diff --git a/sc/source/filter/excel/excform.cxx b/sc/source/filter/excel/excform.cxx
index 27774c1..3815c0f 100644
--- a/sc/source/filter/excel/excform.cxx
+++ b/sc/source/filter/excel/excform.cxx
@@ -1940,10 +1940,8 @@ void ExcelToSc::ReadExtensions( const ExtensionTypeVec& rExtensions,
 {
     unsigned int nArray = 0;
 
-    for( size_t i = 0 ; i < rExtensions.size() ; i++ )
+    for(int eType : rExtensions)
     {
-        ExtensionType eType = rExtensions[i];
-
         switch( eType )
         {
             case EXTENSION_ARRAY:
diff --git a/sc/source/filter/excel/xepivot.cxx b/sc/source/filter/excel/xepivot.cxx
index 7f76447..546064c 100644
--- a/sc/source/filter/excel/xepivot.cxx
+++ b/sc/source/filter/excel/xepivot.cxx
@@ -525,9 +525,9 @@ void XclExpPCField::InsertNumDateGroupItems( const ScDPObject& rDPObj, const ScD
             aTmpDim.SetDateDimension();
         const std::vector<SCROW>& aMemberIds = aTmpDim.GetNumEntries(
             static_cast<SCCOL>(nDim), pCache);
-        for ( size_t  nIdx = 0 ; nIdx < aMemberIds.size(); nIdx++ )
+        for (SCROW nMemberId : aMemberIds)
         {
-            const ScDPItemData* pData = aDPData.GetMemberById(nDim , aMemberIds[nIdx]);
+            const ScDPItemData* pData = aDPData.GetMemberById(nDim, nMemberId);
             if ( pData )
             {
                 OUString aStr = pCache->GetFormattedString(nDim, *pData);
diff --git a/sc/source/filter/excel/xepivotxml.cxx b/sc/source/filter/excel/xepivotxml.cxx
index f655c2b..1b34081 100644
--- a/sc/source/filter/excel/xepivotxml.cxx
+++ b/sc/source/filter/excel/xepivotxml.cxx
@@ -310,9 +310,9 @@ void XclExpXmlPivotTableManager::Initialize()
     std::vector<XclExpXmlPivotCaches::Entry> aCaches;
     const ScDPCollection::SheetCaches& rSheetCaches = pDPColl->GetSheetCaches();
     const std::vector<ScRange>& rRanges = rSheetCaches.getAllRanges();
-    for (size_t i = 0, n = rRanges.size(); i < n; ++i)
+    for (const auto & rRange : rRanges)
     {
-        const ScDPCache* pCache = rSheetCaches.getExistingCache(rRanges[i]);
+        const ScDPCache* pCache = rSheetCaches.getExistingCache(rRange);
         if (!pCache)
             continue;
 
@@ -326,7 +326,7 @@ void XclExpXmlPivotTableManager::Initialize()
         XclExpXmlPivotCaches::Entry aEntry;
         aEntry.meType = XclExpXmlPivotCaches::Worksheet;
         aEntry.mpCache = pCache;
-        aEntry.maSrcRange = rRanges[i];
+        aEntry.maSrcRange = rRange;
         aCaches.push_back(aEntry); // Cache ID equals position + 1.
     }
 
@@ -451,9 +451,9 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP
     // appearance in each axis.
     const ScDPSaveData::DimsType& rDims = rSaveData.GetDimensions();
 
-    for (size_t i = 0, n = rDims.size(); i < n; ++i)
+    for (const auto & i : rDims)
     {
-        const ScDPSaveDimension& rDim = *rDims[i];
+        const ScDPSaveDimension& rDim = *i;
 
         long nPos = -1; // position in cache
         if (rDim.IsDataLayout())
@@ -554,9 +554,8 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP
         XML_count, OString::number(static_cast<long>(aCachedDims.size())).getStr(),
         FSEND);
 
-    for (size_t i = 0, n = aCachedDims.size(); i < n; ++i)
+    for (const ScDPSaveDimension* pDim : aCachedDims)
     {
-        const ScDPSaveDimension* pDim = aCachedDims[i];
         if (!pDim)
         {
             pPivotStrm->singleElement(XML_pivotField,
diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx
index 13e232c..d56d041 100644
--- a/sc/source/filter/excel/xestyle.cxx
+++ b/sc/source/filter/excel/xestyle.cxx
@@ -590,10 +590,10 @@ void XclExpPaletteImpl::RawReducePalette( sal_uInt32 nPass )
     sal_uInt8 nFactor3 = static_cast< sal_uInt8 >( 0x40 >> nPass );
 
     // process each color in the old color list
-    for( sal_uInt32 nIdx = 0, nCount = xOldList->size(); nIdx < nCount; ++nIdx )
+    for(std::unique_ptr<XclListColor> & pOldColor : *xOldList)
     {
         // get the old list entry
-        const XclListColor* pOldEntry = xOldList->at( nIdx ).get();
+        const XclListColor* pOldEntry = pOldColor.get();
         nR = pOldEntry->GetColor().GetRed();
         nG = pOldEntry->GetColor().GetGreen();
         nB = pOldEntry->GetColor().GetBlue();
diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx
index 867d5b8..c08b056 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -2118,8 +2118,8 @@ public:
     void     push_back( XclExpRow *pRow ) { maRows.push_back( pRow ); }
     virtual void doWork() override
     {
-        for (size_t i = 0; i < maRows.size(); i++ )
-            maRows[ i ]->Finalize( mrColXFIndexes, mbProgress );
+        for (XclExpRow* p : maRows)
+            p->Finalize( mrColXFIndexes, mbProgress );
     }
 };
 
diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx
index 726ef0d..d895e75 100644
--- a/sc/source/filter/excel/xiescher.cxx
+++ b/sc/source/filter/excel/xiescher.cxx
@@ -3178,9 +3178,8 @@ void XclImpSolverContainer::RemoveSdrObjectInfo( SdrObject& rSdrObj )
 
 void XclImpSolverContainer::UpdateConnectorRules()
 {
-    for ( size_t i = 0, n = aCList.size(); i < n; ++i )
+    for (SvxMSDffConnectorRule* pRule : aCList)
     {
-        SvxMSDffConnectorRule* pRule = aCList[ i ];
         UpdateConnection( pRule->nShapeA, pRule->pAObj, &pRule->nSpFlagsA );
         UpdateConnection( pRule->nShapeB, pRule->pBObj, &pRule->nSpFlagsB );
         UpdateConnection( pRule->nShapeC, pRule->pCObj );
@@ -3190,8 +3189,8 @@ void XclImpSolverContainer::UpdateConnectorRules()
 void XclImpSolverContainer::RemoveConnectorRules()
 {
     // base class from SVX uses plain untyped tools/List
-    for ( size_t i = 0, n = aCList.size(); i < n; ++i ) {
-        delete aCList[ i ];
+    for (SvxMSDffConnectorRule* p : aCList) {
+        delete p;
     }
     aCList.clear();
     maSdrInfoMap.clear();
diff --git a/sc/source/filter/html/htmlpars.cxx b/sc/source/filter/html/htmlpars.cxx
index c1e124d..51bd98b 100644
--- a/sc/source/filter/html/htmlpars.cxx
+++ b/sc/source/filter/html/htmlpars.cxx
@@ -235,9 +235,9 @@ ScHTMLLayoutParser::~ScHTMLLayoutParser()
         aTableStack.pop();
 
         bool found = false;
-        for ( size_t i = 0, nListSize = maList.size(); i < nListSize; ++i )
+        for (ScEEParseEntry* p : maList)
         {
-            if ( pS->pCellEntry == maList[ i ] )
+            if ( pS->pCellEntry == p )
             {
                 found = true;
                 break;
@@ -496,9 +496,8 @@ void ScHTMLLayoutParser::Adjust()
     SCROW nCurRow = 0;
     sal_uInt16 nPageWidth = (sal_uInt16) aPageSize.Width();
     InnerMap* pTab = nullptr;
-    for ( size_t i = 0, nListSize = maList.size(); i < nListSize; ++i )
+    for (ScEEParseEntry* pE : maList)
     {
-        ScEEParseEntry* pE = maList[ i ];
         if ( pE->nTab < nTab )
         {   // Table finished
             if ( !aStack.empty() )
@@ -834,9 +833,9 @@ void ScHTMLLayoutParser::CloseEntry( ImportInfo* pInfo )
     {   // From the stack in TableOff
         bTabInTabCell = false;
         bool found = false;
-        for ( size_t i = 0, nListSize = maList.size(); i < nListSize; ++i )
+        for (ScEEParseEntry* p : maList)
         {
-            if ( pActEntry == maList[ i ] )
+            if ( pActEntry == p )
             {
                 found = true;
                 break;
@@ -960,9 +959,8 @@ void ScHTMLLayoutParser::TableDataOn( ImportInfo* pInfo )
     bInCell = true;
     bool bHorJustifyCenterTH = (pInfo->nToken == HTML_TABLEHEADER_ON);
     const HTMLOptions& rOptions = static_cast<HTMLParser*>(pInfo->pParser)->GetOptions();
-    for (size_t i = 0, n = rOptions.size(); i < n; ++i)
+    for (const auto & rOption : rOptions)
     {
-        const HTMLOption& rOption = rOptions[i];
         switch( rOption.GetToken() )
         {
             case HTML_O_COLSPAN:
@@ -1082,9 +1080,8 @@ void ScHTMLLayoutParser::TableOn( ImportInfo* pInfo )
         if ( pInfo->nToken == HTML_TABLE_ON )
         {   // It can still be TD or TH, if we didn't have a TABLE earlier
             const HTMLOptions& rOptions = static_cast<HTMLParser*>(pInfo->pParser)->GetOptions();
-            for (size_t i = 0, n = rOptions.size(); i < n; ++i)
+            for (const auto & rOption : rOptions)
             {
-                const HTMLOption& rOption = rOptions[i];
                 switch( rOption.GetToken() )
                 {
                     case HTML_O_WIDTH:
@@ -1142,9 +1139,8 @@ void ScHTMLLayoutParser::TableOn( ImportInfo* pInfo )
         {
             // It can still be TD or TH, if we didn't have a TABLE earlier
             const HTMLOptions& rOptions = static_cast<HTMLParser*>(pInfo->pParser)->GetOptions();
-            for (size_t i = 0, n = rOptions.size(); i < n; ++i)
+            for (const auto & rOption : rOptions)
             {
-                const HTMLOption& rOption = rOptions[i];
                 switch( rOption.GetToken() )
                 {
                     case HTML_O_WIDTH:
@@ -1334,9 +1330,8 @@ void ScHTMLLayoutParser::Image( ImportInfo* pInfo )
     pActEntry->maImageList.push_back( o3tl::make_unique<ScHTMLImage>() );
     ScHTMLImage* pImage = pActEntry->maImageList.back().get();
     const HTMLOptions& rOptions = static_cast<HTMLParser*>(pInfo->pParser)->GetOptions();
-    for (size_t i = 0, n = rOptions.size(); i < n; ++i)
+    for (const auto & rOption : rOptions)
     {
-        const HTMLOption& rOption = rOptions[i];
         switch( rOption.GetToken() )
         {
             case HTML_O_SRC:
@@ -1408,9 +1403,8 @@ void ScHTMLLayoutParser::Image( ImportInfo* pInfo )
     if ( pActEntry->maImageList.size() > 0 )
     {
         long nWidth = 0;
-        for ( size_t i=0; i < pActEntry->maImageList.size(); ++i )
+        for (std::unique_ptr<ScHTMLImage> & pI : pActEntry->maImageList)
         {
-            ScHTMLImage* pI = pActEntry->maImageList[ i ].get();
             if ( pI->nDir & nHorizontal )
                 nWidth += pI->aSize.Width() + 2 * pI->aSpace.X();
             else
@@ -1426,9 +1420,8 @@ void ScHTMLLayoutParser::Image( ImportInfo* pInfo )
 void ScHTMLLayoutParser::ColOn( ImportInfo* pInfo )
 {
     const HTMLOptions& rOptions = static_cast<HTMLParser*>(pInfo->pParser)->GetOptions();
-    for (size_t i = 0, n = rOptions.size(); i < n; ++i)
+    for (const auto & rOption : rOptions)
     {
-        const HTMLOption& rOption = rOptions[i];
         switch( rOption.GetToken() )
         {
             case HTML_O_WIDTH:
@@ -1465,9 +1458,8 @@ sal_uInt16 ScHTMLLayoutParser::GetWidthPixel( const HTMLOption& rOption )
 void ScHTMLLayoutParser::AnchorOn( ImportInfo* pInfo )
 {
     const HTMLOptions& rOptions = static_cast<HTMLParser*>(pInfo->pParser)->GetOptions();
-    for (size_t i = 0, n = rOptions.size(); i < n; ++i)
+    for (const auto & rOption : rOptions)
     {
-        const HTMLOption& rOption = rOptions[i];
         switch( rOption.GetToken() )
         {
             case HTML_O_NAME:
@@ -1492,9 +1484,8 @@ void ScHTMLLayoutParser::FontOn( ImportInfo* pInfo )
     if ( IsAtBeginningOfText( pInfo ) )
     {   // Only at the start of the text; applies to whole line
         const HTMLOptions& rOptions = static_cast<HTMLParser*>(pInfo->pParser)->GetOptions();
-        for (size_t i = 0, n = rOptions.size(); i < n; ++i)
+        for (const auto & rOption : rOptions)
         {
-            const HTMLOption& rOption = rOptions[i];
             switch( rOption.GetToken() )
             {
                 case HTML_O_FACE :
diff --git a/sc/source/filter/lotus/lotattr.cxx b/sc/source/filter/lotus/lotattr.cxx
index 6f5575b..72878eb 100644
--- a/sc/source/filter/lotus/lotattr.cxx
+++ b/sc/source/filter/lotus/lotattr.cxx
@@ -73,8 +73,8 @@ LotAttrCache::LotAttrCache (LOTUS_ROOT* pLotRoot)
 
 LotAttrCache::~LotAttrCache()
 {
-    for( sal_uInt16 nCnt = 0 ; nCnt < 6 ; nCnt++ )
-        delete ppColorItems[ nCnt ];
+    for(SvxColorItem* p : ppColorItems)
+        delete p;
 
     delete pBlack;
     delete pWhite;
diff --git a/sc/source/filter/lotus/tool.cxx b/sc/source/filter/lotus/tool.cxx
index f7174e3..8e867fd 100644
--- a/sc/source/filter/lotus/tool.cxx
+++ b/sc/source/filter/lotus/tool.cxx
@@ -152,15 +152,15 @@ FormCache::FormCache( ScDocument* pDoc1, sal_uInt8 nNewDefaultFormat )
 {   // Default format is 'Default'
     nDefaultFormat = nNewDefaultFormat;
     pFormTable = pDoc1->GetFormatTable();
-    for( sal_uInt16 nC = 0 ; nC < nSize_ ; nC++ )
-        bValid[ nC ] = false;
+    for(bool & rb : bValid)
+        rb = false;
     eLanguage = ScGlobal::eLnge;
 }
 
 FormCache::~FormCache()
 {
-    for( sal_uInt16 nC = 0 ; nC < nSize_ ; nC++ )
-        delete aIdents[ nC ].GetAttr();
+    for(FormIdent & rIdent : aIdents)
+        delete rIdent.GetAttr();
 }
 
 SfxUInt32Item* FormCache::NewAttr( sal_uInt8 nFormat, sal_uInt8 nSt )
diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx
index ecd4a9d..e998b50 100644
--- a/sc/source/filter/oox/condformatbuffer.cxx
+++ b/sc/source/filter/oox/condformatbuffer.cxx
@@ -269,10 +269,8 @@ ScColorScaleEntry* ConvertToModel( const ColorScaleRuleModelEntry& rEntry, ScDoc
 
 void ColorScaleRule::AddEntries( ScColorScaleFormat* pFormat, ScDocument* pDoc, const ScAddress& rAddr )
 {
-    for(size_t i = 0; i < maColorScaleRuleEntries.size(); ++i)
+    for(ColorScaleRuleModelEntry & rEntry : maColorScaleRuleEntries)
     {
-        const ColorScaleRuleModelEntry& rEntry = maColorScaleRuleEntries[i];
-
         ScColorScaleEntry* pEntry = ConvertToModel( rEntry, pDoc, rAddr );
 
         pFormat->AddEntry( pEntry );
@@ -399,9 +397,9 @@ void IconSetRule::importIcon(const AttributeList& rAttribs)
 
 void IconSetRule::SetData( ScIconSetFormat* pFormat, ScDocument* pDoc, const ScAddress& rPos )
 {
-    for(size_t i = 0; i < maEntries.size(); ++i)
+    for(ColorScaleRuleModelEntry & rEntry : maEntries)
     {
-        ScColorScaleEntry* pModelEntry = ConvertToModel( maEntries[i], pDoc, rPos );
+        ScColorScaleEntry* pModelEntry = ConvertToModel( rEntry, pDoc, rPos );
         mxFormatData->m_Entries.push_back(std::unique_ptr<ScColorScaleEntry>(pModelEntry));
     }
 
diff --git a/sc/source/filter/oox/formulabuffer.cxx b/sc/source/filter/oox/formulabuffer.cxx
index 9c010cb..14e3f45 100644
--- a/sc/source/filter/oox/formulabuffer.cxx
+++ b/sc/source/filter/oox/formulabuffer.cxx
@@ -425,10 +425,10 @@ void FormulaBuffer::finalizeImport()
                 xThread->launch();
             }
 
-            for (size_t i = 0, n = aThreads.size(); i < n; ++i)
+            for (rtl::Reference<WorkerThread> & xThread : aThreads)
             {
-                if (aThreads[i].is())
-                    aThreads[i]->join();
+                if (xThread.is())
+                    xThread->join();
             }
 
             aThreads.clear();
diff --git a/sc/source/filter/oox/workbookfragment.cxx b/sc/source/filter/oox/workbookfragment.cxx
index 9b824f1..a207fed 100644
--- a/sc/source/filter/oox/workbookfragment.cxx
+++ b/sc/source/filter/oox/workbookfragment.cxx
@@ -300,8 +300,8 @@ public:
     }
     virtual void Invoke() override
     {
-        for( size_t i = 0; i < aSegments.size(); i++)
-            static_cast< ProgressWrapper *>( aSegments[ i ].get() )->UpdateBar();
+        for(std::shared_ptr<ISegmentProgressBar> & pSegment : aSegments)
+            static_cast< ProgressWrapper *>( pSegment.get() )->UpdateBar();
     }
 };
 
diff --git a/sc/source/filter/rtf/eeimpars.cxx b/sc/source/filter/rtf/eeimpars.cxx
index d4a39d9..2fd9abe 100644
--- a/sc/source/filter/rtf/eeimpars.cxx
+++ b/sc/source/filter/rtf/eeimpars.cxx
@@ -262,22 +262,22 @@ void ScEEImport::WriteToDocument( bool bSizeColsRows, double nOutputFactor, SvNu
                     SvtScriptType nScriptType = mpDoc->GetStringScriptType( aStr );
                     const SvtScriptType nScripts[3] = { SvtScriptType::LATIN,
                         SvtScriptType::ASIAN, SvtScriptType::COMPLEX };
-                    for ( sal_uInt8 j=0; j<3; ++j )
+                    for (SvtScriptType nScript : nScripts)
                     {
-                        if ( nScriptType & nScripts[j] )
+                        if ( nScriptType & nScript )
                         {
                             if ( pFont )
                                 rSet.Put( *pFont, ScGlobal::GetScriptedWhichID(
-                                            nScripts[j], ATTR_FONT ));
+                                            nScript, ATTR_FONT ));
                             if ( pHeight )
                                 rSet.Put( *pHeight, ScGlobal::GetScriptedWhichID(
-                                            nScripts[j], ATTR_FONT_HEIGHT ));
+                                            nScript, ATTR_FONT_HEIGHT ));
                             if ( pWeight )
                                 rSet.Put( *pWeight, ScGlobal::GetScriptedWhichID(
-                                            nScripts[j], ATTR_FONT_WEIGHT ));
+                                            nScript, ATTR_FONT_WEIGHT ));
                             if ( pPosture )
                                 rSet.Put( *pPosture, ScGlobal::GetScriptedWhichID(
-                                            nScripts[j], ATTR_FONT_POSTURE ));
+                                            nScript, ATTR_FONT_POSTURE ));
                         }
                     }
                 }
@@ -476,9 +476,9 @@ bool ScEEImport::GraphicSize( SCCOL nCol, SCROW nRow, SCTAB /*nTab*/, ScEEParseE
     long nWidth, nHeight;
     nWidth = nHeight = 0;
     sal_Char nDir = nHorizontal;
-    for ( size_t i = 0; i < pE->maImageList.size() ; ++i )
+    for (std::unique_ptr<ScHTMLImage> & pImage : pE->maImageList)
     {
-        ScHTMLImage* pI = pE->maImageList[ i ].get();
+        ScHTMLImage* pI = pImage.get();
         if ( pI->pGraphic )
             bHasGraphics = true;
         Size aSizePix = pI->aSize;
@@ -552,9 +552,9 @@ void ScEEImport::InsertGraphic( SCCOL nCol, SCROW nRow, SCTAB nTab,
     Point aSpace;
     Size aLogicSize;
     sal_Char nDir = nHorizontal;
-    for ( size_t i = 0; i < pE->maImageList.size(); ++i )
+    for (std::unique_ptr<ScHTMLImage> & pImage : pE->maImageList)
     {
-        ScHTMLImage* pI = pE->maImageList[ i ].get();
+        ScHTMLImage* pI = pImage.get();
         if ( nDir & nHorizontal )
         {   // Horizontal
             aInsertPos.X() += aLogicSize.Width();
diff --git a/sc/source/filter/rtf/rtfparse.cxx b/sc/source/filter/rtf/rtfparse.cxx
index fa41c43..48a9396 100644
--- a/sc/source/filter/rtf/rtfparse.cxx
+++ b/sc/source/filter/rtf/rtfparse.cxx
@@ -222,9 +222,9 @@ void ScRTFParser::NewCellRow( ImportInfo* /*pInfo*/ )
             }
         }
         // Build up TwipCols only after nLastWidth comparison!
-        for ( size_t i = 0, n = maDefaultList.size(); i < n; ++i )
+        for (std::unique_ptr<ScRTFCellDefault> & pCellDefault : maDefaultList)
         {
-            const ScRTFCellDefault& rD = *maDefaultList[i].get();
+            const ScRTFCellDefault& rD = *pCellDefault.get();
             SCCOL nCol;
             if ( !SeekTwips(rD.nTwips, &nCol) )
                 pColTwips->insert( rD.nTwips );
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 2c33b96..9042eb6 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -706,9 +706,9 @@ void ScXMLExport::GetAreaLinks( ScMyAreaLinksContainer& rAreaLinks )
     if (pDoc->GetLinkManager())
     {
         const sfx2::SvBaseLinks& rLinks = pDoc->GetLinkManager()->GetLinks();
-        for (size_t i = 0; i < rLinks.size(); i++)
+        for (const auto & rLink : rLinks)
         {
-            ScAreaLink *pLink = dynamic_cast<ScAreaLink*>(rLinks[i].get());
+            ScAreaLink *pLink = dynamic_cast<ScAreaLink*>(rLink.get());
             if (pLink)
             {
                 ScMyAreaLink aAreaLink;
diff --git a/sc/source/filter/xml/xmlfonte.cxx b/sc/source/filter/xml/xmlfonte.cxx
index 40a9af7..9d39d60 100644
--- a/sc/source/filter/xml/xmlfonte.cxx
+++ b/sc/source/filter/xml/xmlfonte.cxx
@@ -103,9 +103,8 @@ ScXMLFontAutoStylePool_Impl::ScXMLFontAutoStylePool_Impl(ScXMLExport& rExportP,
             {
                 const SfxItemPool& rPagePool(pStyle->GetPool().GetPool());
 
-                for (sal_uInt8 j = 0; j < 4; ++j)
+                for (sal_uInt16 nPageWhichId : aPageWhichIds)
                 {
-                    sal_uInt16 nPageWhichId(aPageWhichIds[j]);
                     sal_uInt32 nPageHFItems(rPagePool.GetItemCount2(nPageWhichId));
                     for (sal_uInt32 k = 0; k < nPageHFItems; ++k)
                     {
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index 2701b9c..ea8bacf 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -2113,11 +2113,11 @@ ScXMLImport::ScXMLImport(
         { XML_CURRENCY,     util::NumberFormat::CURRENCY },
         { XML_BOOLEAN,      util::NumberFormat::LOGICAL }
     };
-    for (size_t i = 0; i < SAL_N_ELEMENTS(aCellTypePairs); ++i)
+    for (const auto & aCellTypePair : aCellTypePairs)
     {
         aCellTypeMap.insert(
             CellTypeMap::value_type(
-                GetXMLToken(aCellTypePairs[i]._token), aCellTypePairs[i]._type));
+                GetXMLToken(aCellTypePair._token), aCellTypePair._type));
     }
 }
 
diff --git a/sc/source/ui/dbgui/dpgroupdlg.cxx b/sc/source/ui/dbgui/dpgroupdlg.cxx
index 214cf16..6ade3f4 100644
--- a/sc/source/ui/dbgui/dpgroupdlg.cxx
+++ b/sc/source/ui/dbgui/dpgroupdlg.cxx
@@ -228,8 +228,8 @@ ScDPDateGroupDlg::ScDPDateGroupDlg( vcl::Window* pParent,
     maEndHelper     ( mpRbAutoEnd, mpRbManEnd, mpEdEnd, rNullDate )
 {
     static const size_t nCount = SAL_N_ELEMENTS( nDatePartResIds );
-    for( size_t nIdx = 0 ; nIdx < nCount; ++nIdx )
-        mpLbUnits->InsertEntry( ScGlobal::GetRscString( nDatePartResIds[nIdx] ) );
+    for(sal_uInt16 nDatePartResId : nDatePartResIds)
+        mpLbUnits->InsertEntry( ScGlobal::GetRscString( nDatePartResId ) );
 
     mpEdStart->SetShowDateCentury( true );
     mpEdEnd->SetShowDateCentury( true );
diff --git a/sc/source/ui/docshell/datastream.cxx b/sc/source/ui/docshell/datastream.cxx
index 8440c71..cee5227 100644
--- a/sc/source/ui/docshell/datastream.cxx
+++ b/sc/source/ui/docshell/datastream.cxx
@@ -234,9 +234,8 @@ private:
             }
 
             // Read & store new lines from stream.
-            for (size_t i = 0, n = pLines->size(); i < n; ++i)
+            for (DataStream::Line & rLine : *pLines)
             {
-                DataStream::Line& rLine = (*pLines)[i];
                 rLine.maCells.clear();
                 mpStream->ReadLine(rLine.maLine);
 #if ENABLE_ORCUS
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index e7918c6..398a761 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -3432,10 +3432,10 @@ bool ScDocFunc::SetWidthOrHeight(
     bool bShow = nSizeTwips > 0 || eMode != SC_SIZE_DIRECT;
     bool bOutline = false;
 
-    for (size_t i = 0, n = rRanges.size(); i < n; ++i)
+    for (const sc::ColRowSpan& rRange : rRanges)
     {
-        SCCOLROW nStartNo = rRanges[i].mnStart;
-        SCCOLROW nEndNo   = rRanges[i].mnEnd;
+        SCCOLROW nStartNo = rRange.mnStart;
+        SCCOLROW nEndNo   = rRange.mnEnd;
 
         if ( !bWidth )                      // Hoehen immer blockweise
         {
diff --git a/sc/source/ui/docshell/documentlinkmgr.cxx b/sc/source/ui/docshell/documentlinkmgr.cxx
index 3b17a66..02f00e9 100644
--- a/sc/source/ui/docshell/documentlinkmgr.cxx
+++ b/sc/source/ui/docshell/documentlinkmgr.cxx
@@ -98,9 +98,9 @@ bool DocumentLinkManager::idleCheckLinks()
 
     bool bAnyLeft = false;
     const sfx2::SvBaseLinks& rLinks = mpImpl->mpLinkManager->GetLinks();
-    for (size_t i = 0, n = rLinks.size(); i < n; ++i)
+    for (const auto & rLink : rLinks)
     {
-        sfx2::SvBaseLink* pBase = rLinks[i].get();
+        sfx2::SvBaseLink* pBase = rLink.get();
         ScDdeLink* pDdeLink = dynamic_cast<ScDdeLink*>(pBase);
         if (!pDdeLink || !pDdeLink->NeedsUpdate())
             continue;
@@ -119,9 +119,9 @@ bool DocumentLinkManager::hasDdeLinks() const
         return false;
 
     const sfx2::SvBaseLinks& rLinks = mpImpl->mpLinkManager->GetLinks();
-    for (size_t i = 0, n = rLinks.size(); i < n; ++i)
+    for (const auto & rLink : rLinks)
     {
-        sfx2::SvBaseLink* pBase = rLinks[i].get();
+        sfx2::SvBaseLink* pBase = rLink.get();
         if (dynamic_cast<ScDdeLink*>(pBase))
             return true;
     }
@@ -140,9 +140,9 @@ bool DocumentLinkManager::updateDdeLinks( vcl::Window* pWin )
     // If the update takes longer, reset all values so that nothing
     // old (wrong) is left behind
     bool bAny = false;
-    for (size_t i = 0, n = rLinks.size(); i < n; ++i)
+    for (const auto & rLink : rLinks)
     {
-        sfx2::SvBaseLink* pBase = rLinks[i].get();
+        sfx2::SvBaseLink* pBase = rLink.get();
         ScDdeLink* pDdeLink = dynamic_cast<ScDdeLink*>(pBase);
         if (!pDdeLink)
             continue;
@@ -183,9 +183,9 @@ void DocumentLinkManager::updateDdeLink( const OUString& rAppl, const OUString&
     sfx2::LinkManager* pMgr = mpImpl->mpLinkManager.get();
     const sfx2::SvBaseLinks& rLinks = pMgr->GetLinks();
 
-    for (size_t i = 0, n = rLinks.size(); i < n; ++i)
+    for (const auto & rLink : rLinks)
     {
-        ::sfx2::SvBaseLink* pBase = rLinks[i].get();
+        ::sfx2::SvBaseLink* pBase = rLink.get();
         ScDdeLink* pDdeLink = dynamic_cast<ScDdeLink*>(pBase);
         if (!pDdeLink)
             continue;
@@ -207,9 +207,9 @@ size_t DocumentLinkManager::getDdeLinkCount() const
 
     size_t nDdeCount = 0;
     const sfx2::SvBaseLinks& rLinks = mpImpl->mpLinkManager->GetLinks();
-    for (size_t i = 0, n = rLinks.size(); i < n; ++i)
+    for (const auto & rLink : rLinks)
     {
-        ::sfx2::SvBaseLink* pBase = rLinks[i].get();
+        ::sfx2::SvBaseLink* pBase = rLink.get();
         ScDdeLink* pDdeLink = dynamic_cast<ScDdeLink*>(pBase);
         if (!pDdeLink)
             continue;
@@ -226,9 +226,9 @@ void DocumentLinkManager::disconnectDdeLinks()
         return;
 
     const sfx2::SvBaseLinks& rLinks = mpImpl->mpLinkManager->GetLinks();
-    for (size_t i = 0, n = rLinks.size(); i < n; ++i)
+    for (const auto & rLink : rLinks)
     {
-        ::sfx2::SvBaseLink* pBase = rLinks[i].get();
+        ::sfx2::SvBaseLink* pBase = rLink.get();
         ScDdeLink* pDdeLink = dynamic_cast<ScDdeLink*>(pBase);
         if (pDdeLink)
             pDdeLink->Disconnect();
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index 87d51ee..471ff00 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -1312,9 +1312,8 @@ void ScExternalRefCache::clearCacheTables(sal_uInt16 nFileId)
 
     // Clear all cache table content, but keep the tables.
     std::vector<TableTypeRef>& rTabs = pDocItem->maTables;
-    for (size_t i = 0, n = rTabs.size(); i < n; ++i)
+    for (TableTypeRef & pTab : rTabs)
     {
-        TableTypeRef pTab = rTabs[i];
         if (!pTab)
             continue;
 
diff --git a/sc/source/ui/miscdlgs/optsolver.cxx b/sc/source/ui/miscdlgs/optsolver.cxx
index 596fc8a..d8276e0 100644
--- a/sc/source/ui/miscdlgs/optsolver.cxx
+++ b/sc/source/ui/miscdlgs/optsolver.cxx
@@ -367,9 +367,9 @@ void ScOptSolverDlg::Init(const ScAddress& rCursorPos)
     uno::Reference<frame::XFrame> xFrame = GetBindings().GetActiveFrame();
     Image aDelNm = ::GetImage( xFrame, aSlotURL, false );
 
-    for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+    for (VclPtr<PushButton> & pButton : mpDelButton)
     {
-        mpDelButton[nRow]->SetModeImage( aDelNm );
+        pButton->SetModeImage( aDelNm );
     }
 
     m_pBtnOpt->SetClickHdl( LINK( this, ScOptSolverDlg, BtnHdl ) );
diff --git a/sc/source/ui/pagedlg/areasdlg.cxx b/sc/source/ui/pagedlg/areasdlg.cxx
index b0e2632..324eeea 100644
--- a/sc/source/ui/pagedlg/areasdlg.cxx
+++ b/sc/source/ui/pagedlg/areasdlg.cxx
@@ -146,11 +146,11 @@ void ScPrintAreasDlg::dispose()
     // Extra-Data an ListBox-Entries abraeumen
     ListBox* aLb[3] = { pLbPrintArea, pLbRepeatRow, pLbRepeatCol };
 
-    for (sal_uInt16 i = 0; i < SAL_N_ELEMENTS(aLb); ++i)
+    for (ListBox* pBox : aLb)
     {
-        const sal_Int32 nCount = aLb[i]->GetEntryCount();
+        const sal_Int32 nCount = pBox->GetEntryCount();
         for ( sal_Int32 j=0; j<nCount; j++ )
-            delete static_cast<OUString*>(aLb[i]->GetEntryData(j));
+            delete static_cast<OUString*>(pBox->GetEntryData(j));
     }
     pLbPrintArea.clear();
     pEdPrintArea.clear();
diff --git a/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx b/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx
index 13f0f53..10d0c18 100644
--- a/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx
+++ b/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx
@@ -257,9 +257,9 @@ void NumberFormatPropertyPanel::NotifyItemUpdate(
                 OUString aCode = pItem->GetValue();
                 sal_Int32 nIndex = 0;
                 sal_Int32 aFormat[4] = {0};
-                for (size_t i=0; i<SAL_N_ELEMENTS(aFormat); ++i)
+                for (sal_Int32 & rn : aFormat)
                 {
-                    aFormat[i] = aCode.getToken(0, ',', nIndex).toInt32();
+                    rn = aCode.getToken(0, ',', nIndex).toInt32();
                     if (nIndex<0)
                         break;
                 }
diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx
index 2dbdb4d..41a5a83 100644
--- a/sc/source/ui/undo/undocell.cxx
+++ b/sc/source/ui/undo/undocell.cxx
@@ -56,9 +56,9 @@ namespace HelperNotifyChanges
         {
             ScRangeList aChangeRanges;
 
-            for (size_t i = 0, n = rOldValues.size(); i < n; ++i)
+            for (const auto & rOldValue : rOldValues)
             {
-                aChangeRanges.Append( ScRange(rPos.Col(), rPos.Row(), rOldValues[i].mnTab));
+                aChangeRanges.Append( ScRange(rPos.Col(), rPos.Row(), rOldValue.mnTab));
             }
 
             Notify(*pModelObj, aChangeRanges, "cell-change");
@@ -199,8 +199,8 @@ OUString ScUndoEnterData::GetComment() const
 void ScUndoEnterData::DoChange() const
 {
     // only when needed (old or new Edit cell, or Attribute)?
-    for (size_t i = 0, n = maOldValues.size(); i < n; ++i)
-        pDocShell->AdjustRowHeight(maPos.Row(), maPos.Row(), maOldValues[i].mnTab);
+    for (const auto & i : maOldValues)
+        pDocShell->AdjustRowHeight(maPos.Row(), maPos.Row(), i.mnTab);
 
     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
     if (pViewShell)
@@ -219,13 +219,13 @@ void ScUndoEnterData::SetChangeTrack()
     {
         mnEndChangeAction = pChangeTrack->GetActionMax() + 1;
         ScAddress aPos(maPos);
-        for (size_t i = 0, n = maOldValues.size(); i < n; ++i)
+        for (Value & rOldValue : maOldValues)
         {
-            aPos.SetTab(maOldValues[i].mnTab);
+            aPos.SetTab(rOldValue.mnTab);
             sal_uLong nFormat = 0;
-            if (maOldValues[i].mbHasFormat)
-                nFormat = maOldValues[i].mnFormat;
-            pChangeTrack->AppendContent(aPos, maOldValues[i].maCell, nFormat);
+            if (rOldValue.mbHasFormat)
+                nFormat = rOldValue.mnFormat;
+            pChangeTrack->AppendContent(aPos, rOldValue.maCell, nFormat);
         }
         if ( mnEndChangeAction > pChangeTrack->GetActionMax() )
             mnEndChangeAction = 0;       // nothing is appended
@@ -239,9 +239,8 @@ void ScUndoEnterData::Undo()
     BeginUndo();
 
     ScDocument& rDoc = pDocShell->GetDocument();
-    for (size_t i = 0, n = maOldValues.size(); i < n; ++i)
+    for (Value & rVal : maOldValues)
     {
-        Value& rVal = maOldValues[i];
         ScCellValue aNewCell;
         aNewCell.assign(rVal.maCell, rDoc, SC_CLONECELL_STARTLISTENING);
         ScAddress aPos = maPos;
@@ -276,9 +275,9 @@ void ScUndoEnterData::Redo()
     BeginRedo();
 
     ScDocument& rDoc = pDocShell->GetDocument();
-    for (size_t i = 0, n = maOldValues.size(); i < n; ++i)
+    for (Value & rOldValue : maOldValues)
     {
-        SCTAB nTab = maOldValues[i].mnTab;
+        SCTAB nTab = rOldValue.mnTab;
         if (mpNewEditData)
         {
             ScAddress aPos = maPos;
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 4a3c984..1247ab21 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -1611,8 +1611,8 @@ void ScCellRangesBase::Notify( SfxBroadcaster&, const SfxHint& rHint )
 
                 lang::EventObject aEvent;
                 aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
-                for ( size_t n=0; n<aValueListeners.size(); n++ )
-                    aValueListeners[n]->disposing( aEvent );
+                for (uno::Reference<util::XModifyListener> & xValueListener : aValueListeners)
+                    xValueListener->disposing( aEvent );
 
                 aValueListeners.clear();
 
@@ -1641,8 +1641,8 @@ void ScCellRangesBase::Notify( SfxBroadcaster&, const SfxHint& rHint )
                 // the EventObject holds a Ref to this object until after the listener calls
 
                 ScDocument& rDoc = pDocShell->GetDocument();
-                for ( size_t n=0; n<aValueListeners.size(); n++ )
-                    rDoc.AddUnoListenerCall( aValueListeners[n], aEvent );
+                for (uno::Reference<util::XModifyListener> & xValueListener : aValueListeners)
+                    rDoc.AddUnoListenerCall( xValueListener, aEvent );
 
                 bGotDataChangedHint = false;
             }
@@ -4525,12 +4525,12 @@ static bool lcl_FindRangeOrEntry( const ScNamedEntryArr_Impl& rNamedEntries,
 
     if ( !rNamedEntries.empty() )
     {
-        for ( size_t n=0; n<rNamedEntries.size(); n++ )
-            if ( rNamedEntries[n].GetName() == rName )
+        for (const auto & rNamedEntry : rNamedEntries)
+            if ( rNamedEntry.GetName() == rName )
             {
                 //  test if named entry is contained in rRanges
 
-                const ScRange& rComp = rNamedEntries[n].GetRange();
+                const ScRange& rComp = rNamedEntry.GetRange();
                 ScMarkData aMarkData;
                 aMarkData.MarkFromRangeList( rRanges, false );
                 aMarkData.MarkToMulti();        // needed for IsAllMarked
diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx
index 529fda2..afe109d 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -2834,8 +2834,8 @@ void ScChart2DataSequence::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint
 
                 if( m_pDocument )
                 {
-                    for ( size_t n=0; n<m_aValueListeners.size(); n++ )
-                        m_pDocument->AddUnoListenerCall( m_aValueListeners[n], aEvent );
+                    for (uno::Reference<util::XModifyListener> & xListener: m_aValueListeners)
+                        m_pDocument->AddUnoListenerCall( xListener, aEvent );
                 }
 
                 m_bGotDataChangedHint = false;
diff --git a/sc/source/ui/unoobj/condformatuno.cxx b/sc/source/ui/unoobj/condformatuno.cxx
index 5fce4c2..b598649 100644
--- a/sc/source/ui/unoobj/condformatuno.cxx
+++ b/sc/source/ui/unoobj/condformatuno.cxx
@@ -767,11 +767,11 @@ void SAL_CALL ScConditionEntryObj::setPropertyValue(
             sal_Int32 nVal;
             if (aValue >>= nVal)
             {
-                for (size_t i = 0; i < SAL_N_ELEMENTS(aConditionEntryMap); ++i)
+                for (ConditionEntryApiMap & rEntry : aConditionEntryMap)
                 {
-                    if (aConditionEntryMap[i].nApiMode == nVal)
+                    if (rEntry.nApiMode == nVal)
                     {
-                        getCoreObject()->SetOperation(aConditionEntryMap[i].eMode);
+                        getCoreObject()->SetOperation(rEntry.eMode);
                         break;
                     }
                 }
@@ -817,11 +817,11 @@ uno::Any SAL_CALL ScConditionEntryObj::getPropertyValue( const OUString& aProper
         case Operator:
         {
             ScConditionMode eMode = getCoreObject()->GetOperation();
-            for (size_t i = 0; i < SAL_N_ELEMENTS(aConditionEntryMap); ++i)
+            for (ConditionEntryApiMap & rEntry : aConditionEntryMap)
             {
-                if (aConditionEntryMap[i].eMode == eMode)
+                if (rEntry.eMode == eMode)
                 {
-                    aAny <<= aConditionEntryMap[i].nApiMode;
+                    aAny <<= rEntry.nApiMode;
                     break;
                 }
             }
@@ -907,11 +907,11 @@ void setColorScaleEntry(ScColorScaleEntry* pEntry, uno::Reference<sheet::XColorS
     ScColorScaleEntryType eType = ScColorScaleEntryType();
     sal_Int32 nApiType = xEntry->getType();
     bool bFound = false;
-    for (size_t i = 0; i < SAL_N_ELEMENTS(aColorScaleEntryTypeMap); ++i)
+    for (ColorScaleEntryTypeApiMap & rEntry : aColorScaleEntryTypeMap)
     {
-        if (aColorScaleEntryTypeMap[i].nApiType == nApiType)
+        if (rEntry.nApiType == nApiType)
         {
-            eType = aColorScaleEntryTypeMap[i].eType;
+            eType = rEntry.eType;
             bFound = true;
             break;
         }
@@ -1078,11 +1078,11 @@ sal_Int32 ScColorScaleEntryObj::getType()
     throw(uno::RuntimeException, std::exception)
 {
     ScColorScaleEntry* pEntry = getCoreObject();
-    for (size_t i = 0; i < SAL_N_ELEMENTS(aColorScaleEntryTypeMap); ++i)
+    for (ColorScaleEntryTypeApiMap & rEntry : aColorScaleEntryTypeMap)
     {
-        if (aColorScaleEntryTypeMap[i].eType == pEntry->GetType())
+        if (rEntry.eType == pEntry->GetType())
         {
-            return aColorScaleEntryTypeMap[i].nApiType;
+            return rEntry.nApiType;
         }
     }
 
@@ -1093,11 +1093,11 @@ void ScColorScaleEntryObj::setType(sal_Int32 nType)
     throw(uno::RuntimeException, std::exception)
 {
     ScColorScaleEntry* pEntry = getCoreObject();
-    for (size_t i = 0; i < SAL_N_ELEMENTS(aColorScaleEntryTypeMap); ++i)
+    for (ColorScaleEntryTypeApiMap & rEntry : aColorScaleEntryTypeMap)
     {
-        if (aColorScaleEntryTypeMap[i].nApiType == nType)
+        if (rEntry.nApiType == nType)
         {
-            pEntry->SetType(aColorScaleEntryTypeMap[i].eType);
+            pEntry->SetType(rEntry.eType);
             return;
         }
     }
@@ -1180,11 +1180,11 @@ void setDataBarEntry(ScColorScaleEntry* pEntry, uno::Reference<sheet::XDataBarEn
     ScColorScaleEntryType eType = ScColorScaleEntryType();
     sal_Int32 nApiType = xEntry->getType();
     bool bFound = false;
-    for (size_t i = 0; i < SAL_N_ELEMENTS(aDataBarEntryTypeMap); ++i)
+    for (DataBarEntryTypeApiMap & rEntry : aDataBarEntryTypeMap)
     {
-        if (aDataBarEntryTypeMap[i].nApiType == nApiType)
+        if (rEntry.nApiType == nApiType)
         {
-            eType = aDataBarEntryTypeMap[i].eType;
+            eType = rEntry.eType;
             bFound = true;
             break;
         }
@@ -1230,12 +1230,12 @@ void SAL_CALL ScDataBarFormatObj::setPropertyValue(
             sal_Int32 nVal;
             if (aValue >>= nVal)
             {
-                for (size_t i = 0; i < SAL_N_ELEMENTS(aDataBarAxisMap); ++i)
+                for (DataBarAxisApiMap & rEntry : aDataBarAxisMap)
                 {
-                    if (aDataBarAxisMap[i].nApiPos == nVal)
+                    if (rEntry.nApiPos == nVal)
                     {
                         getCoreObject()->GetDataBarData()->meAxisPosition =
-                            aDataBarAxisMap[i].ePos;
+                            rEntry.ePos;
                         break;
                     }
                 }
@@ -1360,11 +1360,11 @@ uno::Any SAL_CALL ScDataBarFormatObj::getPropertyValue( const OUString& aPropert
         {
             databar::ScAxisPosition ePos = getCoreObject()->GetDataBarData()->meAxisPosition;
             sal_Int32 nApiPos = sheet::DataBarAxis::AXIS_NONE;
-            for (size_t i = 0; i < SAL_N_ELEMENTS(aDataBarAxisMap); ++i)
+            for (DataBarAxisApiMap & rEntry : aDataBarAxisMap)
             {
-                if (aDataBarAxisMap[i].ePos == ePos)
+                if (rEntry.ePos == ePos)
                 {
-                    nApiPos = aDataBarAxisMap[i].nApiPos;
+                    nApiPos = rEntry.nApiPos;
                 }
             }
 
@@ -1478,11 +1478,11 @@ sal_Int32 ScDataBarEntryObj::getType()
     throw(uno::RuntimeException, std::exception)
 {
     ScColorScaleEntry* pEntry = getCoreObject();
-    for (size_t i = 0; i < SAL_N_ELEMENTS(aDataBarEntryTypeMap); ++i)
+    for (DataBarEntryTypeApiMap & rEntry : aDataBarEntryTypeMap)
     {
-        if (aDataBarEntryTypeMap[i].eType == pEntry->GetType())
+        if (rEntry.eType == pEntry->GetType())
         {
-            return aDataBarEntryTypeMap[i].nApiType;
+            return rEntry.nApiType;
         }
     }
 
@@ -1493,11 +1493,11 @@ void ScDataBarEntryObj::setType(sal_Int32 nType)
     throw(uno::RuntimeException, std::exception)
 {
     ScColorScaleEntry* pEntry = getCoreObject();
-    for (size_t i = 0; i < SAL_N_ELEMENTS(aDataBarEntryTypeMap); ++i)
+    for (DataBarEntryTypeApiMap & rEntry : aDataBarEntryTypeMap)
     {
-        if (aDataBarEntryTypeMap[i].nApiType == nType)
+        if (rEntry.nApiType == nType)
         {
-            pEntry->SetType(aDataBarEntryTypeMap[i].eType);
+            pEntry->SetType(rEntry.eType);
             return;
         }
     }
@@ -1581,11 +1581,11 @@ void setIconSetEntry(ScIconSetFormat* pFormat, uno::Reference<sheet::XIconSetEnt
     ScColorScaleEntryType eType = ScColorScaleEntryType();
     sal_Int32 nApiType = xEntry->getType();
     bool bFound = false;
-    for (size_t i = 0; i < SAL_N_ELEMENTS(aIconSetEntryTypeMap); ++i)
+    for (IconSetEntryTypeApiMap & rEntry : aIconSetEntryTypeMap)
     {
-        if (aIconSetEntryTypeMap[i].nApiType == nApiType)
+        if (rEntry.nApiType == nApiType)
         {
-            eType = aIconSetEntryTypeMap[i].eType;
+            eType = rEntry.eType;
             bFound = true;
             break;
         }
@@ -1646,11 +1646,11 @@ void SAL_CALL ScIconSetFormatObj::setPropertyValue(
             aValue >>= nApiType;
             ScIconSetType eType = IconSet_3Arrows;
             bool bFound = false;
-            for (size_t i = 0; i < SAL_N_ELEMENTS(aIconSetApiMap); ++i)
+            for (const IconSetTypeApiMap & rEntry : aIconSetApiMap)
             {
-                if (aIconSetApiMap[i].nApiType == nApiType)
+                if (rEntry.nApiType == nApiType)
                 {
-                    eType = aIconSetApiMap[i].eType;
+                    eType = rEntry.eType;
                     bFound = true;
                     break;
                 }
@@ -1711,11 +1711,11 @@ uno::Any SAL_CALL ScIconSetFormatObj::getPropertyValue( const OUString& aPropert
         case Icons:
         {
             ScIconSetType eType = getCoreObject()->GetIconSetData()->eIconSetType;
-            for (size_t i = 0; i < SAL_N_ELEMENTS(aIconSetApiMap); ++i)
+            for (const IconSetTypeApiMap & rEntry : aIconSetApiMap)
             {
-                if (aIconSetApiMap[i].eType == eType)
+                if (rEntry.eType == eType)
                 {
-                    aAny <<= aIconSetApiMap[i].nApiType;
+                    aAny <<= rEntry.nApiType;
                     break;
                 }
             }
@@ -1798,11 +1798,11 @@ sal_Int32 ScIconSetEntryObj::getType()
     if (mnPos == 0)
         return sheet::IconSetFormatEntry::ICONSET_MIN;
 
-    for (size_t i = 0; i < SAL_N_ELEMENTS(aIconSetEntryTypeMap); ++i)
+    for (IconSetEntryTypeApiMap & rEntry : aIconSetEntryTypeMap)
     {
-        if (aIconSetEntryTypeMap[i].eType == pEntry->GetType())
+        if (rEntry.eType == pEntry->GetType())
         {
-            return aIconSetEntryTypeMap[i].nApiType;
+            return rEntry.nApiType;
         }
     }
 
@@ -1817,11 +1817,11 @@ void ScIconSetEntryObj::setType(sal_Int32 nType)
         return;
 
     ScColorScaleEntry* pEntry = getCoreObject();
-    for (size_t i = 0; i < SAL_N_ELEMENTS(aIconSetEntryTypeMap); ++i)
+    for (IconSetEntryTypeApiMap & rEntry : aIconSetEntryTypeMap)
     {
-        if (aIconSetEntryTypeMap[i].nApiType == nType)
+        if (rEntry.nApiType == nType)
         {
-            pEntry->SetType(aIconSetEntryTypeMap[i].eType);
+            pEntry->SetType(rEntry.eType);
             return;
         }
     }
@@ -1928,11 +1928,11 @@ void SAL_CALL ScCondDateFormatObj::setPropertyValue(
             if (!(aValue >>= nApiType))
                 throw lang::IllegalArgumentException();
 
-            for (size_t i = 0; i < SAL_N_ELEMENTS(aDateTypeApiMap); ++i)
+            for (DateTypeApiMap & rEntry : aDateTypeApiMap)
             {
-                if (aDateTypeApiMap[i].nApiType == nApiType)
+                if (rEntry.nApiType == nApiType)
                 {
-                    getCoreObject()->SetDateType(aDateTypeApiMap[i].eType);
+                    getCoreObject()->SetDateType(rEntry.eType);
                     break;
                 }
             }
@@ -1967,11 +1967,11 @@ uno::Any SAL_CALL ScCondDateFormatObj::getPropertyValue( const OUString& aProper
         case DateType:
         {
             condformat::ScCondFormatDateType eType = getCoreObject()->GetDateType();
-            for (size_t i = 0; i < SAL_N_ELEMENTS(aDateTypeApiMap); ++i)
+            for (DateTypeApiMap & rEntry : aDateTypeApiMap)
             {
-                if (aDateTypeApiMap[i].eType == eType)
+                if (rEntry.eType == eType)
                 {
-                    aAny <<= aDateTypeApiMap[i].nApiType;
+                    aAny <<= rEntry.nApiType;
                     break;
                 }
             }
diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx
index f19bb88..646ddac 100644
--- a/sc/source/ui/unoobj/dapiuno.cxx
+++ b/sc/source/ui/unoobj/dapiuno.cxx
@@ -1369,8 +1369,8 @@ void ScDataPilotTableObj::Refreshed_Impl()
     // the EventObject holds a Ref to this object until after the listener calls
 
     ScDocument& rDoc = GetDocShell()->GetDocument();
-    for ( size_t n=0; n<aModifyListeners.size(); n++ )
-        rDoc.AddUnoListenerCall( aModifyListeners[n], aEvent );
+    for (uno::Reference<util::XModifyListener> & xModifyListener : aModifyListeners)
+        rDoc.AddUnoListenerCall( xModifyListener, aEvent );
 }
 
 ScDataPilotDescriptor::ScDataPilotDescriptor(ScDocShell* pDocSh) :
diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx
index ed79338..2772aa2 100644
--- a/sc/source/ui/unoobj/datauno.cxx
+++ b/sc/source/ui/unoobj/datauno.cxx
@@ -557,8 +557,8 @@ void SAL_CALL ScSubTotalDescriptorBase::clear() throw(uno::RuntimeException, std
     ScSubTotalParam aParam;
     GetData(aParam);
 
-    for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
-        aParam.bGroupActive[i] = false;
+    for (bool & rn : aParam.bGroupActive)
+        rn = false;
 
     //! Notify oder so fuer die Field-Objekte???
 
@@ -1953,8 +1953,8 @@ void ScDatabaseRangeObj::Refreshed_Impl()
 {
     lang::EventObject aEvent;
     aEvent.Source = static_cast<cppu::OWeakObject*>(this);
-    for ( size_t n=0; n<aRefreshListeners.size(); n++ )
-        aRefreshListeners[n]->refreshed( aEvent );
+    for (uno::Reference<util::XRefreshListener> & xRefreshListener : aRefreshListeners)
+        xRefreshListener->refreshed( aEvent );
 }
 
 // XCellRangeSource
diff --git a/sc/source/ui/unoobj/dispuno.cxx b/sc/source/ui/unoobj/dispuno.cxx
index 2785078..a285039 100644
--- a/sc/source/ui/unoobj/dispuno.cxx
+++ b/sc/source/ui/unoobj/dispuno.cxx
@@ -358,8 +358,8 @@ void SAL_CALL ScDispatch::selectionChanged( const css::lang::EventObject& /* aEv
 
             lcl_FillDataSource( aEvent, aNewImport );       // modifies State, IsEnabled
 
-            for ( size_t n=0; n<aDataSourceListeners.size(); n++ )
-                aDataSourceListeners[n]->statusChanged( aEvent );
+            for (uno::Reference<frame::XStatusListener> & xDataSourceListener : aDataSourceListeners)
+                xDataSourceListener->statusChanged( aEvent );
 
             aLastImport = aNewImport;
         }
@@ -377,8 +377,8 @@ void SAL_CALL ScDispatch::disposing( const css::lang::EventObject& rSource )
 
     lang::EventObject aEvent;
     aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
-    for ( size_t n=0; n<aDataSourceListeners.size(); n++ )
-        aDataSourceListeners[n]->disposing( aEvent );
+    for (uno::Reference<frame::XStatusListener> & xDataSourceListener : aDataSourceListeners)
+        xDataSourceListener->disposing( aEvent );
 
     pViewShell = nullptr;
 }
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index bf5292c..fbe2a19 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -328,10 +328,10 @@ void ScPrintUIOptions::SetDefaults()
     sal_Int32 nContent = rPrintOpt.GetAllSheets() ? 0 : 1;
     bool bSuppress = rPrintOpt.GetSkipEmpty();
 
-    for (size_t nUIPos=0; nUIPos<m_aUIProperties.size(); ++nUIPos)
+    for (beans::PropertyValue & rPropValue : m_aUIProperties)
     {
         uno::Sequence<beans::PropertyValue> aUIProp;
-        if ( m_aUIProperties[nUIPos].Value >>= aUIProp )
+        if ( rPropValue.Value >>= aUIProp )
         {
             for (sal_Int32 nPropPos=0; nPropPos<aUIProp.getLength(); ++nPropPos)
             {
@@ -354,7 +354,7 @@ void ScPrintUIOptions::SetDefaults()
                     }
                 }
             }
-            m_aUIProperties[nUIPos].Value <<= aUIProp;
+            rPropValue.Value <<= aUIProp;
         }
     }
 }
diff --git a/sc/source/ui/unoobj/linkuno.cxx b/sc/source/ui/unoobj/linkuno.cxx
index abe81aa..85e19f4 100644
--- a/sc/source/ui/unoobj/linkuno.cxx
+++ b/sc/source/ui/unoobj/linkuno.cxx
@@ -185,8 +185,8 @@ void ScSheetLinkObj::Refreshed_Impl()
 {
     lang::EventObject aEvent;
     aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
-    for ( size_t n=0; n<aRefreshListeners.size(); n++ )
-        aRefreshListeners[n]->refreshed( aEvent );
+    for (uno::Reference<util::XRefreshListener> & xRefreshListener : aRefreshListeners)
+        xRefreshListener->refreshed( aEvent );
 }
 
 void ScSheetLinkObj::ModifyRefreshDelay_Impl( sal_Int32 nRefresh )
@@ -728,8 +728,8 @@ void ScAreaLinkObj::Refreshed_Impl()
 {
     lang::EventObject aEvent;
     aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
-    for ( size_t n=0; n<aRefreshListeners.size(); n++ )
-        aRefreshListeners[n]->refreshed( aEvent );
+    for (uno::Reference<util::XRefreshListener> & xRefreshListener : aRefreshListeners)
+        xRefreshListener->refreshed( aEvent );
 }
 
 // XPropertySet
@@ -1219,8 +1219,8 @@ void ScDDELinkObj::Refreshed_Impl()
 {
     lang::EventObject aEvent;
     aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
-    for ( size_t n=0; n<aRefreshListeners.size(); n++ )
-        aRefreshListeners[n]->refreshed( aEvent );
+    for (uno::Reference<util::XRefreshListener> & xRefreshListener : aRefreshListeners)
+        xRefreshListener->refreshed( aEvent );
 }
 
 ScDDELinksObj::ScDDELinksObj(ScDocShell* pDocSh) :
diff --git a/sc/source/ui/unoobj/servuno.cxx b/sc/source/ui/unoobj/servuno.cxx
index 6d9a1db..0d242d7 100644
--- a/sc/source/ui/unoobj/servuno.cxx
+++ b/sc/source/ui/unoobj/servuno.cxx
@@ -366,21 +366,21 @@ ScServiceProvider::Type ScServiceProvider::GetProviderType(const OUString& rServ
 {
     if (!rServiceName.isEmpty())
     {
-        for (sal_uInt16 i = 0; i < SAL_N_ELEMENTS(aProvNamesId); i++)
+        for (const ProvNamesId_Type & i : aProvNamesId)
         {
-            if (rServiceName.equalsAscii( aProvNamesId[i].pName ))
+            if (rServiceName.equalsAscii( i.pName ))
             {
-                return aProvNamesId[i].nType;
+                return i.nType;
             }
         }
 
-        for (sal_uInt16 i=0; i < SAL_N_ELEMENTS(aOldNames); i++)
+        for (const ProvNamesId_Type & rOldName : aOldNames)
         {
-            OSL_ENSURE( aOldNames[i].pName, "ScServiceProvider::GetProviderType: no oldname => crash");
-            if (rServiceName.equalsAscii( aOldNames[i].pName ))
+            OSL_ENSURE( rOldName.pName, "ScServiceProvider::GetProviderType: no oldname => crash");
+            if (rServiceName.equalsAscii( rOldName.pName ))
             {
                 OSL_FAIL("old service name used");
-                return aOldNames[i].nType;
+                return rOldName.nType;
             }
         }
     }
diff --git a/sc/source/ui/unoobj/targuno.cxx b/sc/source/ui/unoobj/targuno.cxx
index 8512c86..5d714f6 100644
--- a/sc/source/ui/unoobj/targuno.cxx
+++ b/sc/source/ui/unoobj/targuno.cxx
@@ -114,8 +114,8 @@ uno::Sequence<OUString> SAL_CALL ScLinkTargetTypesObj::getElementNames() throw(
 
 sal_Bool SAL_CALL ScLinkTargetTypesObj::hasByName(const OUString& aName) throw( uno::RuntimeException, std::exception )
 {
-    for (sal_uInt16 i=0; i<SC_LINKTARGETTYPE_COUNT; i++)
-        if ( aNames[i] == aName )
+    for (const auto & i : aNames)
+        if ( i == aName )
             return true;
     return false;
 }
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index e781d5a..0abbfa9 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -6023,10 +6023,9 @@ void ScGridWindow::UpdateCursorOverlay()
                 std::vector< basegfx::B2DRange > aRanges;
                 const basegfx::B2DHomMatrix aTransform(GetInverseViewTransformation());
 
-                for(size_t a(0); a < aPixelRects.size(); a++)
+                for(const Rectangle & rRA : aPixelRects)
                 {
-                    const Rectangle aRA(aPixelRects[a]);
-                    basegfx::B2DRange aRB(aRA.Left(), aRA.Top(), aRA.Right() + 1, aRA.Bottom() + 1);
+                    basegfx::B2DRange aRB(rRA.Left(), rRA.Top(), rRA.Right() + 1, rRA.Bottom() + 1);
                     aRB.transform(aTransform);
                     aRanges.push_back(aRB);
                 }
@@ -6087,18 +6086,17 @@ void ScGridWindow::UpdateSelectionOverlay()
             SCTAB nTab = pViewData->GetTabNo();
             bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
 
-            for(size_t a(0); a < aPixelRects.size(); a++)
+            for(const Rectangle & rRA : aPixelRects)
             {
-                const Rectangle aRA(aPixelRects[a]);
                 if (bLayoutRTL)
                 {
-                    basegfx::B2DRange aRB(aRA.Left(), aRA.Top() - 1, aRA.Right() + 1, aRA.Bottom());
+                    basegfx::B2DRange aRB(rRA.Left(), rRA.Top() - 1, rRA.Right() + 1, rRA.Bottom());
                     aRB.transform(aTransform);
                     aRanges.push_back(aRB);
                 }
                 else
                 {
-                    basegfx::B2DRange aRB(aRA.Left() - 1, aRA.Top() - 1, aRA.Right(), aRA.Bottom());
+                    basegfx::B2DRange aRB(rRA.Left() - 1, rRA.Top() - 1, rRA.Right(), rRA.Bottom());
                     aRB.transform(aTransform);
                     aRanges.push_back(aRB);
                 }
@@ -6324,10 +6322,9 @@ void ScGridWindow::UpdateDragRectOverlay()
             std::vector< basegfx::B2DRange > aRanges;
             const basegfx::B2DHomMatrix aTransform(GetInverseViewTransformation());
 
-            for(size_t a(0); a < aPixelRects.size(); a++)
+            for(const Rectangle & rRA : aPixelRects)
             {
-                const Rectangle aRA(aPixelRects[a]);
-                basegfx::B2DRange aRB(aRA.Left(), aRA.Top(), aRA.Right() + 1, aRA.Bottom() + 1);
+                basegfx::B2DRange aRB(rRA.Left(), rRA.Top(), rRA.Right() + 1, rRA.Bottom() + 1);
                 aRB.transform(aTransform);
                 aRanges.push_back(aRB);
             }
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 9cd85e6..e4671f6 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -908,9 +908,9 @@ ScGridWindow* ScTabView::GetActiveWin()
 
 void ScTabView::SetActivePointer( const Pointer& rPointer )
 {
-    for (sal_uInt16 i=0; i<4; i++)
-        if (pGridWin[i])
-            pGridWin[i]->SetPointer( rPointer );
+    for (VclPtr<ScGridWindow> & pWin : pGridWin)
+        if (pWin)
+            pWin->SetPointer( rPointer );
 }
 
 void ScTabView::ActiveGrabFocus()
@@ -1516,12 +1516,12 @@ void ScTabView::UpdateShow()
 bool ScTabView::UpdateVisibleRange()
 {
     bool bChanged = false;
-    for (int i = 0; i < 4; ++i)
+    for (VclPtr<ScGridWindow> & pWin : pGridWin)
     {
-        if (!pGridWin[i] || !pGridWin[i]->IsVisible())
+        if (!pWin || !pWin->IsVisible())
             continue;
 
-        if (pGridWin[i]->UpdateVisibleRange())
+        if (pWin->UpdateVisibleRange())
             bChanged = true;
     }
 
@@ -1602,9 +1602,9 @@ void ScTabView::DoHSplit(long nSplitPos)
 
         // Form Layer needs to know the visible part of all windows
         // that is why MapMode must already be correct here
-        for (sal_uInt16 i=0; i<4; i++)
-            if (pGridWin[i])
-                pGridWin[i]->SetMapMode( pGridWin[i]->GetDrawMapMode() );
+        for (VclPtr<ScGridWindow> & pWin : pGridWin)
+            if (pWin)
+                pWin->SetMapMode( pWin->GetDrawMapMode() );
         SetNewVisArea();
 
         PaintGrid();
@@ -1674,9 +1674,9 @@ void ScTabView::DoVSplit(long nSplitPos)
 
         // Form Layer needs to know the visible part of all windows
         // that is why MapMode must already be correct here
-        for (sal_uInt16 i=0; i<4; i++)
-            if (pGridWin[i])
-                pGridWin[i]->SetMapMode( pGridWin[i]->GetDrawMapMode() );
+        for (VclPtr<ScGridWindow> & pWin : pGridWin)
+            if (pWin)
+                pWin->SetMapMode( pWin->GetDrawMapMode() );
         SetNewVisArea();
 
         PaintGrid();
@@ -2058,9 +2058,9 @@ void ScTabView::FreezeSplitters( bool bFreeze, SplitMethod eSplitMetod)
 
     // Form Layer needs to know the visible part of all windows
     // that is why MapMode must already be correct here
-    for (sal_uInt16 i=0; i<4; i++)
-        if (pGridWin[i])
-            pGridWin[i]->SetMapMode( pGridWin[i]->GetDrawMapMode() );
+    for (VclPtr<ScGridWindow> & p : pGridWin)
+        if (p)
+            p->SetMapMode( p->GetDrawMapMode() );
     SetNewVisArea();
 
     RepeatResize(false);
@@ -2258,12 +2258,12 @@ void ScTabView::EnableRefInput(bool bFlag)
 bool ScTabView::ContinueOnlineSpelling()
 {
     bool bChanged = false;
-    for (int i = 0; i < 4; ++i)
+    for (VclPtr<ScGridWindow> & pWin : pGridWin)
     {
-        if (!pGridWin[i] || !pGridWin[i]->IsVisible())
+        if (!pWin || !pWin->IsVisible())
             continue;
 
-        if (pGridWin[i]->ContinueOnlineSpelling())
+        if (pWin->ContinueOnlineSpelling())
             bChanged = true;
     }
 
@@ -2272,34 +2272,34 @@ bool ScTabView::ContinueOnlineSpelling()
 
 void ScTabView::EnableAutoSpell( bool bEnable )
 {
-    for (int i = 0; i < 4; ++i)
+    for (VclPtr<ScGridWindow> & pWin : pGridWin)
     {
-        if (!pGridWin[i])
+        if (!pWin)
             continue;
 
-        pGridWin[i]->EnableAutoSpell(bEnable);
+        pWin->EnableAutoSpell(bEnable);
     }
 }
 
 void ScTabView::ResetAutoSpell()
 {
-    for (int i = 0; i < 4; ++i)
+    for (VclPtr<ScGridWindow> & pWin : pGridWin)
     {
-        if (!pGridWin[i])
+        if (!pWin)
             continue;
 
-        pGridWin[i]->ResetAutoSpell();
+        pWin->ResetAutoSpell();
     }
 }
 
 void ScTabView::SetAutoSpellData( SCCOL nPosX, SCROW nPosY, const std::vector<editeng::MisspellRanges>* pRanges )
 {
-    for (int i = 0; i < 4; ++i)
+    for (VclPtr<ScGridWindow> & pWin: pGridWin)
     {
-        if (!pGridWin[i])
+        if (!pWin)
             continue;
 
-        pGridWin[i]->SetAutoSpellData(nPosX, nPosY, pRanges);
+        pWin->SetAutoSpellData(nPosX, nPosY, pRanges);
     }
 }
 
diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx
index 556390d..3468d08 100644
--- a/sc/source/ui/view/tabview2.cxx
+++ b/sc/source/ui/view/tabview2.cxx
@@ -977,30 +977,30 @@ void ScTabView::ExpandBlockArea(SCsCOL nMovX, SCsROW nMovY)
 
 void ScTabView::UpdateCopySourceOverlay()
 {
-    for (sal_uInt8 i = 0; i < 4; ++i)
-        if (pGridWin[i] && pGridWin[i]->IsVisible())
-            pGridWin[i]->UpdateCopySourceOverlay();
+    for (VclPtr<ScGridWindow> & pWin : pGridWin)
+        if (pWin && pWin->IsVisible())
+            pWin->UpdateCopySourceOverlay();
 }
 
 void ScTabView::UpdateSelectionOverlay()
 {
-    for (sal_uInt16 i=0; i<4; i++)
-        if ( pGridWin[i] && pGridWin[i]->IsVisible() )
-            pGridWin[i]->UpdateSelectionOverlay();
+    for (VclPtr<ScGridWindow> & pWin : pGridWin)
+        if ( pWin && pWin->IsVisible() )
+            pWin->UpdateSelectionOverlay();
 }
 
 void ScTabView::UpdateShrinkOverlay()
 {
-    for (sal_uInt16 i=0; i<4; i++)
-        if ( pGridWin[i] && pGridWin[i]->IsVisible() )
-            pGridWin[i]->UpdateShrinkOverlay();
+    for (VclPtr<ScGridWindow> & pWin : pGridWin)
+        if ( pWin && pWin->IsVisible() )
+            pWin->UpdateShrinkOverlay();
 }
 
 void ScTabView::UpdateAllOverlays()
 {
-    for (sal_uInt16 i=0; i<4; i++)
-        if ( pGridWin[i] && pGridWin[i]->IsVisible() )
-            pGridWin[i]->UpdateAllOverlays();
+    for (VclPtr<ScGridWindow> & pWin : pGridWin)
+        if ( pWin && pWin->IsVisible() )
+            pWin->UpdateAllOverlays();
 }
 
 //!
@@ -1384,9 +1384,9 @@ void ScTabView::StopMarking()
 
 void ScTabView::HideNoteMarker()
 {
-    for (sal_uInt16 i=0; i<4; i++)
-        if (pGridWin[i] && pGridWin[i]->IsVisible())
-            pGridWin[i]->HideNoteMarker();
+    for (VclPtr<ScGridWindow> & pWin : pGridWin)
+        if (pWin && pWin->IsVisible())
+            pWin->HideNoteMarker();
 }
 
 void ScTabView::MakeDrawLayer()
@@ -1398,11 +1398,11 @@ void ScTabView::MakeDrawLayer()
         // pDrawView is set per Notify
         OSL_ENSURE(pDrawView,"ScTabView::MakeDrawLayer does not work");
 
-        for(sal_uInt16 a(0); a < 4; a++)
+        for(VclPtr<ScGridWindow> & pWin : pGridWin)
         {
-            if(pGridWin[a])
+            if(pWin)
             {
-                pGridWin[a]->DrawLayerCreated();
+                pWin->DrawLayerCreated();
             }
         }
     }
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index d5b151e..acd14b2 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -152,27 +152,27 @@ void ScTabView::FakeButtonUp( ScSplitPos eWhich )
 
 void ScTabView::HideAllCursors()
 {
-    for (sal_uInt16 i=0; i<4; i++)
-        if (pGridWin[i])
-            if (pGridWin[i]->IsVisible())
+    for (VclPtr<ScGridWindow> & pWin : pGridWin)
+        if (pWin)
+            if (pWin->IsVisible())
             {
-                vcl::Cursor* pCur = pGridWin[i]->GetCursor();
+                vcl::Cursor* pCur = pWin->GetCursor();
                 if (pCur)
                     if (pCur->IsVisible())
                         pCur->Hide();
-                pGridWin[i]->HideCursor();
+                pWin->HideCursor();
             }
 }
 
 void ScTabView::ShowAllCursors()
 {
-    for (sal_uInt16 i=0; i<4; i++)
-        if (pGridWin[i])
-            if (pGridWin[i]->IsVisible())
+    for (VclPtr<ScGridWindow> & pWin : pGridWin)
+        if (pWin)
+            if (pWin->IsVisible())
             {
-                pGridWin[i]->ShowCursor();
+                pWin->ShowCursor();
 
-                pGridWin[i]->CursorChanged();
+                pWin->CursorChanged();
             }
 }
 
@@ -652,9 +652,9 @@ void ScTabView::TestHintWindow()
     else
         mpInputHintWindow.disposeAndClear();
 
-    for ( sal_uInt16 i=0; i<4; i++ )
-        if ( pGridWin[i] && pGridWin[i]->IsVisible() )
-            pGridWin[i]->UpdateListValPos( bListValButton, aListValPos );
+    for (VclPtr<ScGridWindow> & pWin : pGridWin)
+        if ( pWin && pWin->IsVisible() )
+            pWin->UpdateListValPos( bListValButton, aListValPos );
 }
 
 bool ScTabView::HasHintWindow() const
@@ -1710,9 +1710,9 @@ void ScTabView::SetTabNo( SCTAB nTab, bool bNew, bool bExtendSelection, bool bSa
 
         if ( bRefMode )     // hide EditView if necessary (after aViewData.SetTabNo !)
         {
-            for (sal_uInt16 i = 0; i < 4; ++i)
-                if (pGridWin[i] && pGridWin[i]->IsVisible())
-                    pGridWin[i]->UpdateEditViewPos();
+            for (VclPtr<ScGridWindow> & pWin : pGridWin)
+                if (pWin && pWin->IsVisible())
+                    pWin->UpdateEditViewPos();
         }
 
         TabChanged(bSameTabButMoved);                                       // DrawView
@@ -1774,9 +1774,9 @@ void ScTabView::SetTabNo( SCTAB nTab, bool bNew, bool bExtendSelection, bool bSa
 
         // Form Layer must know the visible area of the new sheet
         // that is why MapMode must already be correct here
-        for (sal_uInt16 i=0; i<4; i++)
-            if (pGridWin[i])
-                pGridWin[i]->SetMapMode( pGridWin[i]->GetDrawMapMode() );
+        for (VclPtr<ScGridWindow> & pWin : pGridWin)
+            if (pWin)
+                pWin->SetMapMode( pWin->GetDrawMapMode() );
         SetNewVisArea();
 
         PaintGrid();
@@ -2584,9 +2584,9 @@ void ScTabView::ActivatePart( ScSplitPos eWhich )
 
 void ScTabView::HideListBox()
 {
-    for (sal_uInt16 i=0; i<4; i++)
-        if (pGridWin[i])
-            pGridWin[i]->ClickExtern();
+    for (VclPtr<ScGridWindow> & pWin : pGridWin)
+        if (pWin)
+            pWin->ClickExtern();
 }
 
 void ScTabView::UpdateInputContext()
@@ -2686,8 +2686,8 @@ void ScTabView::CheckNeedsRepaint()
 
 bool ScTabView::NeedsRepaint()
 {
-    for (size_t i = 0; i < 4; i++)
-        if (pGridWin[i] && pGridWin[i]->IsVisible() && pGridWin[i]->NeedsRepaint())
+    for (VclPtr<ScGridWindow> & pWin : pGridWin)
+        if (pWin && pWin->IsVisible() && pWin->NeedsRepaint())
             return true;
     return false;
 }
diff --git a/sc/source/ui/view/tabview5.cxx b/sc/source/ui/view/tabview5.cxx
index 76b8562..6e5e3bf 100644
--- a/sc/source/ui/view/tabview5.cxx
+++ b/sc/source/ui/view/tabview5.cxx
@@ -504,9 +504,9 @@ void ScTabView::UpdateDrawTextOutliner()
 void ScTabView::DigitLanguageChanged()
 {
     LanguageType eNewLang = SC_MOD()->GetOptDigitLanguage();
-    for (sal_uInt16 i=0; i<4; i++)
-        if ( pGridWin[i] )
-            pGridWin[i]->SetDigitLanguage( eNewLang );
+    for (VclPtr<ScGridWindow> & pWin : pGridWin)
+        if ( pWin )
+            pWin->SetDigitLanguage( eNewLang );
 }
 
 void ScTabView::ScrollToObject( SdrObject* pDrawObj )
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index ed2414a..13bfe10 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -2656,9 +2656,9 @@ void ScViewFunc::MoveTable(
         if ( nErrVal > 0 )
         {
             nDestTab1 = nDestTab;

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list