Kaydet (Commit) 4df183e2 authored tarafından Arnaud Versini's avatar Arnaud Versini Kaydeden (comit) Arnaud Versini

BASIC: use c++ foreach loops when possible.

Change-Id: Ia1c734e26da88010eef40a4375c423b0765f43ae
Reviewed-on: https://gerrit.libreoffice.org/20423Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarArnaud Versini <arnaud.versini@libreoffice.org>
üst fdf12237
...@@ -427,10 +427,10 @@ namespace basic ...@@ -427,10 +427,10 @@ namespace basic
{ {
// handle errors // handle errors
std::vector<BasicError>& aErrors = _out_rpBasicManager->GetErrors(); std::vector<BasicError>& aErrors = _out_rpBasicManager->GetErrors();
for(std::vector<BasicError>::const_iterator i = aErrors.begin(); i != aErrors.end(); ++i) for(const auto& rError : aErrors)
{ {
// show message to user // show message to user
if ( ERRCODE_BUTTON_CANCEL == ErrorHandler::HandleError( i->GetErrorId() ) ) if ( ERRCODE_BUTTON_CANCEL == ErrorHandler::HandleError( rError.GetErrorId() ) )
{ {
// user wants to break loading of BASIC-manager // user wants to break loading of BASIC-manager
delete _out_rpBasicManager; delete _out_rpBasicManager;
......
...@@ -1199,10 +1199,8 @@ void SbModule::implProcessModuleRunInit( ModuleInitDependencyMap& rMap, ClassMod ...@@ -1199,10 +1199,8 @@ void SbModule::implProcessModuleRunInit( ModuleInitDependencyMap& rMap, ClassMod
StringVector& rReqTypes = pModule->pClassData->maRequiredTypes; StringVector& rReqTypes = pModule->pClassData->maRequiredTypes;
if( rReqTypes.size() > 0 ) if( rReqTypes.size() > 0 )
{ {
for( StringVector::iterator it = rReqTypes.begin() ; it != rReqTypes.end() ; ++it ) for( const auto& rStr : rReqTypes )
{ {
OUString& rStr = *it;
// Is required type a class module? // Is required type a class module?
ModuleInitDependencyMap::iterator itFind = rMap.find( rStr ); ModuleInitDependencyMap::iterator itFind = rMap.find( rStr );
if( itFind != rMap.end() ) if( itFind != rMap.end() )
......
...@@ -1293,10 +1293,9 @@ void SbModule::RunInit() ...@@ -1293,10 +1293,9 @@ void SbModule::RunInit()
void SbModule::AddVarName( const OUString& aName ) void SbModule::AddVarName( const OUString& aName )
{ {
// see if the name is added already // see if the name is added already
std::vector< OUString >::iterator it_end = mModuleVariableNames.end(); for ( const auto& rModuleVariableName: mModuleVariableNames )
for ( std::vector< OUString >::iterator it = mModuleVariableNames.begin(); it != it_end; ++it )
{ {
if ( aName == *it ) if ( aName == rModuleVariableName )
return; return;
} }
mModuleVariableNames.push_back( aName ); mModuleVariableNames.push_back( aName );
...@@ -1304,13 +1303,12 @@ void SbModule::AddVarName( const OUString& aName ) ...@@ -1304,13 +1303,12 @@ void SbModule::AddVarName( const OUString& aName )
void SbModule::RemoveVars() void SbModule::RemoveVars()
{ {
std::vector< OUString >::iterator it_end = mModuleVariableNames.end(); for ( const auto& rModuleVariableName: mModuleVariableNames )
for ( std::vector< OUString >::iterator it = mModuleVariableNames.begin(); it != it_end; ++it )
{ {
// We don't want a Find being called in a derived class ( e.g. // We don't want a Find being called in a derived class ( e.g.
// SbUserform because it could trigger say an initialise event // SbUserform because it could trigger say an initialise event
// which would cause basic to be re-run in the middle of the init ( and remember RemoveVars is called from compile and we don't want code to run as part of the compile ) // which would cause basic to be re-run in the middle of the init ( and remember RemoveVars is called from compile and we don't want code to run as part of the compile )
SbxVariableRef p = SbModule::Find( *it, SbxCLASS_PROPERTY ); SbxVariableRef p = SbModule::Find( rModuleVariableName, SbxCLASS_PROPERTY );
if( p.Is() ) if( p.Is() )
Remove (p); Remove (p);
} }
......
...@@ -191,11 +191,8 @@ void SbiExprNode::GenElement( SbiCodeGen& rGen, SbiOpcode eOp ) ...@@ -191,11 +191,8 @@ void SbiExprNode::GenElement( SbiCodeGen& rGen, SbiOpcode eOp )
if( aVar.pvMorePar ) if( aVar.pvMorePar )
{ {
SbiExprListVector* pvMorePar = aVar.pvMorePar; for( auto& pExprList: *aVar.pvMorePar )
SbiExprListVector::iterator it;
for( it = pvMorePar->begin() ; it != pvMorePar->end() ; ++it )
{ {
SbiExprList* pExprList = *it;
pExprList->Gen(); pExprList->Gen();
rGen.Gen( _ARRAYACCESS ); rGen.Gen( _ARRAYACCESS );
} }
......
...@@ -111,9 +111,8 @@ SbiExprNode::~SbiExprNode() ...@@ -111,9 +111,8 @@ SbiExprNode::~SbiExprNode()
SbiExprListVector* pvMorePar = aVar.pvMorePar; SbiExprListVector* pvMorePar = aVar.pvMorePar;
if( pvMorePar ) if( pvMorePar )
{ {
SbiExprListVector::iterator it; for( const auto& pParam : *pvMorePar )
for( it = pvMorePar->begin() ; it != pvMorePar->end() ; ++it ) delete pParam;
delete *it;
delete pvMorePar; delete pvMorePar;
} }
} }
......
...@@ -60,18 +60,16 @@ SbxArray& SbxArray::operator=( const SbxArray& rArray ) ...@@ -60,18 +60,16 @@ SbxArray& SbxArray::operator=( const SbxArray& rArray )
{ {
eType = rArray.eType; eType = rArray.eType;
Clear(); Clear();
VarEntriesType* pSrc = rArray.mpVarEntries; for( const auto& rpSrcRef : *rArray.mpVarEntries )
for( size_t i = 0; i < pSrc->size(); i++ )
{ {
SbxVarEntry* pSrcRef = (*pSrc)[i]; SbxVariableRef pSrc_ = rpSrcRef->mpVar;
SbxVariableRef pSrc_ = pSrcRef->mpVar;
if( !pSrc_ ) if( !pSrc_ )
continue; continue;
SbxVarEntry* pDstRef = new SbxVarEntry; SbxVarEntry* pDstRef = new SbxVarEntry;
pDstRef->mpVar = pSrcRef->mpVar; pDstRef->mpVar = rpSrcRef->mpVar;
if (pSrcRef->maAlias) if (rpSrcRef->maAlias)
pDstRef->maAlias.reset(*pSrcRef->maAlias); pDstRef->maAlias.reset(*rpSrcRef->maAlias);
if( eType != SbxVARIANT ) if( eType != SbxVARIANT )
{ {
...@@ -666,15 +664,14 @@ bool SbxDimArray::GetDim( short n, short& rlb, short& rub ) const ...@@ -666,15 +664,14 @@ bool SbxDimArray::GetDim( short n, short& rlb, short& rub ) const
sal_uInt32 SbxDimArray::Offset32( const sal_Int32* pIdx ) sal_uInt32 SbxDimArray::Offset32( const sal_Int32* pIdx )
{ {
sal_uInt32 nPos = 0; sal_uInt32 nPos = 0;
for( std::vector<SbxDim>::const_iterator it = m_vDimensions.begin(); for( const auto& rDimension : m_vDimensions )
it != m_vDimensions.end(); ++it )
{ {
sal_Int32 nIdx = *pIdx++; sal_Int32 nIdx = *pIdx++;
if( nIdx < it->nLbound || nIdx > it->nUbound ) if( nIdx < rDimension.nLbound || nIdx > rDimension.nUbound )
{ {
nPos = (sal_uInt32)SBX_MAXINDEX32 + 1; break; nPos = (sal_uInt32)SBX_MAXINDEX32 + 1; break;
} }
nPos = nPos * it->nSize + nIdx - it->nLbound; nPos = nPos * rDimension.nSize + nIdx - rDimension.nLbound;
} }
if( m_vDimensions.empty() || nPos > SBX_MAXINDEX32 ) if( m_vDimensions.empty() || nPos > SBX_MAXINDEX32 )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment