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

Noel Grandin noel at peralex.com
Thu May 12 07:13:23 UTC 2016


 sw/source/core/access/accfrmobjmap.cxx                    |    8 -
 sw/source/core/bastyp/calc.cxx                            |    4 
 sw/source/core/bastyp/init.cxx                            |   10 -
 sw/source/core/crsr/viscrs.cxx                            |    8 -
 sw/source/core/doc/DocumentContentOperationsManager.cxx   |   15 --
 sw/source/core/doc/DocumentFieldsManager.cxx              |    6 
 sw/source/core/doc/DocumentLinksAdministrationManager.cxx |    4 
 sw/source/core/doc/DocumentRedlineManager.cxx             |   13 -
 sw/source/core/doc/DocumentStylePoolManager.cxx           |   14 -
 sw/source/core/doc/acmplwrd.cxx                           |    4 
 sw/source/core/doc/doc.cxx                                |    3 
 sw/source/core/doc/docbm.cxx                              |   12 -
 sw/source/core/doc/doccomp.cxx                            |    3 
 sw/source/core/doc/doccorr.cxx                            |    4 
 sw/source/core/doc/docdesc.cxx                            |    6 
 sw/source/core/doc/docedt.cxx                             |    3 
 sw/source/core/doc/docfld.cxx                             |    8 -
 sw/source/core/doc/docfmt.cxx                             |   11 -
 sw/source/core/doc/doclay.cxx                             |    3 
 sw/source/core/doc/docnum.cxx                             |    4 
 sw/source/core/doc/docredln.cxx                           |    6 
 sw/source/core/doc/doctxm.cxx                             |    6 
 sw/source/core/doc/number.cxx                             |   14 -
 sw/source/core/doc/sortopt.cxx                            |    4 
 sw/source/core/doc/tblafmt.cxx                            |    4 
 sw/source/core/doc/textboxhelper.cxx                      |    3 
 sw/source/core/docnode/ndtbl1.cxx                         |    6 
 sw/source/core/draw/dcontact.cxx                          |    8 -
 sw/source/core/draw/dview.cxx                             |    4 
 sw/source/core/frmedt/feshview.cxx                        |    3 
 sw/source/core/layout/anchoredobject.cxx                  |    9 -
 sw/source/core/layout/atrfrm.cxx                          |    3 
 sw/source/core/layout/calcmove.cxx                        |    3 
 sw/source/core/layout/flowfrm.cxx                         |    6 
 sw/source/core/layout/fly.cxx                             |    6 
 sw/source/core/layout/flycnt.cxx                          |    4 
 sw/source/core/layout/flylay.cxx                          |    6 
 sw/source/core/layout/frmtool.cxx                         |   38 ++---
 sw/source/core/layout/ftnfrm.cxx                          |    4 
 sw/source/core/layout/layact.cxx                          |   15 --
 sw/source/core/layout/laycache.cxx                        |    6 
 sw/source/core/layout/layouter.cxx                        |    3 
 sw/source/core/layout/objectformattertxtfrm.cxx           |    3 
 sw/source/core/layout/pagechg.cxx                         |   12 -
 sw/source/core/layout/paintfrm.cxx                        |   12 -
 sw/source/core/layout/sectfrm.cxx                         |   12 -
 sw/source/core/layout/tabfrm.cxx                          |   12 -
 sw/source/core/layout/trvlfrm.cxx                         |   15 --
 sw/source/core/layout/wsfrm.cxx                           |   26 +--
 sw/source/core/table/swtable.cxx                          |    3 
 sw/source/core/text/EnhancedPDFExportHelper.cxx           |   24 +--
 sw/source/core/text/atrstck.cxx                           |    4 
 sw/source/core/text/itrcrsr.cxx                           |    3 
 sw/source/core/text/porfld.cxx                            |    4 
 sw/source/core/text/porlay.cxx                            |    4 
 sw/source/core/text/redlnitr.cxx                          |    4 
 sw/source/core/text/txtfrm.cxx                            |   12 -
 sw/source/core/text/txtftn.cxx                            |    3 
 sw/source/core/text/wrong.cxx                             |   14 -
 sw/source/core/text/xmldump.cxx                           |    3 
 sw/source/core/tox/tox.cxx                                |    8 -
 sw/source/core/txtnode/ndtxt.cxx                          |   13 -
 sw/source/core/txtnode/txtedt.cxx                         |    6 
 sw/source/core/undo/undraw.cxx                            |   12 -
 sw/source/core/undo/unins.cxx                             |    3 
 sw/source/core/undo/unovwr.cxx                            |    4 
 sw/source/core/undo/unsort.cxx                            |   18 +-
 sw/source/core/undo/untbl.cxx                             |    6 
 sw/source/core/unocore/unocoll.cxx                        |   11 -
 sw/source/core/unocore/unofield.cxx                       |    4 
 sw/source/core/unocore/unoidx.cxx                         |    3 
 sw/source/core/unocore/unosect.cxx                        |    3 
 sw/source/core/unocore/unosett.cxx                        |    3 
 sw/source/core/view/viewsh.cxx                            |    3 
 sw/source/filter/basflt/fltini.cxx                        |    3 
 sw/source/filter/basflt/shellio.cxx                       |    4 
 sw/source/filter/html/htmlatr.cxx                         |   16 +-
 sw/source/filter/html/htmlcss1.cxx                        |   28 +--
 sw/source/filter/html/htmldrawreader.cxx                  |    3 
 sw/source/filter/html/htmlflywriter.cxx                   |    4 
 sw/source/filter/html/htmlform.cxx                        |    3 
 sw/source/filter/html/htmlgrin.cxx                        |    6 
 sw/source/filter/html/htmlplug.cxx                        |    6 
 sw/source/filter/html/htmltab.cxx                         |   11 -
 sw/source/filter/html/svxcss1.cxx                         |   18 +-
 sw/source/filter/html/wrthtml.cxx                         |    4 
 sw/source/filter/ww8/docxattributeoutput.cxx              |   14 -
 sw/source/filter/ww8/docxtablestyleexport.cxx             |    4 
 sw/source/filter/ww8/rtfattributeoutput.cxx               |   12 -
 sw/source/filter/ww8/rtfexport.cxx                        |   10 -
 sw/source/filter/ww8/writerwordglue.cxx                   |    8 -
 sw/source/filter/ww8/wrtw8esh.cxx                         |    8 -
 sw/source/filter/ww8/wrtw8nds.cxx                         |    4 
 sw/source/filter/ww8/wrtw8sty.cxx                         |   15 --
 sw/source/filter/ww8/wrtww8.cxx                           |   20 +-
 sw/source/filter/ww8/wrtww8gr.cxx                         |   12 -
 sw/source/filter/ww8/ww8atr.cxx                           |    8 -
 sw/source/filter/ww8/ww8graf.cxx                          |    4 
 sw/source/filter/ww8/ww8graf2.cxx                         |    4 
 sw/source/filter/ww8/ww8par.cxx                           |    8 -
 sw/source/filter/ww8/ww8par2.cxx                          |    4 
 sw/source/filter/ww8/ww8par3.cxx                          |    4 
 sw/source/filter/ww8/ww8par5.cxx                          |    3 
 sw/source/filter/xml/xmlfonte.cxx                         |    4 
 sw/source/filter/xml/xmltble.cxx                          |    4 
 sw/source/filter/xml/xmltbli.cxx                          |    8 -
 sw/source/ui/config/optpage.cxx                           |    8 -
 sw/source/ui/dbui/dbinsdlg.cxx                            |    6 
 sw/source/ui/envelp/label1.cxx                            |    6 
 sw/source/ui/envelp/labfmt.cxx                            |    4 
 sw/source/ui/fldui/fldref.cxx                             |    6 
 sw/source/ui/frmdlg/frmpage.cxx                           |   60 +++-----
 sw/source/ui/index/cnttab.cxx                             |    4 
 sw/source/ui/index/swuiidxmrk.cxx                         |   16 +-
 sw/source/ui/misc/bookmark.cxx                            |    6 
 sw/source/ui/table/tabledlg.cxx                           |   14 -
 sw/source/ui/vba/vbadialog.cxx                            |    3 
 sw/source/uibase/app/docstyle.cxx                         |   16 +-
 sw/source/uibase/app/mainwn.cxx                           |    3 
 sw/source/uibase/config/uinums.cxx                        |   12 -
 sw/source/uibase/dochdl/gloshdl.cxx                       |    5 
 sw/source/uibase/docvw/PostItMgr.cxx                      |  104 +++++++-------
 sw/source/uibase/docvw/SidebarWin.cxx                     |    5 
 sw/source/uibase/docvw/edtwin.cxx                         |    4 
 sw/source/uibase/docvw/srcedtw.cxx                        |    3 
 sw/source/uibase/fldui/fldmgr.cxx                         |    4 
 sw/source/uibase/lingu/olmenu.cxx                         |    6 
 sw/source/uibase/ribbar/workctrl.cxx                      |    9 -
 sw/source/uibase/shells/langhelper.cxx                    |   22 +-
 sw/source/uibase/sidebar/ThemePanel.cxx                   |   16 +-
 sw/source/uibase/uiview/pview.cxx                         |    6 
 sw/source/uibase/uiview/view2.cxx                         |    4 
 sw/source/uibase/uiview/viewsrch.cxx                      |    3 
 sw/source/uibase/uiview/viewtab.cxx                       |    9 -
 sw/source/uibase/uno/unotxdoc.cxx                         |    4 
 sw/source/uibase/uno/unotxvw.cxx                          |    3 
 sw/source/uibase/utlui/glbltree.cxx                       |    3 
 sw/source/uibase/utlui/gloslst.cxx                        |    3 
 sw/source/uibase/utlui/initui.cxx                         |    4 
 sw/source/uibase/utlui/viewlayoutctrl.cxx                 |    6 
 sw/source/uibase/wrtsh/wrtundo.cxx                        |    6 
 141 files changed, 544 insertions(+), 684 deletions(-)

