configmgr/qa/unit/test.cxx                                |    6 ++---
 configmgr/source/dconf.cxx                                |   16 +++++++-------
 configmgr/source/writemodfile.cxx                         |   10 ++++----
 connectivity/source/commontools/dbtools.cxx               |   13 +++++------
 connectivity/source/drivers/firebird/DatabaseMetaData.cxx |    8 +++----
 connectivity/source/drivers/flat/ETable.cxx               |    2 -
 connectivity/source/drivers/postgresql/pq_connection.cxx  |    8 +++----
 connectivity/source/drivers/postgresql/pq_statement.cxx   |    8 +++----
 connectivity/source/drivers/postgresql/pq_xbase.cxx       |    8 +++----
 9 files changed, 39 insertions(+), 40 deletions(-)

New commits:
commit 454eb3bc05f861712bff0f7593f9aa9809e4ee7c
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Mon May 18 09:18:34 2020 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon May 18 13:18:38 2020 +0200

    use for-range on Sequence in cli_ure..connectivity
    
    Change-Id: Ic5254e402d153a13c29928b59738cbe1603d0139
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94399
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/configmgr/qa/unit/test.cxx b/configmgr/qa/unit/test.cxx
index e553c1947f66..daa2070086f7 100644
--- a/configmgr/qa/unit/test.cxx
+++ b/configmgr/qa/unit/test.cxx
@@ -316,15 +316,15 @@ void Test::testReadCommands()
             "/org.openoffice.Office.UI.GenericCommands/UserInterface/"
                      "Commands"),
         css::uno::UNO_QUERY_THROW);
