[Libreoffice-commits] core.git: postprocess/CppunitTest_services.mk postprocess/qa pyuno/source reportdesign/source sax/source

Arkadiy Illarionov (via logerrit) logerrit at kemper.freedesktop.org
Sat Aug 17 12:09:25 UTC 2019


 postprocess/CppunitTest_services.mk                         |    1 
 postprocess/qa/services.cxx                                 |   54 ++++--------
 pyuno/source/module/pyuno_adapter.cxx                       |   38 ++------
 reportdesign/source/core/api/ReportDefinition.cxx           |   21 +---
 reportdesign/source/core/sdr/RptObject.cxx                  |   11 +-
 reportdesign/source/filter/xml/xmlExport.cxx                |    7 -
 reportdesign/source/filter/xml/xmlExportDocumentHandler.cxx |   12 +-
 reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx |    9 --
 reportdesign/source/filter/xml/xmlfilter.cxx                |   28 ++----
 reportdesign/source/ui/dlg/AddField.cxx                     |   18 +---
 reportdesign/source/ui/dlg/DateTime.cxx                     |    6 -
 reportdesign/source/ui/dlg/GroupsSorting.cxx                |   18 +---
 reportdesign/source/ui/dlg/Navigator.cxx                    |    6 -
 reportdesign/source/ui/inspection/GeometryHandler.cxx       |    8 -
 reportdesign/source/ui/misc/RptUndo.cxx                     |   10 --
 reportdesign/source/ui/report/ReportController.cxx          |   27 ++----
 reportdesign/source/ui/report/ReportSection.cxx             |   17 +--
 reportdesign/source/ui/report/ViewsWindow.cxx               |   14 +--
 sax/source/expatwrap/xml2utf.cxx                            |   11 --
 sax/source/fastparser/fastparser.cxx                        |    7 -
 sax/source/fastparser/legacyfastparser.cxx                  |   18 +---
 sax/source/tools/fastserializer.cxx                         |    4 
 22 files changed, 132 insertions(+), 213 deletions(-)

New commits:
commit edcdfe5477559ca6c62897f0cad47d4d6149d77a
Author:     Arkadiy Illarionov <qarkai at gmail.com>
AuthorDate: Sat Aug 10 19:07:30 2019 +0300
Commit:     Arkadiy Illarionov <qarkai at gmail.com>
CommitDate: Sat Aug 17 14:08:33 2019 +0200

    Simplify Sequence iterations in postprocess..sax
    
    Use range-based loops, STL and comphelper functions
    
    Change-Id: If738d8f4e792c4686870183b0c0fdfbb61fd3351
    Reviewed-on: https://gerrit.libreoffice.org/77245
    Tested-by: Jenkins
    Reviewed-by: Arkadiy Illarionov <qarkai at gmail.com>

