sfx2/source/appl/appcfg.cxx                      |    6 
 sfx2/source/appl/appdispatchprovider.cxx         |    7 -
 sfx2/source/appl/appopen.cxx                     |   22 +--
 sfx2/source/appl/appserv.cxx                     |   19 +-
 sfx2/source/appl/appuno.cxx                      |   56 +++-----
 sfx2/source/appl/childwin.cxx                    |    2 
 sfx2/source/appl/fileobj.cxx                     |    6 
 sfx2/source/appl/helpdispatch.cxx                |    8 -
 sfx2/source/appl/helpinterceptor.cxx             |    9 -
 sfx2/source/appl/macroloader.cxx                 |    9 -
 sfx2/source/appl/newhelp.cxx                     |   12 -
 sfx2/source/appl/preventduplicateinteraction.cxx |   12 -
 sfx2/source/appl/sfxhelp.cxx                     |   12 -
 sfx2/source/bastyp/fltfnc.cxx                    |   73 ++++------
 sfx2/source/bastyp/frmhtmlw.cxx                  |    4 
 sfx2/source/control/charmapcontrol.cxx           |   20 --
 sfx2/source/control/recentdocsview.cxx           |    8 -
 sfx2/source/control/shell.cxx                    |    9 -
 sfx2/source/control/templatelocalview.cxx        |   20 --
 sfx2/source/control/unoctitm.cxx                 |    5 
 sfx2/source/dialog/backingcomp.cxx               |    5 
 sfx2/source/dialog/dinfdlg.cxx                   |  105 ++++++---------
 sfx2/source/dialog/dockwin.cxx                   |    6 
 sfx2/source/dialog/filedlghelper.cxx             |   31 +---
 sfx2/source/dialog/filtergrouping.cxx            |   11 -
 sfx2/source/dialog/mailmodel.cxx                 |   23 +--
 sfx2/source/dialog/versdlg.cxx                   |   20 +-
 sfx2/source/doc/DocumentMetadataAccess.cxx       |   29 +---
 sfx2/source/doc/SfxDocumentMetaData.cxx          |   20 +-
 sfx2/source/doc/docfac.cxx                       |    6 
 sfx2/source/doc/docfile.cxx                      |   29 +---
 sfx2/source/doc/docinf.cxx                       |    6 
 sfx2/source/doc/docinsert.cxx                    |   10 -
 sfx2/source/doc/docmacromode.cxx                 |   21 +--
 sfx2/source/doc/doctemplates.cxx                 |   54 +++----
 sfx2/source/doc/guisaveas.cxx                    |   87 +++++-------
 sfx2/source/doc/objmisc.cxx                      |   11 -
 sfx2/source/doc/objserv.cxx                      |   34 ++--
 sfx2/source/doc/objstor.cxx                      |  152 +++++++++------------
 sfx2/source/doc/printhelper.cxx                  |   32 +---
 sfx2/source/doc/sfxbasemodel.cxx                 |  115 ++++++----------
 sfx2/source/doc/templatedlg.cxx                  |   14 +-
 sfx2/source/doc/zoomitem.cxx                     |   14 +-
 sfx2/source/inet/inettbc.cxx                     |    9 -
 sfx2/source/notebookbar/SfxNotebookBar.cxx       |   25 +--
 sfx2/source/notify/eventsupplier.cxx             |  160 +++++++++--------------
 sfx2/source/sidebar/ResourceManager.cxx          |   32 +---
 sfx2/source/view/sfxbasecontroller.cxx           |   19 +-
 sfx2/source/view/viewprn.cxx                     |   56 +++-----
 49 files changed, 608 insertions(+), 847 deletions(-)

New commits:
commit 25b200ff79c71c831bc7e6fe8b1ec0b5315e96d6
Author:     Arkadiy Illarionov <qar...@gmail.com>
AuthorDate: Sun Jul 21 19:39:26 2019 +0300
Commit:     Arkadiy Illarionov <qar...@gmail.com>
CommitDate: Mon Jul 29 18:44:33 2019 +0200

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

diff --git a/sfx2/source/appl/appcfg.cxx b/sfx2/source/appl/appcfg.cxx
index 5ad63a9869f4..323c87432d55 100644
--- a/sfx2/source/appl/appcfg.cxx
+++ b/sfx2/source/appl/appcfg.cxx
@@ -22,6 +22,7 @@
 #include <com/sun/star/beans/PropertyValue.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/util/XFlushable.hpp>
+#include <comphelper/sequence.hxx>
 #include <osl/file.hxx>
 
 #include <stdlib.h>
@@ -335,10 +336,7 @@ void SfxApplication::GetOptions( SfxItemSet& rSet )
                         if 
(!aSecurityOptions.IsReadOnly(SvtSecurityOptions::EOption::SecureUrls))
                         {
                             css::uno::Sequence< OUString > seqURLs = 
aSecurityOptions.GetSecureURLs();
-                            std::vector<OUString> aList;
-                            sal_uInt32 nCount = seqURLs.getLength();
-                            for( sal_uInt32 nURL=0; nURL<nCount; ++nURL )
-                                aList.push_back(seqURLs[nURL]);
+                            auto aList = 
comphelper::sequenceToContainer<std::vector<OUString>>(seqURLs);
 
                             if( !rSet.Put( SfxStringListItem( 
rPool.GetWhich(SID_SECURE_URL), &aList ) ) )
                                 bRet = false;
diff --git a/sfx2/source/appl/appdispatchprovider.cxx 
b/sfx2/source/appl/appdispatchprovider.cxx
index edab1b761f32..5c197bf92eaf 100644
--- a/sfx2/source/appl/appdispatchprovider.cxx
+++ b/sfx2/source/appl/appdispatchprovider.cxx
@@ -164,10 +164,9 @@ Sequence< Reference < XDispatch > > SAL_CALL 
SfxAppDispatchProvider::queryDispat
 {
     sal_Int32 nCount = seqDescriptor.getLength();
     uno::Sequence< uno::Reference < frame::XDispatch > > lDispatcher(nCount);
-    for( sal_Int32 i=0; i<nCount; ++i )
-        lDispatcher[i] = queryDispatch( seqDescriptor[i].FeatureURL,
-                                              seqDescriptor[i].FrameName,
-                                              seqDescriptor[i].SearchFlags );
+    std::transform(seqDescriptor.begin(), seqDescriptor.end(), 
lDispatcher.begin(),
+        [this](const DispatchDescriptor& rDescr) -> 
uno::Reference<frame::XDispatch> {
+            return queryDispatch(rDescr.FeatureURL, rDescr.FrameName, 
rDescr.SearchFlags); });
     return lDispatcher;
 }
 
diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx
index e496b68c114f..1c778623b51f 100644
--- a/sfx2/source/appl/appopen.cxx
+++ b/sfx2/source/appl/appopen.cxx
@@ -44,6 +44,7 @@
 #include <rtl/ustring.hxx>
 
 #include <comphelper/processfactory.hxx>
+#include <comphelper/sequence.hxx>
 #include <comphelper/storagehelper.hxx>
 #include <comphelper/synchronousdispatch.hxx>
 
@@ -250,7 +251,7 @@ ErrCode CheckPasswd_Impl
                             pSet->ClearItem( SID_PASSWORD );
                             pSet->ClearItem( SID_ENCRYPTIONDATA );
 
-                            if ( aEncryptionData.getLength() > 0 )
+                            if ( aEncryptionData.hasElements() )
                             {
                                 pSet->Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, 
uno::makeAny( aEncryptionData ) ) );
 
@@ -866,10 +867,10 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
                     // get registered protocol handlers from configuration
                     Reference < XNameAccess > 
xAccess(officecfg::Office::ProtocolHandler::HandlerSet::get());
                     Sequence < OUString > aNames = xAccess->getElementNames();