New commits:
commit b415494bf0468b74318b61f114e2ff4ae68c00ee
Author: Noel Grandin <noel at peralex.com>
Date:   Wed May 11 09:53:50 2016 +0200

    clang-tidy modernize-loop-convert in sw
    
    Change-Id: I1f4a0ad6658bd3154c48940296aa8edc1ea1612c
    Reviewed-on: https://gerrit.libreoffice.org/24876
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/sw/source/core/access/accfrmobjmap.cxx b/sw/source/core/access/accfrmobjmap.cxx
index ec26221..fc492a7 100644
--- a/sw/source/core/access/accfrmobjmap.cxx
+++ b/sw/source/core/access/accfrmobjmap.cxx
@@ -66,9 +66,9 @@ SwAccessibleChildMap::SwAccessibleChildMap( const SwRect& rVisArea,
         const SwSortedObjs *pObjs = pPgFrame->GetSortedObjs();
         if ( pObjs )
         {
-            for( size_t i=0; i<pObjs->size(); ++i )
+            for(const SwAnchoredObject* pObj : *pObjs)
             {
-                aLower = (*pObjs)[i]->GetDrawObj();
+                aLower = pObj->GetDrawObj();
                 if ( aLower.GetBox( rAccMap ).IsOver( rVisArea ) )
                 {
                     insert( aLower.GetDrawObject(), aLower );
@@ -81,9 +81,9 @@ SwAccessibleChildMap::SwAccessibleChildMap( const SwRect& rVisArea,
         const SwSortedObjs *pObjs = rFrame.GetDrawObjs();
         if ( pObjs )
         {
-            for( size_t i=0; i<pObjs->size(); ++i )
+            for(const SwAnchoredObject* pObj : *pObjs)
             {
-                aLower = (*pObjs)[i]->GetDrawObj();
+                aLower = pObj->GetDrawObj();
                 if ( aLower.IsBoundAsChar() &&
                      ( !bVisibleChildrenOnly ||
                        aLower.AlwaysIncludeAsChild() ||
diff --git a/sw/source/core/bastyp/calc.cxx b/sw/source/core/bastyp/calc.cxx
index a82ea01..272b89f 100644
--- a/sw/source/core/bastyp/calc.cxx
+++ b/sw/source/core/bastyp/calc.cxx
@@ -364,8 +364,8 @@ SwCalc::SwCalc( SwDoc& rD )
 
 SwCalc::~SwCalc()
 {
-    for( sal_uInt16 n = 0; n < TBLSZ; ++n )
-        delete VarTable[n];
+    for(SwHash* p : VarTable)
+        delete p;
 
     if( pLclData != m_aSysLocale.GetLocaleDataPtr() )
         delete pLclData;
diff --git a/sw/source/core/bastyp/init.cxx b/sw/source/core/bastyp/init.cxx
index 105a447..6441245 100644
--- a/sw/source/core/bastyp/init.cxx
+++ b/sw/source/core/bastyp/init.cxx
@@ -819,11 +819,9 @@ void FinitCore()
     delete SwStyleNameMapper::m_pNumRuleProgMap;
 
     // delete all default attributes
-    for( sal_uInt16 n = 0; n < POOLATTR_END - POOLATTR_BEGIN; n++ )
+    for(SfxPoolItem* pHt : aAttrTab)
     {
-        SfxPoolItem* pHt;
-        if( nullptr != ( pHt = aAttrTab[n] ))
-            delete pHt;
+        delete pHt;
     }
 
     ::ClearFEShellTabCols();
@@ -837,8 +835,8 @@ void FinitCore()
     delete[] SwAttrPool::pVersionMap6;
     delete[] SwAttrPool::pVersionMap7;
 
-    for ( size_t i = 0; i < pGlobalOLEExcludeList->size(); ++i )
-        delete (*pGlobalOLEExcludeList)[i];
+    for (SvGlobalName* p : *pGlobalOLEExcludeList)
+        delete p;
     delete pGlobalOLEExcludeList;
 }
 
diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index 9d8ad58..03486c3 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -433,10 +433,9 @@ void SwSelPaintRects::HighlightInputField()
 
             pCursorForInputTextField->FillRects();
             SwRects* pRects = static_cast<SwRects*>(pCursorForInputTextField.get());
-            for (size_t a(0); a < pRects->size(); ++a)
+            for (const SwRect & rNextRect : *pRects)
             {
-                const SwRect aNextRect((*pRects)[a]);
-                const Rectangle aPntRect(aNextRect.SVRect());
+                const Rectangle aPntRect(rNextRect.SVRect());
 
                 aInputFieldRanges.push_back(basegfx::B2DRange(
                     aPntRect.Left(), aPntRect.Top(),
@@ -607,9 +606,8 @@ void SwShellCursor::Show()
     if (comphelper::LibreOfficeKit::isActive())
     {
         std::vector<OString> aRect;
-        for (size_t i = 0; i < aSelectionRectangles.size(); ++i)
+        for (const OString & rSelectionRectangle : aSelectionRectangles)
         {
-            const OString& rSelectionRectangle = aSelectionRectangles[i];
             if (rSelectionRectangle.isEmpty())
                 continue;
             aRect.push_back(rSelectionRectangle);
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 4e9177c..eab114b 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -701,10 +701,10 @@ namespace
         RedlineMode_t eOld = pDoc->getIDocumentRedlineAccess().GetRedlineMode();
         pDoc->getIDocumentRedlineAccess().SetRedlineMode_intern( (RedlineMode_t)(( eOld & ~nsRedlineMode_t::REDLINE_IGNORE) | nsRedlineMode_t::REDLINE_ON ));
 
-        for( size_t n = 0; n < rArr.size(); ++n )
+        for(SaveRedline & rSvRedLine : rArr)
         {
-            rArr[ n ].SetPos( rPos );
-            pDoc->getIDocumentRedlineAccess().AppendRedline( rArr[ n ].pRedl, true );
+            rSvRedLine.SetPos( rPos );
+            pDoc->getIDocumentRedlineAccess().AppendRedline( rSvRedLine.pRedl, true );
         }
 
         pDoc->getIDocumentRedlineAccess().SetRedlineMode_intern( eOld );
@@ -798,10 +798,10 @@ namespace
         RedlineMode_t eOld = pDoc->getIDocumentRedlineAccess().GetRedlineMode();
         pDoc->getIDocumentRedlineAccess().SetRedlineMode_intern( (RedlineMode_t)(( eOld & ~nsRedlineMode_t::REDLINE_IGNORE) | nsRedlineMode_t::REDLINE_ON ));
 
-        for( size_t n = 0; n < rArr.size(); ++n )
+        for(SaveRedline & rSvRedLine : rArr)
         {
-            rArr[ n ].SetPos( nInsPos );
-            pDoc->getIDocumentRedlineAccess().AppendRedline( rArr[ n ].pRedl, true );
+            rSvRedLine.SetPos( nInsPos );
+            pDoc->getIDocumentRedlineAccess().AppendRedline( rSvRedLine.pRedl, true );
         }
 
         pDoc->getIDocumentRedlineAccess().SetRedlineMode_intern( eOld );
@@ -2260,9 +2260,8 @@ bool DocumentContentOperationsManager::MoveNodeRange( SwNodeRange& rRange, SwNod
     if( !aSavRedlInsPosArr.empty() )
     {
         SwNode* pNewNd = &aIdx.GetNode();
-        for( size_t n = 0; n < aSavRedlInsPosArr.size(); ++n )
+        for(SwRangeRedline* pTmp : aSavRedlInsPosArr)
         {
-            SwRangeRedline* pTmp = aSavRedlInsPosArr[ n ];
             if( m_rDoc.getIDocumentRedlineAccess().GetRedlineTable().Contains( pTmp ) )
             {
                 SwPosition* pEnd = pTmp->End();
diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx b/sw/source/core/doc/DocumentFieldsManager.cxx
index eed6222..8c63866 100644
--- a/sw/source/core/doc/DocumentFieldsManager.cxx
+++ b/sw/source/core/doc/DocumentFieldsManager.cxx
@@ -1299,16 +1299,16 @@ void DocumentFieldsManager::SetFixFields( const DateTime* pNewDateTime )
         /*3*/   RES_FILENAMEFLD,
         /*4*/   RES_DATETIMEFLD };  // MUST be at the end!
 
-    for( sal_uInt16 nStt = 0; nStt < 5; ++nStt )
+    for(sal_uInt16 aType : aTypes)
     {
-        SwFieldType* pFieldType = GetSysFieldType( aTypes[ nStt ] );
+        SwFieldType* pFieldType = GetSysFieldType( aType );
         SwIterator<SwFormatField,SwFieldType> aIter( *pFieldType );
         for( SwFormatField* pFormatField = aIter.First(); pFormatField; pFormatField = aIter.Next() )
         {
             if( pFormatField && pFormatField->GetTextField() )
             {
                 bool bChgd = false;
-                switch( aTypes[ nStt ] )
+                switch( aType )
                 {
                 case RES_DOCINFOFLD:
                     if( static_cast<SwDocInfoField*>(pFormatField->GetField())->IsFixed() )
diff --git a/sw/source/core/doc/DocumentLinksAdministrationManager.cxx b/sw/source/core/doc/DocumentLinksAdministrationManager.cxx
index 73b8914..39a8032 100644
--- a/sw/source/core/doc/DocumentLinksAdministrationManager.cxx
+++ b/sw/source/core/doc/DocumentLinksAdministrationManager.cxx
@@ -64,9 +64,9 @@ namespace
 
     ::sfx2::SvBaseLink* lcl_FindNextRemovableLink( const ::sfx2::SvBaseLinks& rLinks )
     {
-        for( ::sfx2::SvBaseLinks::size_type n = 0; n < rLinks.size(); ++n )
+        for(const auto & rLink : rLinks)
         {
-            ::sfx2::SvBaseLink* pLnk = &(*rLinks[ n ]);
+            ::sfx2::SvBaseLink* pLnk = &(*rLink);
             if( pLnk &&
                 ( OBJECT_CLIENT_GRF == pLnk->GetObjType() ||
                   OBJECT_CLIENT_FILE == pLnk->GetObjType() ) &&
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx
index bbb9fba..99e9fcb 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -72,14 +72,14 @@ using namespace com::sun::star;
             const SwRedlineTable& rTable = redlineAccess.GetRedlineTable();
 
             // verify valid redline positions
-            for( size_t i = 0; i < rTable.size(); ++i )
-                lcl_CheckPam( rTable[ i ] );
+            for(SwRangeRedline* i : rTable)
+                lcl_CheckPam( i );
 
-            for( size_t j = 0; j < rTable.size(); ++j )
+            for(SwRangeRedline* j : rTable)
             {
                 // check for empty redlines
-                OSL_ENSURE( ( *(rTable[j]->GetPoint()) != *(rTable[j]->GetMark()) ) ||
-                            ( rTable[j]->GetContentIdx() != nullptr ),
+                OSL_ENSURE( ( *(j->GetPoint()) != *(j->GetMark()) ) ||
+                            ( j->GetContentIdx() != nullptr ),
                             ERROR_PREFIX "empty redline" );
              }
 
@@ -2614,9 +2614,8 @@ sal_uInt16 DocumentRedlineManager::InsertRedlineAuthor( const OUString& rNew )
 void DocumentRedlineManager::UpdateRedlineAttr()
 {
     const SwRedlineTable& rTable = GetRedlineTable();
-    for( size_t n = 0; n < rTable.size(); ++n )
+    for(SwRangeRedline* pRedl : rTable)
     {
-        SwRangeRedline* pRedl = rTable[ n ];
         if( pRedl->IsVisible() )
             pRedl->InvalidateRange();
     }
diff --git a/sw/source/core/doc/DocumentStylePoolManager.cxx b/sw/source/core/doc/DocumentStylePoolManager.cxx
index 66254f4..b3ced5d 100644
--- a/sw/source/core/doc/DocumentStylePoolManager.cxx
+++ b/sw/source/core/doc/DocumentStylePoolManager.cxx
@@ -120,16 +120,16 @@ namespace
             { RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CJK_FONT },
             { RES_CHRATR_CTL_LANGUAGE, RES_CHRATR_CTL_FONT }
         };
-        for( sal_uInt16 n = 0; n < 3; ++n )
+        for(const auto & n : aArr)
         {
             sal_uInt16 nLng = static_cast<const SvxLanguageItem&>(rSet.GetPool()->GetDefaultItem(
-                                aArr[n].nResLngId )).GetLanguage();
+                                n.nResLngId )).GetLanguage();
             vcl::Font aFnt( OutputDevice::GetDefaultFont( nFntType,
                                     nLng, GetDefaultFontFlags::OnlyOne ) );
 
             rSet.Put( SvxFontItem( aFnt.GetFamilyType(), aFnt.GetFamilyName(),
                                 OUString(), aFnt.GetPitch(),
-                                aFnt.GetCharSet(), aArr[n].nResFntId ));
+                                aFnt.GetCharSet(), n.nResFntId ));
         }
     }
 
@@ -149,16 +149,16 @@ namespace
         aArr[1].nFntType = nCJKFntType;
         aArr[2].nFntType = nCTLFntType;
 
-        for( sal_uInt16 n = 0; n < 3; ++n )
+        for(const auto & n : aArr)
         {
             sal_uInt16 nLng = static_cast<const SvxLanguageItem&>(rSet.GetPool()->GetDefaultItem(
-                                aArr[n].nResLngId )).GetLanguage();
-            vcl::Font aFnt( OutputDevice::GetDefaultFont( aArr[n].nFntType,
+                                n.nResLngId )).GetLanguage();
+            vcl::Font aFnt( OutputDevice::GetDefaultFont( n.nFntType,
                                     nLng, GetDefaultFontFlags::OnlyOne ) );
 
             rSet.Put( SvxFontItem( aFnt.GetFamilyType(), aFnt.GetFamilyName(),
                                 OUString(), aFnt.GetPitch(),
-                                aFnt.GetCharSet(), aArr[n].nResFntId ));
+                                aFnt.GetCharSet(), n.nResFntId ));
         }
     }
 
diff --git a/sw/source/core/doc/acmplwrd.cxx b/sw/source/core/doc/acmplwrd.cxx
index 8d8c7eb..634d587 100644
--- a/sw/source/core/doc/acmplwrd.cxx
+++ b/sw/source/core/doc/acmplwrd.cxx
@@ -357,9 +357,9 @@ bool SwAutoCompleteWord::GetWordsMatching(const OUString& aMatch, std::vector<OU
         return false;
     }
 
-    for (size_t i = 0; i < suggestions.size(); i++)
+    for (const OUString & suggestion : suggestions)
     {
-        aWords.push_back( suggestions[i] );
+        aWords.push_back( suggestion );
     }
 
     return true;
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 2c54cfe..7850ffa 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -982,9 +982,8 @@ void SwDoc::CalculatePagePairsForProspectPrinting(
     // now fill the vector for calculating the page pairs with the start frames
     // from the above obtained vector
     std::vector< const SwPageFrame * > aVec;
-    for ( std::vector< sal_Int32 >::size_type i = 0; i < aPagesToPrint.size(); ++i)
+    for (sal_Int32 nPage : aPagesToPrint)
     {
-        const sal_Int32 nPage = aPagesToPrint[i];
         const SwPageFrame *pFrame = validStartFrames[ nPage ];
         aVec.push_back( pFrame );
     }
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index d87b9d5..2c79ac1 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1161,12 +1161,12 @@ void MarkManager::dumpAsXml(xmlTextWriterPtr pWriter) const
     };
 
     xmlTextWriterStartElement(pWriter, BAD_CAST("markManager"));
-    for (size_t i = 0; i < SAL_N_ELEMENTS(aContainers); ++i)
+    for (const auto & rContainer : aContainers)
     {
-        if (!aContainers[i].pContainer->empty())
+        if (!rContainer.pContainer->empty())
         {
-            xmlTextWriterStartElement(pWriter, BAD_CAST(aContainers[i].pName));
-            for (const_iterator_t it = aContainers[i].pContainer->begin(); it != aContainers[i].pContainer->end(); ++it)
+            xmlTextWriterStartElement(pWriter, BAD_CAST(rContainer.pName));
+            for (const_iterator_t it = rContainer.pContainer->begin(); it != rContainer.pContainer->end(); ++it)
                 (*it)->dumpAsXml(pWriter);
             xmlTextWriterEndElement(pWriter);
         }
@@ -1330,11 +1330,9 @@ void DelBookmarks(
     // which holds all position information as offset.
     // Assignement happens after moving.
     SwRedlineTable& rTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable();
-    for(SwRedlineTable::size_type nCnt = 0; nCnt < rTable.size(); ++nCnt )
+    for(SwRangeRedline* pRedl : rTable)
     {
         // Is at position?
-        SwRangeRedline* pRedl = rTable[ nCnt ];
-
         SwPosition *const pRStt = pRedl->Start();
         SwPosition *const pREnd = pRedl->End();
 
diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx
index 3592073..fa2ca52 100644
--- a/sw/source/core/doc/doccomp.cxx
+++ b/sw/source/core/doc/doccomp.cxx
@@ -2079,9 +2079,8 @@ long SwDoc::MergeDoc( const SwDoc& rDoc )
         const SwRedlineTable& rSrcRedlTable = rSrcDoc.getIDocumentRedlineAccess().GetRedlineTable();
         sal_uLong nEndOfExtra = rSrcDoc.GetNodes().GetEndOfExtras().GetIndex();
         sal_uLong nMyEndOfExtra = GetNodes().GetEndOfExtras().GetIndex();
-        for( SwRedlineTable::size_type n = 0; n < rSrcRedlTable.size(); ++n )
+        for(const SwRangeRedline* pRedl : rSrcRedlTable)
         {
-            const SwRangeRedline* pRedl = rSrcRedlTable[ n ];
             sal_uLong nNd = pRedl->GetPoint()->nNode.GetIndex();
             RedlineType_t eType = pRedl->GetType();
             if( nEndOfExtra < nNd &&
diff --git a/sw/source/core/doc/doccorr.cxx b/sw/source/core/doc/doccorr.cxx
index 9496e96..4c440b8 100644
--- a/sw/source/core/doc/doccorr.cxx
+++ b/sw/source/core/doc/doccorr.cxx
@@ -305,10 +305,10 @@ void SwDoc::CorrRel(const SwNodeIndex& rOldNode,
     { // fix the Redlines
         SwRedlineTable& rTable = getIDocumentRedlineAccess().GetRedlineTable();
         SwPosition aNewPos(rNewPos);
-        for( SwRedlineTable::size_type n = 0; n < rTable.size(); ++n )
+        for(SwRangeRedline* p : rTable)
         {
             // lies on the position ??
-            lcl_PaMCorrRel1( rTable[ n ], &rOldNode.GetNode(), aNewPos, aNewPos.nContent.GetIndex() + nOffset );
+            lcl_PaMCorrRel1( p, &rOldNode.GetNode(), aNewPos, aNewPos.nContent.GetIndex() + nOffset );
         }
 
         // To-Do - need to add here 'SwExtraRedlineTable' also ?
diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx
index 44c7b26..34df1d4 100644
--- a/sw/source/core/doc/docdesc.cxx
+++ b/sw/source/core/doc/docdesc.cxx
@@ -579,11 +579,11 @@ void SwDoc::PreDelPageDesc(SwPageDesc * pDel)
         }
     }
 
-    for (SwPageDescs::size_type j = 0; j < m_PageDescs.size(); ++j)
+    for (std::unique_ptr<SwPageDesc> & rpPageDesc : m_PageDescs)
     {
-        if (m_PageDescs[j]->GetFollow() == pDel)
+        if (rpPageDesc->GetFollow() == pDel)
         {
-            m_PageDescs[j]->SetFollow(nullptr);
+            rpPageDesc->SetFollow(nullptr);
             if( bHasLayout )
             {
                 for( auto aLayout : GetAllLayouts() )
diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx
index ad4c8db..0f55ea6 100644
--- a/sw/source/core/doc/docedt.cxx
+++ b/sw/source/core/doc/docedt.cxx
@@ -57,10 +57,9 @@ void RestFlyInRange( SaveFlyArr & rArr, const SwNodeIndex& rSttIdx,
                       const SwNodeIndex* pInsertPos )
 {
     SwPosition aPos( rSttIdx );
-    for( size_t n = 0; n < rArr.size(); ++n )
+    for(SaveFly & rSave : rArr)
     {
         // create new anchor
-        SaveFly& rSave = rArr[n];
         SwFrameFormat* pFormat = rSave.pFrameFormat;
 
         if( rSave.bInsertPosition )
diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx
index 2734f8d..35e3696 100644
--- a/sw/source/core/doc/docfld.cxx
+++ b/sw/source/core/doc/docfld.cxx
@@ -701,9 +701,9 @@ OUString SwDoc::ReplaceUsedDBs( const std::vector<OUString>& rUsedDBNames,
     const OUString sNewName( lcl_CutOffDBCommandType(rNewName) );
     OUString sFormula(rFormula);
 
-    for( size_t i = 0; i < rUsedDBNames.size(); ++i )
+    for(const auto & rUsedDBName : rUsedDBNames)
     {
-        const OUString sDBName( lcl_CutOffDBCommandType(rUsedDBNames[i]) );
+        const OUString sDBName( lcl_CutOffDBCommandType(rUsedDBName) );
 
         if (sDBName!=sNewName)
         {
@@ -1176,8 +1176,8 @@ SwDocUpdateField::~SwDocUpdateField()
 {
     delete pFieldSortLst;
 
-    for( int n = 0; n < TBLSZ; ++n )
-        delete aFieldTypeTable[n];
+    for(SwCalcFieldType* p : aFieldTypeTable)
+        delete p;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index eb2f5d5..332cb3d 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -137,12 +137,12 @@ static bool lcl_RstAttr( const SwNodePtr& rpNd, void* pArgs )
         const SfxPoolItem* pItem;
 
         sal_uInt16 const aSavIds[3] = { RES_PAGEDESC, RES_BREAK, RES_PARATR_NUMRULE };
-        for (int n = 0; n < 3; ++n)
+        for (sal_uInt16 aSavId : aSavIds)
         {
-            if (SfxItemState::SET == pAttrSetOfNode->GetItemState(aSavIds[n], false, &pItem))
+            if (SfxItemState::SET == pAttrSetOfNode->GetItemState(aSavId, false, &pItem))
             {
                 bool bSave = false;
-                switch( aSavIds[ n ] )
+                switch( aSavId )
                 {
                     case RES_PAGEDESC:
                         bSave = nullptr != static_cast<const SwFormatPageDesc*>(pItem)->GetPageDesc();
@@ -157,7 +157,7 @@ static bool lcl_RstAttr( const SwNodePtr& rpNd, void* pArgs )
                 if( bSave )
                 {
                     aSavedAttrsSet.Put(*pItem);
-                    aClearWhichIds.push_back(aSavIds[n]);
+                    aClearWhichIds.push_back(aSavId);
                 }
             }
         }
@@ -1972,9 +1972,8 @@ std::set<Color> SwDoc::GetDocColors()
     std::set<Color> aDocColors;
     SwAttrPool& rPool = GetAttrPool();
     const sal_uInt16 pAttribs[] = {RES_CHRATR_COLOR, RES_CHRATR_HIGHLIGHT, RES_BACKGROUND};
-    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 = rPool.GetItemCount2(nAttrib);
         for (sal_uInt32 j=0; j<nCount; j++)
         {
diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx
index 3c9929f..3b0aff2 100644
--- a/sw/source/core/doc/doclay.cxx
+++ b/sw/source/core/doc/doclay.cxx
@@ -547,9 +547,8 @@ SwPosFlyFrames SwDoc::GetAllFlyFormats( const SwPaM* pCmpRange, bool bDrawAlso,
         if( pPage->GetSortedObjs() )
         {
             const SwSortedObjs &rObjs = *pPage->GetSortedObjs();
-            for( size_t i = 0; i < rObjs.size(); ++i)
+            for(SwAnchoredObject* pAnchoredObj : rObjs)
             {
-                SwAnchoredObject* pAnchoredObj = rObjs[i];
                 SwFrameFormat *pFly;
                 if ( dynamic_cast<const SwFlyFrame*>( pAnchoredObj) !=  nullptr )
                     pFly = &(pAnchoredObj->GetFrameFormat());
diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx
index bf8703f..db6ccf9 100644
--- a/sw/source/core/doc/docnum.cxx
+++ b/sw/source/core/doc/docnum.cxx
@@ -1936,10 +1936,8 @@ bool SwDoc::MoveParagraph( const SwPaM& rPam, long nOffset, bool bIsOutlMv )
 
                 // All, that are in the to-be-deleted Node, need to be
                 // moved to the next Node
-                for( size_t n = 0; n < getIDocumentRedlineAccess().GetRedlineTable().size(); ++n )
+                for(SwRangeRedline* pTmp : getIDocumentRedlineAccess().GetRedlineTable())
                 {
-                    SwRangeRedline* pTmp = getIDocumentRedlineAccess().GetRedlineTable()[ n ];
-
                     SwPosition* pPos;
                     if( ( pPos = &pTmp->GetBound())->nNode == aIdx )
                     {
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index 1f9e8ef..39ecb4c 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -1122,9 +1122,8 @@ void SwRangeRedline::MoveToSection()
             // In order to not move other Redlines' indices, we set them
             // to the end (is exclusive)
             const SwRedlineTable& rTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable();
-            for( SwRedlineTable::size_type n = 0; n < rTable.size(); ++n )
+            for(SwRangeRedline* pRedl : rTable)
             {
-                SwRangeRedline* pRedl = rTable[ n ];
                 if( pRedl->GetBound() == *pStt )
                     pRedl->GetBound() = *pEnd;
                 if( pRedl->GetBound(false) == *pStt )
@@ -1270,9 +1269,8 @@ void SwRangeRedline::DelCopyOfSection(size_t nMyPos)
             // In order to not move other Redlines' indices, we set them
             // to the end (is exclusive)
             const SwRedlineTable& rTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable();
-            for( SwRedlineTable::size_type n = 0; n < rTable.size(); ++n )
+            for(SwRangeRedline* pRedl : rTable)
             {
-                SwRangeRedline* pRedl = rTable[ n ];
                 if( pRedl->GetBound() == *pStt )
                     pRedl->GetBound() = *pEnd;
                 if( pRedl->GetBound(false) == *pStt )
diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx
index d7a239e..0b9138c 100644
--- a/sw/source/core/doc/doctxm.cxx
+++ b/sw/source/core/doc/doctxm.cxx
@@ -228,9 +228,8 @@ const SwTOXMark& SwDoc::GotoTOXMark( const SwTOXMark& rCurTOXMark,
     SwTOXMarks aMarks;
     SwTOXMark::InsertTOXMarks( aMarks, *pType );
 
-    for( size_t nMark=0; nMark<aMarks.size(); ++nMark )
+    for(SwTOXMark* pTOXMark : aMarks)
     {
-        const SwTOXMark* pTOXMark = aMarks[nMark];
         if ( pTOXMark == &rCurTOXMark )
             continue;
 
@@ -1359,9 +1358,8 @@ static long lcl_IsSOObject( const SvGlobalName& rFactoryNm )
 
     long nRet = 0;
     for( const SoObjType* pArr = aArr; !nRet && pArr->nFlag; ++pArr )
-        for ( int n = 0; n < 4; ++n )
+        for (auto & rId : pArr->aGlNmIds)
         {
-            const SoObjType::GlobalNameIds& rId = pArr->aGlNmIds[ n ];
             if( !rId.n1 )
                 break;
             SvGlobalName aGlbNm( rId.n1, rId.n2, rId.n3,
diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx
index a6cbb5e..4595847 100644
--- a/sw/source/core/doc/number.cxx
+++ b/sw/source/core/doc/number.cxx
@@ -487,8 +487,8 @@ SwNumRule::SwNumRule( const SwNumRule& rNumRule )
 
 SwNumRule::~SwNumRule()
 {
-    for( sal_uInt16 n = 0; n < MAXLEVEL; ++n )
-        delete maFormats[ n ];
+    for(SwNumFormat* p : maFormats)
+        delete p;
 
     if (mpNumRuleMap)
     {
@@ -521,17 +521,17 @@ SwNumRule::~SwNumRule()
 
 void SwNumRule::CheckCharFormats( SwDoc* pDoc )
 {
-    for( sal_uInt8 n = 0; n < MAXLEVEL; ++n )
+    for(SwNumFormat*& rpNumFormat : maFormats)
     {
         SwCharFormat* pFormat;
-        if( maFormats[ n ] && nullptr != ( pFormat = maFormats[ n ]->GetCharFormat() ) &&
+        if( rpNumFormat && nullptr != ( pFormat = rpNumFormat->GetCharFormat() ) &&
             pFormat->GetDoc() != pDoc )
         {
             // copy
-            SwNumFormat* pNew = new SwNumFormat( *maFormats[ n ] );
+            SwNumFormat* pNew = new SwNumFormat( *rpNumFormat );
             pNew->SetCharFormat( pDoc->CopyCharFormat( *pFormat ) );
-            delete maFormats[ n ];
-            maFormats[ n ] = pNew;
+            delete rpNumFormat;
+            rpNumFormat = pNew;
         }
     }
 }
diff --git a/sw/source/core/doc/sortopt.cxx b/sw/source/core/doc/sortopt.cxx
index 7705280..6dec439 100644
--- a/sw/source/core/doc/sortopt.cxx
+++ b/sw/source/core/doc/sortopt.cxx
@@ -59,9 +59,9 @@ SwSortOptions::SwSortOptions(const SwSortOptions& rOpt) :
     bTable( rOpt.bTable ),
     bIgnoreCase( rOpt.bIgnoreCase )
 {
-    for( size_t i=0; i < rOpt.aKeys.size(); ++i )
+    for(SwSortKey* pKey : rOpt.aKeys)
     {
-        SwSortKey* pNew = new SwSortKey(*rOpt.aKeys[i]);
+        SwSortKey* pNew = new SwSortKey(*pKey);
         aKeys.push_back( pNew );
     }
 }
diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx
index a9e3d58..414895b 100644
--- a/sw/source/core/doc/tblafmt.cxx
+++ b/sw/source/core/doc/tblafmt.cxx
@@ -611,8 +611,8 @@ SwTableAutoFormat::SwTableAutoFormat( const SwTableAutoFormat& rNew )
     , m_aKeepWithNextPara( false, RES_KEEP )
     , m_aShadow( RES_SHADOW )
 {
-    for( sal_uInt8 n = 0; n < 16; ++n )
-        aBoxAutoFormat[ n ] = nullptr;
+    for(SwBoxAutoFormat* & rp : aBoxAutoFormat)
+        rp = nullptr;
     *this = rNew;
 }
 
diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx
index 43908da..61402fe 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -162,9 +162,8 @@ std::set<const SwFrameFormat*> SwTextBoxHelper::findTextBoxes(const SwNode& rNod
         const SwSortedObjs* pSortedObjs = pContentFrame->GetDrawObjs();
         if (pSortedObjs)
         {
-            for (std::size_t i = 0; i < pSortedObjs->size(); ++i)
+            for (SwAnchoredObject* pAnchoredObject : *pSortedObjs)
             {
-                SwAnchoredObject* pAnchoredObject = (*pSortedObjs)[i];
                 SwFrameFormat* pTextBox = findTextBox(&pAnchoredObject->GetFrameFormat());
                 if (pTextBox)
                     aRet.insert(pTextBox);
diff --git a/sw/source/core/docnode/ndtbl1.cxx b/sw/source/core/docnode/ndtbl1.cxx
index 1a2026a..2a77eaa 100644
--- a/sw/source/core/docnode/ndtbl1.cxx
+++ b/sw/source/core/docnode/ndtbl1.cxx
@@ -1514,9 +1514,9 @@ void SwDoc::AdjustCellWidth( const SwCursor& rCursor, bool bBalance )
             }
         }
         nWish /= nCnt;
-        for ( size_t i = 0; i < aWish.size(); ++i )
-            if ( aWish[i] )
-                aWish[i] = nWish;
+        for (sal_uInt16 & rn : aWish)
+            if ( rn )
+                rn = nWish;
     }
 
     const long nOldRight = aTabCols.GetRight();
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index 853c40a..b9ef741 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -491,10 +491,10 @@ void SwFlyDrawContact::MoveObjToVisibleLayer( SdrObject* _pDrawObj )
     }
     if ( pFlyFrame->GetDrawObjs() )
     {
-        for ( size_t i = 0; i < pFlyFrame->GetDrawObjs()->size(); ++i)
+        for (SwAnchoredObject* i : *pFlyFrame->GetDrawObjs())
         {
             // #i28701# - consider type of objects in sorted object list.
-            SdrObject* pObj = (*pFlyFrame->GetDrawObjs())[i]->DrawObj();
+            SdrObject* pObj = i->DrawObj();
             SwContact* pContact = static_cast<SwContact*>(pObj->GetUserCall());
             pContact->MoveObjToVisibleLayer( pObj );
         }
@@ -526,10 +526,10 @@ void SwFlyDrawContact::MoveObjToInvisibleLayer( SdrObject* _pDrawObj )
     pFlyFrame->DeleteCnt();
     if ( pFlyFrame->GetDrawObjs() )
     {
-        for ( size_t i = 0; i < pFlyFrame->GetDrawObjs()->size(); ++i)
+        for (SwAnchoredObject* i : *pFlyFrame->GetDrawObjs())
         {
             // #i28701# - consider type of objects in sorted object list.
-            SdrObject* pObj = (*pFlyFrame->GetDrawObjs())[i]->DrawObj();
+            SdrObject* pObj = i->DrawObj();
             SwContact* pContact = static_cast<SwContact*>(pObj->GetUserCall());
             pContact->MoveObjToInvisibleLayer( pObj );
         }
diff --git a/sw/source/core/draw/dview.cxx b/sw/source/core/draw/dview.cxx
index ba89634..495485c 100644
--- a/sw/source/core/draw/dview.cxx
+++ b/sw/source/core/draw/dview.cxx
@@ -259,9 +259,9 @@ SdrObject* SwDrawView::GetMaxToTopObj( SdrObject* pObj ) const
                 if ( pPage->GetSortedObjs() )
                 {
                     size_t nOrdNum = 0;
-                    for ( size_t i = 0; i < pPage->GetSortedObjs()->size(); ++i )
+                    for (SwAnchoredObject* i : *pPage->GetSortedObjs())
                     {
-                        const SdrObject *pO = (*pPage->GetSortedObjs())[i]->GetDrawObj();
+                        const SdrObject *pO = i->GetDrawObj();
 
                         if ( pO->GetOrdNumDirect() > nOrdNum )
                         {
diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx
index 866f812..c921e7f 100644
--- a/sw/source/core/frmedt/feshview.cxx
+++ b/sw/source/core/frmedt/feshview.cxx
@@ -430,9 +430,8 @@ bool SwFEShell::MoveAnchor( SwMove nDir )
                     Point aCenter( pOld->Frame().Left() + pOld->Frame().Width()/2,
                                    pOld->Frame().Top() + pOld->Frame().Height()/2 );
                     Point aBest;
-                    for( size_t i = 0; i<pPage->GetSortedObjs()->size(); ++i )
+                    for(SwAnchoredObject* pAnchObj : *pPage->GetSortedObjs())
                     {
-                        SwAnchoredObject* pAnchObj = (*pPage->GetSortedObjs())[i];
                         if( dynamic_cast<const SwFlyFrame*>( pAnchObj) !=  nullptr )
                         {
                             SwFlyFrame* pTmp = static_cast<SwFlyFrame*>(pAnchObj);
diff --git a/sw/source/core/layout/anchoredobject.cxx b/sw/source/core/layout/anchoredobject.cxx
index 0e6c46a..36d24d3 100644
--- a/sw/source/core/layout/anchoredobject.cxx
+++ b/sw/source/core/layout/anchoredobject.cxx
@@ -455,9 +455,8 @@ bool SwAnchoredObject::ConsiderObjWrapInfluenceOfOtherObjs() const
     const SwSortedObjs* pObjs = GetAnchorFrame()->GetDrawObjs();
     if ( pObjs->size() > 1 )
     {
-        for ( size_t i = 0; i < pObjs->size(); ++i )
+        for (SwAnchoredObject* pAnchoredObj : *pObjs)
         {
-            SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
             if ( pAnchoredObj != this &&
                  pAnchoredObj->ConsiderObjWrapInfluenceOnObjPos() )
             {
@@ -630,9 +629,8 @@ void SwAnchoredObject::UpdateObjInSortedList()
             {
                 const SwSortedObjs* pObjs = GetAnchorFrame()->GetDrawObjs();
                 // determine start index
-                for ( size_t i = 0; i < pObjs->size(); ++i )
+                for (SwAnchoredObject* pAnchoredObj : *pObjs)
                 {
-                    SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
                     if ( pAnchoredObj->ConsiderObjWrapInfluenceOnObjPos() )
                         pAnchoredObj->InvalidateObjPosForConsiderWrapInfluence();
                     else
@@ -757,9 +755,8 @@ void SwAnchoredObject::SetTmpConsiderWrapInfluenceOfOtherObjs()
     const SwSortedObjs* pObjs = GetAnchorFrame()->GetDrawObjs();
     if ( pObjs->size() > 1 )
     {
-        for ( size_t i = 0; i < pObjs->size(); ++i )
+        for (SwAnchoredObject* pAnchoredObj : *pObjs)
         {
-            SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
             if ( pAnchoredObj != this )
             {
                 pAnchoredObj->SetTmpConsiderWrapInfluence( true/*bTmpConsiderWrapInfluence*/ );
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 6190be7..3375358 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -2987,11 +2987,10 @@ void SwFlyFrameFormat::MakeFrames()
             {
                 // #i28701# - new type <SwSortedObjs>
                 SwSortedObjs &rObjs = *pFrame->GetDrawObjs();
-                for( size_t i = 0; i < rObjs.size(); ++i)
+                for(SwAnchoredObject* pObj : rObjs)
                 {
                     // #i28701# - consider changed type of
                     // <SwSortedObjs> entries.
-                    SwAnchoredObject* pObj = rObjs[i];
                     if( dynamic_cast<const SwFlyFrame*>( pObj) !=  nullptr &&
                         (&pObj->GetFrameFormat()) == this )
                     {
diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx
index fc9f0f6..c54c7ef 100644
--- a/sw/source/core/layout/calcmove.cxx
+++ b/sw/source/core/layout/calcmove.cxx
@@ -612,11 +612,10 @@ static void lcl_CheckObjects( SwSortedObjs* pSortedObjs, const SwFrame* pFrame,
 {
     // And then there can be paragraph anchored frames that sit below their paragraph.
     long nMax = 0;
-    for ( size_t i = 0; i < pSortedObjs->size(); ++i )
+    for (SwAnchoredObject* pObj : *pSortedObjs)
     {
         // #i28701# - consider changed type of <SwSortedObjs>
         // entries.
-        SwAnchoredObject* pObj = (*pSortedObjs)[i];
         long nTmp = 0;
         if ( dynamic_cast<const SwFlyFrame*>( pObj) !=  nullptr )
         {
diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx
index c9698bd..39a9113 100644
--- a/sw/source/core/layout/flowfrm.cxx
+++ b/sw/source/core/layout/flowfrm.cxx
@@ -1060,11 +1060,10 @@ bool SwFlowFrame::IsPrevObjMove() const
         // #i26945# - re-factoring
         // use <GetVertPosOrientFrame()> to determine, if object has followed the
         // text flow to the next layout frame
-        for ( size_t i = 0; i < pPre->GetDrawObjs()->size(); ++i )
+        for (SwAnchoredObject* pObj : *pPre->GetDrawObjs())
         {
             // #i28701# - consider changed type of
             // <SwSortedObjs> entries.
-            const SwAnchoredObject* pObj = (*pPre->GetDrawObjs())[i];
             // OD 2004-01-20 #110582# - do not consider hidden objects
             // #i26945# - do not consider object, which
             // doesn't follow the text flow.
@@ -2257,9 +2256,8 @@ bool SwFlowFrame::MoveBwd( bool &rbReformat )
         // has restarted the layout process.
         else if ( m_rThis.GetDrawObjs() )
         {
-            for ( size_t i = 0; i < m_rThis.GetDrawObjs()->size(); ++i )
+            for (SwAnchoredObject* pAnchoredObj : *m_rThis.GetDrawObjs())
             {
-                SwAnchoredObject* pAnchoredObj = (*m_rThis.GetDrawObjs())[i];
                 // #i47697# - refine condition - see above
                 if ( pAnchoredObj->RestartLayoutProcess() &&
                      !pAnchoredObj->IsTmpConsiderWrapInfluence() )
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index c87bf59..66c131d 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -2187,9 +2187,8 @@ void SwFrame::InvalidateObjs( const bool _bNoInvaOfAsCharAnchoredObjs )
         // page.
         const SwPageFrame* pPageFrame = FindPageFrame();
         // #i28701# - re-factoring
-        for ( size_t i = 0; i < GetDrawObjs()->size(); ++i )
+        for (SwAnchoredObject* pAnchoredObj : *GetDrawObjs())
         {
-            SwAnchoredObject* pAnchoredObj = (*GetDrawObjs())[i];
             if ( _bNoInvaOfAsCharAnchoredObjs &&
                  (pAnchoredObj->GetFrameFormat().GetAnchor().GetAnchorId()
                     == FLY_AS_CHAR) )
@@ -2254,9 +2253,8 @@ void SwLayoutFrame::NotifyLowerObjs( const bool _bUnlockPosOfObjs )
     if ( pPageFrame && pPageFrame->GetSortedObjs() )
     {
         SwSortedObjs& rObjs = *(pPageFrame->GetSortedObjs());
-        for ( size_t i = 0; i < rObjs.size(); ++i )
+        for (SwAnchoredObject* pObj : rObjs)
         {
-            SwAnchoredObject* pObj = rObjs[i];
             // #i26945# - check, if anchored object is a lower
             // of the layout frame is changed to check, if its anchor frame
             // is a lower of the layout frame.
diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx
index 12232cc..9fbc5d27 100644
--- a/sw/source/core/layout/flycnt.cxx
+++ b/sw/source/core/layout/flycnt.cxx
@@ -145,9 +145,9 @@ void SwFlyAtContentFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pN
             {
                 SwFrameFormat* pMyFlyFrameFormat( &GetFrameFormat() );
                 SwSortedObjs &rObjs = *pContent->GetDrawObjs();
-                for( size_t i = 0; i < rObjs.size(); ++i)
+                for(SwAnchoredObject* rObj : rObjs)
                 {
-                    SwFlyFrame* pFlyFrame = dynamic_cast<SwFlyFrame*>(rObjs[i]);
+                    SwFlyFrame* pFlyFrame = dynamic_cast<SwFlyFrame*>(rObj);
                     if ( pFlyFrame &&
                          &(pFlyFrame->GetFrameFormat()) == pMyFlyFrameFormat )
                     {
diff --git a/sw/source/core/layout/flylay.cxx b/sw/source/core/layout/flylay.cxx
index fd7b5c3..3f6a87c 100644
--- a/sw/source/core/layout/flylay.cxx
+++ b/sw/source/core/layout/flylay.cxx
@@ -616,9 +616,8 @@ void SwPageFrame::AppendFlyToPage( SwFlyFrame *pNew )
     if ( pNew->GetDrawObjs() )
     {
         SwSortedObjs &rObjs = *pNew->GetDrawObjs();
-        for ( size_t i = 0; i < rObjs.size(); ++i )
+        for (SwAnchoredObject* pTmpObj : rObjs)
         {
-            SwAnchoredObject* pTmpObj = rObjs[i];
             if ( dynamic_cast<const SwFlyFrame*>( pTmpObj) !=  nullptr )
             {
                 SwFlyFrame* pTmpFly = static_cast<SwFlyFrame*>(pTmpObj);
@@ -764,9 +763,8 @@ void SwPageFrame::MoveFly( SwFlyFrame *pToMove, SwPageFrame *pDest )
     if ( pToMove->GetDrawObjs() )
     {
         SwSortedObjs &rObjs = *pToMove->GetDrawObjs();
-        for ( size_t i = 0; i < rObjs.size(); ++i )
+        for (SwAnchoredObject* pObj : rObjs)
         {
-            SwAnchoredObject* pObj = rObjs[i];
             if ( dynamic_cast<const SwFlyFrame*>( pObj) !=  nullptr )
             {
                 SwFlyFrame* pFly = static_cast<SwFlyFrame*>(pObj);
diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx
index 96f513c..4cfcdf7 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -255,13 +255,12 @@ SwFrameNotify::~SwFrameNotify()
         {
             const SwSortedObjs &rObjs = *mpFrame->GetDrawObjs();
             SwPageFrame* pPageFrame = nullptr;
-            for ( size_t i = 0; i < rObjs.size(); ++i )
+            for (SwAnchoredObject* pObj : rObjs)
             {
                 // OD 2004-03-31 #i26791# - no general distinction between
                 // Writer fly frames and drawing objects
                 bool bNotify = false;
                 bool bNotifySize = false;
-                SwAnchoredObject* pObj = rObjs[i];
                 SwContact* pContact = ::GetUserCall( pObj->GetDrawObj() );
                 const bool bAnchoredAsChar = pContact->ObjAnchoredAsChar();
                 if ( !bAnchoredAsChar )
@@ -986,9 +985,8 @@ SwContentNotify::~SwContentNotify()
              pMasterFrame->GetDrawObjs() )
         {
             SwSortedObjs* pObjs = pMasterFrame->GetDrawObjs();
-            for ( size_t i = 0; i < pObjs->size(); ++i )
+            for (SwAnchoredObject* pAnchoredObj : *pObjs)
             {
-                SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
                 if ( pAnchoredObj->GetFrameFormat().GetAnchor().GetAnchorId()
                         == FLY_AT_CHAR )
                 {
@@ -2242,9 +2240,9 @@ void SwOrderIter::Top()
         {
             sal_uInt32 nTopOrd = 0;
             (*pObjs)[0]->GetDrawObj()->GetOrdNum();  // force updating
-            for ( size_t i = 0; i < pObjs->size(); ++i )
+            for (SwAnchoredObject* i : *pObjs)
             {
-                const SdrObject* pObj = (*pObjs)[i]->GetDrawObj();
+                const SdrObject* pObj = i->GetDrawObj();
                 if ( m_bFlysOnly && dynamic_cast<const SwVirtFlyDrawObj*>( pObj) ==  nullptr )
                     continue;
                 sal_uInt32 nTmp = pObj->GetOrdNumDirect();
@@ -2268,9 +2266,9 @@ const SdrObject *SwOrderIter::Bottom()
         if ( pObjs->size() )
         {
             (*pObjs)[0]->GetDrawObj()->GetOrdNum();  // force updating
-            for ( size_t i = 0; i < pObjs->size(); ++i )
+            for (SwAnchoredObject* i : *pObjs)
             {
-                const SdrObject* pObj = (*pObjs)[i]->GetDrawObj();
+                const SdrObject* pObj = i->GetDrawObj();
                 if ( m_bFlysOnly && dynamic_cast<const SwVirtFlyDrawObj*>( pObj) ==  nullptr )
                     continue;
                 sal_uInt32 nTmp = pObj->GetOrdNumDirect();
@@ -2296,9 +2294,9 @@ const SdrObject *SwOrderIter::Next()
         if ( pObjs->size() )
         {
             (*pObjs)[0]->GetDrawObj()->GetOrdNum();  // force updating
-            for ( size_t i = 0; i < pObjs->size(); ++i )
+            for (SwAnchoredObject* i : *pObjs)
             {
-                const SdrObject* pObj = (*pObjs)[i]->GetDrawObj();
+                const SdrObject* pObj = i->GetDrawObj();
                 if ( m_bFlysOnly && dynamic_cast<const SwVirtFlyDrawObj*>( pObj) ==  nullptr )
                     continue;
                 sal_uInt32 nTmp = pObj->GetOrdNumDirect();
@@ -2324,9 +2322,9 @@ void SwOrderIter::Prev()
         {
             sal_uInt32 nOrd = 0;
             (*pObjs)[0]->GetDrawObj()->GetOrdNum();  // force updating
-            for ( size_t i = 0; i < pObjs->size(); ++i )
+            for (SwAnchoredObject* i : *pObjs)
             {
-                const SdrObject* pObj = (*pObjs)[i]->GetDrawObj();
+                const SdrObject* pObj = i->GetDrawObj();
                 if ( m_bFlysOnly && dynamic_cast<const SwVirtFlyDrawObj*>( pObj) ==  nullptr )
                     continue;
                 sal_uInt32 nTmp = pObj->GetOrdNumDirect();
@@ -2354,9 +2352,8 @@ static void lcl_RemoveObjsFromPage( SwFrame* _pFrame )
 {
     OSL_ENSURE( _pFrame->GetDrawObjs(), "no DrawObjs in lcl_RemoveObjsFromPage." );
     SwSortedObjs &rObjs = *_pFrame->GetDrawObjs();
-    for ( size_t i = 0; i < rObjs.size(); ++i )
+    for (SwAnchoredObject* pObj : rObjs)
     {
-        SwAnchoredObject* pObj = rObjs[i];
         // #115759# - reset member, at which the anchored
         // object orients its vertical position
         pObj->ClearVertPosOrientFrame();
@@ -2517,10 +2514,8 @@ static void lcl_AddObjsToPage( SwFrame* _pFrame, SwPageFrame* _pPage )
 {
     OSL_ENSURE( _pFrame->GetDrawObjs(), "no DrawObjs in lcl_AddObjsToPage." );
     SwSortedObjs &rObjs = *_pFrame->GetDrawObjs();
-    for ( size_t i = 0; i < rObjs.size(); ++i )
+    for (SwAnchoredObject* pObj : rObjs)
     {
-        SwAnchoredObject* pObj = rObjs[i];
-
         // #115759# - unlock position of anchored object
         // in order to get the object's position calculated.
         pObj->UnlockPosition();
@@ -2712,9 +2707,8 @@ SwPageFrame * InsertNewPage( SwPageDesc &rDesc, SwFrame *pUpper,
 static void lcl_Regist( SwPageFrame *pPage, const SwFrame *pAnch )
 {
     SwSortedObjs *pObjs = const_cast<SwSortedObjs*>(pAnch->GetDrawObjs());
-    for ( size_t i = 0; i < pObjs->size(); ++i )
+    for (SwAnchoredObject* pObj : *pObjs)
     {
-        SwAnchoredObject* pObj = (*pObjs)[i];
         if ( dynamic_cast<const SwFlyFrame*>( pObj) !=  nullptr )
         {
             SwFlyFrame *pFly = static_cast<SwFlyFrame*>(pObj);
@@ -2886,9 +2880,8 @@ static void lcl_NotifyContent( const SdrObject *pThis, SwContentFrame *pCnt,
         if ( pCnt->GetDrawObjs() )
         {
             const SwSortedObjs &rObjs = *pCnt->GetDrawObjs();
-            for ( size_t i = 0; i < rObjs.size(); ++i )
+            for (SwAnchoredObject* pObj : rObjs)
             {
-                SwAnchoredObject* pObj = rObjs[i];
                 if ( dynamic_cast<const SwFlyFrame*>( pObj) !=  nullptr )
                 {
                     SwFlyFrame *pFly = static_cast<SwFlyFrame*>(pObj);
@@ -3020,9 +3013,8 @@ void Notify_Background( const SdrObject* pObj,
     {
         pObj->GetOrdNum();
         const SwSortedObjs &rObjs = *pPage->GetSortedObjs();
-        for ( size_t i = 0; i < rObjs.size(); ++i )
+        for (SwAnchoredObject* pAnchoredObj : rObjs)
         {
-            SwAnchoredObject* pAnchoredObj = rObjs[i];
             if ( dynamic_cast<const SwFlyFrame*>( pAnchoredObj) !=  nullptr )
             {
                 if( pAnchoredObj->GetDrawObj() == pObj )
diff --git a/sw/source/core/layout/ftnfrm.cxx b/sw/source/core/layout/ftnfrm.cxx
index 698dff8..38290c8 100644
--- a/sw/source/core/layout/ftnfrm.cxx
+++ b/sw/source/core/layout/ftnfrm.cxx
@@ -1903,10 +1903,8 @@ void SwFootnoteBossFrame::MoveFootnotes_( SwFootnoteFrames &rFootnoteArr, bool b
     // #i21478# - keep last inserted footnote in order to
     // format the content of the following one.
     SwFootnoteFrame* pLastInsertedFootnote = nullptr;
-    for ( size_t i = 0; i < rFootnoteArr.size(); ++i )
+    for (SwFootnoteFrame* pFootnote : rFootnoteArr)
     {
-        SwFootnoteFrame *pFootnote = rFootnoteArr[i];
-
         SwFootnoteBossFrame* pRefBoss = pFootnote->GetRef()->FindFootnoteBossFrame( true );
         if( pRefBoss != this )
         {
diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx
index 9ead11e..de3b7d8 100644
--- a/sw/source/core/layout/layact.cxx
+++ b/sw/source/core/layout/layact.cxx
@@ -419,9 +419,8 @@ static void unlockPositionOfObjects( SwPageFrame *pPageFrame )
     SwSortedObjs* pObjs = pPageFrame->GetSortedObjs();
     if ( pObjs )
     {
-        for ( size_t i = 0; i < pObjs->size(); ++i )
+        for (SwAnchoredObject* pObj : *pObjs)
         {
-            SwAnchoredObject* pObj = (*pObjs)[i];
             pObj->UnlockPosition();
         }
     }
@@ -914,9 +913,8 @@ static const SwFrame *lcl_FindFirstInvaContent( const SwLayoutFrame *pLay, long
         if ( pCnt->GetDrawObjs() )
         {
             const SwSortedObjs &rObjs = *pCnt->GetDrawObjs();
-            for ( size_t i = 0; i < rObjs.size(); ++i )
+            for (SwAnchoredObject* pObj : rObjs)
             {
-                const SwAnchoredObject* pObj = rObjs[i];
                 if ( dynamic_cast< const SwFlyFrame *>( pObj ) !=  nullptr )
                 {
                     const SwFlyFrame* pFly = static_cast<const SwFlyFrame*>(pObj);
@@ -950,9 +948,8 @@ static const SwAnchoredObject* lcl_FindFirstInvaObj( const SwPageFrame* _pPage,
 {
     OSL_ENSURE( _pPage->GetSortedObjs(), "FindFirstInvaObj, no Objs" );
 
-    for ( size_t i = 0; i < _pPage->GetSortedObjs()->size(); ++i )
+    for (SwAnchoredObject* pObj : *_pPage->GetSortedObjs())
     {
-        const SwAnchoredObject* pObj = (*_pPage->GetSortedObjs())[i];
         if ( dynamic_cast< const SwFlyFrame *>( pObj ) !=  nullptr )
         {
             const SwFlyFrame* pFly = static_cast<const SwFlyFrame*>(pObj);
@@ -1158,9 +1155,8 @@ bool SwLayAction::IsShortCut( SwPageFrame *&prPage )
                         static_cast<SwPageFrame*>(prPage->GetPrev())->GetSortedObjs();
                     if ( pObjs )
                     {
-                        for ( size_t i = 0; i < pObjs->size(); ++i )
+                        for (SwAnchoredObject* pObj : *pObjs)
                         {
-                            SwAnchoredObject* pObj = (*pObjs)[i];
                             if ( pObj->GetAnchorFrameContainingAnchPos() == pContent )
                             {
                                 bRet = false;
@@ -1971,9 +1967,8 @@ bool SwLayIdle::DoIdleJob_( const SwContentFrame *pCnt, IdleJobType eJob )
     if ( pCnt->GetDrawObjs() )
     {
         const SwSortedObjs &rObjs = *pCnt->GetDrawObjs();
-        for ( size_t i = 0; i < rObjs.size(); ++i )
+        for (SwAnchoredObject* pObj : rObjs)
         {
-            SwAnchoredObject* pObj = rObjs[i];
             if ( dynamic_cast< const SwFlyFrame *>( pObj ) !=  nullptr )
             {
                 SwFlyFrame* pFly = static_cast<SwFlyFrame*>(pObj);
diff --git a/sw/source/core/layout/laycache.cxx b/sw/source/core/layout/laycache.cxx
index f7867dc..44d4fd5 100644
--- a/sw/source/core/layout/laycache.cxx
+++ b/sw/source/core/layout/laycache.cxx
@@ -275,9 +275,8 @@ void SwLayoutCache::Write( SvStream &rStream, const SwDoc& rDoc )
             if( pPage->GetSortedObjs() )
             {
                 SwSortedObjs &rObjs = *pPage->GetSortedObjs();
-                for ( size_t i = 0; i < rObjs.size(); ++i )
+                for (SwAnchoredObject* pAnchoredObj : rObjs)
                 {
-                    SwAnchoredObject* pAnchoredObj = rObjs[i];
                     if (SwFlyFrame *pFly = dynamic_cast<SwFlyFrame*>(pAnchoredObj))
                     {
                         if( pFly->Frame().Left() != FAR_AWAY &&
@@ -939,9 +938,8 @@ void SwLayHelper::CheckFlyCache_( SwPageFrame* pPage )
 
         // sort objects on this page by ordnum
         std::set< const SdrObject*, SdrObjectCompare > aFlySet;
-        for ( size_t i = 0; i < rObjs.size(); ++i )
+        for (SwAnchoredObject* pAnchoredObj : rObjs)
         {
-            SwAnchoredObject* pAnchoredObj = rObjs[i];
             if (SwFlyFrame *pFly = dynamic_cast<SwFlyFrame*>(pAnchoredObj))  // a text frame?
             {
                 if( pFly->GetAnchorFrame() &&
diff --git a/sw/source/core/layout/layouter.cxx b/sw/source/core/layout/layouter.cxx
index 288496c..18efbe1 100644
--- a/sw/source/core/layout/layouter.cxx
+++ b/sw/source/core/layout/layouter.cxx
@@ -104,9 +104,8 @@ void SwEndnoter::CollectEndnote( SwFootnoteFrame* pFootnote )
     }
     else if( pEndArr )
     {
-        for ( size_t i = 0; i < pEndArr->size(); ++i )
+        for (SwFootnoteFrame* pEndFootnote : *pEndArr)
         {
-            SwFootnoteFrame *pEndFootnote = (*pEndArr)[i];
             if( pEndFootnote->GetAttr() == pFootnote->GetAttr() )
             {
                 SwFrame::DestroyFrame(pFootnote);
diff --git a/sw/source/core/layout/objectformattertxtfrm.cxx b/sw/source/core/layout/objectformattertxtfrm.cxx
index e49d700..b59b9f5 100644
--- a/sw/source/core/layout/objectformattertxtfrm.cxx
+++ b/sw/source/core/layout/objectformattertxtfrm.cxx
@@ -769,9 +769,8 @@ bool SwObjectFormatterTextFrame::AtLeastOneObjIsTmpConsiderWrapInfluence()
     const SwSortedObjs* pObjs = GetAnchorFrame().GetDrawObjs();
     if ( pObjs && pObjs->size() > 1 )
     {
-        for ( size_t i = 0; i < pObjs->size(); ++i )
+        for (SwAnchoredObject* pAnchoredObj : *pObjs)
         {
-            SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
             if ( pAnchoredObj->ConsiderObjWrapInfluenceOnObjPos() )
             {
                 bRet = true;
diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx
index 278894c..beb6039 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -236,9 +236,8 @@ void SwPageFrame::DestroyImpl()
     {
         // Objects can be anchored at pages that are before their anchors (why ever...).
         // In such cases, we would access already freed memory.
-        for ( size_t i = 0; i < m_pSortedObjs->size(); ++i )
+        for (SwAnchoredObject* pAnchoredObj : *m_pSortedObjs)
         {
-            SwAnchoredObject* pAnchoredObj = (*m_pSortedObjs)[i];
             pAnchoredObj->SetPageFrame( nullptr );
         }
         delete m_pSortedObjs;
@@ -910,10 +909,9 @@ static void lcl_PrepFlyInCntRegister( SwContentFrame *pFrame )
     pFrame->Prepare( PREP_REGISTER );
     if( pFrame->GetDrawObjs() )
     {
-        for( size_t i = 0; i < pFrame->GetDrawObjs()->size(); ++i )
+        for(SwAnchoredObject* pAnchoredObj : *pFrame->GetDrawObjs())
         {
             // #i28701#
-            SwAnchoredObject* pAnchoredObj = (*pFrame->GetDrawObjs())[i];
             if ( dynamic_cast< const SwFlyInContentFrame *>( pAnchoredObj ) !=  nullptr )
             {
                 SwFlyFrame* pFly = static_cast<SwFlyInContentFrame*>(pAnchoredObj);
@@ -940,10 +938,9 @@ void SwPageFrame::PrepareRegisterChg()
     }
     if( GetSortedObjs() )
     {
-        for( size_t i = 0; i < GetSortedObjs()->size(); ++i )
+        for(SwAnchoredObject* pAnchoredObj : *GetSortedObjs())
         {
             // #i28701#
-            SwAnchoredObject* pAnchoredObj = (*GetSortedObjs())[i];
             if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) !=  nullptr )
             {
                 SwFlyFrame *pFly = static_cast<SwFlyFrame*>(pAnchoredObj);
@@ -1767,9 +1764,8 @@ static void lcl_MoveAllLowerObjs( SwFrame* pFrame, const Point& rOffset )
 
     // note: pSortedObj elements may be removed and inserted from
     // MoveObjectIfActive(), invalidating iterators
-    for (size_t i = 0; i < pSortedObj->size(); ++i)
+    for (SwAnchoredObject* pAnchoredObj : *pSortedObj)
     {
-        SwAnchoredObject *const pAnchoredObj = (*pSortedObj)[i];
         const SwFrameFormat& rObjFormat = pAnchoredObj->GetFrameFormat();
         const SwFormatAnchor& rAnchor = rObjFormat.GetAnchor();
 
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index b9ab3aa..6696675 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -4613,9 +4613,8 @@ static void lcl_PaintShadow( const SwRect& rRect, SwRect& rOutRect,
 
     pOut->SetDrawMode( nOldDrawMode );
 
-    for ( size_t i = 0; i < aRegion.size(); ++i )
+    for (SwRect & rOut : aRegion)
     {
-        SwRect &rOut = aRegion[i];
         aOut = rOut;
         if ( rRect.IsOver( aOut ) && aOut.Height() > 0 && aOut.Width() > 0 )
         {
@@ -6766,9 +6765,8 @@ void SwLayoutFrame::RefreshLaySubsidiary( const SwPageFrame *pPage,
             else if ( pLow->GetDrawObjs() )
             {
                 const SwSortedObjs& rObjs = *(pLow->GetDrawObjs());
-                for ( size_t i = 0; i < rObjs.size(); ++i )
+                for (SwAnchoredObject* pAnchoredObj : rObjs)
                 {
-                    const SwAnchoredObject* pAnchoredObj = rObjs[i];
                     if ( pPage->GetFormat()->GetDoc()->getIDocumentDrawModelAccess().IsVisibleLayerId(
                                     pAnchoredObj->GetDrawObj()->GetLayer() ) &&
                          dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) !=  nullptr )
@@ -7248,9 +7246,8 @@ void SwPageFrame::RefreshExtraData( const SwRect &rRect ) const
         SwLayoutFrame::RefreshExtraData( aRect );
 
         if ( bLineInFly && GetSortedObjs() )
-            for ( size_t i = 0; i < GetSortedObjs()->size(); ++i )
+            for (SwAnchoredObject* pAnchoredObj : *GetSortedObjs())
             {
-                const SwAnchoredObject* pAnchoredObj = (*GetSortedObjs())[i];
                 if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) !=  nullptr )
                 {
                     const SwFlyFrame *pFly = static_cast<const SwFlyFrame*>(pAnchoredObj);
@@ -7283,9 +7280,8 @@ void SwLayoutFrame::RefreshExtraData( const SwRect &rRect ) const
             static_cast<const SwTextFrame*>(pCnt)->PaintExtraData( rRect );
         }
         if ( bLineInFly && pCnt->GetDrawObjs() )
-            for ( size_t i = 0; i < pCnt->GetDrawObjs()->size(); ++i )
+            for (SwAnchoredObject* pAnchoredObj : *pCnt->GetDrawObjs())
             {
-                const SwAnchoredObject* pAnchoredObj = (*pCnt->GetDrawObjs())[i];
                 if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) !=  nullptr )
                 {
                     const SwFlyFrame *pFly = static_cast<const SwFlyFrame*>(pAnchoredObj);
diff --git a/sw/source/core/layout/sectfrm.cxx b/sw/source/core/layout/sectfrm.cxx
index c24282c..8335368 100644
--- a/sw/source/core/layout/sectfrm.cxx
+++ b/sw/source/core/layout/sectfrm.cxx
@@ -1105,10 +1105,8 @@ class ExtraFormatToPositionObjs
                 SwSortedObjs* pObjs = pPageFrame ? pPageFrame->GetSortedObjs() : nullptr;
                 if ( pObjs )
                 {
-                    for ( size_t i = 0; i < pObjs->size(); ++i )
+                    for (SwAnchoredObject* pAnchoredObj : *pObjs)
                     {
-                        SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
-
                         if ( mpSectFrame->IsAnLower( pAnchoredObj->GetAnchorFrame() ) )
                         {
                             pAnchoredObj->SetKeepPosLocked( false );
@@ -1124,10 +1122,8 @@ class ExtraFormatToPositionObjs
             SwSortedObjs* pObjs = rFrame.GetDrawObjs();
             if ( pObjs )
             {
-                for ( size_t i = 0; i < pObjs->size(); ++i )
+                for (SwAnchoredObject* pAnchoredObj : *pObjs)
                 {
-                    SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
-
                     pAnchoredObj->UnlockPosition();
                     pAnchoredObj->SetClearedEnvironment( false );
                 }
@@ -1199,10 +1195,8 @@ class ExtraFormatToPositionObjs
                 SwSortedObjs* pObjs = pPageFrame ? pPageFrame->GetSortedObjs() : nullptr;
                 if ( pObjs )
                 {
-                    for ( size_t i = 0; i < pObjs->size(); ++i )
+                    for (SwAnchoredObject* pAnchoredObj : *pObjs)
                     {
-                        SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
-
                         if ( mpSectFrame->IsAnLower( pAnchoredObj->GetAnchorFrame() ) )
                         {
                             pAnchoredObj->SetKeepPosLocked( true );
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index f645fcd..e87418f 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -275,10 +275,8 @@ static void lcl_InvalidateLowerObjs( SwLayoutFrame& _rLayoutFrame,
         }
         if ( pLowerFrame->GetDrawObjs() )
         {
-            for ( size_t i = 0; i < pLowerFrame->GetDrawObjs()->size(); ++i )
+            for (SwAnchoredObject* pAnchoredObj : *pLowerFrame->GetDrawObjs())
             {
-                SwAnchoredObject* pAnchoredObj = (*pLowerFrame->GetDrawObjs())[i];
-
                 // invalidate position of anchored object
                 pAnchoredObj->SetTmpConsiderWrapInfluence( false );
                 pAnchoredObj->SetConsiderForTextWrap( false );
@@ -3676,13 +3674,12 @@ long CalcHeightWithFlys( const SwFrame *pFrame )
         }
         if ( pObjs )
         {
-            for ( size_t i = 0; i < pObjs->size(); ++i )
+            for (SwAnchoredObject* pAnchoredObj : *pObjs)
             {
-                const SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
                 // #i26945# - if <pTmp> is follow, the
                 // anchor character frame has to be <pTmp>.
                 if ( bIsFollow &&
-                     const_cast<SwAnchoredObject*>(pAnchoredObj)->FindAnchorCharFrame() != pTmp )
+                     pAnchoredObj->FindAnchorCharFrame() != pTmp )
                 {
                     continue;
                 }
@@ -4891,9 +4888,8 @@ void SwCellFrame::Format( vcl::RenderContext* /*pRenderContext*/, const SwBorder
         if ( pPg->GetSortedObjs() )
         {
             SwRect aRect( Prt() ); aRect += Frame().Pos();
-            for ( size_t i = 0; i < pPg->GetSortedObjs()->size(); ++i )
+            for (SwAnchoredObject* pAnchoredObj : *pPg->GetSortedObjs())
             {
-                const SwAnchoredObject* pAnchoredObj = (*pPg->GetSortedObjs())[i];
                 SwRect aTmp( pAnchoredObj->GetObjRect() );
                 if ( aTmp.IsOver( aRect ) )
                 {
diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx
index a1598d8..a102300 100644
--- a/sw/source/core/layout/trvlfrm.cxx
+++ b/sw/source/core/layout/trvlfrm.cxx
@@ -380,9 +380,8 @@ bool SwPageFrame::FillSelection( SwSelectionList& rList, const SwRect& rRect ) c
         if( GetSortedObjs() )
         {
             const SwSortedObjs &rObjs = *GetSortedObjs();
-            for ( size_t i = 0; i < rObjs.size(); ++i )
+            for (SwAnchoredObject* pAnchoredObj : rObjs)
             {
-                const SwAnchoredObject* pAnchoredObj = rObjs[i];
                 if( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) ==  nullptr )
                     continue;
                 const SwFlyFrame* pFly = static_cast<const SwFlyFrame*>(pAnchoredObj);
@@ -1905,10 +1904,9 @@ bool SwRootFrame::MakeTableCursors( SwTableCursor& rTableCursor )
 
         const bool bReadOnlyAvailable = rTableCursor.IsReadOnlyAvailable();
 
-        for ( size_t i = 0; i < aUnions.size(); ++i )
+        for (SwSelUnion & rUnion : aUnions)
         {
-            SwSelUnion *pUnion = &aUnions[i];
-            const SwTabFrame *pTable = pUnion->GetTable();
+            const SwTabFrame *pTable = rUnion.GetTable();
 
             // Skip any repeated headlines in the follow:
             SwLayoutFrame* pRow = pTable->IsFollow() ?
@@ -1917,14 +1915,14 @@ bool SwRootFrame::MakeTableCursors( SwTableCursor& rTableCursor )
 
             while ( pRow )
             {
-                if ( pRow->Frame().IsOver( pUnion->GetUnion() ) )
+                if ( pRow->Frame().IsOver( rUnion.GetUnion() ) )
                 {
                     const SwLayoutFrame *pCell = pRow->FirstCell();
 
                     while ( pCell && pRow->IsAnLower( pCell ) )
                     {
                         OSL_ENSURE( pCell->IsCellFrame(), "Frame without cell" );
-                        if( IsFrameInTableSel( pUnion->GetUnion(), pCell ) &&
+                        if( IsFrameInTableSel( rUnion.GetUnion(), pCell ) &&
                             (bReadOnlyAvailable ||
                              !pCell->GetFormat()->GetProtect().IsContentProtected()))
                         {
@@ -2571,9 +2569,8 @@ void SwRootFrame::CalcFrameRects(SwShellCursor &rCursor)
         if ( pPage->GetSortedObjs() )
         {
             const SwSortedObjs &rObjs = *pPage->GetSortedObjs();
-            for ( size_t i = 0; i < rObjs.size(); ++i )
+            for (SwAnchoredObject* pAnchoredObj : rObjs)
             {
-                SwAnchoredObject* pAnchoredObj = rObjs[i];
                 if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) ==  nullptr )
                     continue;
                 const SwFlyFrame* pFly = static_cast<const SwFlyFrame*>(pAnchoredObj);
diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index 9f04d84..52042e9 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -1518,9 +1518,8 @@ SwTwips SwFrame::AdjustNeighbourhood( SwTwips nDiff, bool bTst )
         {
             const SwSortedObjs &rObjs = *pBoss->GetDrawObjs();
             OSL_ENSURE( pBoss->IsPageFrame(), "Header/Footer out of page?" );
-            for ( size_t i = 0; i < rObjs.size(); ++i )
+            for (SwAnchoredObject* pAnchoredObj : rObjs)
             {
-                SwAnchoredObject* pAnchoredObj = rObjs[i];
                 if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) !=  nullptr )
                 {
                     SwFlyFrame* pFly = static_cast<SwFlyFrame*>(pAnchoredObj);
@@ -1882,9 +1881,8 @@ SwTwips SwContentFrame::ShrinkFrame( SwTwips nDist, bool bTst, bool bInfo )
             const SwSortedObjs* pSorted = pPage ? pPage->GetSortedObjs() : nullptr;
             if( pSorted )
             {
-                for ( size_t i = 0; i < pSorted->size(); ++i )
+                for (SwAnchoredObject* pAnchoredObj : *pSorted)
                 {
-                    const SwAnchoredObject* pAnchoredObj = (*pSorted)[i];
                     const SwRect aBound( pAnchoredObj->GetObjRectWithSpaces() );
 
                     if( aBound.Left() > aRect.Right() )
@@ -3059,9 +3057,8 @@ void SwLayoutFrame::Format( vcl::RenderContext* /*pRenderContext*/, const SwBord
 static void InvaPercentFlys( SwFrame *pFrame, SwTwips nDiff )
 {
     OSL_ENSURE( pFrame->GetDrawObjs(), "Can't find any Objects" );
-    for ( size_t i = 0; i < pFrame->GetDrawObjs()->size(); ++i )
+    for (SwAnchoredObject* pAnchoredObj : *pFrame->GetDrawObjs())
     {
-        SwAnchoredObject* pAnchoredObj = (*pFrame->GetDrawObjs())[i];
         if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) !=  nullptr )
         {
             SwFlyFrame *pFly = static_cast<SwFlyFrame*>(pAnchoredObj);
@@ -3315,10 +3312,8 @@ void SwLayoutFrame::FormatWidthCols( const SwBorderAttrs &rAttrs,
         SwSortedObjs* pObjs = pPageFrame ? pPageFrame->GetSortedObjs() : nullptr;
         if ( pObjs )
         {
-            for ( size_t i = 0; i < pObjs->size(); ++i )
+            for (SwAnchoredObject* pAnchoredObj : *pObjs)
             {
-                SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
-
                 if ( IsAnLower( pAnchoredObj->GetAnchorFrame() ) )
                 {
                     pAnchoredObj->SetTmpConsiderWrapInfluence( false );
@@ -3511,10 +3506,8 @@ void SwLayoutFrame::FormatWidthCols( const SwBorderAttrs &rAttrs,
                     SwSortedObjs* pTmpObjs = pTmpPageFrame ? pTmpPageFrame->GetSortedObjs() : nullptr;
                     if ( pTmpObjs )
                     {
-                        for ( size_t i = 0; i < pTmpObjs->size(); ++i )
+                        for (SwAnchoredObject* pAnchoredObj : *pTmpObjs)
                         {
-                            SwAnchoredObject* pAnchoredObj = (*pTmpObjs)[i];
-
                             if ( IsAnLower( pAnchoredObj->GetAnchorFrame() ) )
                             {
                                 pAnchoredObj->SetTmpConsiderWrapInfluence( false );
@@ -3666,9 +3659,8 @@ static void lcl_InvalidateContent( SwContentFrame *pCnt, SwInvalidateFlags nInv
 static void lcl_InvalidateAllContent( SwContentFrame *pCnt, SwInvalidateFlags nInv )
 {
     SwSortedObjs &rObjs = *pCnt->GetDrawObjs();
-    for ( size_t i = 0; i < rObjs.size(); ++i )
+    for (SwAnchoredObject* pAnchoredObj : rObjs)
     {
-        SwAnchoredObject* pAnchoredObj = rObjs[i];
         if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) !=  nullptr )
         {
             SwFlyFrame *pFly = static_cast<SwFlyFrame*>(pAnchoredObj);
@@ -3698,9 +3690,8 @@ void SwRootFrame::InvalidateAllContent( SwInvalidateFlags nInv )
         if ( pPage->GetSortedObjs() )
         {
             const SwSortedObjs &rObjs = *pPage->GetSortedObjs();
-            for ( size_t i = 0; i < rObjs.size(); ++i )
+            for (SwAnchoredObject* pAnchoredObj : rObjs)
             {
-                SwAnchoredObject* pAnchoredObj = rObjs[i];
                 if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) !=  nullptr )
                 {
                     SwFlyFrame* pFly = static_cast<SwFlyFrame*>(pAnchoredObj);
@@ -3740,9 +3731,8 @@ void SwRootFrame::InvalidateAllObjPos()
         if ( pPageFrame->GetSortedObjs() )
         {
             const SwSortedObjs& rObjs = *(pPageFrame->GetSortedObjs());
-            for ( size_t i = 0; i < rObjs.size(); ++i )
+            for (SwAnchoredObject* pAnchoredObj : rObjs)
             {
-                SwAnchoredObject* pAnchoredObj = rObjs[i];
                 const SwFormatAnchor& rAnch = pAnchoredObj->GetFrameFormat().GetAnchor();
                 if ((rAnch.GetAnchorId() != FLY_AT_PARA) &&
                     (rAnch.GetAnchorId() != FLY_AT_CHAR))
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index ef3f738..3f997d7 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -293,9 +293,8 @@ static void lcl_ModifyLines( SwTableLines &rLines, const long nOld,
         ::lcl_ModifyBoxes( rLines[i]->GetTabBoxes(), nOld, nNew, rFormatArr );
     if( bCheckSum )
     {
-        for( size_t i = 0; i < rFormatArr.size(); ++i )
+        for(SwFormat* pFormat : rFormatArr)
         {
-            SwFormat* pFormat = rFormatArr[i];
             const SwTwips nBox = lcl_MulDiv64<SwTwips>(pFormat->GetFrameSize().GetWidth(), nNew, nOld);
             SwFormatFrameSize aNewBox( ATT_VAR_SIZE, nBox, 0 );
             pFormat->LockModify();
diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index 076a2ae3..24ece60 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -1589,7 +1589,7 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport()
 
                         // Link PageNums
                         std::vector<sal_Int32> aNotePageNums = CalcOutputPageNums( rNoteRect );
-                        for ( size_t nNumIdx = 0; nNumIdx < aNotePageNums.size(); ++nNumIdx )
+                        for (sal_Int32 aNotePageNum : aNotePageNums)
                         {
                             // Link Note
                             vcl::PDFNote aNote;
@@ -1612,7 +1612,7 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport()
 
                             // Link Export
                             Rectangle aRect(SwRectToPDFRect(pCurrPage, rNoteRect.SVRect()));
-                            pPDFExtOutDevData->CreateNote(aRect, aNote, aNotePageNums[nNumIdx]);
+                            pPDFExtOutDevData->CreateNote(aRect, aNote, aNotePageNum);
                         }
                     }
                 }
@@ -1706,12 +1706,12 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport()
                             // Link PageNums
                             std::vector<sal_Int32> aLinkPageNums = CalcOutputPageNums( rLinkRect );
 
-                            for ( size_t nNumIdx = 0; nNumIdx < aLinkPageNums.size(); ++nNumIdx )
+                            for (sal_Int32 aLinkPageNum : aLinkPageNums)
                             {
                                 // Link Export
                                 Rectangle aRect(SwRectToPDFRect(pSelectionPage, rLinkRect.SVRect()));
                                 const sal_Int32 nLinkId =
-                                    pPDFExtOutDevData->CreateLink(aRect, aLinkPageNums[nNumIdx]);
+                                    pPDFExtOutDevData->CreateLink(aRect, aLinkPageNum);
 
                                 // Store link info for tagged pdf output:
                                 const IdMapEntry aLinkEntry( rLinkRect, nLinkId );
@@ -1784,11 +1784,11 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport()
                     std::vector<sal_Int32> aLinkPageNums = CalcOutputPageNums( aLinkRect );
 
                     // Link Export
-                    for ( size_t nNumIdx = 0; nNumIdx < aLinkPageNums.size(); ++nNumIdx )
+                    for (sal_Int32 aLinkPageNum : aLinkPageNums)
                     {
                         Rectangle aRect(SwRectToPDFRect(pCurrPage, aLinkRect.SVRect()));
                         const sal_Int32 nLinkId =
-                            pPDFExtOutDevData->CreateLink(aRect, aLinkPageNums[nNumIdx]);
+                            pPDFExtOutDevData->CreateLink(aRect, aLinkPageNum);
 
                         // Connect Link and Destination:
                         if ( bIntern )
@@ -1875,12 +1875,12 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport()
                             // Link PageNums
                             std::vector<sal_Int32> aLinkPageNums = CalcOutputPageNums( rLinkRect );
 
-                            for ( size_t nNumIdx = 0; nNumIdx < aLinkPageNums.size(); ++nNumIdx )
+                            for (sal_Int32 aLinkPageNum : aLinkPageNums)
                             {
                                 // Link Export
                                 aRect = SwRectToPDFRect(pCurrPage, rLinkRect.SVRect());
                                 const sal_Int32 nLinkId =
-                                    pPDFExtOutDevData->CreateLink(aRect, aLinkPageNums[nNumIdx]);
+                                    pPDFExtOutDevData->CreateLink(aRect, aLinkPageNum);
 
                                 // Store link info for tagged pdf output:
                                 const IdMapEntry aLinkEntry( rLinkRect, nLinkId );
@@ -1955,12 +1955,12 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport()
                 // Destination PageNum
                 const sal_Int32 nDestPageNum = CalcOutputPageNum( rDestRect );
 
-                for ( size_t nNumIdx = 0; nNumIdx < aLinkPageNums.size(); ++nNumIdx )
+                for (sal_Int32 aLinkPageNum : aLinkPageNums)
                 {
                     // Link Export
                     Rectangle aRect(SwRectToPDFRect(pCurrPage, aLinkRect.SVRect()));
                     const sal_Int32 nLinkId =
-                        pPDFExtOutDevData->CreateLink(aRect, aLinkPageNums[nNumIdx]);
+                        pPDFExtOutDevData->CreateLink(aRect, aLinkPageNum);
 
                     // Store link info for tagged pdf output:
                     const IdMapEntry aLinkEntry( aLinkRect, nLinkId );
@@ -2233,12 +2233,12 @@ void SwEnhancedPDFExportHelper::MakeHeaderFooterLinks( vcl::PDFExtOutDevData& rP
                 // Link PageNums
                 std::vector<sal_Int32> aHFLinkPageNums = CalcOutputPageNums( aHFLinkRect );
 
-                for ( size_t nNumIdx = 0; nNumIdx < aHFLinkPageNums.size(); ++nNumIdx )
+                for (sal_Int32 aHFLinkPageNum : aHFLinkPageNums)
                 {
                     // Link Export
                     Rectangle aRect(SwRectToPDFRect(pPageFrame, aHFLinkRect.SVRect()));
                     const sal_Int32 nHFLinkId =
-                        rPDFExtOutDevData.CreateLink(aRect, aHFLinkPageNums[nNumIdx]);
+                        rPDFExtOutDevData.CreateLink(aRect, aHFLinkPageNum);
 
                     // Connect Link and Destination:
                     if ( bIntern )
diff --git a/sw/source/core/text/atrstck.cxx b/sw/source/core/text/atrstck.cxx
index c5dea97..2766ac5 100644
--- a/sw/source/core/text/atrstck.cxx
+++ b/sw/source/core/text/atrstck.cxx
@@ -411,8 +411,8 @@ void SwAttrHandler::Init( const SfxPoolItem** pPoolItem, const SwAttrSet* pAS,
 
 void SwAttrHandler::Reset( )
 {
-    for ( sal_uInt16 i = 0; i < NUM_ATTRIBUTE_STACKS; i++ )
-        aAttrStack[ i ].Reset();
+    for (SwAttrStack & i : aAttrStack)
+        i.Reset();
 }
 
 void SwAttrHandler::PushAndChg( const SwTextAttr& rAttr, SwFont& rFnt )
diff --git a/sw/source/core/text/itrcrsr.cxx b/sw/source/core/text/itrcrsr.cxx
index 6be0145..3f8acaa 100644
--- a/sw/source/core/text/itrcrsr.cxx
+++ b/sw/source/core/text/itrcrsr.cxx
@@ -1869,9 +1869,8 @@ bool SwTextFrame::FillSelection( SwSelectionList& rSelList, const SwRect& rRect
     if( GetDrawObjs() )
     {
         const SwSortedObjs &rObjs = *GetDrawObjs();
-        for ( size_t i = 0; i < rObjs.size(); ++i )
+        for (SwAnchoredObject* pAnchoredObj : rObjs)
         {
-            const SwAnchoredObject* pAnchoredObj = rObjs[i];
             if( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) ==  nullptr )
                 continue;
             const SwFlyFrame* pFly = static_cast<const SwFlyFrame*>(pAnchoredObj);
diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx
index c8ac92c..8c489de 100644
--- a/sw/source/core/text/porfld.cxx
+++ b/sw/source/core/text/porfld.cxx
@@ -1089,8 +1089,8 @@ SwCombinedPortion::SwCombinedPortion( const OUString &rText )
     }
     else
     {
-        for( int i = 0; i < 6; ++i )
-            aScrType[i] = SwFontScript::Latin;
+        for(SwFontScript & rn : aScrType)
+            rn = SwFontScript::Latin;
     }
     memset( &aWidth, 0, sizeof(aWidth) );
 }
diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index be55e84..0c9ebb6 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -1749,9 +1749,9 @@ bool SwScriptInfo::IsArabicText( const OUString& rText, sal_Int32 nStt, sal_Int3
 
 bool SwScriptInfo::IsKashidaValid(sal_Int32 nKashPos) const
 {
-    for ( size_t i = 0; i < aKashidaInvalid.size(); ++i )
+    for (sal_Int32 i : aKashidaInvalid)
     {
-        if ( aKashidaInvalid [ i ] == nKashPos )
+        if ( i == nKashPos )
             return false;
     }
     return true;
diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx
index 761e0d9..83e13d2 100644
--- a/sw/source/core/text/redlnitr.cxx
+++ b/sw/source/core/text/redlnitr.cxx
@@ -363,9 +363,9 @@ bool SwRedlineItr::ChkSpecialUnderline_() const
     // If the underlining or the escapement is caused by redlining,
     // we always apply the SpecialUnderlining, i.e. the underlining
     // below the base line
-    for (size_t i = 0; i < m_Hints.size(); ++i)
+    for (SwTextAttr* pHint : m_Hints)
     {
-        const sal_uInt16 nWhich = m_Hints[i]->Which();
+        const sal_uInt16 nWhich = pHint->Which();
         if( RES_CHRATR_UNDERLINE == nWhich ||
             RES_CHRATR_ESCAPEMENT == nWhich )
             return true;
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index 2400c2b..acb8831 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -575,16 +575,16 @@ void SwTextFrame::HideAndShowObjects()
         if ( IsHiddenNow() )
         {
             // complete paragraph is hidden. Thus, hide all objects
-            for ( size_t i = 0; i < GetDrawObjs()->size(); ++i )
+            for (SwAnchoredObject* i : *GetDrawObjs())
             {
-                SdrObject* pObj = (*GetDrawObjs())[i]->DrawObj();
+                SdrObject* pObj = i->DrawObj();
                 SwContact* pContact = static_cast<SwContact*>(pObj->GetUserCall());
                 // under certain conditions
                 const RndStdIds eAnchorType( pContact->GetAnchorId() );
                 const sal_Int32 nObjAnchorPos = pContact->GetContentAnchorIndex().GetIndex();
                 if ((eAnchorType != FLY_AT_CHAR) ||
                     sw_HideObj( *this, eAnchorType, nObjAnchorPos,
-                                 (*GetDrawObjs())[i] ))
+                                 i ))
                 {
                     pContact->MoveObjToInvisibleLayer( pObj );
                 }
@@ -602,9 +602,9 @@ void SwTextFrame::HideAndShowObjects()
             // Thus, show all objects, which are anchored at paragraph and
             // hide/show objects, which are anchored at/as character, according
             // to the visibility of the anchor character.
-            for ( size_t i = 0; i < GetDrawObjs()->size(); ++i )
+            for (SwAnchoredObject* i : *GetDrawObjs())
             {
-                SdrObject* pObj = (*GetDrawObjs())[i]->DrawObj();
+                SdrObject* pObj = i->DrawObj();
                 SwContact* pContact = static_cast<SwContact*>(pObj->GetUserCall());
                 // Determine anchor type only once
                 const RndStdIds eAnchorType( pContact->GetAnchorId() );
@@ -622,7 +622,7 @@ void SwTextFrame::HideAndShowObjects()
                     SwScriptInfo::GetBoundsOfHiddenRange( rNode, nObjAnchorPos, nHiddenStart, nHiddenEnd );
                     // Under certain conditions
                     if ( nHiddenStart != COMPLETE_STRING && bShouldBeHidden &&
-                         sw_HideObj( *this, eAnchorType, nObjAnchorPos, (*GetDrawObjs())[i] ) )
+                         sw_HideObj( *this, eAnchorType, nObjAnchorPos, i ) )
                         pContact->MoveObjToInvisibleLayer( pObj );
                     else
                         pContact->MoveObjToVisibleLayer( pObj );
diff --git a/sw/source/core/text/txtftn.cxx b/sw/source/core/text/txtftn.cxx
index 7d972ee..1eb36ef 100644
--- a/sw/source/core/text/txtftn.cxx
+++ b/sw/source/core/text/txtftn.cxx
@@ -226,9 +226,8 @@ static SwTwips lcl_GetFootnoteLower( const SwTextFrame* pFrame, SwTwips nLower )
         if ( pStartFrame->GetDrawObjs() )
         {
             const SwSortedObjs &rObjs = *pStartFrame->GetDrawObjs();
-            for ( size_t i = 0; i < rObjs.size(); ++i )
+            for (SwAnchoredObject* pAnchoredObj : rObjs)
             {
-                SwAnchoredObject* pAnchoredObj = rObjs[i];
                 SwRect aRect( pAnchoredObj->GetObjRect() );
 
                 if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) ==  nullptr ||
diff --git a/sw/source/core/text/wrong.cxx b/sw/source/core/text/wrong.cxx
index e0a14d1..40d315e 100644
--- a/sw/source/core/text/wrong.cxx
+++ b/sw/source/core/text/wrong.cxx
@@ -72,20 +72,20 @@ void SwWrongList::CopyFrom( const SwWrongList& rCopy )
     meType = rCopy.meType;
     nBeginInvalid = rCopy.nBeginInvalid;
     nEndInvalid = rCopy.nEndInvalid;
-    for( size_t i = 0; i < maList.size(); ++i )
+    for(SwWrongArea & i : maList)
     {
-        if( maList[i].mpSubList )
-            maList[i].mpSubList = maList[i].mpSubList->Clone();
+        if( i.mpSubList )
+            i.mpSubList = i.mpSubList->Clone();
     }
 }
 
 void SwWrongList::ClearList()
 {
-    for ( size_t i = 0; i < maList.size(); ++i)
+    for (SwWrongArea & i : maList)
     {
-        if (maList[i].mpSubList)
-            delete maList[i].mpSubList;
-        maList[i].mpSubList = nullptr;
+        if (i.mpSubList)
+            delete i.mpSubList;
+        i.mpSubList = nullptr;
     }
     maList.clear();
 }
diff --git a/sw/source/core/text/xmldump.cxx b/sw/source/core/text/xmldump.cxx
index cedffc9..8085036 100644
--- a/sw/source/core/text/xmldump.cxx
+++ b/sw/source/core/text/xmldump.cxx
@@ -309,9 +309,8 @@ void SwFrame::dumpAsXml( xmlTextWriterPtr writer ) const
         {
             xmlTextWriterStartElement( writer, BAD_CAST( "anchored" ) );
 
-            for ( size_t i = 0, len = pAnchored->size(); i < len; ++i )
+            for (SwAnchoredObject* pObject : *pAnchored)
             {
-                SwAnchoredObject* pObject = (*pAnchored)[i];
                 pObject->dumpAsXml( writer );
             }
 
diff --git a/sw/source/core/tox/tox.cxx b/sw/source/core/tox/tox.cxx
index 171755e..ee0617d 100644
--- a/sw/source/core/tox/tox.cxx
+++ b/sw/source/core/tox/tox.cxx
@@ -677,14 +677,14 @@ static FormTokenType lcl_GetTokenType(const OUString & sToken,
         { SwForm::GetFormAuth(),        3, TOKEN_AUTHORITY }
     };
 
-    for( size_t i = 0; i<SAL_N_ELEMENTS(aTokenArr); ++i )
+    for(const auto & i : aTokenArr)
     {
-        const sal_Int32 nLen(aTokenArr[i].sNm.getLength());
-        if( sToken.startsWith( aTokenArr[i].sNm.copy(0, nLen - aTokenArr[i].nOffset) ))
+        const sal_Int32 nLen(i.sNm.getLength());
+        if( sToken.startsWith( i.sNm.copy(0, nLen - i.nOffset) ))
         {
             if (pTokenLen)
                 *pTokenLen = nLen;
-            return aTokenArr[ i ].eToken;
+            return i.eToken;
         }
     }
 
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 99b7768..13064a1 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -1036,9 +1036,8 @@ void SwTextNode::Update(
     if ( !bNegative && !bDelete )
     {
         const SwRedlineTable& rTable = GetDoc()->getIDocumentRedlineAccess().GetRedlineTable();
-        for ( size_t i = 0; i < rTable.size(); ++i )
+        for (SwRangeRedline* pRedl : rTable)
         {
-            SwRangeRedline *const pRedl = rTable[ i ];
             if ( pRedl->HasMark() )
             {
                 SwPosition* const pEnd = pRedl->End();
@@ -1873,16 +1872,15 @@ void SwTextNode::CopyText( SwTextNode *const pDest,
 
     // nur falls im Array Attribute stehen (kann nur beim Kopieren
     // sich selbst passieren!!)
-    for ( size_t i = 0; i < aArr.size(); ++i )
+    for (SwTextAttr* i : aArr)
     {
-        InsertHint( aArr[ i ], SetAttrMode::NOTXTATRCHR );
+        InsertHint( i, SetAttrMode::NOTXTATRCHR );
     }
 
     if( pDest->GetpSwpHints() )
     {
-        for ( size_t i = 0; i < aRefMrkArr.size(); ++i )
+        for (SwTextAttr* pNewHt : aRefMrkArr)
         {
-            SwTextAttr * const pNewHt = aRefMrkArr[i];
             if( pNewHt->GetEnd() )
             {
                 pDest->GetpSwpHints()->Delete( pNewHt );
@@ -2216,9 +2214,8 @@ void SwTextNode::CutImpl( SwTextNode * const pDest, const SwIndex & rDestStart,
         }
         Update( rStart, nLen, true, true );
 
-        for (size_t n = 0; n < aArr.size(); ++n)
+        for (SwTextAttr* pHt : aArr)
         {
-            SwTextAttr * const pHt = aArr[ n ];
             pHt->GetStart() = *pHt->GetEnd() = rStart.GetIndex();
             InsertHint( pHt );
         }
diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx
index 5a3805b..2e8a57e 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -1195,11 +1195,11 @@ bool SwTextNode::Convert( SwConversionArgs &rArgs )
         } while (!bFound && aIter.Next());  /* loop while nothing was found and still sth is left to be searched */
 
         // Apply implicit changes, if any, now that aIter is no longer used
-        for (size_t i = 0; i < aImplicitChanges.size(); ++i)
+        for (const std::pair<int,int> & rImplicitChange : aImplicitChanges)
         {
-            SwPaM aPaM( *this, aImplicitChanges[i].first );
+            SwPaM aPaM( *this, rImplicitChange.first );
             aPaM.SetMark();
-            aPaM.GetPoint()->nContent = aImplicitChanges[i].second;
+            aPaM.GetPoint()->nContent = rImplicitChange.second;
             SetLanguageAndFont( aPaM, rArgs.nConvTargetLang, RES_CHRATR_CJK_LANGUAGE, rArgs.pTargetFont, RES_CHRATR_CJK_FONT );
         }
 
diff --git a/sw/source/core/undo/undraw.cxx b/sw/source/core/undo/undraw.cxx
index 56d5331..ba52ed4 100644
--- a/sw/source/core/undo/undraw.cxx
+++ b/sw/source/core/undo/undraw.cxx
@@ -457,10 +457,9 @@ SwUndoDrawUnGroupConnectToLayout::~SwUndoDrawUnGroupConnectToLayout()
 void
 SwUndoDrawUnGroupConnectToLayout::UndoImpl(::sw::UndoRedoContext &)
 {
-    for ( std::vector< SdrObject >::size_type i = 0;
-          i < aDrawFormatsAndObjs.size(); ++i )
+    for (const std::pair< SwDrawFrameFormat*, SdrObject* > & rPair : aDrawFormatsAndObjs)
     {
-        SdrObject* pObj( aDrawFormatsAndObjs[i].second );
+        SdrObject* pObj( rPair.second );
         SwDrawContact* pDrawContact( dynamic_cast<SwDrawContact*>(pObj->GetUserCall()) );
         OSL_ENSURE( pDrawContact,
                 "<SwUndoDrawUnGroupConnectToLayout::Undo(..)> -- missing SwDrawContact instance" );
@@ -477,11 +476,10 @@ SwUndoDrawUnGroupConnectToLayout::UndoImpl(::sw::UndoRedoContext &)
 void
 SwUndoDrawUnGroupConnectToLayout::RedoImpl(::sw::UndoRedoContext &)
 {
-    for ( std::vector< std::pair< SwDrawFrameFormat*, SdrObject* > >::size_type i = 0;
-          i < aDrawFormatsAndObjs.size(); ++i )
+    for (const std::pair< SwDrawFrameFormat*, SdrObject* > & rPair : aDrawFormatsAndObjs)
     {
-        SwDrawFrameFormat* pFormat( aDrawFormatsAndObjs[i].first );
-        SdrObject* pObj( aDrawFormatsAndObjs[i].second );
+        SwDrawFrameFormat* pFormat( rPair.first );
+        SdrObject* pObj( rPair.second );
         SwDrawContact *pContact = new SwDrawContact( pFormat, pObj );
         pContact->ConnectToLayout();
         pContact->MoveObjToVisibleLayer( pObj );
diff --git a/sw/source/core/undo/unins.cxx b/sw/source/core/undo/unins.cxx
index 436a006..f105bbc 100644
--- a/sw/source/core/undo/unins.cxx
+++ b/sw/source/core/undo/unins.cxx
@@ -170,9 +170,8 @@ bool SwUndoInsert::CanGrouping( const SwPosition& rPos )
             {
                 SwRedlineData aRData( nsRedlineType_t::REDLINE_INSERT, rDoc.getIDocumentRedlineAccess().GetRedlineAuthor() );
                 const SwIndexReg* pIReg = rPos.nContent.GetIdxReg();
-                for( size_t i = 0; i < rTable.size(); ++i )
+                for(SwRangeRedline* pRedl : rTable)
                 {
-                    SwRangeRedline* pRedl = rTable[ i ];
                     SwIndex* pIdx = &pRedl->End()->nContent;
                     if( pIReg == pIdx->GetIdxReg() &&
                         nContent == pIdx->GetIndex() )
diff --git a/sw/source/core/undo/unovwr.cxx b/sw/source/core/undo/unovwr.cxx
index 1fe6021..25c178b 100644
--- a/sw/source/core/undo/unovwr.cxx
+++ b/sw/source/core/undo/unovwr.cxx
@@ -349,8 +349,8 @@ SwUndoTransliterate::SwUndoTransliterate(
 
 SwUndoTransliterate::~SwUndoTransliterate()
 {
-    for (size_t i = 0; i < aChanges.size();  ++i)
-        delete aChanges[i];
+    for (UndoTransliterate_Data* p : aChanges)
+        delete p;
 }
 
 void SwUndoTransliterate::UndoImpl(::sw::UndoRedoContext & rContext)
diff --git a/sw/source/core/undo/unsort.cxx b/sw/source/core/undo/unsort.cxx
index 4833545..1f62d42 100644
--- a/sw/source/core/undo/unsort.cxx
+++ b/sw/source/core/undo/unsort.cxx
@@ -92,12 +92,12 @@ void SwUndoSort::UndoImpl(::sw::UndoRedoContext & rContext)
         const SwTable& rTable = pTableNd->GetTable();
 
         SwMovedBoxes aMovedList;
-        for (size_t i=0; i < m_SortList.size(); i++)
+        for (std::unique_ptr<SwSortUndoElement> & i : m_SortList)
         {
             const SwTableBox* pSource = rTable.GetTableBox(
-                    *m_SortList[i]->SORT_TXT_TBL.TBL.pSource );
+                    *i->SORT_TXT_TBL.TBL.pSource );
             const SwTableBox* pTarget = rTable.GetTableBox(
-                    *m_SortList[i]->SORT_TXT_TBL.TBL.pTarget );
+                    *i->SORT_TXT_TBL.TBL.pTarget );
 
             // move back
             MoveCell(&rDoc, pTarget, pSource,
@@ -125,12 +125,12 @@ void SwUndoSort::UndoImpl(::sw::UndoRedoContext & rContext)
 
         for (size_t i = 0; i < m_SortList.size(); ++i)
         {
-            for (size_t ii = 0; ii < m_SortList.size(); ++ii)
+            for (std::unique_ptr<SwSortUndoElement> & j : m_SortList)
             {
-                if (m_SortList[ii]->SORT_TXT_TBL.TXT.nSource == nSttNode + i)
+                if (j->SORT_TXT_TBL.TXT.nSource == nSttNode + i)
                 {
                     SwNodeIndex* pIdx = new SwNodeIndex( rDoc.GetNodes(),
-                        m_SortList[ii]->SORT_TXT_TBL.TXT.nTarget );
+                        j->SORT_TXT_TBL.TXT.nTarget );
                     aIdxList.insert( aIdxList.begin() + i, pIdx );
                     break;
                 }
@@ -171,12 +171,12 @@ void SwUndoSort::RedoImpl(::sw::UndoRedoContext & rContext)
         const SwTable& rTable = pTableNd->GetTable();
 
         SwMovedBoxes aMovedList;
-        for (size_t i = 0; i < m_SortList.size(); ++i)
+        for (std::unique_ptr<SwSortUndoElement> & i : m_SortList)
         {
             const SwTableBox* pSource = rTable.GetTableBox(
-                    *m_SortList[i]->SORT_TXT_TBL.TBL.pSource );
+                    *i->SORT_TXT_TBL.TBL.pSource );
             const SwTableBox* pTarget = rTable.GetTableBox(
-                    *m_SortList[i]->SORT_TXT_TBL.TBL.pTarget );
+                    *i->SORT_TXT_TBL.TBL.pTarget );
 
             // move back
             MoveCell(&rDoc, pSource, pTarget,
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index f6d17a1..c6c1e69 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -1787,12 +1787,12 @@ void SwUndoTableNdsChg::UndoImpl(::sw::UndoRedoContext & rContext)
 
     // do this _after_ deleting Frames because disposing SwAccessible requires
     // connection to the nodes, see SwAccessibleChild::IsAccessible()
-    for (size_t i = 0; i < aDelNodes.size(); ++i)
+    for (const std::pair<SwTableBox *, sal_uLong> & rDelNode : aDelNodes)
     {
         // first disconnect box from node, otherwise ~SwTableBox would
         // access pBox->pSttNd, deleted by DeleteSection
-        aDelNodes[i].first->RemoveFromTable();
-        rDoc.getIDocumentContentOperations().DeleteSection(rDoc.GetNodes()[ aDelNodes[i].second ]);
+        rDelNode.first->RemoveFromTable();
+        rDoc.getIDocumentContentOperations().DeleteSection(rDoc.GetNodes()[ rDelNode.second ]);
     }
 
     // Remove boxes from table structure
diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx
index b66916d..09ee314 100644
--- a/sw/source/core/unocore/unocoll.cxx
+++ b/sw/source/core/unocore/unocoll.cxx
@@ -485,9 +485,9 @@ uno::Sequence<OUString>     SwXServiceProvider::GetAllServiceNames()
     uno::Sequence<OUString> aRet(nEntries);
     OUString* pArray = aRet.getArray();
     sal_uInt16 n = 0;
-    for(sal_uInt16 i = 0; i < nEntries; i++)
+    for(const ProvNamesId_Type & i : aProvNamesId)
     {
-        OUString sProv(OUString::createFromAscii(aProvNamesId[i].pName));
+        OUString sProv(OUString::createFromAscii(i.pName));
         if(!sProv.isEmpty())
         {
             pArray[n] = sProv;
@@ -501,11 +501,10 @@ uno::Sequence<OUString>     SwXServiceProvider::GetAllServiceNames()
 
 sal_uInt16  SwXServiceProvider::GetProviderType(const OUString& rServiceName)
 {
-    const sal_uInt16 nEntries = SAL_N_ELEMENTS(aProvNamesId);
-    for(sal_uInt16 i = 0; i < nEntries; i++ )
+    for(const ProvNamesId_Type & i : aProvNamesId)
     {
-        if (rServiceName.equalsAscii(aProvNamesId[i].pName))
-            return aProvNamesId[i].nType;
+        if (rServiceName.equalsAscii(i.pName))
+            return i.nType;
     }
     return SW_SERVICE_INVALID;
 }
diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx
index 69ded11..beea48c 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -3022,9 +3022,9 @@ SwXFieldEnumeration::SwXFieldEnumeration(SwDoc & rDoc)
     // now handle meta-fields, which are not SwFields
     const ::std::vector< uno::Reference<text::XTextField> > MetaFields(
            m_pImpl->m_pDoc->GetMetaFieldManager().getMetaFields() );
-    for (size_t i = 0; i < MetaFields.size(); ++i)
+    for (const auto & rMetaField : MetaFields)
     {
-        m_pImpl->m_Items.push_back( MetaFields[i] );
+        m_pImpl->m_Items.push_back( rMetaField );
     }
 }
 
diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx
index 61812a6..cb901d5 100644
--- a/sw/source/core/unocore/unoidx.cxx
+++ b/sw/source/core/unocore/unoidx.cxx
@@ -936,9 +936,8 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException,
                     SwSections aSectArr;
                     pSectionFormat->GetChildSections(aSectArr,
                             SORTSECT_NOT, false);
-                    for(size_t i = 0; i < aSectArr.size(); ++i)
+                    for(SwSection* pSect : aSectArr)
                     {
-                        SwSection* pSect = aSectArr[i];
                         if(pSect->GetType() == TOX_HEADER_SECTION)
                         {
                             const uno::Reference <text::XTextSection> xHeader =
diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx
index 9f8333f..dbad25a 100644
--- a/sw/source/core/unocore/unosect.cxx
+++ b/sw/source/core/unocore/unosect.cxx
@@ -1134,9 +1134,8 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException,
                 }
                 const SwRedlineTable& rRedTable =
                     pFormat->GetDoc()->getIDocumentRedlineAccess().GetRedlineTable();
-                for (size_t nRed = 0; nRed < rRedTable.size(); ++nRed)
+                for (SwRangeRedline* pRedline : rRedTable)
                 {
-                    const SwRangeRedline* pRedline = rRedTable[nRed];
                     const SwNode& rRedPointNode = pRedline->GetNode();
                     const SwNode& rRedMarkNode = pRedline->GetNode(false);
                     if ((&rRedPointNode == pSectNode) ||
diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx
index 92b4931..cd84531 100644
--- a/sw/source/core/unocore/unosett.cxx
+++ b/sw/source/core/unocore/unosett.cxx
@@ -1514,9 +1514,8 @@ static PropertyValue const* lcl_FindProperty(
     const char* cName, std::vector<PropertyValue const*> const& rPropertyValues)
 {
     const OUString sCmp = OUString::createFromAscii(cName);
-    for(size_t i = 0; i < rPropertyValues.size(); ++i)
+    for(const PropertyValue* pTemp : rPropertyValues)
     {
-        PropertyValue const*const pTemp = rPropertyValues[i];
         if (sCmp == pTemp->Name)
             return pTemp;
     }
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index 79fc84e..319b4ac 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -1128,9 +1128,8 @@ void SwViewShell::VisPortChgd( const SwRect &rRect)
                     {
                         const long nOfst = GetOut()->PixelToLogic(
                             Size(Imp()->GetDrawView()->GetMarkHdlSizePixel()/2,0)).Width();
-                        for ( size_t i = 0; i < pPage->GetSortedObjs()->size(); ++i )
+                        for (SwAnchoredObject* pObj : *pPage->GetSortedObjs())
                         {
-                            SwAnchoredObject* pObj = (*pPage->GetSortedObjs())[i];
                             // ignore objects that are not actually placed on the page
                             if (pObj->IsFormatPossible())
                             {
diff --git a/sw/source/filter/basflt/fltini.cxx b/sw/source/filter/basflt/fltini.cxx
index 8075b89..a40c11f 100644
--- a/sw/source/filter/basflt/fltini.cxx
+++ b/sw/source/filter/basflt/fltini.cxx
@@ -126,9 +126,8 @@ Filters::Filters()
 Filters::~Filters()
 {
     // kill Readers
-    for( sal_uInt16 n = 0; n < MAXFILTER; ++n )

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list