[Libreoffice-commits] core.git: basegfx/source basic/qa basic/source

Julien Nabet serval2412 at yahoo.fr
Sat Feb 24 16:29:04 UTC 2018


 basegfx/source/polygon/b2dpolygon.cxx             |    7 ---
 basegfx/source/polygon/b2dpolygontriangulator.cxx |    6 --
 basegfx/source/polygon/b3dpolygon.cxx             |   19 ++-------
 basic/qa/cppunit/basic_coverage.cxx               |    9 +---
 basic/source/basmgr/basicmanagerrepository.cxx    |    7 ---
 basic/source/classes/codecompletecache.cxx        |   46 +++++++++++-----------
 basic/source/classes/sb.cxx                       |   10 +---
 basic/source/classes/sbunoobj.cxx                 |   22 ++++------
 basic/source/classes/sbxmod.cxx                   |    8 ++-
 basic/source/runtime/dllmgr-x64.cxx               |   10 +---
 basic/source/sbx/sbxarray.cxx                     |   16 +++----
 11 files changed, 70 insertions(+), 90 deletions(-)

New commits:
commit 3ceb01afc3e5f47930e24fb0b21e6e85b86f660e
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Sat Feb 24 16:27:42 2018 +0100

    Use for range loops in basegfx and basic
    
    Change-Id: I5b2086c245695aeb30630150b3c5ccf61fbd6a56
    Reviewed-on: https://gerrit.libreoffice.org/50280
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>

diff --git a/basegfx/source/polygon/b2dpolygon.cxx b/basegfx/source/polygon/b2dpolygon.cxx
index 601f493c27b4..1a4d4a76da0c 100644
--- a/basegfx/source/polygon/b2dpolygon.cxx
+++ b/basegfx/source/polygon/b2dpolygon.cxx
@@ -186,12 +186,9 @@ public:
 
     void transform(const basegfx::B2DHomMatrix& rMatrix)
     {
-        CoordinateData2DVector::iterator aStart(maVector.begin());
-        CoordinateData2DVector::iterator aEnd(maVector.end());
-
-        for(; aStart != aEnd; ++aStart)
+        for (auto & elem : maVector)
         {
-            aStart->transform(rMatrix);
+            elem.transform(rMatrix);
         }
     }
 };
diff --git a/basegfx/source/polygon/b2dpolygontriangulator.cxx b/basegfx/source/polygon/b2dpolygontriangulator.cxx
index ed36a83b9a39..a2c740f91798 100644
--- a/basegfx/source/polygon/b2dpolygontriangulator.cxx
+++ b/basegfx/source/polygon/b2dpolygontriangulator.cxx
@@ -367,11 +367,9 @@ namespace basegfx
 
         Triangulator::~Triangulator()
         {
-            EdgeEntryPointers::iterator aIter(maNewEdgeEntries.begin());
-
-            while(aIter != maNewEdgeEntries.end())
+            for (auto const& newEdgeEntry : maNewEdgeEntries)
             {
-                delete *aIter++;
+                delete newEdgeEntry;
             }
         }
 
diff --git a/basegfx/source/polygon/b3dpolygon.cxx b/basegfx/source/polygon/b3dpolygon.cxx
index 0a78614f4320..fc0ef2c23f22 100644
--- a/basegfx/source/polygon/b3dpolygon.cxx
+++ b/basegfx/source/polygon/b3dpolygon.cxx
@@ -226,12 +226,9 @@ public:
 
     void transform(const ::basegfx::B3DHomMatrix& rMatrix)
     {
-        CoordinateData3DVector::iterator aStart(maVector.begin());
-        CoordinateData3DVector::iterator aEnd(maVector.end());
-
-        for(; aStart != aEnd; ++aStart)
+        for (auto & elem : maVector)
         {
-            aStart->transform(rMatrix);
+            elem.transform(rMatrix);
         }
     }
 };
@@ -532,11 +529,9 @@ public:
 
     void transform(const basegfx::B3DHomMatrix& rMatrix)
     {
-        const NormalsData3DVector::const_iterator aEnd(maVector.end());
-
-        for(NormalsData3DVector::iterator aStart(maVector.begin()); aStart != aEnd; ++aStart)
+        for (auto & elem : maVector)
         {
-            (*aStart) *= rMatrix;
+            elem *= rMatrix;
         }
     }
 };
