[Libreoffice-commits] core.git: dbaccess/source

Julien Nabet serval2412 at yahoo.fr
Wed Mar 7 23:15:59 UTC 2018


 dbaccess/source/core/api/CacheSet.cxx                   |   18 ++---
 dbaccess/source/core/api/FilteredContainer.cxx          |   42 +++++-------
 dbaccess/source/core/api/HelperCollections.cxx          |    7 --
 dbaccess/source/core/api/KeySet.cxx                     |   24 +++----
 dbaccess/source/core/api/RowSet.cxx                     |    5 -
 dbaccess/source/core/api/RowSetBase.cxx                 |    6 -
 dbaccess/source/core/api/SingleSelectQueryComposer.cxx  |   54 +++++-----------
 dbaccess/source/core/api/querycontainer.cxx             |    8 --
 dbaccess/source/core/dataaccess/ComponentDefinition.cxx |    6 -
 dbaccess/source/core/dataaccess/ModelImpl.cxx           |   46 +++++--------
 10 files changed, 86 insertions(+), 130 deletions(-)

New commits:
commit d6b33e49a5e9c51827eda9c5ba16d8daeb27e8af
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Tue Mar 6 23:30:30 2018 +0100

    Use for-range loops in dbaccess (part 3)
    
    Change-Id: I4cec44ea6366b6a38992e583d6290223d5c469f6
    Reviewed-on: https://gerrit.libreoffice.org/50849
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>

diff --git a/dbaccess/source/core/api/CacheSet.cxx b/dbaccess/source/core/api/CacheSet.cxx
index 46eb35cefce4..9a7303cf52a1 100644
--- a/dbaccess/source/core/api/CacheSet.cxx
+++ b/dbaccess/source/core/api/CacheSet.cxx
@@ -248,11 +248,9 @@ void OCacheSet::fillParameters( const ORowSetRow& _rRow
             _rOrgValues.push_back(nCheckCount);
 
         }
-        std::vector< Reference<XNameAccess> >::const_iterator aIndexEnd = aAllIndexColumns.end();
-        for( std::vector< Reference<XNameAccess> >::const_iterator aIndexIter = aAllIndexColumns.begin();
-                aIndexIter != aIndexEnd;++aIndexIter)
+        for (auto const& indexColumn : aAllIndexColumns)
         {
-            if((*aIndexIter)->hasByName(aColumnName))
+            if(indexColumn->hasByName(aColumnName))
             {
                 _sCondition.append(::dbtools::quoteName( aQuote,aColumnName));
                 if(aIter->isNull())
@@ -306,10 +304,10 @@ void OCacheSet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOri
             ++i;
         }
     }
-    auto aOrgValueEnd = aOrgValues.cend();
-    for(auto aOrgValue = aOrgValues.cbegin(); aOrgValue != aOrgValueEnd;++aOrgValue,++i)
+    for (auto const& orgValue : aOrgValues)
     {
-        setParameter(i,xParameter,(_rOriginalRow->get())[*aOrgValue],m_xSetMetaData->getColumnType(i),m_xSetMetaData->getScale(i));
+        setParameter(i,xParameter,(_rOriginalRow->get())[orgValue],m_xSetMetaData->getColumnType(i),m_xSetMetaData->getScale(i));
+        ++i;
     }
 
      m_bUpdated = xPrep->executeUpdate() > 0;
@@ -357,10 +355,10 @@ void OCacheSet::deleteRow(const ORowSetRow& _rDeleteRow ,const connectivity::OSQ
     Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql.makeStringAndClear()));
     Reference< XParameters > xParameter(xPrep,UNO_QUERY);
     sal_Int32 i = 1;