diff --git a/postprocess/CppunitTest_services.mk b/postprocess/CppunitTest_services.mk
index d886cb4961d8..9371443b5d6a 100644
--- a/postprocess/CppunitTest_services.mk
+++ b/postprocess/CppunitTest_services.mk
@@ -18,6 +18,7 @@ $(eval $(call gb_CppunitTest_use_externals,services, \
 ))
 
 $(eval $(call gb_CppunitTest_use_libraries,services, \
+	comphelper \
 	cppu \
 	cppuhelper \
 	sal \
diff --git a/postprocess/qa/services.cxx b/postprocess/qa/services.cxx
index a807a037e80e..3c0fa8f7c6cf 100644
--- a/postprocess/qa/services.cxx
+++ b/postprocess/qa/services.cxx
@@ -37,6 +37,7 @@
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/reflection/XServiceConstructorDescription.hpp>
 #include <com/sun/star/reflection/XServiceTypeDescription2.hpp>
+#include <comphelper/sequence.hxx>
 #include <cppuhelper/exc_hlp.hxx>
 #include <rtl/strbuf.hxx>
 #include <test/bootstrapfixture.hxx>
@@ -77,12 +78,7 @@ bool unique(css::uno::Sequence<OUString> const & strings) {
 bool contains(
     css::uno::Sequence<OUString> const & strings, OUString const & string)
 {
-    for (sal_Int32 i = 0; i != strings.getLength(); ++i) {
-        if (string == strings[i]) {
-            return true;
-        }
-    }
-    return false;
+    return comphelper::findValue(strings, string) != -1;
 }
 
 bool contains(
@@ -90,12 +86,8 @@ bool contains(
     css::uno::Sequence<OUString> const & strings2)
 {
     // Assumes small sequences for which quadratic algorithm is acceptable:
-    for (sal_Int32 i = 0; i != strings2.getLength(); ++i) {
-        if (!contains(strings1, strings2[i])) {
-            return false;
-        }
-    }
-    return true;
+    return std::all_of(strings2.begin(), strings2.end(),
+        [&strings1](const OUString& rStr) { return contains(strings1, rStr); });
 }
 
 void addService(
@@ -157,7 +149,7 @@ void Test::test() {
         m_xContext->getValueByName(
             "/singletons/com.sun.star.reflection.theTypeDescriptionManager"),
         css::uno::UNO_QUERY_THROW);
-    css::uno::Sequence<OUString> serviceNames(
+    const css::uno::Sequence<OUString> serviceNames(
         m_xContext->getServiceManager()->getAvailableServiceNames());
     struct Constructor {
         Constructor(
@@ -181,9 +173,9 @@ void Test::test() {
         bool accumulationBased;
     };
     std::map<OUString, Implementation> impls;
-    for (sal_Int32 i = 0; i != serviceNames.getLength(); ++i) {
+    for (const auto& rServiceName : serviceNames) {
         css::uno::Reference<css::container::XEnumeration> serviceImpls1(
-            enumAcc->createContentEnumeration(serviceNames[i]),
+            enumAcc->createContentEnumeration(rServiceName),
             css::uno::UNO_SET_THROW);
         std::vector<css::uno::Reference<css::lang::XServiceInfo>> serviceImpls2;
         while (serviceImpls1->hasMoreElements()) {
@@ -191,9 +183,9 @@ void Test::test() {
                     serviceImpls1->nextElement(), css::uno::UNO_QUERY_THROW);
         }
         css::uno::Reference<css::reflection::XServiceTypeDescription2> desc;
-        if (typeMgr->hasByHierarchicalName(serviceNames[i])) {
+        if (typeMgr->hasByHierarchicalName(rServiceName)) {
             desc.set(
-                typeMgr->getByHierarchicalName(serviceNames[i]),
+                typeMgr->getByHierarchicalName(rServiceName),
                 css::uno::UNO_QUERY_THROW);
         }
         if (serviceImpls2.empty()) {
@@ -201,15 +193,15 @@ void Test::test() {
                 CPPUNIT_ASSERT_MESSAGE(
                     (OString(
                         "no implementations of single-interface--based \""
-                        + msg(serviceNames[i]) + "\"")
+                        + msg(rServiceName) + "\"")
                      .getStr()),
                     !desc->isSingleInterfaceBased());
                 std::cout
-                    << "accumulation-based service \"" << serviceNames[i]
+                    << "accumulation-based service \"" << rServiceName
                     << "\" without implementations\n";
             } else {
                 std::cout
-                    << "fantasy service name \"" << serviceNames[i]
+                    << "fantasy service name \"" << rServiceName
                     << "\" without implementations\n";
             }
         } else {
@@ -240,24 +232,22 @@ void Test::test() {
                     (OString(
                         "implementation \"" + msg(name) + "\" supports "
                         + msg(k->second.serviceNames) + " but not \""
-                        + msg(serviceNames[i]) + "\"")
+                        + msg(rServiceName) + "\"")
                      .getStr()),
-                    contains(k->second.serviceNames, serviceNames[i]));
+                    contains(k->second.serviceNames, rServiceName));
                 if (desc.is()) {
                     if (desc->isSingleInterfaceBased()) {
                         if (serviceImpls2.size() == 1) {
-                            css::uno::Sequence<
+                            const css::uno::Sequence<
                                 css::uno::Reference<
                                     css::reflection::XServiceConstructorDescription>>
                                         ctors(desc->getConstructors());
-                            for (sal_Int32 l = 0; l != ctors.getLength(); ++l) {
-                                if (!ctors[l]->getParameters().hasElements()) {
-                                    k->second.constructors.emplace_back(
-                                            serviceNames[i],
-                                            ctors[l]->isDefaultConstructor());
-                                    break;
-                                }
-                            }
+                            auto pCtor = std::find_if(ctors.begin(), ctors.end(),
+                                [](const auto& rCtor) { return !rCtor->getParameters().hasElements(); });
+                            if (pCtor != ctors.end())
+                                k->second.constructors.emplace_back(
+                                        rServiceName,
+                                        (*pCtor)->isDefaultConstructor());
                         }
                     } else {
                         k->second.accumulationBased = true;
@@ -266,7 +256,7 @@ void Test::test() {
                     std::cout
                         << "implementation \"" << name
                         << "\" supports fantasy service name \""
-                        << serviceNames[i] << "\"\n";
+                        << rServiceName << "\"\n";
                 }
             }
         }
diff --git a/pyuno/source/module/pyuno_adapter.cxx b/pyuno/source/module/pyuno_adapter.cxx
index f434b9ec2aed..1c392989d744 100644
--- a/pyuno/source/module/pyuno_adapter.cxx
+++ b/pyuno/source/module/pyuno_adapter.cxx
@@ -26,6 +26,7 @@
 #include <com/sun/star/script/XInvocationAdapterFactory2.hpp>
 #include <com/sun/star/beans/XIntrospection.hpp>
 
+#include <comphelper/sequence.hxx>
 #include <cppuhelper/exc_hlp.hxx>
 #include <cppuhelper/typeprovider.hxx>
 
@@ -137,33 +138,18 @@ Sequence< sal_Int16 > Adapter::getOutIndexes( const OUString & functionName )
                     "pyuno bridge: Couldn't get reflection for method " + functionName );
             }
 
-            Sequence< ParamInfo > seqInfo = method->getParameterInfos();
-            int i;
-            int nOuts = 0;
-            for( i = 0 ; i < seqInfo.getLength() ; i ++ )
+            const Sequence< ParamInfo > seqInfo = method->getParameterInfos();
+            std::vector<sal_Int16> retVec;
+            for( sal_Int32 i = 0; i < seqInfo.getLength(); ++i )
             {
                 if( seqInfo[i].aMode == css::reflection::ParamMode_OUT ||
                     seqInfo[i].aMode == css::reflection::ParamMode_INOUT )
                 {
-                    // sequence must be interpreted as return value/outparameter tuple !
-                    nOuts ++;
+                    retVec.push_back(static_cast<sal_Int16>(i));
                 }
             }
 
-            if( nOuts )
-            {
-                ret.realloc( nOuts );
-                sal_Int32 nOutsAssigned = 0;
-                for( i = 0 ; i < seqInfo.getLength() ; i ++ )
-                {
-                    if( seqInfo[i].aMode == css::reflection::ParamMode_OUT ||
-                        seqInfo[i].aMode == css::reflection::ParamMode_INOUT )
-                    {
-                        ret[nOutsAssigned] = static_cast<sal_Int16>(i);
-                        nOutsAssigned ++;
-                    }
-                }
-            }
+            ret = comphelper::containerToSequence(retVec);
         }
         // guard active again !
         m_methodOutIndexMap[ functionName ] = ret;
@@ -276,24 +262,22 @@ Any Adapter::invoke( const OUString &aFunctionName,
                             "pyuno bridge: Couldn't extract out parameters for method " + aFunctionName );
                     }
 
-                    if( aOutParamIndex.getLength() +1 != seq.getLength() )
+                    auto nOutLength = aOutParamIndex.getLength();
+                    if( nOutLength + 1 != seq.getLength() )
                     {
                         OUString sMsg = "pyuno bridge: expected for method "
                                       + aFunctionName
                                       + " one return value and "
-                                      + OUString::number(aOutParamIndex.getLength())
+                                      + OUString::number(nOutLength)
                                       + " out parameters, got a sequence of "
                                       + OUString::number(seq.getLength())
                                       + " elements as return value.";
                         throw RuntimeException( sMsg, *this );
                     }
 
-                    aOutParam.realloc( aOutParamIndex.getLength() );
+                    aOutParam.realloc( nOutLength );
                     ret = seq[0];
-                    for( i = 0 ; i < aOutParamIndex.getLength() ; i ++ )
-                    {
-                        aOutParam[i] = seq[1+i];
-                    }
+                    std::copy_n(std::next(seq.begin()), nOutLength, aOutParam.begin());
                 }
                 // else { sequence is a return value !}
             }
diff --git a/reportdesign/source/core/api/ReportDefinition.cxx b/reportdesign/source/core/api/ReportDefinition.cxx
index 1396c93ebb2e..7ac5e6e09d20 100644
--- a/reportdesign/source/core/api/ReportDefinition.cxx
+++ b/reportdesign/source/core/api/ReportDefinition.cxx
@@ -434,19 +434,15 @@ void SAL_CALL OStyle::setAllPropertiesToDefault(  )
 
 void SAL_CALL OStyle::setPropertiesToDefault( const uno::Sequence< OUString >& aPropertyNames )
 {
-    const OUString* pIter = aPropertyNames.getConstArray();
-    const OUString* pEnd   = pIter + aPropertyNames.getLength();
-    for(;pIter != pEnd;++pIter)
-        setPropertyToDefault(*pIter);
+    for(const OUString& rName : aPropertyNames)
+        setPropertyToDefault(rName);
 }
 
 uno::Sequence< uno::Any > SAL_CALL OStyle::getPropertyDefaults( const uno::Sequence< OUString >& aPropertyNames )
 {
     uno::Sequence< uno::Any > aRet(aPropertyNames.getLength());
-    const OUString* pIter = aPropertyNames.getConstArray();
-    const OUString* pEnd   = pIter + aPropertyNames.getLength();
-    for(sal_Int32 i = 0;pIter != pEnd;++pIter,++i)
-        aRet[i] = getPropertyDefault(*pIter);
+    std::transform(aPropertyNames.begin(), aPropertyNames.end(), aRet.begin(),
+        [this](const OUString& rName) -> uno::Any { return getPropertyDefault(rName); });
     return aRet;
 }
 
@@ -1515,8 +1511,7 @@ bool OReportDefinition::WriteThroughComponent(
     // prepare arguments (prepend doc handler to given arguments)
     uno::Sequence<uno::Any> aArgs( 1 + rArguments.getLength() );
     aArgs[0] <<= xSaxWriter;
-    for(sal_Int32 i = 0; i < rArguments.getLength(); i++)
-        aArgs[i+1] = rArguments[i];
+    std::copy(rArguments.begin(), rArguments.end(), std::next(aArgs.begin()));
 
     // get filter component
     uno::Reference< document::XExporter > xExporter(
@@ -2007,12 +2002,10 @@ uno::Reference< uno::XInterface > SAL_CALL OReportDefinition::createInstanceWith
     if ( aServiceSpecifier.startsWith( "com.sun.star.document.ImportEmbeddedObjectResolver") )
     {
         uno::Reference< embed::XStorage > xStorage;
-        const uno::Any* pIter = _aArgs.getConstArray();
-        const uno::Any* pEnd  = pIter + _aArgs.getLength();
-        for(;pIter != pEnd ;++pIter)
+        for(const uno::Any& rArg : _aArgs)
         {
             beans::NamedValue aValue;
-            *pIter >>= aValue;
+            rArg >>= aValue;
             if ( aValue.Name == "Storage" )
                 aValue.Value >>= xStorage;
         }
diff --git a/reportdesign/source/core/sdr/RptObject.cxx b/reportdesign/source/core/sdr/RptObject.cxx
index 7a77b212e25e..0c132a93be48 100644
--- a/reportdesign/source/core/sdr/RptObject.cxx
+++ b/reportdesign/source/core/sdr/RptObject.cxx
@@ -1218,14 +1218,15 @@ uno::Reference< style::XStyle> getUsedStyle(const uno::Reference< report::XRepor
     uno::Reference<container::XNameAccess> xPageStyles(xStyles->getByName("PageStyles"),uno::UNO_QUERY);
 
     uno::Reference< style::XStyle> xReturn;
-    uno::Sequence< OUString> aSeq = xPageStyles->getElementNames();
-    const OUString* pIter = aSeq.getConstArray();
-    const OUString* pEnd   = pIter + aSeq.getLength();
-    for(;pIter != pEnd && !xReturn.is() ;++pIter)
+    const uno::Sequence< OUString> aSeq = xPageStyles->getElementNames();
+    for(const OUString& rName : aSeq)
     {
-        uno::Reference< style::XStyle> xStyle(xPageStyles->getByName(*pIter),uno::UNO_QUERY);
+        uno::Reference< style::XStyle> xStyle(xPageStyles->getByName(rName),uno::UNO_QUERY);
         if ( xStyle->isInUse() )
+        {
             xReturn = xStyle;
+            break;
+        }
     }
     return xReturn;
 }
diff --git a/reportdesign/source/filter/xml/xmlExport.cxx b/reportdesign/source/filter/xml/xmlExport.cxx
index 1a1416994f05..ce77628ea17c 100644
--- a/reportdesign/source/filter/xml/xmlExport.cxx
+++ b/reportdesign/source/filter/xml/xmlExport.cxx
@@ -355,14 +355,13 @@ void ORptExport::exportMasterDetailFields(const Reference<XReportComponent>& _xR
         OSL_ENSURE(aDetailFields.getLength() == aMasterFields.getLength(),"not equal length for master and detail fields!");
 
         const OUString* pDetailFieldsIter = aDetailFields.getConstArray();
-        const OUString* pIter = aMasterFields.getConstArray();
-        const OUString* pEnd   = pIter + aMasterFields.getLength();
-        for(;pIter != pEnd;++pIter,++pDetailFieldsIter)
+        for(const OUString& rMasterField : aMasterFields)
         {
-            AddAttribute( XML_NAMESPACE_REPORT, XML_MASTER , *pIter );
+            AddAttribute( XML_NAMESPACE_REPORT, XML_MASTER , rMasterField );
             if ( !pDetailFieldsIter->isEmpty() )
                 AddAttribute( XML_NAMESPACE_REPORT, XML_DETAIL , *pDetailFieldsIter );
             SvXMLElementExport aPair(*this,XML_NAMESPACE_REPORT, XML_MASTER_DETAIL_FIELD, true, true);
+            ++pDetailFieldsIter;
         }
     }
 }
diff --git a/reportdesign/source/filter/xml/xmlExportDocumentHandler.cxx b/reportdesign/source/filter/xml/xmlExportDocumentHandler.cxx
index 00cb0508e706..2116ca0c0893 100644
--- a/reportdesign/source/filter/xml/xmlExportDocumentHandler.cxx
+++ b/reportdesign/source/filter/xml/xmlExportDocumentHandler.cxx
@@ -321,14 +321,14 @@ void SAL_CALL ExportDocumentHandler::initialize( const uno::Sequence< uno::Any >
     if ( xDataProvider.is() )
     {
         m_aColumns.realloc(1);
-        uno::Sequence< OUString > aColumnNames = xDataProvider->getColumnDescriptions();
-        for(sal_Int32 i = 0 ; i < aColumnNames.getLength();++i)
+        const uno::Sequence< OUString > aColumnNames = xDataProvider->getColumnDescriptions();
+        for(const auto& rColumnName : aColumnNames)
         {
-            if ( !aColumnNames[i].isEmpty() )
+            if ( !rColumnName.isEmpty() )
             {
                 sal_Int32 nCount = m_aColumns.getLength();
                 m_aColumns.realloc(nCount+1);
-                m_aColumns[nCount] = aColumnNames[i];
+                m_aColumns[nCount] = rColumnName;
             }
         }
     }
@@ -388,9 +388,9 @@ void ExportDocumentHandler::exportTableRows()
             m_xDelegatee->endElement(sCell);
         }
     }
-    for(sal_Int32 i = 0; i < nCount ; ++i)
+    for(const auto& rColumn : std::as_const(m_aColumns))
     {
-        OUString sFormula = "field:[" + m_aColumns[i] + "]";
+        OUString sFormula = "field:[" + rColumn + "]";
         SvXMLAttributeList* pList = new SvXMLAttributeList();
         uno::Reference< xml::sax::XAttributeList > xAttribs = pList;
         pList->AddAttribute(sFormulaAttrib,sFormula);
diff --git a/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx b/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx
index 43a68a40e482..d71379715fb2 100644
--- a/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx
+++ b/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx
@@ -121,13 +121,12 @@ void SAL_CALL ImportDocumentHandler::endDocument()
         uno::Reference< chart2::data::XDataSource > xDataSource(m_xModel, uno::UNO_QUERY);
         if( xDataSource.is())
         {
-            uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aSequences(xDataSource->getDataSequences());
-            const sal_Int32 nCount( aSequences.getLength());
-            for( sal_Int32 nIdx=0; nIdx<nCount; ++nIdx )
+            const uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aSequences(xDataSource->getDataSequences());
+            for( const auto& rSequence : aSequences )
             {
-                if( aSequences[nIdx].is() )
+                if( rSequence.is() )
                 {
-                    uno::Reference< beans::XPropertySet > xSeqProp( aSequences[nIdx]->getValues(), uno::UNO_QUERY );
+                    uno::Reference< beans::XPropertySet > xSeqProp( rSequence->getValues(), uno::UNO_QUERY );
                     OUString aRole;
                     if  (   xSeqProp.is()
                         &&  ( xSeqProp->getPropertyValue( "Role" ) >>= aRole )
diff --git a/reportdesign/source/filter/xml/xmlfilter.cxx b/reportdesign/source/filter/xml/xmlfilter.cxx
index c7cc090755f2..00f7fe86a9c5 100644
--- a/reportdesign/source/filter/xml/xmlfilter.cxx
+++ b/reportdesign/source/filter/xml/xmlfilter.cxx
@@ -397,28 +397,24 @@ bool ORptFilter::implImport( const Sequence< PropertyValue >& rDescriptor )
     uno::Reference< embed::XStorage >   xStorage;
     uno::Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier;
 
-    const PropertyValue* pIter = rDescriptor.getConstArray();
-    const PropertyValue* pEnd   = pIter + rDescriptor.getLength();
-    for(;pIter != pEnd;++pIter)
+    for(const PropertyValue& rProp : rDescriptor)
     {
-        if ( pIter->Name == "FileName" )
-            pIter->Value >>= sFileName;
-        else if ( pIter->Name == "Storage" )
-            pIter->Value >>= xStorage;
-        else if ( pIter->Name == "ComponentData" )
+        if ( rProp.Name == "FileName" )
+            rProp.Value >>= sFileName;
+        else if ( rProp.Name == "Storage" )
+            rProp.Value >>= xStorage;
+        else if ( rProp.Name == "ComponentData" )
         {
             Sequence< PropertyValue > aComponent;
-            pIter->Value >>= aComponent;
+            rProp.Value >>= aComponent;
             const PropertyValue* pComponentIter = aComponent.getConstArray();
             const PropertyValue* pComponentEnd  = pComponentIter + aComponent.getLength();
-            for(;pComponentIter != pComponentEnd;++pComponentIter)
+            pComponentIter = std::find_if(pComponentIter, pComponentEnd,
+                [](const PropertyValue& rComponent) { return rComponent.Name == "ActiveConnection"; });
+            if (pComponentIter != pComponentEnd)
             {
-                if ( pComponentIter->Name == "ActiveConnection" )
-                {
-                    uno::Reference<sdbc::XConnection> xCon(pComponentIter->Value,uno::UNO_QUERY);
-                    xNumberFormatsSupplier = ::dbtools::getNumberFormats(xCon);
-                    break;
-                }
+                uno::Reference<sdbc::XConnection> xCon(pComponentIter->Value, uno::UNO_QUERY);
+                xNumberFormatsSupplier = ::dbtools::getNumberFormats(xCon);
             }
         }
     }
diff --git a/reportdesign/source/ui/dlg/AddField.cxx b/reportdesign/source/ui/dlg/AddField.cxx
index ec3297328428..5a56839f1ef9 100644
--- a/reportdesign/source/ui/dlg/AddField.cxx
+++ b/reportdesign/source/ui/dlg/AddField.cxx
@@ -277,26 +277,22 @@ namespace
 {
     void lcl_addToList( OAddFieldWindowListBox& _rListBox, const uno::Sequence< OUString >& _rEntries )
     {
-        const OUString* pEntries = _rEntries.getConstArray();
-        sal_Int32 nEntries = _rEntries.getLength();
-        for ( sal_Int32 i = 0; i < nEntries; ++i, ++pEntries )
-            _rListBox.InsertEntry( *pEntries,nullptr,false,TREELIST_APPEND,new ColumnInfo(*pEntries) );
+        for ( const OUString& rEntry : _rEntries )
+            _rListBox.InsertEntry( rEntry,nullptr,false,TREELIST_APPEND,new ColumnInfo(rEntry) );
     }
     void lcl_addToList( OAddFieldWindowListBox& _rListBox, const uno::Reference< container::XNameAccess>& i_xColumns )
     {
-        uno::Sequence< OUString > aEntries = i_xColumns->getElementNames();
-        const OUString* pEntries = aEntries.getConstArray();
-        sal_Int32 nEntries = aEntries.getLength();
-        for ( sal_Int32 i = 0; i < nEntries; ++i, ++pEntries )
+        const uno::Sequence< OUString > aEntries = i_xColumns->getElementNames();
+        for ( const OUString& rEntry : aEntries )
         {
-            uno::Reference< beans::XPropertySet> xColumn(i_xColumns->getByName(*pEntries),UNO_QUERY_THROW);
+            uno::Reference< beans::XPropertySet> xColumn(i_xColumns->getByName(rEntry),UNO_QUERY_THROW);
             OUString sLabel;
             if ( xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_LABEL) )
                 xColumn->getPropertyValue(PROPERTY_LABEL) >>= sLabel;
             if ( !sLabel.isEmpty() )
-                _rListBox.InsertEntry( sLabel,nullptr,false,TREELIST_APPEND,new ColumnInfo(*pEntries,sLabel) );
+                _rListBox.InsertEntry( sLabel,nullptr,false,TREELIST_APPEND,new ColumnInfo(rEntry,sLabel) );
             else
-                _rListBox.InsertEntry( *pEntries,nullptr,false,TREELIST_APPEND,new ColumnInfo(*pEntries,sLabel) );
+                _rListBox.InsertEntry( rEntry,nullptr,false,TREELIST_APPEND,new ColumnInfo(rEntry,sLabel) );
         }
     }
 }
diff --git a/reportdesign/source/ui/dlg/DateTime.cxx b/reportdesign/source/ui/dlg/DateTime.cxx
index 6aa4c1566073..4d2be17a59b5 100644
--- a/reportdesign/source/ui/dlg/DateTime.cxx
+++ b/reportdesign/source/ui/dlg/DateTime.cxx
@@ -86,11 +86,9 @@ void ODateTimeDialog::InsertEntry(sal_Int16 _nNumberFormatId)
     const uno::Reference< util::XNumberFormatter> xNumberFormatter = m_pController->getReportNumberFormatter();
     const uno::Reference< util::XNumberFormats> xFormats = xNumberFormatter->getNumberFormatsSupplier()->getNumberFormats();
     const uno::Sequence<sal_Int32> aFormatKeys = xFormats->queryKeys(_nNumberFormatId,m_nLocale,true);
-    const sal_Int32* pIter = aFormatKeys.getConstArray();
-    const sal_Int32* pEnd  = pIter + aFormatKeys.getLength();
-    for (;pIter != pEnd; ++pIter)
+    for (const sal_Int32 nFormatKey : aFormatKeys)
     {
-        pListBox->append(OUString::number(*pIter), getFormatStringByKey(*pIter,xFormats,bTime));
+        pListBox->append(OUString::number(nFormatKey), getFormatStringByKey(nFormatKey,xFormats,bTime));
     }
 }
 
diff --git a/reportdesign/source/ui/dlg/GroupsSorting.cxx b/reportdesign/source/ui/dlg/GroupsSorting.cxx
index 84e5c626b123..5bdc020c929c 100644
--- a/reportdesign/source/ui/dlg/GroupsSorting.cxx
+++ b/reportdesign/source/ui/dlg/GroupsSorting.cxx
@@ -58,20 +58,18 @@ using namespace ::comphelper;
 
     static void lcl_addToList_throw( ComboBoxControl& _rListBox, ::std::vector<ColumnInfo>& o_aColumnList,const uno::Reference< container::XNameAccess>& i_xColumns )
     {
-        uno::Sequence< OUString > aEntries = i_xColumns->getElementNames();
-        const OUString* pEntries = aEntries.getConstArray();
-        sal_Int32 nEntries = aEntries.getLength();
-        for ( sal_Int32 i = 0; i < nEntries; ++i, ++pEntries )
+        const uno::Sequence< OUString > aEntries = i_xColumns->getElementNames();
+        for ( const OUString& rEntry : aEntries )
         {
-            uno::Reference< beans::XPropertySet> xColumn(i_xColumns->getByName(*pEntries),uno::UNO_QUERY_THROW);
+            uno::Reference< beans::XPropertySet> xColumn(i_xColumns->getByName(rEntry),uno::UNO_QUERY_THROW);
             OUString sLabel;
             if ( xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_LABEL) )
                 xColumn->getPropertyValue(PROPERTY_LABEL) >>= sLabel;
-            o_aColumnList.emplace_back(*pEntries,sLabel );
+            o_aColumnList.emplace_back(rEntry,sLabel );
             if ( !sLabel.isEmpty() )
                 _rListBox.InsertEntry( sLabel );
             else
-                _rListBox.InsertEntry( *pEntries );
+                _rListBox.InsertEntry( rEntry );
         }
     }
 
@@ -317,11 +315,9 @@ void OFieldExpressionControl::moveGroups(const uno::Sequence<uno::Any>& _aGroups
             const UndoContext aUndoContext( m_pParent->m_pController->getUndoManager(), sUndoAction );
 
             uno::Reference< report::XGroups> xGroups = m_pParent->getGroups();
-            const uno::Any* pIter = _aGroups.getConstArray();
-            const uno::Any* pEnd  = pIter + _aGroups.getLength();
-            for(;pIter != pEnd;++pIter)
+            for(const uno::Any& rGroup : _aGroups)
             {
-                uno::Reference< report::XGroup> xGroup(*pIter,uno::UNO_QUERY);
+                uno::Reference< report::XGroup> xGroup(rGroup,uno::UNO_QUERY);
                 if ( xGroup.is() )
                 {
                     uno::Sequence< beans::PropertyValue > aArgs(1);
diff --git a/reportdesign/source/ui/dlg/Navigator.cxx b/reportdesign/source/ui/dlg/Navigator.cxx
index 6dd851e5bd0c..80d018d88220 100644
--- a/reportdesign/source/ui/dlg/Navigator.cxx
+++ b/reportdesign/source/ui/dlg/Navigator.cxx
@@ -502,11 +502,9 @@ void NavigatorTree::_selectionChanged( const lang::EventObject& aEvent )
     }
     else
     {
-        const uno::Reference< report::XReportComponent >* pIter = aSelection.getConstArray();
-        const uno::Reference< report::XReportComponent >* pEnd  = pIter + aSelection.getLength();
-        for (; pIter != pEnd; ++pIter)
+        for (const uno::Reference<report::XReportComponent>& rElem : std::as_const(aSelection))
         {
-            SvTreeListEntry* pEntry = find(*pIter);
+            SvTreeListEntry* pEntry = find(rElem);
             if ( pEntry && !IsSelected(pEntry) )
             {
                 Select(pEntry);
diff --git a/reportdesign/source/ui/inspection/GeometryHandler.cxx b/reportdesign/source/ui/inspection/GeometryHandler.cxx
index 37631941ce21..4a724dd490a5 100644
--- a/reportdesign/source/ui/inspection/GeometryHandler.cxx
+++ b/reportdesign/source/ui/inspection/GeometryHandler.cxx
@@ -1711,12 +1711,10 @@ void GeometryHandler::impl_fillMimeTypes_nothrow(::std::vector< OUString >& _out
         const uno::Reference< report::XReportDefinition> xReportDefinition(m_xReportComponent,uno::UNO_QUERY);
         if ( xReportDefinition.is() )
         {
-            uno::Sequence< OUString > aMimeTypes( xReportDefinition->getAvailableMimeTypes() );
-            const OUString* pIter = aMimeTypes.getConstArray();
-            const OUString* pEnd  = pIter + aMimeTypes.getLength();
-            for(;pIter != pEnd; ++pIter)
+            const uno::Sequence< OUString > aMimeTypes( xReportDefinition->getAvailableMimeTypes() );
+            for(const OUString& rMimeType : aMimeTypes)
             {
-                const OUString sDocName( impl_ConvertMimeTypeToUI_nothrow(*pIter) );
+                const OUString sDocName( impl_ConvertMimeTypeToUI_nothrow(rMimeType) );
                 if ( !sDocName.isEmpty() )
                     _out_rList.push_back(sDocName);
             }
diff --git a/reportdesign/source/ui/misc/RptUndo.cxx b/reportdesign/source/ui/misc/RptUndo.cxx
index 1f53e763207a..121f8e76d3be 100644
--- a/reportdesign/source/ui/misc/RptUndo.cxx
+++ b/reportdesign/source/ui/misc/RptUndo.cxx
@@ -155,13 +155,11 @@ void OSectionUndo::collectControls(const uno::Reference< report::XSection >& _xS
     {
         // copy all properties for restoring
         uno::Reference< beans::XPropertySetInfo> xInfo = _xSection->getPropertySetInfo();
-        uno::Sequence< beans::Property> aSeq = xInfo->getProperties();
-        const beans::Property* pIter = aSeq.getConstArray();
-        const beans::Property* pEnd  = pIter + aSeq.getLength();
-        for(;pIter != pEnd;++pIter)
+        const uno::Sequence< beans::Property> aSeq = xInfo->getProperties();
+        for(const beans::Property& rProp : aSeq)
         {
-            if ( 0 == (pIter->Attributes & beans::PropertyAttribute::READONLY) )
-                m_aValues.emplace_back(pIter->Name,_xSection->getPropertyValue(pIter->Name));
+            if ( 0 == (rProp.Attributes & beans::PropertyAttribute::READONLY) )
+                m_aValues.emplace_back(rProp.Name,_xSection->getPropertyValue(rProp.Name));
         }
         lcl_collectElements(_xSection,m_aControls);
     }
diff --git a/reportdesign/source/ui/report/ReportController.cxx b/reportdesign/source/ui/report/ReportController.cxx
index fd0a6b4ca88e..1c7d05fd1f12 100644
--- a/reportdesign/source/ui/report/ReportController.cxx
+++ b/reportdesign/source/ui/report/ReportController.cxx
@@ -3306,12 +3306,12 @@ void OReportController::addPairControls(const Sequence< PropertyValue >& aArgs)
     try
     {
         bool bHandleOnlyOne = false;
-        const PropertyValue* pIter = aArgs.getConstArray();
-        const PropertyValue* pEnd  = pIter + aArgs.getLength();
-        for(;pIter != pEnd && !bHandleOnlyOne;++pIter)
+        for(const PropertyValue& rArg : aArgs)
         {
+            if (bHandleOnlyOne)
+                break;
             Sequence< PropertyValue > aValue;
-            if ( !(pIter->Value >>= aValue) )
+            if ( !(rArg.Value >>= aValue) )
             {   // the sequence has only one element which already contains the descriptor
                 bHandleOnlyOne = true;
                 aValue = aArgs;
@@ -3666,15 +3666,13 @@ void OReportController::listen(const bool _bAdd)
 
     OXUndoEnvironment& rUndoEnv = m_aReportModel->GetUndoEnv();
     uno::Reference< XPropertyChangeListener > xUndo = &rUndoEnv;
-    uno::Sequence< beans::Property> aSeq = m_xReportDefinition->getPropertySetInfo()->getProperties();
-    const beans::Property* pIter = aSeq.getConstArray();
-    const beans::Property* pEnd   = pIter + aSeq.getLength();
+    const uno::Sequence< beans::Property> aSeq = m_xReportDefinition->getPropertySetInfo()->getProperties();
     const OUString* pPropsBegin = &aProps[0];
     const OUString* pPropsEnd   = pPropsBegin + SAL_N_ELEMENTS(aProps) - 3;
-    for(;pIter != pEnd;++pIter)
+    for(const beans::Property& rProp : aSeq)
     {
-        if ( ::std::find(pPropsBegin,pPropsEnd,pIter->Name) == pPropsEnd )
-            (m_xReportDefinition.get()->*pPropertyListenerAction)( pIter->Name, xUndo );
+        if ( ::std::find(pPropsBegin,pPropsEnd,rProp.Name) == pPropsEnd )
+            (m_xReportDefinition.get()->*pPropertyListenerAction)( rProp.Name, xUndo );
     }
 
     // Add Listeners to UndoEnvironment
@@ -4060,14 +4058,7 @@ css::uno::Sequence< OUString > SAL_CALL OReportController::getSupportedModes(  )
 sal_Bool SAL_CALL OReportController::supportsMode( const OUString& aMode )
 {
     uno::Sequence< OUString> aModes = getSupportedModes();
-    const OUString* pIter = aModes.getConstArray();
-    const OUString* pEnd  = pIter + aModes.getLength();
-    for(;pIter != pEnd;++pIter)
-    {
-        if ( *pIter == aMode )
-            break;
-    }
-    return pIter != pEnd;
+    return comphelper::findValue(aModes, aMode) != -1;
 }
 
 bool OReportController::isUiVisible() const
diff --git a/reportdesign/source/ui/report/ReportSection.cxx b/reportdesign/source/ui/report/ReportSection.cxx
index 880a68f7b59c..6c8b6af013ab 100644
--- a/reportdesign/source/ui/report/ReportSection.cxx
+++ b/reportdesign/source/ui/report/ReportSection.cxx
@@ -244,29 +244,24 @@ void OReportSection::Paste(const uno::Sequence< beans::NamedValue >& _aAllreadyC
         // unmark all objects
         m_pView->UnmarkAll();
         const OUString sSectionName = m_xSection->getName();
-        const sal_Int32 nLength = _aAllreadyCopiedObjects.getLength();
-        const beans::NamedValue* pIter = _aAllreadyCopiedObjects.getConstArray();
-        const beans::NamedValue* pEnd  = pIter + nLength;
-        for(;pIter != pEnd;++pIter)
+        for(const beans::NamedValue& rObject : _aAllreadyCopiedObjects)
         {
-            if ( _bForce || pIter->Name == sSectionName)
+            if ( _bForce || rObject.Name == sSectionName)
             {
                 try
                 {
                     uno::Sequence< uno::Reference<report::XReportComponent> > aCopies;
-                    pIter->Value >>= aCopies;
-                    const uno::Reference<report::XReportComponent>* pCopiesIter = aCopies.getConstArray();
-                    const uno::Reference<report::XReportComponent>* pCopiesEnd = pCopiesIter + aCopies.getLength();
-                    for (;pCopiesIter != pCopiesEnd ; ++pCopiesIter)
+                    rObject.Value >>= aCopies;
+                    for (const uno::Reference<report::XReportComponent>& rCopy : std::as_const(aCopies))
                     {
-                        SvxShape* pShape = comphelper::getUnoTunnelImplementation<SvxShape>( *pCopiesIter );
+                        SvxShape* pShape = comphelper::getUnoTunnelImplementation<SvxShape>( rCopy );
                         SdrObject* pObject = pShape ? pShape->GetSdrObject() : nullptr;
                         if ( pObject )
                         {
                             // Clone to target SdrModel
                             SdrObject* pNewObj(pObject->CloneSdrObject(*m_pModel.get()));
                             m_pPage->InsertObject(pNewObj, SAL_MAX_SIZE);
-                            tools::Rectangle aRet(VCLPoint((*pCopiesIter)->getPosition()),VCLSize((*pCopiesIter)->getSize()));
+                            tools::Rectangle aRet(VCLPoint(rCopy->getPosition()),VCLSize(rCopy->getSize()));
                             aRet.setHeight(aRet.getHeight() + 1);
                             aRet.setWidth(aRet.getWidth() + 1);
                             bool bOverlapping = true;
diff --git a/reportdesign/source/ui/report/ViewsWindow.cxx b/reportdesign/source/ui/report/ViewsWindow.cxx
index f81db3a9a4bf..bbff52d5e05f 100644
--- a/reportdesign/source/ui/report/ViewsWindow.cxx
+++ b/reportdesign/source/ui/report/ViewsWindow.cxx
@@ -602,11 +602,9 @@ void OViewsWindow::setMarked(const uno::Reference< report::XSection>& _xSection,
 void OViewsWindow::setMarked(const uno::Sequence< uno::Reference< report::XReportComponent> >& _aShapes, bool _bMark)
 {
     bool bFirst = true;
-    const uno::Reference< report::XReportComponent>* pIter = _aShapes.getConstArray();
-    const uno::Reference< report::XReportComponent>* pEnd  = pIter + _aShapes.getLength();
-    for(;pIter != pEnd;++pIter)
+    for(const uno::Reference< report::XReportComponent>& rShape : _aShapes)
     {
-        const uno::Reference< report::XSection> xSection = (*pIter)->getSection();
+        const uno::Reference< report::XSection> xSection = rShape->getSection();
         if ( xSection.is() )
         {
             if ( bFirst )
@@ -617,7 +615,7 @@ void OViewsWindow::setMarked(const uno::Sequence< uno::Reference< report::XRepor
             OSectionWindow* pSectionWindow = getSectionWindow(xSection);
             if ( pSectionWindow )
             {
-                SvxShape* pShape = comphelper::getUnoTunnelImplementation<SvxShape>( *pIter );
+                SvxShape* pShape = comphelper::getUnoTunnelImplementation<SvxShape>( rShape );
                 SdrObject* pObject = pShape ? pShape->GetSdrObject() : nullptr;
                 OSL_ENSURE( pObject, "OViewsWindow::setMarked: no SdrObject for the shape!" );
                 if ( pObject )
@@ -1607,12 +1605,10 @@ void OViewsWindow::fillCollapsedSections(::std::vector<sal_uInt16>& _rCollapsedP
 
 void OViewsWindow::collapseSections(const uno::Sequence< beans::PropertyValue>& _aCollpasedSections)
 {
-    const beans::PropertyValue* pIter = _aCollpasedSections.getConstArray();
-    const beans::PropertyValue* pEnd = pIter + _aCollpasedSections.getLength();
-    for (; pIter != pEnd; ++pIter)
+    for (const beans::PropertyValue& rSection : _aCollpasedSections)
     {
         sal_uInt16 nPos = sal_uInt16(-1);
-        if ( (pIter->Value >>= nPos) && nPos < m_aSections.size() )
+        if ( (rSection.Value >>= nPos) && nPos < m_aSections.size() )
         {
             m_aSections[nPos]->setCollapsed(true);
         }
diff --git a/sax/source/expatwrap/xml2utf.cxx b/sax/source/expatwrap/xml2utf.cxx
index c71f0bf2a993..103ef46344cb 100644
--- a/sax/source/expatwrap/xml2utf.cxx
+++ b/sax/source/expatwrap/xml2utf.cxx
@@ -187,15 +187,8 @@ bool XMLFile2UTFConverter::isEncodingRecognizable( const Sequence< sal_Int8 > &s
 
     if( bCheckIfFirstClosingBracketExsists )
     {
-        for( sal_Int32 i = 0; i < seq.getLength() ; i ++ )
-        {
-            // whole <?xml tag is valid
-            if( '>' == pSource[ i ] )
-            {
-                return true;
-            }
-        }
-        return false;
+        // whole <?xml tag is valid
+        return std::find(seq.begin(), seq.end(), '>') != seq.end();
     }
 
     // No <? tag in front, no need for a bigger buffer
diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx
index 4f1641f80b76..517f16f7c14a 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -408,11 +408,10 @@ void Entity::startElement( Event const *pEvent )
 
         if ( mxNamespaceHandler.is() )
         {
-            Sequence< xml::Attribute > NSDeclAttribs = pEvent->mxDeclAttributes->getUnknownAttributes();
-            sal_uInt16 len = NSDeclAttribs.getLength();
-            for (sal_uInt16 i = 0; i < len; i++)
+            const Sequence< xml::Attribute > NSDeclAttribs = pEvent->mxDeclAttributes->getUnknownAttributes();
+            for (const auto& rNSDeclAttrib : NSDeclAttribs)
             {
-                mxNamespaceHandler->registerNamespace( NSDeclAttribs[i].Name, NSDeclAttribs[i].Value );
+                mxNamespaceHandler->registerNamespace( rNSDeclAttrib.Name, rNSDeclAttrib.Value );
             }
         }
 
diff --git a/sax/source/fastparser/legacyfastparser.cxx b/sax/source/fastparser/legacyfastparser.cxx
index 13dfc3b1d9bf..994835acc666 100644
--- a/sax/source/fastparser/legacyfastparser.cxx
+++ b/sax/source/fastparser/legacyfastparser.cxx
@@ -227,12 +227,11 @@ void SAL_CALL CallbackDocumentHandler::startUnknownElement( const OUString& /*Na
         rtl::Reference < comphelper::AttributeList > rAttrList = new comphelper::AttributeList;
         m_aNamespaceHandler->addNSDeclAttributes( rAttrList );
 
-        Sequence< xml::FastAttribute > fastAttribs = Attribs->getFastAttributes();
-        sal_uInt16 len = fastAttribs.getLength();
-        for (sal_uInt16 i = 0; i < len; i++)
+        const Sequence< xml::FastAttribute > fastAttribs = Attribs->getFastAttributes();
+        for (const auto& rAttr : fastAttribs)
         {
-            const OUString& rAttrValue = fastAttribs[i].Value;
-            sal_Int32 nToken = fastAttribs[i].Token;
+            const OUString& rAttrValue = rAttr.Value;
+            sal_Int32 nToken = rAttr.Token;
             const OUString& rAttrNamespacePrefix = CallbackDocumentHandler::getNamespacePrefixFromToken( nToken );
             OUString sAttrName = CallbackDocumentHandler::getNameFromToken( nToken );
             if ( !rAttrNamespacePrefix.isEmpty() )
@@ -241,12 +240,11 @@ void SAL_CALL CallbackDocumentHandler::startUnknownElement( const OUString& /*Na
             rAttrList->AddAttribute( sAttrName, "CDATA", rAttrValue );
         }
 
-        Sequence< xml::Attribute > unknownAttribs = Attribs->getUnknownAttributes();
-        len = unknownAttribs.getLength();
-        for (sal_uInt16 i = 0; i < len; i++)
+        const Sequence< xml::Attribute > unknownAttribs = Attribs->getUnknownAttributes();
+        for (const auto& rAttr : unknownAttribs)
         {
-            const OUString& rAttrValue = unknownAttribs[i].Value;
-            const OUString& rAttrName = unknownAttribs[i].Name;
+            const OUString& rAttrValue = rAttr.Value;
+            const OUString& rAttrName = rAttr.Name;
 
             rAttrList->AddAttribute( rAttrName, "CDATA", rAttrValue );
         }
diff --git a/sax/source/tools/fastserializer.cxx b/sax/source/tools/fastserializer.cxx
index 70a359b1c5ee..444924f0d521 100644
--- a/sax/source/tools/fastserializer.cxx
+++ b/sax/source/tools/fastserializer.cxx
@@ -773,9 +773,9 @@ namespace sax_fastparser {
 
         // Sort it all
         std::map< sal_Int32, Int8Sequence >::iterator iter;
-        for ( sal_Int32 i=0, len=maOrder.getLength(); i < len; i++ )
+        for ( const auto nIndex : std::as_const(maOrder) )
         {
-            iter = maData.find( maOrder[i] );
+            iter = maData.find( nIndex );
             if ( iter != maData.end() )
                 ForMerge::append( iter->second );
         }


More information about the Libreoffice-commits mailing list