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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Oct 30 06:52:49 UTC 2018


 sw/source/ui/chrdlg/pardlg.cxx                     |    4 
 sw/source/ui/config/optcomp.cxx                    |   24 +---
 sw/source/ui/config/optpage.cxx                    |   13 +-
 sw/source/ui/dbui/createaddresslistdialog.cxx      |   60 +++++------
 sw/source/ui/dbui/customizeaddresslistdialog.cxx   |   37 ++-----
 sw/source/ui/dbui/mmaddressblockpage.cxx           |   74 ++++++--------
 sw/source/ui/dialog/ascfldlg.cxx                   |    5 
 sw/source/ui/envelp/label1.cxx                     |    6 -
 sw/source/ui/fmtui/tmpdlg.cxx                      |    4 
 sw/source/ui/frmdlg/frmpage.cxx                    |   39 +++----
 sw/source/ui/index/cntex.cxx                       |    6 -
 sw/source/ui/index/cnttab.cxx                      |   83 ++++++----------
 sw/source/ui/vba/vbadocumentproperties.cxx         |    8 -
 sw/source/ui/vba/vbarevisions.cxx                  |    6 -
 sw/source/ui/vba/vbatables.cxx                     |    7 -
 sw/source/uibase/config/StoredChapterNumbering.cxx |   10 -
 sw/source/uibase/dbui/mmconfigitem.cxx             |   50 +++------
 sw/source/uibase/dochdl/swdtflvr.cxx               |   11 --
 sw/source/uibase/docvw/FrameControlsManager.cxx    |   30 +----
 sw/source/uibase/docvw/PostItMgr.cxx               |   74 ++++++--------
 sw/source/uibase/docvw/frmsidebarwincontainer.cxx  |   38 ++-----
 sw/source/uibase/envelp/labelcfg.cxx               |    5 
 sw/source/uibase/lingu/olmenu.cxx                  |    4 
 sw/source/uibase/misc/glosdoc.cxx                  |  107 ++++++++-------------
 sw/source/uibase/misc/redlndlg.cxx                 |   44 +++-----
 sw/source/uibase/shells/basesh.cxx                 |    6 -
 sw/source/uibase/uiview/formatclipboard.cxx        |   11 --
 sw/source/uibase/uiview/uivwimp.cxx                |   13 --
 sw/source/uibase/uno/unotxdoc.cxx                  |    8 -
 sw/source/uibase/utlui/content.cxx                 |    4 
 sw/source/uibase/utlui/gloslst.cxx                 |    9 -
 sw/source/uibase/wrtsh/navmgr.cxx                  |   12 --
 32 files changed, 329 insertions(+), 483 deletions(-)

New commits:
commit 16b2b4f27acb83fc651b8484dead53ebd0e269e1
Author:     Arkadiy Illarionov <qarkai at gmail.com>
AuthorDate: Sat Oct 27 19:50:00 2018 +0300
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Oct 30 07:52:11 2018 +0100

    Simplify containers iterations in sw/source/ui*
    
    Use range-based loop or replace with STL functions.
    
    Change-Id: I0d690e873f720a68f04991674ce84ec590231fd0
    Reviewed-on: https://gerrit.libreoffice.org/62432
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sw/source/ui/chrdlg/pardlg.cxx b/sw/source/ui/chrdlg/pardlg.cxx
index f3df6a32e9f2..7d74c451942e 100644
--- a/sw/source/ui/chrdlg/pardlg.cxx
+++ b/sw/source/ui/chrdlg/pardlg.cxx
@@ -222,8 +222,8 @@ void SwParaDlg::PageCreated(const OString& rId, SfxTabPage& rPage)
             aNames.insert(pBase->GetName());
             pBase = pPool->Next();
         }
-        for(std::set<OUString>::const_iterator it = aNames.begin(); it != aNames.end(); ++it)
-            rBox.append_text(*it);
+        for(const auto& rName : aNames)
+            rBox.append_text(rName);
     }
     // inits for Area and Transparency TabPages
     // The selection attribute lists (XPropertyList derivates, e.g. XColorList for
diff --git a/sw/source/ui/config/optcomp.cxx b/sw/source/ui/config/optcomp.cxx
index 5ea1304c1d66..8752338a7ede 100644
--- a/sw/source/ui/config/optcomp.cxx
+++ b/sw/source/ui/config/optcomp.cxx
@@ -269,20 +269,17 @@ IMPL_LINK_NOARG(SwCompatibilityOptPage, UseAsDefaultHdl, Button*, void)
     std::unique_ptr<weld::MessageDialog> xQueryBox(xBuilder->weld_message_dialog("QueryDefaultCompatDialog"));
     if (xQueryBox->run() == RET_YES)
     {
-        for ( vector< SvtCompatibilityEntry >::iterator pItem = m_pImpl->m_aList.begin();
-              pItem != m_pImpl->m_aList.end(); ++pItem )
+        auto pItem = std::find_if(m_pImpl->m_aList.begin(), m_pImpl->m_aList.end(),
+            [](const SvtCompatibilityEntry& rItem) { return rItem.isDefaultEntry(); });
+        if (pItem != m_pImpl->m_aList.end())
         {
-            if ( pItem->isDefaultEntry() )
+            const sal_Int32 nCount = m_pOptionsLB->GetEntryCount();
+            for ( sal_Int32 i = 0; i < nCount; ++i )
             {
-                const sal_Int32 nCount = m_pOptionsLB->GetEntryCount();
-                for ( sal_Int32 i = 0; i < nCount; ++i )
-                {
-                    bool bChecked = m_pOptionsLB->IsChecked(static_cast< sal_uLong >( i ));
+                bool bChecked = m_pOptionsLB->IsChecked(static_cast< sal_uLong >( i ));
 
-                    int nCoptIdx = i + 2; /* Consider "Name" & "Module" indexes */
-                    pItem->setValue<bool>( SvtCompatibilityEntry::Index(nCoptIdx), bChecked );
-                }
-                break;
+                int nCoptIdx = i + 2; /* Consider "Name" & "Module" indexes */
+                pItem->setValue<bool>( SvtCompatibilityEntry::Index(nCoptIdx), bChecked );
             }
         }
 
@@ -331,9 +328,8 @@ sal_uLong SwCompatibilityOptPage::GetDocumentOptions() const
 void SwCompatibilityOptPage::WriteOptions()
 {
     m_aConfigItem.Clear();
-    for ( vector< SvtCompatibilityEntry >::const_iterator pItem = m_pImpl->m_aList.begin();
-          pItem != m_pImpl->m_aList.end(); ++pItem )
-        m_aConfigItem.AppendItem(*pItem);
+    for ( const auto& rItem : m_pImpl->m_aList )
+        m_aConfigItem.AppendItem(rItem);
 }
 
 VclPtr<SfxTabPage> SwCompatibilityOptPage::Create( TabPageParent pParent, const SfxItemSet* rAttrSet )
diff --git a/sw/source/ui/config/optpage.cxx b/sw/source/ui/config/optpage.cxx
index 71d7f831aeb2..526bc089aad2 100644
--- a/sw/source/ui/config/optpage.cxx
+++ b/sw/source/ui/config/optpage.cxx
@@ -808,14 +808,13 @@ void SwStdFontTabPage::Reset( const SfxItemSet* rSet)
         }
 
         // insert to listboxes
-        for( std::set< OUString >::const_iterator it = aFontNames.begin();
-             it != aFontNames.end(); ++it )
+        for( const auto& rFontName : aFontNames )
         {
-            m_pStandardBox->InsertEntry( *it );
-            m_pTitleBox->InsertEntry( *it );
-            m_pListBox->InsertEntry( *it );
-            m_pLabelBox->InsertEntry( *it );
-            m_pIdxBox->InsertEntry( *it );
+            m_pStandardBox->InsertEntry( rFontName );
+            m_pTitleBox->InsertEntry( rFontName );
+            m_pListBox->InsertEntry( rFontName );
+            m_pLabelBox->InsertEntry( rFontName );
+            m_pIdxBox->InsertEntry( rFontName );
         }
     }
     if(SfxItemState::SET == rSet->GetItemState(FN_PARAM_STDFONTS, false, &pItem))
diff --git a/sw/source/ui/dbui/createaddresslistdialog.cxx b/sw/source/ui/dbui/createaddresslistdialog.cxx
index ad8452df3e5d..0e7961c42fb8 100644
--- a/sw/source/ui/dbui/createaddresslistdialog.cxx
+++ b/sw/source/ui/dbui/createaddresslistdialog.cxx
@@ -120,11 +120,11 @@ SwAddressControl_Impl::~SwAddressControl_Impl()
 
 void SwAddressControl_Impl::dispose()
 {
-    for(auto aTextIter = m_aFixedTexts.begin(); aTextIter != m_aFixedTexts.end(); ++aTextIter)
-        aTextIter->disposeAndClear();
+    for(auto& rText : m_aFixedTexts)
+        rText.disposeAndClear();
     m_aFixedTexts.clear();
-    for(auto aEditIter = m_aEdits.begin(); aEditIter != m_aEdits.end(); ++aEditIter)
-        aEditIter->disposeAndClear();
+    for(auto& rEdit : m_aEdits)
+        rEdit.disposeAndClear();
     m_aEdits.clear();
     m_pScrollBar.disposeAndClear();
     m_pWindow.disposeAndClear();
@@ -137,28 +137,24 @@ void SwAddressControl_Impl::SetData(SwCSVData& rDBData)
     //when the address data is updated then remove the controls an build again
     if(!m_aFixedTexts.empty())
     {
-        for(auto aTextIter = m_aFixedTexts.begin(); aTextIter != m_aFixedTexts.end(); ++aTextIter)
-            aTextIter->disposeAndClear();
+        for(auto& rText : m_aFixedTexts)
+            rText.disposeAndClear();
         m_aFixedTexts.clear();
-        for(auto aEditIter = m_aEdits.begin(); aEditIter != m_aEdits.end(); ++aEditIter)
-            aEditIter->disposeAndClear();
+        for(auto& rEdit : m_aEdits)
+            rEdit.disposeAndClear();
         m_aEdits.clear();
         m_bNoDataSet = true;
     }
     //now create appropriate controls
 
-    std::vector< OUString >::iterator    aHeaderIter;
-
     long nFTXPos = m_pWindow->LogicToPixel(Point(RSC_SP_CTRL_X, RSC_SP_CTRL_X), MapMode(MapUnit::MapAppFont)).X();
     long nFTHeight = m_pWindow->LogicToPixel(Size(RSC_BS_CHARHEIGHT, RSC_BS_CHARHEIGHT), MapMode(MapUnit::MapAppFont)).Height();
     long nFTWidth = 0;
 
     //determine the width of the FixedTexts
-    for(aHeaderIter = m_pData->aDBColumnHeaders.begin();
-                aHeaderIter != m_pData->aDBColumnHeaders.end();
-                ++aHeaderIter)
+    for(const auto& rHeader : m_pData->aDBColumnHeaders)
     {
-        sal_Int32 nTemp = m_pWindow->GetTextWidth(*aHeaderIter);
+        sal_Int32 nTemp = m_pWindow->GetTextWidth(rHeader);
         if(nTemp > nFTWidth)
           nFTWidth = nTemp;
     }
@@ -178,9 +174,7 @@ void SwAddressControl_Impl::SetData(SwCSVData& rDBData)
     Edit* pLastEdit = nullptr;
     sal_Int32 nVisibleLines = 0;
     sal_Int32 nLines = 0;
-    for(aHeaderIter = m_pData->aDBColumnHeaders.begin();
-                aHeaderIter != m_pData->aDBColumnHeaders.end();
-                ++aHeaderIter, nEDYPos += m_nLineHeight, nFTYPos += m_nLineHeight, nLines++)
+    for(const auto& rHeader : m_pData->aDBColumnHeaders)
     {
         VclPtr<FixedText> pNewFT = VclPtr<FixedText>::Create(m_pWindow, WB_RIGHT);
         VclPtr<Edit> pNewED = VclPtr<Edit>::Create(m_pWindow, WB_BORDER);
@@ -194,13 +188,16 @@ void SwAddressControl_Impl::SetData(SwCSVData& rDBData)
         if(nEDYPos + nEDHeight < m_aWinOutputSize.Height())
             ++nVisibleLines;
 
-        pNewFT->SetText(*aHeaderIter);
+        pNewFT->SetText(rHeader);
 
         pNewFT->Show();
         pNewED->Show();
         m_aFixedTexts.push_back(pNewFT);
         m_aEdits.push_back(pNewED);
         pLastEdit = pNewED;
+        nEDYPos += m_nLineHeight;
+        nFTYPos += m_nLineHeight;
+        nLines++;
     }
     //scrollbar adjustment
     if(pLastEdit)
@@ -251,11 +248,12 @@ void SwAddressControl_Impl::SetCurrentDataSet(sal_uInt32 nSet)
         if(m_pData->aDBData.size() > m_nCurrentDataSet)
         {
             sal_uInt32 nIndex = 0;
-            for(auto aEditIter = m_aEdits.begin(); aEditIter != m_aEdits.end(); ++aEditIter, ++nIndex)
+            for(auto& rEdit : m_aEdits)
             {
                 OSL_ENSURE(nIndex < m_pData->aDBData[m_nCurrentDataSet].size(),
                             "number of columns doesn't match number of Edits");
-                (*aEditIter)->SetText(m_pData->aDBData[m_nCurrentDataSet][nIndex]);
+                rEdit->SetText(m_pData->aDBData[m_nCurrentDataSet][nIndex]);
+                ++nIndex;
             }
         }
     }
@@ -381,9 +379,9 @@ void SwAddressControl_Impl::Resize()
     {
         long nNewEditSize = aSize.Width() - (*m_aEdits.begin())->GetPosPixel().X() - nScrollBarWidth - 6;
 
-        for(auto aEditIter = m_aEdits.begin(); aEditIter != m_aEdits.end(); ++aEditIter)
+        for(auto& rEdit : m_aEdits)
         {
-            (*aEditIter)->SetSizePixel(Size(nNewEditSize, (*aEditIter)->GetSizePixel().Height()));
+            rEdit->SetSizePixel(Size(nNewEditSize, rEdit->GetSizePixel().Height()));
         }
     }
 
@@ -552,11 +550,8 @@ IMPL_LINK_NOARG(SwCreateAddressListDialog, FindHdl_Impl, Button*, void)
     {
         m_xFindDlg.reset(new SwFindEntryDialog(this));
         weld::ComboBox& rColumnBox = m_xFindDlg->GetFieldsListBox();
-        std::vector< OUString >::iterator    aHeaderIter;
-        for(aHeaderIter = m_pCSVData->aDBColumnHeaders.begin();
-                    aHeaderIter != m_pCSVData->aDBColumnHeaders.end();
-                    ++aHeaderIter)
-            rColumnBox.append_text(*aHeaderIter);
+        for(const auto& rHeader : m_pCSVData->aDBColumnHeaders)
+            rColumnBox.append_text(rHeader);
         rColumnBox.set_active(0);
         m_xFindDlg->show();
     }
@@ -579,11 +574,8 @@ IMPL_LINK_NOARG(SwCreateAddressListDialog, CustomizeHdl_Impl, Button*, void)
     {
         weld::ComboBox& rColumnBox = m_xFindDlg->GetFieldsListBox();
         rColumnBox.clear();
-        std::vector< OUString >::iterator    aHeaderIter;
-        for(aHeaderIter = m_pCSVData->aDBColumnHeaders.begin();
-                    aHeaderIter != m_pCSVData->aDBColumnHeaders.end();
-                    ++aHeaderIter)
-            rColumnBox.append_text(*aHeaderIter);
+        for(const auto& rHeader : m_pCSVData->aDBColumnHeaders)
+            rColumnBox.append_text(rHeader);
     }
 }
 
@@ -643,9 +635,9 @@ IMPL_LINK_NOARG(SwCreateAddressListDialog, OkHdl_Impl, Button*, void)
         lcl_WriteValues(&(m_pCSVData->aDBColumnHeaders), pStream);
 
         std::vector< std::vector< OUString > >::iterator aDataIter;
-        for( aDataIter = m_pCSVData->aDBData.begin(); aDataIter != m_pCSVData->aDBData.end(); ++aDataIter)
+        for(const auto& rData : m_pCSVData->aDBData)
         {
-            lcl_WriteValues(&(*aDataIter), pStream);
+            lcl_WriteValues(&rData, pStream);
         }
         aMedium.Commit();
         EndDialog(RET_OK);
