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

Use for-range loops in some modules

jvmaccess, jvmfwk, l10ntools, libreofficekit and linguistic

Change-Id: I9d290d1098b25ccb3aee19d2df18c18f4aa65105
Reviewed-on: https://gerrit.libreoffice.org/51495Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJulien Nabet <serval2412@yahoo.fr>
üst dd5df4cc
......@@ -93,9 +93,9 @@ jobjectArray jvmaccess::ClassPath::translateToUrls(
return nullptr;
}
jsize idx = 0;
for (std::vector< jobject >::iterator i(urls.begin()); i != urls.end(); ++i)
for (auto const& url : urls)
{
environment->SetObjectArrayElement(result, idx++, *i);
environment->SetObjectArrayElement(result, idx++, url);
}
return result;
}
......
......@@ -614,10 +614,9 @@ bool getJavaInfoFromRegistry(const wchar_t* szRegKey,
{
bool bAppend= true;
//iterate over the vector with java home strings
for(auto itHome= vecJavaHome.begin();
itHome != vecJavaHome.end(); ++itHome)
for (auto const& javaHome : vecJavaHome)
{
if(usHomeUrl.equals(*itHome))
if(usHomeUrl.equals(javaHome))
{
bAppend= false;
break;
......
......@@ -52,9 +52,9 @@
#if OSL_DEBUG_LEVEL > 2
void HelpParser::Dump(XMLHashMap* rElem_in)
{
for(XMLHashMap::iterator pos = rElem_in->begin();pos != rElem_in->end(); ++pos)
for (auto const& pos : *rElem_in)
{
Dump(pos->second,pos->first);
Dump(pos.second,pos.first);
}
}
......@@ -63,10 +63,10 @@ void HelpParser::Dump(LangHashMap* rElem_in,const OString & sKey_in)
OString x;
OString y;
fprintf(stdout,"+------------%s-----------+\n",sKey_in.getStr() );
for(LangHashMap::iterator posn=rElem_in->begin();posn!=rElem_in->end();++posn)
for (auto const& posn : *rElem_in)
{
x=posn->first;
y=posn->second->ToOString();
x=posn.first;
y=posn.second->ToOString();
fprintf(stdout,"key=%s value=%s\n",x.getStr(),y.getStr());
}
fprintf(stdout,"+--------------------------+\n");
......@@ -110,12 +110,10 @@ bool HelpParser::CreatePO(
XMLHashMap* aXMLStrHM = file->GetStrings();
std::vector<OString> order = file->getOrder();
std::vector<OString>::iterator pos;
XMLHashMap::iterator posm;
for( pos = order.begin(); pos != order.end() ; ++pos )
for (auto const& pos : order)
{
posm = aXMLStrHM->find( *pos );
auto posm = aXMLStrHM->find(pos);
LangHashMap* pElem = posm->second;
XMLElement* pXMLElement = (*pElem)[ "en-US" ];
......@@ -173,12 +171,10 @@ bool HelpParser::MergeSingleFile( XMLFile* file , MergeDataFile* pMergeDataFile
s_ResData.sResTyp = "help";
std::vector<OString> order = file->getOrder();
std::vector<OString>::iterator pos;
XMLHashMap::iterator posm;
for( pos = order.begin(); pos != order.end() ; ++pos ) // Merge every l10n related string in the same order as export
for (auto const& pos : order) // Merge every l10n related string in the same order as export
{
posm = aXMLStrHM->find( *pos );
auto posm = aXMLStrHM->find(pos);
LangHashMap* aLangHM = posm->second;
#if OSL_DEBUG_LEVEL > 2
printf("*********************DUMPING HASHMAP***************************************");
......
......@@ -84,12 +84,9 @@ int main(int argc, char *argv[])
outputStream << encoding << '\n' << entries.size() << '\n';
for (multimap<string, size_t>::const_iterator ii(entries.begin());
ii != entries.end();
++ii
)
for (auto const& entry : entries)
{
outputStream << ii->first << '|' << ii->second << '\n';
outputStream << entry.first << '|' << entry.second << '\n';
}
}
......
......@@ -247,8 +247,8 @@ void handleFilesOfDir(
///Handle files in lexical order
std::sort(aFiles.begin(), aFiles.end());
for( auto aIt = aFiles.begin(); aIt != aFiles.end(); ++aIt )
handleFile(rProject, *aIt, rPotDir);
for (auto const& elem : aFiles)
handleFile(rProject, elem, rPotDir);
}
bool includeProject(const OString& rProject) {
......
......@@ -296,8 +296,8 @@ MergeDataFile::MergeDataFile(
MergeDataFile::~MergeDataFile()
{
for (MergeDataHashMap::iterator aI = aMap.begin(), aEnd = aMap.end(); aI != aEnd; ++aI)
delete aI->second;
for (auto const& elem : aMap)
delete elem.second;
}
std::vector<OString> MergeDataFile::GetLanguages() const
......
......@@ -71,21 +71,21 @@ static void checkStyleNames(const OString& aLanguage)
}
aPoInput.close();
for( std::map<OString,sal_uInt16>::iterator it=aLocalizedStyleNames.begin(); it!=aLocalizedStyleNames.end(); ++it)
for (auto const& localizedStyleName : aLocalizedStyleNames)
{
if( it->second > 1 )
if( localizedStyleName.second > 1 )
{
std::cout << "ERROR: Style name translations must be unique in:\n" <<
aPoPath << "\nLanguage: " << aLanguage << "\nDuplicated translation is: " << it->first <<
aPoPath << "\nLanguage: " << aLanguage << "\nDuplicated translation is: " << localizedStyleName.first <<
"\nSee STR_POOLCOLL_*\n\n";
}
}
for( std::map<OString,sal_uInt16>::iterator it=aLocalizedNumStyleNames.begin(); it!=aLocalizedNumStyleNames.end(); ++it)
for (auto const& localizedNumStyleName : aLocalizedNumStyleNames)
{
if( it->second > 1 )
if( localizedNumStyleName.second > 1 )
{
std::cout << "ERROR: Style name translations must be unique in:\n" <<
aPoPath << "\nLanguage: " << aLanguage << "\nDuplicated translation is: " << it->first <<
aPoPath << "\nLanguage: " << aLanguage << "\nDuplicated translation is: " << localizedNumStyleName.first <<
"\nSee STR_POOLNUMRULE_*\n\n";
}
}
......@@ -268,14 +268,14 @@ static void checkFunctionNames(const OString& aLanguage)
}
}
aPoInput.close();
for( std::map<OString,sal_uInt16>::iterator it=aLocalizedFunctionNames.begin(); it!=aLocalizedFunctionNames.end(); ++it)
for (auto const& localizedFunctionName : aLocalizedFunctionNames)
{
if( it->second > 1 )
if( localizedFunctionName.second > 1 )
{
std::cout
<< ("ERROR: Spreadsheet function name translations must be"
" unique.\nLanguage: ")
<< aLanguage << "\nDuplicated translation is: " << it->first
<< aLanguage << "\nDuplicated translation is: " << localizedFunctionName.first
<< "\n\n";
}
}
......
......@@ -301,10 +301,9 @@ XMLFile::~XMLFile()
{
if( m_pXMLStrings )
{
XMLHashMap::iterator pos = m_pXMLStrings->begin();
for( ; pos != m_pXMLStrings->end() ; ++pos )
for (auto const& pos : *m_pXMLStrings)
{
delete pos->second; // Check and delete content also ?
delete pos.second; // Check and delete content also ?
}
}
}
......@@ -404,15 +403,15 @@ XMLFile& XMLFile::operator=(const XMLFile& rObj)
if( rObj.m_pXMLStrings )
{
m_pXMLStrings.reset( new XMLHashMap );
for( XMLHashMap::iterator pos = rObj.m_pXMLStrings->begin() ; pos != rObj.m_pXMLStrings->end() ; ++pos )
for (auto const& pos : *rObj.m_pXMLStrings)
{
LangHashMap* pElem=pos->second;
LangHashMap* pElem=pos.second;
LangHashMap* pNewelem = new LangHashMap;
for(LangHashMap::iterator pos2=pElem->begin(); pos2!=pElem->end();++pos2)
for (auto const& pos2 : *pElem)
{
(*pNewelem)[ pos2->first ] = new XMLElement( *pos2->second );
(*pNewelem)[ pos2.first ] = new XMLElement( *pos2.second );
}
(*m_pXMLStrings)[ pos->first ] = pNewelem;
(*m_pXMLStrings)[ pos.first ] = pNewelem;
}
}
}
......
......@@ -50,10 +50,9 @@ void Tile::setSurface(cairo_surface_t *buffer)
*/
void TileBuffer::resetAllTiles()
{
std::map<int, Tile>::iterator it = m_mTiles.begin();
for (; it != m_mTiles.end(); ++it)
for (auto & tile : m_mTiles)
{
it->second.valid = false;
tile.second.valid = false;
}
}
......
......@@ -449,18 +449,16 @@ uno::Sequence< OUString > SAL_CALL ConvDic::getConversionEntries(
aFromLeft : *pFromRight;
uno::Sequence< OUString > aRes( rConvMap.size() );
OUString *pRes = aRes.getArray();
ConvMap::iterator aIt = rConvMap.begin();
sal_Int32 nIdx = 0;
while (aIt != rConvMap.end())
for (auto const& elem : rConvMap)
{
OUString aCurEntry( (*aIt).first );
OUString aCurEntry( elem.first );
// skip duplicate entries ( duplicate = duplicate entries
// respective to the evaluated side (FROM_LEFT or FROM_RIGHT).
// Thus if FROM_LEFT is evaluated for pairs (A,B) and (A,C)
// only one entry for A will be returned in the result)
if (nIdx == 0 || !lcl_SeqHasEntry( pRes, nIdx, aCurEntry ))
pRes[ nIdx++ ] = aCurEntry;
++aIt;
}
aRes.realloc( nIdx );
......@@ -510,25 +508,21 @@ sal_Int16 SAL_CALL ConvDic::getMaxCharCount( ConversionDirection eDirection )
if (!bMaxCharCountIsValid)
{
nMaxLeftCharCount = 0;
ConvMap::iterator aIt = aFromLeft.begin();
while (aIt != aFromLeft.end())
for (auto const& elem : aFromLeft)
{
sal_Int16 nTmp = static_cast<sal_Int16>((*aIt).first.getLength());
sal_Int16 nTmp = static_cast<sal_Int16>(elem.first.getLength());
if (nTmp > nMaxLeftCharCount)
nMaxLeftCharCount = nTmp;
++aIt;
}
nMaxRightCharCount = 0;
if (pFromRight.get())
{
aIt = pFromRight->begin();
while (aIt != pFromRight->end())
for (auto const& elem : *pFromRight)
{
sal_Int16 nTmp = static_cast<sal_Int16>((*aIt).first.getLength());
sal_Int16 nTmp = static_cast<sal_Int16>(elem.first.getLength());
if (nTmp > nMaxRightCharCount)
nMaxRightCharCount = nTmp;
++aIt;
}
}
......
......@@ -326,14 +326,12 @@ void ConvDicXMLExport::ExportContent_()
{
// acquire sorted list of all keys
ConvMapKeySet aKeySet;
ConvMap::iterator aIt;
for (aIt = rDic.aFromLeft.begin(); aIt != rDic.aFromLeft.end(); ++aIt)
aKeySet.insert( (*aIt).first );
for (auto const& elem : rDic.aFromLeft)
aKeySet.insert( elem.first );
ConvMapKeySet::iterator aKeyIt;
for (aKeyIt = aKeySet.begin(); aKeyIt != aKeySet.end(); ++aKeyIt)
for (auto const& elem : aKeySet)
{
OUString aLeftText( *aKeyIt );
OUString aLeftText(elem);
AddAttribute( XML_NAMESPACE_TCD, "left-text", aLeftText );
if (rDic.pConvPropType.get()) // property-type list available?
{
......@@ -350,10 +348,10 @@ void ConvDicXMLExport::ExportContent_()
"entry" , true, true );
pair< ConvMap::iterator, ConvMap::iterator > aRange =
rDic.aFromLeft.equal_range( *aKeyIt );
for (aIt = aRange.first; aIt != aRange.second; ++aIt)
rDic.aFromLeft.equal_range(elem);
for (auto aIt = aRange.first; aIt != aRange.second; ++aIt)
{
DBG_ASSERT( *aKeyIt == (*aIt).first, "key <-> entry mismatch" );
DBG_ASSERT( elem == (*aIt).first, "key <-> entry mismatch" );
OUString aRightText( (*aIt).second );
SvXMLElementExport aEntryRightText( *this, XML_NAMESPACE_TCD,
"right-text" , true, false );
......
......@@ -797,13 +797,11 @@ sal_Int32 GrammarCheckingIterator::GetSuggestedEndOfSentence(
void SAL_CALL GrammarCheckingIterator::resetIgnoreRules( )
{
GCReferences_t::iterator aIt( m_aGCReferencesByService.begin() );
while (aIt != m_aGCReferencesByService.end())
for (auto const& elem : m_aGCReferencesByService)
{
uno::Reference< linguistic2::XProofreader > xGC( aIt->second );
uno::Reference< linguistic2::XProofreader > xGC(elem.second);
if (xGC.is())
xGC->resetIgnoreRules();
++aIt;
}
}
......
......@@ -251,10 +251,9 @@ Sequence< Locale > SAL_CALL HyphenatorDispatcher::getLocales()
Sequence< Locale > aLocales( static_cast< sal_Int32 >(aSvcMap.size()) );
Locale *pLocales = aLocales.getArray();
HyphSvcByLangMap_t::const_iterator aIt;
for (aIt = aSvcMap.begin(); aIt != aSvcMap.end(); ++aIt)
for (auto const& elem : aSvcMap)
{
*pLocales++ = LanguageTag::convertToLocale( aIt->first );
*pLocales++ = LanguageTag::convertToLocale(elem.first);
}
return aLocales;
}
......
......@@ -131,11 +131,10 @@ static uno::Sequence< lang::Locale > GetAvailLocales(
sal_Int32 nLanguages = static_cast< sal_Int32 >(aLanguages.size());
aRes.realloc( nLanguages );
lang::Locale *pRes = aRes.getArray();
std::set< LanguageType >::const_iterator aIt( aLanguages.begin() );
for (i = 0; aIt != aLanguages.end(); ++aIt, ++i)
i=0;
for (auto const& language : aLanguages)
{
LanguageType nLang = *aIt;
pRes[i] = LanguageTag::convertToLocale( nLang );
pRes[i++] = LanguageTag::convertToLocale(language);
}
}
......@@ -745,16 +744,14 @@ void LngSvcMgr::UpdateAll()
OUString aSubNodeName( OUString::createFromAscii(pSubNodeName) );
list_entry_map_t &rCurMap = (i == 0) ? aCurSvcs[k] : aLastFoundSvcs[k];
list_entry_map_t::const_iterator aIt( rCurMap.begin() );
sal_Int32 nVals = static_cast< sal_Int32 >( rCurMap.size() );
Sequence< PropertyValue > aNewValues( nVals );
PropertyValue *pNewValue = aNewValues.getArray();
while (aIt != rCurMap.end())
for (auto const& elem : rCurMap)
{
pNewValue->Name = aSubNodeName + "/" + (*aIt).first;
pNewValue->Value <<= (*aIt).second;
pNewValue->Name = aSubNodeName + "/" + elem.first;
pNewValue->Value <<= elem.second;
++pNewValue;
++aIt;
}
OSL_ENSURE( pNewValue - aNewValues.getArray() == nVals,
"possible mismatch of sequence size and property number" );
......
......@@ -192,10 +192,9 @@ Sequence< Locale > SAL_CALL SpellCheckerDispatcher::getLocales()
Sequence< Locale > aLocales( static_cast< sal_Int32 >(m_aSvcMap.size()) );
Locale *pLocales = aLocales.getArray();
SpellSvcByLangMap_t::const_iterator aIt;
for (aIt = m_aSvcMap.begin(); aIt != m_aSvcMap.end(); ++aIt)
for (auto const& elem : m_aSvcMap)
{
*pLocales++ = LanguageTag::convertToLocale( aIt->first );
*pLocales++ = LanguageTag::convertToLocale(elem.first);
}
return aLocales;
}
......
......@@ -83,10 +83,9 @@ Sequence< Locale > SAL_CALL
Sequence< Locale > aLocales( static_cast< sal_Int32 >(aSvcMap.size()) );
Locale *pLocales = aLocales.getArray();
ThesSvcByLangMap_t::const_iterator aIt;
for (aIt = aSvcMap.begin(); aIt != aSvcMap.end(); ++aIt)
for (auto const& elem : aSvcMap)
{
*pLocales++ = LanguageTag::convertToLocale( aIt->first );
*pLocales++ = LanguageTag::convertToLocale(elem.first);
}
return aLocales;
}
......
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