sw/source/ui/config/optcomp.cxx               |    8 ---
 sw/source/ui/dbui/addresslistdialog.cxx       |   21 +++-----
 sw/source/ui/dbui/dbinsdlg.cxx                |   32 ++++--------
 sw/source/ui/dbui/dbtablepreviewdialog.cxx    |   17 ++----
 sw/source/ui/dbui/mmaddressblockpage.cxx      |   42 +++++-----------
 sw/source/ui/dbui/mmdocselectpage.cxx         |    4 -
 sw/source/ui/dbui/mmgreetingspage.cxx         |   12 ++--
 sw/source/ui/dbui/mmlayoutpage.cxx            |   14 ++---
 sw/source/ui/dbui/mmoutputtypepage.cxx        |    4 -
 sw/source/ui/dbui/mmresultdialogs.cxx         |    5 -
 sw/source/ui/dbui/selectdbtabledialog.cxx     |    6 --
 sw/source/ui/envelp/envlop1.cxx               |    5 -
 sw/source/ui/envelp/label1.cxx                |    5 -
 sw/source/ui/envelp/mailmrge.cxx              |   19 ++-----
 sw/source/ui/fldui/DropDownFieldDialog.cxx    |    5 -
 sw/source/ui/fldui/changedb.cxx               |   11 ----
 sw/source/ui/fldui/flddinf.cxx                |    4 -
 sw/source/ui/fldui/fldfunc.cxx                |    5 -
 sw/source/ui/index/swuiidxmrk.cxx             |   28 ++++------
 sw/source/ui/vba/vbaaddins.cxx                |    4 -
 sw/source/ui/vba/vbadocumentproperties.cxx    |   36 ++++---------
 sw/source/ui/vba/vbafilterpropsfromformat.hxx |   67 ++++++++++++--------------
 sw/source/ui/vba/vbastyles.cxx                |   12 +---
 sw/source/ui/vba/vbatabstops.cxx              |   30 +++++------
 sw/source/ui/vba/vbavariable.cxx              |    9 +--
 sw/source/ui/vba/vbavariables.cxx             |    5 +
 26 files changed, 165 insertions(+), 245 deletions(-)