-                    for ( sal_Int32 nName = 0; nName < aNames.getLength(); 
nName ++)
+                    for ( const auto& rName : aNames )
                     {
                         Reference < XPropertySet > xSet;
-                        Any aRet = xAccess->getByName( aNames[nName] );
+                        Any aRet = xAccess->getByName( rName );
                         aRet >>= xSet;
                         if ( xSet.is() )
                         {
@@ -1033,15 +1034,12 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq 
)
     // Any Referer (that was relevant in the above call to
     // SvtSecurityOptions::isSecureMacroUri) is no longer relevant, assuming
     // this "open" request is initiated directly by the user:
-    for (sal_Int32 i = 0; i != aArgs.getLength(); ++i) {
-        if (aArgs[i].Name == "Referer") {
-            ++i;
-            for (; i != aArgs.getLength(); ++i) {
-                aArgs[i - 1] = aArgs[i];
-            }
-            aArgs.realloc(aArgs.getLength()-1);
-            break;
-        }
+    auto pArg = std::find_if(aArgs.begin(), aArgs.end(),
+        [](const PropertyValue& rArg) { return rArg.Name == "Referer"; });
+    if (pArg != aArgs.end())
+    {
+        auto nIndex = static_cast<sal_Int32>(std::distance(aArgs.begin(), 
pArg));
+        comphelper::removeElementAt(aArgs, nIndex);
     }
 
     // TODO/LATER: either remove LinkItem or create an asynchronous process 
for it
diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx
index fe24e15b8cc4..a6f66d604c1c 100644
--- a/sfx2/source/appl/appserv.cxx
+++ b/sfx2/source/appl/appserv.cxx
@@ -49,6 +49,7 @@
 #include <comphelper/namedvaluecollection.hxx>
 #include <comphelper/processfactory.hxx>
 #include <comphelper/propertysequence.hxx>
+#include <comphelper/sequence.hxx>
 
 #include <svtools/addresstemplate.hxx>
 #include <svtools/miscopt.hxx>
@@ -875,11 +876,10 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
                     }
 
                     const Sequence<OUString> aModeNodeNames( 
aModesNode.getNodeNames() );
-                    const sal_Int32 nCount( aModeNodeNames.getLength() );
 
-                    for ( sal_Int32 nReadIndex = 0; nReadIndex < nCount; 
++nReadIndex )
+                    for ( const auto& rModeNodeName : aModeNodeNames )
                     {
-                        const utl::OConfigurationNode aModeNode( 
aModesNode.openNode( aModeNodeNames[nReadIndex] ) );
+                        const utl::OConfigurationNode aModeNode( 
aModesNode.openNode( rModeNodeName ) );
                         if ( !aModeNode.isValid() )
                             continue;
 
@@ -896,10 +896,9 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
 
                     // Backup visible toolbar list and hide all toolbars
                     Sequence<Reference<XUIElement>> aUIElements = 
xLayoutManager->getElements();
-                    for ( sal_Int32 i = 0; i < aUIElements.getLength(); i++ )
+                    for ( const Reference< XUIElement >& xUIElement : 
aUIElements )
                     {
-                        Reference< XUIElement > xUIElement( aUIElements[i] );
-                        Reference< XPropertySet > xPropertySet( 
aUIElements[i], UNO_QUERY );
+                        Reference< XPropertySet > xPropertySet( xUIElement, 
UNO_QUERY );
                         if ( xPropertySet.is() && xUIElement.is() )
                         {
                             try
@@ -969,13 +968,11 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
                     // Save settings
                     if ( pViewFrame == SfxViewFrame::Current() )
                     {
-                        css::uno::Sequence<OUString> aBackup( 
aBackupList.size() );
-                        for ( size_t i = 0; i < aBackupList.size(); ++i )
-                            aBackup[i] = aBackupList[i];
+                        css::uno::Sequence<OUString> aBackup( 
comphelper::containerToSequence(aBackupList) );
 
-                        for ( sal_Int32 nReadIndex = 0; nReadIndex < nCount; 
++nReadIndex )
+                        for ( const auto& rModeNodeName : aModeNodeNames )
                         {
-                            const utl::OConfigurationNode aModeNode( 
aModesNode.openNode( aModeNodeNames[nReadIndex] ) );
+                            const utl::OConfigurationNode aModeNode( 
aModesNode.openNode( rModeNodeName ) );
                             if ( !aModeNode.isValid() )
                                 continue;
 
diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx
index 1528f231ca39..2954eb45a522 100644
--- a/sfx2/source/appl/appuno.cxx
+++ b/sfx2/source/appl/appuno.cxx
@@ -250,9 +250,8 @@ void TransformParameters( sal_uInt16 nSlotId, const 
uno::Sequence<beans::Propert
 #endif
             // complex property; collect sub items from the parameter set and 
reconstruct complex item
             sal_uInt16 nFound=0;
-            for ( sal_Int32 n=0; n<nCount; n++ )
+            for ( const beans::PropertyValue& rPropValue : rArgs )
             {
-                const beans::PropertyValue& rPropValue = pPropsVal[n];
                 sal_uInt16 nSub;
                 for ( nSub=0; nSub<nSubCount; nSub++ )
                 {
@@ -313,23 +312,20 @@ void TransformParameters( sal_uInt16 nSlotId, const 
uno::Sequence<beans::Propert
         if ( nSubCount == 0 )
         {
             // "simple" (base type) argument
-            for ( sal_Int32 n=0; n<nCount; n++ )
+            auto aName = OUString( rArg.pName, strlen(rArg.pName), 
RTL_TEXTENCODING_UTF8 );
+            auto pProp = std::find_if(rArgs.begin(), rArgs.end(),
+                [&aName](const beans::PropertyValue& rProp) { return 
rProp.Name == aName; });
+            if (pProp != rArgs.end())
             {
-                const beans::PropertyValue& rProp = pPropsVal[n];
-                const OUString& rName = rProp.Name;
-                if ( rName == OUString( rArg.pName, strlen(rArg.pName), 
RTL_TEXTENCODING_UTF8 )  )
-                {
 #ifdef DBG_UTIL
-                    ++nFoundArgs;
+                ++nFoundArgs;
 #endif
-                    if( pItem->PutValue( rProp.Value, 0 ) )
-                        // only use successfully converted items
-                        rSet.Put( *pItem );
-                    else
-                    {
-                        SAL_WARN( "sfx", "Property not convertible: " << 
rArg.pName );
-                    }
-                    break;
+                if( pItem->PutValue( pProp->Value, 0 ) )
+                    // only use successfully converted items
+                    rSet.Put( *pItem );
+                else
+                {
+                    SAL_WARN( "sfx", "Property not convertible: " << 
rArg.pName );
                 }
             }
         }
@@ -337,9 +333,8 @@ void TransformParameters( sal_uInt16 nSlotId, const 
uno::Sequence<beans::Propert
         {
             // complex argument, could be passed in one struct
             bool bAsWholeItem = false;
-            for ( sal_Int32 n=0; n<nCount; n++ )
+            for ( const beans::PropertyValue& rProp : rArgs )
             {
-                const beans::PropertyValue& rProp = pPropsVal[n];
                 const OUString& rName = rProp.Name;
                 if ( rName == OUString(rArg.pName, strlen(rArg.pName), 
RTL_TEXTENCODING_UTF8) )
                 {
@@ -363,9 +358,8 @@ void TransformParameters( sal_uInt16 nSlotId, const 
uno::Sequence<beans::Propert
                 // only put item if at least one member was found and had the 
correct type
                 // (is this a good idea?! Should we ask for *all* members?)
                 bool bRet = false;
-                for ( sal_Int32 n=0; n<nCount; n++ )
+                for ( const beans::PropertyValue& rProp : rArgs )
                 {
-                    const beans::PropertyValue& rProp = pPropsVal[n];
                     for ( sal_uInt16 nSub=0; nSub<nSubCount; nSub++ )
                     {
                         // search sub item by name
@@ -408,9 +402,8 @@ void TransformParameters( sal_uInt16 nSlotId, const 
uno::Sequence<beans::Propert
     // f.e. "SaveAs" shouldn't support parameters not in the slot definition!)
     if ( nSlotId == SID_NEWWINDOW )
     {
-        for ( sal_Int32 n=0; n<nCount; n++ )
+        for ( const beans::PropertyValue& rProp : rArgs )
         {
-            const beans::PropertyValue& rProp = pPropsVal[n];
             const OUString& rName = rProp.Name;
             if ( rName == sFrame )
             {
@@ -429,12 +422,11 @@ void TransformParameters( sal_uInt16 nSlotId, const 
uno::Sequence<beans::Propert
     }
     else if ( bIsMediaDescriptor )
     {
-        for ( sal_Int32 n=0; n<nCount; n++ )
+        for ( const beans::PropertyValue& rProp : rArgs )
         {
 #ifdef DBG_UTIL
             ++nFoundArgs;
 #endif
-            const beans::PropertyValue& rProp = pPropsVal[n];
             const OUString& aName = rProp.Name;
             if ( aName == sModel )
                 rSet.Put( SfxUnoAnyItem( SID_DOCUMENT, rProp.Value ) );
@@ -865,17 +857,13 @@ void TransformParameters( sal_uInt16 nSlotId, const 
uno::Sequence<beans::Propert
         // transform parameter "OptionsPageURL" of slot "OptionsTreeDialog"
         if ( "OptionsTreeDialog" == OUString( pSlot->pUnoName, 
strlen(pSlot->pUnoName), RTL_TEXTENCODING_UTF8 ) )
         {
-            for ( sal_Int32 n = 0; n < nCount; ++n )
+            auto pProp = std::find_if(rArgs.begin(), rArgs.end(),
+                [](const PropertyValue& rProp) { return rProp.Name == 
"OptionsPageURL"; });
+            if (pProp != rArgs.end())
             {
-                const PropertyValue& rProp = pPropsVal[n];
-                OUString sName( rProp.Name );
-                if ( sName == "OptionsPageURL" )
-                {
-                    OUString sURL;
-                    if ( rProp.Value >>= sURL )
-                        rSet.Put( SfxStringItem( SID_OPTIONS_PAGEURL, sURL ) );
-                    break;
-                }
+                OUString sURL;
+                if ( pProp->Value >>= sURL )
+                    rSet.Put( SfxStringItem( SID_OPTIONS_PAGEURL, sURL ) );
             }
         }
     }
diff --git a/sfx2/source/appl/childwin.cxx b/sfx2/source/appl/childwin.cxx
index cd5686e8154a..62838f4ae240 100644
--- a/sfx2/source/appl/childwin.cxx
+++ b/sfx2/source/appl/childwin.cxx
@@ -390,7 +390,7 @@ void 
SfxChildWindow::InitializeChildWinFactory_Impl(sal_uInt16 nId, SfxChildWinI
     css::uno::Sequence < css::beans::NamedValue > aSeq = 
xWinOpt->GetUserData();
 
     OUString aTmp;
-    if ( aSeq.getLength() )
+    if ( aSeq.hasElements() )
         aSeq[0].Value >>= aTmp;
 
     OUString aWinData( aTmp );
diff --git a/sfx2/source/appl/fileobj.cxx b/sfx2/source/appl/fileobj.cxx
index fe4d1e463119..799fbb2ffdbb 100644
--- a/sfx2/source/appl/fileobj.cxx
+++ b/sfx2/source/appl/fileobj.cxx
@@ -225,11 +225,11 @@ static OUString impl_getFilter( const OUString& _rURL )
             if ( !sType.isEmpty() )
             {
                 // Honor a selected/detected filter.
-                for (sal_Int32 i=0; i < aDescrList.getLength(); ++i)
+                for (const auto& rDescr : aDescrList)
                 {
-                    if (aDescrList[i].Name == "FilterName")
+                    if (rDescr.Name == "FilterName")
                     {
-                        if (aDescrList[i].Value >>= sFilter)
+                        if (rDescr.Value >>= sFilter)
                             break;
                     }
                 }
diff --git a/sfx2/source/appl/helpdispatch.cxx 
b/sfx2/source/appl/helpdispatch.cxx
index 809078add4d0..a53c5e5ed622 100644
--- a/sfx2/source/appl/helpdispatch.cxx
+++ b/sfx2/source/appl/helpdispatch.cxx
@@ -57,14 +57,12 @@ void SAL_CALL HelpDispatch_Impl::dispatch(
     // search for a keyword (dispatch from the basic ide)
     bool bHasKeyword = false;
     OUString sKeyword;
-    const PropertyValue* pBegin = aArgs.getConstArray();
-    const PropertyValue* pEnd   = pBegin + aArgs.getLength();
-    for ( ; pBegin != pEnd; ++pBegin )
+    for ( const PropertyValue& rArg : aArgs )
     {
-        if ( pBegin->Name == "HelpKeyword" )
+        if ( rArg.Name == "HelpKeyword" )
         {
             OUString sHelpKeyword;
-            if ( ( pBegin->Value >>= sHelpKeyword ) && !sHelpKeyword.isEmpty() 
)
+            if ( ( rArg.Value >>= sHelpKeyword ) && !sHelpKeyword.isEmpty() )
             {
                 sKeyword = sHelpKeyword;
                 bHasKeyword = !sKeyword.isEmpty();
diff --git a/sfx2/source/appl/helpinterceptor.cxx 
b/sfx2/source/appl/helpinterceptor.cxx
index 0b6034a6c0da..90f95151da26 100644
--- a/sfx2/source/appl/helpinterceptor.cxx
+++ b/sfx2/source/appl/helpinterceptor.cxx
@@ -132,12 +132,9 @@ Sequence < Reference < XDispatch > > SAL_CALL 
HelpInterceptor_Impl::queryDispatc
 
 {
     Sequence< Reference< XDispatch > > aReturn( aDescripts.getLength() );
-    Reference< XDispatch >* pReturn = aReturn.getArray();
-    const 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 DispatchDescriptor& rDescr) -> Reference<XDispatch> {
+            return queryDispatch(rDescr.FeatureURL, rDescr.FrameName, 
rDescr.SearchFlags); });
     return aReturn;
 }
 
diff --git a/sfx2/source/appl/macroloader.cxx b/sfx2/source/appl/macroloader.cxx
index 970ff56b5083..1aeff343e275 100644
--- a/sfx2/source/appl/macroloader.cxx
+++ b/sfx2/source/appl/macroloader.cxx
@@ -53,7 +53,7 @@ using namespace ::com::sun::star::util;
 SfxMacroLoader::SfxMacroLoader(const css::uno::Sequence< css::uno::Any >& 
aArguments)
 {
     Reference < XFrame > xFrame;
-    if ( aArguments.getLength() )
+    if ( aArguments.hasElements() )
     {
         aArguments[0] >>= xFrame;
         m_xFrame = xFrame;
@@ -114,10 +114,9 @@ uno::Sequence< uno::Reference<frame::XDispatch> > SAL_CALL
 {
     sal_Int32 nCount = seqDescriptor.getLength();
     uno::Sequence< uno::Reference<frame::XDispatch> > lDispatcher(nCount);
-    for( sal_Int32 i=0; i<nCount; ++i )
-        lDispatcher[i] = queryDispatch( seqDescriptor[i].FeatureURL,
-                                              seqDescriptor[i].FrameName,
-                                              seqDescriptor[i].SearchFlags );
+    std::transform(seqDescriptor.begin(), seqDescriptor.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/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx
index 6dbd7b82f6eb..a491d3ec02a2 100644
--- a/sfx2/source/appl/newhelp.cxx
+++ b/sfx2/source/appl/newhelp.cxx
@@ -656,10 +656,10 @@ void IndexTabPage_Impl::InitializeIndex()
 
                     sal_uInt32 nRefListLen = aRefList.getLength();
 
-                    DBG_ASSERT( aAnchorList.getLength(), 
"*IndexTabPage_Impl::InitializeIndex(): AnchorList is empty!" );
+                    DBG_ASSERT( aAnchorList.hasElements(), 
"*IndexTabPage_Impl::InitializeIndex(): AnchorList is empty!" );
                     DBG_ASSERT( nRefListLen, 
"*IndexTabPage_Impl::InitializeIndex(): RefList is empty!" );
 
-                    if ( aAnchorList.getLength() && nRefListLen )
+                    if ( aAnchorList.hasElements() && nRefListLen )
                     {
                         if ( aAnchorList[0].getLength() > 0 )
                         {
@@ -1121,9 +1121,8 @@ static void GetBookmarkEntry_Impl
     OUString& rURL
 )
 {
-    for ( int i = 0; i < aBookmarkEntry.getLength(); i++ )
+    for ( const PropertyValue& aValue : aBookmarkEntry )
     {
-        PropertyValue aValue = aBookmarkEntry[i];
         if ( aValue.Name == HISTORY_PROPERTYNAME_URL )
             aValue.Value >>= rURL;
         else if ( aValue.Name == HISTORY_PROPERTYNAME_TITLE )
@@ -1279,10 +1278,9 @@ 
BookmarksTabPage_Impl::BookmarksTabPage_Impl(vcl::Window* pParent, SfxHelpIndexW
     OUString aTitle;
     OUString aURL;
 
-    sal_uInt32 i, nCount = aBookmarkSeq.getLength();
-    for ( i = 0; i < nCount; ++i )
+    for ( auto& rBookmark : aBookmarkSeq )
     {
-        GetBookmarkEntry_Impl( aBookmarkSeq[i], aTitle, aURL );
+        GetBookmarkEntry_Impl( rBookmark, aTitle, aURL );
         AddBookmarks( aTitle, aURL );
     }
 }
diff --git a/sfx2/source/appl/preventduplicateinteraction.cxx 
b/sfx2/source/appl/preventduplicateinteraction.cxx
index 3f34743891d3..8c9796491b8f 100644
--- a/sfx2/source/appl/preventduplicateinteraction.cxx
+++ b/sfx2/source/appl/preventduplicateinteraction.cxx
@@ -104,11 +104,9 @@ void SAL_CALL PreventDuplicateInteraction::handle(const 
css::uno::Reference< css
     else
     {
         const css::uno::Sequence< css::uno::Reference< 
css::task::XInteractionContinuation > > lContinuations = 
xRequest->getContinuations();
-        sal_Int32 c = lContinuations.getLength();
-        sal_Int32 i = 0;
-        for (i=0; i<c; ++i)
+        for (const auto& rContinuation : lContinuations)
         {
-            css::uno::Reference< css::task::XInteractionAbort > 
xAbort(lContinuations[i], css::uno::UNO_QUERY);
+            css::uno::Reference< css::task::XInteractionAbort > 
xAbort(rContinuation, css::uno::UNO_QUERY);
             if (xAbort.is())
             {
                 xAbort->select();
@@ -151,11 +149,9 @@ sal_Bool SAL_CALL 
PreventDuplicateInteraction::handleInteractionRequest( const c
     else
     {
         const css::uno::Sequence< css::uno::Reference< 
css::task::XInteractionContinuation > > lContinuations = 
xRequest->getContinuations();
-        sal_Int32 c = lContinuations.getLength();
-        sal_Int32 i = 0;
-        for (i=0; i<c; ++i)
+        for (const auto& rContinuation : lContinuations)
         {
-            css::uno::Reference< css::task::XInteractionAbort > 
xAbort(lContinuations[i], css::uno::UNO_QUERY);
+            css::uno::Reference< css::task::XInteractionAbort > 
xAbort(rContinuation, css::uno::UNO_QUERY);
             if (xAbort.is())
             {
                 xAbort->select();
diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx
index d6fac42bd6de..409edaf57e16 100644
--- a/sfx2/source/appl/sfxhelp.cxx
+++ b/sfx2/source/appl/sfxhelp.cxx
@@ -481,14 +481,10 @@ OUString SfxHelp::GetHelpModuleName_Impl(const OUString& 
rHelpID)
                     
ModuleManager::create(::comphelper::getProcessComponentContext()) );
                 Sequence< PropertyValue > lProps;
                 xModuleManager->getByName( aModuleIdentifier ) >>= lProps;
-                for ( sal_Int32 i = 0; i < lProps.getLength(); ++i )
-                {
-                    if ( lProps[i].Name == "ooSetupFactoryShortName" )
-                    {
-                        lProps[i].Value >>= aFactoryShortName;
-                        break;
-                    }
-                }
+                auto pProp = std::find_if(lProps.begin(), lProps.end(),
+                    [](const PropertyValue& rProp) { return rProp.Name == 
"ooSetupFactoryShortName"; });
+                if (pProp != lProps.end())
+                    pProp->Value >>= aFactoryShortName;
             }
             catch (const Exception&)
             {
diff --git a/sfx2/source/bastyp/fltfnc.cxx b/sfx2/source/bastyp/fltfnc.cxx
index f8772610617d..b5970c7ac874 100644
--- a/sfx2/source/bastyp/fltfnc.cxx
+++ b/sfx2/source/bastyp/fltfnc.cxx
@@ -434,11 +434,11 @@ ErrCode  SfxFilterMatcher::GuessFilterControlDefaultUI( 
SfxMedium& rMedium, std:
             uno::Sequence< beans::PropertyValue > lDescriptor = 
aDescriptor.getAsConstPropertyValueList();
             sTypeName = xDetection->queryTypeByDescriptor(lDescriptor, true); 
// lDescriptor is used as In/Out param ... don't use 
aDescriptor.getAsConstPropertyValueList() directly!
 
-            for (sal_Int32 i = 0; i < lDescriptor.getLength(); ++i)
+            for (const auto& rProp : lDescriptor)
             {
-                if (lDescriptor[i].Name == "FilterName")
+                if (rProp.Name == "FilterName")
                     // Type detection picked a preferred filter for this 
format.
-                    aFilterName = lDescriptor[i].Value.get<OUString>();
+                    aFilterName = rProp.Value.get<OUString>();
             }
         }
         // no stream exists => try flat detection without preselection as 
fallback
@@ -926,49 +926,47 @@ void SfxFilterContainer::ReadSingleFilter_Impl(
     bool bEnabled = true         ;
 
     // first get directly available properties
-    sal_Int32 nFilterPropertyCount = lFilterProperties.getLength();
-    sal_Int32 nFilterProperty      = 0                            ;
-    for( nFilterProperty=0; nFilterProperty<nFilterPropertyCount; 
++nFilterProperty )
+    for( const auto& rFilterProperty : lFilterProperties )
     {
-        if ( lFilterProperties[nFilterProperty].Name == "FileFormatVersion" )
+        if ( rFilterProperty.Name == "FileFormatVersion" )
         {
-            lFilterProperties[nFilterProperty].Value >>= nFormatVersion;
+            rFilterProperty.Value >>= nFormatVersion;
         }
-        else if ( lFilterProperties[nFilterProperty].Name == "TemplateName" )
+        else if ( rFilterProperty.Name == "TemplateName" )
         {
-            lFilterProperties[nFilterProperty].Value >>= sDefaultTemplate;
+            rFilterProperty.Value >>= sDefaultTemplate;
         }
-        else if ( lFilterProperties[nFilterProperty].Name == "Flags" )
+        else if ( rFilterProperty.Name == "Flags" )
         {
             sal_Int32 nTmp(0);
-            lFilterProperties[nFilterProperty].Value >>= nTmp;
+            rFilterProperty.Value >>= nTmp;
             assert((nTmp & ~o3tl::typed_flags<SfxFilterFlags>::mask) == 0);
             nFlags = static_cast<SfxFilterFlags>(nTmp);
         }
-        else if ( lFilterProperties[nFilterProperty].Name == "UIName" )
+        else if ( rFilterProperty.Name == "UIName" )
         {
-            lFilterProperties[nFilterProperty].Value >>= sUIName;
+            rFilterProperty.Value >>= sUIName;
         }
-        else if ( lFilterProperties[nFilterProperty].Name == "UserData" )
+        else if ( rFilterProperty.Name == "UserData" )
         {
             uno::Sequence< OUString > lUserData;
-            lFilterProperties[nFilterProperty].Value >>= lUserData;
+            rFilterProperty.Value >>= lUserData;
             sUserData = implc_convertStringlistToString( lUserData, ',', 
OUString() );
         }
-        else if ( lFilterProperties[nFilterProperty].Name == "DocumentService" 
)
+        else if ( rFilterProperty.Name == "DocumentService" )
         {
-            lFilterProperties[nFilterProperty].Value >>= sServiceName;
+            rFilterProperty.Value >>= sServiceName;
         }
-        else if (lFilterProperties[nFilterProperty].Name == "ExportExtension")
+        else if (rFilterProperty.Name == "ExportExtension")
         {
             // Extension preferred by the filter.  This takes precedence
             // over those that are given in the file format type.
-            lFilterProperties[nFilterProperty].Value >>= sExtension;
+            rFilterProperty.Value >>= sExtension;
             sExtension = "*." + sExtension;
         }
-        else if ( lFilterProperties[nFilterProperty].Name == "Type" )
+        else if ( rFilterProperty.Name == "Type" )
         {
-            lFilterProperties[nFilterProperty].Value >>= sType;
+            rFilterProperty.Value >>= sType;
             // Try to get filter .. but look for any exceptions!
             // May be filter was deleted by another thread ...
             try
@@ -984,39 +982,37 @@ void SfxFilterContainer::ReadSingleFilter_Impl(
             if( aResult >>= lTypeProperties )
             {
                 // get indirect available properties then (types)
-                sal_Int32 nTypePropertyCount = lTypeProperties.getLength();
-                sal_Int32 nTypeProperty      = 0                          ;
-                for( nTypeProperty=0; nTypeProperty<nTypePropertyCount; 
++nTypeProperty )
+                for( const auto& rTypeProperty : lTypeProperties )
                 {
-                    if ( lTypeProperties[nTypeProperty].Name == 
"ClipboardFormat" )
+                    if ( rTypeProperty.Name == "ClipboardFormat" )
                     {
-                        lTypeProperties[nTypeProperty].Value >>= sHumanName;
+                        rTypeProperty.Value >>= sHumanName;
                     }
-                    else if ( lTypeProperties[nTypeProperty].Name == 
"MediaType" )
+                    else if ( rTypeProperty.Name == "MediaType" )
                     {
-                        lTypeProperties[nTypeProperty].Value >>= sMimeType;
+                        rTypeProperty.Value >>= sMimeType;
                     }
-                    else if ( lTypeProperties[nTypeProperty].Name == 
"Extensions" )
+                    else if ( rTypeProperty.Name == "Extensions" )
                     {
                         if (sExtension.isEmpty())
                         {
                             uno::Sequence< OUString > lExtensions;
-                            lTypeProperties[nTypeProperty].Value >>= 
lExtensions;
+                            rTypeProperty.Value >>= lExtensions;
                             sExtension = implc_convertStringlistToString( 
lExtensions, ';', "*." );
                         }
                     }
-                    else if ( lTypeProperties[nTypeProperty].Name == 
"URLPattern" )
+                    else if ( rTypeProperty.Name == "URLPattern" )
                     {
                             uno::Sequence< OUString > lPattern;
-                            lTypeProperties[nTypeProperty].Value >>= lPattern;
+                            rTypeProperty.Value >>= lPattern;
                             sPattern = implc_convertStringlistToString( 
lPattern, ';', OUString() );
                     }
                 }
             }
         }
-        else if ( lFilterProperties[nFilterProperty].Name == "Enabled" )
+        else if ( rFilterProperty.Name == "Enabled" )
         {
-            lFilterProperties[nFilterProperty].Value >>= bEnabled;
+            rFilterProperty.Value >>= bEnabled;
         }
 
     }
@@ -1109,7 +1105,7 @@ void SfxFilterContainer::ReadFilters_Impl( bool bUpdate )
         {
             // select right query to get right set of filters for search module
             uno::Sequence< OUString > lFilterNames = 
xFilterCFG->getElementNames();
-            if ( lFilterNames.getLength() )
+            if ( lFilterNames.hasElements() )
             {
                 // If list of filters already exist ...
                 // ReadExternalFilters must work in update mode.
@@ -1126,13 +1122,10 @@ void SfxFilterContainer::ReadFilters_Impl( bool bUpdate 
)
                 }
 
                 // get all properties of filters ... put it into the filter 
container
-                sal_Int32 nFilterCount = lFilterNames.getLength();
-                sal_Int32 nFilter=0;
-                for( nFilter=0; nFilter<nFilterCount; ++nFilter )
+                for( const OUString& sFilterName : lFilterNames )
                 {
                     // Try to get filter .. but look for any exceptions!
                     // May be filter was deleted by another thread ...
-                    OUString sFilterName = lFilterNames[nFilter];
                     ReadSingleFilter_Impl( sFilterName, xTypeCFG, xFilterCFG, 
bUpdate );
                 }
             }
diff --git a/sfx2/source/bastyp/frmhtmlw.cxx b/sfx2/source/bastyp/frmhtmlw.cxx
index d074138ce56a..0cff220f48ae 100644
--- a/sfx2/source/bastyp/frmhtmlw.cxx
+++ b/sfx2/source/bastyp/frmhtmlw.cxx
@@ -212,11 +212,11 @@ void SfxFrameHTMLWriter::Out_DocInfo( SvStream& rStrm, 
const OUString& rBaseURL,
         xUserDefinedProps->getPropertySetInfo();
     DBG_ASSERT(xPropInfo.is(), "UserDefinedProperties Info is null");
     uno::Sequence<beans::Property> props = xPropInfo->getProperties();
-    for (sal_Int32 i = 0; i < props.getLength(); ++i)
+    for (const auto& rProp : props)
     {
         try
         {
-            OUString name = props[i].Name;
+            OUString name = rProp.Name;
             uno::Any aStr = xConverter->convertToSimpleType(
                     xUserDefinedProps->getPropertyValue(name),
                     uno::TypeClass_STRING);
diff --git a/sfx2/source/control/charmapcontrol.cxx 
b/sfx2/source/control/charmapcontrol.cxx
index 6534a9b1efc6..c28a5d75108c 100644
--- a/sfx2/source/control/charmapcontrol.cxx
+++ b/sfx2/source/control/charmapcontrol.cxx
@@ -106,17 +106,11 @@ void SfxCharmapCtrl::getFavCharacterList()
 {
     //retrieve recent character list
     css::uno::Sequence< OUString > rFavCharList( 
officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterList::get() );
-    for (int i = 0; i < rFavCharList.getLength(); ++i)
-    {
-        maFavCharList.push_back(rFavCharList[i]);
-    }
+    std::copy(rFavCharList.begin(), rFavCharList.end(), 
std::back_inserter(maFavCharList));
 
     //retrieve recent character font list
     css::uno::Sequence< OUString > rFavCharFontList( 
officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterFontList::get() 
);
-    for (int i = 0; i < rFavCharFontList.getLength(); ++i)
-    {
-        maFavCharFontList.push_back(rFavCharFontList[i]);
-    }
+    std::copy(rFavCharFontList.begin(), rFavCharFontList.end(), 
std::back_inserter(maFavCharFontList));
 }
 
 
@@ -146,17 +140,11 @@ void SfxCharmapCtrl::getRecentCharacterList()
 {
     //retrieve recent character list
     css::uno::Sequence< OUString > rRecentCharList( 
officecfg::Office::Common::RecentCharacters::RecentCharacterList::get() );
-    for (int i = 0; i < rRecentCharList.getLength(); ++i)
-    {
-        maRecentCharList.push_back(rRecentCharList[i]);
-    }
+    std::copy(rRecentCharList.begin(), rRecentCharList.end(), 
std::back_inserter(maRecentCharList));
 
     //retrieve recent character font list
     css::uno::Sequence< OUString > rRecentCharFontList( 
officecfg::Office::Common::RecentCharacters::RecentCharacterFontList::get() );
-    for (int i = 0; i < rRecentCharFontList.getLength(); ++i)
-    {
-        maRecentCharFontList.push_back(rRecentCharFontList[i]);
-    }
+    std::copy(rRecentCharFontList.begin(), rRecentCharFontList.end(), 
std::back_inserter(maRecentCharFontList));
 }
 
 
diff --git a/sfx2/source/control/recentdocsview.cxx 
b/sfx2/source/control/recentdocsview.cxx
index 51674e4e808d..46314a428ab2 100644
--- a/sfx2/source/control/recentdocsview.cxx
+++ b/sfx2/source/control/recentdocsview.cxx
@@ -240,14 +240,14 @@ void RecentDocsView::Reload()
         OUString aTitle;
         BitmapEx aThumbnail;
 
-        for ( int j = 0; j < rRecentEntry.getLength(); j++ )
+        for ( const auto& rProp : rRecentEntry )
         {
-            Any a = rRecentEntry[j].Value;
+            Any a = rProp.Value;
 
-            if (rRecentEntry[j].Name == "URL")
+            if (rProp.Name == "URL")
                 a >>= aURL;
             //fdo#74834: only load thumbnail if the corresponding option is 
not disabled in the configuration
-            else if (rRecentEntry[j].Name == "Thumbnail" && 
officecfg::Office::Common::History::RecentDocsThumbnail::get())
+            else if (rProp.Name == "Thumbnail" && 
officecfg::Office::Common::History::RecentDocsThumbnail::get())
             {
                 OUString aBase64;
                 a >>= aBase64;
diff --git a/sfx2/source/control/shell.cxx b/sfx2/source/control/shell.cxx
index 52c59572daa7..abdb828d7721 100644
--- a/sfx2/source/control/shell.cxx
+++ b/sfx2/source/control/shell.cxx
@@ -602,19 +602,20 @@ void SfxShell::VerbExec(SfxRequest& rReq)
 
     bool bReadOnly = pViewShell->GetObjectShell()->IsReadOnly();
     css::uno::Sequence < css::embed::VerbDescriptor > aList = 
pViewShell->GetVerbs();
-    for (sal_Int32 n=0, nVerb=0; n<aList.getLength(); n++)
+    sal_Int32 nVerb = 0;
+    for (const auto& rVerb : aList)
     {
         // check for ReadOnly verbs
-        if ( bReadOnly && !(aList[n].VerbAttributes & 
embed::VerbAttributes::MS_VERBATTR_NEVERDIRTIES) )
+        if ( bReadOnly && !(rVerb.VerbAttributes & 
embed::VerbAttributes::MS_VERBATTR_NEVERDIRTIES) )
             continue;
 
         // check for verbs that shouldn't appear in the menu
-        if ( !(aList[n].VerbAttributes & 
embed::VerbAttributes::MS_VERBATTR_ONCONTAINERMENU) )
+        if ( !(rVerb.VerbAttributes & 
embed::VerbAttributes::MS_VERBATTR_ONCONTAINERMENU) )
             continue;
 
         if (nId == SID_VERB_START + nVerb++)
         {
-            pViewShell->DoVerb(aList[n].VerbID);
+            pViewShell->DoVerb(rVerb.VerbID);
             rReq.Done();
             return;
         }
diff --git a/sfx2/source/control/templatelocalview.cxx 
b/sfx2/source/control/templatelocalview.cxx
index 982811f93fc4..500bacca768d 100644
--- a/sfx2/source/control/templatelocalview.cxx
+++ b/sfx2/source/control/templatelocalview.cxx
@@ -438,14 +438,8 @@ bool TemplateLocalView::IsDefaultTemplate(const OUString& 
rPath)
     SvtModuleOptions aModOpt;
     const css::uno::Sequence<OUString> &aServiceNames = 
aModOpt.GetAllServiceNames();
 
-    for( sal_Int32 i=0, nCount = aServiceNames.getLength(); i < nCount; ++i )
-    {
-        const OUString defaultPath = SfxObjectFactory::GetStandardTemplate( 
aServiceNames[i] );
-        if(defaultPath.match(rPath))
-            return true;
-    }
-
-    return false;
+    return std::any_of(aServiceNames.begin(), aServiceNames.end(), 
[&rPath](const OUString& rName) {
+        return SfxObjectFactory::GetStandardTemplate(rName).match(rPath); });
 }
 
 BitmapEx TemplateLocalView::getDefaultThumbnail( const OUString& rPath )
@@ -1301,14 +1295,8 @@ bool SfxTemplateLocalView::IsDefaultTemplate(const 
OUString& rPath)
     SvtModuleOptions aModOpt;
     const css::uno::Sequence<OUString> &aServiceNames = 
aModOpt.GetAllServiceNames();
 
-    for( sal_Int32 i=0, nCount = aServiceNames.getLength(); i < nCount; ++i )
-    {
-        const OUString defaultPath = SfxObjectFactory::GetStandardTemplate( 
aServiceNames[i] );
-        if(defaultPath.match(rPath))
-            return true;
-    }
-
-    return false;
+    return std::any_of(aServiceNames.begin(), aServiceNames.end(), 
[&rPath](const OUString& rName) {
+        return SfxObjectFactory::GetStandardTemplate(rName).match(rPath); });
 }
 
 void SfxTemplateLocalView::RemoveDefaultTemplateIcon(const OUString& rPath)
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
index e4e1b8d5f691..a321248cdc9b 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -667,9 +667,8 @@ void SfxDispatchController_Impl::dispatch( const 
css::util::URL& aURL,
     {
         sal_uInt32 nIndex( lNewArgs.getLength() );
 
-        lNewArgs.realloc( lNewArgs.getLength()+aAddArgs.size() );
-        for ( sal_uInt32 i = 0; i < nAddArgs; i++ )
-            lNewArgs[nIndex++] = aAddArgs[i];
+        lNewArgs.realloc( nIndex + nAddArgs );
+        std::copy(aAddArgs.begin(), aAddArgs.end(), 
std::next(lNewArgs.begin(), nIndex));
     }
 
     // Overwrite possible detected synchron argument, if real listener exists 
(currently no other way)
diff --git a/sfx2/source/dialog/backingcomp.cxx 
b/sfx2/source/dialog/backingcomp.cxx
index ccb5f05962f1..22df8b24937a 100644
--- a/sfx2/source/dialog/backingcomp.cxx
+++ b/sfx2/source/dialog/backingcomp.cxx
@@ -711,8 +711,9 @@ css::uno::Sequence < css::uno::Reference< 
css::frame::XDispatch > > SAL_CALL Bac
     sal_Int32 nCount = seqDescripts.getLength();
     css::uno::Sequence < css::uno::Reference < 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 css::frame::DispatchDescriptor& rDesc) -> 
css::uno::Reference<XDispatch> {
+            return queryDispatch(rDesc.FeatureURL, rDesc.FrameName, 
rDesc.SearchFlags); });
 
     return lDispatcher;
 }
diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index 70669200b5a8..5c8d83be5398 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -236,19 +236,17 @@ SfxDocumentInfoItem::SfxDocumentInfoItem( const OUString& 
rFile,
         {
             Reference < beans::XPropertySet > xSet( xContainer, UNO_QUERY );
             const Sequence< beans::Property > lProps = 
xSet->getPropertySetInfo()->getProperties();
-            const beans::Property* pProps = lProps.getConstArray();
-            sal_Int32 nCount = lProps.getLength();
-            for ( sal_Int32 i = 0; i < nCount; ++i )
+            for ( const beans::Property& rProp : lProps )
             {
                 // "fix" property? => not a custom property => ignore it!
-                if (!(pProps[i].Attributes & 
css::beans::PropertyAttribute::REMOVABLE))
+                if (!(rProp.Attributes & 
css::beans::PropertyAttribute::REMOVABLE))
                 {
                     SAL_WARN( "sfx.dialog", "non-removable user-defined 
property?");
                     continue;
                 }
 
-                uno::Any aValue = xSet->getPropertyValue(pProps[i].Name);
-                std::unique_ptr<CustomProperty> pProp(new CustomProperty( 
pProps[i].Name, aValue ));
+                uno::Any aValue = xSet->getPropertyValue(rProp.Name);
+                std::unique_ptr<CustomProperty> pProp(new CustomProperty( 
rProp.Name, aValue ));
                 m_aCustomProperties.push_back( std::move(pProp) );
             }
         }
@@ -392,13 +390,11 @@ void SfxDocumentInfoItem::UpdateDocumentInfo(
         Reference < beans::XPropertySet > xSet( xContainer, UNO_QUERY );
         Reference< beans::XPropertySetInfo > xSetInfo = 
xSet->getPropertySetInfo();
         const Sequence< beans::Property > lProps = xSetInfo->getProperties();
-        const beans::Property* pProps = lProps.getConstArray();
-        sal_Int32 nCount = lProps.getLength();
-        for ( sal_Int32 j = 0; j < nCount; ++j )
+        for ( const beans::Property& rProp : lProps )
         {
-            if (pProps[j].Attributes & 
css::beans::PropertyAttribute::REMOVABLE)
+            if (rProp.Attributes & css::beans::PropertyAttribute::REMOVABLE)
             {
-                xContainer->removeProperty( pProps[j].Name );
+                xContainer->removeProperty( rProp.Name );
             }
         }
 
@@ -854,7 +850,7 @@ void SfxDocumentPage::ImplCheckPasswordState()
         else
              break;
 
-        if (!aEncryptionData.getLength())
+        if (!aEncryptionData.hasElements())
              break;
         m_xChangePassBtn->set_sensitive(true);
         return;
@@ -1033,17 +1029,17 @@ void SfxDocumentPage::Reset( const SfxItemSet* rSet )
     if ( rInfoItem.isCmisDocument( ) )
     {
         uno::Sequence< document::CmisProperty > aCmisProps = 
rInfoItem.GetCmisProperties();
-        for ( sal_Int32 i = 0; i < aCmisProps.getLength(); i++ )
+        for ( const auto& rCmisProp : aCmisProps )
         {
-            if ( aCmisProps[i].Id == "cmis:contentStreamLength" &&
+            if ( rCmisProp.Id == "cmis:contentStreamLength" &&
                  aSizeText == m_aUnknownSize )
             {
                 Sequence< sal_Int64 > seqValue;
-                aCmisProps[i].Value >>= seqValue;
+                rCmisProp.Value >>= seqValue;
                 SvNumberFormatter aNumberFormatter( 
::comphelper::getProcessComponentContext(),
                         
Application::GetSettings().GetLanguageTag().getLanguageType() );
                 sal_uInt32 nIndex = aNumberFormatter.GetFormatIndex( 
NF_NUMBER_SYSTEM );
-                if ( seqValue.getLength( ) > 0 )
+                if ( seqValue.hasElements() )
                 {
                     OUString sValue;
                     aNumberFormatter.GetInputLineString( seqValue[0], nIndex, 
sValue );
@@ -1053,24 +1049,24 @@ void SfxDocumentPage::Reset( const SfxItemSet* rSet )
 
             util::DateTime uDT;
             OUString emptyDate = ConvertDateTime_Impl( "", uDT, rLocaleWrapper 
);
-            if ( aCmisProps[i].Id == "cmis:creationDate" &&
+            if ( rCmisProp.Id == "cmis:creationDate" &&
                  (m_xCreateValFt->get_label() == emptyDate ||
                   m_xCreateValFt->get_label().isEmpty()))
             {
                 Sequence< util::DateTime > seqValue;
-                aCmisProps[i].Value >>= seqValue;
-                if ( seqValue.getLength( ) > 0 )
+                rCmisProp.Value >>= seqValue;
+                if ( seqValue.hasElements() )
                 {
                     m_xCreateValFt->set_label( ConvertDateTime_Impl( "", 
seqValue[0], rLocaleWrapper ) );
                 }
             }
-            if ( aCmisProps[i].Id == "cmis:lastModificationDate" &&
+            if ( rCmisProp.Id == "cmis:lastModificationDate" &&
                  (m_xChangeValFt->get_label() == emptyDate ||
                   m_xChangeValFt->get_label().isEmpty()))
             {
                 Sequence< util::DateTime > seqValue;
-                aCmisProps[i].Value >>= seqValue;
-                if ( seqValue.getLength( ) > 0 )
+                rCmisProp.Value >>= seqValue;
+                if ( seqValue.hasElements() )
                 {
                     m_xChangeValFt->set_label( ConvertDateTime_Impl( "", 
seqValue[0], rLocaleWrapper ) );
                 }
@@ -1882,12 +1878,11 @@ IMPL_LINK_NOARG(SfxCustomPropertiesPage, AddHdl, 
weld::Button&, void)
     // each time SfxDocumentInfoItem destructor is called
     SfxDocumentInfoItem pInfo;
     Sequence< beans::PropertyValue > aPropertySeq = 
m_xPropertiesCtrl->GetCustomProperties();
-    sal_Int32 i = 0, nCount = aPropertySeq.getLength();
-    for ( ; i < nCount; ++i )
+    for ( const auto& rProperty : aPropertySeq )
     {
-        if ( !aPropertySeq[i].Name.isEmpty() )
+        if ( !rProperty.Name.isEmpty() )
         {
-            pInfo.AddCustomProperty( aPropertySeq[i].Name, 
aPropertySeq[i].Value );
+            pInfo.AddCustomProperty( rProperty.Name, rProperty.Value );
         }
     }
 
@@ -1924,11 +1919,10 @@ bool SfxCustomPropertiesPage::FillItemSet( SfxItemSet* 
rSet )
 
         pInfo->ClearCustomProperties();
         Sequence< beans::PropertyValue > aPropertySeq = 
m_xPropertiesCtrl->GetCustomProperties();
-        sal_Int32 i = 0, nCount = aPropertySeq.getLength();
-        for ( ; i < nCount; ++i )
+        for ( const auto& rProperty : aPropertySeq )
         {
-            if ( !aPropertySeq[i].Name.isEmpty() )
-                pInfo->AddCustomProperty( aPropertySeq[i].Name, 
aPropertySeq[i].Value );
+            if ( !rProperty.Name.isEmpty() )
+                pInfo->AddCustomProperty( rProperty.Name, rProperty.Value );
         }
     }
 
@@ -2053,11 +2047,10 @@ void CmisPropertiesWindow::AddLine( const OUString& 
sId, const OUString& sName,
         Sequence< sal_Int64 > seqValue;
         rAny >>= seqValue;
         sal_uInt32 nIndex = m_aNumberFormatter.GetFormatIndex( 
NF_NUMBER_SYSTEM );
-        sal_Int32 nNumValue = seqValue.getLength( );
-        for ( sal_Int32 i = 0; i < nNumValue; ++i )
+        for ( const auto& rValue : seqValue )
         {
             OUString sValue;
-            m_aNumberFormatter.GetInputLineString( seqValue[i], nIndex, sValue 
);
+            m_aNumberFormatter.GetInputLineString( rValue, nIndex, sValue );
             std::unique_ptr<CmisValue> pValue(new CmisValue(m_xBox.get(), 
sValue));
             pValue->m_xValueEdit->set_editable(bUpdatable);
             pNewLine->m_aValues.push_back( std::move(pValue) );
@@ -2068,11 +2061,10 @@ void CmisPropertiesWindow::AddLine( const OUString& 
sId, const OUString& sName,
         Sequence< double > seqValue;
         rAny >>= seqValue;
         sal_uInt32 nIndex = m_aNumberFormatter.GetFormatIndex( 
NF_NUMBER_SYSTEM );
-        sal_Int32 nNumValue = seqValue.getLength( );
-        for ( sal_Int32 i = 0; i < nNumValue; ++i )
+        for ( const auto& rValue : seqValue )
         {
             OUString sValue;
-            m_aNumberFormatter.GetInputLineString( seqValue[i], nIndex, sValue 
);
+            m_aNumberFormatter.GetInputLineString( rValue, nIndex, sValue );
             std::unique_ptr<CmisValue> pValue(new CmisValue(m_xBox.get(), 
sValue));
             pValue->m_xValueEdit->set_editable(bUpdatable);
             pNewLine->m_aValues.push_back( std::move(pValue) );
@@ -2083,10 +2075,9 @@ void CmisPropertiesWindow::AddLine( const OUString& sId, 
const OUString& sName,
     {
         Sequence<sal_Bool> seqValue;
         rAny >>= seqValue;
-        sal_Int32 nNumValue = seqValue.getLength( );
-        for ( sal_Int32 i = 0; i < nNumValue; ++i )
+        for ( const auto& rValue : seqValue )
         {
-            std::unique_ptr<CmisYesNo> pYesNo(new CmisYesNo(m_xBox.get(), 
seqValue[i]));
+            std::unique_ptr<CmisYesNo> pYesNo(new CmisYesNo(m_xBox.get(), 
rValue));
             pYesNo->m_xYesButton->set_sensitive( bUpdatable );
             pYesNo->m_xNoButton->set_sensitive( bUpdatable );
             pNewLine->m_aYesNos.push_back( std::move(pYesNo) );
@@ -2096,10 +2087,9 @@ void CmisPropertiesWindow::AddLine( const OUString& sId, 
const OUString& sName,
     {
         Sequence< OUString > seqValue;
         rAny >>= seqValue;
-        sal_Int32 nNumValue = seqValue.getLength( );
-        for ( sal_Int32 i = 0; i < nNumValue; ++i )
+        for ( const auto& rValue : seqValue )
         {
-            std::unique_ptr<CmisValue> pValue(new CmisValue(m_xBox.get(), 
seqValue[i]));
+            std::unique_ptr<CmisValue> pValue(new CmisValue(m_xBox.get(), 
rValue));
             pValue->m_xValueEdit->set_editable(bUpdatable);
             pNewLine->m_aValues.push_back( std::move(pValue) );
         }
@@ -2108,10 +2098,9 @@ void CmisPropertiesWindow::AddLine( const OUString& sId, 
const OUString& sName,
     {
         Sequence< util::DateTime > seqValue;
         rAny >>= seqValue;
-        sal_Int32 nNumValue = seqValue.getLength( );
-        for ( sal_Int32 i = 0; i < nNumValue; ++i )
+        for ( const auto& rValue : seqValue )
         {
-            std::unique_ptr<CmisDateTime> pDateTime(new 
CmisDateTime(m_xBox.get(), seqValue[i]));
+            std::unique_ptr<CmisDateTime> pDateTime(new 
CmisDateTime(m_xBox.get(), rValue));
             pDateTime->m_xDateField->set_sensitive(bUpdatable);
             pDateTime->m_xTimeField->set_sensitive(bUpdatable);
             pNewLine->m_aDateTimes.push_back( std::move(pDateTime) );
@@ -2305,10 +2294,10 @@ bool SfxCmisPropertiesPage::FillItemSet( SfxItemSet* 
rSet )
                     aOldProps[i].Value >>= oldValue;
                     // We only edit hours and minutes
                     // don't compare NanoSeconds and Seconds
-                    for ( sal_Int32 ii = 0; ii < oldValue.getLength( ); ++ii )
+                    for ( auto& rDateTime : oldValue )
                     {
-                        oldValue[ii].NanoSeconds = 0;
-                        oldValue[ii].Seconds = 0;
+                        rDateTime.NanoSeconds = 0;
+                        rDateTime.Seconds = 0;
                     }
                     Sequence< util::DateTime > newValue;
                     aNewProps[i].Value >>= newValue;
@@ -2340,17 +2329,17 @@ void SfxCmisPropertiesPage::Reset( const SfxItemSet* 
rItemSet )
     m_xPropertiesCtrl->ClearAllLines();
     const SfxDocumentInfoItem& rInfoItem = rItemSet->Get(SID_DOCINFO);
     uno::Sequence< document::CmisProperty > aCmisProps = 
rInfoItem.GetCmisProperties();
-    for ( sal_Int32 i = 0; i < aCmisProps.getLength(); i++ )
+    for ( auto& rCmisProp : aCmisProps )
     {
-        m_xPropertiesCtrl->AddLine(aCmisProps[i].Id,
-                                   aCmisProps[i].Name,
-                                   aCmisProps[i].Type,
-                                   aCmisProps[i].Updatable,
-                                   aCmisProps[i].Required,
-                                   aCmisProps[i].MultiValued,
-                                   aCmisProps[i].OpenChoice,
-                                   aCmisProps[i].Choices,
-                                   aCmisProps[i].Value);
+        m_xPropertiesCtrl->AddLine(rCmisProp.Id,
+                                   rCmisProp.Name,
+                                   rCmisProp.Type,
+                                   rCmisProp.Updatable,
+                                   rCmisProp.Required,
+                                   rCmisProp.MultiValued,
+                                   rCmisProp.OpenChoice,
+                                   rCmisProp.Choices,
+                                   rCmisProp.Value);
     }
 }
 
diff --git a/sfx2/source/dialog/dockwin.cxx b/sfx2/source/dialog/dockwin.cxx
index 4dbce1831f91..d38a361b5a2a 100644
--- a/sfx2/source/dialog/dockwin.cxx
+++ b/sfx2/source/dialog/dockwin.cxx
@@ -102,11 +102,11 @@ static bool lcl_getWindowState( const uno::Reference< 
container::XNameAccess >&
         a = xWindowStateMgr->getByName( rResourceURL );
         if ( a >>= aWindowState )
         {
-            for ( sal_Int32 n = 0; n < aWindowState.getLength(); n++ )
+            for ( const auto& rProp : aWindowState )
             {
-                if ( aWindowState[n].Name == "UIName" )
+                if ( rProp.Name == "UIName" )
                 {
-                    aWindowState[n].Value >>= rWindowState.sTitle;
+                    rProp.Value >>= rWindowState.sTitle;
                 }
             }
         }
diff --git a/sfx2/source/dialog/filedlghelper.cxx 
b/sfx2/source/dialog/filedlghelper.cxx
index 5f2699d0f525..198043cac4a9 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -410,12 +410,11 @@ bool FileDialogHelper_Impl::CheckFilterOptionsCapability( 
const std::shared_ptr<
             if ( aAny >>= aProps )
             {
                 OUString aServiceName;
-                sal_Int32 nPropertyCount = aProps.getLength();
-                for( sal_Int32 nProperty=0; nProperty < nPropertyCount; 
++nProperty )
+                for( const auto& rProp : aProps )
                 {
-                    if( aProps[nProperty].Name == "UIComponent" )
+                    if( rProp.Name == "UIComponent" )
                     {
-                        aProps[nProperty].Value >>= aServiceName;
+                        rProp.Value >>= aServiceName;
                         if( !aServiceName.isEmpty() )
                             bResult = true;
                     }
@@ -508,13 +507,7 @@ void FileDialogHelper_Impl::updateSelectionBox()
     if ( xCtrlInfo.is() )
     {
         Sequence< OUString > aCtrlList = xCtrlInfo->getSupportedControls();
-        sal_uInt32 nCount = aCtrlList.getLength();
-        for ( sal_uInt32 nCtrl = 0; nCtrl < nCount; ++nCtrl )
-            if ( aCtrlList[ nCtrl ] == "SelectionBox" )
-            {
-                bSelectionBoxFound = true;
-                break;
-            }
+        bSelectionBoxFound = comphelper::findValue(aCtrlList, "SelectionBox") 
!= -1;
     }
 
     if ( bSelectionBoxFound )
@@ -632,8 +625,8 @@ void FileDialogHelper_Impl::updateVersions()
                 aEntries.realloc( xVersions.getLength() + 1 );
                 aEntries[0] = SfxResId( STR_SFX_FILEDLG_ACTUALVERSION );
 
-                for ( sal_Int32 i=0; i<xVersions.getLength(); i++ )
-                    aEntries[ i + 1 ] = xVersions[i].Identifier;
+                std::transform(xVersions.begin(), xVersions.end(), 
std::next(aEntries.begin()),
+                    [](const util::RevisionTag& rVersion) -> OUString { return 
rVersion.Identifier; });
             }
             catch( const uno::Exception& )
             {
@@ -651,9 +644,7 @@ void FileDialogHelper_Impl::updateVersions()
     }
     catch( const IllegalArgumentException& ){}
 
-    sal_Int32 nCount = aEntries.getLength();
-
-    if ( !nCount )
+    if ( !aEntries.hasElements() )
         return;
 
     try
@@ -1361,9 +1352,7 @@ void FileDialogHelper_Impl::implGetAndCacheFiles(const 
uno::Reference< XInterfac
     if (xPickNew.is())
     {
         Sequence< OUString > lFiles    = xPickNew->getSelectedFiles();
-        ::sal_Int32          nFiles    = lFiles.getLength();
-        for(sal_Int32 i = 0; i < nFiles; ++i)
-            rpURLList.push_back(lFiles[i]);
+        comphelper::sequenceToContainer(rpURLList, lFiles);
     }
 
     // b) the olde way ... non optional.
@@ -2724,7 +2713,7 @@ ErrCode RequestPassword(const std::shared_ptr<const 
SfxFilter>& pCurrentFilter,
                     uno::Sequence< sal_Int8 > aUniqueID = 
::comphelper::DocPasswordHelper::GenerateRandomByteSequence( 16 );
                     uno::Sequence< sal_Int8 > aEncryptionKey = 
::comphelper::DocPasswordHelper::GenerateStd97Key( 
pPasswordRequest->getPassword(), aUniqueID );
 
-                    if ( aEncryptionKey.getLength() )
+                    if ( aEncryptionKey.hasElements() )
                     {
                         ::comphelper::SequenceAsHashMap aHashData;
                         aHashData[ OUString( "STD97EncryptionKey"  ) ] <<= 
aEncryptionKey;
@@ -2758,7 +2747,7 @@ ErrCode RequestPassword(const std::shared_ptr<const 
SfxFilter>& pCurrentFilter,
         else
         {
             uno::Sequence< beans::PropertyValue > aModifyPasswordInfo = 
::comphelper::DocPasswordHelper::GenerateNewModifyPasswordInfo( 
pPasswordRequest->getPasswordToModify() );
-            if ( aModifyPasswordInfo.getLength() )
+            if ( aModifyPasswordInfo.hasElements() )
                 pSet->Put( SfxUnoAnyItem( SID_MODIFYPASSWORDINFO, 
uno::makeAny( aModifyPasswordInfo ) ) );
         }
     }
diff --git a/sfx2/source/dialog/filtergrouping.cxx 
b/sfx2/source/dialog/filtergrouping.cxx
index 0701c5c62f77..a59d7c8159c6 100644
--- a/sfx2/source/dialog/filtergrouping.cxx
+++ b/sfx2/source/dialog/filtergrouping.cxx
@@ -225,17 +225,12 @@ namespace sfx2
         _rGlobalClasses.clear();
         _rGlobalClassNames.clear();
 
-
         // get the list describing the order of all global classes
         Sequence< OUString > aGlobalClasses;
         _rFilterClassification.getNodeValue( "GlobalFilters/Order" ) >>= 
aGlobalClasses;
 
-        const OUString* pNames = aGlobalClasses.getConstArray();
-        const OUString* pNamesEnd = pNames + aGlobalClasses.getLength();
-
         // copy the logical names
-        _rGlobalClassNames.resize( aGlobalClasses.getLength() );
-        ::std::copy( pNames, pNamesEnd, _rGlobalClassNames.begin() );
+        comphelper::sequenceToContainer(_rGlobalClassNames, aGlobalClasses);
 
         // Global classes are presented in an own group, so their order 
matters (while the order of the
         // "local classes" doesn't).
@@ -243,8 +238,8 @@ namespace sfx2
         // are returned from the configuration - it is completely undefined, 
and we need a _defined_ order.
         FilterClassReferrer aClassReferrer;
         ::std::for_each(
-            pNames,
-            pNamesEnd,
+            aGlobalClasses.begin(),
+            aGlobalClasses.end(),
             CreateEmptyClassRememberPos( _rGlobalClasses, aClassReferrer )
         );
             // now _rGlobalClasses contains a dummy entry for each global 
class,
diff --git a/sfx2/source/dialog/mailmodel.cxx b/sfx2/source/dialog/mailmodel.cxx
index f8933256e539..31ee48bf6e0b 100644
--- a/sfx2/source/dialog/mailmodel.cxx
+++ b/sfx2/source/dialog/mailmodel.cxx
@@ -146,13 +146,12 @@ SfxMailModel::SaveResult 
SfxMailModel::ShowFilterOptionsDialog(
 
         if ( aAny >>= aProps )
         {
-            sal_Int32 nPropertyCount = aProps.getLength();
-            for( sal_Int32 nProperty=0; nProperty < nPropertyCount; 
++nProperty )
+            for( const auto& rProp : aProps )
             {
-                if( aProps[nProperty].Name == "UIComponent" )
+                if( rProp.Name == "UIComponent" )
                 {
                     OUString aServiceName;
-                    aProps[nProperty].Value >>= aServiceName;
+                    rProp.Value >>= aServiceName;
                     if( !aServiceName.isEmpty() )
                     {
                         uno::Reference< ui::dialogs::XExecutableDialog > 
xFilterDialog(
@@ -191,16 +190,14 @@ SfxMailModel::SaveResult 
SfxMailModel::ShowFilterOptionsDialog(
                                 uno::Sequence< beans::PropertyValue > 
aPropsFromDialog = xFilterProperties->getPropertyValues();
 
                                 //add them to the args
-                                for ( sal_Int32 nInd = 0; nInd < 
aPropsFromDialog.getLength(); nInd++ )
+                                auto pProp = 
std::find_if(aPropsFromDialog.begin(), aPropsFromDialog.end(),
+                                    [](const beans::PropertyValue& 
rDialogProp) { return rDialogProp.Name == "FilterData"; });
+                                if (pProp != aPropsFromDialog.end())
                                 {
-                                    if( aPropsFromDialog[ nInd ].Name == 
"FilterData" )
-                                    {
-                                        //found the filterdata, add to the 
storing argument
-                                        rArgs.realloc( ++rNumArgs );
-                                        rArgs[rNumArgs-1].Name = 
aPropsFromDialog[ nInd ].Name;
-                                        rArgs[rNumArgs-1].Value = 
aPropsFromDialog[ nInd ].Value;
-                                        break;
-                                    }
+                                    //found the filterdata, add to the storing 
argument
+                                    rArgs.realloc( ++rNumArgs );
+                                    rArgs[rNumArgs-1].Name = pProp->Name;
+                                    rArgs[rNumArgs-1].Value = pProp->Value;
                                 }
                                 eRet = SAVE_SUCCESSFULL;
                             }
diff --git a/sfx2/source/dialog/versdlg.cxx b/sfx2/source/dialog/versdlg.cxx
index 743ecd6158e3..6dfc4329c769 100644
--- a/sfx2/source/dialog/versdlg.cxx
+++ b/sfx2/source/dialog/versdlg.cxx
@@ -80,28 +80,28 @@ public:
 
 SfxVersionTableDtor::SfxVersionTableDtor( const uno::Sequence < 
util::RevisionTag >& rInfo )
 {
-    for ( sal_Int32 n=0; n<rInfo.getLength(); n++ )
+    for ( const auto& rItem : rInfo )
     {
         std::unique_ptr<SfxVersionInfo> pInfo(new SfxVersionInfo);
-        pInfo->aName = rInfo[n].Identifier;
-        pInfo->aComment = rInfo[n].Comment;
-        pInfo->aAuthor = rInfo[n].Author;
+        pInfo->aName = rItem.Identifier;
+        pInfo->aComment = rItem.Comment;
+        pInfo->aAuthor = rItem.Author;
 
-        pInfo->aCreationDate = DateTime( rInfo[n].TimeStamp );
+        pInfo->aCreationDate = DateTime( rItem.TimeStamp );
         aTableList.push_back( std::move(pInfo) );
     }
 }
 
 SfxVersionTableDtor::SfxVersionTableDtor( const uno::Sequence < 
document::CmisVersion >& rInfo )
 {
-    for ( sal_Int32 n=0; n<rInfo.getLength(); n++ )
+    for ( const auto& rItem : rInfo )
     {
         std::unique_ptr<SfxVersionInfo> pInfo(new SfxVersionInfo);
-        pInfo->aName = rInfo[n].Id;
-        pInfo->aComment = rInfo[n].Comment;
-        pInfo->aAuthor = rInfo[n].Author;
+        pInfo->aName = rItem.Id;
+        pInfo->aComment = rItem.Comment;
+        pInfo->aAuthor = rItem.Author;
 
-        pInfo->aCreationDate = DateTime( rInfo[n].TimeStamp );
+        pInfo->aCreationDate = DateTime( rItem.TimeStamp );
         aTableList.push_back( std::move(pInfo) );
     }
 }
diff --git a/sfx2/source/doc/DocumentMetadataAccess.cxx 
b/sfx2/source/doc/DocumentMetadataAccess.cxx
index 14c5d98ca5d2..35952895e99c 100644
--- a/sfx2/source/doc/DocumentMetadataAccess.cxx
+++ b/sfx2/source/doc/DocumentMetadataAccess.cxx
@@ -329,10 +329,10 @@ addFile(struct DocumentMetadataAccess_Impl const & 
i_rImpl,
             getURI<rdf::URIs::RDF_TYPE>(i_rImpl.m_xContext),
             i_xType.get());
         if (i_pTypes) {
-            for (sal_Int32 i = 0; i < i_pTypes->getLength(); ++i) {
+            for (const auto& rType : *i_pTypes) {
                 i_rImpl.m_xManifest->addStatement(xURI.get(),
                     getURI<rdf::URIs::RDF_TYPE>(i_rImpl.m_xContext),
-                    (*i_pTypes)[i].get());
+                    rType.get());
             }
         }
     } catch (const uno::RuntimeException &) {
@@ -956,12 +956,11 @@ DocumentMetadataAccess::addMetadataFile(const OUString & 
i_rFileName,
             "DocumentMetadataAccess::addMetadataFile:"
             "invalid FileName: reserved", *this, 0);
     }
-    for (sal_Int32 i = 0; i < i_rTypes.getLength(); ++i) {
-        if (!i_rTypes[i].is()) {
-            throw lang::IllegalArgumentException(
-                    "DocumentMetadataAccess::addMetadataFile: "
-                    "null type", *this, 2);
-        }
+    if (std::any_of(i_rTypes.begin(), i_rTypes.end(),
+            [](const uno::Reference< rdf::XURI >& rType) { return !rType.is(); 
})) {
+        throw lang::IllegalArgumentException(
+                "DocumentMetadataAccess::addMetadataFile: "
+                "null type", *this, 2);
     }
 
     const uno::Reference<rdf::XURI> xGraphName(
@@ -998,12 +997,11 @@ DocumentMetadataAccess::importMetadataFile(::sal_Int16 
i_Format,
             "DocumentMetadataAccess::importMetadataFile:"
             "invalid FileName: reserved", *this, 0);
     }
-    for (sal_Int32 i = 0; i < i_rTypes.getLength(); ++i) {
-        if (!i_rTypes[i].is()) {
-            throw lang::IllegalArgumentException(
-                "DocumentMetadataAccess::importMetadataFile: null type",
-                *this, 5);
-        }
+    if (std::any_of(i_rTypes.begin(), i_rTypes.end(),
+            [](const uno::Reference< rdf::XURI >& rType) { return !rType.is(); 
})) {
+        throw lang::IllegalArgumentException(
+            "DocumentMetadataAccess::importMetadataFile: null type",
+            *this, 5);
     }
 
     const uno::Reference<rdf::XURI> xGraphName(
@@ -1232,8 +1230,7 @@ void SAL_CALL 
DocumentMetadataAccess::storeMetadataToStorage(
         const uno::Sequence<uno::Reference<rdf::XURI> > graphs(
             m_pImpl->m_xRepository->getGraphNames());
         const sal_Int32 len( baseURI.getLength() );
-        for (sal_Int32 i = 0; i < graphs.getLength(); ++i) {
-            const uno::Reference<rdf::XURI> xName(graphs[i]);
+        for (const uno::Reference<rdf::XURI>& xName : graphs) {
             const OUString name(xName->getStringValue());
             if (!name.match(baseURI)) {
                 SAL_WARN("sfx", "storeMetadataToStorage: graph not in 
document: " << name);
diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx 
b/sfx2/source/doc/SfxDocumentMetaData.cxx
index 7d2ed6faf10b..a9d248a2738c 100644
--- a/sfx2/source/doc/SfxDocumentMetaData.cxx
+++ b/sfx2/source/doc/SfxDocumentMetaData.cxx
@@ -571,18 +571,18 @@ SfxDocumentMetaData::getURLProperties(
     css::uno::Reference< css::beans::XPropertyBag> xPropArg = 
css::beans::PropertyBag::createDefault( m_xContext );
     try {
         css::uno::Any baseUri;
-        for (sal_Int32 i = 0; i < i_rMedium.getLength(); ++i) {
-            if (i_rMedium[i].Name == "DocumentBaseURL") {
-                baseUri = i_rMedium[i].Value;
-            } else if (i_rMedium[i].Name == "URL") {
+        for (const auto& rProp : i_rMedium) {
+            if (rProp.Name == "DocumentBaseURL") {
+                baseUri = rProp.Value;
+            } else if (rProp.Name == "URL") {
                 if (!baseUri.hasValue()) {
-                    baseUri = i_rMedium[i].Value;
+                    baseUri = rProp.Value;
                 }
-            } else if (i_rMedium[i].Name == "HierarchicalDocumentName") {
+            } else if (rProp.Name == "HierarchicalDocumentName") {
                 xPropArg->addProperty(
                     "StreamRelPath",
                     css::beans::PropertyAttribute::MAYBEVOID,
-                    i_rMedium[i].Value);
+                    rProp.Value);
             }
         }
         if (baseUri.hasValue()) {
@@ -1621,12 +1621,12 @@ SfxDocumentMetaData::setDocumentStatistics(
         osl::MutexGuard g(m_aMutex);
         checkInit();
         std::vector<std::pair<const char *, OUString> > attributes;
-        for (sal_Int32 i = 0; i < the_value.getLength(); ++i) {
-            const OUString name = the_value[i].Name;
+        for (const auto& rValue : the_value) {
+            const OUString name = rValue.Name;
             // inefficiently search for matching attribute
             for (size_t j = 0; s_stdStats[j] != nullptr; ++j) {
                 if (name.equalsAscii(s_stdStats[j])) {
-                    const css::uno::Any any = the_value[i].Value;
+                    const css::uno::Any any = rValue.Value;
                     sal_Int32 val = 0;
                     if (any >>= val) {
                         attributes.emplace_back(s_stdStatAttrs[j],
diff --git a/sfx2/source/doc/docfac.cxx b/sfx2/source/doc/docfac.cxx
index 313065b3cab5..43514b1bc68e 100644
--- a/sfx2/source/doc/docfac.cxx
+++ b/sfx2/source/doc/docfac.cxx
@@ -176,9 +176,9 @@ void SfxObjectFactory::SetSystemTemplate( const OUString& 
rServiceName, const OU
         OUString aActualFilterTypeName;
         uno::Sequence< beans::PropertyValue > aActuralFilterData;
         xFilterFactory->getByName( aActualFilter ) >>= aActuralFilterData;
-        for ( sal_Int32 nInd = 0; nInd < aActuralFilterData.getLength(); 
nInd++ )
-            if ( aActuralFilterData[nInd].Name == "Type" )
-                aActuralFilterData[nInd].Value >>= aActualFilterTypeName;
+        for ( const auto& rProp : aActuralFilterData )
+            if ( rProp.Name == "Type" )
+                rProp.Value >>= aActualFilterTypeName;
         ::comphelper::SequenceAsHashMap aProps1( xTypeDetection->getByName( 
aActualFilterTypeName ) );
         uno::Sequence< OUString > aAllExt =
             aProps1.getUnpackedValueOrDefault("Extensions", uno::Sequence< 
OUString >() );
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index 96ff6618739c..f2782b99de40 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -83,6 +83,7 @@
 #include <comphelper/fileurl.hxx>
 #include <comphelper/processfactory.hxx>
 #include <comphelper/interaction.hxx>
+#include <comphelper/sequence.hxx>
 #include <comphelper/simplefileaccessinteraction.hxx>
 #include <framework/interaction.hxx>
 #include <unotools/streamhelper.hxx>
@@ -1639,7 +1640,7 @@ uno::Reference < embed::XStorage > SfxMedium::GetStorage( 
bool bCreateTempIfNo )
     if ( pVersion && pVersion->GetValue() )
     {
         // Read all available versions
-        if ( pImpl->aVersions.getLength() )
+        if ( pImpl->aVersions.hasElements() )
         {
             // Search for the version fits the comment
             // The versions are numbered starting with 1, versions with
@@ -3457,7 +3458,7 @@ css::uno::Reference< css::io::XInputStream > const &  
SfxMedium::GetInputStream(
 const uno::Sequence < util::RevisionTag >& SfxMedium::GetVersionList( bool 
_bNoReload )
 {
     // if the medium has no name, then this medium should represent a new 
document and can have no version info
-    if ( ( !_bNoReload || !pImpl->m_bVersionsAlreadyLoaded ) && 
!pImpl->aVersions.getLength() &&
+    if ( ( !_bNoReload || !pImpl->m_bVersionsAlreadyLoaded ) && 
!pImpl->aVersions.hasElements() &&
          ( !pImpl->m_aName.isEmpty() || !pImpl->m_aLogicName.isEmpty() ) && 
GetStorage().is() )
     {
         uno::Reference < document::XDocumentRevisionListPersistence > xReader =
@@ -3500,9 +3501,9 @@ void SfxMedium::AddVersion_Impl( util::RevisionTag& 
rRevision )
     // To determine a unique name for the stream
     std::vector<sal_uInt32> aLongs;
     sal_Int32 nLength = pImpl->aVersions.getLength();
-    for ( sal_Int32 m=0; m<nLength; m++ )
+    for ( const auto& rVersion : pImpl->aVersions )
     {
-        sal_uInt32 nVer = static_cast<sal_uInt32>( 
pImpl->aVersions[m].Identifier.copy(7).toInt32());
+        sal_uInt32 nVer = static_cast<sal_uInt32>( 
rVersion.Identifier.copy(7).toInt32());
         size_t n;
         for ( n=0; n<aLongs.size(); ++n )
             if ( nVer<aLongs[n] )
@@ -3524,25 +3525,21 @@ void SfxMedium::AddVersion_Impl( util::RevisionTag& 
rRevision )
 
 void SfxMedium::RemoveVersion_Impl( const OUString& rName )
 {
-    if ( !pImpl->aVersions.getLength() )
+    if ( !pImpl->aVersions.hasElements() )
         return;
 
-    sal_Int32 nLength = pImpl->aVersions.getLength();
-    for ( sal_Int32 n=0; n<nLength; n++ )
+    auto pVersion = std::find_if(pImpl->aVersions.begin(), 
pImpl->aVersions.end(),
+        [&rName](const auto& rVersion) { return rVersion.Identifier == rName; 
});
+    if (pVersion != pImpl->aVersions.end())
     {
-        if ( pImpl->aVersions[n].Identifier == rName )
-        {
-            for ( sal_Int32 m=n; m<nLength-1; m++ )
-                pImpl->aVersions[m] = pImpl->aVersions[m+1];
-            pImpl->aVersions.realloc(nLength-1);
-            return;
-        }
+        auto nIndex = 
static_cast<sal_Int32>(std::distance(pImpl->aVersions.begin(), pVersion));
+        comphelper::removeElementAt(pImpl->aVersions, nIndex);
     }
 }
 
 bool SfxMedium::TransferVersionList_Impl( SfxMedium const & rMedium )
 {
-    if ( rMedium.pImpl->aVersions.getLength() )
+    if ( rMedium.pImpl->aVersions.hasElements() )
     {
         pImpl->aVersions = rMedium.pImpl->aVersions;
         return true;
@@ -3556,7 +3553,7 @@ void SfxMedium::SaveVersionList_Impl()
     if ( !GetStorage().is() )
         return;
 
-    if ( !pImpl->aVersions.getLength() )
+    if ( !pImpl->aVersions.hasElements() )
         return;
 
     uno::Reference < document::XDocumentRevisionListPersistence > xWriter =
diff --git a/sfx2/source/doc/docinf.cxx b/sfx2/source/doc/docinf.cxx
index b58dfd81bca1..71dbff9a64ed 100644
--- a/sfx2/source/doc/docinf.cxx
+++ b/sfx2/source/doc/docinf.cxx
@@ -274,14 +274,14 @@ bool SaveOlePropertySet(
         xUserDefinedProps->getPropertySetInfo();
     DBG_ASSERT(xPropInfo.is(), "UserDefinedProperties Info is null");
     uno::Sequence<beans::Property> props = xPropInfo->getProperties();
-    for (sal_Int32 i = 0; i < props.getLength(); ++i)
+    for (const auto& rProp : props)
     {
         try
         {
             // skip transient properties
-            if (~props[i].Attributes & beans::PropertyAttribute::TRANSIENT)
+            if (~rProp.Attributes & beans::PropertyAttribute::TRANSIENT)
             {
-                const OUString name = props[i].Name;
+                const OUString name = rProp.Name;
                 const sal_Int32 nPropId = rCustomSect.GetFreePropertyId();
                 if (rCustomSect.SetAnyValue( nPropId,
                             xUserDefinedProps->getPropertyValue(name))) {
diff --git a/sfx2/source/doc/docinsert.cxx b/sfx2/source/doc/docinsert.cxx
index aa9c4c6b3a33..b24806a1b460 100644
--- a/sfx2/source/doc/docinsert.cxx
+++ b/sfx2/source/doc/docinsert.cxx
@@ -175,11 +175,11 @@ static void impl_FillURLList( sfx2::FileDialogHelper 
const * _pFileDlg, std::vec
     {
         _rpURLList.clear();
 
-        for ( sal_Int32 i = 0; i < aPathSeq.getLength(); ++i )
-        {
-            INetURLObject aPathObj( aPathSeq[i] );
-            
_rpURLList.push_back(aPathObj.GetMainURL(INetURLObject::DecodeMechanism::NONE));
-        }
+        std::transform(aPathSeq.begin(), aPathSeq.end(), 
std::back_inserter(_rpURLList),
+            [](const OUString& rPath) -> OUString {
+                INetURLObject aPathObj( rPath );
+                return 
aPathObj.GetMainURL(INetURLObject::DecodeMechanism::NONE);
+            });
     }
 }
 
diff --git a/sfx2/source/doc/docmacromode.cxx b/sfx2/source/doc/docmacromode.cxx
index 41b25170b8a3..cef89b0d0aa2 100644
--- a/sfx2/source/doc/docmacromode.cxx
+++ b/sfx2/source/doc/docmacromode.cxx
@@ -311,23 +311,18 @@ namespace sfx2
                     const OUString aStdLibName( "Standard" );
                     const OUString aVBAProject( "VBAProject" );
                     Sequence< OUString > aElements = 
xContainer->getElementNames();
-                    if ( aElements.hasElements() )
+                    for( const OUString& aElement : aElements )
                     {
-                        sal_Int32 nElements = aElements.getLength();
-                        for( sal_Int32 i = 0; i < nElements; ++i )
+                        if( aElement == aStdLibName || aElement == aVBAProject 
)
                         {
-                            const OUString aElement = aElements[i];
-                            if( aElement == aStdLibName || aElement == 
aVBAProject )
-                            {
-                                Reference < XNameAccess > xLib;
-                                Any aAny = xContainer->getByName( aElement );
-                                aAny >>= xLib;
-                                if ( xLib.is() && xLib->hasElements() )
-                                    return true;
-                            }
-                            else
+                            Reference < XNameAccess > xLib;
+                            Any aAny = xContainer->getByName( aElement );
+                            aAny >>= xLib;
+                            if ( xLib.is() && xLib->hasElements() )
                                 return true;
                         }
+                        else
+                            return true;
                     }
                 }
             }
diff --git a/sfx2/source/doc/doctemplates.cxx b/sfx2/source/doc/doctemplates.cxx
index 435041fd1189..7c980be3b77f 100644
--- a/sfx2/source/doc/doctemplates.cxx
+++ b/sfx2/source/doc/doctemplates.cxx
@@ -553,22 +553,20 @@ void SfxDocTplService_Impl::getDirList()
         "vnd.sun.star.expand:"  );
 
     sal_Int32 nIdx{ 0 };
-    for (sal_Int32 i = 0; i < nCount; ++i)
+    for (auto& rTemplateDir : maTemplateDirs)
     {
         aURL.SetSmartProtocol( INetProtocol::File );
         aURL.SetURL( aDirs.getToken( 0, C_DELIM, nIdx ) );
-        maTemplateDirs[i] = aURL.GetMainURL( 
INetURLObject::DecodeMechanism::NONE );
+        rTemplateDir = aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE );
 
         if ( xExpander.is() )
         {
-            const sal_Int32 nIndex{ maTemplateDirs[i].indexOf( aPrefix ) };
+            const sal_Int32 nIndex{ rTemplateDir.indexOf( aPrefix ) };
             if (nIndex<0)
                 continue;
 
-            maTemplateDirs[i] = maTemplateDirs[i].replaceAt(nIndex,
-                                                            
aPrefix.getLength(),
-                                                            OUString());
-            maTemplateDirs[i] = xExpander->expandMacros( maTemplateDirs[i] );
+            rTemplateDir = rTemplateDir.replaceAt(nIndex, aPrefix.getLength(), 
OUString());
+            rTemplateDir = xExpander->expandMacros( rTemplateDir );
         }
     }
 
@@ -581,13 +579,12 @@ void SfxDocTplService_Impl::getDirList()
     Any aAny = xPathSettings->getPropertyValue( "Template_internal" );
     aAny >>= maInternalTemplateDirs;
 
-    nCount = maInternalTemplateDirs.getLength();
-    for (sal_Int32 i = 0; i < nCount; ++i)
+    for (auto& rInternalTemplateDir : maInternalTemplateDirs)
     {
         //expand vnd.sun.star.expand: and remove "..." from them
         //to normalize into the expected url patterns
-        maRelocator.makeRelocatableURL(maInternalTemplateDirs[i]);
-        maRelocator.makeAbsoluteURL(maInternalTemplateDirs[i]);
+        maRelocator.makeRelocatableURL(rInternalTemplateDir);
+        maRelocator.makeAbsoluteURL(rInternalTemplateDir);
     }
 
     // Store the template dir list
@@ -994,9 +991,9 @@ bool SfxDocTplService_Impl::setProperty( Content& rContent,
                 Sequence< OUString > aValues;
                 if ( rPropValue >>= aValues )
                 {
-                    for ( sal_Int32 n = 0; n < aValues.getLength(); n++ )
+                    for ( auto& rValue : aValues )
                     {
-                        maRelocator.makeRelocatableURL( aValues[ n ] );
+                        maRelocator.makeRelocatableURL( rValue );
                     }
                     aPropValue <<= aValues;
                 }
@@ -1053,9 +1050,9 @@ bool SfxDocTplService_Impl::getProperty(Content& 
rContent, const OUString& rProp
                 Sequence< OUString > aValues;
                 if ( rPropValue >>= aValues )
                 {
-                    for ( sal_Int32 n = 0; n < aValues.getLength(); n++ )
+                    for ( auto& rValue : aValues )
                     {
-                        maRelocator.makeAbsoluteURL( aValues[ n ] );
+                        maRelocator.makeAbsoluteURL( rValue );
                     }
                     rPropValue <<= aValues;
                 }
@@ -1769,9 +1766,9 @@ bool SfxDocTplService_Impl::storeTemplate( const 
OUString& rGroupName,
         uno::Sequence< beans::PropertyValue > aFilterData;
         xFilterFactory->getByName( aFilterName ) >>= aFilterData;
         OUString aTypeName;
-        for ( sal_Int32 nInd = 0; nInd < aFilterData.getLength(); nInd++ )
-            if ( aFilterData[nInd].Name == "Type" )
-                aFilterData[nInd].Value >>= aTypeName;
+        for ( const auto& rProp : aFilterData )
+            if ( rProp.Name == "Type" )
+                rProp.Value >>= aTypeName;
 
         if ( aTypeName.isEmpty() )
             throw uno::RuntimeException();
@@ -2005,25 +2002,16 @@ bool SfxDocTplService_Impl::addTemplate( const 
OUString& rGroupName,
 
 bool SfxDocTplService_Impl::isInternalTemplateDir(const OUString& rURL) const
 {
-    const sal_Int32 nDirs = maInternalTemplateDirs.getLength();
-    const OUString* pDirs = maInternalTemplateDirs.getConstArray();
-    for (sal_Int32 i = 0; i < nDirs; ++i, ++pDirs)
-    {
-        if (::utl::UCBContentHelper::IsSubPath(*pDirs, rURL))
-            return true;
-    }
-    return false;
+    return std::any_of(maInternalTemplateDirs.begin(), 
maInternalTemplateDirs.end(),
+        [&rURL](const OUString& rDir) { return 
::utl::UCBContentHelper::IsSubPath(rDir, rURL); });
 }
 
 OUString SfxDocTplService_Impl::findParentTemplateDir(const OUString& rURL) 
const
 {
-    const sal_Int32 nDirs = maTemplateDirs.getLength();
-    const OUString* pDirs = maTemplateDirs.getConstArray();
-    for (sal_Int32 i = 0; i < nDirs; ++i, ++pDirs)
-    {
-        if (::utl::UCBContentHelper::IsSubPath(*pDirs, rURL))
-            return *pDirs;
-    }
+    const OUString* pDirs = std::find_if(maTemplateDirs.begin(), 
maTemplateDirs.end(),
+        [&rURL](const OUString& rDir) { return 
::utl::UCBContentHelper::IsSubPath(rDir, rURL); });
+    if (pDirs != maTemplateDirs.end())
+        return *pDirs;
     return OUString();
 }
 
diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx
index dedb5a83d72f..8dec12dda161 100644
--- a/sfx2/source/doc/guisaveas.cxx
+++ b/sfx2/source/doc/guisaveas.cxx
@@ -568,54 +568,49 @@ bool ModelData_Impl::ExecuteFilterDialog_Impl( const 
OUString& aFilterName )
         uno::Any aAny = m_pOwner->GetFilterConfiguration()->getByName( 
aFilterName );
         if ( aAny >>= aProps )
         {
-            const sal_Int32 nPropertyCount = aProps.getLength();
-            for( sal_Int32 nProperty=0; nProperty < nPropertyCount; 
++nProperty )
+            auto pProp = std::find_if(aProps.begin(), aProps.end(),
+                [](const beans::PropertyValue& rProp) { return rProp.Name == 
"UIComponent"; });
+            if (pProp != aProps.end())
             {
-                if( aProps[nProperty].Name == "UIComponent" )
+                OUString aServiceName;
+                pProp->Value >>= aServiceName;
+                if( !aServiceName.isEmpty() )
                 {
-                    OUString aServiceName;
-                    aProps[nProperty].Value >>= aServiceName;
-                    if( !aServiceName.isEmpty() )
+                    uno::Sequence<uno::Any> 
aDialogArgs(comphelper::InitAnyPropertySequence(
                     {
-                        uno::Sequence<uno::Any> 
aDialogArgs(comphelper::InitAnyPropertySequence(
-                        {
-                            {"ParentWindow", 
uno::Any(SfxStoringHelper::GetModelXWindow(m_xModel))},
-                        }));
+                        {"ParentWindow", 
uno::Any(SfxStoringHelper::GetModelXWindow(m_xModel))},
+                    }));
+
+                    uno::Reference< ui::dialogs::XExecutableDialog > 
xFilterDialog(
+                                                
comphelper::getProcessServiceFactory()->createInstanceWithArguments(aServiceName,
 aDialogArgs), uno::UNO_QUERY );
+                    uno::Reference< beans::XPropertyAccess > 
xFilterProperties( xFilterDialog, uno::UNO_QUERY );
+
+                    if( xFilterDialog.is() && xFilterProperties.is() )
+                    {
+                        bDialogUsed = true;
 
-                        uno::Reference< ui::dialogs::XExecutableDialog > 
xFilterDialog(
-                                                    
comphelper::getProcessServiceFactory()->createInstanceWithArguments(aServiceName,
 aDialogArgs), uno::UNO_QUERY );
-                        uno::Reference< beans::XPropertyAccess > 
xFilterProperties( xFilterDialog, uno::UNO_QUERY );
+                        uno::Reference< document::XExporter > xExporter( 
xFilterDialog, uno::UNO_QUERY );
+                        if( xExporter.is() )
+                            xExporter->setSourceDocument( GetModel() );
 
-                        if( xFilterDialog.is() && xFilterProperties.is() )
+                        uno::Sequence< beans::PropertyValue > aPropsForDialog;
+                        GetMediaDescr() >> aPropsForDialog;
+                        xFilterProperties->setPropertyValues( aPropsForDialog 
);
+
+                        if( !xFilterDialog->execute() )
                         {
-                            bDialogUsed = true;
-
-                            uno::Reference< document::XExporter > xExporter( 
xFilterDialog, uno::UNO_QUERY );
-                            if( xExporter.is() )
-                                xExporter->setSourceDocument( GetModel() );
-
-                            uno::Sequence< beans::PropertyValue > 
aPropsForDialog;
-                            GetMediaDescr() >> aPropsForDialog;
-                            xFilterProperties->setPropertyValues( 
aPropsForDialog );
-
-                            if( !xFilterDialog->execute() )
-                            {
-                                throw task::ErrorCodeIOException(
-                                    
("ModelData_Impl::ExecuteFilterDialog_Impl:"
-                                     " ERRCODE_IO_ABORT"),
-                                    uno::Reference< uno::XInterface >(),
-                                    sal_uInt32(ERRCODE_IO_ABORT));
-                            }
-
-                            uno::Sequence< beans::PropertyValue > 
aPropsFromDialog =
-                                                                        
xFilterProperties->getPropertyValues();
-                            const sal_Int32 nPropsLen 
{aPropsFromDialog.getLength()};
-                            for ( sal_Int32 nInd = 0; nInd < nPropsLen; ++nInd 
)
-                                GetMediaDescr()[aPropsFromDialog[nInd].Name] = 
aPropsFromDialog[nInd].Value;
+                            throw task::ErrorCodeIOException(
+                                ("ModelData_Impl::ExecuteFilterDialog_Impl:"
+                                 " ERRCODE_IO_ABORT"),
+                                uno::Reference< uno::XInterface >(),
+                                sal_uInt32(ERRCODE_IO_ABORT));
                         }
-                    }
 
-                    break;
+                        uno::Sequence< beans::PropertyValue > aPropsFromDialog 
=
+                                                                    
xFilterProperties->getPropertyValues();
+                        for ( const auto& rProp : aPropsFromDialog )
+                            GetMediaDescr()[rProp.Name] = rProp.Value;
+                    }
                 }
             }
         }
@@ -1740,23 +1735,21 @@ void SfxStoringHelper::SetDocInfoState(
         uno::Reference< beans::XPropertyContainer > xContainer( xSet, 
uno::UNO_QUERY );
         uno::Reference< beans::XPropertySetInfo > xSetInfo = 
xSet->getPropertySetInfo();
         uno::Sequence< beans::Property > lProps = xSetInfo->getProperties();
-        const beans::Property* pProps = lProps.getConstArray();
-        const sal_Int32 nPropLen = lProps.getLength();
-        for (sal_Int32 i=0; i<nPropLen; ++i)
+        for (const beans::Property& rProp : lProps)
         {
-            uno::Any aValue = xPropSet->getPropertyValue( pProps[i].Name );
-            if ( pProps[i].Attributes & 
css::beans::PropertyAttribute::REMOVABLE )
+            uno::Any aValue = xPropSet->getPropertyValue( rProp.Name );
+            if ( rProp.Attributes & css::beans::PropertyAttribute::REMOVABLE )
             {
                 try
                 {
                     // QUESTION: DefaultValue?!
-                    xContainer->addProperty( pProps[i].Name, 
pProps[i].Attributes, aValue );
+                    xContainer->addProperty( rProp.Name, rProp.Attributes, 
aValue );
                 }
                 catch (beans::PropertyExistException const&) {}
                 try
                 {
                     // it is possible that the propertysets from XML and 
binary files differ; we shouldn't break then
-                    xSet->setPropertyValue( pProps[i].Name, aValue );
+                    xSet->setPropertyValue( rProp.Name, aValue );
                 }
                 catch ( const uno::Exception& ) {}
             }
diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx
index 5ecfad4faf8e..d4b30edfa5b2 100644
--- a/sfx2/source/doc/objmisc.cxx
+++ b/sfx2/source/doc/objmisc.cxx
@@ -259,9 +259,9 @@ bool SfxObjectShell::IsModified()
     if (pImpl->mpObjectContainer)
     {
         uno::Sequence < OUString > aNames = 
GetEmbeddedObjectContainer().GetObjectNames();
-        for ( sal_Int32 n=0; n<aNames.getLength(); n++ )
+        for ( const auto& rName : aNames )
         {
-            uno::Reference < embed::XEmbeddedObject > xObj = 
GetEmbeddedObjectContainer().GetEmbeddedObject( aNames[n] );
+            uno::Reference < embed::XEmbeddedObject > xObj = 
GetEmbeddedObjectContainer().GetEmbeddedObject( rName );
             OSL_ENSURE( xObj.is(), "An empty entry in the embedded objects 
list!" );
             if ( xObj.is() )
             {
@@ -1802,10 +1802,9 @@ bool SfxObjectShell_Impl::hasTrustedScriptingSignature( 
bool bAllowUIToAddAuthor
                 if ( nScriptingSignatureState == SignatureState::OK
                   || nScriptingSignatureState == SignatureState::NOTVALIDATED )
                 {
-                    for ( sal_Int32 nInd = 0; !bResult && nInd < 
aInfo.getLength(); nInd++ )
-                    {
-                        bResult = xSigner->isAuthorTrusted( aInfo[nInd].Signer 
);
-                    }
+                    bResult = std::any_of(aInfo.begin(), aInfo.end(),
+                        [&xSigner](const 
security::DocumentSignatureInformation& rInfo) {
+                            return xSigner->isAuthorTrusted( rInfo.Signer ); 
});
 
                     if ( !bResult && bAllowUIToAddAuthor )
                     {
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 517d30a7c950..69e106319b16 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -1134,17 +1134,17 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet)
                         // Loop over the CMIS Properties to find 
cmis:isVersionSeriesCheckedOut
                         bool bIsGoogleFile = false;
                         bool bCheckedOut = false;
-                        for ( sal_Int32 i = 0; i < 
aCmisProperties.getLength(); ++i )
+                        for ( const auto& rCmisProperty : aCmisProperties )
                         {
-                            if ( aCmisProperties[i].Id == 
"cmis:isVersionSeriesCheckedOut" )
+                            if ( rCmisProperty.Id == 
"cmis:isVersionSeriesCheckedOut" )
                             {
                                 uno::Sequence< sal_Bool > bTmp;
-                                aCmisProperties[i].Value >>= bTmp;
+                                rCmisProperty.Value >>= bTmp;
                                 bCheckedOut = bTmp[0];
                             }
                             // using title to know if it's a Google Drive file
                             // maybe there's a safer way.
-                            if ( aCmisProperties[i].Name == "title" )
+                            if ( rCmisProperty.Name == "title" )
                                 bIsGoogleFile = true;
                         }
                         bShow = !bCheckedOut && !bIsGoogleFile;
@@ -1168,17 +1168,14 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet)
                     if ( xCmisDoc->isVersionable( ) && 
aCmisProperties.hasElements( ) )
                     {
                         // Loop over the CMIS Properties to find 
cmis:isVersionSeriesCheckedOut
-                        bool bFoundCheckedout = false;
                         bool bCheckedOut = false;
-                        for ( sal_Int32 i = 0; i < aCmisProperties.getLength() 
&& !bFoundCheckedout; ++i )
+                        auto pProp = std::find_if(aCmisProperties.begin(), 
aCmisProperties.end(),
+                            [](const document::CmisProperty& rProp) { return 
rProp.Id == "cmis:isVersionSeriesCheckedOut"; });
+                        if (pProp != aCmisProperties.end())
                         {
-                            if ( aCmisProperties[i].Id == 
"cmis:isVersionSeriesCheckedOut" )
-                            {
-                                bFoundCheckedout = true;
-                                uno::Sequence< sal_Bool > bTmp;
-                                aCmisProperties[i].Value >>= bTmp;
-                                bCheckedOut = bTmp[0];
-                            }
+                            uno::Sequence< sal_Bool > bTmp;
+                            pProp->Value >>= bTmp;
+                            bCheckedOut = bTmp[0];
                         }
                         bShow = bCheckedOut;
                     }
@@ -1516,25 +1513,24 @@ SignatureState 
SfxObjectShell::ImplCheckSignaturesInformation( const uno::Sequen
 {
     bool bCertValid = true;
     SignatureState nResult = SignatureState::NOSIGNATURES;
-    int nInfos = aInfos.getLength();
     bool bCompleteSignature = true;
-    if( nInfos )
+    if( aInfos.hasElements() )
     {
         nResult = SignatureState::OK;
-        for ( int n = 0; n < nInfos; n++ )
+        for ( const auto& rInfo : aInfos )
         {
             if ( bCertValid )
             {
-                sal_Int32 nCertStat = aInfos[n].CertificateStatus;
+                sal_Int32 nCertStat = rInfo.CertificateStatus;
                 bCertValid = nCertStat == security::CertificateValidity::VALID;
             }
 
-            if ( !aInfos[n].SignatureIsValid )
+            if ( !rInfo.SignatureIsValid )
             {
                 nResult = SignatureState::BROKEN;
                 break; // we know enough
             }
-            bCompleteSignature &= !aInfos[n].PartialDocumentSignature;
+            bCompleteSignature &= !rInfo.PartialDocumentSignature;
         }
     }
 
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index 86ca3b03375f..9375989e35e3 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -537,11 +537,11 @@ bool SfxObjectShell::ImportFromGeneratedStream_Impl(
         pMedium->GetItemSet()->Put( aSet );
         pMedium->CanDisposeStorage_Impl( false );
         uno::Reference<text::XTextRange> xInsertTextRange;
-        for (sal_Int32 i = 0; i < rMediaDescr.getLength(); ++i)
+        for (const auto& rProp : rMediaDescr)
         {
-            if (rMediaDescr[i].Name == "TextInsertModeRange")
+            if (rProp.Name == "TextInsertModeRange")
             {
-                rMediaDescr[i].Value >>= xInsertTextRange;
+                rProp.Value >>= xInsertTextRange;
             }
         }
 
@@ -884,56 +884,54 @@ ErrCode SfxObjectShell::HandleFilter( SfxMedium* pMedium, 
SfxObjectShell const *
                 Any aAny = xFilterCFG->getByName( pFilter->GetName() );
                 if ( aAny >>= aProps )
                 {
-                    sal_Int32 nPropertyCount = aProps.getLength();
-                    for( sal_Int32 nProperty=0; nProperty < nPropertyCount; 
++nProperty )
-                        if( aProps[nProperty].Name == "UIComponent" )
+                    auto pProp = std::find_if(aProps.begin(), aProps.end(),
+                        [](const PropertyValue& rProp) { return rProp.Name == 
"UIComponent"; });
+                    if (pProp != aProps.end())
+                    {
+                        OUString aServiceName;
+                        pProp->Value >>= aServiceName;
+                        if( !aServiceName.isEmpty() )
                         {
-                            OUString aServiceName;
-                            aProps[nProperty].Value >>= aServiceName;
-                            if( !aServiceName.isEmpty() )
+                            css::uno::Reference< XInteractionHandler > 
rHandler = pMedium->GetInteractionHandler();
+                            if( rHandler.is() )
                             {
-                                css::uno::Reference< XInteractionHandler > 
rHandler = pMedium->GetInteractionHandler();
-                                if( rHandler.is() )
+                                // we need some properties in the media 
descriptor, so we have to make sure that they are in
+                                Any aStreamAny;
+                                aStreamAny <<= pMedium->GetInputStream();
+                                if ( pSet->GetItemState( SID_INPUTSTREAM ) < 
SfxItemState::SET )
+                                    pSet->Put( SfxUnoAnyItem( SID_INPUTSTREAM, 
aStreamAny ) );
+                                if ( pSet->GetItemState( SID_FILE_NAME ) < 
SfxItemState::SET )
+                                    pSet->Put( SfxStringItem( SID_FILE_NAME, 
pMedium->GetName() ) );
+                                if ( pSet->GetItemState( SID_FILTER_NAME ) < 
SfxItemState::SET )
+                                    pSet->Put( SfxStringItem( SID_FILTER_NAME, 
pFilter->GetName() ) );
+
+                                Sequence< PropertyValue > rProperties;
+                                TransformItems( SID_OPENDOC, *pSet, 
rProperties );

... etc. - the rest is truncated
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to