-    auto aOrgValueEnd = aOrgValues.cend();
-    for(auto j = aOrgValues.cbegin(); j != aOrgValueEnd; ++j,++i)
+    for (auto const& orgValue : aOrgValues)
     {
-        setParameter(i,xParameter,(_rDeleteRow->get())[*j],m_xSetMetaData->getColumnType(i),m_xSetMetaData->getScale(i));
+        setParameter(i,xParameter,(_rDeleteRow->get())[orgValue],m_xSetMetaData->getColumnType(i),m_xSetMetaData->getScale(i));
+        ++i;
     }
 
     m_bDeleted = xPrep->executeUpdate() > 0;
diff --git a/dbaccess/source/core/api/FilteredContainer.cxx b/dbaccess/source/core/api/FilteredContainer.cxx
index 09e5089ccaee..9f5fe4c824b8 100644
--- a/dbaccess/source/core/api/FilteredContainer.cxx
+++ b/dbaccess/source/core/api/FilteredContainer.cxx
@@ -85,11 +85,12 @@ sal_Int32 createWildCardVector(Sequence< OUString >& _rTableFilter, std::vector<
         // the table is allowed to "pass" if we had no filters at all or any of the non-wildcard filters matches
         if (!bFilterMatch && !_rWCSearch.empty())
         {   // or if one of the wildcard expression matches
-            for (   std::vector< WildCard >::const_iterator aLoop = _rWCSearch.begin();
-                    aLoop != _rWCSearch.end() && !bFilterMatch;
-                    ++aLoop
-                )
-                bFilterMatch = aLoop->Matches( _rName );
+            for (auto const& elem : _rWCSearch)
+            {
+                bFilterMatch = elem.Matches( _rName );
+                if (bFilterMatch)
+                    break;
+            }
         }
 
         return bFilterMatch;
@@ -184,15 +185,12 @@ sal_Int32 createWildCardVector(Sequence< OUString >& _rTableFilter, std::vector<
             TableInfos aUnfilteredTables( _unfilteredTables );
             aUnfilteredTables.reserve( nTableFilterCount + ( aWildCardTableFilter.size() * 10 ) );
 
-            for (   TableInfos::iterator table = aUnfilteredTables.begin();
-                    table != aUnfilteredTables.end();
-                    ++table
-                )
+            for (auto & unfilteredTable : aUnfilteredTables)
             {
-                lcl_ensureComposedName( *table, _metaData );
+                lcl_ensureComposedName(unfilteredTable, _metaData);
 
-                if ( lcl_isElementAllowed( *table->sComposedName, aNonWildCardTableFilter, aWildCardTableFilter ) )
-                    aFilteredTables.push_back( *table );
+                if ( lcl_isElementAllowed( *unfilteredTable.sComposedName, aNonWildCardTableFilter, aWildCardTableFilter ) )
+                    aFilteredTables.push_back(unfilteredTable);
             }
         }
 
@@ -209,27 +207,21 @@ sal_Int32 createWildCardVector(Sequence< OUString >& _rTableFilter, std::vector<
             const OUString* pTableTypeFilterBegin = _tableTypeFilter.getConstArray();
             const OUString* pTableTypeFilterEnd = pTableTypeFilterBegin + _tableTypeFilter.getLength();
 
-            for (   TableInfos::iterator table = aUnfilteredTables.begin();
-                    table != aUnfilteredTables.end();
-                    ++table
-                )
+            for (auto & unfilteredTable : aUnfilteredTables)
             {
                 // ensure that we know the table type
-                lcl_ensureType( *table, _metaData, _masterContainer );
+                lcl_ensureType( unfilteredTable, _metaData, _masterContainer );
 
-                if ( std::find( pTableTypeFilterBegin, pTableTypeFilterEnd, *table->sType ) != pTableTypeFilterEnd )
-                    aFilteredTables.push_back( *table );
+                if ( std::find( pTableTypeFilterBegin, pTableTypeFilterEnd, *unfilteredTable.sType ) != pTableTypeFilterEnd )
+                    aFilteredTables.push_back(unfilteredTable);
             }
         }
 
         ::std::vector< OUString> aReturn;
-        for (   TableInfos::iterator table = aFilteredTables.begin();
-                table != aFilteredTables.end();
-                ++table
-            )
+        for (auto & filteredTable : aFilteredTables)
         {
-            lcl_ensureComposedName( *table, _metaData );
-            aReturn.push_back( *table->sComposedName );
+            lcl_ensureComposedName(filteredTable, _metaData);
+            aReturn.push_back(*filteredTable.sComposedName);
         }
         return aReturn;
     }
