sw/source/uibase/app/docsh.cxx                 |    5 -
 sw/source/uibase/app/docshini.cxx              |   14 +--
 sw/source/uibase/dbui/dbmgr.cxx                |   93 ++++++++++-------------
 sw/source/uibase/dbui/dbtree.cxx               |   32 ++------
 sw/source/uibase/dbui/mailmergehelper.cxx      |    5 -
 sw/source/uibase/dbui/mmconfigitem.cxx         |   99 ++++++++++---------------
 sw/source/uibase/docvw/edtwin.cxx              |    4 -
 sw/source/uibase/envelp/labelcfg.cxx           |   43 +++-------
 sw/source/uibase/fldui/fldmgr.cxx              |   29 ++-----
 sw/source/uibase/lingu/olmenu.cxx              |   41 ++++------
 sw/source/uibase/misc/numberingtypelistbox.cxx |   29 +------
 sw/source/uibase/shells/textsh1.cxx            |    4 -
 sw/source/uibase/uiview/view.cxx               |   58 +++++++-------
 sw/source/uibase/uno/SwXFilterOptions.cxx      |    5 -
 sw/source/uibase/uno/unodispatch.cxx           |   10 --
 sw/source/uibase/uno/unomailmerge.cxx          |   21 ++---
 sw/source/uibase/uno/unomodule.cxx             |    9 --
 sw/source/uibase/uno/unotxdoc.cxx              |   82 ++++++--------------
 sw/source/uibase/uno/unotxvw.cxx               |   34 ++++----
 19 files changed, 234 insertions(+), 383 deletions(-)

New commits:
commit 671517c462c51b356a35a2d51aa27e90bd3f9531
Author:     Arkadiy Illarionov <qar...@gmail.com>
AuthorDate: Tue Jul 2 17:18:03 2019 +0300
Commit:     Arkadiy Illarionov <qar...@gmail.com>
CommitDate: Wed Jul 3 21:00:07 2019 +0200

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

diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx
index 96c7634ea5c3..229decaf2a9c 100644
--- a/sw/source/uibase/app/docsh.cxx
+++ b/sw/source/uibase/app/docsh.cxx
@@ -652,10 +652,9 @@ bool SwDocShell::ConvertTo( SfxMedium& rMedium )
             uno::Reference< XLibraryContainer > xLibCont(GetBasicContainer(), 
UNO_QUERY);
             uno::Reference< XNameAccess > xLib;
             Sequence<OUString> aNames = xLibCont->getElementNames();
