[Libreoffice-commits] core.git: cppuhelper/source cui/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Wed May 20 06:38:27 UTC 2020


 cppuhelper/source/propertysetmixin.cxx            |   52 +++++-----
 cppuhelper/source/servicemanager.cxx              |   28 ++---
 cppuhelper/source/tdmgr.cxx                       |   16 +--
 cppuhelper/source/typemanager.cxx                 |   19 +--
 cui/source/customize/SvxConfigPageHelper.cxx      |   58 ++++++------
 cui/source/customize/SvxNotebookbarConfigPage.cxx |    6 -
 cui/source/customize/cfg.cxx                      |  105 ++++++++++------------
 cui/source/customize/cfgutil.cxx                  |   27 ++---
 cui/source/dialogs/colorpicker.cxx                |   10 +-
 cui/source/dialogs/cuicharmap.cxx                 |   24 ++---
 cui/source/dialogs/hldocntp.cxx                   |   12 +-
 cui/source/dialogs/insdlg.cxx                     |   12 +-
 cui/source/dialogs/scriptdlg.cxx                  |   38 +++----
 cui/source/options/optaboutconfig.cxx             |   24 ++---
 cui/source/options/optcolor.cxx                   |    7 -
 cui/source/options/optlingu.cxx                   |   73 ++++++---------
 cui/source/options/treeopt.cxx                    |   15 +--
 cui/source/options/webconninfo.cxx                |   22 ++--
 18 files changed, 264 insertions(+), 284 deletions(-)