@@ -689,11 +684,9 @@ public:
 
     void transform(const ::basegfx::B2DHomMatrix& rMatrix)
     {
-        const TextureData2DVector::const_iterator aEnd(maVector.end());
-
-        for(TextureData2DVector::iterator aStart(maVector.begin()); aStart != aEnd; ++aStart)
+        for (auto & elem : maVector)
         {
-            (*aStart) *= rMatrix;
+            elem *= rMatrix;
         }
     }
 };
diff --git a/basic/qa/cppunit/basic_coverage.cxx b/basic/qa/cppunit/basic_coverage.cxx
index 1831eb71d1e3..d78d322addbd 100644
--- a/basic/qa/cppunit/basic_coverage.cxx
+++ b/basic/qa/cppunit/basic_coverage.cxx
@@ -138,20 +138,19 @@ void Coverage::Coverage_Iterator()
     process_directory(sDirName); // any files in the root test dir are run in test harness default locale ( en-US )
     std::vector< OUString > sLangDirs = get_subdirnames( sDirName );
 
-    for ( std::vector< OUString >::iterator it = sLangDirs.begin(), it_end = sLangDirs.end(); it != it_end; ++it )
+    for (auto const& langDir : sLangDirs)
     {
-        OUString sDir( *it );
-        sal_Int32 nSlash = (*it).lastIndexOf('/');
+        sal_Int32 nSlash = langDir.lastIndexOf('/');
         if ( nSlash != -1 )
         {
-            OUString sLangISO = sDir.copy( nSlash + 1 );
+            OUString sLangISO = langDir.copy( nSlash + 1 );
             LanguageTag aLocale( sLangISO );
             if ( aLocale.isValidBcp47() )
             {
                 SvtSysLocaleOptions aLocalOptions;
                 // set locale for test dir
                 aLocalOptions.SetLocaleConfigString( sLangISO );
-                process_directory(sDir);
+                process_directory(langDir);
             }
         }
     }
diff --git a/basic/source/basmgr/basicmanagerrepository.cxx b/basic/source/basmgr/basicmanagerrepository.cxx
index 7140cf748a28..fc0d29855968 100644
--- a/basic/source/basmgr/basicmanagerrepository.cxx
+++ b/basic/source/basmgr/basicmanagerrepository.cxx
@@ -348,12 +348,9 @@ namespace basic
 
     void ImplRepository::impl_notifyCreationListeners( const Reference< XModel >& _rxDocumentModel, BasicManager& _rManager )
     {
-        for (   CreationListeners::const_iterator loop = m_aCreationListeners.begin();
-                loop != m_aCreationListeners.end();
-                ++loop
-            )
+        for (auto const& creationListener : m_aCreationListeners)
         {
-            (*loop)->onBasicManagerCreated( _rxDocumentModel, _rManager );
+            creationListener->onBasicManagerCreated( _rxDocumentModel, _rManager );
         }
     }
 
