diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2018-03-18 12:36:02 +0100 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2018-03-25 15:14:44 +0200 |
commit | f365b17bf170c8ed1baae299a2d719774fcc4305 (patch) | |
tree | 312378ff5e6ef487ab65d7a1d011307486941c56 | |
parent | dd5df4ccb33048fa5fa8f85b2e6e69a6a225be57 (diff) |
Use for-range loops in some modules
jvmaccess, jvmfwk, l10ntools, libreofficekit and linguistic
Change-Id: I9d290d1098b25ccb3aee19d2df18c18f4aa65105
Reviewed-on: https://gerrit.libreoffice.org/51495
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
-rw-r--r-- | jvmaccess/source/classpath.cxx | 4 | ||||
-rw-r--r-- | jvmfwk/plugins/sunmajor/pluginlib/util.cxx | 5 | ||||
-rw-r--r-- | l10ntools/source/helpmerge.cxx | 22 | ||||
-rw-r--r-- | l10ntools/source/idxdict/idxdict.cxx | 7 | ||||
-rw-r--r-- | l10ntools/source/localize.cxx | 4 | ||||
-rw-r--r-- | l10ntools/source/merge.cxx | 4 | ||||
-rw-r--r-- | l10ntools/source/pocheck.cxx | 18 | ||||
-rw-r--r-- | l10ntools/source/xmlparse.cxx | 15 | ||||
-rw-r--r-- | libreofficekit/source/gtk/tilebuffer.cxx | 5 | ||||
-rw-r--r-- | linguistic/source/convdic.cxx | 18 | ||||
-rw-r--r-- | linguistic/source/convdicxml.cxx | 16 | ||||
-rw-r--r-- | linguistic/source/gciterator.cxx | 6 | ||||
-rw-r--r-- | linguistic/source/hyphdsp.cxx | 5 | ||||
-rw-r--r-- | linguistic/source/lngsvcmgr.cxx | 15 | ||||
-rw-r--r-- | linguistic/source/spelldsp.cxx | 5 | ||||
-rw-r--r-- | linguistic/source/thesdsp.cxx | 5 |
16 files changed, 64 insertions, 90 deletions
diff --git a/jvmaccess/source/classpath.cxx b/jvmaccess/source/classpath.cxx index 6a5ccf87b1d4..4be1fedb7d26 100644 --- a/jvmaccess/source/classpath.cxx +++ b/jvmaccess/source/classpath.cxx @@ -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; } diff --git a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx index 187a2789b4cc..dfa4653054cc 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx @@ -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; diff --git a/l10ntools/source/helpmerge.cxx b/l10ntools/source/helpmerge.cxx index f09fe6af45a0..92f5171e5e67 100644 --- a/l10ntools/source/helpmerge.cxx +++ b/l10ntools/source/helpmerge.cxx @@ -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***************************************"); diff --git a/l10ntools/source/idxdict/idxdict.cxx b/l10ntools/source/idxdict/idxdict.cxx index e35bceaa0aea..38955a5b8258 100644 --- a/l10ntools/source/idxdict/idxdict.cxx +++ b/l10ntools/source/idxdict/idxdict.cxx @@ -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'; } } diff --git a/l10ntools/source/localize.cxx b/l10ntools/source/localize.cxx index 9a2cf8ad4b94..98098b775456 100644 --- a/l10ntools/source/localize.cxx +++ b/l10ntools/source/localize.cxx @@ -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) { diff --git a/l10ntools/source/merge.cxx b/l10ntools/source/merge.cxx index b80eaf91b232..66aca214467d 100644 --- a/l10ntools/source/merge.cxx +++ b/l10ntools/source/merge.cxx @@ -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 diff --git a/l10ntools/source/pocheck.cxx b/l10ntools/source/pocheck.cxx index dc56014b083a..241c225e1c35 100644 --- a/l10ntools/source/pocheck.cxx +++ b/l10ntools/source/pocheck.cxx @@ -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"; } } diff --git a/l10ntools/source/xmlparse.cxx b/l10ntools/source/xmlparse.cxx index 3ba61be5e1a0..297b736dae22 100644 --- a/l10ntools/source/xmlparse.cxx +++ b/l10ntools/source/xmlparse.cxx @@ -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; } } } diff --git a/libreofficekit/source/gtk/tilebuffer.cxx b/libreofficekit/source/gtk/tilebuffer.cxx index bded6b1ad853..f81d0bfbfd0a 100644 --- a/libreofficekit/source/gtk/tilebuffer.cxx +++ b/libreofficekit/source/gtk/tilebuffer.cxx @@ -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; } } diff --git a/linguistic/source/convdic.cxx b/linguistic/source/convdic.cxx index 555244ada44a..755ffb72c060 100644 --- a/linguistic/source/convdic.cxx +++ b/linguistic/source/convdic.cxx @@ -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; } } diff --git a/linguistic/source/convdicxml.cxx b/linguistic/source/convdicxml.cxx index 97a1d6a56268..51ba74467120 100644 --- a/linguistic/source/convdicxml.cxx +++ b/linguistic/source/convdicxml.cxx @@ -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 ); diff --git a/linguistic/source/gciterator.cxx b/linguistic/source/gciterator.cxx index 4ecfffa8603b..144aaa599b85 100644 --- a/linguistic/source/gciterator.cxx +++ b/linguistic/source/gciterator.cxx @@ -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; } } diff --git a/linguistic/source/hyphdsp.cxx b/linguistic/source/hyphdsp.cxx index bb1bdfebdef5..425d29124500 100644 --- a/linguistic/source/hyphdsp.cxx +++ b/linguistic/source/hyphdsp.cxx @@ -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; } diff --git a/linguistic/source/lngsvcmgr.cxx b/linguistic/source/lngsvcmgr.cxx index e5dc4b1d4829..8c8aba8fdca6 100644 --- a/linguistic/source/lngsvcmgr.cxx +++ b/linguistic/source/lngsvcmgr.cxx @@ -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" ); diff --git a/linguistic/source/spelldsp.cxx b/linguistic/source/spelldsp.cxx index 7d1ac95fc32c..b3a795f7f75c 100644 --- a/linguistic/source/spelldsp.cxx +++ b/linguistic/source/spelldsp.cxx @@ -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; } diff --git a/linguistic/source/thesdsp.cxx b/linguistic/source/thesdsp.cxx index d81fbf4f79ef..9b34cf300204 100644 --- a/linguistic/source/thesdsp.cxx +++ b/linguistic/source/thesdsp.cxx @@ -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; } |