diff --git a/sw/source/ui/dbui/customizeaddresslistdialog.cxx b/sw/source/ui/dbui/customizeaddresslistdialog.cxx
index af6162bfd0f5..49c1df3fdaa3 100644
--- a/sw/source/ui/dbui/customizeaddresslistdialog.cxx
+++ b/sw/source/ui/dbui/customizeaddresslistdialog.cxx
@@ -46,11 +46,8 @@ SwCustomizeAddressListDialog::SwCustomizeAddressListDialog(
     m_xUpPB->connect_clicked(aUpDownLk);
     m_xDownPB->connect_clicked(aUpDownLk);
 
-    std::vector< OUString >::iterator aHeaderIter;
-
-    for(aHeaderIter = m_xNewData->aDBColumnHeaders.begin();
-                aHeaderIter != m_xNewData->aDBColumnHeaders.end(); ++aHeaderIter)
-        m_xFieldsLB->append_text(*aHeaderIter);
+    for (const auto& rHeader : m_xNewData->aDBColumnHeaders)
+        m_xFieldsLB->append_text(rHeader);
 
     m_xFieldsLB->select(0);
     UpdateButtons();
@@ -97,9 +94,8 @@ IMPL_LINK(SwCustomizeAddressListDialog, AddRenameHdl_Impl, weld::Button&, rButto
             //add the new column
             m_xNewData->aDBColumnHeaders.insert(m_xNewData->aDBColumnHeaders.begin() + nPos, sNew);
             //add a new entry into all data arrays
-            std::vector< std::vector< OUString > >::iterator aDataIter;
-            for( aDataIter = m_xNewData->aDBData.begin(); aDataIter != m_xNewData->aDBData.end(); ++aDataIter)
-                aDataIter->insert(aDataIter->begin() + nPos, OUString());
+            for (auto& rData : m_xNewData->aDBData)
+                rData.insert(rData.begin() + nPos, OUString());
 
         }
 
@@ -118,9 +114,8 @@ IMPL_LINK_NOARG(SwCustomizeAddressListDialog, DeleteHdl_Impl, weld::Button&, voi
     //remove the column
     m_xNewData->aDBColumnHeaders.erase(m_xNewData->aDBColumnHeaders.begin() + nPos);
     //remove the data
-    std::vector< std::vector< OUString > >::iterator aDataIter;
-    for( aDataIter = m_xNewData->aDBData.begin(); aDataIter != m_xNewData->aDBData.end(); ++aDataIter)
-        aDataIter->erase(aDataIter->begin() + nPos);
+    for (auto& rData : m_xNewData->aDBData)
+        rData.erase(rData.begin() + nPos);
 
     UpdateButtons();
 }
@@ -141,12 +136,11 @@ IMPL_LINK(SwCustomizeAddressListDialog, UpDownHdl_Impl, weld::Button&, rButton,
     OUString sHeader = m_xNewData->aDBColumnHeaders[nOldPos];
     m_xNewData->aDBColumnHeaders.erase(m_xNewData->aDBColumnHeaders.begin() + nOldPos);
     m_xNewData->aDBColumnHeaders.insert(m_xNewData->aDBColumnHeaders.begin() + nPos, sHeader);
-    std::vector< std::vector< OUString > >::iterator aDataIter;
-    for( aDataIter = m_xNewData->aDBData.begin(); aDataIter != m_xNewData->aDBData.end(); ++aDataIter)
+    for (auto& rData : m_xNewData->aDBData)
     {
-        OUString sData = (*aDataIter)[nOldPos];
-        aDataIter->erase(aDataIter->begin() + nOldPos);
-        aDataIter->insert(aDataIter->begin() + nPos, sData);
+        OUString sData = rData[nOldPos];
+        rData.erase(rData.begin() + nOldPos);
+        rData.insert(rData.begin() + nPos, sData);
     }
 
     UpdateButtons();
@@ -181,15 +175,8 @@ IMPL_LINK(SwAddRenameEntryDialog, ModifyHdl_Impl, weld::Entry&, rEdit, void)
 
     if(!bFound)
     {
-        std::vector< OUString >::const_iterator aHeaderIter;
-        for(aHeaderIter = m_rCSVHeader.begin();
-                    aHeaderIter != m_rCSVHeader.end();
-                    ++aHeaderIter)
-            if(*aHeaderIter == sEntry)
-            {
-                bFound = true;
-                break;
-            }
+        bFound = std::any_of(m_rCSVHeader.begin(), m_rCSVHeader.end(),
+            [&sEntry](const OUString& rHeader) { return rHeader == sEntry; });
     }
     m_xOK->set_sensitive(!bFound);
 }
diff --git a/sw/source/ui/dbui/mmaddressblockpage.cxx b/sw/source/ui/dbui/mmaddressblockpage.cxx
index 57b30c60c56b..29b99cf6a8c1 100644
--- a/sw/source/ui/dbui/mmaddressblockpage.cxx
+++ b/sw/source/ui/dbui/mmaddressblockpage.cxx
@@ -696,9 +696,8 @@ IMPL_LINK(SwCustomizeAddressBlockDialog, SelectionChangedHdl_Impl, AddressMultiL
         }
         m_pFieldCB->Clear();
         if(pVector) {
-            std::vector<OUString>::iterator    aIterator;
-            for( aIterator = pVector->begin(); aIterator != pVector->end(); ++aIterator)
-                m_pFieldCB->InsertEntry(*aIterator);
+            for (const auto& rItem : *pVector)
+                m_pFieldCB->InsertEntry(rItem);
         }
         m_pFieldCB->SetText(sSelect);
         m_pFieldCB->Enable();
@@ -970,12 +969,12 @@ SwAssignFieldsControl::~SwAssignFieldsControl()
 
 void SwAssignFieldsControl::dispose()
 {
-    for(auto aFIIter = m_aFieldNames.begin(); aFIIter != m_aFieldNames.end(); ++aFIIter)
-        aFIIter->disposeAndClear();
-    for(auto aLBIter = m_aMatches.begin(); aLBIter != m_aMatches.end(); ++aLBIter)
-        aLBIter->disposeAndClear();
-    for(auto aFIIter = m_aPreviews.begin(); aFIIter != m_aPreviews.end(); ++aFIIter)
-        aFIIter->disposeAndClear();
+    for(auto& rFIItem : m_aFieldNames)
+        rFIItem.disposeAndClear();
+    for(auto& rLBItem : m_aMatches)
+        rLBItem.disposeAndClear();
+    for(auto& rFIItem : m_aPreviews)
+        rFIItem.disposeAndClear();
 
     m_aFieldNames.clear();
     m_aMatches.clear();
@@ -1015,17 +1014,17 @@ void SwAssignFieldsControl::Resize()
     long nControlHeight = std::max(m_aFieldNames[0]->get_preferred_size().Height(),
                                    m_aMatches[0]->get_preferred_size().Height());
 
-    for(auto aFIIter = m_aFieldNames.begin(); aFIIter != m_aFieldNames.end(); ++aFIIter)
-        (*aFIIter)->SetSizePixel(Size(nColWidth - 6, nControlHeight));
-    for(auto aLBIter = m_aMatches.begin(); aLBIter != m_aMatches.end(); ++aLBIter)
+    for(auto& rFIItem : m_aFieldNames)
+        rFIItem->SetSizePixel(Size(nColWidth - 6, nControlHeight));
+    for(auto& rLBItem : m_aMatches)
     {
-        long nPosY = (*aLBIter)->GetPosPixel().Y();
-        (*aLBIter)->SetPosSizePixel(Point(nColWidth, nPosY), Size(nColWidth - 6, nControlHeight));
+        long nPosY = rLBItem->GetPosPixel().Y();
+        rLBItem->SetPosSizePixel(Point(nColWidth, nPosY), Size(nColWidth - 6, nControlHeight));
     }
-    for(auto aFIIter = m_aPreviews.begin(); aFIIter != m_aPreviews.end(); ++aFIIter)
+    for(auto& rFIItem : m_aPreviews)
     {
-        long nPosY = (*aFIIter)->GetPosPixel().Y();
-        (*aFIIter)->SetPosSizePixel(Point(2 * nColWidth + 6, nPosY), Size(nColWidth, nControlHeight));
+        long nPosY = rFIItem->GetPosPixel().Y();
+        rFIItem->SetPosSizePixel(Point(2 * nColWidth + 6, nPosY), Size(nColWidth, nControlHeight));
     }
 }
 
@@ -1086,12 +1085,12 @@ IMPL_LINK(SwAssignFieldsControl, ScrollHdl_Impl, ScrollBar*, pScroll, void)
     long nMove = m_nFirstYPos - (*m_aMatches.begin())->GetPosPixel().Y() - (nThumb * m_nYOffset);
 
     SetUpdateMode(false);
-    for(auto aFIIter = m_aFieldNames.begin(); aFIIter != m_aFieldNames.end(); ++aFIIter)
-        lcl_Move(*aFIIter, nMove);
-    for(auto aLBIter = m_aMatches.begin(); aLBIter != m_aMatches.end(); ++aLBIter)
-        lcl_Move(*aLBIter, nMove);
-    for(auto aFIIter = m_aPreviews.begin(); aFIIter != m_aPreviews.end(); ++aFIIter)
-        lcl_Move(*aFIIter, nMove);
+    for(auto& rFIItem : m_aFieldNames)
+        lcl_Move(rFIItem, nMove);
+    for(auto& rLBItem : m_aMatches)
+        lcl_Move(rLBItem, nMove);
+    for(auto& rFIItem : m_aPreviews)
+        lcl_Move(rFIItem, nMove);
     SetUpdateMode(true);
 }
 
@@ -1117,14 +1116,11 @@ IMPL_LINK(SwAssignFieldsControl, MatchHdl_Impl, ListBox&, rBox, void)
             }
         }
     }
-    sal_Int32 nIndex = 0;
-    for(auto aLBIter = m_aMatches.begin(); aLBIter != m_aMatches.end(); ++aLBIter, ++nIndex)
+    auto aLBIter = std::find(m_aMatches.begin(), m_aMatches.end(), &rBox);
+    if(aLBIter != m_aMatches.end())
     {
-        if(*aLBIter == &rBox)
-        {
-            m_aPreviews[nIndex]->SetText(sPreview);
-            break;
-        }
+        auto nIndex = static_cast<sal_Int32>(std::distance(m_aMatches.begin(), aLBIter));
+        m_aPreviews[nIndex]->SetText(sPreview);
     }
     m_aModifyHdl.Call(nullptr);
 }
@@ -1134,14 +1130,11 @@ IMPL_LINK(SwAssignFieldsControl, GotFocusHdl_Impl, Control&, rControl, void)
     ListBox* pBox = static_cast<ListBox*>(&rControl);
     if(GetFocusFlags::Tab & pBox->GetGetFocusFlags())
     {
-        sal_Int32 nIndex = 0;
-        for(auto aLBIter = m_aMatches.begin(); aLBIter != m_aMatches.end(); ++aLBIter, ++nIndex)
+        auto aLBIter = std::find(m_aMatches.begin(), m_aMatches.end(), pBox);
+        if(aLBIter != m_aMatches.end())
         {
-            if(*aLBIter == pBox)
-            {
-                MakeVisible(nIndex);
-                break;
-            }
+            auto nIndex = static_cast<sal_Int32>(std::distance(m_aMatches.begin(), aLBIter));
+            MakeVisible(nIndex);
         }
     }
 }
@@ -1212,12 +1205,11 @@ uno::Sequence< OUString > SwAssignFieldsDialog::CreateAssignments()
             m_rConfigItem.GetDefaultAddressHeaders().size());
     OUString* pAssignments = aAssignments.getArray();
     sal_Int32 nIndex = 0;
-    for(auto aLBIter = m_pFieldsControl->m_aMatches.begin();
-                aLBIter != m_pFieldsControl->m_aMatches.end();
-                    ++aLBIter, ++nIndex)
+    for(const auto& rLBItem : m_pFieldsControl->m_aMatches)
     {
-        const OUString sSelect = (*aLBIter)->GetSelectedEntry();
+        const OUString sSelect = rLBItem->GetSelectedEntry();
         pAssignments[nIndex] = (m_sNone != sSelect) ? sSelect : OUString();
+        ++nIndex;
     }
     return aAssignments;
 }
diff --git a/sw/source/ui/dialog/ascfldlg.cxx b/sw/source/ui/dialog/ascfldlg.cxx
index 2be497a2701b..3b36d6f858d2 100644
--- a/sw/source/ui/dialog/ascfldlg.cxx
+++ b/sw/source/ui/dialog/ascfldlg.cxx
@@ -204,10 +204,9 @@ SwAsciiFilterDlg::SwAsciiFilterDlg( weld::Window* pParent, SwDocShell& rDocSh,
             }
 
             // insert into listbox
-            for( std::set< OUString >::const_iterator it = aFontNames.begin();
-                 it != aFontNames.end(); ++it )
+            for( const auto& rFontName : aFontNames )
             {
-                m_xFontLB->append_text(*it);
+                m_xFontLB->append_text(rFontName);
             }
 
             if( aOpt.GetFontName().isEmpty() )
diff --git a/sw/source/ui/envelp/label1.cxx b/sw/source/ui/envelp/label1.cxx
index 733d55c6e025..a6f7e0afe580 100644
--- a/sw/source/ui/envelp/label1.cxx
+++ b/sw/source/ui/envelp/label1.cxx
@@ -513,10 +513,10 @@ void SwLabPage::Reset(const SfxItemSet* rSet)
     m_xAddrBox->set_active( aItem.m_bAddr );
     m_xWritingEdit->set_text( aWriting );
 
-    for(std::vector<OUString>::const_iterator i = GetParentSwLabDlg()->Makes().begin(); i != GetParentSwLabDlg()->Makes().end(); ++i)
+    for(const auto& rMake : GetParentSwLabDlg()->Makes())
     {
-        if (m_xMakeBox->find_text(*i) == -1)
-            m_xMakeBox->append_text(*i);
+        if (m_xMakeBox->find_text(rMake) == -1)
+            m_xMakeBox->append_text(rMake);
     }
 
     m_xMakeBox->set_active_text(aItem.m_aMake);
diff --git a/sw/source/ui/fmtui/tmpdlg.cxx b/sw/source/ui/fmtui/tmpdlg.cxx
index 77aa92b22293..c9370c1e5e9e 100644
--- a/sw/source/ui/fmtui/tmpdlg.cxx
+++ b/sw/source/ui/fmtui/tmpdlg.cxx
@@ -417,8 +417,8 @@ void SwTemplateDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
             aNames.insert(pBase->GetName());
             pBase = pPool->Next();
         }