-    css::uno::Sequence< OUString > names(access->getElementNames());
+    const css::uno::Sequence< OUString > names(access->getElementNames());
 
     /*CPPUNIT_ASSERT_EQUAL(749, names.getLength());*/
     // testSetSetMemberName() already removed ".uno:FontworkGalleryFloater"
     sal_uInt32 n = osl_getGlobalTimer();
     for (int i = 0; i < 8; ++i) {
-        for (sal_Int32 j = 0; j < names.getLength(); ++j) {
+        for (OUString const & childName : names) {
             css::uno::Reference< css::container::XNameAccess > child;
-            if (access->getByName(names[j]) >>= child) {
+            if (access->getByName(childName) >>= child) {
                 CPPUNIT_ASSERT(child.is());
                 child->getByName("Label");
                 child->getByName("ContextLabel");
diff --git a/configmgr/source/dconf.cxx b/configmgr/source/dconf.cxx
index 8493b3351e83..75c0bb360ce3 100644
--- a/configmgr/source/dconf.cxx
+++ b/configmgr/source/dconf.cxx
@@ -1264,12 +1264,12 @@ bool addProperty(
             }
         case TYPE_STRING_LIST:
             {
-                css::uno::Sequence<OUString> seq(
+                const css::uno::Sequence<OUString> seq(
                     value.get<css::uno::Sequence<OUString>>());
                 std::vector<GVariant *> vs;
-                for (sal_Int32 i = 0; i != seq.getLength(); ++i) {
+                for (OUString const & s : seq) {
                     children.emplace_front(
-                        g_variant_new_string(encodeString(seq[i]).getStr()));
+                        g_variant_new_string(encodeString(s).getStr()));
                     if (children.front().get() == nullptr) {
                         SAL_WARN(
                             "configmgr.dconf", "g_variant_new_string failed");
@@ -1287,11 +1287,11 @@ bool addProperty(
             }
         case TYPE_HEXBINARY_LIST:
             {
-                css::uno::Sequence<css::uno::Sequence<sal_Int8>> seq(
+                const css::uno::Sequence<css::uno::Sequence<sal_Int8>> seqSeq(
                     value.get<
                         css::uno::Sequence<css::uno::Sequence<sal_Int8>>>());
                 std::vector<GVariant *> vs;
-                for (sal_Int32 i = 0; i != seq.getLength(); ++i) {
+                for (css::uno::Sequence<sal_Int8> const & seq : seqSeq) {
                     static_assert(
                         sizeof(sal_Int32) <= sizeof(gsize),
                         "G_MAXSIZE too small");
@@ -1299,8 +1299,8 @@ bool addProperty(
                         sizeof (sal_Int8) == sizeof (guchar), "size mismatch");
                     children.emplace_front(
                         g_variant_new_fixed_array(
-                            G_VARIANT_TYPE_BYTE, seq[i].getConstArray(),
-                            seq[i].getLength(), sizeof (sal_Int8)));
+                            G_VARIANT_TYPE_BYTE, seq.getConstArray(),
+                            seq.getLength(), sizeof (sal_Int8)));
                     if (children.front().get() == nullptr) {
                         SAL_WARN(
                             "configmgr.dconf",
@@ -1318,7 +1318,7 @@ bool addProperty(
                     sizeof(sal_Int32) <= sizeof(gsize),
                     "G_MAXSIZE too small");
                 v.reset(
-                    g_variant_new_array(ty.get(), vs.data(), seq.getLength()));
+                    g_variant_new_array(ty.get(), vs.data(), 
seqSeq.getLength()));
                 break;
             }
         default:
diff --git a/configmgr/source/writemodfile.cxx 
b/configmgr/source/writemodfile.cxx
index 22fd43ecf797..3df150c448cd 100644
--- a/configmgr/source/writemodfile.cxx
+++ b/configmgr/source/writemodfile.cxx
@@ -178,13 +178,13 @@ void writeValueContent_(TempFile &handle, const OUString& 
value) {
 void writeValueContent_(
     TempFile &handle, css::uno::Sequence< sal_Int8 > const & value)
 {
-    for (sal_Int32 i = 0; i < value.getLength(); ++i) {
+    for (const auto & v : value) {
         static char const hexDigit[16] = {
             '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C',
             'D', 'E', 'F' };
         handle.writeString(
-            std::string_view(hexDigit + ((value[i] >> 4) & 0xF), 1));
-        handle.writeString(std::string_view(hexDigit + (value[i] & 0xF), 1));
+            std::string_view(hexDigit + ((v >> 4) & 0xF), 1));
+        handle.writeString(std::string_view(hexDigit + (v & 0xF), 1));
     }
 }
 
@@ -219,9 +219,9 @@ template< typename T > void writeItemListValue(
     handle.writeString(">");
     css::uno::Sequence< T > val;
     value >>= val;
-    for (sal_Int32 i = 0; i < val.getLength(); ++i) {
+    for (const auto & i : val) {
         handle.writeString("<it>");
-        writeValueContent_(handle, val[i]);
+        writeValueContent_(handle, i);
         handle.writeString("</it>");
     }
     handle.writeString("</value>");
diff --git a/connectivity/source/commontools/dbtools.cxx 
b/connectivity/source/commontools/dbtools.cxx
index a16549ba3b50..419cd26e7c07 100644
--- a/connectivity/source/commontools/dbtools.cxx
+++ b/connectivity/source/commontools/dbtools.cxx
@@ -946,11 +946,10 @@ try
     Reference< XPropertySetInfo> xOldInfo( xOldProps->getPropertySetInfo());
     Reference< XPropertySetInfo> xNewInfo( xNewProps->getPropertySetInfo());
 
-    Sequence< Property> aOldProperties = xOldInfo->getProperties();
+    const Sequence< Property> aOldProperties = xOldInfo->getProperties();
     Sequence< Property> aNewProperties = xNewInfo->getProperties();
     int nNewLen = aNewProperties.getLength();
 
-    Property* pOldProps = aOldProperties.getArray();
     Property* pNewProps = aNewProperties.getArray();
 
     OUString sPropFormatsSupplier("FormatsSupplier");
@@ -968,18 +967,18 @@ try
     OUString sPropClassId("ClassId");
     OUString sFormattedServiceName( 
"com.sun.star.form.component.FormattedField" );
 
-    for (sal_Int32 i=0; i<aOldProperties.getLength(); ++i)
+    for (const Property& rOldProp : aOldProperties)
     {
-        if ( pOldProps[i].Name != "DefaultControl" && pOldProps[i].Name != 
"LabelControl" )
+        if ( rOldProp.Name != "DefaultControl" && rOldProp.Name != 
"LabelControl" )
         {
             // binary search
             Property* pResult = std::lower_bound(
-                pNewProps, pNewProps + nNewLen, pOldProps[i], 
::comphelper::PropertyCompareByName());
+                pNewProps, pNewProps + nNewLen, rOldProp, 
::comphelper::PropertyCompareByName());
 
             if (   ( pResult != aNewProperties.end() )
-                && ( pResult->Name == pOldProps[i].Name )
+                && ( pResult->Name == rOldProp.Name )
                 && ( (pResult->Attributes & PropertyAttribute::READONLY) == 0 )
-                && ( pResult->Type.equals(pOldProps[i].Type)) )
+                && ( pResult->Type.equals(rOldProp.Type)) )
             {   // Attributes match and the property is not read-only
                 try
                 {
diff --git a/connectivity/source/drivers/firebird/DatabaseMetaData.cxx 
b/connectivity/source/drivers/firebird/DatabaseMetaData.cxx
index 661dd7dc95d0..3823e7874f34 100644
--- a/connectivity/source/drivers/firebird/DatabaseMetaData.cxx
+++ b/connectivity/source/drivers/firebird/DatabaseMetaData.cxx
@@ -1338,13 +1338,13 @@ uno::Reference< XResultSet > SAL_CALL 
ODatabaseMetaData::getTables(
     else
     {
         queryBuf.append("( (0 = 1) ");
-        for (int i = 0; i < types.getLength(); i++)
+        for (OUString const & t : types)
         {
-            if (types[i] == "SYSTEM TABLE")
+            if (t == "SYSTEM TABLE")
                 queryBuf.append("OR (RDB$SYSTEM_FLAG = 1 AND RDB$VIEW_BLR IS 
NULL) ");
-            else if (types[i] == "TABLE")
+            else if (t == "TABLE")
                 queryBuf.append("OR (RDB$SYSTEM_FLAG IS NULL OR 
RDB$SYSTEM_FLAG = 0 AND RDB$VIEW_BLR IS NULL) ");
-            else if (types[i] == "VIEW")
+            else if (t == "VIEW")
                 queryBuf.append("OR (RDB$SYSTEM_FLAG IS NULL OR 
RDB$SYSTEM_FLAG = 0 AND RDB$VIEW_BLR IS NOT NULL) ");
             else
                 throw SQLException(); // TODO: implement other types, see 
above.
diff --git a/connectivity/source/drivers/flat/ETable.cxx 
b/connectivity/source/drivers/flat/ETable.cxx
index 43bc75225b1d..0dceba05b641 100644
--- a/connectivity/source/drivers/flat/ETable.cxx
+++ b/connectivity/source/drivers/flat/ETable.cxx
@@ -662,7 +662,7 @@ bool OFlatTable::fetchRow(OValueRefRow& _rRow, const 
OSQLColumns & _rCols, bool
                             }
                             else
                                 aBuf.append(cChar);
-                        } // for (j = 0; j < aStr.getLength(); ++j)
+                        } // for (j = 0; j < aStr.(); ++j)
                         aStrConverted = aBuf.makeStringAndClear();
                     } // if ( DataType::INTEGER != nType )
                     else
diff --git a/connectivity/source/drivers/postgresql/pq_connection.cxx 
b/connectivity/source/drivers/postgresql/pq_connection.cxx
index fd1b9fd1297d..66c30c893aed 100644
--- a/connectivity/source/drivers/postgresql/pq_connection.cxx
+++ b/connectivity/source/drivers/postgresql/pq_connection.cxx
@@ -397,12 +397,12 @@ static void properties2arrays( const Sequence< 
PropertyValue > & args,
         "requiressl"
     };
 
-    for( int i = 0; i < args.getLength() ; ++i )
+    for( PropertyValue const & prop : args )
     {
         bool append = false;
         for(const char* j : keyword_list)
         {
-            if( args[i].Name.equalsIgnoreAsciiCaseAscii( j ))
+            if( prop.Name.equalsIgnoreAsciiCaseAscii( j ))
             {
                 keywords.push_back( j, SAL_NO_ACQUIRE );
                 append = true;
@@ -413,14 +413,14 @@ static void properties2arrays( const Sequence< 
PropertyValue > & args,
         if( append )
         {
             OUString value;
-            tc->convertTo( args[i].Value, 
cppu::UnoType<decltype(value)>::get() ) >>= value;
+            tc->convertTo( prop.Value, cppu::UnoType<decltype(value)>::get() ) 
>>= value;
             char *v = strdup(OUStringToOString(value, enc).getStr());
             values.push_back ( v );
         }
         else
         {
             // ignore for now
-            SAL_WARN("connectivity.postgresql", "sdbc-postgresql: unknown 
argument '" << args[i].Name << "' having value: " << args[i].Value );
+            SAL_WARN("connectivity.postgresql", "sdbc-postgresql: unknown 
argument '" << prop.Name << "' having value: " << prop.Value );
         }
     }
 }
diff --git a/connectivity/source/drivers/postgresql/pq_statement.cxx 
b/connectivity/source/drivers/postgresql/pq_statement.cxx
index 6c2deef8fe0f..dd7ab576b37f 100644
--- a/connectivity/source/drivers/postgresql/pq_statement.cxx
+++ b/connectivity/source/drivers/postgresql/pq_statement.cxx
@@ -637,7 +637,7 @@ Reference< XResultSet > getGeneratedValuesFromLastInsert(
         // TODO: make also unqualified tables names work here. Have a look at 
2.8.3. The Schema Search Path
         //       in postgresql doc
 
-        Sequence< OUString > keyColumnNames = getPrimaryKeyColumnNames( 
connection, schemaName, tableName );
+        const Sequence< OUString > keyColumnNames = getPrimaryKeyColumnNames( 
connection, schemaName, tableName );
         if( keyColumnNames.hasElements() )
         {
             OUStringBuffer buf( 128 );
@@ -646,10 +646,10 @@ Reference< XResultSet > getGeneratedValuesFromLastInsert(
             buf.append( " WHERE " );
             bool bAdditionalCondition = false;
             String2StringMap autoValues;
-            for( int i = 0 ; i < keyColumnNames.getLength() ; i ++ )
+            for( OUString const & columnNameUnicode : keyColumnNames )
             {
                 OUString value;
-                OString columnName = OUStringToOString( keyColumnNames[i], 
ConnectionSettings::encoding );
+                OString columnName = OUStringToOString( columnNameUnicode, 
ConnectionSettings::encoding );
                 bool bColumnMatchNamedValue = false;
                 for (auto const& namedValue : namedValues)
                 {
@@ -701,7 +701,7 @@ Reference< XResultSet > getGeneratedValuesFromLastInsert(
 
                 if( bAdditionalCondition )
                     buf.append( " AND " );
-                bufferQuoteIdentifier( buf, keyColumnNames[i], 
pConnectionSettings );
+                bufferQuoteIdentifier( buf, columnNameUnicode, 
pConnectionSettings );
                 buf.append( " = " );
                 buf.append( value );
                 bAdditionalCondition = true;
diff --git a/connectivity/source/drivers/postgresql/pq_xbase.cxx 
b/connectivity/source/drivers/postgresql/pq_xbase.cxx
index 377b3dd4b99b..1fec4130a9db 100644
--- a/connectivity/source/drivers/postgresql/pq_xbase.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xbase.cxx
@@ -178,12 +178,12 @@ void ReflectionBase::copyValuesFrom( const Reference< 
XPropertySet > & set )
     {
         Reference< XPropertySetInfo > myPropInfo = getPropertySetInfo();
 
-        Sequence< Property > props = info->getProperties();
-        for( int i = 0 ; i < props.getLength() ; i ++ )
+        const Sequence< Property > props = info->getProperties();
+        for( Property const & prop : props )
         {
-            if( myPropInfo->hasPropertyByName( props[i].Name ) )
+            if( myPropInfo->hasPropertyByName( prop.Name ) )
                 setPropertyValue_NoBroadcast_public(
-                    props[i].Name, set->getPropertyValue( props[i].Name ) );
+                    prop.Name, set->getPropertyValue( prop.Name ) );
         }
     }
 }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to