diff --git a/dbaccess/source/core/api/HelperCollections.cxx b/dbaccess/source/core/api/HelperCollections.cxx
index 2a873c862718..edf1a60c0a1c 100644
--- a/dbaccess/source/core/api/HelperCollections.cxx
+++ b/dbaccess/source/core/api/HelperCollections.cxx
@@ -55,12 +55,9 @@ namespace dbaccess
         std::vector< OUString > aNames; aNames.reserve( _rColumns->get().size() );
 
         OUString sColumName;
-        for (   ::connectivity::OSQLColumns::Vector::const_iterator column = _rColumns->get().begin();
-                column != _rColumns->get().end();
-                ++column
-            )
+        for (auto const& column : _rColumns->get())
         {
-            Reference< XPropertySet > xColumn( *column, UNO_QUERY_THROW );
+            Reference< XPropertySet > xColumn(column, UNO_QUERY_THROW);
             xColumn->getPropertyValue( PROPERTY_NAME ) >>= sColumName;
             aNames.push_back( sColumName );
         }
diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx
index 47002e0a73be..66bd473612e2 100644
--- a/dbaccess/source/core/api/KeySet.cxx
+++ b/dbaccess/source/core/api/KeySet.cxx
@@ -803,19 +803,20 @@ void OKeySet::copyRowValue(const ORowSetRow& _rInsertRow, ORowSetRow const & _rK
     connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaValuesIter = m_aParameterValueForCache->get().begin() +1;
 
     bool bChanged = false;
-    SelectColumnsMetaData::const_iterator aParaIter = (*m_pParameterNames).begin();
-    SelectColumnsMetaData::const_iterator aParaEnd = (*m_pParameterNames).end();
-    for(sal_Int32 i = 1;aParaIter != aParaEnd;++aParaIter,++aParaValuesIter,++i)
+    sal_Int32 i = 1;
+    for (auto const& parameterName : *m_pParameterNames)
     {
         ORowSetValue aValue(*aParaValuesIter);
-        aValue.setSigned(m_aSignedFlags[aParaIter->second.nPosition-1]);
-        if ( (_rInsertRow->get())[aParaIter->second.nPosition] != aValue )
+        aValue.setSigned(m_aSignedFlags[parameterName.second.nPosition-1]);
+        if ( (_rInsertRow->get())[parameterName.second.nPosition] != aValue )
         {
             rtl::Reference<ORowSetValueVector> aCopy(new ORowSetValueVector(*m_aParameterValueForCache.get()));
-            (aCopy->get())[i] = (_rInsertRow->get())[aParaIter->second.nPosition];
+            (aCopy->get())[i] = (_rInsertRow->get())[parameterName.second.nPosition];
             m_aUpdatedParameter[i_nBookmark] = aCopy;
             bChanged = true;
         }
+        ++aParaValuesIter;
+        ++i;
     }
     if ( !bChanged )
     {
@@ -823,13 +824,12 @@ void OKeySet::copyRowValue(const ORowSetRow& _rInsertRow, ORowSetRow const & _rK
     }
 
     // update the key values
-    SelectColumnsMetaData::const_iterator aPosIter = (*m_pKeyColumnNames).begin();
-    const SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end();
-    for(;aPosIter != aPosEnd;++aPosIter,++aIter)
+    for (auto const& keyColumnName : *m_pKeyColumnNames)
     {
-        impl_convertValue_throw(_rInsertRow,aPosIter->second);
-        *aIter = (_rInsertRow->get())[aPosIter->second.nPosition];
-        aIter->setTypeKind(aPosIter->second.nType);
+        impl_convertValue_throw(_rInsertRow,keyColumnName.second);
+        *aIter = (_rInsertRow->get())[keyColumnName.second.nPosition];
+        aIter->setTypeKind(keyColumnName.second.nType);
+        ++aIter;
     }
 }
 
diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx
index cf7d33f40eaa..3d4e58a93c6b 100644
--- a/dbaccess/source/core/api/RowSet.cxx
+++ b/dbaccess/source/core/api/RowSet.cxx
@@ -2182,10 +2182,9 @@ void ORowSet::notifyRowSetAndClonesRowDeleted( const Any& _rBookmark, sal_Int32
     // notify ourself
     onDeletedRow( _rBookmark, _nPos );
     // notify the clones
-    connectivity::OWeakRefArray::const_iterator aEnd = m_aClones.end();
-    for (connectivity::OWeakRefArray::const_iterator i = m_aClones.begin(); aEnd != i; ++i)
+    for (auto const& clone : m_aClones)
     {
-        Reference< XUnoTunnel > xTunnel(i->get(),UNO_QUERY);
+        Reference< XUnoTunnel > xTunnel(clone.get(),UNO_QUERY);
         if(xTunnel.is())
         {
             ORowSetClone* pClone = reinterpret_cast<ORowSetClone*>(xTunnel->getSomething(ORowSetClone::getUnoTunnelImplementationId()));
diff --git a/dbaccess/source/core/api/RowSetBase.cxx b/dbaccess/source/core/api/RowSetBase.cxx
index 454ee93cab74..8e77f4b39731 100644
--- a/dbaccess/source/core/api/RowSetBase.cxx
+++ b/dbaccess/source/core/api/RowSetBase.cxx
@@ -1167,17 +1167,17 @@ void ORowSetBase::firePropertyChange(const ORowSetRow& _rOldRow)
     SAL_INFO("dbaccess", "ORowSetBase::firePropertyChange() Clone = " << m_bClone);
     OSL_ENSURE(m_pColumns,"Columns can not be NULL here!");
     sal_Int32 i=0;
-    TDataColumns::const_iterator aEnd = m_aDataColumns.end();
-    for(TDataColumns::const_iterator aIter = m_aDataColumns.begin();aIter != aEnd;++aIter,++i)
+    for (auto const& dataColumn : m_aDataColumns)
     {
         try
         {
-            (*aIter)->fireValueChange(_rOldRow.is() ? (_rOldRow->get())[i+1] : ::connectivity::ORowSetValue());
+            dataColumn->fireValueChange(_rOldRow.is() ? (_rOldRow->get())[i+1] : ::connectivity::ORowSetValue());
         }
         catch (const Exception&)
         {
             SAL_WARN("dbaccess", "firePropertyChange: Exception on column " << i);
         }
+        ++i;
     }
     SAL_INFO("dbaccess", "ORowSetBase::firePropertyChange() Clone = " << m_bClone);
 }
diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
index 785f74e590ff..04b3bb40e51b 100644
--- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
+++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
@@ -264,15 +264,11 @@ OSingleSelectQueryComposer::OSingleSelectQueryComposer(const Reference< XNameAcc
 
 OSingleSelectQueryComposer::~OSingleSelectQueryComposer()
 {
-    std::vector<OPrivateColumns*>::const_iterator aColIter = m_aColumnsCollection.begin();
-    std::vector<OPrivateColumns*>::const_iterator aEnd = m_aColumnsCollection.end();
-    for(;aColIter != aEnd;++aColIter)
-        delete *aColIter;
-
-    std::vector<OPrivateTables*>::const_iterator aTabIter = m_aTablesCollection.begin();
-    std::vector<OPrivateTables*>::const_iterator aTabEnd = m_aTablesCollection.end();
-    for(;aTabIter != aTabEnd;++aTabIter)
-        delete *aTabIter;
+    for (auto const& columnCollection : m_aColumnsCollection)
+        delete columnCollection;
+
+    for (auto const& tableCollection : m_aTablesCollection)
+        delete tableCollection;
 }
 
 // OComponentHelper
@@ -728,9 +724,8 @@ Reference< XNameAccess > SAL_CALL OSingleSelectQueryComposer::getTables(  )
     {
         const OSQLTables& aTables = m_aSqlIterator.getTables();
         std::vector< OUString> aNames;
-        OSQLTables::const_iterator aEnd = aTables.end();
-        for(OSQLTables::const_iterator aIter = aTables.begin(); aIter != aEnd;++aIter)
-            aNames.push_back(aIter->first);
+        for (auto const& elem : aTables)
+            aNames.push_back(elem.first);
 
         m_pTables = new OPrivateTables(aTables,m_xMetaData->supportsMixedCaseQuotedIdentifiers(),*this,m_aMutex,aNames);
     }
@@ -1333,9 +1328,8 @@ Reference< XIndexAccess > SAL_CALL OSingleSelectQueryComposer::getParameters(  )
     {
         ::rtl::Reference< OSQLColumns> aCols = m_aSqlIterator.getParameters();
         std::vector< OUString> aNames;
-        OSQLColumns::Vector::const_iterator aEnd = aCols->get().end();
-        for(OSQLColumns::Vector::const_iterator aIter = aCols->get().begin(); aIter != aEnd;++aIter)
-            aNames.push_back(getString((*aIter)->getPropertyValue(PROPERTY_NAME)));
+        for (auto const& elem : aCols->get())
+            aNames.push_back(getString(elem->getPropertyValue(PROPERTY_NAME)));
         m_aCurrentColumns[ParameterColumns] = new OPrivateColumns(aCols,m_xMetaData->supportsMixedCaseQuotedIdentifiers(),*this,m_aMutex,aNames,true);
     }
 
@@ -1355,15 +1349,13 @@ void OSingleSelectQueryComposer::clearColumns( const EColumnType _eType )
 
 void OSingleSelectQueryComposer::clearCurrentCollections()
 {
-    std::vector<OPrivateColumns*>::iterator aIter = m_aCurrentColumns.begin();
-    std::vector<OPrivateColumns*>::const_iterator aEnd = m_aCurrentColumns.end();
-    for (;aIter != aEnd;++aIter)
+    for (auto & currentColumn : m_aCurrentColumns)
     {
-        if ( *aIter )
+        if (currentColumn)
         {
-            (*aIter)->disposing();
-            m_aColumnsCollection.push_back(*aIter);
-            *aIter = nullptr;
+            currentColumn->disposing();
+            m_aColumnsCollection.push_back(currentColumn);
+            currentColumn = nullptr;
         }
     }
 
@@ -1385,9 +1377,8 @@ Reference< XIndexAccess > OSingleSelectQueryComposer::setCurrentColumns( EColumn
     if ( !m_aCurrentColumns[_eType] )
     {
         std::vector< OUString> aNames;
-        OSQLColumns::Vector::const_iterator aEnd = _rCols->get().end();
-        for(OSQLColumns::Vector::const_iterator aIter = _rCols->get().begin(); aIter != aEnd;++aIter)
-            aNames.push_back(getString((*aIter)->getPropertyValue(PROPERTY_NAME)));
+        for (auto const& elem : _rCols->get())
+            aNames.push_back(getString(elem->getPropertyValue(PROPERTY_NAME)));
         m_aCurrentColumns[_eType] = new OPrivateColumns(_rCols,m_xMetaData->supportsMixedCaseQuotedIdentifiers(),*this,m_aMutex,aNames,true);
     }
 
@@ -1759,18 +1750,13 @@ Sequence< Sequence< PropertyValue > > OSingleSelectQueryComposer::getStructuredC
                 {
                     aFilterSeq.realloc(aFilters.size());
                     Sequence<PropertyValue>* pFilters = aFilterSeq.getArray();
-                    std::vector< std::vector < PropertyValue > >::const_iterator aEnd = aFilters.end();
-                    std::vector< std::vector < PropertyValue > >::const_iterator i = aFilters.begin();
-                    for ( ; i != aEnd ; ++i)
+                    for (auto const& filter : aFilters)
                     {
-                        const std::vector < PropertyValue >& rProperties = *i;
-                        pFilters->realloc(rProperties.size());
+                        pFilters->realloc(filter.size());
                         PropertyValue* pFilter = pFilters->getArray();
-                        std::vector < PropertyValue >::const_iterator j = rProperties.begin();
-                        std::vector < PropertyValue >::const_iterator aEnd2 = rProperties.end();
-                        for ( ; j != aEnd2 ; ++j)
+                        for (auto const& elem : filter)
                         {
-                            *pFilter = *j;
+                            *pFilter = elem;
                             ++pFilter;
                         }
                         ++pFilters;
diff --git a/dbaccess/source/core/api/querycontainer.cxx b/dbaccess/source/core/api/querycontainer.cxx
index 1951136ec315..6c9a4da2f9f2 100644
--- a/dbaccess/source/core/api/querycontainer.cxx
+++ b/dbaccess/source/core/api/querycontainer.cxx
@@ -323,13 +323,11 @@ void SAL_CALL OQueryContainer::disposing( const css::lang::EventObject& _rSource
     {
         Reference< XContent > xSource(_rSource.Source, UNO_QUERY);
         // it's one of our documents ....
-        Documents::const_iterator aIter = m_aDocumentMap.begin();
-        Documents::const_iterator aEnd = m_aDocumentMap.end();
-        for (;aIter != aEnd;++aIter )
+        for (auto const& document : m_aDocumentMap)
         {
-            if ( xSource == aIter->second.get() )
+            if ( xSource == document.second.get() )
             {
-                m_xCommandDefinitions->removeByName(aIter->first);
+                m_xCommandDefinitions->removeByName(document.first);
                 break;
             }
         }
diff --git a/dbaccess/source/core/dataaccess/ComponentDefinition.cxx b/dbaccess/source/core/dataaccess/ComponentDefinition.cxx
index f3ed8e73e388..72dbde0c2e44 100644
--- a/dbaccess/source/core/dataaccess/ComponentDefinition.cxx
+++ b/dbaccess/source/core/dataaccess/ComponentDefinition.cxx
@@ -202,10 +202,8 @@ Reference< XNameAccess> OComponentDefinition::getColumns()
         const OComponentDefinition_Impl& rDefinition( getDefinition() );
         aNames.reserve( rDefinition.size() );
 
-        OComponentDefinition_Impl::const_iterator aIter = rDefinition.begin();
-        OComponentDefinition_Impl::const_iterator aEnd = rDefinition.end();
-        for ( ; aIter != aEnd; ++aIter )
-            aNames.push_back( aIter->first );
+        for (auto const& definition : rDefinition)
+            aNames.push_back(definition.first);
 
         m_xColumns = new OColumns( *this, m_aMutex, true, aNames, this, nullptr, true, false, false );
         m_xColumns->setParent( *this );
diff --git a/dbaccess/source/core/dataaccess/ModelImpl.cxx b/dbaccess/source/core/dataaccess/ModelImpl.cxx
index e1bde0c71386..68439e8b71fb 100644
--- a/dbaccess/source/core/dataaccess/ModelImpl.cxx
+++ b/dbaccess/source/core/dataaccess/ModelImpl.cxx
@@ -159,14 +159,11 @@ void DocumentStorageAccess::dispose()
 {
     ::osl::MutexGuard aGuard( m_aMutex );
 
-    for (   NamedStorages::const_iterator loop = m_aExposedStorages.begin();
-            loop != m_aExposedStorages.end();
-            ++loop
-        )
+    for (auto const& exposedStorage : m_aExposedStorages)
     {
         try
         {
-            Reference< XTransactionBroadcaster > xBroadcaster( loop->second, UNO_QUERY );
+            Reference< XTransactionBroadcaster > xBroadcaster(exposedStorage.second, UNO_QUERY);
             if ( xBroadcaster.is() )
                 xBroadcaster->removeTransactionListener( this );
         }
@@ -217,15 +214,11 @@ void DocumentStorageAccess::disposeStorages()
 {
     m_bDisposingSubStorages = true;
 
-    NamedStorages::const_iterator aEnd = m_aExposedStorages.end();
-    for (   NamedStorages::iterator aIter = m_aExposedStorages.begin();
-            aIter != aEnd ;
-            ++aIter
-        )
+    for (auto & exposedStorage : m_aExposedStorages)
     {
         try
         {
-            ::comphelper::disposeComponent( aIter->second );
+            ::comphelper::disposeComponent( exposedStorage.second );
         }
         catch( const Exception& )
         {
@@ -241,12 +234,9 @@ void DocumentStorageAccess::commitStorages()
 {
     try
     {
-        for (   NamedStorages::const_iterator aIter = m_aExposedStorages.begin();
-                aIter != m_aExposedStorages.end();
-                ++aIter
-            )
+        for (auto const& exposedStorage : m_aExposedStorages)
         {
-            tools::stor::commitStorageIfWriteable( aIter->second );
+            tools::stor::commitStorageIfWriteable( exposedStorage.second );
         }
     }
     catch(const WrappedTargetException&)
@@ -502,22 +492,23 @@ namespace
     {
         bool bSomeDocHasMacros = false;
 
-        for (   ODefinitionContainer_Impl::const_iterator object = _rObjectDefinitions.begin();
-                ( object != _rObjectDefinitions.end() ) && !bSomeDocHasMacros;
-                ++object
-            )
+        for (auto const& objectDefinition : _rObjectDefinitions)
         {
-            const TContentPtr& rDefinition( object->second );
+            const TContentPtr& rDefinition( objectDefinition.second );
             const OUString& rPersistentName( rDefinition->m_aProps.sPersistentName );
 
             if ( rPersistentName.isEmpty() )
             {   // it's a logical sub folder used to organize the real objects
                 const ODefinitionContainer_Impl& rSubFoldersObjectDefinitions( dynamic_cast< const ODefinitionContainer_Impl& >( *rDefinition.get() ) );
                 bSomeDocHasMacros = lcl_hasObjectWithMacros_throw( rSubFoldersObjectDefinitions, _rxContainerStorage );
+                if (bSomeDocHasMacros)
+                    break;
                 continue;
             }
 
             bSomeDocHasMacros = ODatabaseModelImpl::objectHasMacros( _rxContainerStorage, rPersistentName );
+            if (bSomeDocHasMacros)
+                break;
         }
         return bSomeDocHasMacros;
     }
@@ -627,10 +618,9 @@ void ODatabaseModelImpl::clearConnections()
     aConnections.swap( m_aConnections );
 
     Reference< XConnection > xConn;
-    OWeakConnectionArray::const_iterator aEnd = aConnections.end();
-    for ( OWeakConnectionArray::const_iterator i = aConnections.begin(); aEnd != i; ++i )
+    for (auto const& connection : aConnections)
     {
-        xConn = *i;
+        xConn = connection;
         if ( xConn.is() )
         {
             try
@@ -666,12 +656,10 @@ void ODatabaseModelImpl::dispose()
     m_xDataSource = WeakReference<XDataSource>();
     m_xModel = WeakReference< XModel >();
 
-    std::vector<TContentPtr>::const_iterator aIter = m_aContainer.begin();
-    std::vector<TContentPtr>::const_iterator aEnd = m_aContainer.end();
-    for (;aIter != aEnd ; ++aIter)
+    for (auto const& elem : m_aContainer)
     {
-        if ( aIter->get() )
-            (*aIter)->m_pDataSource = nullptr;
+        if ( elem.get() )
+            elem->m_pDataSource = nullptr;
     }
     m_aContainer.clear();
 


More information about the Libreoffice-commits mailing list