-        for(std::set<OUString>::const_iterator it = aNames.begin(); it != aNames.end(); ++it)
-            rBox.append_text(*it);
+        for(const auto& rName : aNames)
+            rBox.append_text(rName);
     }
     else if (nId == m_nAlignId)
     {
diff --git a/sw/source/ui/frmdlg/frmpage.cxx b/sw/source/ui/frmdlg/frmpage.cxx
index b7d41aca0474..76c5ce2be016 100644
--- a/sw/source/ui/frmdlg/frmpage.cxx
+++ b/sw/source/ui/frmdlg/frmpage.cxx
@@ -441,25 +441,24 @@ static void lcl_InsertVectors(weld::ComboBox& rBox,
     const std::vector< OUString >& rPrev, const std::vector< OUString >& rThis,
     const std::vector< OUString >& rNext, const std::vector< OUString >& rRemain)
 {
-    std::vector< OUString >::const_iterator aIt;
-    for(aIt = rPrev.begin(); aIt != rPrev.end(); ++aIt)
-        rBox.append_text(*aIt);
-    for(aIt = rThis.begin(); aIt != rThis.end(); ++aIt)
-        rBox.append_text(*aIt);
-    for(aIt = rNext.begin(); aIt != rNext.end(); ++aIt)
-        rBox.append_text(*aIt);
+    for(const auto& rItem : rPrev)
+        rBox.append_text(rItem);
+    for(const auto& rItem : rThis)
+        rBox.append_text(rItem);
+    for(const auto& rItem : rNext)
+        rBox.append_text(rItem);
     rBox.append_separator();
     //now insert all strings sorted
     const auto nStartPos = rBox.get_count();
 
-    for(aIt = rPrev.begin(); aIt != rPrev.end(); ++aIt)
-        ::InsertStringSorted("", *aIt, rBox, nStartPos );
-    for(aIt = rThis.begin(); aIt != rThis.end(); ++aIt)
-        ::InsertStringSorted("", *aIt, rBox, nStartPos );
-    for(aIt = rNext.begin(); aIt != rNext.end(); ++aIt)
-        ::InsertStringSorted("", *aIt, rBox, nStartPos );
-    for(aIt = rRemain.begin(); aIt != rRemain.end(); ++aIt)
-        ::InsertStringSorted("", *aIt, rBox, nStartPos );
+    for(const auto& rItem : rPrev)
+        ::InsertStringSorted("", rItem, rBox, nStartPos );
+    for(const auto& rItem : rThis)
+        ::InsertStringSorted("", rItem, rBox, nStartPos );
+    for(const auto& rItem : rNext)
+        ::InsertStringSorted("", rItem, rBox, nStartPos );
+    for(const auto& rItem : rRemain)
+        ::InsertStringSorted("", rItem, rBox, nStartPos );
 }
 
 // --> OD 2009-08-31 #mongolianlayout#
@@ -812,10 +811,9 @@ void SwFramePage::setOptimalFrameWidth()
     std::sort(aFrames.begin(), aFrames.end());
     aFrames.erase(std::unique(aFrames.begin(), aFrames.end()), aFrames.end());
 
-    for (std::vector<SvxSwFramePosString::StringId>::const_iterator aI = aFrames.begin(), aEnd = aFrames.end();
-        aI != aEnd; ++aI)
+    for (const auto& rFrame : aFrames)
     {
-        m_pHorizontalDLB->InsertEntry(SvxSwFramePosString::GetString(*aI));
+        m_pHorizontalDLB->InsertEntry(SvxSwFramePosString::GetString(rFrame));
     }
 
     Size aBiggest(m_pHorizontalDLB->GetOptimalSize());
@@ -853,10 +851,9 @@ void SwFramePage::setOptimalRelWidth()
     std::sort(aRels.begin(), aRels.end());
     aRels.erase(std::unique(aRels.begin(), aRels.end()), aRels.end());
 
-    for (std::vector<SvxSwFramePosString::StringId>::const_iterator aI = aRels.begin(), aEnd = aRels.end();
-        aI != aEnd; ++aI)
+    for (const auto& rRel : aRels)
     {
-        m_pHoriRelationLB->InsertEntry(SvxSwFramePosString::GetString(*aI));
+        m_pHoriRelationLB->InsertEntry(SvxSwFramePosString::GetString(rRel));
     }
 
     Size aBiggest(m_pHoriRelationLB->GetOptimalSize());
diff --git a/sw/source/ui/index/cntex.cxx b/sw/source/ui/index/cntex.cxx
index 5d796bcbda59..17a5d1a9cb1f 100644
--- a/sw/source/ui/index/cntex.cxx
+++ b/sw/source/ui/index/cntex.cxx
@@ -284,14 +284,12 @@ void SwMultiTOXTabDialog::CreateOrUpdateExample(
 
                     // #i24377#
                     SwFormTokens aPattern = pForm->GetPattern(nCurrLevel);
-                    SwFormTokens::iterator aIt = aPattern.begin();
 
-                    while(aIt != aPattern.end())
+                    for(const auto& aToken : aPattern)
                     {
                         if( aSequPropVals.getLength() <= nTokenIndex)
                             aSequPropVals.realloc(nTokenIndex + 10);
 
-                        SwFormToken aToken = *aIt; // #i24377#
                         switch(aToken.eTokenType)
                         {
                             case TOKEN_ENTRY_NO     :
@@ -355,8 +353,6 @@ void SwMultiTOXTabDialog::CreateOrUpdateExample(
                         beans::PropertyValues* pValues = aSequPropVals.getArray();
                         pValues[nTokenIndex] = aPropVals;
                         nTokenIndex++;
-
-                        ++aIt; // #i24377#
                     }
                     aSequPropVals.realloc(nTokenIndex);
 
diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx
index 6764592ad64b..b234569aa86b 100644
--- a/sw/source/ui/index/cnttab.cxx
+++ b/sw/source/ui/index/cnttab.cxx
@@ -2407,11 +2407,9 @@ IMPL_LINK(SwTOXEntryTabPage, LevelHdl, SvTreeListBox*, pBox, void)
 
         // #i21237#
         SwFormTokens aPattern = m_pCurrentForm->GetPattern(nLevel + 1);
-        SwFormTokens::iterator aIt = aPattern.begin();
 
-        while(aIt != aPattern.end())
+        for(const auto& aToken : aPattern)
         {
-            SwFormToken aToken = *aIt; // #i21237#
             if(TOKEN_AUTHORITY == aToken.eTokenType)
             {
                 sal_uInt32 nSearch = aToken.nAuthorityField;
@@ -2419,8 +2417,6 @@ IMPL_LINK(SwTOXEntryTabPage, LevelHdl, SvTreeListBox*, pBox, void)
                 OSL_ENSURE(LISTBOX_ENTRY_NOTFOUND != nLstBoxPos, "Entry not found?");
                 m_pAuthFieldsLB->RemoveEntry(nLstBoxPos);
             }
-
-            ++aIt; // #i21237#
         }
         m_pAuthFieldsLB->SelectEntryPos(0);
     }
@@ -2822,14 +2818,11 @@ void SwTokenWindow::SetForm(SwForm& rForm, sal_uInt16 nL)
     {
         // #i21237#
         SwFormTokens aPattern = m_pForm->GetPattern(m_nLevel + 1);
-        SwFormTokens::iterator aIt = aPattern.begin();
         bool bLastWasText = false; //assure alternating text - code - text
 
         Control* pSetActiveControl = nullptr;
-        while(aIt != aPattern.end()) // #i21237#
+        for (const auto& aToken : aPattern) // #i21237#
         {
-            SwFormToken aToken(*aIt); // #i21237#
-
             if(TOKEN_TEXT == aToken.eTokenType)
             {
                 SAL_WARN_IF(bLastWasText, "sw", "text following text is invalid");
@@ -2866,8 +2859,6 @@ void SwTokenWindow::SetForm(SwForm& rForm, sal_uInt16 nL)
                 InsertItem( sForm, aToken );
                 bLastWasText = false;
             }
-
-            ++aIt; // #i21237#
         }
         if(!bLastWasText)
         {
@@ -3317,56 +3308,48 @@ IMPL_LINK(SwTokenWindow, ScrollHdl, Button*, pBtn, void )
     if(pBtn == m_pLeftScrollWin)
     {
         //find the first completely visible control (left edge visible)
-        for (auto it = m_aControlList.begin(); it != m_aControlList.end(); ++it)
+        auto it = std::find_if(m_aControlList.begin(), m_aControlList.end(),
+            [](const VclPtr<Control>& rControl) {
+                Control *pCtrl = rControl.get();
+                return pCtrl->GetPosPixel().X() >= 0;
+            });
+        if (it != m_aControlList.end())
         {
-            Control *pCtrl = it->get();
-
-            long nXPos = pCtrl->GetPosPixel().X();
-
-            if (nXPos >= 0)
+            if (it == m_aControlList.begin())
             {
-                if (it == m_aControlList.begin())
-                {
-                    //move the current control to the left edge
-                    nMove = -nXPos;
-                }
-                else
-                {
-                    //move the left neighbor to the start position
-                    auto itLeft = it;
-                    --itLeft;
-                    Control *pLeft = itLeft->get();
+                //move the current control to the left edge
+                Control *pCtrl = it->get();
 
-                    nMove = -pLeft->GetPosPixel().X();
-                }
+                nMove = -pCtrl->GetPosPixel().X();
+            }
+            else
+            {
+                //move the left neighbor to the start position
+                auto itLeft = it;
+                --itLeft;
+                Control *pLeft = itLeft->get();
 
-                break;
+                nMove = -pLeft->GetPosPixel().X();
             }
         }
     }
     else
     {
         //find the first completely visible control (right edge visible)
-        for (auto it = m_aControlList.rbegin(); it != m_aControlList.rend(); ++it)
+        auto it = std::find_if(m_aControlList.rbegin(), m_aControlList.rend(),
+            [&nSpace](const VclPtr<Control>& rControl) {
+                Control *pCtrl = rControl.get();
+                long nCtrlWidth = pCtrl->GetSizePixel().Width();
+                long nXPos = pCtrl->GetPosPixel().X() + nCtrlWidth;
+                return nXPos <= nSpace;
+            });
+        if (it != m_aControlList.rend() && it != m_aControlList.rbegin())
         {
-            Control *pCtrl = it->get();
-
-            long nCtrlWidth = pCtrl->GetSizePixel().Width();
-            long nXPos = pCtrl->GetPosPixel().X() + nCtrlWidth;
-
-            if (nXPos <= nSpace)
-            {
-                if (it != m_aControlList.rbegin())
-                {
-                    //move the right neighbor  to the right edge right aligned
-                    auto itRight = it;
-                    --itRight;
-                    Control *pRight = itRight->get();
-                    nMove = nSpace - pRight->GetPosPixel().X() - pRight->GetSizePixel().Width();
-                }
-
-                break;
-            }
+            //move the right neighbor  to the right edge right aligned
+            auto itRight = it;
+            --itRight;
+            Control *pRight = itRight->get();
+            nMove = nSpace - pRight->GetPosPixel().X() - pRight->GetSizePixel().Width();
         }
 
         //move it left until it's completely visible
diff --git a/sw/source/ui/vba/vbadocumentproperties.cxx b/sw/source/ui/vba/vbadocumentproperties.cxx
index 4a74d5abd25b..130471a35d12 100644
--- a/sw/source/ui/vba/vbadocumentproperties.cxx
+++ b/sw/source/ui/vba/vbadocumentproperties.cxx
@@ -705,9 +705,11 @@ protected:
     {
         uno::Sequence< OUString > aNames( getCount() );
         OUString* pName = aNames.getArray();
-        DocPropsByName::iterator it_end = mNamedDocProps.end();
-        for(  DocPropsByName::iterator it = mNamedDocProps.begin(); it != it_end; ++it, ++pName )
-           *pName = it->first;
+        for (const auto& rEntry : mNamedDocProps)
+        {
+           *pName = rEntry.first;
+           ++pName;
+        }
         return aNames;
     }
 
diff --git a/sw/source/ui/vba/vbarevisions.cxx b/sw/source/ui/vba/vbarevisions.cxx
index 661413f1ed20..223e523c1c56 100644
--- a/sw/source/ui/vba/vbarevisions.cxx
+++ b/sw/source/ui/vba/vbarevisions.cxx
@@ -146,12 +146,8 @@ void SAL_CALL SwVbaRevisions::AcceptAll(  )
         aRevisions.push_back( xRevision );
     }
 
-    std::vector< uno::Reference< word::XRevision > >::iterator it = aRevisions.begin();
-    for( ; it != aRevisions.end(); ++it )
-    {
-        uno::Reference< word::XRevision > xRevision( *it );
+    for( const auto& xRevision : aRevisions )
         xRevision->Accept();
-    }
 }
 
 void SAL_CALL SwVbaRevisions::RejectAll(  )
diff --git a/sw/source/ui/vba/vbatables.cxx b/sw/source/ui/vba/vbatables.cxx
index 932e416d460e..eb9b4441de89 100644
--- a/sw/source/ui/vba/vbatables.cxx
+++ b/sw/source/ui/vba/vbatables.cxx
@@ -107,12 +107,11 @@ public:
     {
         uno::Sequence< OUString > sNames( mxTables.size() );
         OUString* pString = sNames.getArray();
-        XTextTableVec::iterator it = mxTables.begin();
-        XTextTableVec::iterator it_end = mxTables.end();
-        for ( ; it != it_end; ++it, ++pString )
+        for ( const auto& rxTable : mxTables )
         {
-            uno::Reference< container::XNamed > xName( *it, uno::UNO_QUERY_THROW );
+            uno::Reference< container::XNamed > xName( rxTable, uno::UNO_QUERY_THROW );
             *pString = xName->getName();
+            ++pString;
         }
         return sNames;
     }
diff --git a/sw/source/uibase/config/StoredChapterNumbering.cxx b/sw/source/uibase/config/StoredChapterNumbering.cxx
index 80f27600d3a8..940ffb32d845 100644
--- a/sw/source/uibase/config/StoredChapterNumbering.cxx
+++ b/sw/source/uibase/config/StoredChapterNumbering.cxx
@@ -231,15 +231,15 @@ public:
                     XML_NAMESPACE_OFFICE, XML_STYLES, true, true);
 
             // horrible hack for char styles to get display-name mapping
-            for (auto it = rCharStyles.begin(); it != rCharStyles.end(); ++it)
+            for (const auto& rCharStyle : rCharStyles)
             {
                 AddAttribute( XML_NAMESPACE_STYLE, XML_FAMILY, XML_TEXT );
                 bool bEncoded(false);
                 AddAttribute( XML_NAMESPACE_STYLE, XML_NAME,
-                              EncodeStyleName(*it, &bEncoded) );
+                              EncodeStyleName(rCharStyle, &bEncoded) );
                 if (bEncoded)
                 {
-                    AddAttribute(XML_NAMESPACE_STYLE, XML_DISPLAY_NAME, *it);
+                    AddAttribute(XML_NAMESPACE_STYLE, XML_DISPLAY_NAME, rCharStyle);
                 }
 
                 SvXMLElementExport style(*this,
@@ -248,9 +248,9 @@ public:
 
             SvxXMLNumRuleExport numRuleExport(*this);
 
-            for (auto it = rRules.begin(); it != rRules.end(); ++it)
+            for (const auto& rRule : rRules)
             {
-                ExportRule(numRuleExport, *it);
+                ExportRule(numRuleExport, rRule);
             }
         }
 
diff --git a/sw/source/uibase/dbui/mmconfigitem.cxx b/sw/source/uibase/dbui/mmconfigitem.cxx
index 5cba59440bc5..154d6ec4d9a5 100644
--- a/sw/source/uibase/dbui/mmconfigitem.cxx
+++ b/sw/source/uibase/dbui/mmconfigitem.cxx
@@ -560,15 +560,13 @@ void  SwMailMergeConfigItem_Impl::ImplCommit()
     //load the existing node names to find new names
     Sequence<OUString> aAssignments = GetNodeNames(cAddressDataAssignments);
 
-    std::vector<DBAddressDataAssignment>::iterator aAssignIter;
-    for(aAssignIter = m_aAddressDataAssignments.begin();
-                aAssignIter != m_aAddressDataAssignments.end(); ++aAssignIter)
+    for(const auto& rAssignment : m_aAddressDataAssignments)
     {
-        if(aAssignIter->bColumnAssignmentsChanged)
+        if(rAssignment.bColumnAssignmentsChanged)
         {
             //create a new node name
-            OUString sNewNode = !aAssignIter->sConfigNodeName.isEmpty() ?
-                        aAssignIter->sConfigNodeName :
+            OUString sNewNode = !rAssignment.sConfigNodeName.isEmpty() ?
+                        rAssignment.sConfigNodeName :
                         lcl_CreateNodeName(aAssignments);
             OUString sSlash = "/";
             OUString sNodePath = cAddressDataAssignments;
@@ -580,16 +578,16 @@ void  SwMailMergeConfigItem_Impl::ImplCommit()
             PropertyValue* pNewValues = aNewValues.getArray();
             pNewValues[0].Name = sNodePath;
             pNewValues[0].Name += cDataSourceName;
-            pNewValues[0].Value <<= aAssignIter->aDBData.sDataSource;
+            pNewValues[0].Value <<= rAssignment.aDBData.sDataSource;
             pNewValues[1].Name = sNodePath;
             pNewValues[1].Name += cDataTableName;
-            pNewValues[1].Value <<= aAssignIter->aDBData.sCommand;
+            pNewValues[1].Value <<= rAssignment.aDBData.sCommand;
             pNewValues[2].Name = sNodePath;
             pNewValues[2].Name += cDataCommandType;
-            pNewValues[2].Value <<= aAssignIter->aDBData.nCommandType;
+            pNewValues[2].Value <<= rAssignment.aDBData.nCommandType;
             pNewValues[3].Name = sNodePath;
             pNewValues[3].Name += cDBColumnAssignments;
-            pNewValues[3].Value <<= aAssignIter->aDBColumnAssignments;
+            pNewValues[3].Value <<= rAssignment.aDBColumnAssignments;
 
             SetSetProperties(cAddressDataAssignments, aNewValues);
         }
@@ -1144,15 +1142,11 @@ Sequence< OUString> SwMailMergeConfigItem::GetColumnAssignment(
                 const SwDBData& rDBData ) const
 {
     Sequence< OUString> aRet;
-    std::vector<DBAddressDataAssignment>::iterator aAssignIter;
-    for(aAssignIter = m_pImpl->m_aAddressDataAssignments.begin();
-                aAssignIter != m_pImpl->m_aAddressDataAssignments.end(); ++aAssignIter)
+    auto aAssignIter = std::find_if(m_pImpl->m_aAddressDataAssignments.begin(), m_pImpl->m_aAddressDataAssignments.end(),
+        [&rDBData](const DBAddressDataAssignment& rAssignment) { return rAssignment.aDBData == rDBData; });
+    if (aAssignIter != m_pImpl->m_aAddressDataAssignments.end())
     {
-        if(aAssignIter->aDBData == rDBData)
-        {
-            aRet = aAssignIter->aDBColumnAssignments;
-            break;
-        }
+        aRet = aAssignIter->aDBColumnAssignments;
     }
     return aRet;
 }
@@ -1172,23 +1166,17 @@ OUString     SwMailMergeConfigItem::GetAssignedColumn(sal_uInt32 nColumn) const
 void SwMailMergeConfigItem::SetColumnAssignment( const SwDBData& rDBData,
                             const Sequence< OUString>& rList)
 {
-    std::vector<DBAddressDataAssignment>::iterator aAssignIter;
-    bool bFound = false;
-    for(aAssignIter = m_pImpl->m_aAddressDataAssignments.begin();
-                aAssignIter != m_pImpl->m_aAddressDataAssignments.end(); ++aAssignIter)
+    auto aAssignIter = std::find_if(m_pImpl->m_aAddressDataAssignments.begin(), m_pImpl->m_aAddressDataAssignments.end(),
+        [&rDBData](const DBAddressDataAssignment& rAssignment) { return rAssignment.aDBData == rDBData; });
+    if (aAssignIter != m_pImpl->m_aAddressDataAssignments.end())
     {
-        if(aAssignIter->aDBData == rDBData)
+        if(aAssignIter->aDBColumnAssignments != rList)
         {
-            if(aAssignIter->aDBColumnAssignments != rList)
-            {
-                aAssignIter->aDBColumnAssignments = rList;
-                aAssignIter->bColumnAssignmentsChanged = true;
-            }
-            bFound = true;
-            break;
+            aAssignIter->aDBColumnAssignments = rList;
+            aAssignIter->bColumnAssignmentsChanged = true;
         }
     }
-    if(!bFound)
+    else
     {
         DBAddressDataAssignment aAssignment;
         aAssignment.aDBData = rDBData;
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index 9b6b4fd92272..2fffef5820de 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -835,10 +835,9 @@ int SwTransferable::PrepareForCopy( bool bIsCut )
             if ( aD.GetTransferable().is() )
             {
                 DataFlavorExVector              aVector( aD.GetDataFlavorExVector() );
-                DataFlavorExVector::iterator    aIter( aVector.begin() ), aEnd( aVector.end() );
 
-                while( aIter != aEnd )
-                    AddFormat( *aIter++ );
+                for( const auto& rItem : aVector )
+                    AddFormat( rItem );
             }
         }
         m_eBufferType = TransferBufferType::Ole;
@@ -877,10 +876,8 @@ int SwTransferable::PrepareForCopy( bool bIsCut )
                     vDdeMarks.push_back(ppMark->get());
             }
             // remove all DDE-Bookmarks, they are invalid inside the clipdoc!
-            for(std::vector< ::sw::mark::IMark* >::iterator ppMark = vDdeMarks.begin();
-                ppMark != vDdeMarks.end();
-                ++ppMark)
-                pMarkAccess->deleteMark(*ppMark);
+            for(const auto& rpMark : vDdeMarks)
+                pMarkAccess->deleteMark(rpMark);
         }
 
         // a new one was created in CORE (OLE objects copied!)
diff --git a/sw/source/uibase/docvw/FrameControlsManager.cxx b/sw/source/uibase/docvw/FrameControlsManager.cxx
index 56b99b8bc217..e0c09639d09b 100644
--- a/sw/source/uibase/docvw/FrameControlsManager.cxx
+++ b/sw/source/uibase/docvw/FrameControlsManager.cxx
@@ -47,13 +47,10 @@ SwFrameControlPtr SwFrameControlsManager::GetControl( FrameControlType eType, co
 
 void SwFrameControlsManager::RemoveControls( const SwFrame* pFrame )
 {
-    map< FrameControlType, SwFrameControlPtrMap >::iterator pIt = m_aControls.begin();
-
-    while ( pIt != m_aControls.end() )
+    for ( auto& rEntry : m_aControls )
     {
-        SwFrameControlPtrMap& rMap = pIt->second;
+        SwFrameControlPtrMap& rMap = rEntry.second;
         rMap.erase(pFrame);
-        ++pIt;
     }
 }
 
@@ -65,28 +62,15 @@ void SwFrameControlsManager::RemoveControlsByType( FrameControlType eType, const
 
 void SwFrameControlsManager::HideControls( FrameControlType eType )
 {
-    SwFrameControlPtrMap::iterator pIt = m_aControls[eType].begin();
-    while ( pIt != m_aControls[eType].end() )
-    {
-        pIt->second->ShowAll( false );
-        ++pIt;
-    }
+    for ( const auto& rCtrl : m_aControls[eType] )
+        rCtrl.second->ShowAll( false );
 }
 
 void SwFrameControlsManager::SetReadonlyControls( bool bReadonly )
 {
-    map< FrameControlType, SwFrameControlPtrMap >::iterator pIt = m_aControls.begin();
-
-    while ( pIt != m_aControls.end() )
-    {
-        SwFrameControlPtrMap::iterator aCtrlIt = pIt->second.begin();
-        while ( aCtrlIt != pIt->second.end() )
-        {
-            aCtrlIt->second->SetReadonly( bReadonly );
-            ++aCtrlIt;
-        }
-        ++pIt;
-    }
+    for ( auto& rEntry : m_aControls )
+        for ( auto& rCtrl : rEntry.second )
+            rCtrl.second->SetReadonly( bReadonly );
 }
 
 void SwFrameControlsManager::SetHeaderFooterControl( const SwPageFrame* pPageFrame, FrameControlType eType, Point aOffset )
diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx
index ffa1ffe4f069..1bad79904b2a 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -299,21 +299,19 @@ SwSidebarItem* SwPostItMgr::InsertItem(SfxBroadcaster* pItem, bool bCheckExisten
 void SwPostItMgr::RemoveItem( SfxBroadcaster* pBroadcast )
 {
     EndListening(*pBroadcast);
-    for(auto i = mvPostItFields.begin(); i != mvPostItFields.end() ; ++i)
-    {
-        if ( (*i)->GetBroadCaster() == pBroadcast )
-        {
-            SwSidebarItem* p = (*i);
-            if (GetActiveSidebarWin() == p->pPostIt)
-                SetActiveSidebarWin(nullptr);
-            // tdf#120487 remove from list before dispose, so comment window
-            // won't be recreated due to the entry still in the list if focus
-            // transferring from the pPostIt triggers relayout of postits
-            mvPostItFields.erase(i);
-            p->pPostIt.disposeAndClear();
-            delete p;
-            break;
-        }
+    auto i = std::find_if(mvPostItFields.begin(), mvPostItFields.end(),
+        [&pBroadcast](const SwSidebarItem* pField) { return pField->GetBroadCaster() == pBroadcast; });
+    if (i != mvPostItFields.end())
+    {
+        SwSidebarItem* p = (*i);
+        if (GetActiveSidebarWin() == p->pPostIt)
+            SetActiveSidebarWin(nullptr);
+        // tdf#120487 remove from list before dispose, so comment window
+        // won't be recreated due to the entry still in the list if focus
+        // transferring from the pPostIt triggers relayout of postits
+        mvPostItFields.erase(i);
+        p->pPostIt.disposeAndClear();
+        delete p;
     }
     mbLayout = true;
     PrepareView();
@@ -1690,34 +1688,32 @@ SwAnnotationWin* SwPostItMgr::GetNextPostIt( sal_uInt16 aDirection,
 {
     if (mvPostItFields.size()>1)
     {
-        for(auto i = mvPostItFields.begin(); i != mvPostItFields.end() ; ++i)
+        auto i = std::find_if(mvPostItFields.begin(), mvPostItFields.end(),
+            [&aPostIt](const SwSidebarItem* pField) { return pField->pPostIt == aPostIt; });
+        if (i == mvPostItFields.end())
+            return nullptr;
+
+        auto iNextPostIt = i;
+        if (aDirection == KEY_PAGEUP)
         {
-            if ( (*i)->pPostIt == aPostIt)
+            if ( iNextPostIt == mvPostItFields.begin() )
             {
-                auto iNextPostIt  = i;
-                if (aDirection == KEY_PAGEUP)
-                {
-                    if ( iNextPostIt == mvPostItFields.begin() )
-                    {
-                        return nullptr;
-                    }
-                    --iNextPostIt;
-                }
-                else
-                {
-                    ++iNextPostIt;
-                    if ( iNextPostIt == mvPostItFields.end() )
-                    {
-                        return nullptr;
-                    }
-                }
-                // lets quit, we are back at the beginning
-                if ( (*iNextPostIt)->pPostIt == aPostIt)
-                    return nullptr;
-                return (*iNextPostIt)->pPostIt;
+                return nullptr;
             }
+            --iNextPostIt;
         }
-        return nullptr;
+        else
+        {
+            ++iNextPostIt;
+            if ( iNextPostIt == mvPostItFields.end() )
+            {
+                return nullptr;
+            }
+        }
+        // lets quit, we are back at the beginning
+        if ( (*iNextPostIt)->pPostIt == aPostIt)
+            return nullptr;
+        return (*iNextPostIt)->pPostIt;
     }
     else
         return nullptr;
diff --git a/sw/source/uibase/docvw/frmsidebarwincontainer.cxx b/sw/source/uibase/docvw/frmsidebarwincontainer.cxx
index 6a363e697bf7..5769386a2b56 100644
--- a/sw/source/uibase/docvw/frmsidebarwincontainer.cxx
+++ b/sw/source/uibase/docvw/frmsidebarwincontainer.cxx
@@ -104,16 +104,12 @@ bool SwFrameSidebarWinContainer::remove( const SwFrame& rFrame,
     if ( aFrameIter != mpFrameSidebarWinContainer->end() )
     {
         SidebarWinContainer& rSidebarWinContainer = (*aFrameIter).second;
-        for ( SidebarWinContainer::iterator aIter = rSidebarWinContainer.begin();
-              aIter != rSidebarWinContainer.end();
-              ++aIter )
+        auto aIter = std::find_if(rSidebarWinContainer.begin(), rSidebarWinContainer.end(),
+            [&rSidebarWin](const SidebarWinContainer::value_type& rEntry) { return rEntry.second == &rSidebarWin; });
+        if ( aIter != rSidebarWinContainer.end() )
         {
-            if ( (*aIter).second == &rSidebarWin )
-            {
-                rSidebarWinContainer.erase( aIter );
-                bRemoved = true;
-                break;
-            }
+            rSidebarWinContainer.erase( aIter );
+            bRemoved = true;
         }
     }
 
@@ -141,22 +137,12 @@ sw::annotation::SwAnnotationWin* SwFrameSidebarWinContainer::get( const SwFrame&
 
     FrameKey aFrameKey( &rFrame );
     FrameSidebarWinContainer::iterator aFrameIter = mpFrameSidebarWinContainer->find( aFrameKey );
-    if ( aFrameIter != mpFrameSidebarWinContainer->end() )
+    if ( aFrameIter != mpFrameSidebarWinContainer->end() && nIndex >= 0 )
     {
         SidebarWinContainer& rSidebarWinContainer = (*aFrameIter).second;
-        sal_Int32 nCounter( nIndex );
-        for ( SidebarWinContainer::iterator aIter = rSidebarWinContainer.begin();
-              nCounter >= 0 && aIter != rSidebarWinContainer.end();
-              ++aIter )
-        {
-            if ( nCounter == 0 )
-            {
-                pRet = (*aIter).second;
-                break;
-            }
-
-            --nCounter;
-        }
+        auto aIter = rSidebarWinContainer.begin();
+        std::advance(aIter, nIndex);
+        pRet = (*aIter).second;
     }
 
     return pRet;
@@ -172,11 +158,9 @@ void SwFrameSidebarWinContainer::getAll( const SwFrame& rFrame,
     if ( aFrameIter != mpFrameSidebarWinContainer->end() )
     {
         SidebarWinContainer& rSidebarWinContainer = (*aFrameIter).second;
-        for ( SidebarWinContainer::iterator aIter = rSidebarWinContainer.begin();
-              aIter != rSidebarWinContainer.end();
-              ++aIter )
+        for ( const auto& rEntry : rSidebarWinContainer )
         {
-            pSidebarWins->push_back( (*aIter).second );
+            pSidebarWins->push_back( rEntry.second );
         }
     }
 }
diff --git a/sw/source/uibase/envelp/labelcfg.cxx b/sw/source/uibase/envelp/labelcfg.cxx
index bb1a7191485c..8de5f3eb1499 100644
--- a/sw/source/uibase/envelp/labelcfg.cxx
+++ b/sw/source/uibase/envelp/labelcfg.cxx
@@ -254,9 +254,8 @@ void    SwLabelConfig::FillLabels(const OUString& rManufacturer, SwLabRecs& rLab
 {
     if (m_aLabels.find(rManufacturer) == m_aLabels.end())
         return;
-    for (std::map<OUString, SwLabelMeasure>::iterator it = m_aLabels[rManufacturer].begin();
-            it != m_aLabels[rManufacturer].end(); ++it)
-        rLabArr.push_back( lcl_CreateSwLabRec(it->first, it->second.m_aMeasure, rManufacturer) );
+    for (const auto& rEntry : m_aLabels[rManufacturer])
+        rLabArr.push_back( lcl_CreateSwLabRec(rEntry.first, rEntry.second.m_aMeasure, rManufacturer) );
 }
 
 bool    SwLabelConfig::HasLabel(const OUString& rManufacturer, const OUString& rType)
diff --git a/sw/source/uibase/lingu/olmenu.cxx b/sw/source/uibase/lingu/olmenu.cxx
index 8e945ddfc5c3..7295008727bb 100644
--- a/sw/source/uibase/lingu/olmenu.cxx
+++ b/sw/source/uibase/lingu/olmenu.cxx
@@ -185,10 +185,8 @@ void SwSpellPopup::fillLangPopupMenu(
     }
 
     sal_uInt16 nItemId = nLangItemIdStart;
-    std::set< OUString >::const_iterator it;
-    for (it = aLangItems.begin(); it != aLangItems.end(); ++it)
+    for (const OUString& aEntryText : aLangItems)
     {
-        OUString aEntryText( *it );
         if (aEntryText != SvtLanguageTable::GetLanguageString( LANGUAGE_NONE ) &&
             aEntryText != "*" && // multiple languages in current selection
             !aEntryText.isEmpty()) // 'no language found' from language guessing
diff --git a/sw/source/uibase/misc/glosdoc.cxx b/sw/source/uibase/misc/glosdoc.cxx
index 6fe5b9480fda..08cab28a4304 100644
--- a/sw/source/uibase/misc/glosdoc.cxx
+++ b/sw/source/uibase/misc/glosdoc.cxx
@@ -161,13 +161,8 @@ std::unique_ptr<SwTextBlocks> SwGlossaries::GetGroupDoc(const OUString &rName,
     // insert to the list of text blocks if applicable
     if(bCreate && !m_GlosArr.empty())
     {
-        std::vector<OUString>::const_iterator it(m_GlosArr.begin());
-        for (; it != m_GlosArr.end(); ++it)
-        {
-            if (*it == rName)
-                break;
-        }
-        if (it == m_GlosArr.end())
+        if (std::none_of(m_GlosArr.begin(), m_GlosArr.end(),
+                [&rName](const OUString& rEntry) { return rEntry == rName; }))
         {   // block not in the list
             m_GlosArr.push_back(rName);
         }
@@ -314,10 +309,8 @@ std::vector<OUString> & SwGlossaries::GetNameList()
             std::vector<OUString> aFiles;
 
             SWUnoHelper::UCB_GetFileListOfFolder(m_PathArr[i], aFiles, &sExt);
-            for( std::vector<OUString>::const_iterator filesIt(aFiles.begin());
-                 filesIt != aFiles.end(); ++filesIt)
+            for (const OUString& aTitle : aFiles)
             {
-                const OUString aTitle = *filesIt;
                 const OUString sName( aTitle.copy( 0, aTitle.getLength() - sExt.getLength() )
                     + OUStringLiteral1(GLOS_DELIM) + OUString::number( static_cast<sal_Int16>(i) ));
                 m_GlosArr.push_back(sName);
@@ -432,60 +425,56 @@ void SwGlossaries::RemoveFileFromList( const OUString& rGroup )
 {
     if (!m_GlosArr.empty())
     {
-        for (std::vector<OUString>::iterator it(m_GlosArr.begin());
-                it != m_GlosArr.end(); ++it)
+        auto it = std::find(m_GlosArr.begin(), m_GlosArr.end(), rGroup);
+        if (it != m_GlosArr.end())
         {
-            if (*it == rGroup)
             {
+                // tell the UNO AutoTextGroup object that it's not valid anymore
+                for (   UnoAutoTextGroups::iterator aLoop = m_aGlossaryGroups.begin();
+                        aLoop != m_aGlossaryGroups.end();
+                    )
                 {
-                    // tell the UNO AutoTextGroup object that it's not valid anymore
-                    for (   UnoAutoTextGroups::iterator aLoop = m_aGlossaryGroups.begin();
-                            aLoop != m_aGlossaryGroups.end();
-                        )
+                    Reference< container::XNamed > xNamed( aLoop->get(), UNO_QUERY );
+                    if ( !xNamed.is() )
                     {
-                        Reference< container::XNamed > xNamed( aLoop->get(), UNO_QUERY );
-                        if ( !xNamed.is() )
-                        {
-                            aLoop = m_aGlossaryGroups.erase(aLoop);
-                        }
-                        else if ( xNamed->getName() == rGroup )
-                        {
-                            static_cast< SwXAutoTextGroup* >( xNamed.get() )->Invalidate();
-                                // note that this static_cast works because we know that the array only
-                                // contains SwXAutoTextGroup implementation
-                            m_aGlossaryGroups.erase( aLoop );
-                            break;
-                        } else
-                            ++aLoop;
+                        aLoop = m_aGlossaryGroups.erase(aLoop);
                     }
+                    else if ( xNamed->getName() == rGroup )
+                    {
+                        static_cast< SwXAutoTextGroup* >( xNamed.get() )->Invalidate();
+                            // note that this static_cast works because we know that the array only
+                            // contains SwXAutoTextGroup implementation
+                        m_aGlossaryGroups.erase( aLoop );
+                        break;
+                    } else
+                        ++aLoop;
                 }
+            }
 
+            {
+                // tell all our UNO AutoTextEntry objects that they're not valid anymore
+                for (   UnoAutoTextEntries::iterator aLoop = m_aGlossaryEntries.begin();
+                        aLoop != m_aGlossaryEntries.end();
+                    )
                 {
-                    // tell all our UNO AutoTextEntry objects that they're not valid anymore
-                    for (   UnoAutoTextEntries::iterator aLoop = m_aGlossaryEntries.begin();
-                            aLoop != m_aGlossaryEntries.end();
-                        )
+                    Reference< lang::XUnoTunnel > xEntryTunnel( aLoop->get(), UNO_QUERY );
+
+                    SwXAutoTextEntry* pEntry = nullptr;
+                    if ( xEntryTunnel.is() )
+                        pEntry = reinterpret_cast< SwXAutoTextEntry* >(
+                            xEntryTunnel->getSomething( SwXAutoTextEntry::getUnoTunnelId() ) );
+
+                    if ( pEntry && ( pEntry->GetGroupName() == rGroup ) )
                     {
-                        Reference< lang::XUnoTunnel > xEntryTunnel( aLoop->get(), UNO_QUERY );
-
-                        SwXAutoTextEntry* pEntry = nullptr;
-                        if ( xEntryTunnel.is() )
-                            pEntry = reinterpret_cast< SwXAutoTextEntry* >(
-                                xEntryTunnel->getSomething( SwXAutoTextEntry::getUnoTunnelId() ) );
-
-                        if ( pEntry && ( pEntry->GetGroupName() == rGroup ) )
-                        {
-                            pEntry->Invalidate();
-                            aLoop = m_aGlossaryEntries.erase( aLoop );
-                        }
-                        else
-                            ++aLoop;
+                        pEntry->Invalidate();
+                        aLoop = m_aGlossaryEntries.erase( aLoop );
                     }
+                    else
+                        ++aLoop;
                 }
-
-                m_GlosArr.erase(it);
-                break;
             }
+
+            m_GlosArr.erase(it);
         }
     }
 }
@@ -517,12 +506,9 @@ OUString SwGlossaries::GetCompleteGroupName( const OUString& rGroupName )
 void SwGlossaries::InvalidateUNOOjects()
 {
     // invalidate all the AutoTextGroup-objects
-    for (   UnoAutoTextGroups::iterator aGroupLoop = m_aGlossaryGroups.begin();
-            aGroupLoop != m_aGlossaryGroups.end();
-            ++aGroupLoop
-        )
+    for (const auto& rGroup : m_aGlossaryGroups)
     {
-        Reference< text::XAutoTextGroup > xGroup( aGroupLoop->get(), UNO_QUERY );
+        Reference< text::XAutoTextGroup > xGroup( rGroup.get(), UNO_QUERY );
         if ( xGroup.is() )
             static_cast< SwXAutoTextGroup* >( xGroup.get() )->Invalidate();
     }
@@ -530,12 +516,9 @@ void SwGlossaries::InvalidateUNOOjects()
     m_aGlossaryGroups.swap( aTmpg );
 
     // invalidate all the AutoTextEntry-objects
-    for (   UnoAutoTextEntries::const_iterator aEntryLoop = m_aGlossaryEntries.begin();
-            aEntryLoop != m_aGlossaryEntries.end();
-            ++aEntryLoop
-        )
+    for (const auto& rEntry : m_aGlossaryEntries)
     {
-        Reference< lang::XUnoTunnel > xEntryTunnel( aEntryLoop->get(), UNO_QUERY );
+        Reference< lang::XUnoTunnel > xEntryTunnel( rEntry.get(), UNO_QUERY );
         SwXAutoTextEntry* pEntry = nullptr;
         if ( xEntryTunnel.is() )
             pEntry = reinterpret_cast< SwXAutoTextEntry* >(
diff --git a/sw/source/uibase/misc/redlndlg.cxx b/sw/source/uibase/misc/redlndlg.cxx
index cd1579496ef2..8b2001b3f065 100644
--- a/sw/source/uibase/misc/redlndlg.cxx
+++ b/sw/source/uibase/misc/redlndlg.cxx
@@ -497,15 +497,11 @@ SwRedlineTable::size_type SwRedlineAcceptDlg::CalcDiff(SwRedlineTable::size_type
             if (pBackupData->pTLBChild)
                 m_pTable->RemoveEntry(pBackupData->pTLBChild);
 
-            for (SwRedlineDataChildArr::iterator it = m_RedlineChildren.begin();
-                 it != m_RedlineChildren.end(); ++it)
-            {
-                if (it->get() == pBackupData)
-                {
-                    m_RedlineChildren.erase(it);
-                    break;
-                }
-            }
+            auto it = std::find_if(m_RedlineChildren.begin(), m_RedlineChildren.end(),
+                [&pBackupData](const std::unique_ptr<SwRedlineDataChild>& rChildPtr) { return rChildPtr.get() == pBackupData; });
+            if (it != m_RedlineChildren.end())
+                m_RedlineChildren.erase(it);
+
             pBackupData = pNext;
         }
         pParent->pNext = nullptr;
@@ -669,22 +665,19 @@ void SwRedlineAcceptDlg::RemoveParents(SwRedlineTable::size_type nStart, SwRedli
         {
             SwRedlineDataChild * pChildPtr =
                 const_cast<SwRedlineDataChild*>(m_RedlineParents[i]->pNext);
-            for (SwRedlineDataChildArr::iterator it = m_RedlineChildren.begin();
-                 it != m_RedlineChildren.end(); ++it)
+            auto it = std::find_if(m_RedlineChildren.begin(), m_RedlineChildren.end(),
+                [&pChildPtr](const std::unique_ptr<SwRedlineDataChild>& rChildPtr) { return rChildPtr.get() == pChildPtr; });
+            if (it != m_RedlineChildren.end())
             {
-                if (it->get() == pChildPtr)
+                sal_uInt16 nChildren = 0;
+                while (pChildPtr)
                 {
-                    sal_uInt16 nChildren = 0;
-                    while (pChildPtr)
-                    {
-                        pChildPtr = const_cast<SwRedlineDataChild*>(pChildPtr->pNext);
-                        nChildren++;
-                    }
-
-                    m_RedlineChildren.erase(it, it + nChildren);
-                    bChildrenRemoved = true;
-                    break;
+                    pChildPtr = const_cast<SwRedlineDataChild*>(pChildPtr->pNext);
+                    nChildren++;
                 }
+
+                m_RedlineChildren.erase(it, it + nChildren);
+                bChildrenRemoved = true;
             }
         }
         SvTreeListEntry *const pEntry = m_RedlineParents[i]->pTLBParent;
@@ -834,12 +827,9 @@ void SwRedlineAcceptDlg::CallAcceptReject( bool bSelect, bool bAccept )
     // are merged in result of another one being deleted), so the
     // position must be resolved late and checked before using it.
     // (cf #102547#)
-    ListBoxEntries_t::iterator aEnd = aRedlines.end();
-    for( ListBoxEntries_t::iterator aIter = aRedlines.begin();
-         aIter != aEnd;
-         ++aIter )
+    for (const auto& rRedLine : aRedlines)
     {
-        SwRedlineTable::size_type nPosition = GetRedlinePos( **aIter );
+        SwRedlineTable::size_type nPosition = GetRedlinePos( *rRedLine );
         if( nPosition != SwRedlineTable::npos )
             (pSh->*FnAccRej)( nPosition );
     }
diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx
index a54eb47a179d..5e2ee8a5e808 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -1283,13 +1283,11 @@ IMPL_LINK_NOARG(SwBaseShell, GraphicArrivedHdl, SwCursorShell&, void)
     {
         bool bProtect = FlyProtectFlags::NONE != rSh.IsSelObjProtected(FlyProtectFlags::Content|FlyProtectFlags::Parent);
         SfxViewFrame* pVFrame = GetView().GetViewFrame();
-        sal_uInt16 nSlot;
-        std::set<sal_uInt16>::iterator it;
-        for( it = aGrfUpdateSlots.begin(); it != aGrfUpdateSlots.end(); ++it )
+        for( const auto nSlot : aGrfUpdateSlots )
         {
             bool bSetState = false;
             bool bState = false;
-            switch( nSlot = *it )
+            switch( nSlot )
             {
             case SID_IMAP:
             case SID_IMAP_EXEC:
diff --git a/sw/source/uibase/uiview/formatclipboard.cxx b/sw/source/uibase/uiview/formatclipboard.cxx
index 7fb50ee8c7c7..7ea583af5305 100644
--- a/sw/source/uibase/uiview/formatclipboard.cxx
+++ b/sw/source/uibase/uiview/formatclipboard.cxx
@@ -441,17 +441,14 @@ static void lcl_AppendSetItems( ItemVector& rItemVector, const SfxItemSet& rStyl
 // remove all items that are inherited from the styles
 static void lcl_RemoveEqualItems( SfxItemSet& rTemplateItemSet, const ItemVector& rItemVector )
 {
-    ItemVector::const_iterator aEnd = rItemVector.end();
-    ItemVector::const_iterator aIter = rItemVector.begin();
-    while( aIter != aEnd )
+    for( const auto& rItem : rItemVector )
     {
         const SfxPoolItem* pItem;
-        if( SfxItemState::SET == rTemplateItemSet.GetItemState( (*aIter)->Which(), true, &pItem ) &&
-            *pItem == *(*aIter) )
+        if( SfxItemState::SET == rTemplateItemSet.GetItemState( rItem->Which(), true, &pItem ) &&
+            *pItem == *rItem )
         {
-            rTemplateItemSet.ClearItem( (*aIter)->Which() );
+            rTemplateItemSet.ClearItem( rItem->Which() );
         }
-        ++aIter;
     }
 }
 
diff --git a/sw/source/uibase/uiview/uivwimp.cxx b/sw/source/uibase/uiview/uivwimp.cxx
index 69ee63b9daa4..e7ce5be812ab 100644
--- a/sw/source/uibase/uiview/uivwimp.cxx
+++ b/sw/source/uibase/uiview/uivwimp.cxx
@@ -226,14 +226,11 @@ void SwView_Impl::AddTransferable(SwTransferable& rTransferable)
     rTransferable.m_refCount++;
     {
         // Remove previously added, but no longer existing weak references.
-        for (auto it = mxTransferables.begin(); it != mxTransferables.end();)
-        {
-            uno::Reference<lang::XUnoTunnel> xTunnel(it->get(), uno::UNO_QUERY);
-            if (!xTunnel.is())
-                it = mxTransferables.erase(it);
-            else
-                ++it;
-        }
+        mxTransferables.erase(std::remove_if(mxTransferables.begin(), mxTransferables.end(),
+            [](const css::uno::WeakReference<css::lang::XUnoTunnel>& rTunnel) {
+                uno::Reference<lang::XUnoTunnel> xTunnel(rTunnel.get(), uno::UNO_QUERY);
+                return !xTunnel.is();
+            }), mxTransferables.end());
 
         mxTransferables.emplace_back(uno::Reference<lang::XUnoTunnel>(&rTransferable));
     }
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 0446bf4bac7c..9324c70999af 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3902,14 +3902,14 @@ uno::Sequence< lang::Locale > SAL_CALL SwXTextDocument::getDocumentLanguages(
     if (nMaxCount > 0)
     {
         sal_Int32 nCount = 0;
-        for (std::set< LanguageType >::const_iterator it = aAllLangs.begin(); it != aAllLangs.end(); ++it)
+        for (const auto& rLang : aAllLangs)
         {
             if (nCount >= nMaxCount)
                 break;
-            if (LANGUAGE_NONE != *it)
+            if (LANGUAGE_NONE != rLang)
             {
-                pLanguage[nCount] = LanguageTag::convertToLocale( *it );
-                pLanguage[nCount].Language = SvtLanguageTable::GetLanguageString( *it );
+                pLanguage[nCount] = LanguageTag::convertToLocale( rLang );
+                pLanguage[nCount].Language = SvtLanguageTable::GetLanguageString( rLang );
                 nCount += 1;
             }
         }
diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx
index 2bb546138d60..014dcfb22493 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -701,10 +701,10 @@ void SwContentType::FillMemberList(bool* pbLevelOrVisibilityChanged)
             std::vector<OUString> aRefMarks;
             nMemberCount = pWrtShell->GetRefMarks( &aRefMarks );
 
-            for(std::vector<OUString>::const_iterator i = aRefMarks.begin(); i != aRefMarks.end(); ++i)
+            for (const auto& rRefMark : aRefMarks)
             {
                 // References sorted alphabetically
-                pMember->insert(o3tl::make_unique<SwContent>(this, *i, 0));
+                pMember->insert(o3tl::make_unique<SwContent>(this, rRefMark, 0));
             }
         }
         break;
diff --git a/sw/source/uibase/utlui/gloslst.cxx b/sw/source/uibase/utlui/gloslst.cxx
index ea41daf985f4..c8f1102813ce 100644
--- a/sw/source/uibase/utlui/gloslst.cxx
+++ b/sw/source/uibase/utlui/gloslst.cxx
@@ -146,8 +146,8 @@ bool SwGlossaryList::GetShortName(const OUString& rLongName,
         aDlg.set_title(sTitle);
 
         weld::TreeView& rLB = aDlg.GetTreeView();
-        for(std::vector<TripleString>::const_iterator i = aTripleStrings.begin(); i != aTripleStrings.end(); ++i)
-            rLB.append_text(i->sGroup.getToken(0, GLOS_DELIM));
+        for (const auto& rTriple : aTripleStrings)
+            rLB.append_text(rTriple.sGroup.getToken(0, GLOS_DELIM));
 
         rLB.select(0);
         if (aDlg.run() == RET_OK && rLB.get_selected_index() != -1)
@@ -317,10 +317,9 @@ void SwGlossaryList::Update()
                 // for the current subpath.
                 if( nGroupPath == nPath )
                 {
-                    bool bFound = false;
                     OUString sCompareGroup = pGroup->sName.getToken(0, GLOS_DELIM);
-                    for(std::vector<OUString>::const_iterator j = aFoundGroupNames.begin(); j != aFoundGroupNames.end() && !bFound; ++j)
-                        bFound = (sCompareGroup == *j);
+                    bool bFound = std::any_of(aFoundGroupNames.begin(), aFoundGroupNames.end(),
+                        [&sCompareGroup](const OUString& rGroupName) { return sCompareGroup == rGroupName; });
 
                     if(!bFound)
                     {
diff --git a/sw/source/uibase/wrtsh/navmgr.cxx b/sw/source/uibase/wrtsh/navmgr.cxx
index e2adc872ebbe..021c6be512b3 100644
--- a/sw/source/uibase/wrtsh/navmgr.cxx
+++ b/sw/source/uibase/wrtsh/navmgr.cxx
@@ -62,14 +62,12 @@ void SwNavigationMgr::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
     // m_entries if that happens
     if (typeid(rHint) == typeid(sw::UnoCursorHint))
     {
-        for (auto it = m_entries.begin(); it != m_entries.end(); ++it)
+        auto it = std::find_if(m_entries.begin(), m_entries.end(),
+            [&rBC](const sw::UnoCursorPointer& rItem) { return !rItem || &rBC == &rItem.get()->m_aNotifier; });
+        if (it != m_entries.end())
         {
-            if (!*it || &rBC == &it->get()->m_aNotifier)
-            {
-                EndListening(rBC);
-                m_entries.erase(it);
-                break;
-            }
+            EndListening(rBC);
+            m_entries.erase(it);
         }
     }
 }


More information about the Libreoffice-commits mailing list