From 1e3a5bb9e92aea074d7350ccde0dae5c123e885d Mon Sep 17 00:00:00 2001 From: Julien Nabet Date: Sun, 18 Mar 2018 10:34:42 +0100 Subject: Use for-range loops in hwpfilter, i18n*, idl* and io Change-Id: I980464162b73ed9ee0a09acbca1b9050af8d1027 Reviewed-on: https://gerrit.libreoffice.org/51492 Tested-by: Jenkins Reviewed-by: Julien Nabet --- i18nlangtag/qa/cppunit/test_languagetag.cxx | 22 +++++++++--------- i18nlangtag/source/languagetag/languagetag.cxx | 32 +++++++++++++------------- 2 files changed, 27 insertions(+), 27 deletions(-) (limited to 'i18nlangtag') diff --git a/i18nlangtag/qa/cppunit/test_languagetag.cxx b/i18nlangtag/qa/cppunit/test_languagetag.cxx index 6192075cf266..a945a20cbf03 100644 --- a/i18nlangtag/qa/cppunit/test_languagetag.cxx +++ b/i18nlangtag/qa/cppunit/test_languagetag.cxx @@ -749,28 +749,28 @@ bool checkMapping( const OUString& rStr1, const OUString& rStr2 ) void TestLanguageTag::testAllIsoLangEntries() { const ::std::vector< MsLangId::LanguagetagMapping > aList( MsLangId::getDefinedLanguagetags()); - for (::std::vector< MsLangId::LanguagetagMapping >::const_iterator it( aList.begin()); it != aList.end(); ++it) + for (auto const& elem : aList) { bool b=false; - if ((*it).maBcp47 == "la-VA") + if (elem.maBcp47 == "la-VA") b=true; (void)b; - LanguageTag aTagString( (*it).maBcp47, true); - LanguageTag aTagID( (*it).mnLang); - if (!checkMapping( (*it).maBcp47, aTagString.getBcp47())) + LanguageTag aTagString( elem.maBcp47, true); + LanguageTag aTagID( elem.mnLang); + if (!checkMapping( elem.maBcp47, aTagString.getBcp47())) { - OString aMessage( OUStringToOString( (*it).maBcp47, RTL_TEXTENCODING_ASCII_US)); + OString aMessage( OUStringToOString( elem.maBcp47, RTL_TEXTENCODING_ASCII_US)); aMessage += " -> " + OUStringToOString( aTagString.getBcp47(), RTL_TEXTENCODING_ASCII_US); - CPPUNIT_ASSERT_EQUAL_MESSAGE( aMessage.getStr(), aTagString.getBcp47(), (*it).maBcp47 ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( aMessage.getStr(), aTagString.getBcp47(), elem.maBcp47 ); } - if ((*it).maBcp47 != aTagID.getBcp47()) + if (elem.maBcp47 != aTagID.getBcp47()) { // There are multiple mappings, ID must be equal after conversions. LanguageTag aTagBack( aTagID.getBcp47(), true); if (aTagString.getLanguageType() != aTagBack.getLanguageType()) { - OString aMessage( OUStringToOString( (*it).maBcp47, RTL_TEXTENCODING_ASCII_US)); + OString aMessage( OUStringToOString( elem.maBcp47, RTL_TEXTENCODING_ASCII_US)); aMessage += " " + OUStringToOString( aTagString.getBcp47(), RTL_TEXTENCODING_ASCII_US) + ": " + OUStringToOString( aTagString.getBcp47(), RTL_TEXTENCODING_ASCII_US) + " " + OString::number( static_cast(aTagString.getLanguageType()), 16) + @@ -783,13 +783,13 @@ void TestLanguageTag::testAllIsoLangEntries() // This does not hold, there are cases like 'ar' // LANGUAGE_ARABIC_PRIMARY_ONLY that when mapped back results in // 'ar-SA' as default locale. - if ((*it).mnLang != aTagString.getLanguageType()) + if (elem.mnLang != aTagString.getLanguageType()) { // There are multiple mappings, string must be equal after conversions. LanguageTag aTagBack( aTagString.getLanguageType()); if (aTagID.getBcp47() != aTagBack.getBcp47()) { - OString aMessage( OUStringToOString( (*it).maBcp47, RTL_TEXTENCODING_ASCII_US)); + OString aMessage( OUStringToOString( elem.maBcp47, RTL_TEXTENCODING_ASCII_US)); aMessage += " " + OUStringToOString( aTagID.getBcp47(), RTL_TEXTENCODING_ASCII_US) + " -> " + OUStringToOString( aTagBack.getBcp47(), RTL_TEXTENCODING_ASCII_US); CPPUNIT_ASSERT_MESSAGE( aMessage.getStr(), aTagID.getBcp47() == aTagBack.getBcp47()); diff --git a/i18nlangtag/source/languagetag/languagetag.cxx b/i18nlangtag/source/languagetag/languagetag.cxx index f9945f10c5c9..8d9c2424c9b9 100644 --- a/i18nlangtag/source/languagetag/languagetag.cxx +++ b/i18nlangtag/source/languagetag/languagetag.cxx @@ -61,16 +61,15 @@ static const KnownTagSet & getKnowns() if (rKnowns.empty()) { ::std::vector< MsLangId::LanguagetagMapping > aDefined( MsLangId::getDefinedLanguagetags()); - for (::std::vector< MsLangId::LanguagetagMapping >::const_iterator it( aDefined.begin()); - it != aDefined.end(); ++it) + for (auto const& elemDefined : aDefined) { // Do not use the BCP47 string here to initialize the // LanguageTag because then canonicalize() would call this // getKnowns() again.. - ::std::vector< OUString > aFallbacks( LanguageTag( (*it).mnLang).getFallbackStrings( true)); - for (::std::vector< OUString >::const_iterator fb( aFallbacks.begin()); fb != aFallbacks.end(); ++fb) + ::std::vector< OUString > aFallbacks( LanguageTag( elemDefined.mnLang).getFallbackStrings( true)); + for (auto const& fallback : aFallbacks) { - rKnowns.insert( *fb); + rKnowns.insert(fallback); } } } @@ -2101,9 +2100,9 @@ LanguageTag & LanguageTag::makeFallback() // "en-US" is the last resort fallback, try if we get a better // one for the fallback hierarchy of a non-"en" locale. ::std::vector< OUString > aFallbacks( getFallbackStrings( false)); - for (::std::vector< OUString >::const_iterator it( aFallbacks.begin()); it != aFallbacks.end(); ++it) + for (auto const& fallback : aFallbacks) { - lang::Locale aLocale3( LanguageTag( *it).getLocale()); + lang::Locale aLocale3( LanguageTag(fallback).getLocale()); aLocale2 = MsLangId::Conversion::lookupFallbackLocale( aLocale3); if (aLocale2.Language != "en" || aLocale2.Country != "US") break; // for, success @@ -2652,21 +2651,22 @@ LanguageTagImpl::Extraction LanguageTagImpl::simpleExtract( const OUString& rBcp ::std::vector< OUString > aFallbacks( LanguageTag( rReference).getFallbackStrings( false)); ::std::vector< ::std::vector< OUString > > aListFallbacks( rList.size()); size_t i = 0; - for (it = rList.begin(); it != rList.end(); ++it, ++i) + for (auto const& elem : rList) { - ::std::vector< OUString > aTmp( LanguageTag( *it).getFallbackStrings( true)); - aListFallbacks[i] = aTmp; + ::std::vector< OUString > aTmp( LanguageTag(elem).getFallbackStrings( true)); + aListFallbacks[i++] = aTmp; } - for (::std::vector< OUString >::const_iterator rfb( aFallbacks.begin()); rfb != aFallbacks.end(); ++rfb) + for (auto const& rfb : aFallbacks) { - for (::std::vector< ::std::vector< OUString > >::const_iterator lfb( aListFallbacks.begin()); - lfb != aListFallbacks.end(); ++lfb) + size_t nPosFb = 0; + for (auto const& lfb : aListFallbacks) { - for (::std::vector< OUString >::const_iterator fb( (*lfb).begin()); fb != (*lfb).end(); ++fb) + for (auto const& fb : lfb) { - if (*rfb == *fb) - return rList.begin() + (lfb - aListFallbacks.begin()); + if (rfb == fb) + return rList.begin() + nPosFb; } + ++nPosFb; } } -- cgit