summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorArnaud Versini <arnaud.versini@gmail.com>2015-12-06 14:29:18 +0100
committerArnaud Versini <arnaud.versini@libreoffice.org>2015-12-13 15:57:42 +0000
commit4df183e2c9c548ecdd6f3421d9ef043194aa0981 (patch)
tree73d1389ba1de313648325fe300b9f428bc5b1413 /basic
parentfdf122378d5dfa7160fa29eace026424b125e3e4 (diff)
BASIC: use c++ foreach loops when possible.
Change-Id: Ia1c734e26da88010eef40a4375c423b0765f43ae Reviewed-on: https://gerrit.libreoffice.org/20423 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Arnaud Versini <arnaud.versini@libreoffice.org>
Diffstat (limited to 'basic')
-rw-r--r--basic/source/basmgr/basicmanagerrepository.cxx4
-rw-r--r--basic/source/classes/sb.cxx4
-rw-r--r--basic/source/classes/sbxmod.cxx10
-rw-r--r--basic/source/comp/exprgen.cxx5
-rw-r--r--basic/source/comp/exprnode.cxx5
-rw-r--r--basic/source/sbx/sbxarray.cxx19
6 files changed, 18 insertions, 29 deletions
diff --git a/basic/source/basmgr/basicmanagerrepository.cxx b/basic/source/basmgr/basicmanagerrepository.cxx
index 1b3ca26af456..de559e99c94b 100644
--- a/basic/source/basmgr/basicmanagerrepository.cxx
+++ b/basic/source/basmgr/basicmanagerrepository.cxx
@@ -427,10 +427,10 @@ namespace basic
{
// handle errors
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
- if ( ERRCODE_BUTTON_CANCEL == ErrorHandler::HandleError( i->GetErrorId() ) )
+ if ( ERRCODE_BUTTON_CANCEL == ErrorHandler::HandleError( rError.GetErrorId() ) )
{
// user wants to break loading of BASIC-manager
delete _out_rpBasicManager;
diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx
index bfdfcef8c1e4..a59da1ee26e6 100644
--- a/basic/source/classes/sb.cxx
+++ b/basic/source/classes/sb.cxx
@@ -1199,10 +1199,8 @@ void SbModule::implProcessModuleRunInit( ModuleInitDependencyMap& rMap, ClassMod
StringVector& rReqTypes = pModule->pClassData->maRequiredTypes;
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?
ModuleInitDependencyMap::iterator itFind = rMap.find( rStr );
if( itFind != rMap.end() )
diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx
index 0730273c8520..73428af604b2 100644
--- a/basic/source/classes/sbxmod.cxx
+++ b/basic/source/classes/sbxmod.cxx
@@ -1293,10 +1293,9 @@ void SbModule::RunInit()
void SbModule::AddVarName( const OUString& aName )
{
// see if the name is added already
- std::vector< OUString >::iterator it_end = mModuleVariableNames.end();
- for ( std::vector< OUString >::iterator it = mModuleVariableNames.begin(); it != it_end; ++it )
+ for ( const auto& rModuleVariableName: mModuleVariableNames )
{
- if ( aName == *it )
+ if ( aName == rModuleVariableName )
return;
}
mModuleVariableNames.push_back( aName );
@@ -1304,13 +1303,12 @@ void SbModule::AddVarName( const OUString& aName )
void SbModule::RemoveVars()
{
- std::vector< OUString >::iterator it_end = mModuleVariableNames.end();
- for ( std::vector< OUString >::iterator it = mModuleVariableNames.begin(); it != it_end; ++it )
+ for ( const auto& rModuleVariableName: mModuleVariableNames )
{
// We don't want a Find being called in a derived class ( e.g.
// 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 )
- SbxVariableRef p = SbModule::Find( *it, SbxCLASS_PROPERTY );
+ SbxVariableRef p = SbModule::Find( rModuleVariableName, SbxCLASS_PROPERTY );
if( p.Is() )
Remove (p);
}
diff --git a/basic/source/comp/exprgen.cxx b/basic/source/comp/exprgen.cxx
index c1c74a0b2121..ce6ff9363174 100644
--- a/basic/source/comp/exprgen.cxx
+++ b/basic/source/comp/exprgen.cxx
@@ -191,11 +191,8 @@ void SbiExprNode::GenElement( SbiCodeGen& rGen, SbiOpcode eOp )
if( aVar.pvMorePar )
{
- SbiExprListVector* pvMorePar = aVar.pvMorePar;
- SbiExprListVector::iterator it;
- for( it = pvMorePar->begin() ; it != pvMorePar->end() ; ++it )
+ for( auto& pExprList: *aVar.pvMorePar )
{
- SbiExprList* pExprList = *it;
pExprList->Gen();
rGen.Gen( _ARRAYACCESS );
}
diff --git a/basic/source/comp/exprnode.cxx b/basic/source/comp/exprnode.cxx
index 3bd9693e58b0..52c2211fcfa3 100644
--- a/basic/source/comp/exprnode.cxx
+++ b/basic/source/comp/exprnode.cxx
@@ -111,9 +111,8 @@ SbiExprNode::~SbiExprNode()
SbiExprListVector* pvMorePar = aVar.pvMorePar;
if( pvMorePar )
{
- SbiExprListVector::iterator it;
- for( it = pvMorePar->begin() ; it != pvMorePar->end() ; ++it )
- delete *it;
+ for( const auto& pParam : *pvMorePar )
+ delete pParam;
delete pvMorePar;
}
}
diff --git a/basic/source/sbx/sbxarray.cxx b/basic/source/sbx/sbxarray.cxx
index ab44f577178d..2020485f4000 100644
--- a/basic/source/sbx/sbxarray.cxx
+++ b/basic/source/sbx/sbxarray.cxx
@@ -60,18 +60,16 @@ SbxArray& SbxArray::operator=( const SbxArray& rArray )
{
eType = rArray.eType;
Clear();
- VarEntriesType* pSrc = rArray.mpVarEntries;
- for( size_t i = 0; i < pSrc->size(); i++ )
+ for( const auto& rpSrcRef : *rArray.mpVarEntries )
{
- SbxVarEntry* pSrcRef = (*pSrc)[i];
- SbxVariableRef pSrc_ = pSrcRef->mpVar;
+ SbxVariableRef pSrc_ = rpSrcRef->mpVar;
if( !pSrc_ )
continue;
SbxVarEntry* pDstRef = new SbxVarEntry;
- pDstRef->mpVar = pSrcRef->mpVar;
+ pDstRef->mpVar = rpSrcRef->mpVar;
- if (pSrcRef->maAlias)
- pDstRef->maAlias.reset(*pSrcRef->maAlias);
+ if (rpSrcRef->maAlias)
+ pDstRef->maAlias.reset(*rpSrcRef->maAlias);
if( eType != SbxVARIANT )
{
@@ -666,15 +664,14 @@ bool SbxDimArray::GetDim( short n, short& rlb, short& rub ) const
sal_uInt32 SbxDimArray::Offset32( const sal_Int32* pIdx )
{
sal_uInt32 nPos = 0;
- for( std::vector<SbxDim>::const_iterator it = m_vDimensions.begin();
- it != m_vDimensions.end(); ++it )
+ for( const auto& rDimension : m_vDimensions )
{
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 = nPos * it->nSize + nIdx - it->nLbound;
+ nPos = nPos * rDimension.nSize + nIdx - rDimension.nLbound;
}
if( m_vDimensions.empty() || nPos > SBX_MAXINDEX32 )
{