New commits:
commit 9a0faf09a8963556eafe172ae16735472f24659d
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue May 19 19:16:41 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed May 20 08:37:46 2020 +0200

    use for-range on Sequence in cppuhelper,cui
    
    Change-Id: I482d48e29ddc9690d9c671cde2f6b0c611ec378d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94550
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/cppuhelper/source/propertysetmixin.cxx b/cppuhelper/source/propertysetmixin.cxx
index 899567e85686..c7c8154896a4 100644
--- a/cppuhelper/source/propertysetmixin.cxx
+++ b/cppuhelper/source/propertysetmixin.cxx
@@ -137,26 +137,26 @@ void Data::initProperties(
     if (!seen->insert(ifc->getName()).second)
         return;
 
-    css::uno::Sequence<
-    css::uno::Reference< css::reflection::XTypeDescription > > bases(
+    const css::uno::Sequence<
+        css::uno::Reference< css::reflection::XTypeDescription > > bases(
         ifc->getBaseTypes());
-    for (sal_Int32 i = 0; i < bases.getLength(); ++i) {
-        initProperties(bases[i], absentOptional, handleNames, seen);
+    for (const auto & i : bases) {
+        initProperties(i, absentOptional, handleNames, seen);
     }
-    css::uno::Sequence<
-    css::uno::Reference<
-    css::reflection::XInterfaceMemberTypeDescription > > members(
+    const css::uno::Sequence<
+        css::uno::Reference<
+            css::reflection::XInterfaceMemberTypeDescription > > members(
         ifc->getMembers());
     OUString const * absentBegin = absentOptional.getConstArray();
     OUString const * absentEnd =
         absentBegin + absentOptional.getLength();
-    for (sal_Int32 i = 0; i < members.getLength(); ++i) {
-        if (members[i]->getTypeClass()
+    for (const auto & m : members) {
+        if (m->getTypeClass()
             == css::uno::TypeClass_INTERFACE_ATTRIBUTE)
         {
             css::uno::Reference<
             css::reflection::XInterfaceAttributeTypeDescription2 > attr(
-                members[i], css::uno::UNO_QUERY_THROW);
+                m, css::uno::UNO_QUERY_THROW);
             sal_Int16 attrAttribs = 0;
             if (attr->isBound()) {
                 attrAttribs |= css::beans::PropertyAttribute::BOUND;
@@ -174,19 +174,19 @@ void Data::initProperties(
             //XXX  Special interpretation of getter/setter exceptions only
             // works if the specified exceptions are of the exact type, not
             // of a supertype:
-            for (sal_Int32 j = 0; j < excs.getLength(); ++j) {
-                if ( excs[j]->getName() == "com.sun.star.beans.UnknownPropertyException" )
+            for (const auto & ex : std::as_const(excs)) {
+                if ( ex->getName() == "com.sun.star.beans.UnknownPropertyException" )
                 {
                     bGetUnknown = true;
                     break;
                 }
             }
             excs = attr->getSetExceptions();
-            for (sal_Int32 j = 0; j < excs.getLength(); ++j) {
-                if ( excs[j]->getName() == "com.sun.star.beans.UnknownPropertyException" )
+            for (const auto & ex : std::as_const(excs)) {
+                if ( ex->getName() == "com.sun.star.beans.UnknownPropertyException" )
                 {
                     bSetUnknown = true;
-                } else if ( excs[j]->getName() == "com.sun.star.beans.PropertyVetoException" )
+                } else if ( ex->getName() == "com.sun.star.beans.PropertyVetoException" )
                 {
                     attrAttribs
                         |= css::beans::PropertyAttribute::CONSTRAINED;
@@ -239,7 +239,7 @@ void Data::initProperties(
                 throw css::uno::RuntimeException(
                     "interface type has too many attributes");
             }
-            OUString name(members[i]->getMemberName());
+            OUString name(m->getMemberName());
             if (!properties.emplace(
                         name,
                         PropertyData(
@@ -1117,23 +1117,23 @@ PropertySetMixinImpl::getPropertyValues()
 void PropertySetMixinImpl::setPropertyValues(
     css::uno::Sequence< css::beans::PropertyValue > const & props)
 {
-    for (sal_Int32 i = 0; i < props.getLength(); ++i) {
-        if (props[i].Handle != -1
-            && (props[i].Name
+    for (const auto & p : props) {
+        if (p.Handle != -1
+            && (p.Name
                 != m_impl->translateHandle(
                     static_cast< css::beans::XPropertySet * >(this),
-                    props[i].Handle)))
+                    p.Handle)))
         {
             throw css::beans::UnknownPropertyException(
-                ("name " + props[i].Name + " does not match handle "
-                 + OUString::number(props[i].Handle)),
+                ("name " + p.Name + " does not match handle "
+                 + OUString::number(p.Handle)),
                 static_cast< css::beans::XPropertySet * >(this));
         }
         m_impl->setProperty(
-            static_cast< css::beans::XPropertySet * >(this), props[i].Name,
-            props[i].Value,
-            props[i].State == css::beans::PropertyState_AMBIGUOUS_VALUE,
-            props[i].State == css::beans::PropertyState_DEFAULT_VALUE, 0);
+            static_cast< css::beans::XPropertySet * >(this), p.Name,
+            p.Value,
+            p.State == css::beans::PropertyState_AMBIGUOUS_VALUE,
+            p.State == css::beans::PropertyState_DEFAULT_VALUE, 0);
     }
 }
 
diff --git a/cppuhelper/source/servicemanager.cxx b/cppuhelper/source/servicemanager.cxx
index 00b9c40213d5..2ba6ae51a888 100644
--- a/cppuhelper/source/servicemanager.cxx
+++ b/cppuhelper/source/servicemanager.cxx
@@ -1001,29 +1001,29 @@ void cppuhelper::ServiceManager::insert(css::uno::Any const & aElement)
     if (aElement >>= args) {
         std::vector< OUString > uris;
         css::uno::Reference< css::uno::XComponentContext > alienContext;
-        for (sal_Int32 i = 0; i < args.getLength(); ++i) {
-            if (args[i].Name == "uri") {
+        for (const auto & arg : std::as_const(args)) {
+            if (arg.Name == "uri") {
                 OUString uri;
-                if (!(args[i].Value >>= uri)) {
+                if (!(arg.Value >>= uri)) {
                     throw css::lang::IllegalArgumentException(
                         "Bad uri argument",
                         static_cast< cppu::OWeakObject * >(this), 0);
                 }
                 uris.push_back(uri);
-            } else if (args[i].Name == "component-context") {
+            } else if (arg.Name == "component-context") {
                 if (alienContext.is()) {
                     throw css::lang::IllegalArgumentException(
                         "Multiple component-context arguments",
                         static_cast< cppu::OWeakObject * >(this), 0);
                 }
-                if (!(args[i].Value >>= alienContext) || !alienContext.is()) {
+                if (!(arg.Value >>= alienContext) || !alienContext.is()) {
                     throw css::lang::IllegalArgumentException(
                         "Bad component-context argument",
                         static_cast< cppu::OWeakObject * >(this), 0);
                 }
             } else {
                 throw css::lang::IllegalArgumentException(
-                    "Bad argument " + args[i].Name,
+                    "Bad argument " + arg.Name,
                     static_cast< cppu::OWeakObject * >(this), 0);
             }
         }
@@ -1063,14 +1063,14 @@ void cppuhelper::ServiceManager::remove(css::uno::Any const & aElement)
     css::uno::Sequence< css::beans::NamedValue > args;
     if (aElement >>= args) {
         std::vector< OUString > uris;
-        for (sal_Int32 i = 0; i < args.getLength(); ++i) {
-            if (args[i].Name != "uri") {
+        for (const auto & i : std::as_const(args)) {
+            if (i.Name != "uri") {
                 throw css::lang::IllegalArgumentException(
-                    "Bad argument " + args[i].Name,
+                    "Bad argument " + i.Name,
                     static_cast< cppu::OWeakObject * >(this), 0);
             }
             OUString uri;
-            if (!(args[i].Value >>= uri)) {
+            if (!(i.Value >>= uri)) {
                 throw css::lang::IllegalArgumentException(
                     "Bad uri argument",
                     static_cast< cppu::OWeakObject * >(this), 0);
@@ -1528,11 +1528,11 @@ void cppuhelper::ServiceManager::insertLegacyFactory(
         extra.namedImplementations.emplace(name, impl);
     }
     extra.dynamicImplementations.emplace(factoryInfo, impl);
-    css::uno::Sequence< OUString > services(
+    const css::uno::Sequence< OUString > services(
         factoryInfo->getSupportedServiceNames());
-    for (sal_Int32 i = 0; i != services.getLength(); ++i) {
-        impl->services.push_back(services[i]);
-        extra.services[services[i]].push_back(impl);
+    for (const auto & i : services) {
+        impl->services.push_back(i);
+        extra.services[i].push_back(impl);
     }
     if (insertExtraData(extra) && comp.is()) {
         comp->addEventListener(this);
diff --git a/cppuhelper/source/tdmgr.cxx b/cppuhelper/source/tdmgr.cxx
index e11b6d6077f3..1e5826e248c7 100644
--- a/cppuhelper/source/tdmgr.cxx
+++ b/cppuhelper/source/tdmgr.cxx
@@ -204,20 +204,20 @@ static typelib_TypeDescription * createCTD(
         Reference< XTypeDescription > xType( xAttribute->getType() );
         OUString aMemberTypeName( xType->getName() );
         std::vector< rtl_uString * > getExc;
-        Sequence< Reference< XCompoundTypeDescription > > getExcs(
+        const Sequence< Reference< XCompoundTypeDescription > > getExcs(
             xAttribute->getGetExceptions() );
-        for (sal_Int32 i = 0; i != getExcs.getLength(); ++i)
+        for (const auto & ctd : getExcs)
         {
-            OSL_ASSERT( getExcs[i].is() );
-            getExc.push_back( getExcs[i]->getName().pData );
+            OSL_ASSERT( ctd.is() );
+            getExc.push_back( ctd->getName().pData );
         }
         std::vector< rtl_uString * > setExc;
-        Sequence< Reference< XCompoundTypeDescription > > setExcs(
+        const Sequence< Reference< XCompoundTypeDescription > > setExcs(
             xAttribute->getSetExceptions() );
-        for (sal_Int32 i = 0; i != setExcs.getLength(); ++i)
+        for (const auto & ctd : setExcs)
         {
-            OSL_ASSERT( setExcs[i].is() );
-            setExc.push_back( setExcs[i]->getName().pData );
+            OSL_ASSERT( ctd.is() );
+            setExc.push_back( ctd->getName().pData );
         }
         typelib_typedescription_newExtendedInterfaceAttribute(
             reinterpret_cast<typelib_InterfaceAttributeTypeDescription **>(&pRet),
diff --git a/cppuhelper/source/typemanager.cxx b/cppuhelper/source/typemanager.cxx
index f3fa99ac9769..3a3866b60f6d 100644
--- a/cppuhelper/source/typemanager.cxx
+++ b/cppuhelper/source/typemanager.cxx
@@ -838,13 +838,13 @@ void BaseOffset::calculateBases(
     css::uno::Reference< css::reflection::XInterfaceTypeDescription2 > const &
         description)
 {
-    css::uno::Sequence<
+    const css::uno::Sequence<
         css::uno::Reference < css::reflection::XTypeDescription > > bases(
             description->getBaseTypes());
-    for (sal_Int32 i = 0; i != bases.getLength(); ++i) {
+    for (const auto & i : bases) {
         calculate(
             css::uno::Reference< css::reflection::XInterfaceTypeDescription2 >(
-                resolveTypedefs(css::uno::makeAny(bases[i])),
+                resolveTypedefs(css::uno::makeAny(i)),
                 css::uno::UNO_QUERY_THROW));
     }
 }
@@ -1693,8 +1693,8 @@ bool Enumeration::matches(css::uno::TypeClass tc) const {
     if (!types_.hasElements()) {
         return true;
     }
-    for (sal_Int32 i = 0; i != types_.getLength(); ++i) {
-        if (types_[i] == tc) {
+    for (const auto & i : types_) {
+        if (i == tc) {
             return true;
         }
     }
@@ -2133,15 +2133,14 @@ css::uno::Any cppuhelper::TypeManager::getInterfaceMember(
         return css::uno::Any();
     }
     OUString member(name.copy(separator + std::strlen("::")));
-    css::uno::Sequence<
+    const css::uno::Sequence<
         css::uno::Reference<
             css::reflection::XInterfaceMemberTypeDescription > > mems(
                 ifc->getMembers());
-    for (sal_Int32 i = 0; i != mems.getLength(); ++i) {
-        if (mems[i]->getMemberName() == member) {
+    for (const auto & m : mems) {
+        if (m->getMemberName() == member) {
             return css::uno::makeAny<
-                css::uno::Reference< css::reflection::XTypeDescription > >(
-                    mems[i]);
+                css::uno::Reference< css::reflection::XTypeDescription > >(m);
         }
     }
     return css::uno::Any();
diff --git a/cui/source/customize/SvxConfigPageHelper.cxx b/cui/source/customize/SvxConfigPageHelper.cxx
index ead3f59da7d4..3ac1ca9e479f 100644
--- a/cui/source/customize/SvxConfigPageHelper.cxx
+++ b/cui/source/customize/SvxConfigPageHelper.cxx
@@ -266,11 +266,11 @@ OUString SvxConfigPageHelper::GetUIModuleName(
 
         if ( a >>= aSeq )
         {
-            for ( sal_Int32 i = 0; i < aSeq.getLength(); ++i )
+            for ( css::beans::PropertyValue const & rProp : std::as_const(aSeq) )
             {
-                if ( aSeq[i].Name == "ooSetupFactoryUIName" )
+                if ( rProp.Name == "ooSetupFactoryUIName" )
                 {
-                    aSeq[i].Value >>= aModuleUIName;
+                    rProp.Value >>= aModuleUIName;
                     break;
                 }
             }
@@ -301,30 +301,30 @@ bool SvxConfigPageHelper::GetMenuItemData(
 {
     try
     {
-        css::uno::Sequence< css::beans::PropertyValue > aProp;
-        if ( rItemContainer->getByIndex( nIndex ) >>= aProp )
+        css::uno::Sequence< css::beans::PropertyValue > aProps;
+        if ( rItemContainer->getByIndex( nIndex ) >>= aProps )
         {
-            for ( sal_Int32 i = 0; i < aProp.getLength(); ++i )
+            for ( css::beans::PropertyValue const & rProp : std::as_const(aProps) )
             {
-                if ( aProp[i].Name == ITEM_DESCRIPTOR_COMMANDURL )
+                if ( rProp.Name == ITEM_DESCRIPTOR_COMMANDURL )
                 {
-                    aProp[i].Value >>= rCommandURL;
+                    rProp.Value >>= rCommandURL;
                 }
-                else if ( aProp[i].Name == ITEM_DESCRIPTOR_CONTAINER )
+                else if ( rProp.Name == ITEM_DESCRIPTOR_CONTAINER )
                 {
-                    aProp[i].Value >>= rSubMenu;
+                    rProp.Value >>= rSubMenu;
                 }
-                else if ( aProp[i].Name == ITEM_DESCRIPTOR_STYLE )
+                else if ( rProp.Name == ITEM_DESCRIPTOR_STYLE )
                 {
-                    aProp[i].Value >>= rStyle;
+                    rProp.Value >>= rStyle;
                 }
-                else if ( aProp[i].Name == ITEM_DESCRIPTOR_LABEL )
+                else if ( rProp.Name == ITEM_DESCRIPTOR_LABEL )
                 {
-                    aProp[i].Value >>= rLabel;
+                    rProp.Value >>= rLabel;
                 }
-                else if ( aProp[i].Name == ITEM_DESCRIPTOR_TYPE )
+                else if ( rProp.Name == ITEM_DESCRIPTOR_TYPE )
                 {
-                    aProp[i].Value >>= rType;
+                    rProp.Value >>= rType;
                 }
             }
 
@@ -349,30 +349,30 @@ bool SvxConfigPageHelper::GetToolbarItemData(
 {
     try
     {
-        css::uno::Sequence< css::beans::PropertyValue > aProp;
-        if ( rItemContainer->getByIndex( nIndex ) >>= aProp )
+        css::uno::Sequence< css::beans::PropertyValue > aProps;
+        if ( rItemContainer->getByIndex( nIndex ) >>= aProps )
         {
-            for ( sal_Int32 i = 0; i < aProp.getLength(); ++i )
+            for ( css::beans::PropertyValue const & rProp : std::as_const(aProps) )
             {
-                if ( aProp[i].Name == ITEM_DESCRIPTOR_COMMANDURL )
+                if ( rProp.Name == ITEM_DESCRIPTOR_COMMANDURL )
                 {
-                    aProp[i].Value >>= rCommandURL;
+                    rProp.Value >>= rCommandURL;
                 }
-                else if ( aProp[i].Name == ITEM_DESCRIPTOR_STYLE )
+                else if ( rProp.Name == ITEM_DESCRIPTOR_STYLE )
                 {
-                    aProp[i].Value >>= rStyle;
+                    rProp.Value >>= rStyle;
                 }
-                else if ( aProp[i].Name == ITEM_DESCRIPTOR_LABEL )
+                else if ( rProp.Name == ITEM_DESCRIPTOR_LABEL )
                 {
-                    aProp[i].Value >>= rLabel;
+                    rProp.Value >>= rLabel;
                 }
-                else if ( aProp[i].Name == ITEM_DESCRIPTOR_TYPE )
+                else if ( rProp.Name == ITEM_DESCRIPTOR_TYPE )
                 {
-                    aProp[i].Value >>= rType;
+                    rProp.Value >>= rType;
                 }
-                else if ( aProp[i].Name == ITEM_DESCRIPTOR_ISVISIBLE )
+                else if ( rProp.Name == ITEM_DESCRIPTOR_ISVISIBLE )
                 {
-                    aProp[i].Value >>= rIsVisible;
+                    rProp.Value >>= rIsVisible;
                 }
             }
 
diff --git a/cui/source/customize/SvxNotebookbarConfigPage.cxx b/cui/source/customize/SvxNotebookbarConfigPage.cxx
index 2d6bdca787b1..584767d6af5a 100644
--- a/cui/source/customize/SvxNotebookbarConfigPage.cxx
+++ b/cui/source/customize/SvxNotebookbarConfigPage.cxx
@@ -241,9 +241,9 @@ void SvxConfigPage::InsertEntryIntoNotebookbarTabUI(const OUString& sClassId,
     }
 
     OUString aLabel;
-    for (sal_Int32 i = 0; i < aPropSeq.getLength(); ++i)
-        if (aPropSeq[i].Name == "Name")
-            aPropSeq[i].Value >>= aLabel;
+    for (auto const& prop : std::as_const(aPropSeq))
+        if (prop.Name == "Name")
+            prop.Value >>= aLabel;
 
     OUString aName = SvxConfigPageHelper::stripHotKey(aLabel);
 
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index 67466b3bf6d2..dae7f6a547b5 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -110,7 +110,7 @@ void printPropertySet(
 
     SAL_WARN("cui", "printPropertySet: " << aPropDetails.getLength() << " properties" );
 
-    for ( sal_Int32 i = 0; i < aPropDetails.getLength(); ++i )
+    for ( sal_Int32 i = 0; i < aPropDetails.(); ++i )
     {
         OUString tmp;
         sal_Int32 ival;
@@ -136,7 +136,7 @@ void printProperties(
     const OUString& prefix,
     const uno::Sequence< beans::PropertyValue >& aProp )
 {
-    for ( sal_Int32 i = 0; i < aProp.getLength(); ++i )
+    for ( sal_Int32 i = 0; i < aProp.(); ++i )
     {
         OUString tmp;
 
@@ -479,23 +479,23 @@ void SaveInData::LoadSubMenus( const uno::Reference< container::XIndexAccess >&
                     if ( a >>= aPropSeq )
                     {
                         OUString aMenuLabel;
-                        for ( sal_Int32 i = 0; i < aPropSeq.getLength(); ++i )
+                        for ( const beans::PropertyValue& prop : std::as_const(aPropSeq) )
                         {
                             if ( bContextMenu )
                             {
-                                if ( aPropSeq[i].Name == "PopupLabel" )
+                                if ( prop.Name == "PopupLabel" )
                                 {
-                                    aPropSeq[i].Value >>= aLabel;
+                                    prop.Value >>= aLabel;
                                     break;
                                 }
-                                else if ( aPropSeq[i].Name == "Label" )
+                                else if ( prop.Name == "Label" )
                                 {
-                                    aPropSeq[i].Value >>= aMenuLabel;
+                                    prop.Value >>= aMenuLabel;
                                 }
                             }
-                            else if ( aPropSeq[i].Name == "Label" )
+                            else if ( prop.Name == "Label" )
                             {
-                                aPropSeq[i].Value >>= aLabel;
+                                prop.Value >>= aLabel;
                                 break;
                             }
                         }
@@ -1164,10 +1164,8 @@ void SvxConfigPage::Reset( const SfxItemSet* )
                 DBG_UNHANDLED_EXCEPTION("cui.customize");
             }
 
-            for ( sal_Int32 i = 0; i < aFrameList.getLength(); ++i )
+            for ( uno::Reference < frame::XFrame > const & xf : std::as_const(aFrameList) )
             {
-                uno::Reference < frame::XFrame > xf = aFrameList[i];
-
                 if ( xf.is() && xf != m_xFrame )
                 {
                     OUString aCheckId;
@@ -1922,11 +1920,11 @@ sal_Int32 ToolbarSaveInData::GetSystemStyle( const OUString& rResourceURL )
 
             if ( a >>= aProps )
             {
-                for ( sal_Int32 i = 0; i < aProps.getLength(); ++i )
+                for ( beans::PropertyValue const & prop : std::as_const(aProps) )
                 {
-                    if ( aProps[ i ].Name == ITEM_DESCRIPTOR_STYLE )
+                    if ( prop.Name == ITEM_DESCRIPTOR_STYLE )
                     {
-                        aProps[i].Value >>= result;
+                        prop.Value >>= result;
                         break;
                     }
                 }
@@ -2012,11 +2010,11 @@ void ToolbarSaveInData::SetSystemStyle(
 
         if ( a >>= aProps )
         {
-            for ( sal_Int32 i = 0; i < aProps.getLength(); ++i )
+            for ( beans::PropertyValue& prop : aProps )
             {
-                if ( aProps[ i ].Name == ITEM_DESCRIPTOR_STYLE )
+                if ( prop.Name == ITEM_DESCRIPTOR_STYLE )
                 {
-                    aProps[ i ].Value <<= nStyle;
+                    prop.Value <<= nStyle;
                     break;
                 }
             }
@@ -2049,11 +2047,11 @@ OUString ToolbarSaveInData::GetSystemUIName( const OUString& rResourceURL )
 
             if ( a >>= aProps )
             {
-                for ( sal_Int32 i = 0; i < aProps.getLength(); ++i )
+                for ( beans::PropertyValue const & prop : std::as_const(aProps) )
                 {
-                    if ( aProps[ i ].Name == ITEM_DESCRIPTOR_UINAME )
+                    if ( prop.Name == ITEM_DESCRIPTOR_UINAME )
                     {
-                        aProps[ i ].Value >>= result;
+                        prop.Value >>= result;
                     }
                 }
             }
@@ -2076,11 +2074,11 @@ OUString ToolbarSaveInData::GetSystemUIName( const OUString& rResourceURL )
             uno::Sequence< beans::PropertyValue > aPropSeq;
             if ( a >>= aPropSeq )
             {
-                for ( sal_Int32 i = 0; i < aPropSeq.getLength(); ++i )
+                for ( beans::PropertyValue const & prop : std::as_const(aPropSeq) )
                 {
-                    if ( aPropSeq[i].Name == ITEM_DESCRIPTOR_LABEL )
+                    if ( prop.Name == ITEM_DESCRIPTOR_LABEL )
                     {
-                        aPropSeq[i].Value >>= result;
+                        prop.Value >>= result;
                     }
                 }
             }
@@ -2105,28 +2103,26 @@ SvxEntries* ToolbarSaveInData::GetEntries()
 
         pRootEntry.reset( new SvxConfigEntry( "MainToolbars", OUString(), true, /*bParentData*/false) );
 
-        uno::Sequence< uno::Sequence < beans::PropertyValue > > info =
+        const uno::Sequence< uno::Sequence < beans::PropertyValue > > info =
             GetConfigManager()->getUIElementsInfo(
                 css::ui::UIElementType::TOOLBAR );
 
-        for ( sal_Int32 i = 0; i < info.getLength(); ++i )
+        for ( uno::Sequence<beans::PropertyValue> const & props : info )
         {
-            uno::Sequence< beans::PropertyValue > props = info[ i ];
-
             OUString url;
             OUString systemname;
             OUString uiname;
 
-            for ( sal_Int32 j = 0; j < props.getLength(); ++j )
+            for ( const beans::PropertyValue& prop : props )
             {
-                if ( props[ j ].Name == ITEM_DESCRIPTOR_RESOURCEURL )
+                if ( prop.Name == ITEM_DESCRIPTOR_RESOURCEURL )
                 {
-                    props[ j ].Value >>= url;
+                    prop.Value >>= url;
                     systemname = url.copy( url.lastIndexOf( '/' ) + 1 );
                 }
-                else if ( props[ j ].Name == ITEM_DESCRIPTOR_UINAME )
+                else if ( prop.Name == ITEM_DESCRIPTOR_UINAME )
                 {
-                    props[ j ].Value >>= uiname;
+                    prop.Value >>= uiname;
                 }
             }
 
@@ -2182,28 +2178,26 @@ SvxEntries* ToolbarSaveInData::GetEntries()
             // Retrieve also the parent toolbars to make it possible
             // to configure module toolbars and save them into the document
             // config manager.
-            uno::Sequence< uno::Sequence < beans::PropertyValue > > info_ =
+            const uno::Sequence< uno::Sequence < beans::PropertyValue > > info_ =
                 xParentCfgMgr->getUIElementsInfo(
                     css::ui::UIElementType::TOOLBAR );
 
-            for ( sal_Int32 i = 0; i < info_.getLength(); ++i )
+            for ( uno::Sequence<beans::PropertyValue> const & props : info_ )
             {
-                uno::Sequence< beans::PropertyValue > props = info_[ i ];
-
                 OUString url;
                 OUString systemname;
                 OUString uiname;
 
-                for ( sal_Int32 j = 0; j < props.getLength(); ++j )
+                for ( const beans::PropertyValue& prop : props )
                 {
-                    if ( props[ j ].Name == ITEM_DESCRIPTOR_RESOURCEURL )
+                    if ( prop.Name == ITEM_DESCRIPTOR_RESOURCEURL )
                     {
-                        props[ j ].Value >>= url;
+                        prop.Value >>= url;
                         systemname = url.copy( url.lastIndexOf( '/' ) + 1 );
                     }
-                    else if ( props[ j ].Name == ITEM_DESCRIPTOR_UINAME )
+                    else if ( prop.Name == ITEM_DESCRIPTOR_UINAME )
                     {
-                        props[ j ].Value >>= uiname;
+                        prop.Value >>= uiname;
                     }
                 }
 
@@ -2581,11 +2575,11 @@ void ToolbarSaveInData::LoadToolbar(
                     uno::Sequence< beans::PropertyValue > aPropSeq;
                     if ( a >>= aPropSeq )
                     {
-                        for ( sal_Int32 i = 0; i < aPropSeq.getLength(); ++i )
+                        for ( beans::PropertyValue const & prop : std::as_const(aPropSeq) )
                         {
-                            if ( aPropSeq[i].Name == "Name" )
+                            if ( prop.Name == "Name" )
                             {
-                                aPropSeq[i].Value >>= aLabel;
+                                prop.Value >>= aLabel;
                                 break;
                             }
                         }
@@ -2714,12 +2708,11 @@ SvxIconSelectorDialog::SvxIconSelectorDialog(weld::Window *pWindow,
     m_xImportedImageManager->initialize(aProp);
 
     ImageInfo aImageInfo1;
-    uno::Sequence< OUString > names;
     if ( m_xImportedImageManager.is() )
     {
-        names = m_xImportedImageManager->getAllImageNames( SvxConfigPageHelper::GetImageType() );
-        for ( sal_Int32 n = 0; n < names.getLength(); ++n )
-            aImageInfo1.emplace( names[n], false );
+        const uno::Sequence< OUString > names = m_xImportedImageManager->getAllImageNames( SvxConfigPageHelper::GetImageType() );
+        for (auto const & name : names )
+            aImageInfo1.emplace( name, false );
     }
 
     uno::Sequence< OUString > name( 1 );
@@ -2739,19 +2732,19 @@ SvxIconSelectorDialog::SvxIconSelectorDialog(weld::Window *pWindow,
 
     if ( m_xParentImageManager.is() )
     {
-        names = m_xParentImageManager->getAllImageNames( SvxConfigPageHelper::GetImageType() );
-        for ( sal_Int32 n = 0; n < names.getLength(); ++n )
-            aImageInfo.emplace( names[n], false );
+        const uno::Sequence< OUString > names = m_xParentImageManager->getAllImageNames( SvxConfigPageHelper::GetImageType() );
+        for ( auto const & i : names )
+            aImageInfo.emplace( i, false );
     }
 
-    names = m_xImageManager->getAllImageNames( SvxConfigPageHelper::GetImageType() );
-    for ( sal_Int32 n = 0; n < names.getLength(); ++n )
+    const uno::Sequence< OUString > names = m_xImageManager->getAllImageNames( SvxConfigPageHelper::GetImageType() );
+    for ( auto const & i : names )
     {
-        ImageInfo::iterator pIter = aImageInfo.find( names[n] );
+        ImageInfo::iterator pIter = aImageInfo.find( i );
         if ( pIter != aImageInfo.end() )
             pIter->second = true;
         else
-            aImageInfo.emplace( names[n], true );
+            aImageInfo.emplace( i, true );
     }
 
     // large growth factor, expecting many entries
diff --git a/cui/source/customize/cfgutil.cxx b/cui/source/customize/cfgutil.cxx
index 9b3e9ecdc4f0..d8ec5d79c765 100644
--- a/cui/source/customize/cfgutil.cxx
+++ b/cui/source/customize/cfgutil.cxx
@@ -500,7 +500,7 @@ void CuiConfigGroupListBox::FillScriptList(const css::uno::Reference< css::scrip
             // tdf#120362: Don't ask to enable disabled Java when filling script list
             css::uno::ContextLayer layer(comphelper::NoEnableJavaInteractionContext());
 
-            Sequence< Reference< browse::XBrowseNode > > children =
+            const Sequence< Reference< browse::XBrowseNode > > children =
                 xRootNode->getChildNodes();
             bool bIsRootNode = false;
 
@@ -524,9 +524,8 @@ void CuiConfigGroupListBox::FillScriptList(const css::uno::Reference< css::scrip
                 currentDocTitle = ::comphelper::DocumentInfo::getDocumentTitle( xDocument );
             }
 
-            for ( sal_Int32 n = 0; n < children.getLength(); ++n )
+            for ( Reference< browse::XBrowseNode > const & theChild : children )
             {
-                Reference< browse::XBrowseNode >& theChild = children[n];
                 bool bDisplay = true;
                 OUString uiName = theChild->getName();
                 if ( bIsRootNode )
@@ -557,15 +556,15 @@ void CuiConfigGroupListBox::FillScriptList(const css::uno::Reference< css::scrip
                     bool bChildOnDemand = false;
                     if ( !bCheapChildrenOnDemand && theChild->hasChildNodes() )
                     {
-                        Sequence< Reference< browse::XBrowseNode > > grandchildren =
+                        const Sequence< Reference< browse::XBrowseNode > > grandchildren =
                             theChild->getChildNodes();
 
-                        for ( sal_Int32 m = 0; m < grandchildren.getLength(); ++m )
+                        for ( const auto& rxNode : grandchildren )
                         {
-                            if ( grandchildren[m]->getType() == browse::BrowseNodeTypes::CONTAINER )
+                            if ( rxNode->getType() == browse::BrowseNodeTypes::CONTAINER )
                             {
                                 bChildOnDemand = true;
-                                m = grandchildren.getLength();
+                                break;
                             }
                         }
                     }
@@ -858,16 +857,16 @@ void CuiConfigGroupListBox::GroupSelected()
                 try {
                     if ( rootNode->hasChildNodes() )
                     {
-                        Sequence< Reference< browse::XBrowseNode > > children =
+                        const Sequence< Reference< browse::XBrowseNode > > children =
                             rootNode->getChildNodes();
 
-                        for ( sal_Int32 n = 0; n < children.getLength(); ++n )
+                        for ( const Reference< browse::XBrowseNode >& childNode : children )
                         {
-                            if (children[n]->getType() == browse::BrowseNodeTypes::SCRIPT)
+                            if (childNode->getType() == browse::BrowseNodeTypes::SCRIPT)
                             {
                                 OUString uri, description;
 
-                                Reference < beans::XPropertySet >xPropSet( children[n], UNO_QUERY );
+                                Reference < beans::XPropertySet >xPropSet( childNode, UNO_QUERY );
                                 if (!xPropSet.is())
                                 {
                                     continue;
@@ -888,14 +887,14 @@ void CuiConfigGroupListBox::GroupSelected()
 
                                 OUString* pScriptURI = new OUString( uri );
 
-                                OUString aImage = GetImage(children[n], Reference< XComponentContext >(), false);
+                                OUString aImage = GetImage(childNode, Reference< XComponentContext >(), false);
                                 m_pFunctionListBox->aArr.push_back( std::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::FUNCTION_SCRIPT, 0, pScriptURI ));
                                 m_pFunctionListBox->aArr.back()->sCommand = uri;
-                                m_pFunctionListBox->aArr.back()->sLabel = children[n]->getName();
+                                m_pFunctionListBox->aArr.back()->sLabel = childNode->getName();
                                 m_pFunctionListBox->aArr.back()->sHelpText = description;
 
                                 OUString sId(OUString::number(reinterpret_cast<sal_Int64>(m_pFunctionListBox->aArr.back().get())));
-                                m_pFunctionListBox->append(sId, children[n]->getName(), aImage);
+                                m_pFunctionListBox->append(sId, childNode->getName(), aImage);
                             }
                         }
                     }
diff --git a/cui/source/dialogs/colorpicker.cxx b/cui/source/dialogs/colorpicker.cxx
index fbba1abd1e90..65f03fb3a046 100644
--- a/cui/source/dialogs/colorpicker.cxx
+++ b/cui/source/dialogs/colorpicker.cxx
@@ -1302,15 +1302,15 @@ Sequence< PropertyValue > SAL_CALL ColorPicker::getPropertyValues(  )
 
 void SAL_CALL ColorPicker::setPropertyValues( const Sequence< PropertyValue >& aProps )
 {
-    for( sal_Int32 n = 0; n < aProps.getLength(); n++ )
+    for ( const PropertyValue& rProp : aProps )
     {
-        if( aProps[n].Name == gsColorKey )
+        if( rProp.Name == gsColorKey )
         {
-            aProps[n].Value >>= mnColor;
+            rProp.Value >>= mnColor;
         }
-        else if( aProps[n].Name == gsModeKey )
+        else if( rProp.Name == gsModeKey )
         {
-            aProps[n].Value >>= mnMode;
+            rProp.Value >>= mnMode;
         }
     }
 }
diff --git a/cui/source/dialogs/cuicharmap.cxx b/cui/source/dialogs/cuicharmap.cxx
index 22450f6722e6..3f3651bce366 100644
--- a/cui/source/dialogs/cuicharmap.cxx
+++ b/cui/source/dialogs/cuicharmap.cxx
@@ -222,17 +222,17 @@ void SvxCharacterMap::DisableFontSelection()
 void SvxCharacterMap::getRecentCharacterList()
 {
     //retrieve recent character list
-    css::uno::Sequence< OUString > rRecentCharList( officecfg::Office::Common::RecentCharacters::RecentCharacterList::get() );
-    for (int i = 0; i < rRecentCharList.getLength(); ++i)
+    const css::uno::Sequence< OUString > rRecentCharList( officecfg::Office::Common::RecentCharacters::RecentCharacterList::get() );
+    for (OUString const & s : rRecentCharList)
     {
-        maRecentCharList.push_back(rRecentCharList[i]);
+        maRecentCharList.push_back(s);
     }
 
     //retrieve recent character font list
-    css::uno::Sequence< OUString > rRecentCharFontList( officecfg::Office::Common::RecentCharacters::RecentCharacterFontList::get() );
-    for (int i = 0; i < rRecentCharFontList.getLength(); ++i)
+    const css::uno::Sequence< OUString > rRecentCharFontList( officecfg::Office::Common::RecentCharacters::RecentCharacterFontList::get() );
+    for (OUString const & s : rRecentCharFontList)
     {
-        maRecentCharFontList.push_back(rRecentCharFontList[i]);
+        maRecentCharFontList.push_back(s);
     }
 }
 
@@ -242,17 +242,17 @@ void SvxCharacterMap::getFavCharacterList()
     maFavCharList.clear();
     maFavCharFontList.clear();
     //retrieve recent character list
-    css::uno::Sequence< OUString > rFavCharList( officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterList::get() );
-    for (int i = 0; i < rFavCharList.getLength(); ++i)
+    const css::uno::Sequence< OUString > rFavCharList( officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterList::get() );
+    for (const OUString& s : rFavCharList)
     {
-        maFavCharList.push_back(rFavCharList[i]);
+        maFavCharList.push_back(s);
     }
 
     //retrieve recent character font list
-    css::uno::Sequence< OUString > rFavCharFontList( officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterFontList::get() );
-    for (int i = 0; i < rFavCharFontList.getLength(); ++i)
+    const css::uno::Sequence< OUString > rFavCharFontList( officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterFontList::get() );
+    for (const OUString& s : rFavCharFontList)
     {
-        maFavCharFontList.push_back(rFavCharFontList[i]);
+        maFavCharFontList.push_back(s);
     }
 }
 
diff --git a/cui/source/dialogs/hldocntp.cxx b/cui/source/dialogs/hldocntp.cxx
index fa4529735185..50d7131ad8fa 100644
--- a/cui/source/dialogs/hldocntp.cxx
+++ b/cui/source/dialogs/hldocntp.cxx
@@ -163,16 +163,16 @@ void SvxHyperlinkNewDocTp::FillDocumentList()
     sal_uInt32 i, nCount = aDynamicMenuEntries.getLength();
     for ( i = 0; i < nCount; i++ )
     {
-        uno::Sequence< beans::PropertyValue >& rDynamicMenuEntry = aDynamicMenuEntries[ i ];
+        const uno::Sequence< beans::PropertyValue >& rDynamicMenuEntry = aDynamicMenuEntries[ i ];
 
         OUString aDocumentUrl, aTitle;
 
-        for ( int e = 0; e < rDynamicMenuEntry.getLength(); e++ )
+        for ( const beans::PropertyValue& e : rDynamicMenuEntry )
         {
-            if ( rDynamicMenuEntry[ e ].Name == DYNAMICMENU_PROPERTYNAME_URL )
-                rDynamicMenuEntry[ e ].Value >>= aDocumentUrl;
-            else if ( rDynamicMenuEntry[e].Name == DYNAMICMENU_PROPERTYNAME_TITLE )
-                rDynamicMenuEntry[e].Value >>= aTitle;
+            if ( e.Name == DYNAMICMENU_PROPERTYNAME_URL )
+                e.Value >>= aDocumentUrl;
+            else if ( e.Name == DYNAMICMENU_PROPERTYNAME_TITLE )
+                e.Value >>= aTitle;
         }
         //#i96822# business cards, labels and database should not be inserted here
         if( aDocumentUrl == "private:factory/swriter?slot=21051" ||
diff --git a/cui/source/dialogs/insdlg.cxx b/cui/source/dialogs/insdlg.cxx
index 1df80452d056..4f34b461eba5 100644
--- a/cui/source/dialogs/insdlg.cxx
+++ b/cui/source/dialogs/insdlg.cxx
@@ -185,22 +185,22 @@ short SvInsertOleDlg::run()
                         if ( xDialogCreator.is() )
                         {
                             aName = aCnt.CreateUniqueObjectName();
-                            embed::InsertedObjectInfo aNewInf = xDialogCreator->createInstanceByDialog(
+                            const embed::InsertedObjectInfo aNewInf = xDialogCreator->createInstanceByDialog(
                                                                     m_xStorage,
                                                                     aName,
                                                                     uno::Sequence < beans::PropertyValue >() );
 
                             OSL_ENSURE( aNewInf.Object.is(), "The object must be created or an exception must be thrown!" );
                             m_xObj = aNewInf.Object;
-                            for ( sal_Int32 nInd = 0; nInd < aNewInf.Options.getLength(); nInd++ )
-                                if ( aNewInf.Options[nInd].Name == "Icon" )
+                            for ( const auto& opt : aNewInf.Options )
+                                if ( opt.Name == "Icon" )
                                 {
-                                    aNewInf.Options[nInd].Value >>= m_aIconMetaFile;
+                                    opt.Value >>= m_aIconMetaFile;
                                 }
-                                else if ( aNewInf.Options[nInd].Name == "IconFormat" )
+                                else if ( opt.Name == "IconFormat" )
                                 {
                                     datatransfer::DataFlavor aFlavor;
-                                    if ( aNewInf.Options[nInd].Value >>= aFlavor )
+                                    if ( opt.Value >>= aFlavor )
                                         m_aIconMediaType = aFlavor.MimeType;
                                 }
 
diff --git a/cui/source/dialogs/scriptdlg.cxx b/cui/source/dialogs/scriptdlg.cxx
index 1716316fb32f..7f32f6343b7c 100644
--- a/cui/source/dialogs/scriptdlg.cxx
+++ b/cui/source/dialogs/scriptdlg.cxx
@@ -153,10 +153,10 @@ void SvxScriptOrgDialog::Init( const OUString& language  )
     }
 
     Reference<XModel> xDocumentModel;
-    for ( sal_Int32 n = 0; n < children.getLength(); n++ )
+    for ( const Reference< browse::XBrowseNode >& childNode : std::as_const(children) )
     {
         bool app = false;
-        OUString uiName = children[ n ]->getName();
+        OUString uiName = childNode->getName();
         OUString factoryURL;
         if ( uiName == userStr || uiName == shareStr )
         {
@@ -186,13 +186,11 @@ void SvxScriptOrgDialog::Init( const OUString& language  )
                 } catch(const uno::Exception&)
                     {}
 
-                beans::PropertyValue const * pmoduleDescr =
-                    moduleDescr.getConstArray();
-                for ( sal_Int32 pos = moduleDescr.getLength(); pos--; )
+                for ( const beans::PropertyValue& prop : std::as_const(moduleDescr))
                 {
-                    if ( pmoduleDescr[ pos ].Name == "ooSetupFactoryEmptyDocumentURL" )
+                    if ( prop.Name == "ooSetupFactoryEmptyDocumentURL" )
                     {
-                        pmoduleDescr[ pos ].Value >>= factoryURL;
+                        prop.Value >>= factoryURL;
                         break;
                     }
                 }
@@ -200,7 +198,7 @@ void SvxScriptOrgDialog::Init( const OUString& language  )
         }
 
         Reference< browse::XBrowseNode > langEntries =
-            getLangNodeFromRootNode( children[ n ], language );
+            getLangNodeFromRootNode( childNode, language );
 
         insertEntry( uiName, app ? OUStringLiteral(RID_CUIBMP_HARDDISK) : OUStringLiteral(RID_CUIBMP_DOC),
             nullptr, true, std::make_unique< SFEntry >( langEntries, xDocumentModel ), factoryURL, false );
@@ -288,16 +286,16 @@ void SvxScriptOrgDialog::RequestSubEntries(const weld::TreeIter& rRootEntry, Ref
         // if we catch an exception in getChildNodes then no entries are added
     }
 
-    for ( sal_Int32 n = 0; n < children.getLength(); n++ )
+    for ( const Reference< browse::XBrowseNode >& childNode : std::as_const(children) )
     {
-        OUString name( children[ n ]->getName() );
-        if (  children[ n ]->getType() !=  browse::BrowseNodeTypes::SCRIPT)
+        OUString name( childNode->getName() );
+        if (  childNode->getType() !=  browse::BrowseNodeTypes::SCRIPT)
         {
-            insertEntry(name, RID_CUIBMP_LIB, &rRootEntry, true, std::make_unique<SFEntry>(children[n], model), false);
+            insertEntry(name, RID_CUIBMP_LIB, &rRootEntry, true, std::make_unique<SFEntry>(childNode, model), false);
         }
         else
         {
-            insertEntry(name, RID_CUIBMP_MACRO, &rRootEntry, false, std::make_unique<SFEntry>(children[n], model), false);
+            insertEntry(name, RID_CUIBMP_MACRO, &rRootEntry, false, std::make_unique<SFEntry>(childNode, model), false);
         }
     }
 }
@@ -761,9 +759,9 @@ void SvxScriptOrgDialog::createEntry(weld::TreeIter& rEntry)
                 if(extnPos>0)
                     extn = nodeName.copy(extnPos);
             }
-            for( sal_Int32 index = 0; index < childNodes.getLength(); index++ )
+            for( const Reference< browse::XBrowseNode >& n : std::as_const(childNodes) )
             {
-                if (aNewName+extn == childNodes[index]->getName())
+                if (aNewName+extn == n->getName())
                 {
                     bFound = true;
                     break;
@@ -788,9 +786,9 @@ void SvxScriptOrgDialog::createEntry(weld::TreeIter& rEntry)
             {
                 OUString aUserSuppliedName = aNewDlg.GetObjectName();
                 bValid = true;
-                for( sal_Int32 index = 0; index < childNodes.getLength(); index++ )
+                for( const Reference< browse::XBrowseNode >& n : std::as_const(childNodes) )
                 {
-                    if (aUserSuppliedName+extn == childNodes[index]->getName())
+                    if (aUserSuppliedName+extn == n->getName())
                     {
                         bValid = false;
                         OUString aError = m_createErrStr + m_createDupStr;
@@ -1009,11 +1007,11 @@ OUString SvxScriptOrgDialog::getListOfChildren( const Reference< browse::XBrowse
     {
         if ( node->hasChildNodes() )
         {
-            Sequence< Reference< browse::XBrowseNode > > children
+            const Sequence< Reference< browse::XBrowseNode > > children
                 = node->getChildNodes();
-            for ( sal_Int32 n = 0; n < children.getLength(); n++ )
+            for( const Reference< browse::XBrowseNode >& n : children )
             {
-                result.append( getListOfChildren( children[ n ] , depth+1 ) );
+                result.append( getListOfChildren( n , depth+1 ) );
             }
         }
     }
diff --git a/cui/source/options/optaboutconfig.cxx b/cui/source/options/optaboutconfig.cxx
index 799f31c38962..44bacb1e1195 100644
--- a/cui/source/options/optaboutconfig.cxx
+++ b/cui/source/options/optaboutconfig.cxx
@@ -259,10 +259,10 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces
 {
     OUString sPath = Reference< XHierarchicalName >(
         xNameAccess, uno::UNO_QUERY_THROW )->getHierarchicalName();
-    uno::Sequence< OUString > seqItems = xNameAccess->getElementNames();
-    for( sal_Int32 i = 0; i < seqItems.getLength(); ++i )
+    const uno::Sequence< OUString > seqItems = xNameAccess->getElementNames();
+    for( const OUString& item : seqItems )
     {
-        Any aNode = xNameAccess->getByName( seqItems[i] );
+        Any aNode = xNameAccess->getByName( item );
 
         bool bNotLeaf = false;
 
@@ -287,7 +287,7 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces
                 m_vectorUserData.push_back(std::make_unique<UserData>(xNextNameAccess, lineage + 1));
                 OUString sId(OUString::number(reinterpret_cast<sal_Int64>(m_vectorUserData.back().get())));
 
-                m_xPrefBox->insert(pParentEntry, -1, &seqItems[i], &sId, nullptr, nullptr, nullptr, true, m_xScratchIter.get());
+                m_xPrefBox->insert(pParentEntry, -1, &item, &sId, nullptr, nullptr, nullptr, true, m_xScratchIter.get());
                 //It is needed, without this the selection line will be truncated.
                 m_xPrefBox->set_text(*m_xScratchIter, "", 1);
                 m_xPrefBox->set_text(*m_xScratchIter, "", 2);
@@ -297,7 +297,7 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces
         else
         {
             // leaf node
-            OUString sPropertyName = seqItems[i];
+            OUString sPropertyName = item;
             auto it = std::find_if(m_modifiedPrefBoxEntries.begin(), m_modifiedPrefBoxEntries.end(),
               [&sPath, &sPropertyName](const prefBoxEntry& rEntry) -> bool
               {
@@ -352,10 +352,10 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces
                     else if( sType == "[]byte" )
                     {
                         uno::Sequence<sal_Int8> seq = aNode.get< uno::Sequence<sal_Int8> >();
-                        for( sal_Int32 j = 0; j != seq.getLength(); ++j )
+                        for( sal_Int8 j : seq )
                         {
                             OUString s = OUString::number(
-                                static_cast<sal_uInt8>(seq[j]), 16 );
+                                static_cast<sal_uInt8>(j), 16 );
                             if( s.getLength() == 1 )
                             {
                                 sValue.append("0");
@@ -372,10 +372,10 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces
                             {
                                 sValue.append(",");
                             }
-                            for( sal_Int32 k = 0; k != seq[j].getLength(); ++k )
+                            for( sal_Int8 k : seq[j] )
                             {
                                 OUString s = OUString::number(
-                                    static_cast<sal_uInt8>(seq[j][k]), 16 );
+                                    static_cast<sal_uInt8>(k), 16 );
                                 if( s.getLength() == 1 )
                                 {
                                     sValue.append("0");
@@ -448,7 +448,7 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces
                     {
                         SAL_WARN(
                             "cui.options",
-                            "path \"" << sPath << "\" member " << seqItems[i]
+                            "path \"" << sPath << "\" member " << item
                                 << " of unsupported type " << sType);
                     }
                     break;
@@ -456,7 +456,7 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces
                 default:
                     SAL_WARN(
                         "cui.options",
-                        "path \"" << sPath << "\" member " << seqItems[i]
+                        "path \"" << sPath << "\" member " << item
                             << " of unsupported type " << sType);
                     break;
                 }
@@ -467,7 +467,7 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces
             for(int j = 1; j < lineage; ++j)
                 index = sPath.indexOf("/", index + 1);
 
-            InsertEntry(sPath, sPath.copy(index+1), seqItems[i], sType, sValue.makeStringAndClear(), pParentEntry, !bLoadAll);
+            InsertEntry(sPath, sPath.copy(index+1), item, sType, sValue.makeStringAndClear(), pParentEntry, !bLoadAll);
         }
     }
 }
diff --git a/cui/source/options/optcolor.cxx b/cui/source/options/optcolor.cxx
index 384f5f23ed16..f7807adc57e9 100644
--- a/cui/source/options/optcolor.cxx
+++ b/cui/source/options/optcolor.cxx
@@ -785,10 +785,9 @@ void SvxColorOptionsTabPage::Reset( const SfxItemSet* )
     //has to be called always to speed up accessibility tools
     m_xColorConfigCT->SetScrollPosition(sUser.toInt32());
     m_xColorSchemeLB->clear();
-    uno::Sequence< OUString >  aSchemes = pColorConfig->GetSchemeNames();
-    const OUString* pSchemes = aSchemes.getConstArray();
-    for(sal_Int32 i = 0; i < aSchemes.getLength(); i++)
-        m_xColorSchemeLB->append_text(pSchemes[i]);
+    const uno::Sequence< OUString >  aSchemes = pColorConfig->GetSchemeNames();
+    for(const OUString& s : aSchemes)
+        m_xColorSchemeLB->append_text(s);
     m_xColorSchemeLB->set_active_text(pColorConfig->GetCurrentSchemeName());
     m_xColorSchemeLB->save_value();
     m_xDeleteSchemePB->set_sensitive( aSchemes.getLength() > 1 );
diff --git a/cui/source/options/optlingu.cxx b/cui/source/options/optlingu.cxx
index 57149d726bda..296451e6a380 100644
--- a/cui/source/options/optlingu.cxx
+++ b/cui/source/options/optlingu.cxx
@@ -466,30 +466,31 @@ ServiceInfo_Impl * SvxLinguData_Impl::GetInfoByImplName( const OUString &rSvcImp
 
 static void lcl_MergeLocales(Sequence< Locale >& aAllLocales, const Sequence< Locale >& rAdd)
 {
-    const Locale* pAdd = rAdd.getConstArray();
     Sequence<Locale> aLocToAdd(rAdd.getLength());
-    const Locale* pAllLocales = aAllLocales.getConstArray();
     Locale* pLocToAdd = aLocToAdd.getArray();
     sal_Int32 nFound = 0;
-    sal_Int32 i;
-    for(i = 0; i < rAdd.getLength(); i++)
+    for(const Locale& i : rAdd)
     {
         bool bFound = false;
-        for(sal_Int32 j = 0; j < aAllLocales.getLength() && !bFound; j++)
+        for(const Locale& j : std::as_const(aAllLocales))
         {
-            bFound = pAdd[i].Language == pAllLocales[j].Language &&
-                pAdd[i].Country == pAllLocales[j].Country &&
-                pAdd[i].Variant == pAllLocales[j].Variant;
+            if (i.Language == j.Language &&
+                i.Country == j.Country &&
+                i.Variant == j.Variant)
+            {
+                bFound = true;
+                break;
+            }
         }
         if(!bFound)
         {
-            pLocToAdd[nFound++] = pAdd[i];
+            pLocToAdd[nFound++] = i;
         }
     }
     sal_Int32 nLength = aAllLocales.getLength();
     aAllLocales.realloc( nLength + nFound);
     Locale* pAllLocales2 = aAllLocales.getArray();
-    for(i = 0; i < nFound; i++)
+    for(sal_Int32 i = 0; i < nFound; i++)
         pAllLocales2[nLength++] = pLocToAdd[i];
 }
 
@@ -558,15 +559,13 @@ SvxLinguData_Impl::SvxLinguData_Impl() :
     aArgs.getArray()[0] <<= LinguMgr::GetLinguPropertySet();
 
     //read spell checker
-    Sequence< OUString > aSpellNames = xLinguSrvcMgr->getAvailableServices(
+    const Sequence< OUString > aSpellNames = xLinguSrvcMgr->getAvailableServices(
                     cSpell,    Locale() );
-    const OUString* pSpellNames = aSpellNames.getConstArray();
 
-    sal_Int32 nIdx;
-    for(nIdx = 0; nIdx < aSpellNames.getLength(); nIdx++)
+    for(const OUString& spellName : aSpellNames)
     {
         ServiceInfo_Impl aInfo;
-        aInfo.sSpellImplName = pSpellNames[nIdx];
+        aInfo.sSpellImplName = spellName;
         aInfo.xSpell.set(
                         xContext->getServiceManager()->createInstanceWithArgumentsAndContext(aInfo.sSpellImplName, aArgs, xContext), UNO_QUERY);
 
@@ -584,13 +583,12 @@ SvxLinguData_Impl::SvxLinguData_Impl() :
     }
 
     //read grammar checker
-    Sequence< OUString > aGrammarNames = xLinguSrvcMgr->getAvailableServices(
+    const Sequence< OUString > aGrammarNames = xLinguSrvcMgr->getAvailableServices(
                     cGrammar, Locale() );
-    const OUString* pGrammarNames = aGrammarNames.getConstArray();
-    for(nIdx = 0; nIdx < aGrammarNames.getLength(); nIdx++)
+    for(const OUString& grammarName : aGrammarNames)
     {
         ServiceInfo_Impl aInfo;
-        aInfo.sGrammarImplName = pGrammarNames[nIdx];
+        aInfo.sGrammarImplName = grammarName;
         aInfo.xGrammar.set(
                         xContext->getServiceManager()->createInstanceWithArgumentsAndContext(aInfo.sGrammarImplName, aArgs, xContext), UNO_QUERY);
 
@@ -608,13 +606,12 @@ SvxLinguData_Impl::SvxLinguData_Impl() :
     }
 
     //read hyphenator
-    Sequence< OUString > aHyphNames = xLinguSrvcMgr->getAvailableServices(
+    const Sequence< OUString > aHyphNames = xLinguSrvcMgr->getAvailableServices(
                     cHyph, Locale() );
-    const OUString* pHyphNames = aHyphNames.getConstArray();
-    for(nIdx = 0; nIdx < aHyphNames.getLength(); nIdx++)
+    for(const OUString& hyphName : aHyphNames)
     {
         ServiceInfo_Impl aInfo;
-        aInfo.sHyphImplName = pHyphNames[nIdx];
+        aInfo.sHyphImplName = hyphName;
         aInfo.xHyph.set( xContext->getServiceManager()->createInstanceWithArgumentsAndContext(aInfo.sHyphImplName, aArgs, xContext), UNO_QUERY);
 
         uno::Reference<XServiceDisplayName> xDispName(aInfo.xHyph, UNO_QUERY);
@@ -631,13 +628,12 @@ SvxLinguData_Impl::SvxLinguData_Impl() :
     }
 
     //read thesauri
-    Sequence< OUString > aThesNames = xLinguSrvcMgr->getAvailableServices(
+    const Sequence< OUString > aThesNames = xLinguSrvcMgr->getAvailableServices(
                     cThes,     Locale() );
-    const OUString* pThesNames = aThesNames.getConstArray();
-    for(nIdx = 0; nIdx < aThesNames.getLength(); nIdx++)
+    for(const OUString& thesName : aThesNames)
     {
         ServiceInfo_Impl aInfo;
-        aInfo.sThesImplName = pThesNames[nIdx];
+        aInfo.sThesImplName = thesName;
         aInfo.xThes.set( xContext->getServiceManager()->createInstanceWithArgumentsAndContext(aInfo.sThesImplName, aArgs, xContext), UNO_QUERY);
 
         uno::Reference<XServiceDisplayName> xDispName(aInfo.xThes, UNO_QUERY);
@@ -654,27 +650,26 @@ SvxLinguData_Impl::SvxLinguData_Impl() :
     }
 
     Sequence< OUString > aCfgSvcs;
-    const Locale* pAllLocales = aAllServiceLocales.getConstArray();
-    for(sal_Int32 nLocale = 0; nLocale < aAllServiceLocales.getLength(); nLocale++)
+    for(auto const & locale : std::as_const(aAllServiceLocales))
     {
-        LanguageType nLang = LanguageTag::convertToLanguageType( pAllLocales[nLocale] );
+        LanguageType nLang = LanguageTag::convertToLanguageType( locale );
 
-        aCfgSvcs = xLinguSrvcMgr->getConfiguredServices(cSpell, pAllLocales[nLocale]);
+        aCfgSvcs = xLinguSrvcMgr->getConfiguredServices(cSpell, locale);
         SetChecked( aCfgSvcs );
         if (aCfgSvcs.hasElements())
             aCfgSpellTable[ nLang ] = aCfgSvcs;
 
-        aCfgSvcs = xLinguSrvcMgr->getConfiguredServices(cGrammar, pAllLocales[nLocale]);
+        aCfgSvcs = xLinguSrvcMgr->getConfiguredServices(cGrammar, locale);
         SetChecked( aCfgSvcs );
         if (aCfgSvcs.hasElements())
             aCfgGrammarTable[ nLang ] = aCfgSvcs;
 
-        aCfgSvcs = xLinguSrvcMgr->getConfiguredServices(cHyph, pAllLocales[nLocale]);
+        aCfgSvcs = xLinguSrvcMgr->getConfiguredServices(cHyph, locale);
         SetChecked( aCfgSvcs );
         if (aCfgSvcs.hasElements())
             aCfgHyphTable[ nLang ] = aCfgSvcs;
 
-        aCfgSvcs = xLinguSrvcMgr->getConfiguredServices(cThes, pAllLocales[nLocale]);
+        aCfgSvcs = xLinguSrvcMgr->getConfiguredServices(cThes, locale);
         SetChecked( aCfgSvcs );
         if (aCfgSvcs.hasElements())
             aCfgThesTable[ nLang ] = aCfgSvcs;
@@ -683,15 +678,14 @@ SvxLinguData_Impl::SvxLinguData_Impl() :
 
 void SvxLinguData_Impl::SetChecked(const Sequence<OUString>& rConfiguredServices)
 {
-    const OUString* pConfiguredServices = rConfiguredServices.getConstArray();
-    for(sal_Int32 n = 0; n < rConfiguredServices.getLength(); n++)
+    for(OUString const & configService : rConfiguredServices)
     {
         for (sal_uInt32 i = 0;  i < nDisplayServices;  ++i)
         {
             ServiceInfo_Impl& rEntry = aDisplayServiceArr[i];
             if (!rEntry.bConfigured)
             {
-                const OUString &rSrvcImplName = pConfiguredServices[n];
+                const OUString &rSrvcImplName = configService;
                 if (!rSrvcImplName.isEmpty()  &&
                     (rEntry.sSpellImplName == rSrvcImplName ||
                         rEntry.sGrammarImplName == rSrvcImplName ||
@@ -1583,10 +1577,9 @@ SvxEditModulesDlg::SvxEditModulesDlg(weld::Window* pParent, SvxLinguData_Impl& r
 
     //fill language box
     const Sequence< Locale >& rLoc = rLinguData.GetAllSupportedLocales();
-    const Locale* pLocales = rLoc.getConstArray();
-    for (int i = 0; i < rLoc.getLength(); ++i)
+    for (Locale const & locale : rLoc)
     {
-        LanguageType nLang = LanguageTag::convertToLanguageType( pLocales[i] );
+        LanguageType nLang = LanguageTag::convertToLanguageType( locale );
         m_xLanguageLB->InsertLanguage(nLang);
     }
     LanguageType eSysLang = MsLangId::getSystemLanguage();
diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx
index 4e71fd62aa7b..2d6b104e1d9b 100644
--- a/cui/source/options/treeopt.cxx
+++ b/cui/source/options/treeopt.cxx
@@ -1738,20 +1738,19 @@ VectorOfNodes OfaTreeOptionsDialog::LoadNodes(
     Reference< XNameAccess > xSet(
         officecfg::Office::OptionsDialog::Nodes::get());
     VectorOfNodes aNodeList;
-    Sequence< OUString > seqNames = xSet->getElementNames();
+    const Sequence< OUString > seqNames = xSet->getElementNames();
 
-    for ( int i = 0; i < seqNames.getLength(); ++i )
+    for ( OUString const & sGroupName : seqNames )
     {
-        OUString sGroupName( seqNames[i] );
         Reference< XNameAccess > xNodeAccess;
-        xSet->getByName( seqNames[i] ) >>= xNodeAccess;
+        xSet->getByName( sGroupName ) >>= xNodeAccess;
 
         if ( xNodeAccess.is() )
         {
             OUString sNodeId, sLabel, sPageURL;
             bool bAllModules = false;
 
-            sNodeId = seqNames[i];
+            sNodeId = sGroupName;
             xNodeAccess->getByName( "Label" ) >>= sLabel;
             xNodeAccess->getByName( "OptionsPage" ) >>= sPageURL;
             xNodeAccess->getByName( "AllModules" ) >>= bAllModules;
@@ -1772,11 +1771,11 @@ VectorOfNodes OfaTreeOptionsDialog::LoadNodes(
             xNodeAccess->getByName( "Leaves" ) >>= xLeavesSet;
             if ( xLeavesSet.is() )
             {
-                Sequence< OUString > seqLeaves = xLeavesSet->getElementNames();
-                for ( int j = 0; j < seqLeaves.getLength(); ++j )
+                const Sequence< OUString > seqLeaves = xLeavesSet->getElementNames();
+                for ( OUString const & leafName : seqLeaves )
                 {
                     Reference< XNameAccess > xLeaveAccess;
-                    xLeavesSet->getByName( seqLeaves[j] ) >>= xLeaveAccess;
+                    xLeavesSet->getByName( leafName ) >>= xLeaveAccess;
 
                     if ( xLeaveAccess.is() )
                     {
diff --git a/cui/source/options/webconninfo.cxx b/cui/source/options/webconninfo.cxx
index c06f085ccfa4..1d3abe82f860 100644
--- a/cui/source/options/webconninfo.cxx
+++ b/cui/source/options/webconninfo.cxx
@@ -86,14 +86,14 @@ void WebConnectionInfoDialog::FillPasswordList()
             uno::Reference< task::XInteractionHandler > xInteractionHandler =
                 task::InteractionHandler::createWithParent(comphelper::getProcessComponentContext(), nullptr);
 
-            uno::Sequence< task::UrlRecord > aURLEntries = xMasterPasswd->getAllPersistent( xInteractionHandler );
+            const uno::Sequence< task::UrlRecord > aURLEntries = xMasterPasswd->getAllPersistent( xInteractionHandler );
             sal_Int32 nCount = 0;
-            for ( sal_Int32 nURLInd = 0; nURLInd < aURLEntries.getLength(); nURLInd++ )
+            for ( task::UrlRecord const & urlEntry : aURLEntries )
             {
-                for ( sal_Int32 nUserInd = 0; nUserInd < aURLEntries[nURLInd].UserList.getLength(); nUserInd++ )
+                for ( auto const & user : urlEntry.UserList )
                 {
-                    m_xPasswordsLB->append(OUString::number(nCount), aURLEntries[nURLInd].Url);
-                    m_xPasswordsLB->set_text(nCount, aURLEntries[nURLInd].UserList[nUserInd].UserName, 1);
+                    m_xPasswordsLB->append(OUString::number(nCount), urlEntry.Url);
+                    m_xPasswordsLB->set_text(nCount, user.UserName, 1);
                     ++nCount;
                 }
             }
@@ -101,12 +101,12 @@ void WebConnectionInfoDialog::FillPasswordList()
             // remember pos of first url container entry.
             m_nPos = nCount;
 
-            uno::Sequence< OUString > aUrls
+            const uno::Sequence< OUString > aUrls
                 = xMasterPasswd->getUrls( true /* OnlyPersistent */ );
 
-            for ( sal_Int32 nURLIdx = 0; nURLIdx < aUrls.getLength(); nURLIdx++ )
+            for ( OUString const & url : aUrls )
             {
-                m_xPasswordsLB->append(OUString::number(nCount), aUrls[nURLIdx]);
+                m_xPasswordsLB->append(OUString::number(nCount), url);
                 m_xPasswordsLB->set_text(nCount, "*");
                 ++nCount;
             }
@@ -157,10 +157,10 @@ IMPL_LINK_NOARG(WebConnectionInfoDialog, RemoveAllPasswordsHdl, weld::Button&, v
         // should the master password be requested before?
         xPasswdContainer->removeAllPersistent();
 
-        uno::Sequence< OUString > aUrls
+        const uno::Sequence< OUString > aUrls
             = xPasswdContainer->getUrls( true /* OnlyPersistent */ );
-        for ( sal_Int32 nURLIdx = 0; nURLIdx < aUrls.getLength(); nURLIdx++ )
-            xPasswdContainer->removeUrl( aUrls[ nURLIdx ] );
+        for ( OUString const & url : aUrls )
+            xPasswdContainer->removeUrl( url );
 
         m_xPasswordsLB->clear();
     }


More information about the Libreoffice-commits mailing list