New commits:
commit 890a59934985ee73d15be10fc083d325858c4f4b
Author:     Arkadiy Illarionov <qar...@gmail.com>
AuthorDate: Tue Jul 2 19:15:51 2019 +0300
Commit:     Arkadiy Illarionov <qar...@gmail.com>
CommitDate: Wed Jul 3 21:00:41 2019 +0200

    Simplify Sequence iterations in sw/source/ui/*
    
    Use range-based loops, STL and comphelper functions
    
    Change-Id: I0832f526cc549c76b423f5d5d7a5d2928ce117dc
    Reviewed-on: https://gerrit.libreoffice.org/75005
    Tested-by: Jenkins
    Reviewed-by: Arkadiy Illarionov <qar...@gmail.com>

diff --git a/sw/source/ui/config/optcomp.cxx b/sw/source/ui/config/optcomp.cxx
index fff81e5e82a5..439fbb8285a6 100644
--- a/sw/source/ui/config/optcomp.cxx
+++ b/sw/source/ui/config/optcomp.cxx
@@ -242,14 +242,10 @@ void SwCompatibilityOptPage::InitControls( const 
SfxItemSet& rSet )
     SvtCompatibilityEntry aEntry;
     aEntry.setValue<bool>( SvtCompatibilityEntry::Index::ExpandWordSpace, 
false );
 
-    const sal_Int32 nCount = aList.getLength();
-    for ( sal_Int32 i = 0; i < nCount; ++i )
+    for ( const Sequence< PropertyValue >& rEntry : aList )
     {
-        const Sequence< PropertyValue >& rEntry = aList[i];
-        const sal_Int32 nEntries = rEntry.getLength();
-        for ( sal_Int32 j = 0; j < nEntries; j++ )
+        for ( const PropertyValue& aValue : rEntry )
         {
-            PropertyValue aValue = rEntry[j];
             aEntry.setValue( SvtCompatibilityEntry::getIndex(aValue.Name), 
aValue.Value );
         }
 
diff --git a/sw/source/ui/dbui/addresslistdialog.cxx 
b/sw/source/ui/dbui/addresslistdialog.cxx
index 93446315ee55..21c2a19dfef1 100644
--- a/sw/source/ui/dbui/addresslistdialog.cxx
+++ b/sw/source/ui/dbui/addresslistdialog.cxx
@@ -99,12 +99,12 @@ static OUString lcl_getFlatURL( 
uno::Reference<beans::XPropertySet> const & xSou
             {
                 OUString sExtension;
                 OUString sCharSet;
-                for(sal_Int32 nInfo = 0; nInfo < aInfo.getLength(); ++nInfo)
+                for(const auto& rInfo : aInfo)
                 {
-                    if(aInfo[nInfo].Name == "Extension")
-                        aInfo[nInfo].Value >>= sExtension;
-                    else if(aInfo[nInfo].Name == "CharSet")
-                        aInfo[nInfo].Value >>= sCharSet;
+                    if(rInfo.Name == "Extension")
+                        rInfo.Value >>= sExtension;
+                    else if(rInfo.Name == "CharSet")
+                        rInfo.Value >>= sCharSet;
                 }
                 if (sCharSet=="UTF-8")
                 {
@@ -168,17 +168,16 @@ 
SwAddressListDialog::SwAddressListDialog(SwMailMergeAddressBlockPage* pParent)
     SwDBConfig aDb;
     const OUString sBibliography = aDb.GetBibliographySource().sDataSource;
     uno::Sequence< OUString> aNames = m_xDBContext->getElementNames();
-    const OUString* pNames = aNames.getConstArray();
-    for(sal_Int32 nName = 0; nName < aNames.getLength(); ++nName)
+    for(const OUString& rName : aNames)
     {
-        if ( pNames[nName] == sBibliography )
+        if ( rName == sBibliography )
             continue;
         m_xListLB->append(m_xIter.get());
-        m_xListLB->set_text(*m_xIter, pNames[nName], 0);
+        m_xListLB->set_text(*m_xIter, rName, 0);
         m_aUserData.emplace_back(new AddressUserData_Impl);
         AddressUserData_Impl* pUserData = m_aUserData.back().get();
         m_xListLB->set_id(*m_xIter, 
OUString::number(reinterpret_cast<sal_Int64>(pUserData)));
-        if (pNames[nName] == rCurrentData.sDataSource)
+        if (rName == rCurrentData.sDataSource)
         {
             m_xListLB->select(*m_xIter);
             m_xListLB->set_text(*m_xIter, rCurrentData.sCommand, 1);
@@ -192,7 +191,7 @@ 
SwAddressListDialog::SwAddressListDialog(SwMailMergeAddressBlockPage* pParent)
             uno::Reference<beans::XPropertySet> xSourceProperties;
             try
             {
-                m_xDBContext->getByName(pNames[nName]) >>= xSourceProperties;
+                m_xDBContext->getByName(rName) >>= xSourceProperties;
                 pUserData->sURL = lcl_getFlatURL( xSourceProperties );
                 bEnableEdit = !pUserData->sURL.isEmpty() &&
                     SWUnoHelper::UCB_IsFile( pUserData->sURL ) && //#i97577#
diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx
index d5f925903836..07ce4b12186e 100644
--- a/sw/source/ui/dbui/dbinsdlg.cxx
+++ b/sw/source/ui/dbui/dbinsdlg.cxx
@@ -40,6 +40,7 @@
 #include <com/sun/star/util/XNumberFormatTypes.hpp>
 #include <com/sun/star/sdbc/XRowSet.hpp>
 #include <comphelper/processfactory.hxx>
+#include <comphelper/sequence.hxx>
 #include <comphelper/types.hxx>
 #include <sal/log.hxx>
 #include <editeng/langitem.hxx>
@@ -246,12 +247,10 @@ SwInsertDBColAutoPilot::SwInsertDBColAutoPilot( SwView& 
rView,
         }
         Reference <XNameAccess> xCols = xColSupp->getColumns();
         Sequence<OUString> aColNames = xCols->getElementNames();
-        const OUString* pColNames = aColNames.getConstArray();
-        sal_Int32 nCount = aColNames.getLength();
-        for (sal_Int32 n = 0; n < nCount; ++n)
+        for (const OUString& rColName : aColNames)
         {
-            std::unique_ptr<SwInsDBColumn> pNew(new SwInsDBColumn( 
pColNames[n] ));
-            Any aCol = xCols->getByName(pColNames[n]);
+            std::unique_ptr<SwInsDBColumn> pNew(new SwInsDBColumn( rColName ));
+            Any aCol = xCols->getByName(rColName);
             Reference <XPropertySet> xCol;
             aCol >>= xCol;
             Any aType = xCol->getPropertyValue("Type");
@@ -1467,18 +1466,11 @@ static Sequence<OUString> lcl_CreateSubNames(const 
OUString& rSubNodeName)
 
 static OUString lcl_CreateUniqueName(const Sequence<OUString>& aNames)
 {
-    const sal_Int32 nNames = aNames.getLength();
-    sal_Int32 nIdx = nNames;
-    const OUString* pNames = aNames.getConstArray();
+    sal_Int32 nIdx = aNames.getLength();
     while(true)
     {
         const OUString sRet = "_" + OUString::number(nIdx++);
-        sal_Int32 i = 0;
-        while ( i < nNames && pNames[i] != sRet )
-        {
-            ++i;
-        }
-        if ( i >= nNames )
+        if ( comphelper::findValue(aNames, sRet) == -1 )
             return sRet;    // No match found, return unique name
     }
 }
@@ -1562,11 +1554,10 @@ void SwInsertDBColAutoPilot::ImplCommit()
         Sequence <OUString> aSubNodeNames = 
lcl_CreateSubNames(sColumnInsertNode);
         Sequence<PropertyValue> aSubValues(aSubNodeNames.getLength());
         PropertyValue* pSubValues = aSubValues.getArray();
-        const OUString* pSubNodeNames = aSubNodeNames.getConstArray();
-        sal_Int32 i;
+        sal_Int32 i = 0;
 
-        for( i = 0; i < aSubNodeNames.getLength(); i++)
-            pSubValues[i].Name = pSubNodeNames[i];
+        for( const OUString& rSubNodeName : aSubNodeNames)
+            pSubValues[i++].Name = rSubNodeName;
         pSubValues[0].Value <<= pColumn->sColumn;
         pSubValues[1].Value <<= i;
         pSubValues[2].Value <<= pColumn->bHasFormat;
@@ -1633,11 +1624,10 @@ void SwInsertDBColAutoPilot::Load()
 
             const OUString sSubNodeName(nodeName + "/ColumnSet/");
             Sequence <OUString> aSubNames = GetNodeNames(sSubNodeName);
-            const OUString* pSubNames = aSubNames.getConstArray();
-            for(sal_Int32 nSub = 0; nSub < aSubNames.getLength(); nSub++)
+            for(const OUString& rSubName : aSubNames)
             {
                 Sequence <OUString> aSubNodeNames =
-                    lcl_CreateSubNames(sSubNodeName + pSubNames[nSub]);
+                    lcl_CreateSubNames(sSubNodeName + rSubName);
                 Sequence< Any> aSubProps = GetProperties(aSubNodeNames);
                 const Any* pSubProps = aSubProps.getConstArray();
 
diff --git a/sw/source/ui/dbui/dbtablepreviewdialog.cxx 
b/sw/source/ui/dbui/dbtablepreviewdialog.cxx
index 9676508fa7c6..42f07505fe37 100644
--- a/sw/source/ui/dbui/dbtablepreviewdialog.cxx
+++ b/sw/source/ui/dbui/dbtablepreviewdialog.cxx
@@ -41,17 +41,14 @@ SwDBTablePreviewDialog::SwDBTablePreviewDialog(vcl::Window* 
pParent, uno::Sequen
     m_pBeamerWIN->set_width_request(aSize.Width());
     m_pBeamerWIN->set_height_request(aSize.Height());
 
-    const beans::PropertyValue* pValues = rValues.getConstArray();
-    for(sal_Int32 nValue = 0; nValue < rValues.getLength(); ++nValue        )
+    auto pValue = std::find_if(rValues.begin(), rValues.end(),
+        [](const beans::PropertyValue& rValue) { return rValue.Name == 
"Command"; });
+    if (pValue != rValues.end())
     {
-        if ( pValues[nValue].Name == "Command" )
-        {
-            OUString sDescription = m_pDescriptionFI->GetText();
-            OUString sTemp;
-            pValues[nValue].Value >>= sTemp;
-            m_pDescriptionFI->SetText(sDescription.replaceFirst("%1", sTemp));
-            break;
-        }
+        OUString sDescription = m_pDescriptionFI->GetText();
+        OUString sTemp;
+        pValue->Value >>= sTemp;
+        m_pDescriptionFI->SetText(sDescription.replaceFirst("%1", sTemp));
     }
 
     try
diff --git a/sw/source/ui/dbui/mmaddressblockpage.cxx 
b/sw/source/ui/dbui/mmaddressblockpage.cxx
index 9fbc4395b886..6331035d7a01 100644
--- a/sw/source/ui/dbui/mmaddressblockpage.cxx
+++ b/sw/source/ui/dbui/mmaddressblockpage.cxx
@@ -38,6 +38,7 @@
 #include <com/sun/star/sdbc/SQLException.hpp>
 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
 #include <com/sun/star/sdb/XColumn.hpp>
+#include <comphelper/sequence.hxx>
 #include <comphelper/string.hxx>
 #include <sal/log.hxx>
 #include <tools/diagnose_ex.h>
@@ -147,8 +148,8 @@ void SwMailMergeAddressBlockPage::ActivatePage()
         m_pSettingsWIN->Clear();
         const uno::Sequence< OUString> aBlocks =
                     m_pWizard->GetConfigItem().GetAddressBlocks();
-        for(sal_Int32 nAddress = 0; nAddress < aBlocks.getLength(); ++nAddress)
-            m_pSettingsWIN->AddAddress(aBlocks[nAddress]);
+        for(const auto& rAddress : aBlocks)
+            m_pSettingsWIN->AddAddress(rAddress);
         
m_pSettingsWIN->SelectAddress(static_cast<sal_uInt16>(rConfigItem.GetCurrentAddressBlockIndex()));
         m_pAddressCB->Check(rConfigItem.IsAddressBlock());
         AddressBlockHdl_Impl(m_pAddressCB);
@@ -203,8 +204,8 @@ IMPL_LINK_NOARG(SwMailMergeAddressBlockPage, 
SettingsHdl_Impl, Button*, void)
         const uno::Sequence< OUString> aBlocks = aDlg.GetAddressBlocks();
         rConfig.SetAddressBlocks(aBlocks);
         m_pSettingsWIN->Clear();
-        for(sal_Int32 nAddress = 0; nAddress < aBlocks.getLength(); ++nAddress)
-            m_pSettingsWIN->AddAddress(aBlocks[nAddress]);
+        for(const auto& rAddress : aBlocks)
+            m_pSettingsWIN->AddAddress(rAddress);
         m_pSettingsWIN->SelectAddress(0);
         m_pSettingsWIN->Invalidate();    // #i40408
         rConfig.SetCountrySettings(aDlg.IsIncludeCountry(), aDlg.GetCountry());
@@ -355,8 +356,8 @@ void SwSelectAddressBlockDialog::SetAddressBlocks(const 
uno::Sequence< OUString>
         sal_uInt16 nSelectedAddress)
 {
     m_aAddressBlocks = rBlocks;
-    for (sal_Int32 nAddress = 0; nAddress < m_aAddressBlocks.getLength(); 
++nAddress)
-        m_xPreview->AddAddress(m_aAddressBlocks[nAddress]);
+    for (const auto& rAddressBlock : m_aAddressBlocks)
+        m_xPreview->AddAddress(rAddressBlock);
     m_xPreview->SelectAddress(nSelectedAddress);
 }
 
@@ -368,17 +369,9 @@ const uno::Sequence< OUString >&    
SwSelectAddressBlockDialog::GetAddressBlocks
     if(nSelect)
     {
         uno::Sequence< OUString >aTemp = m_aAddressBlocks;
-        OUString* pTemp = aTemp.getArray();
-        pTemp[0] = m_aAddressBlocks[nSelect];
-        sal_Int32 nIndex = 0;
-        const sal_Int32 nNumBlocks = m_aAddressBlocks.getLength();
-        for(sal_Int32 nAddress = 1; nAddress < nNumBlocks; ++nAddress)
-        {
-            if(nIndex == nSelect)
-                ++nIndex;
-            pTemp[nAddress] = m_aAddressBlocks[nIndex];
-            nIndex++;
-        }
+        aTemp[0] = m_aAddressBlocks[nSelect];
+        std::copy(m_aAddressBlocks.begin(), 
std::next(m_aAddressBlocks.begin(), nSelect), std::next(aTemp.begin()));
+        std::copy(std::next(m_aAddressBlocks.begin(), nSelect + 1), 
m_aAddressBlocks.end(), std::next(aTemp.begin(), nSelect + 1));
         m_aAddressBlocks = aTemp;
     }
     return m_aAddressBlocks;
@@ -410,15 +403,7 @@ IMPL_LINK(SwSelectAddressBlockDialog, DeleteHdl_Impl, 
weld::Button&, rButton, vo
     if (m_aAddressBlocks.getLength())
     {
         const sal_Int32 nSelected = 
static_cast<sal_Int32>(m_xPreview->GetSelectedAddress());
-        OUString* pAddressBlocks = m_aAddressBlocks.getArray();
-        sal_Int32 nSource = 0;
-        for(sal_Int32 nTarget = 0; nTarget < m_aAddressBlocks.getLength() - 1; 
nTarget++)
-        {
-            if(nSource == nSelected)
-                ++nSource;
-            pAddressBlocks[nTarget] = pAddressBlocks[nSource++];
-        }
-        m_aAddressBlocks.realloc(m_aAddressBlocks.getLength() - 1);
+        comphelper::removeElementAt(m_aAddressBlocks, nSelected);
         if (m_aAddressBlocks.getLength() <= 1)
             rButton.set_sensitive(false);
         m_xPreview->RemoveSelectedAddress();
@@ -858,7 +843,6 @@ void SwAssignFieldsControl::Init(SwAssignFieldsDialog* 
pDialog, SwMailMergeConfi
     uno::Sequence< OUString > aFields;
     if(xColAccess.is())
         aFields = xColAccess->getElementNames();
-    const OUString* pFields = aFields.getConstArray();
 
     //get the current assignment list
     //each position in this sequence matches the position in the header array 
rHeaders
@@ -879,8 +863,8 @@ void SwAssignFieldsControl::Init(SwAssignFieldsDialog* 
pDialog, SwMailMergeConfi
         rNewLB.append_text(SwResId(SW_STR_NONE));
         rNewLB.set_active(0);
 
-        for (sal_Int32 nField = 0; nField < aFields.getLength(); ++nField)
-            rNewLB.append_text(pFields[nField]);
+        for (const OUString& rField : aFields)
+            rNewLB.append_text(rField);
         //select the ListBox
         //if there is an assignment
         if(static_cast<sal_uInt32>(aAssignments.getLength()) > i && 
!aAssignments[i].isEmpty())
diff --git a/sw/source/ui/dbui/mmdocselectpage.cxx 
b/sw/source/ui/dbui/mmdocselectpage.cxx
index 1991a7d4b2ef..fd2e3544639c 100644
--- a/sw/source/ui/dbui/mmdocselectpage.cxx
+++ b/sw/source/ui/dbui/mmdocselectpage.cxx
@@ -70,10 +70,10 @@ 
SwMailMergeDocSelectPage::SwMailMergeDocSelectPage(SwMailMergeWizard* pWizard, T
 
     const uno::Sequence< OUString >& rDocs =
                             m_pWizard->GetConfigItem().GetSavedDocuments();
-    for(sal_Int32 nDoc = 0; nDoc < rDocs.getLength(); ++nDoc)
+    for(const auto& rDoc : rDocs)
     {
         //insert in reverse order
-        m_xRecentDocLB->insert_text(0, rDocs[nDoc]);
+        m_xRecentDocLB->insert_text(0, rDoc);
     }
     m_xRecentDocLB->set_active(0);
     if(!rDocs.hasElements())
diff --git a/sw/source/ui/dbui/mmgreetingspage.cxx 
b/sw/source/ui/dbui/mmgreetingspage.cxx
index 2280df3b3711..ae105778768b 100644
--- a/sw/source/ui/dbui/mmgreetingspage.cxx
+++ b/sw/source/ui/dbui/mmgreetingspage.cxx
@@ -39,8 +39,8 @@ static void lcl_FillGreetingsBox(weld::ComboBox& rBox,
                         SwMailMergeConfigItem::Gender eType)
 {
     const Sequence< OUString> rEntries = rConfig.GetGreetings(eType);
-    for(sal_Int32 nEntry = 0; nEntry < rEntries.getLength(); ++nEntry)
-        rBox.append_text(rEntries[nEntry]);
+    for(const auto& rEntry : rEntries)
+        rBox.append_text(rEntry);
     rBox.set_active(rConfig.GetCurrentGreeting(eType));
 }
 
@@ -266,8 +266,8 @@ void SwMailMergeGreetingsPage::ActivatePage()
     {
         Reference < container::XNameAccess> xColAccess = 
xColsSupp->getColumns();
         Sequence< OUString > aColumns = xColAccess->getElementNames();
-        for(sal_Int32 nName = 0; nName < aColumns.getLength(); ++nName)
-            m_xFemaleColumnLB->append_text(aColumns[nName]);
+        for(const auto& rColumn : aColumns)
+            m_xFemaleColumnLB->append_text(rColumn);
     }
 
     
m_xFemaleColumnLB->set_active_text(m_rConfigItem.GetAssignedColumn(MM_PART_GENDER));
@@ -378,8 +378,8 @@ SwMailBodyDialog::SwMailBodyDialog(weld::Window* pParent)
     {
         Reference < container::XNameAccess> xColAccess = 
xColsSupp->getColumns();
         Sequence< OUString > aColumns = xColAccess->getElementNames();
-        for(sal_Int32 nName = 0; nName < aColumns.getLength(); ++nName)
-            m_xFemaleColumnLB->append_text(aColumns[nName]);
+        for(const auto& rColumn : aColumns)
+            m_xFemaleColumnLB->append_text(rColumn);
     }
 
     
m_xFemaleColumnLB->set_active_text(m_rConfigItem.GetAssignedColumn(MM_PART_GENDER));
diff --git a/sw/source/ui/dbui/mmlayoutpage.cxx 
b/sw/source/ui/dbui/mmlayoutpage.cxx
index 88070a1da2b1..e2738aaf413a 100644
--- a/sw/source/ui/dbui/mmlayoutpage.cxx
+++ b/sw/source/ui/dbui/mmlayoutpage.cxx
@@ -334,10 +334,9 @@ SwFrameFormat* SwMailMergeLayoutPage::InsertAddressFrame(
             if(aItem.bIsColumn)
             {
                 OUString sConvertedColumn = aItem.sText;
-                for(sal_uInt32 nColumn = 0;
-                        nColumn < rHeaders.size() &&
-                        nColumn < 
static_cast<sal_uInt32>(aAssignment.getLength());
-                                                                               
     ++nColumn)
+                auto nSize = std::min(static_cast<sal_uInt32>(rHeaders.size()),
+                                      
static_cast<sal_uInt32>(aAssignment.getLength()));
+                for(sal_uInt32 nColumn = 0; nColumn < nSize; ++nColumn)
                 {
                     if (rHeaders[nColumn].first == aItem.sText &&
                         !pAssignment[nColumn].isEmpty())
@@ -554,10 +553,9 @@ void SwMailMergeLayoutPage::InsertGreeting(SwWrtShell& 
rShell, SwMailMergeConfig
                         if(aItem.bIsColumn)
                         {
                             OUString sConvertedColumn = aItem.sText;
-                            for(sal_uInt32 nColumn = 0;
-                                    nColumn < rHeaders.size() &&
-                                    nColumn < 
static_cast<sal_uInt32>(aAssignment.getLength());
-                                                                               
                 ++nColumn)
+                            auto nSize = 
std::min(static_cast<sal_uInt32>(rHeaders.size()),
+                                                  
static_cast<sal_uInt32>(aAssignment.getLength()));
+                            for(sal_uInt32 nColumn = 0; nColumn < nSize; 
++nColumn)
                             {
                                 if (rHeaders[nColumn].first == aItem.sText &&
                                     !pAssignment[nColumn].isEmpty())
diff --git a/sw/source/ui/dbui/mmoutputtypepage.cxx 
b/sw/source/ui/dbui/mmoutputtypepage.cxx
index 5e94ce1826a8..8422c2aa0a50 100644
--- a/sw/source/ui/dbui/mmoutputtypepage.cxx
+++ b/sw/source/ui/dbui/mmoutputtypepage.cxx
@@ -187,11 +187,11 @@ void SwMailDispatcherListener_Impl::DeleteAttachments( 
uno::Reference< mail::XMa
 {
     uno::Sequence< mail::MailAttachment > aAttachments = 
xMessage->getAttachments();
 
-    for(sal_Int32 nFile = 0; nFile < aAttachments.getLength(); ++nFile)
+    for(const auto& rAttachment : aAttachments)
     {
         try
         {
-            uno::Reference< beans::XPropertySet > xTransferableProperties( 
aAttachments[nFile].Data, uno::UNO_QUERY_THROW);
+            uno::Reference< beans::XPropertySet > xTransferableProperties( 
rAttachment.Data, uno::UNO_QUERY_THROW);
             OUString sURL;
             xTransferableProperties->getPropertyValue("URL") >>= sURL;
             if(!sURL.isEmpty())
diff --git a/sw/source/ui/dbui/mmresultdialogs.cxx 
b/sw/source/ui/dbui/mmresultdialogs.cxx
index 230d26c98cb7..21c9588d71d8 100644
--- a/sw/source/ui/dbui/mmresultdialogs.cxx
+++ b/sw/source/ui/dbui/mmresultdialogs.cxx
@@ -387,9 +387,8 @@ void SwMMResultEmailDialog::FillInEmailSettings()
     uno::Sequence< OUString > aFields;
     if (xColAccess.is())
         aFields = xColAccess->getElementNames();
-    const OUString* pFields = aFields.getConstArray();
-    for (sal_Int32 nField = 0; nField < aFields.getLength(); ++nField)
-        m_xMailToLB->append_text(pFields[nField]);
+    for (const OUString& rField : aFields)
+        m_xMailToLB->append_text(rField);
 
     m_xMailToLB->set_active(0);
     // then select the right one - may not be available
diff --git a/sw/source/ui/dbui/selectdbtabledialog.cxx 
b/sw/source/ui/dbui/selectdbtabledialog.cxx
index 542df4f46dd7..04c05b858071 100644
--- a/sw/source/ui/dbui/selectdbtabledialog.cxx
+++ b/sw/source/ui/dbui/selectdbtabledialog.cxx
@@ -76,12 +76,10 @@ SwSelectDBTableDialog::SwSelectDBTableDialog(weld::Window* 
pParent,
     {
         Reference<XNameAccess> xQueries = xQSupplier->getQueries();
         Sequence<OUString> aQueries = xQueries->getElementNames();
-        const OUString* pQueries = aQueries.getConstArray();
         int nPos = m_xTable->n_children();
-        for (sal_Int32 i = 0; i < aQueries.getLength(); i++)
+        for (const OUString& rQuery : aQueries)
         {
-            OUString sEntry = pQueries[i];
-            m_xTable->append_text(sEntry);
+            m_xTable->append_text(rQuery);
             m_xTable->set_text(nPos, SwResId(ST_QUERY), 1);
             m_xTable->set_id(nPos, OUString::number(1));
             ++nPos;
diff --git a/sw/source/ui/envelp/envlop1.cxx b/sw/source/ui/envelp/envlop1.cxx
index cd9923701bad..438498ab749f 100644
--- a/sw/source/ui/envelp/envlop1.cxx
+++ b/sw/source/ui/envelp/envlop1.cxx
@@ -280,10 +280,9 @@ void SwEnvPage::InitDatabaseBox()
     {
         m_xDatabaseLB->clear();
         Sequence<OUString> aDataNames = 
SwDBManager::GetExistingDatabaseNames();
-        const OUString* pDataNames = aDataNames.getConstArray();
 
-        for (sal_Int32 i = 0; i < aDataNames.getLength(); ++i)
-            m_xDatabaseLB->append_text(pDataNames[i]);
+        for (const OUString& rDataName : aDataNames)
+            m_xDatabaseLB->append_text(rDataName);
 
         sal_Int32 nIdx{ 0 };
         OUString sDBName = m_sActDBName.getToken( 0, DB_DELIM, nIdx );
diff --git a/sw/source/ui/envelp/label1.cxx b/sw/source/ui/envelp/label1.cxx
index 54b447ef0d0c..56bdc3b33e56 100644
--- a/sw/source/ui/envelp/label1.cxx
+++ b/sw/source/ui/envelp/label1.cxx
@@ -428,9 +428,8 @@ void SwLabPage::InitDatabaseBox()
     {
         m_xDatabaseLB->clear();
         css::uno::Sequence<OUString> aDataNames = 
SwDBManager::GetExistingDatabaseNames();
-        const OUString* pDataNames = aDataNames.getConstArray();
-        for (long i = 0; i < aDataNames.getLength(); i++)
-            m_xDatabaseLB->append_text(pDataNames[i]);
+        for (const OUString& rDataName : aDataNames)
+            m_xDatabaseLB->append_text(rDataName);
         sal_Int32 nIdx{ 0 };
         OUString sDBName = sActDBName.getToken( 0, DB_DELIM, nIdx );
         OUString sTableName = sActDBName.getToken( 0, DB_DELIM, nIdx );
diff --git a/sw/source/ui/envelp/mailmrge.cxx b/sw/source/ui/envelp/mailmrge.cxx
index 6c3f91d59f4f..1ab1348eb65d 100644
--- a/sw/source/ui/envelp/mailmrge.cxx
+++ b/sw/source/ui/envelp/mailmrge.cxx
@@ -338,13 +338,10 @@ SwMailMergeDlg::SwMailMergeDlg(vcl::Window* pParent, 
SwWrtShell& rShell,
             uno::Sequence< beans::PropertyValue > aFilterProperties;
             aProps >>= aFilterProperties;
             OUString sUIName2;
-            const beans::PropertyValue* pFilterProperties = 
aFilterProperties.getConstArray();
-            for(sal_Int32 nProp = 0; nProp < aFilterProperties.getLength(); 
++nProp) {
-                if(pFilterProperties[nProp].Name == "UIName") {
-                    pFilterProperties[nProp].Value >>= sUIName2;
-                    break;
-                }
-            }
+            auto pProp = std::find_if(aFilterProperties.begin(), 
aFilterProperties.end(),
+                [](const beans::PropertyValue& rProp) { return rProp.Name == 
"UIName"; });
+            if (pProp != aFilterProperties.end())
+                pProp->Value >>= sUIName2;
             if( !sUIName2.isEmpty() ) {
                 const sal_Int32 nFilter = m_pFilterLB->InsertEntry( sUIName2 );
                 if( sFilter == "writer8" )
@@ -544,11 +541,9 @@ bool SwMailMergeDlg::ExecQryShell()
             uno::Reference< XResultSet > xRes(xRowLocate,UNO_QUERY);
             pImpl->xSelSupp->getSelection() >>= m_aSelection;
             if ( xRowLocate.is() ) {
-                Any* pBegin = m_aSelection.getArray();
-                Any* pEnd   = pBegin + m_aSelection.getLength();
-                for (; pBegin != pEnd ; ++pBegin) {
-                    if ( xRowLocate->moveToBookmark(*pBegin) )
-                        *pBegin <<= xRes->getRow();
+                for (Any& rRow : m_aSelection) {
+                    if ( xRowLocate->moveToBookmark(rRow) )
+                        rRow <<= xRes->getRow();
                 }
             }
         }
diff --git a/sw/source/ui/fldui/DropDownFieldDialog.cxx 
b/sw/source/ui/fldui/DropDownFieldDialog.cxx
index 46d6f9d9b041..ec050f5161d0 100644
--- a/sw/source/ui/fldui/DropDownFieldDialog.cxx
+++ b/sw/source/ui/fldui/DropDownFieldDialog.cxx
@@ -67,9 +67,8 @@ sw::DropDownFieldDialog::DropDownFieldDialog(weld::Widget 
*pParent, SwWrtShell &
         sTitle += m_pDropField->GetPar2();
         m_xDialog->set_title(sTitle);
         uno::Sequence< OUString > aItems = m_pDropField->GetItemSequence();
-        const OUString* pArray = aItems.getConstArray();
-        for (sal_Int32 i = 0; i < aItems.getLength(); ++i)
-            m_xListItemsLB->append_text(pArray[i]);
+        for (const OUString& rItem : aItems)
+            m_xListItemsLB->append_text(rItem);
         m_xListItemsLB->select_text(m_pDropField->GetSelectedItem());
     }
 
diff --git a/sw/source/ui/fldui/changedb.cxx b/sw/source/ui/fldui/changedb.cxx
index b04d69a6baef..0118adb136b0 100644
--- a/sw/source/ui/fldui/changedb.cxx
+++ b/sw/source/ui/fldui/changedb.cxx
@@ -23,6 +23,7 @@
 #include <com/sun/star/sdb/CommandType.hpp>
 #include <com/sun/star/sdb/XDatabaseAccess.hpp>
 #include <comphelper/processfactory.hxx>
+#include <comphelper/sequence.hxx>
 #include <sfx2/viewfrm.hxx>
 
 #include <view.hxx>
@@ -89,16 +90,8 @@ void SwChangeDBDlg::FillDBPopup()
     m_xAvailDBTLB->Select(rDBData.sDataSource, rDBData.sCommand, OUString());
     TreeSelect();
 
-    std::vector<OUString> aAllDBNames;
-
     Sequence< OUString > aDBNames = xDBContext->getElementNames();
-    const OUString* pDBNames = aDBNames.getConstArray();
-    sal_Int32 nDBCount = aDBNames.getLength();
-    aAllDBNames.reserve(nDBCount);
-    for (sal_Int32 i = 0; i < nDBCount; i++)
-    {
-        aAllDBNames.push_back(pDBNames[i]);
-    }
+    auto aAllDBNames = 
comphelper::sequenceToContainer<std::vector<OUString>>(aDBNames);
 
     std::vector<OUString> aDBNameList;
     pSh->GetAllUsedDB( aDBNameList, &aAllDBNames );
diff --git a/sw/source/ui/fldui/flddinf.cxx b/sw/source/ui/fldui/flddinf.cxx
index 0603774eb127..8780fa60c9e9 100644
--- a/sw/source/ui/fldui/flddinf.cxx
+++ b/sw/source/ui/fldui/flddinf.cxx
@@ -147,9 +147,9 @@ void SwFieldDokInfPage::Reset(const SfxItemSet* )
                         OUString sEntryId(OUString::number(USHRT_MAX));
                         m_xTypeTLB->insert(nullptr, -1, &sText, &sEntryId, 
nullptr,
                                            nullptr, nullptr, false, 
xInfo.get());
-                        for (sal_Int32 n=0; n < rProperties.getLength(); n++)
+                        for (const auto& rProperty : rProperties)
                         {
-                            const OUString sEntry = rProperties[n].Name;
+                            const OUString sEntry = rProperty.Name;
 
                             m_xTypeTLB->insert(xInfo.get(), -1, &sEntry, &sId,
                                                nullptr, nullptr, nullptr, 
false, xEntry.get());
diff --git a/sw/source/ui/fldui/fldfunc.cxx b/sw/source/ui/fldui/fldfunc.cxx
index 7db5912ef02d..400a32238a80 100644
--- a/sw/source/ui/fldui/fldfunc.cxx
+++ b/sw/source/ui/fldui/fldfunc.cxx
@@ -258,10 +258,9 @@ IMPL_LINK_NOARG(SwFieldFuncPage, TypeHdl, weld::TreeView&, 
void)
         {
             const SwDropDownField* pDrop = static_cast<const 
SwDropDownField*>(GetCurField());
             uno::Sequence<OUString> aItems = pDrop->GetItemSequence();
-            const OUString* pArray = aItems.getConstArray();
             m_xListItemsLB->clear();
-            for (sal_Int32 i = 0; i < aItems.getLength(); i++)
-                m_xListItemsLB->append_text(pArray[i]);
+            for (const OUString& rItem : aItems)
+                m_xListItemsLB->append_text(rItem);
             m_xListItemsLB->select_text(pDrop->GetSelectedItem());
             m_xListNameED->set_text(pDrop->GetPar2());
             m_xListNameED->save_value();
diff --git a/sw/source/ui/index/swuiidxmrk.cxx 
b/sw/source/ui/index/swuiidxmrk.cxx
index 9b7ac9c6df29..b4b37b2d5935 100644
--- a/sw/source/ui/index/swuiidxmrk.cxx
+++ b/sw/source/ui/index/swuiidxmrk.cxx
@@ -1068,13 +1068,13 @@ static const TextInfo aTextInfoArr[] =
     {AUTH_FIELD_CUSTOM5,         HID_AUTH_FIELD_CUSTOM5         }
 };
 
-static OUString lcl_FindColumnEntry(const beans::PropertyValue* pFields, 
sal_Int32 nLen, const OUString& rColumnTitle)
+static OUString lcl_FindColumnEntry(const uno::Sequence<beans::PropertyValue>& 
rFields, const OUString& rColumnTitle)
 {
-    for(sal_Int32 i = 0; i < nLen; i++)
+    for(const auto& rField : rFields)
     {
         OUString sRet;
-        if(pFields[i].Name == rColumnTitle &&
-            (pFields[i].Value >>= sRet))
+        if(rField.Name == rColumnTitle &&
+            (rField.Value >>= sRet))
         {
             return sRet;
         }
@@ -1157,11 +1157,10 @@ IMPL_LINK( SwAuthorMarkPane, CompEntryHdl, 
weld::ComboBox&, rBox, void)
                 uno::Sequence<beans::PropertyValue> aFieldProps;
                 if(aEntry >>= aFieldProps)
                 {
-                    const beans::PropertyValue* pProps = 
aFieldProps.getConstArray();
-                    for(sal_Int32 i = 0; i < AUTH_FIELD_END && i < 
aFieldProps.getLength(); i++)
+                    auto nSize = 
std::min(static_cast<sal_Int32>(AUTH_FIELD_END), aFieldProps.getLength());
+                    for(sal_Int32 i = 0; i < nSize; i++)
                     {
-                        m_sFields[i] = lcl_FindColumnEntry(
-                                pProps, aFieldProps.getLength(), 
m_sColumnTitles[i]);
+                        m_sFields[i] = lcl_FindColumnEntry(aFieldProps, 
m_sColumnTitles[i]);
                     }
                 }
             }
@@ -1306,14 +1305,12 @@ IMPL_LINK_NOARG(SwAuthorMarkPane, ChangeSourceHdl, 
weld::ToggleButton&, void)
                 uno::Sequence<beans::PropertyValue> aSeq;
                 if( aNames >>= aSeq)
                 {
-                    const beans::PropertyValue* pArr = aSeq.getConstArray();
-                    for(sal_Int32 i = 0; i < aSeq.getLength(); i++)
+                    for(const beans::PropertyValue& rProp : aSeq)
                     {
-                        OUString sTitle = pArr[i].Name;
                         sal_Int16 nField = 0;
-                        pArr[i].Value >>= nField;
+                        rProp.Value >>= nField;
                         if(nField >= 0 && nField < AUTH_FIELD_END)
-                            m_sColumnTitles[nField] = sTitle;
+                            m_sColumnTitles[nField] = rProp.Name;
                     }
                 }
             }
@@ -1322,9 +1319,8 @@ IMPL_LINK_NOARG(SwAuthorMarkPane, ChangeSourceHdl, 
weld::ToggleButton&, void)
         if(xBibAccess.is())
         {
             uno::Sequence<OUString> aIdentifiers = 
xBibAccess->getElementNames();
-            const OUString* pNames = aIdentifiers.getConstArray();
-            for(sal_Int32 i = 0; i < aIdentifiers.getLength(); i++)
-                m_xEntryLB->append_text(pNames[i]);
+            for(const OUString& rName : aIdentifiers)
+                m_xEntryLB->append_text(rName);
         }
     }
     else
diff --git a/sw/source/ui/vba/vbaaddins.cxx b/sw/source/ui/vba/vbaaddins.cxx
index 1451e5b77396..8f165461b86e 100644
--- a/sw/source/ui/vba/vbaaddins.cxx
+++ b/sw/source/ui/vba/vbaaddins.cxx
@@ -40,10 +40,8 @@ static uno::Reference< container::XIndexAccess > 
lcl_getAddinCollection( const u
     if( xSFA->isFolder( aAddinPath ) )
     {
         uno::Sequence< OUString > sEntries = xSFA->getFolderContents( 
aAddinPath, false );
-        sal_Int32 nEntry = sEntries.getLength();
-        for( sal_Int32 index = 0; index < nEntry; ++index )
+        for( const OUString& sUrl : sEntries )
         {
-            OUString sUrl = sEntries[ index ];
             if( !xSFA->isFolder( sUrl ) && sUrl.endsWithIgnoreAsciiCase( 
".dot" ) )
             {
                 aAddins.push_back( uno::Reference< word::XAddin >( new 
SwVbaAddin( xParent, xContext, sUrl ) ) );
diff --git a/sw/source/ui/vba/vbadocumentproperties.cxx 
b/sw/source/ui/vba/vbadocumentproperties.cxx
index cf8d1f3017a0..a06d6156932a 100644
--- a/sw/source/ui/vba/vbadocumentproperties.cxx
+++ b/sw/source/ui/vba/vbadocumentproperties.cxx
@@ -322,18 +322,12 @@ public:
             uno::Sequence< beans::NamedValue > const stats(
                 m_xDocProps->getDocumentStatistics());
 
-            sal_Int32 nLen = stats.getLength();
-            bool bFound = false;
-            for ( sal_Int32 index = 0; index < nLen && !bFound ; ++index )
-            {
-                if ( rPropName == stats[ index ].Name )
-                {
-                    aReturn = stats[ index ].Value;
-                    bFound = true;
-                }
-            }
-            if ( !bFound )
+            auto pStat = std::find_if(stats.begin(), stats.end(),
+                [&rPropName](const beans::NamedValue& rStat) { return 
rPropName == rStat.Name; });
+            if (pStat == stats.end())
                 throw uno::RuntimeException(); // bad Property
+
+            aReturn = pStat->Value;
         }
         return aReturn;
     }
@@ -343,15 +337,12 @@ public:
         uno::Sequence< beans::NamedValue > stats(
                 m_xDocProps->getDocumentStatistics());
 
-        sal_Int32 nLen = stats.getLength();
-        for ( sal_Int32 index = 0; index < nLen; ++index )
+        auto pStat = std::find_if(stats.begin(), stats.end(),
+            [&rPropName](const beans::NamedValue& rStat) { return rPropName == 
rStat.Name; });
+        if (pStat != stats.end())
         {
-            if ( rPropName == stats[ index ].Name )
-            {
-                stats[ index ].Value = aValue;
-                m_xDocProps->setDocumentStatistics(stats);
-                break;
-            }
+            pStat->Value = aValue;
+            m_xDocProps->setDocumentStatistics(stats);
         }
     }
 };
@@ -828,11 +819,8 @@ public:
     {
         uno::Sequence< beans::Property > aProps = 
mxUserDefinedProp->getPropertySetInfo()->getProperties();
         uno::Sequence< OUString > aNames( aProps.getLength() );
-        OUString* pString = aNames.getArray();
-        OUString* pEnd = pString + aNames.getLength();
-        beans::Property* pProp = aProps.getArray();
-        for ( ; pString != pEnd; ++pString, ++pProp )
-            *pString = pProp->Name;
+        std::transform(aProps.begin(), aProps.end(), aNames.begin(),
+            [](const beans::Property& rProp) -> OUString { return rProp.Name; 
});
         return aNames;
     }
 
diff --git a/sw/source/ui/vba/vbafilterpropsfromformat.hxx 
b/sw/source/ui/vba/vbafilterpropsfromformat.hxx
index e51cdc3cc30e..01fd93be5555 100644
--- a/sw/source/ui/vba/vbafilterpropsfromformat.hxx
+++ b/sw/source/ui/vba/vbafilterpropsfromformat.hxx
@@ -31,45 +31,44 @@ namespace
 inline bool setFilterPropsFromFormat(sal_Int32 nFormat,
                                      
css::uno::Sequence<css::beans::PropertyValue>& rProps)
 {
-    bool bRes = false;
-    for (sal_Int32 index = 0; index < rProps.getLength(); ++index)
+    auto pProp
+        = std::find_if(rProps.begin(), rProps.end(), [](const 
css::beans::PropertyValue& rProp) {
+              return rProp.Name == "FilterName";
+          });
+    if (pProp != rProps.end())
     {
-        if (rProps[index].Name == "FilterName")
+        switch (nFormat)
         {
-            switch (nFormat)
-            {
-                case ooo::vba::word::WdSaveFormat::wdFormatDocument:
-                    rProps[index].Value <<= OUString("MS Word 97");
-                    break;
-                // Just save all the text formats as "Text"
-                case ooo::vba::word::WdSaveFormat::wdFormatDOSText:
-                case ooo::vba::word::WdSaveFormat::wdFormatDOSTextLineBreaks:
-                case ooo::vba::word::WdSaveFormat::wdFormatEncodedText:
-                case ooo::vba::word::WdSaveFormat::wdFormatText:
-                case ooo::vba::word::WdSaveFormat::wdFormatTextLineBreaks:
-                    rProps[index].Value <<= OUString("Text");
-                    break;
-                case ooo::vba::word::WdSaveFormat::wdFormatFilteredHTML:
-                case ooo::vba::word::WdSaveFormat::wdFormatHTML:
-                    rProps[index].Value <<= OUString("HTML");
-                    break;
-                case ooo::vba::word::WdSaveFormat::wdFormatRTF:
-                    rProps[index].Value <<= OUString("Rich Text Format");
-                    break;
-                case ooo::vba::word::WdSaveFormat::wdFormatTemplate:
-                    rProps[index].Value <<= OUString("MS Word 97 Vorlage");
-                    break;
+            case ooo::vba::word::WdSaveFormat::wdFormatDocument:
+                pProp->Value <<= OUString("MS Word 97");
+                break;
+            // Just save all the text formats as "Text"
+            case ooo::vba::word::WdSaveFormat::wdFormatDOSText:
+            case ooo::vba::word::WdSaveFormat::wdFormatDOSTextLineBreaks:
+            case ooo::vba::word::WdSaveFormat::wdFormatEncodedText:
+            case ooo::vba::word::WdSaveFormat::wdFormatText:
+            case ooo::vba::word::WdSaveFormat::wdFormatTextLineBreaks:
+                pProp->Value <<= OUString("Text");
+                break;
+            case ooo::vba::word::WdSaveFormat::wdFormatFilteredHTML:
+            case ooo::vba::word::WdSaveFormat::wdFormatHTML:
+                pProp->Value <<= OUString("HTML");
+                break;
+            case ooo::vba::word::WdSaveFormat::wdFormatRTF:
+                pProp->Value <<= OUString("Rich Text Format");
+                break;
+            case ooo::vba::word::WdSaveFormat::wdFormatTemplate:
+                pProp->Value <<= OUString("MS Word 97 Vorlage");
+                break;
 
-                // Default to "MS Word 97"
-                default:
-                    rProps[index].Value <<= OUString("MS Word 97");
-                    break;
-            }
-            bRes = true;
-            break;
+            // Default to "MS Word 97"
+            default:
+                pProp->Value <<= OUString("MS Word 97");
+                break;
         }
+        return true;
     }
-    return bRes;
+    return false;
 }
 }
 
diff --git a/sw/source/ui/vba/vbastyles.cxx b/sw/source/ui/vba/vbastyles.cxx
index e247f0128116..eac88129162d 100644
--- a/sw/source/ui/vba/vbastyles.cxx
+++ b/sw/source/ui/vba/vbastyles.cxx
@@ -213,14 +213,12 @@ public:
         else
         {
             uno::Sequence< OUString > sElementNames = 
mxParaStyles->getElementNames();
-            for( sal_Int32 j = 0; j < sElementNames.getLength(); j++ )
+            auto pStyleName = std::find_if(sElementNames.begin(), 
sElementNames.end(),
+                [&aName](const OUString& rStyleName) { return 
rStyleName.equalsIgnoreAsciiCase( aName ); });
+            if (pStyleName != sElementNames.end())
             {
-                OUString aStyleName = sElementNames[j];
-                if( aStyleName.equalsIgnoreAsciiCase( aName ) )
-                {
-                    cachePos = mxParaStyles->getByName( aStyleName );
-                    return true;
-                }
+                cachePos = mxParaStyles->getByName( *pStyleName );
+                return true;
             }
         }
         return false;
diff --git a/sw/source/ui/vba/vbatabstops.cxx b/sw/source/ui/vba/vbatabstops.cxx
index 2f18e784dcb8..f1d19dd7c838 100644
--- a/sw/source/ui/vba/vbatabstops.cxx
+++ b/sw/source/ui/vba/vbatabstops.cxx
@@ -199,28 +199,24 @@ uno::Reference< word::XTabStop > SAL_CALL 
SwVbaTabStops::Add( float Position, co
     aTab.FillChar = cLeader;
 
     uno::Sequence< style::TabStop > aOldTabs = lcl_getTabStops( mxParaProps );
-    bool bOverWriter = false;
 
-    sal_Int32 nTabs = aOldTabs.getLength();
-    uno::Sequence< style::TabStop > aNewTabs( nTabs + 1 );
-
-    style::TabStop* pOldTab = aOldTabs.getArray();
-    style::TabStop* pNewTab = aNewTabs.getArray();
-    pNewTab[0] = aTab;
-    for (sal_Int32 nIndex = 0; nIndex < nTabs; nIndex++)
-    {
-        if( pOldTab[nIndex].Position == nPosition )
-        {
-            bOverWriter = true;
-            pOldTab[nIndex] = aTab;
-            break;
-        }
-        pNewTab[ nIndex+1 ] = pOldTab[ nIndex ];
-    }
+    style::TabStop* pOldTab = std::find_if(aOldTabs.begin(), aOldTabs.end(),
+        [nPosition](const style::TabStop& rTab) { return rTab.Position == 
nPosition; });
+    bool bOverWriter = pOldTab != aOldTabs.end();
     if( bOverWriter )
+    {
+        *pOldTab = aTab;
         lcl_setTabStops( mxParaProps, aOldTabs );
+    }
     else
+    {
+        sal_Int32 nTabs = aOldTabs.getLength();
+        uno::Sequence< style::TabStop > aNewTabs( nTabs + 1 );
+
+        aNewTabs[0] = aTab;
+        std::copy(aOldTabs.begin(), aOldTabs.end(), 
std::next(aNewTabs.begin()));
         lcl_setTabStops( mxParaProps, aNewTabs );
+    }
 
     return uno::Reference< word::XTabStop >( new SwVbaTabStop( this, mxContext 
) );
 }
diff --git a/sw/source/ui/vba/vbavariable.cxx b/sw/source/ui/vba/vbavariable.cxx
index e28e959790d9..2e663f6582b0 100644
--- a/sw/source/ui/vba/vbavariable.cxx
+++ b/sw/source/ui/vba/vbavariable.cxx
@@ -66,11 +66,10 @@ sal_Int32 SAL_CALL
 SwVbaVariable::getIndex()
 {
     const uno::Sequence< beans::PropertyValue > props = 
mxUserDefined->getPropertyValues();
-    for (sal_Int32 i = 0; i < props.getLength(); ++i)
-    {
-        if( maVariableName == props[i].Name )
-            return i+1;
-    }
+    auto pProp = std::find_if(props.begin(), props.end(),
+        [this](const beans::PropertyValue& rProp) { return rProp.Name == 
maVariableName; });
+    if (pProp != props.end())
+        return static_cast<sal_Int32>(std::distance(props.begin(), pProp)) + 1;
 
     return 0;
 }
diff --git a/sw/source/ui/vba/vbavariables.cxx 
b/sw/source/ui/vba/vbavariables.cxx
index 919b5d07c268..8663c00719b5 100644
--- a/sw/source/ui/vba/vbavariables.cxx
+++ b/sw/source/ui/vba/vbavariables.cxx
@@ -32,8 +32,9 @@ static uno::Reference< container::XIndexAccess > 
createVariablesAccess( const un
     const uno::Sequence< beans::PropertyValue > props = 
xUserDefined->getPropertyValues();
     sal_Int32 nCount = props.getLength();
     aVariables.reserve( nCount );
-    for( sal_Int32 i=0; i < nCount; i++ )
-        aVariables.push_back( uno::Reference< word::XVariable > ( new 
SwVbaVariable( xParent, xContext, xUserDefined, props[i].Name ) ) );
+    std::transform(props.begin(), props.end(), std::back_inserter(aVariables),
+        [&xParent, &xContext, &xUserDefined](const beans::PropertyValue& 
rProp) -> uno::Reference< word::XVariable > {
+            return uno::Reference< word::XVariable > ( new SwVbaVariable( 
xParent, xContext, xUserDefined, rProp.Name ) ); });
 
     uno::Reference< container::XIndexAccess > xVariables( new 
XNamedObjectCollectionHelper< word::XVariable >( aVariables ) );
     return xVariables;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to