diff --git a/basic/source/classes/codecompletecache.cxx b/basic/source/classes/codecompletecache.cxx
index 445132401574..7c54a66e964f 100644
--- a/basic/source/classes/codecompletecache.cxx
+++ b/basic/source/classes/codecompletecache.cxx
@@ -100,18 +100,18 @@ void CodeCompleteOptions::SetAutoCorrectOn( bool b )
 std::ostream& operator<< (std::ostream& aStream, const CodeCompleteDataCache& aCache)
 {
     aStream << "Global variables" << std::endl;
-    for(CodeCompleteVarTypes::const_iterator aIt = aCache.aGlobalVars.begin(); aIt != aCache.aGlobalVars.end(); ++aIt )
+    for (auto const& globalVar : aCache.aGlobalVars)
     {
-        aStream << aIt->first << "," << aIt->second << std::endl;
+        aStream << globalVar.first << "," << globalVar.second << std::endl;
     }
     aStream << "Local variables" << std::endl;
-    for( CodeCompleteVarScopes::const_iterator aIt = aCache.aVarScopes.begin(); aIt != aCache.aVarScopes.end(); ++aIt )
+    for (auto const& varScope : aCache.aVarScopes)
     {
-        aStream << aIt->first << std::endl;
-        CodeCompleteVarTypes aVarTypes = aIt->second;
-        for( CodeCompleteVarTypes::const_iterator aOtherIt = aVarTypes.begin(); aOtherIt != aVarTypes.end(); ++aOtherIt )
+        aStream << varScope.first << std::endl;
+        CodeCompleteVarTypes aVarTypes = varScope.second;
+        for (auto const& varType : aVarTypes)
         {
-            aStream << "\t" << aOtherIt->first << "," << aOtherIt->second << std::endl;
+            aStream << "\t" << varType.first << "," << varType.second << std::endl;
         }
     }
     aStream << "-----------------" << std::endl;
@@ -148,44 +148,44 @@ void CodeCompleteDataCache::InsertLocalVar( const OUString& sProcName, const OUS
 
 OUString CodeCompleteDataCache::GetVarType( const OUString& sVarName ) const
 {
-    for( CodeCompleteVarScopes::const_iterator aIt = aVarScopes.begin(); aIt != aVarScopes.end(); ++aIt )
+    for (auto const& varScope : aVarScopes)
     {
-        CodeCompleteVarTypes aTypes = aIt->second;
-        for( CodeCompleteVarTypes::const_iterator aOtherIt = aTypes.begin(); aOtherIt != aTypes.end(); ++aOtherIt )
+        CodeCompleteVarTypes aTypes = varScope.second;
+        for (auto const& elem : aTypes)
         {
-            if( aOtherIt->first.equalsIgnoreAsciiCase( sVarName ) )
+            if( elem.first.equalsIgnoreAsciiCase( sVarName ) )
             {
-                return aOtherIt->second;
+                return elem.second;
             }
         }
     }
     //not a local, search global scope
-    for( CodeCompleteVarTypes::const_iterator aIt = aGlobalVars.begin(); aIt != aGlobalVars.end(); ++aIt )
+    for (auto const& globalVar : aGlobalVars)
     {
-        if( aIt->first.equalsIgnoreAsciiCase( sVarName ) )
-            return aIt->second;
+        if( globalVar.first.equalsIgnoreAsciiCase( sVarName ) )
+            return globalVar.second;
     }
     return OUString(); //not found
 }
 
 OUString CodeCompleteDataCache::GetCorrectCaseVarName( const OUString& sVarName, const OUString& sActProcName ) const
 {
-    for( CodeCompleteVarScopes::const_iterator aIt = aVarScopes.begin(); aIt != aVarScopes.end(); ++aIt )
+    for (auto const& varScope : aVarScopes)
     {
-        CodeCompleteVarTypes aTypes = aIt->second;
-        for( CodeCompleteVarTypes::const_iterator aOtherIt = aTypes.begin(); aOtherIt != aTypes.end(); ++aOtherIt )
+        CodeCompleteVarTypes aTypes = varScope.second;
+        for (auto const& elem : aTypes)
         {
-            if( aOtherIt->first.equalsIgnoreAsciiCase( sVarName ) && aIt->first.equalsIgnoreAsciiCase( sActProcName ) )
+            if( elem.first.equalsIgnoreAsciiCase( sVarName ) && varScope.first.equalsIgnoreAsciiCase( sActProcName ) )
             {
-                return aOtherIt->first;
+                return elem.first;
             }
         }
     }
     // search global scope
-    for( CodeCompleteVarTypes::const_iterator aIt = aGlobalVars.begin(); aIt != aGlobalVars.end(); ++aIt )
+    for (auto const& globalVar : aGlobalVars)
     {
-        if( aIt->first.equalsIgnoreAsciiCase( sVarName ) )
-            return aIt->first;
+        if( globalVar.first.equalsIgnoreAsciiCase( sVarName ) )
+            return globalVar.first;
     }
     return OUString(); //not found
 }
diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx
index 132ea5d49415..c418776fa764 100644
--- a/basic/source/classes/sb.cxx
+++ b/basic/source/classes/sb.cxx
@@ -1204,10 +1204,9 @@ void StarBASIC::InitAllModules( StarBASIC const * pBasicNotToInit )
         }
     }
 
-    ModuleInitDependencyMap::iterator it;
-    for( it = aMIDMap.begin() ; it != aMIDMap.end(); ++it )
+    for (auto & elem : aMIDMap)
     {
-        ClassModuleRunInitItem& rItem = it->second;
+        ClassModuleRunInitItem& rItem = elem.second;
         SbModule::implProcessModuleRunInit( aMIDMap, rItem );
     }
 