-            const OUString* pNames = aNames.getConstArray();
-            for(sal_Int32 nLib = 0; nLib < aNames.getLength(); nLib++)
+            for(const OUString& rName : aNames)
             {
-                Any aLib = xLibCont->getByName(pNames[nLib]);
+                Any aLib = xLibCont->getByName(rName);
                 aLib >>= xLib;
                 if(xLib.is())
                 {
diff --git a/sw/source/uibase/app/docshini.cxx 
b/sw/source/uibase/app/docshini.cxx
index 537be6405bfd..5bbc20421fbc 100644
--- a/sw/source/uibase/app/docshini.cxx
+++ b/sw/source/uibase/app/docshini.cxx
@@ -127,16 +127,12 @@ bool SwDocShell::InitNew( const uno::Reference < 
embed::XStorage >& xStor )
         {
             SvxAsianConfig aAsian;
             Sequence<lang::Locale> aLocales =  aAsian.GetStartEndCharLocales();
-            if (aLocales.hasElements())
+            for(const lang::Locale& rLocale : aLocales)
             {
-                const lang::Locale* pLocales = aLocales.getConstArray();
-                for(sal_Int32 i = 0; i < aLocales.getLength(); i++)
-                {
-                    ForbiddenCharacters aForbidden;
-                    aAsian.GetStartEndChars( pLocales[i], 
aForbidden.beginLine, aForbidden.endLine);
-                    LanguageType  eLang = 
LanguageTag::convertToLanguageType(pLocales[i]);
-                    
m_xDoc->getIDocumentSettingAccess().setForbiddenCharacters( eLang, aForbidden);
-                }
+                ForbiddenCharacters aForbidden;
+                aAsian.GetStartEndChars( rLocale, aForbidden.beginLine, 
aForbidden.endLine);
+                LanguageType  eLang = 
LanguageTag::convertToLanguageType(rLocale);
+                m_xDoc->getIDocumentSettingAccess().setForbiddenCharacters( 
eLang, aForbidden);
             }
             
m_xDoc->getIDocumentSettingAccess().set(DocumentSettingId::KERN_ASIAN_PUNCTUATION,
                   !aAsian.IsKerningWesternTextOnly());
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index 3b1adf7ea7ba..48ce4dc80a5a 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -730,18 +730,16 @@ bool SwDBManager::GetTableNames(weld::ComboBox& rBox, 
const OUString& rDBName)
         {
             uno::Reference<container::XNameAccess> xTables = 
xTSupplier->getTables();
             uno::Sequence<OUString> aTables = xTables->getElementNames();
-            const OUString* pTables = aTables.getConstArray();
-            for (sal_Int32 i = 0; i < aTables.getLength(); ++i)
-                rBox.append("0", pTables[i]);
+            for (const OUString& rTable : aTables)
+                rBox.append("0", rTable);
         }
         uno::Reference<sdb::XQueriesSupplier> xQSupplier(xConnection, 
uno::UNO_QUERY);
         if(xQSupplier.is())
         {
             uno::Reference<container::XNameAccess> xQueries = 
xQSupplier->getQueries();
             uno::Sequence<OUString> aQueries = xQueries->getElementNames();
-            const OUString* pQueries = aQueries.getConstArray();
-            for (sal_Int32 i = 0; i < aQueries.getLength(); i++)
-                rBox.append("1", pQueries[i]);
+            for (const OUString& rQuery : aQueries)
+                rBox.append("1", rQuery);
         }
         if (!sOldTableName.isEmpty())
             rBox.set_active_text(sOldTableName);
@@ -797,10 +795,9 @@ void SwDBManager::GetColumnNames(ListBox* pListBox,
     {
         uno::Reference<container::XNameAccess> xCols = xColsSupp->getColumns();
         const uno::Sequence<OUString> aColNames = xCols->getElementNames();
-        const OUString* pColNames = aColNames.getConstArray();
-        for(int nCol = 0; nCol < aColNames.getLength(); nCol++)
+        for (const OUString& rColName : aColNames)
         {
-            pListBox->InsertEntry(pColNames[nCol]);
+            pListBox->InsertEntry(rColName);
         }
         ::comphelper::disposeComponent( xColsSupp );
     }
@@ -816,10 +813,9 @@ void SwDBManager::GetColumnNames(weld::ComboBox& rBox,
     {
         uno::Reference<container::XNameAccess> xCols = xColsSupp->getColumns();
         const uno::Sequence<OUString> aColNames = xCols->getElementNames();
-        const OUString* pColNames = aColNames.getConstArray();
-        for (sal_Int32 nCol = 0; nCol < aColNames.getLength(); ++nCol)
+        for (const OUString& rColName : aColNames)
         {
-            rBox.append_text(pColNames[nCol]);
+            rBox.append_text(rColName);
         }
         ::comphelper::disposeComponent( xColsSupp );
     }
@@ -976,17 +972,17 @@ static void lcl_PreparePrinterOptions(
     rOutPrintOptions[ 0 ].Value <<= true;
 
     // copy print options
-    const beans::PropertyValue* pOptions = rInPrintOptions.getConstArray();
-    for( sal_Int32 n = 0, nIndex = nOffset ; n < rInPrintOptions.getLength(); 
++n)
+    sal_Int32 nIndex = nOffset;
+    for( const beans::PropertyValue& rOption : rInPrintOptions)
     {
-        if( pOptions[n].Name == "CopyCount" || pOptions[n].Name == "FileName"
-            || pOptions[n].Name == "Collate" || pOptions[n].Name == "Pages"
-            || pOptions[n].Name == "Wait" || pOptions[n].Name == "PrinterName" 
)
+        if( rOption.Name == "CopyCount" || rOption.Name == "FileName"
+            || rOption.Name == "Collate" || rOption.Name == "Pages"
+            || rOption.Name == "Wait" || rOption.Name == "PrinterName" )
         {
             // add an option
             rOutPrintOptions.realloc( nIndex + 1 );
-            rOutPrintOptions[ nIndex ].Name = pOptions[n].Name;
-            rOutPrintOptions[ nIndex++ ].Value = pOptions[n].Value ;
+            rOutPrintOptions[ nIndex ].Name = rOption.Name;
+            rOutPrintOptions[ nIndex++ ].Value = rOption.Value ;
         }
     }
 }
@@ -2142,15 +2138,12 @@ bool SwDBManager::GetColumnCnt(const OUString& 
rSourceName, const OUString& rTab
     if(pFound->aSelection.hasElements())
     {
         //the destination has to be an element of the selection
-        const uno::Any* pSelection = pFound->aSelection.getConstArray();
-        bool bFound = false;
-        for(sal_Int32 nPos = 0; !bFound && nPos < 
pFound->aSelection.getLength(); nPos++)
-        {
-            sal_Int32 nSelection = 0;
-            pSelection[nPos] >>= nSelection;
-            if(nSelection == static_cast<sal_Int32>(nAbsRecordId))
-                bFound = true;
-        }
+        bool bFound = std::any_of(pFound->aSelection.begin(), 
pFound->aSelection.end(),
+            [nAbsRecordId](const uno::Any& rSelection) {
+                sal_Int32 nSelection = 0;
+                rSelection >>= nSelection;
+                return nSelection == static_cast<sal_Int32>(nAbsRecordId);
+            });
         if(!bFound)
             return false;
     }
@@ -2210,18 +2203,17 @@ bool SwDBManager::FillCalcWithMergeData( 
SvNumberFormatter *pDocFormatter,
     {
         uno::Reference<container::XNameAccess> xCols = xColsSupp->getColumns();
         const uno::Sequence<OUString> aColNames = xCols->getElementNames();
-        const OUString* pColNames = aColNames.getConstArray();
         OUString aString;
 
         // add the "record number" variable, as SwCalc::VarLook would.
         rCalc.VarChange( GetAppCharClass().lowercase(
             SwFieldType::GetTypeStr(TYP_DBSETNUMBERFLD) ), 
GetSelectedRecordId() );
 
-        for( int nCol = 0; nCol < aColNames.getLength(); nCol++ )
+        for( const OUString& rColName : aColNames )
         {
             // get the column type
             sal_Int32 nColumnType = sdbc::DataType::SQLNULL;
-            uno::Any aCol = xCols->getByName( pColNames[nCol] );
+            uno::Any aCol = xCols->getByName( rColName );
             uno::Reference<beans::XPropertySet> xColumnProps;
             aCol >>= xColumnProps;
             uno::Any aType = xColumnProps->getPropertyValue( "Type" );
@@ -2232,7 +2224,7 @@ bool SwDBManager::FillCalcWithMergeData( 
SvNumberFormatter *pDocFormatter,
 
             sal_uInt32 nFormat = GetColumnFormat( 
m_pImpl->pMergeData->sDataSource,
                                             m_pImpl->pMergeData->sCommand,
-                                            pColNames[nCol], pDocFormatter, 
nLanguage );
+                                            rColName, pDocFormatter, nLanguage 
);
             // aNumber is overwritten by SwDBField::FormatValue, so store 
initial status
             bool colIsNumber = aNumber != DBL_MAX;
             bool bValidValue = SwDBField::FormatValue( pDocFormatter, aString, 
nFormat,
@@ -2244,8 +2236,8 @@ bool SwDBManager::FillCalcWithMergeData( 
SvNumberFormatter *pDocFormatter,
                     SwSbxValue aValue;
                     aValue.PutDouble( aNumber );
                     aValue.SetDBvalue( true );
-                    SAL_INFO( "sw.ui", "'" << pColNames[nCol] << "': " << 
aNumber << " / " << aString );
-                    rCalc.VarChange( pColNames[nCol], aValue );
+                    SAL_INFO( "sw.ui", "'" << rColName << "': " << aNumber << 
" / " << aString );
+                    rCalc.VarChange( rColName, aValue );
                 }
             }
             else
@@ -2253,8 +2245,8 @@ bool SwDBManager::FillCalcWithMergeData( 
SvNumberFormatter *pDocFormatter,
                 SwSbxValue aValue;
                 aValue.PutString( aString );
                 aValue.SetDBvalue( true );
-                SAL_INFO( "sw.ui", "'" << pColNames[nCol] << "': " << aString 
);
-                rCalc.VarChange( pColNames[nCol], aValue );
+                SAL_INFO( "sw.ui", "'" << rColName << "': " << aString );
+                rCalc.VarChange( rColName, aValue );
             }
         }
     }
@@ -3126,22 +3118,21 @@ void SwDBManager::InsertText(SwWrtShell& rSh,
     uno::Reference<sdbc::XResultSet>  xResSet;
     uno::Sequence<uno::Any> aSelection;
     sal_Int16 nCmdType = sdb::CommandType::TABLE;
-    const beans::PropertyValue* pValues = rProperties.getConstArray();
     uno::Reference< sdbc::XConnection> xConnection;
-    for(sal_Int32 nPos = 0; nPos < rProperties.getLength(); nPos++)
-    {
-        if ( pValues[nPos].Name == "DataSourceName" )
-            pValues[nPos].Value >>= sDataSource;
-        else if ( pValues[nPos].Name == "Command" )
-            pValues[nPos].Value >>= sDataTableOrQuery;
-        else if ( pValues[nPos].Name == "Cursor" )
-            pValues[nPos].Value >>= xResSet;
-        else if ( pValues[nPos].Name == "Selection" )
-            pValues[nPos].Value >>= aSelection;
-        else if ( pValues[nPos].Name == "CommandType" )
-            pValues[nPos].Value >>= nCmdType;
-        else if ( pValues[nPos].Name == "ActiveConnection" )
-            pValues[nPos].Value >>= xConnection;
+    for(const beans::PropertyValue& rValue : rProperties)
+    {
+        if ( rValue.Name == "DataSourceName" )
+            rValue.Value >>= sDataSource;
+        else if ( rValue.Name == "Command" )
+            rValue.Value >>= sDataTableOrQuery;
+        else if ( rValue.Name == "Cursor" )
+            rValue.Value >>= xResSet;
+        else if ( rValue.Name == "Selection" )
+            rValue.Value >>= aSelection;
+        else if ( rValue.Name == "CommandType" )
+            rValue.Value >>= nCmdType;
+        else if ( rValue.Name == "ActiveConnection" )
+            rValue.Value >>= xConnection;
     }
     if(sDataSource.isEmpty() || sDataTableOrQuery.isEmpty() || !xResSet.is())
     {
diff --git a/sw/source/uibase/dbui/dbtree.cxx b/sw/source/uibase/dbui/dbtree.cxx
index d8b35c8b2759..d7d9e96e626c 100644
--- a/sw/source/uibase/dbui/dbtree.cxx
+++ b/sw/source/uibase/dbui/dbtree.cxx
@@ -158,17 +158,14 @@ void SwDBTreeList::InitTreeList()
         aDBNames.begin(), aDBNames.end(),
         [&sort](OUString const & x, OUString const & y)
         { return sort.compare(x, y) < 0; });
-    const OUString* pDBNames = aDBNames.getConstArray();
-    sal_Int32 nCount = aDBNames.getLength();
 
     OUString aImg(RID_BMP_DB);
-    for (sal_Int32 i = 0; i < nCount; ++i)
+    for (const OUString& rDBName : aDBNames)
     {
-        OUString sDBName(pDBNames[i]);
-        Reference<XConnection> xConnection = pImpl->GetConnection(sDBName);
+        Reference<XConnection> xConnection = pImpl->GetConnection(rDBName);
         if (xConnection.is())
         {
-            m_xTreeView->insert(nullptr, -1, &sDBName, nullptr, nullptr, 
nullptr, &aImg, true, nullptr);
+            m_xTreeView->insert(nullptr, -1, &rDBName, nullptr, nullptr, 
nullptr, &aImg, true, nullptr);
         }
     }
     Select(OUString(), OUString(), OUString());
@@ -245,12 +242,9 @@ IMPL_LINK(SwDBTreeList, RequestingChildrenHdl, const 
weld::TreeIter&, rParent, b
                 {
                     Reference <XNameAccess> xCols = 
xColsSupplier->getColumns();
                     Sequence< OUString> aColNames = xCols->getElementNames();
-                    const OUString* pColNames = aColNames.getConstArray();
-                    long nCount = aColNames.getLength();
-                    for (long i = 0; i < nCount; i++)
+                    for (const OUString& rColName : aColNames)
                     {
-                        OUString sName = pColNames[i];
-                        m_xTreeView->append(&rParent, sName);
+                        m_xTreeView->append(&rParent, rColName);
                     }
                 }
             }
@@ -273,14 +267,10 @@ IMPL_LINK(SwDBTreeList, RequestingChildrenHdl, const 
weld::TreeIter&, rParent, b
                     {
                         Reference<XNameAccess> xTables = 
xTSupplier->getTables();
                         Sequence< OUString> aTableNames = 
xTables->getElementNames();
-                        OUString sTableName;
-                        long nCount = aTableNames.getLength();
-                        const OUString* pTableNames = 
aTableNames.getConstArray();
                         OUString aImg(RID_BMP_DBTABLE);
-                        for (long i = 0; i < nCount; i++)
+                        for (const OUString& rTableName : aTableNames)
                         {
-                            sTableName = pTableNames[i];
-                            m_xTreeView->insert(&rParent, -1, &sTableName, 
nullptr,
+                            m_xTreeView->insert(&rParent, -1, &rTableName, 
nullptr,
                                                 nullptr, nullptr, &aImg, 
bShowColumns, nullptr);
                         }
                     }
@@ -290,16 +280,12 @@ IMPL_LINK(SwDBTreeList, RequestingChildrenHdl, const 
weld::TreeIter&, rParent, b
                     {
                         Reference<XNameAccess> xQueries = 
xQSupplier->getQueries();
                         Sequence< OUString> aQueryNames = 
xQueries->getElementNames();
-                        OUString sQueryName;
-                        long nCount = aQueryNames.getLength();
-                        const OUString* pQueryNames = 
aQueryNames.getConstArray();
                         OUString aImg(RID_BMP_DBQUERY);
-                        for (long i = 0; i < nCount; i++)
+                        for (const OUString& rQueryName : aQueryNames)
                         {
-                            sQueryName = pQueryNames[i];
                             //to discriminate between queries and tables the 
user data of query entries is set
                             OUString sId(OUString::number(1));
-                            m_xTreeView->insert(&rParent, -1, &sQueryName, 
&sId,
+                            m_xTreeView->insert(&rParent, -1, &rQueryName, 
&sId,
                                                 nullptr, nullptr, &aImg, 
bShowColumns, nullptr);
                         }
                     }
diff --git a/sw/source/uibase/dbui/mailmergehelper.cxx 
b/sw/source/uibase/dbui/mailmergehelper.cxx
index ba5dfd625a5b..cd01bbfb9e19 100644
--- a/sw/source/uibase/dbui/mailmergehelper.cxx
+++ b/sw/source/uibase/dbui/mailmergehelper.cxx
@@ -472,9 +472,8 @@ OUString SwAddressPreview::FillData(
 
             //find the appropriate assignment
             OUString sConvertedColumn = aItem.sText;
-            for(sal_uInt32 nColumn = 0;
-                    nColumn < rDefHeaders.size() && nColumn < 
sal_uInt32(aAssignment.getLength());
-                                                                               
 ++nColumn)
+            auto nSize = std::min(sal_uInt32(rDefHeaders.size()), 
sal_uInt32(aAssignment.getLength()));
+            for(sal_uInt32 nColumn = 0; nColumn < nSize; ++nColumn)
             {
                 if (rDefHeaders[nColumn].first == aItem.sText &&
                     !pAssignment[nColumn].isEmpty())
diff --git a/sw/source/uibase/dbui/mmconfigitem.cxx 
b/sw/source/uibase/dbui/mmconfigitem.cxx
index 41aa414233b8..ba235222bccf 100644
--- a/sw/source/uibase/dbui/mmconfigitem.cxx
+++ b/sw/source/uibase/dbui/mmconfigitem.cxx
@@ -330,15 +330,9 @@ SwMailMergeConfigItem_Impl::SwMailMergeConfigItem_Impl() :
     if(m_aSavedDocuments.hasElements())
     {
         uno::Sequence< OUString > 
aTempDocuments(m_aSavedDocuments.getLength());
-        OUString* pTempDocuments = aTempDocuments.getArray();
-        sal_Int32 nIndex = 0;
-        for(sal_Int32 i = 0; i < m_aSavedDocuments.getLength(); ++i)
-        {
-            if(SWUnoHelper::UCB_IsFile( m_aSavedDocuments[i] ))
-            {
-                pTempDocuments[nIndex++] = m_aSavedDocuments[i];
-            }
-        }
+        OUString* pTempDocuments = std::copy_if(m_aSavedDocuments.begin(), 
m_aSavedDocuments.end(), aTempDocuments.begin(),
+            [](const OUString& rDoc) { return SWUnoHelper::UCB_IsFile( rDoc ); 
});
+        sal_Int32 nIndex = 
static_cast<sal_Int32>(std::distance(aTempDocuments.begin(), pTempDocuments));
         if(nIndex < m_aSavedDocuments.getLength())
         {
             m_aSavedDocuments = aTempDocuments;
@@ -358,26 +352,15 @@ void 
SwMailMergeConfigItem_Impl::SetCurrentAddressBlockIndex( sal_Int32 nSet )
 
 static OUString lcl_CreateNodeName(Sequence<OUString>& rAssignments )
 {
-    const OUString* pNames = rAssignments.getConstArray();
     sal_Int32 nStart = rAssignments.getLength();
     OUString sNewName;
-    bool bFound;
-    do
+    //search if the name exists
+    while(true)
     {
-        bFound = false;
-        sNewName = "_" + OUString::number(nStart);
-        //search if the name exists
-        for(sal_Int32 nAssign = 0; nAssign < rAssignments.getLength(); 
++nAssign)
-        {
-            if(pNames[nAssign] == sNewName)
-            {
-                bFound = true;
-                ++nStart;
-                break;
-            }
-        }
+        sNewName = "_" + OUString::number(nStart++);
+        if(comphelper::findValue(rAssignments, sNewName) == -1)
+            break;
     }
-    while(bFound);
     // add the new name to the array of existing names
     rAssignments.realloc(rAssignments.getLength() + 1);
     rAssignments.getArray()[rAssignments.getLength() - 1] = sNewName;
@@ -601,13 +584,13 @@ const Sequence< OUString> 
SwMailMergeConfigItem_Impl::GetAddressBlocks(
         bool bConvertToConfig) const
 {
     Sequence< OUString> aRet(m_aAddressBlocks.size());
-    OUString* pRet = aRet.getArray();
-    for(size_t nBlock = 0; nBlock < m_aAddressBlocks.size(); nBlock++)
-    {
-        pRet[nBlock] = m_aAddressBlocks[nBlock];
-        if(bConvertToConfig)
-            lcl_ConvertToNumbers(pRet[nBlock], m_AddressHeaderSA);
-    }
+    std::transform(m_aAddressBlocks.begin(), m_aAddressBlocks.end(), 
aRet.begin(),
+        [this, bConvertToConfig](const OUString& rBlock) -> OUString {
+            OUString sBlock = rBlock;
+            if(bConvertToConfig)
+                lcl_ConvertToNumbers(sBlock, m_AddressHeaderSA);
+            return sBlock;
+        });
     return aRet;
 }
 
@@ -616,13 +599,13 @@ void SwMailMergeConfigItem_Impl::SetAddressBlocks(
         bool bConvertFromConfig)
 {
     m_aAddressBlocks.clear();
-    for(sal_Int32 nBlock = 0; nBlock < rBlocks.getLength(); nBlock++)
-    {
-        OUString sBlock = rBlocks[nBlock];
-        if(bConvertFromConfig)
-            lcl_ConvertFromNumbers(sBlock, m_AddressHeaderSA);
-        m_aAddressBlocks.push_back(sBlock);
-    }
+    std::transform(rBlocks.begin(), rBlocks.end(), 
std::back_inserter(m_aAddressBlocks),
+        [this, bConvertFromConfig](const OUString& rBlock) -> OUString {
+            OUString sBlock = rBlock;
+            if(bConvertFromConfig)
+                lcl_ConvertFromNumbers(sBlock, m_AddressHeaderSA);
+            return sBlock;
+        });
     m_nCurrentAddressBlock = 0;
     SetModified();
 }
@@ -635,13 +618,13 @@ const Sequence< OUString>   
SwMailMergeConfigItem_Impl::GetGreetings(
             eType == SwMailMergeConfigItem::MALE ? m_aMaleGreetingLines :
                                 m_aNeutralGreetingLines;
     Sequence< OUString> aRet(rGreetings.size());
-    OUString* pRet = aRet.getArray();
-    for(size_t nGreeting = 0; nGreeting < rGreetings.size(); nGreeting++)
-    {
-        pRet[nGreeting] = rGreetings[nGreeting];
-        if(bConvertToConfig)
-            lcl_ConvertToNumbers(pRet[nGreeting], m_AddressHeaderSA);
-    }
+    std::transform(rGreetings.begin(), rGreetings.end(), aRet.begin(),
+        [this, bConvertToConfig](const OUString& rGreeting) -> OUString {
+            OUString sGreeting = rGreeting;
+            if(bConvertToConfig)
+                lcl_ConvertToNumbers(sGreeting, m_AddressHeaderSA);
+            return sGreeting;
+        });
     return aRet;
 }
 
@@ -656,13 +639,13 @@ void  SwMailMergeConfigItem_Impl::SetGreetings(
                                 m_aNeutralGreetingLines;
 
     rGreetings.clear();
-    for(sal_Int32 nGreeting = 0; nGreeting < rSetGreetings.getLength(); 
nGreeting++)
-    {
-        OUString sGreeting = rSetGreetings[nGreeting];
-        if(bConvertFromConfig)
-            lcl_ConvertFromNumbers(sGreeting, m_AddressHeaderSA);
-        rGreetings.push_back(sGreeting);
-    }
+    std::transform(rSetGreetings.begin(), rSetGreetings.end(), 
std::back_inserter(rGreetings),
+        [this, bConvertFromConfig](const OUString& rGreeting) -> OUString {
+            OUString sGreeting = rGreeting;
+            if(bConvertFromConfig)
+                lcl_ConvertFromNumbers(sGreeting, m_AddressHeaderSA);
+            return sGreeting;
+        });
     SetModified();
 }
 
@@ -1215,9 +1198,8 @@ bool SwMailMergeConfigItem::IsAddressFieldsAssigned() 
const
         if(aItem.bIsColumn)
         {
             OUString sConvertedColumn = aItem.sText;
-            for(sal_uInt32 nColumn = 0;
-                    nColumn < rHeaders.size() && nColumn < 
sal_uInt32(aAssignment.getLength());
-                                                                               
 ++nColumn)
+            auto nSize = std::min(sal_uInt32(rHeaders.size()), 
sal_uInt32(aAssignment.getLength()));
+            for(sal_uInt32 nColumn = 0; nColumn < nSize; ++nColumn)
             {
                 if (rHeaders[nColumn].first == aItem.sText &&
                     !pAssignment[nColumn].isEmpty())
@@ -1274,9 +1256,8 @@ bool SwMailMergeConfigItem::IsGreetingFieldsAssigned() 
const
         if(aItem.bIsColumn)
         {
             OUString sConvertedColumn = aItem.sText;
-            for(sal_uInt32 nColumn = 0;
-                    nColumn < rHeaders.size() && nColumn < 
sal_uInt32(aAssignment.getLength());
-                                                                               
 ++nColumn)
+            auto nSize = std::min(sal_uInt32(rHeaders.size()), 
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/uibase/docvw/edtwin.cxx 
b/sw/source/uibase/docvw/edtwin.cxx
index 77f8af3ef285..5ed8668e2e0b 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -5970,9 +5970,9 @@ void QuickHelpData::FillStrArr( SwWrtShell const & rSh, 
const OUString& rWord )
     uno::Sequence< i18n::CalendarItem2 > aNames( (*pCalendar)->getMonths() );
     for ( sal_uInt16 i = 0; i < 2; ++i )
     {
-        for ( long n = 0; n < aNames.getLength(); ++n )
+        for ( const auto& rName : aNames )
         {
-            const OUString& rStr( aNames[n].FullName );
+            const OUString& rStr( rName.FullName );
             // Check string longer than word and case insensitive match
             if( rStr.getLength() > rWord.getLength() &&
                 rCC.lowercase( rStr, 0, rWord.getLength() ) == sWordLower )
diff --git a/sw/source/uibase/envelp/labelcfg.cxx 
b/sw/source/uibase/envelp/labelcfg.cxx
index 70e3cc8b54c5..f562fba66d5b 100644
--- a/sw/source/uibase/envelp/labelcfg.cxx
+++ b/sw/source/uibase/envelp/labelcfg.cxx
@@ -26,6 +26,7 @@
 #include <rtl/bootstrap.hxx>
 #include <unotools/configpaths.hxx>
 #include <xmlreader/xmlreader.hxx>
+#include <comphelper/sequence.hxx>
 #include <osl/diagnose.h>
 
 #include <unomid.h>
@@ -64,8 +65,7 @@ static Sequence<OUString> lcl_CreatePropertyNames(const 
OUString& rPrefix)
 {
     Sequence<OUString> aProperties(2);
     OUString* pProperties = aProperties.getArray();
-    for(sal_Int32 nProp = 0; nProp < 2; nProp++)
-        pProperties[nProp] = rPrefix;
+    std::fill(aProperties.begin(), aProperties.end(), rPrefix);
 
     pProperties[ 0] += "Name";
     pProperties[ 1] += "Measure";
@@ -136,17 +136,14 @@ SwLabelConfig::SwLabelConfig() :
 
     // add to m_aLabels and m_aManufacturers the custom labels
     const Sequence<OUString>& rMan = GetNodeNames( OUString() );
-    const OUString* pMan = rMan.getConstArray();
-    for ( sal_Int32 nMan = 0; nMan < rMan.getLength(); nMan++ )
+    for ( const OUString& rManufacturer : rMan )
     {
-        sManufacturer = pMan[nMan];
-        const Sequence<OUString> aLabels = GetNodeNames( sManufacturer );
-        const OUString* pLabels = aLabels.getConstArray();
-        for( sal_Int32 nLabel = 0; nLabel < aLabels.getLength(); nLabel++ )
+        const Sequence<OUString> aLabels = GetNodeNames( rManufacturer );
+        for( const OUString& rLabel : aLabels )
         {
-            OUString sPrefix( sManufacturer );
+            OUString sPrefix( rManufacturer );
             sPrefix += "/";
-            sPrefix += pLabels[nLabel];
+            sPrefix += rLabel;
             sPrefix += "/";
             Sequence<OUString> aPropNames = lcl_CreatePropertyNames( sPrefix );
             Sequence<Any>   aValues = GetProperties( aPropNames );
@@ -157,10 +154,10 @@ SwLabelConfig::SwLabelConfig() :
             if (aValues.getLength() >= 2)
                 if(pValues[1].hasValue())
                     pValues[1] >>= sMeasure;
-            if ( m_aLabels.find( sManufacturer ) == m_aLabels.end() )
-                m_aManufacturers.push_back( sManufacturer );
-            m_aLabels[sManufacturer][sName].m_aMeasure = sMeasure;
-            m_aLabels[sManufacturer][sName].m_bPredefined = false;
+            if ( m_aLabels.find( rManufacturer ) == m_aLabels.end() )
+                m_aManufacturers.push_back( rManufacturer );
+            m_aLabels[rManufacturer][sName].m_aMeasure = sMeasure;
+            m_aLabels[rManufacturer][sName].m_bPredefined = false;
         }
     }
 }
@@ -265,15 +262,6 @@ bool    SwLabelConfig::HasLabel(const OUString& 
rManufacturer, const OUString& r
              ( m_aLabels[rManufacturer].find(rType) != 
m_aLabels[rManufacturer].end() ) );
 }
 
-static bool lcl_Exists(const OUString& rNode, const Sequence<OUString>& 
rLabels)
-{
-    const OUString* pLabels = rLabels.getConstArray();
-    for(sal_Int32 i = 0; i < rLabels.getLength(); i++)
-        if(pLabels[i] == rNode)
-            return true;
-    return false;
-}
-
 // label is always saved as a custom label
 // predefined labels can NOT be overwritten by custom labels with same 
manufacturer/name
 void SwLabelConfig::SaveLabel( const OUString& rManufacturer,
@@ -305,7 +293,7 @@ void SwLabelConfig::SaveLabel( const OUString& 
rManufacturer,
         OUString sPrefix( "Label" );
         sFoundNode = sPrefix;
         sFoundNode += OUString::number( nIndex );
-        while ( lcl_Exists( sFoundNode, aLabels ) )
+        while ( comphelper::findValue(aLabels, sFoundNode) != -1 )
         {
             sFoundNode = sPrefix + OUString::number(nIndex++);
         }
@@ -315,12 +303,11 @@ void SwLabelConfig::SaveLabel( const OUString& 
rManufacturer,
         // get the appropriate node
         OUString sManufacturer( wrapConfigurationElementName( rManufacturer ) 
);
         const Sequence<OUString> aLabels = GetNodeNames( sManufacturer );
-        const OUString* pLabels = aLabels.getConstArray();
-        for (sal_Int32 nLabel = 0; nLabel < aLabels.getLength(); nLabel++)
+        for (const OUString& rLabel : aLabels)
         {
             OUString sPrefix( sManufacturer );
             sPrefix += "/";
-            sPrefix += pLabels[nLabel];
+            sPrefix += rLabel;
             sPrefix += "/";
             Sequence<OUString> aProperties { sPrefix };
             aProperties.getArray()[0] += "Name";
@@ -332,7 +319,7 @@ void SwLabelConfig::SaveLabel( const OUString& 
rManufacturer,
                 pValues[0] >>= sTmp;
                 if ( rType == sTmp )
                 {
-                    sFoundNode = pLabels[nLabel];
+                    sFoundNode = rLabel;
                     break;
                 }
             }
diff --git a/sw/source/uibase/fldui/fldmgr.cxx 
b/sw/source/uibase/fldui/fldmgr.cxx
index 547e71e1283f..c365d661a684 100644
--- a/sw/source/uibase/fldui/fldmgr.cxx
+++ b/sw/source/uibase/fldui/fldmgr.cxx
@@ -704,17 +704,10 @@ sal_uInt16 SwFieldMgr::GetFormatCount(sal_uInt16 nTypeId, 
bool bHtmlMode) const
             if(m_xNumberingInfo.is())
             {
                 Sequence<sal_Int16> aTypes = 
m_xNumberingInfo->getSupportedNumberingTypes();
-                const sal_Int16* pTypes = aTypes.getConstArray();
-                for(sal_Int32 nType = 0; nType < aTypes.getLength(); nType++)
-                {
-                    sal_Int16 nCurrent = pTypes[nType];
-                    //skip all values below or equal to CHARS_LOWER_LETTER_N
-                    if(nCurrent > NumberingType::CHARS_LOWER_LETTER_N)
-                    {
-                        // #i28073# it's not necessarily a sorted sequence
-                        ++nCount;
-                    }
-                }
+                // #i28073# it's not necessarily a sorted sequence
+                //skip all values below or equal to CHARS_LOWER_LETTER_N
+                nCount += std::count_if(aTypes.begin(), aTypes.end(),
+                    [](sal_Int16 nCurrent) { return nCurrent > 
NumberingType::CHARS_LOWER_LETTER_N; });
             }
             return nCount;
         }
@@ -748,25 +741,23 @@ OUString SwFieldMgr::GetFormatStr(sal_uInt16 nTypeId, 
sal_uInt32 nFormatId) cons
         if (m_xNumberingInfo.is())
         {
             Sequence<sal_Int16> aTypes = 
m_xNumberingInfo->getSupportedNumberingTypes();
-            const sal_Int16* pTypes = aTypes.getConstArray();
             sal_Int32 nOffset = aSwFields[nPos].nFormatLength;
             sal_uInt32 nValidEntry = 0;
-            for (sal_Int32 nType = 0; nType < aTypes.getLength(); nType++)
+            for (const sal_Int16 nCurrent : aTypes)
             {
-                sal_Int16 nCurrent = pTypes[nType];
                 if(nCurrent > NumberingType::CHARS_LOWER_LETTER_N &&
                         (nCurrent != (NumberingType::BITMAP | LINK_TOKEN)))
                 {
                     if (nValidEntry == nFormatId - nOffset)
                     {
-                        sal_uInt32 n = 
SvxNumberingTypeTable::FindIndex(pTypes[nType]);
+                        sal_uInt32 n = 
SvxNumberingTypeTable::FindIndex(nCurrent);
                         if (n != RESARRAY_INDEX_NOTFOUND)
                         {
                             aRet = SvxNumberingTypeTable::GetString(n);
                         }
                         else
                         {
-                            aRet = m_xNumberingInfo->getNumberingIdentifier( 
pTypes[nType] );
+                            aRet = m_xNumberingInfo->getNumberingIdentifier( 
nCurrent );
                         }
                         break;
                     }
@@ -830,17 +821,15 @@ sal_uInt16 SwFieldMgr::GetFormatId(sal_uInt16 nTypeId, 
sal_uInt32 nFormatId) con
             else if (m_xNumberingInfo.is())
             {
                 Sequence<sal_Int16> aTypes = 
m_xNumberingInfo->getSupportedNumberingTypes();
-                const sal_Int16* pTypes = aTypes.getConstArray();
                 sal_Int32 nOffset = aSwFields[nPos].nFormatLength;
                 sal_Int32 nValidEntry = 0;
-                for (sal_Int32 nType = 0; nType < aTypes.getLength(); nType++)
+                for (const sal_Int16 nCurrent : aTypes)
                 {
-                    sal_Int16 nCurrent = pTypes[nType];
                     if (nCurrent > NumberingType::CHARS_LOWER_LETTER_N)
                     {
                         if (nValidEntry == static_cast<sal_Int32>(nFormatId) - 
nOffset)
                         {
-                            nId = pTypes[nType];
+                            nId = nCurrent;
                             break;
                         }
                         ++nValidEntry;
diff --git a/sw/source/uibase/lingu/olmenu.cxx 
b/sw/source/uibase/lingu/olmenu.cxx
index 7368b2dc301d..a8ff226fce6f 100644
--- a/sw/source/uibase/lingu/olmenu.cxx
+++ b/sw/source/uibase/lingu/olmenu.cxx
@@ -175,16 +175,12 @@ void SwSpellPopup::fillLangPopupMenu(
     if (xDocumentLanguages.is())
     {
         uno::Sequence< lang::Locale > rLocales( 
xDocumentLanguages->getDocumentLanguages( static_cast<sal_Int16>(nScriptType), 
nMaxCount ) );
-        if (rLocales.hasElements())
+        for (const lang::Locale& rLocale : rLocales)
         {
-            for (sal_Int32 i = 0; i < rLocales.getLength(); ++i)
-            {
-                if (aLangItems.size() == size_t(nMaxCount))
-                    break;
-                const lang::Locale& rLocale = rLocales[i];
-                if (lcl_checkScriptType( nScriptType, 
SvtLanguageTable::GetLanguageType( rLocale.Language )))
-                    aLangItems.insert( rLocale.Language );
-            }
+            if (aLangItems.size() == size_t(nMaxCount))
+                break;
+            if (lcl_checkScriptType( nScriptType, 
SvtLanguageTable::GetLanguageType( rLocale.Language )))
+                aLangItems.insert( rLocale.Language );
         }
     }
 
@@ -337,12 +333,10 @@ SwSpellPopup::SwSpellPopup(
             xDic->setActive( true );
 
         m_aDics = xDicList->getDictionaries();
-        const uno::Reference< linguistic2::XDictionary >  *pDic = 
m_aDics.getConstArray();
-        sal_uInt16 nDicCount = static_cast< sal_uInt16 >(m_aDics.getLength());
 
-        for( sal_uInt16 i = 0; i < nDicCount; i++ )
+        for( const uno::Reference< linguistic2::XDictionary >& rDic : m_aDics )
         {
-            uno::Reference< linguistic2::XDictionary >  xDicTmp( pDic[i], 
uno::UNO_QUERY );
+            uno::Reference< linguistic2::XDictionary >  xDicTmp( rDic, 
uno::UNO_QUERY );
             if (!xDicTmp.is() || LinguMgr::GetIgnoreAllList() == xDicTmp)
                 continue;
 
@@ -459,16 +453,15 @@ SwSpellPopup::SwSpellPopup(
 
     // Add an item to show detailed infos if the FullCommentURL property is 
defined
     beans::PropertyValues  aProperties = rResult.aErrors[ nErrorInResult 
].aProperties;
+    for ( const auto& rProp : aProperties )
     {
-        sal_Int32 i = 0;
-        while ( m_sExplanationLink.isEmpty() && i < aProperties.getLength() )
+        if ( rProp.Name == "FullCommentURL" )
         {
-            if ( aProperties[i].Name == "FullCommentURL" )
-            {
-                uno::Any aValue = aProperties[i].Value;
-                aValue >>= m_sExplanationLink;
-            }
-            ++i;
+            uno::Any aValue = rProp.Value;
+            aValue >>= m_sExplanationLink;
+
+            if ( !m_sExplanationLink.isEmpty( ) )
+                break;
         }
     }
 
@@ -480,8 +473,7 @@ SwSpellPopup::SwSpellPopup(
     m_xPopupMenu->SetMenuFlags(MenuFlags::NoAutoMnemonics);
 
     m_xPopupMenu->InsertSeparator(OString(), nPos++);
-    sal_Int32 nStringCount = m_aSuggestions.getLength();
-    if ( nStringCount )     // suggestions available...
+    if ( m_aSuggestions.hasElements() )     // suggestions available...
     {
         Image aImage;
         OUString aSuggestionImageUrl;
@@ -497,9 +489,8 @@ SwSpellPopup::SwSpellPopup(
         }
 
         sal_uInt16 nItemId = MN_SUGGESTION_START;
-        for (sal_Int32 i = 0;  i < nStringCount;  ++i)
+        for (const OUString& aEntry : m_aSuggestions)
         {
-            const OUString aEntry = m_aSuggestions[ i ];
             m_xPopupMenu->InsertItem(nItemId, aEntry, MenuItemBits::NONE, 
OString(), nPos++);
             m_xPopupMenu->SetHelpId(nItemId, HID_LINGU_REPLACE);
             if (!aSuggestionImageUrl.isEmpty())
diff --git a/sw/source/uibase/misc/numberingtypelistbox.cxx 
b/sw/source/uibase/misc/numberingtypelistbox.cxx
index f2a5955e84cb..4aacd48ba78b 100644
--- a/sw/source/uibase/misc/numberingtypelistbox.cxx
+++ b/sw/source/uibase/misc/numberingtypelistbox.cxx
@@ -55,14 +55,10 @@ void SwNumberingTypeListBox::Reload(SwInsertNumTypes 
nTypeFlags)
 {
     m_xWidget->clear();
     uno::Sequence<sal_Int16> aTypes;
-    const sal_Int16* pTypes = nullptr;
     if (nTypeFlags & SwInsertNumTypes::Extended)
     {
         if (m_xImpl->xInfo.is())
-        {
             aTypes = m_xImpl->xInfo->getSupportedNumberingTypes();
-            pTypes = aTypes.getConstArray();
-        }
     }
 
     for(size_t i = 0; i < SvxNumberingTypeTable::Count(); i++)
@@ -97,18 +93,7 @@ void SwNumberingTypeListBox::Reload(SwInsertNumTypes 
nTypeFlags)
                 if (nValue >  style::NumberingType::CHARS_LOWER_LETTER_N)
                 {
                     // Insert only if offered by i18n framework per 
configuration.
-                    bInsert = false;
-                    if (pTypes)
-                    {
-                        for(sal_Int32 nType = 0; nType < aTypes.getLength(); 
nType++)
-                        {
-                            if (pTypes[nType] == nValue)
-                            {
-                                bInsert = true;
-                                break;  // for
-                            }
-                        }
-                    }
+                    bInsert = std::find(aTypes.begin(), aTypes.end(), nValue) 
!= aTypes.end();
                 }
         }
         if (bInsert)
@@ -119,17 +104,13 @@ void SwNumberingTypeListBox::Reload(SwInsertNumTypes 
nTypeFlags)
     }
     if (nTypeFlags & SwInsertNumTypes::Extended)
     {
-        if (pTypes)
+        for (sal_Int16 nCurrent : aTypes)
         {
-            for (sal_Int32 nType = 0; nType < aTypes.getLength(); nType++)
+            if (nCurrent > style::NumberingType::CHARS_LOWER_LETTER_N)
             {
-                sal_Int16 nCurrent = pTypes[nType];
-                if (nCurrent > style::NumberingType::CHARS_LOWER_LETTER_N)
+                if (m_xWidget->find_id(OUString::number(nCurrent)) == -1)
                 {
-                    if (m_xWidget->find_id(OUString::number(nCurrent)) == -1)
-                    {
-                        m_xWidget->append(OUString::number(nCurrent), 
m_xImpl->xInfo->getNumberingIdentifier(nCurrent));
-                    }
+                    m_xWidget->append(OUString::number(nCurrent), 
m_xImpl->xInfo->getNumberingIdentifier(nCurrent));
                 }
             }
         }
diff --git a/sw/source/uibase/shells/textsh1.cxx 
b/sw/source/uibase/shells/textsh1.cxx
index 92a62f64a55b..704c54bb1e55 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -1666,9 +1666,9 @@ void SwTextShell::GetState( SfxItemSet &rSet )
                     if (xFamilies->getByName("PageStyles") >>= xContainer)
                     {
                         uno::Sequence< OUString > aSeqNames = 
xContainer->getElementNames();
-                        for (sal_Int32 itName = 0; itName < 
aSeqNames.getLength(); itName++)
+                        for (const auto& rName : aSeqNames)
                         {
-                            aStyleName = aSeqNames[itName];
+                            aStyleName = rName;
                             uno::Reference<XPropertySet> 
xPropSet(xContainer->getByName(aStyleName), uno::UNO_QUERY);
                             if (xPropSet.is() && 
(xPropSet->getPropertyValue(sPhysical) >>= bIsPhysical) && bIsPhysical)
                             {
diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx
index ac79afc31f01..79cee5d94399 100644
--- a/sw/source/uibase/uiview/view.cxx
+++ b/sw/source/uibase/uiview/view.cxx
@@ -1289,12 +1289,10 @@ void SwView::ReadUserDataSequence ( const uno::Sequence 
< beans::PropertyValue >
     if(GetDocShell()->IsPreview()||m_bIsPreviewDoubleClick)
         return;
     bool bIsOwnDocument = lcl_IsOwnDocument( *this );
-    sal_Int32 nLength = rSequence.getLength();
-    if (!nLength)
+    if (!rSequence.hasElements())
         return;
 
     SET_CURR_SHELL(m_pWrtShell.get());
-    const beans::PropertyValue *pValue = rSequence.getConstArray();
     const SwRect& rRect = m_pWrtShell->GetCharRect();
     const tools::Rectangle &rVis = GetVisArea();
     const SwViewOption* pVOpt = m_pWrtShell->GetViewOptions();
@@ -1315,75 +1313,75 @@ void SwView::ReadUserDataSequence ( const uno::Sequence 
< beans::PropertyValue >
              bGotViewLayoutColumns = false, bGotViewLayoutBookMode = false,
              bBrowseMode = false, bGotBrowseMode = false;
 
-    for (sal_Int32 i = 0 ; i < nLength; i++)
+    for (const beans::PropertyValue& rValue : rSequence)
     {
-        if ( pValue->Name == "ViewLeft" )
+        if ( rValue.Name == "ViewLeft" )
         {
-           pValue->Value >>= nX;
+           rValue.Value >>= nX;
            nX = convertMm100ToTwip( nX );
         }
-        else if ( pValue->Name == "ViewTop" )
+        else if ( rValue.Name == "ViewTop" )
         {
-           pValue->Value >>= nY;
+           rValue.Value >>= nY;
            nY = convertMm100ToTwip( nY );
         }
-        else if ( pValue->Name == "VisibleLeft" )
+        else if ( rValue.Name == "VisibleLeft" )
         {
-           pValue->Value >>= nLeft;
+           rValue.Value >>= nLeft;
            nLeft = convertMm100ToTwip( nLeft );
            bGotVisibleLeft = true;
         }
-        else if ( pValue->Name == "VisibleTop" )
+        else if ( rValue.Name == "VisibleTop" )
         {
-           pValue->Value >>= nTop;
+           rValue.Value >>= nTop;
            nTop = convertMm100ToTwip( nTop );
            bGotVisibleTop = true;
         }
-        else if ( pValue->Name == "VisibleRight" )
+        else if ( rValue.Name == "VisibleRight" )
         {
-           pValue->Value >>= nRight;
+           rValue.Value >>= nRight;
            nRight = convertMm100ToTwip( nRight );
            bGotVisibleRight = true;
         }
-        else if ( pValue->Name == "VisibleBottom" )
+        else if ( rValue.Name == "VisibleBottom" )
         {
-           pValue->Value >>= nBottom;
+           rValue.Value >>= nBottom;
            nBottom = convertMm100ToTwip( nBottom );
            bGotVisibleBottom = true;
         }
-        else if ( pValue->Name == "ZoomType" )
+        else if ( rValue.Name == "ZoomType" )
         {
-           pValue->Value >>= nZoomType;
+           rValue.Value >>= nZoomType;
            bGotZoomType = true;
         }
-        else if ( pValue->Name == "ZoomFactor" )
+        else if ( rValue.Name == "ZoomFactor" )
         {
-           pValue->Value >>= nZoomFactor;
+           rValue.Value >>= nZoomFactor;
            bGotZoomFactor = true;
         }
-        else if ( pValue->Name == "ViewLayoutColumns" )
+        else if ( rValue.Name == "ViewLayoutColumns" )
         {
-           pValue->Value >>= nViewLayoutColumns;
+           rValue.Value >>= nViewLayoutColumns;
            bGotViewLayoutColumns = true;
         }
-        else if ( pValue->Name == "ViewLayoutBookMode" )
+        else if ( rValue.Name == "ViewLayoutBookMode" )
         {
-           bViewLayoutBookMode = *o3tl::doAccess<bool>(pValue->Value);
+           bViewLayoutBookMode = *o3tl::doAccess<bool>(rValue.Value);
            bGotViewLayoutBookMode = true;
         }
-        else if ( pValue->Name == "IsSelectedFrame" )
+        else if ( rValue.Name == "IsSelectedFrame" )
         {
-           pValue->Value >>= bSelectedFrame;
+           rValue.Value >>= bSelectedFrame;
            bGotIsSelectedFrame = true;
         }
-        else if (pValue->Name == "ShowOnlineLayout")
+        else if (rValue.Name == "ShowOnlineLayout")
         {
-           pValue->Value >>= bBrowseMode;
+           rValue.Value >>= bBrowseMode;
            bGotBrowseMode = true;
         }
         // Fallback to common SdrModel processing
-        else 
GetDocShell()->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->ReadUserDataSequenceValue(pValue);
-        pValue++;
+        else
+           
GetDocShell()->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->ReadUserDataSequenceValue(&rValue);
     }
     if (bGotBrowseMode)
     {
diff --git a/sw/source/uibase/uno/SwXFilterOptions.cxx 
b/sw/source/uibase/uno/SwXFilterOptions.cxx
index 0c09c570308b..79f23f77da99 100644
--- a/sw/source/uibase/uno/SwXFilterOptions.cxx
+++ b/sw/source/uibase/uno/SwXFilterOptions.cxx
@@ -57,11 +57,8 @@ uno::Sequence< beans::PropertyValue > 
SwXFilterOptions::getPropertyValues()
 
 void   SwXFilterOptions::setPropertyValues( const 
uno::Sequence<beans::PropertyValue >& aProps )
 {
-    const beans::PropertyValue* pPropArray = aProps.getConstArray();
-    long nPropCount = aProps.getLength();
-    for (long i = 0; i < nPropCount; i++)
+    for (const beans::PropertyValue& rProp : aProps)
     {
-        const beans::PropertyValue& rProp = pPropArray[i];
         OUString aPropName = rProp.Name;
 
         if ( aPropName == FILTER_OPTIONS_NAME )
diff --git a/sw/source/uibase/uno/unodispatch.cxx 
b/sw/source/uibase/uno/unodispatch.cxx
index 0d4db10ab71a..fd34d95602c9 100644
--- a/sw/source/uibase/uno/unodispatch.cxx
+++ b/sw/source/uibase/uno/unodispatch.cxx
@@ -104,13 +104,9 @@ uno::Sequence< uno::Reference< frame::XDispatch > > 
SwXDispatchProviderIntercept
 {
     DispatchMutexLock_Impl aLock;
     uno::Sequence< uno::Reference< frame::XDispatch> > 
aReturn(aDescripts.getLength());
-    uno::Reference< frame::XDispatch>* pReturn = aReturn.getArray();
-    const frame::DispatchDescriptor* pDescripts = aDescripts.getConstArray();
-    for (sal_Int32 i=0; i<aDescripts.getLength(); ++i, ++pReturn, ++pDescripts)
-    {
-        *pReturn = queryDispatch(pDescripts->FeatureURL,
-                pDescripts->FrameName, pDescripts->SearchFlags);
-    }
+    std::transform(aDescripts.begin(), aDescripts.end(), aReturn.begin(),
+        [this](const frame::DispatchDescriptor& rDescr) -> 
uno::Reference<frame::XDispatch> {
+            return queryDispatch(rDescr.FeatureURL, rDescr.FrameName, 
rDescr.SearchFlags); });
     return aReturn;
 }
 
diff --git a/sw/source/uibase/uno/unomailmerge.cxx 
b/sw/source/uibase/uno/unomailmerge.cxx
index 128b9a25765c..f960d95c95a6 100644
--- a/sw/source/uibase/uno/unomailmerge.cxx
+++ b/sw/source/uibase/uno/unomailmerge.cxx
@@ -457,12 +457,10 @@ uno::Any SAL_CALL SwXMailMerge::execute(
 
     SfxObjectShellRef xCurDocSh = m_xDocSh;   // the document
 
-    const beans::NamedValue *pArguments = rArguments.getConstArray();
-    sal_Int32 nArgs = rArguments.getLength();
-    for (sal_Int32 i = 0;  i < nArgs;  ++i)
+    for (const beans::NamedValue& rArgument : rArguments)
     {
-        const OUString &rName   = pArguments[i].Name;
-        const Any &rValue       = pArguments[i].Value;
+        const OUString &rName   = rArgument.Name;
+        const Any &rValue       = rArgument.Value;
 
         bool bOK = true;
         if (rName == UNO_NAME_SELECTION)
@@ -558,20 +556,17 @@ uno::Any SAL_CALL SwXMailMerge::execute(
         Reference< sdbcx::XRowLocate > xRowLocate( xCurResultSet, UNO_QUERY );
         if ( xRowLocate.is() )
         {
-
-            const Any* pBookmarks = aCurSelection.getConstArray();
-            const Any* pBookmarksEnd = pBookmarks + aCurSelection.getLength();
             Any* pTranslated = aTranslated.getArray();
 
             try
             {
                 bool bEverythingsFine = true;
-                for ( ; ( pBookmarks != pBookmarksEnd ) && bEverythingsFine; 
++pBookmarks )
+                for ( const Any& rBookmark : aCurSelection )
                 {
-                    if ( xRowLocate->moveToBookmark( *pBookmarks ) )
-                        *pTranslated <<= xCurResultSet->getRow();
-                    else
-                        bEverythingsFine = false;
+                    bEverythingsFine = xRowLocate->moveToBookmark( rBookmark );
+                    if ( !bEverythingsFine )
+                        break;
+                    *pTranslated <<= xCurResultSet->getRow();
                     ++pTranslated;
                 }
                 if ( bEverythingsFine )
diff --git a/sw/source/uibase/uno/unomodule.cxx 
b/sw/source/uibase/uno/unomodule.cxx
index 12436cfcd2de..11c51725648e 100644
--- a/sw/source/uibase/uno/unomodule.cxx
+++ b/sw/source/uibase/uno/unomodule.cxx
@@ -109,12 +109,9 @@ uno::Sequence< uno::Reference< frame::XDispatch > > 
SAL_CALL SwUnoModule::queryD
     sal_Int32 nCount = seqDescripts.getLength();
     uno::Sequence< uno::Reference< frame::XDispatch > > lDispatcher( nCount );
 
-    for( sal_Int32 i=0; i<nCount; ++i )
-    {
-        lDispatcher[i] = queryDispatch( seqDescripts[i].FeatureURL  ,
-                                        seqDescripts[i].FrameName   ,
-                                        seqDescripts[i].SearchFlags );
-    }
+    std::transform(seqDescripts.begin(), seqDescripts.end(), 
lDispatcher.begin(),
+        [this](const frame::DispatchDescriptor& rDescr) -> uno::Reference< 
frame::XDispatch > {
+            return queryDispatch( rDescr.FeatureURL, rDescr.FrameName, 
rDescr.SearchFlags ); });
 
     return lDispatcher;
 }
diff --git a/sw/source/uibase/uno/unotxdoc.cxx 
b/sw/source/uibase/uno/unotxdoc.cxx
index 8d53dd08701b..a73f4fd5d791 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -1082,12 +1082,10 @@ void SwXTextDocument::setPagePrintSettings(const 
Sequence< beans::PropertyValue
     const SwPagePreviewPrtData* pData = 
pDocShell->GetDoc()->GetPreviewPrtData();
     if(pData)
         aData = *pData;
-    const beans::PropertyValue* pProperties = aSettings.getConstArray();
-    int nCount = aSettings.getLength();
-    for(int i = 0; i < nCount; i++)
+    for(const beans::PropertyValue& rProperty : aSettings)
     {
-        OUString sName = pProperties[i].Name;
-        const Any& rVal = pProperties[i].Value;
+        OUString sName = rProperty.Name;
+        const Any& rVal = rProperty.Value;
         bool bException;
         sal_uInt32 nVal = lcl_Any_To_ULONG(rVal, bException);
         if( sName == "PageRows" )
@@ -1155,10 +1153,9 @@ void SwXTextDocument::printPages(const Sequence< 
beans::PropertyValue >& xOption
                                 pDocShell->GetDoc()->GetAttrPool());
     aReq.AppendItem(SfxBoolItem(FN_PRINT_PAGEPREVIEW, true));
 
-    for ( int n = 0; n < xOptions.getLength(); ++n )
+    for ( const beans::PropertyValue &rProp : xOptions )
     {
         // get Property-Value from options
-        const beans::PropertyValue &rProp = xOptions.getConstArray()[n];
         Any aValue( rProp.Value );
 
         // FileName-Property?
@@ -1768,15 +1765,12 @@ Sequence< OUString > 
SwXTextDocument::getAvailableServiceNames()
     if ( !aServices.hasElements() )
     {
         Sequence< OUString > aRet =  
SvxFmMSFactory::getAvailableServiceNames();
-        OUString* pRet = aRet.getArray();
-        for ( sal_Int32 i = 0; i < aRet.getLength(); ++i )
+        auto i = comphelper::findValue(aRet, "com.sun.star.drawing.OLE2Shape");
+        if (i != -1)
         {
-            if ( pRet[i] == "com.sun.star.drawing.OLE2Shape" )
-            {
-                pRet[i] = pRet[aRet.getLength() - 1];
-                aRet.realloc( aRet.getLength() - 1 ); // <pRet> no longer 
valid.
-                break;
-            }
+            auto nLength = aRet.getLength();
+            aRet[i] = aRet[nLength - 1];
+            aRet.realloc( nLength - 1 );
         }
         Sequence< OUString > aOwn = SwXServiceProvider::GetAllServiceNames();
         aServices = SvxFmMSFactory::concatServiceNames(aRet, aOwn);
@@ -2280,12 +2274,10 @@ PropertyState SAL_CALL 
SwXTextDocument::getPropertyState( const OUString& rPrope
 Sequence< PropertyState > SAL_CALL SwXTextDocument::getPropertyStates( const 
Sequence< OUString >& rPropertyNames )
 {
     const sal_Int32 nCount = rPropertyNames.getLength();
-    const OUString * pNames = rPropertyNames.getConstArray();
     Sequence < PropertyState > aRet ( nCount );
-    PropertyState *pState = aRet.getArray();
 
-    for ( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++)
-        pState[nIndex] = getPropertyState( pNames[nIndex] );
+    std::transform(rPropertyNames.begin(), rPropertyNames.end(), aRet.begin(),
+        [this](const OUString& rName) -> PropertyState { return 
getPropertyState(rName); });
 
     return aRet;
 }
@@ -2342,15 +2334,9 @@ static bool lcl_SeqHasProperty(
     const uno::Sequence< beans::PropertyValue >& rOptions,
     const sal_Char *pPropName )
 {
-    bool bRes = false;
-    const sal_Int32 nLen = rOptions.getLength();
-    const beans::PropertyValue *pProps = rOptions.getConstArray();
-    for (sal_Int32 i = 0;  i < nLen && !bRes;  ++i)
-    {
-        if (pProps[i].Name.equalsAscii( pPropName ))
-            bRes = true;
-    }
-    return bRes;
+    return std::any_of(rOptions.begin(), rOptions.end(),
+        [&pPropName](const beans::PropertyValue& rProp) {
+            return rProp.Name.equalsAscii( pPropName ); });
 }
 
 static bool lcl_GetBoolProperty(
@@ -2358,16 +2344,11 @@ static bool lcl_GetBoolProperty(
     const sal_Char *pPropName )
 {
     bool bRes = false;
-    const sal_Int32 nLen = rOptions.getLength();
-    const beans::PropertyValue *pProps = rOptions.getConstArray();
-    for ( sal_Int32 i = 0;  i < nLen;  ++i )
-    {
-        if ( pProps[i].Name.equalsAscii( pPropName ) )
-        {
-            pProps[i].Value >>= bRes;
-            break;
-        }
-    }
+    auto pOption = std::find_if(rOptions.begin(), rOptions.end(),
+        [&pPropName](const beans::PropertyValue& rProp) {
+            return rProp.Name.equalsAscii( pPropName ); });
+    if (pOption != rOptions.end())
+        pOption->Value >>= bRes;
     return bRes;
 }
 
@@ -2383,16 +2364,10 @@ SfxViewShell * SwXTextDocument::GetRenderView(
     else
     {
         uno::Any aTmp;
-        const sal_Int32 nLen = rOptions.getLength();
-        const beans::PropertyValue *pProps = rOptions.getConstArray();
-        for (sal_Int32 i = 0; i < nLen; ++i)
-        {
-            if ( pProps[i].Name == "View" )
-            {
-                aTmp = pProps[i].Value;
-                break;
-            }
-        }
+        auto pOption = std::find_if(rOptions.begin(), rOptions.end(),
+            [](const beans::PropertyValue& rProp) { return rProp.Name == 
"View"; });
+        if (pOption != rOptions.end())
+            aTmp = pOption->Value;
 
         uno::Reference< frame::XController > xController;
         if (aTmp >>= xController)
@@ -3460,9 +3435,8 @@ void SwXTextDocument::initializeForTiledRendering(const 
css::uno::Sequence<css::
     // Tiled rendering defaults.
     SwViewOption aViewOption(*pViewShell->GetViewOptions());
     aViewOption.SetHardBlank(false);
-    for (sal_Int32 i = 0; i < rArguments.getLength(); ++i)
+    for (const beans::PropertyValue& rValue : rArguments)
     {
-        const beans::PropertyValue& rValue = rArguments[i];
         if (rValue.Name == ".uno:HideWhitespace" && rValue.Value.has<bool>())
             aViewOption.SetHideWhitespaceMode(rValue.Value.get<bool>());
         else if (rValue.Name == ".uno:ShowBorderShadow" && 
rValue.Value.has<bool>())
@@ -4091,13 +4065,9 @@ Sequence< OUString > 
SwXLinkNameAccessWrapper::getElementNames()
     else
     {
         Sequence< OUString > aOrg = xRealAccess->getElementNames();
-        const OUString* pOrgArr = aOrg.getConstArray();
         aRet.realloc(aOrg.getLength());
-        OUString* pResArr = aRet.getArray();
-        for(long i = 0; i < aOrg.getLength(); i++)
-        {
-            pResArr[i] = pOrgArr[i] + sLinkSuffix;
-        }
+        std::transform(aOrg.begin(), aOrg.end(), aRet.begin(),
+            [this](const OUString& rOrg) -> OUString { return rOrg + 
sLinkSuffix; });
     }
     return aRet;
 }
diff --git a/sw/source/uibase/uno/unotxvw.cxx b/sw/source/uibase/uno/unotxvw.cxx
index 12bc55ac579e..5958aa9a103a 100644
--- a/sw/source/uibase/uno/unotxvw.cxx
+++ b/sw/source/uibase/uno/unotxvw.cxx
@@ -593,27 +593,25 @@ void SAL_CALL SwXTextView::setRubyList(
 
     SwRubyList aList;
 
-    const Sequence<PropertyValue>* pRubyList = rRubyList.getConstArray();
-    for(sal_Int32 nPos = 0; nPos < rRubyList.getLength(); nPos++)
+    for(const Sequence<PropertyValue>& rPropList : rRubyList)
     {
         std::unique_ptr<SwRubyListEntry> pEntry(new SwRubyListEntry);
-        const PropertyValue* pProperties = pRubyList[nPos].getConstArray();
         OUString sTmp;
-        for(sal_Int32 nProp = 0; nProp < pRubyList[nPos].getLength(); nProp++)
+        for(const PropertyValue& rProperty : rPropList)
         {
-            if(pProperties[nProp].Name == UNO_NAME_RUBY_BASE_TEXT)
+            if(rProperty.Name == UNO_NAME_RUBY_BASE_TEXT)
             {
-                pProperties[nProp].Value >>= sTmp;
+                rProperty.Value >>= sTmp;
                 pEntry->SetText(sTmp);
             }
-            else if(pProperties[nProp].Name == UNO_NAME_RUBY_TEXT)
+            else if(rProperty.Name == UNO_NAME_RUBY_TEXT)
             {
-                pProperties[nProp].Value >>= sTmp;
+                rProperty.Value >>= sTmp;
                 pEntry->GetRubyAttr().SetText(sTmp);
             }
-            else if(pProperties[nProp].Name == UNO_NAME_RUBY_CHAR_STYLE_NAME)
+            else if(rProperty.Name == UNO_NAME_RUBY_CHAR_STYLE_NAME)
             {
-                if(pProperties[nProp].Value >>= sTmp)
+                if(rProperty.Value >>= sTmp)
                 {
                     OUString sName;
                     SwStyleNameMapper::FillUIName(sTmp, sName, 
SwGetPoolIdFromName::ChrFmt );
@@ -625,26 +623,26 @@ void SAL_CALL SwXTextView::setRubyList(
                     pEntry->GetRubyAttr().SetCharFormatId( nPoolId );
                 }
             }
-            else if(pProperties[nProp].Name == UNO_NAME_RUBY_ADJUST)
+            else if(rProperty.Name == UNO_NAME_RUBY_ADJUST)
             {
                 sal_Int16 nTmp = 0;
-                if(pProperties[nProp].Value >>= nTmp)
+                if(rProperty.Value >>= nTmp)
                     
pEntry->GetRubyAttr().SetAdjustment(static_cast<css::text::RubyAdjust>(nTmp));
             }
-            else if(pProperties[nProp].Name == UNO_NAME_RUBY_IS_ABOVE)
+            else if(rProperty.Name == UNO_NAME_RUBY_IS_ABOVE)
             {
-                bool bValue = !pProperties[nProp].Value.hasValue() ||
-                    *o3tl::doAccess<bool>(pProperties[nProp].Value);
+                bool bValue = !rProperty.Value.hasValue() ||
+                    *o3tl::doAccess<bool>(rProperty.Value);
                 pEntry->GetRubyAttr().SetPosition(bValue ? 0 : 1);
             }
-            else if(pProperties[nProp].Name == UNO_NAME_RUBY_POSITION)
+            else if(rProperty.Name == UNO_NAME_RUBY_POSITION)
             {
                 sal_Int16 nTmp = 0;
-                if(pProperties[nProp].Value >>= nTmp)
+                if(rProperty.Value >>= nTmp)
                     pEntry->GetRubyAttr().SetPosition( nTmp );
             }
         }
-        aList.insert(aList.begin() + nPos, std::move(pEntry));
+        aList.push_back(std::move(pEntry));
     }
     SwDoc* pDoc = m_pView->GetDocShell()->GetDoc();
     pDoc->SetRubyList( *rSh.GetCursor(), aList );
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to