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
{
// 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;
......
......@@ -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() )
......
......@@ -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);
}
......
......@@ -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 );
}
......
......@@ -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;
}
}
......
......@@ -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 )
{
......
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