diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2018-02-24 16:27:42 +0100 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2018-02-24 17:28:43 +0100 |
commit | 3ceb01afc3e5f47930e24fb0b21e6e85b86f660e (patch) | |
tree | b0f28ccf328460ae5f189d6855f55f9815dce39a /basic/source | |
parent | 85643ad3b66ee057a6d620d6284a2b1b19de8dc8 (diff) |
Use for range loops in basegfx and basic
Change-Id: I5b2086c245695aeb30630150b3c5ccf61fbd6a56
Reviewed-on: https://gerrit.libreoffice.org/50280
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'basic/source')
-rw-r--r-- | basic/source/basmgr/basicmanagerrepository.cxx | 7 | ||||
-rw-r--r-- | basic/source/classes/codecompletecache.cxx | 46 | ||||
-rw-r--r-- | basic/source/classes/sb.cxx | 10 | ||||
-rw-r--r-- | basic/source/classes/sbunoobj.cxx | 22 | ||||
-rw-r--r-- | basic/source/classes/sbxmod.cxx | 8 | ||||
-rw-r--r-- | basic/source/runtime/dllmgr-x64.cxx | 10 | ||||
-rw-r--r-- | basic/source/sbx/sbxarray.cxx | 16 |
7 files changed, 56 insertions, 63 deletions
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) ) { |