Kaydet (Commit) 3ceb01af authored tarafından Julien Nabet's avatar Julien Nabet

Use for range loops in basegfx and basic

Change-Id: I5b2086c245695aeb30630150b3c5ccf61fbd6a56
Reviewed-on: https://gerrit.libreoffice.org/50280Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJulien Nabet <serval2412@yahoo.fr>
üst 85643ad3
......@@ -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);
}
}
};
......
......@@ -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;
}
}
......
......@@ -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;
}
}
};
......
......@@ -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);
}
}
}
......
......@@ -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 );
}
}
......
......@@ -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
}
......
......@@ -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);
}
}
......
......@@ -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() );
......
......@@ -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;
}
}
}
......
......@@ -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;
}
......
......@@ -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) )
{
......
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