@@ -1936,10 +1935,9 @@ Reference< frame::XModel > StarBASIC::GetModelFromBasic( SbxObject* pBasic )
 void StarBASIC::DetachAllDocBasicItems()
 {
     std::unordered_map< const StarBASIC *, DocBasicItemRef >& rItems = GaDocBasicItems::get();
-    auto it = rItems.begin(), itEnd = rItems.end();
-    for (; it != itEnd; ++it)
+    for (auto const& item : rItems)
     {
-        DocBasicItemRef xItem = it->second;
+        DocBasicItemRef xItem = item.second;
         xItem->setDisposed(true);
     }
 }
diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx
index 034ee01d0bba..ac4b8d4b3ea9 100644
--- a/basic/source/classes/sbunoobj.cxx
+++ b/basic/source/classes/sbunoobj.cxx
@@ -3257,11 +3257,10 @@ VBAConstantHelper::isVBAConstantType( const OUString& rName )
 {
     init();
     bool bConstant = false;
-    VBAConstantsVector::const_iterator it = aConstCache.begin();
 
-    for( ; it != aConstCache.end(); ++it )
+    for (auto const& elem : aConstCache)
     {
-        if( rName.equalsIgnoreAsciiCase( *it ) )
+        if( rName.equalsIgnoreAsciiCase(elem) )
         {
             bConstant = true;
             break;
@@ -4471,10 +4470,9 @@ void disposeComVariablesForBasic( StarBASIC const * pBasic )
         }
 
         ComponentRefVector& rv = pItem->m_vComImplementsObjects;
-        ComponentRefVector::iterator itCRV;
-        for( itCRV = rv.begin() ; itCRV != rv.end() ; ++itCRV )
+        for (auto const& elem : rv)
         {
-            Reference< XComponent > xComponent( (*itCRV).get(), UNO_QUERY );
+            Reference< XComponent > xComponent( elem.get(), UNO_QUERY );
             if (xComponent.is())
                 xComponent->dispose();
         }
@@ -4639,8 +4637,8 @@ SbUnoStructRefObject::SbUnoStructRefObject( const OUString& aName_, const Struct
 
 SbUnoStructRefObject::~SbUnoStructRefObject()
 {
-    for ( StructFieldInfo::iterator it = maFields.begin(), it_end = maFields.end(); it != it_end; ++it )
-        delete it->second;
+    for (auto const& field : maFields)
+        delete field.second;
 }
 
 void SbUnoStructRefObject::initMemberCache()
@@ -4736,15 +4734,15 @@ void SbUnoStructRefObject::implCreateAll()
     if (!mbMemberCacheInit)
         initMemberCache();
 
-    for ( StructFieldInfo::iterator it = maFields.begin(), it_end = maFields.end(); it != it_end; ++it )
+    for (auto const& field : maFields)
     {
-        const OUString& rName = it->first;
+        const OUString& rName = field.first;
         SbxDataType eSbxType;
-        eSbxType = unoToSbxType( it->second->getTypeClass() );
+        eSbxType = unoToSbxType( field.second->getTypeClass() );
         SbxDataType eRealSbxType = eSbxType;
         Property aProp;
         aProp.Name = rName;
-        aProp.Type = css::uno::Type( it->second->getTypeClass(), it->second->getTypeName() );
+        aProp.Type = css::uno::Type( field.second->getTypeClass(), field.second->getTypeName() );
         SbUnoProperty* pProp = new SbUnoProperty( rName, eSbxType, eRealSbxType, aProp, 0, false, ( aProp.Type.getTypeClass() == css::uno::TypeClass_STRUCT) );
         SbxVariableRef xVarRef = pProp;
         QuickInsert( xVarRef.get() );
diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx
index 8c2edf1c8912..09f23f3e0e99 100644
--- a/basic/source/classes/sbxmod.cxx
+++ b/basic/source/classes/sbxmod.cxx
@@ -276,10 +276,12 @@ DocObjectWrapper::invoke( const OUString& aFunctionName, const Sequence< Any >&
             aOutParam.realloc( nOutParamCount );
             sal_Int16* pOutParamIndex = aOutParamIndex.getArray();
             Any* pOutParam = aOutParam.getArray();
-            for ( OutParamMap::iterator aIt = aOutParamMap.begin(); aIt != aOutParamMap.end(); ++aIt, ++pOutParamIndex, ++pOutParam )
+            for (auto const& outParam : aOutParamMap)
             {
-                *pOutParamIndex = aIt->first;
-                *pOutParam = aIt->second;
+                *pOutParamIndex = outParam.first;
+                *pOutParam = outParam.second;
+                ++pOutParamIndex;
+                ++pOutParam;
             }
         }
     }
diff --git a/basic/source/runtime/dllmgr-x64.cxx b/basic/source/runtime/dllmgr-x64.cxx
index 10a05ef9463f..bb47a0d96aeb 100644
--- a/basic/source/runtime/dllmgr-x64.cxx
+++ b/basic/source/runtime/dllmgr-x64.cxx
@@ -603,15 +603,13 @@ ErrCode call(
         arguments->Get(i)->ResetFlag(SbxFlagBits::Reference);
             //TODO: skipped for errors?!?
     }
-    for (std::vector< UnmarshalData >::iterator i(data.unmarshal.begin());
-         i != data.unmarshal.end(); ++i)
+    for (auto const& elem : data.unmarshal)
     {
-        unmarshal(i->variable, i->buffer);
+        unmarshal(elem.variable, elem.buffer);
     }
-    for (std::vector< StringData >::iterator i(data.unmarshalStrings.begin());
-         i != data.unmarshalStrings.end(); ++i)
+    for (auto const& unmarshalString : data.unmarshalStrings)
     {
-        ErrCode e = unmarshalString(*i, result);
+        ErrCode e = unmarshalString(unmarshalString, result);
         if (e != ERRCODE_NONE) {
             return e;
         }
diff --git a/basic/source/sbx/sbxarray.cxx b/basic/source/sbx/sbxarray.cxx
index 8d3c5515cc8a..ace9c6c139f8 100644
--- a/basic/source/sbx/sbxarray.cxx
+++ b/basic/source/sbx/sbxarray.cxx
@@ -646,16 +646,15 @@ sal_uInt32 SbxDimArray::Offset32( const sal_Int32* pIdx )
 sal_uInt16 SbxDimArray::Offset( const short* pIdx )
 {
     long nPos = 0;
-    for( std::vector<SbxDim>::const_iterator it = m_vDimensions.begin();
-         it != m_vDimensions.end(); ++it )
+    for (auto const& vDimension : m_vDimensions)
     {
         short nIdx = *pIdx++;
-        if( nIdx < it->nLbound || nIdx > it->nUbound )
+        if( nIdx < vDimension.nLbound || nIdx > vDimension.nUbound )
         {
             nPos = SBX_MAXINDEX + 1;
             break;
         }
-        nPos = nPos * it->nSize + nIdx - it->nLbound;
+        nPos = nPos * vDimension.nSize + nIdx - vDimension.nLbound;
     }
     if( m_vDimensions.empty() || nPos > SBX_MAXINDEX )
     {
@@ -699,16 +698,17 @@ sal_uInt32 SbxDimArray::Offset32( SbxArray* pPar )
 #endif
     sal_uInt32 nPos = 0;
     sal_uInt16 nOff = 1;    // Non element 0!
-    for( std::vector<SbxDim>::const_iterator it = m_vDimensions.begin();
-         it != m_vDimensions.end() && !IsError(); ++it )
+    for (auto const& vDimension : m_vDimensions)
     {
         sal_Int32 nIdx = pPar->Get( nOff++ )->GetLong();
-        if( nIdx < it->nLbound || nIdx > it->nUbound )
+        if( nIdx < vDimension.nLbound || nIdx > vDimension.nUbound )
         {
             nPos = sal_uInt32(SBX_MAXINDEX32)+1;
             break;
         }
-        nPos = nPos * it->nSize + nIdx - it->nLbound;
+        nPos = nPos * vDimension.nSize + nIdx - vDimension.nLbound;
+        if (IsError())
+            break;
     }
     if( nPos > sal_uInt32(SBX_MAXINDEX32) )
     {


More information about the Libreoffice-commits mailing list