[Libreoffice-commits] core.git: i18nlangtag/source include/i18nlangtag include/linguistic jvmfwk/source linguistic/source

Noel Grandin noel.grandin at collabora.co.uk
Tue Oct 31 12:09:53 UTC 2017


 i18nlangtag/source/isolang/mslangid.cxx        |   30 +++++++----------
 i18nlangtag/source/languagetag/languagetag.cxx |    6 +--
 include/i18nlangtag/mslangid.hxx               |   10 +----
 include/linguistic/spelldta.hxx                |    3 -
 jvmfwk/source/elements.cxx                     |   11 ++----
 linguistic/source/spelldta.cxx                 |   42 ++++++++++---------------
 6 files changed, 40 insertions(+), 62 deletions(-)

New commits:
commit eb5d232342b1d0f596b6e9c5f8df740a6ec614ff
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Oct 31 09:07:27 2017 +0200

    loplugin:constantparam in i18nlangtag
    
    Change-Id: I148a47a9b63b78651ec18cd947f45b8f4dbb9345
    Reviewed-on: https://gerrit.libreoffice.org/44094
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/i18nlangtag/source/isolang/mslangid.cxx b/i18nlangtag/source/isolang/mslangid.cxx
index 5e2df2ee86c4..6d4b98781640 100644
--- a/i18nlangtag/source/isolang/mslangid.cxx
+++ b/i18nlangtag/source/isolang/mslangid.cxx
@@ -144,26 +144,20 @@ LanguageType MsLangId::resolveSystemLanguageByScriptType( LanguageType nLang, sa
 
 // static
 css::lang::Locale MsLangId::Conversion::convertLanguageToLocale(
-        LanguageType nLang, bool bResolveSystem )
+        LanguageType nLang )
 {
     css::lang::Locale aLocale;
-    if (!bResolveSystem && simplifySystemLanguages( nLang) == LANGUAGE_SYSTEM)
-        ;   // nothing => empty locale
-    else
+    // Still resolve LANGUAGE_DONTKNOW if resolving is not requested,
+    // but not LANGUAGE_SYSTEM or others.
+    LanguageType nOrigLang = nLang;
+    nLang = MsLangId::getRealLanguage(nLang);
+    convertLanguageToLocaleImpl( nLang, aLocale, true );
+    if (aLocale.Language.isEmpty() && simplifySystemLanguages(nOrigLang) == LANGUAGE_SYSTEM)
     {
-        // Still resolve LANGUAGE_DONTKNOW if resolving is not requested,
-        // but not LANGUAGE_SYSTEM or others.
-        LanguageType nOrigLang = nLang;
-        if (bResolveSystem || nLang == LANGUAGE_DONTKNOW)
-            nLang = MsLangId::getRealLanguage( nLang);
-        convertLanguageToLocaleImpl( nLang, aLocale, true);
-        if (bResolveSystem && aLocale.Language.isEmpty() && simplifySystemLanguages( nOrigLang) == LANGUAGE_SYSTEM)
-        {
-            // None found but resolve requested, last resort is "en-US".
-            aLocale.Language = "en";
-            aLocale.Country  = "US";
-            aLocale.Variant.clear();
-        }
+        // None found but resolve requested, last resort is "en-US".
+        aLocale.Language = "en";
+        aLocale.Country  = "US";
+        aLocale.Variant.clear();
     }
     return aLocale;
 }
@@ -187,7 +181,7 @@ css::lang::Locale MsLangId::getFallbackLocale(
 {
     // empty language => LANGUAGE_SYSTEM
     if (rLocale.Language.isEmpty())
-        return Conversion::lookupFallbackLocale( Conversion::convertLanguageToLocale( LANGUAGE_SYSTEM, true));
+        return Conversion::lookupFallbackLocale( Conversion::convertLanguageToLocale( LANGUAGE_SYSTEM ));
     else
         return Conversion::lookupFallbackLocale( rLocale);
 }
diff --git a/i18nlangtag/source/languagetag/languagetag.cxx b/i18nlangtag/source/languagetag/languagetag.cxx
index 1e65fe593f6d..3f887de7d6c1 100644
--- a/i18nlangtag/source/languagetag/languagetag.cxx
+++ b/i18nlangtag/source/languagetag/languagetag.cxx
@@ -961,7 +961,7 @@ LanguageTag::ImplPtr LanguageTag::registerImpl() const
                         // May have involved canonicalize(), so compare with
                         // pImpl->maBcp47 instead of maBcp47!
                         aBcp47 = LanguageTagImpl::convertToBcp47(
-                                MsLangId::Conversion::convertLanguageToLocale( pImpl->mnLangID, true));
+                                MsLangId::Conversion::convertLanguageToLocale( pImpl->mnLangID ));
                         bInsert = (aBcp47 == pImpl->maBcp47);
                     }
                 }
@@ -1344,7 +1344,7 @@ void LanguageTagImpl::convertLocaleToBcp47()
         // locale via LanguageTag::convertToBcp47(LanguageType) and
         // LanguageTag::convertToLocale(LanguageType) would instantiate another
         // LanguageTag.
-        maLocale = MsLangId::Conversion::convertLanguageToLocale( LANGUAGE_SYSTEM, true);
+        maLocale = MsLangId::Conversion::convertLanguageToLocale( LANGUAGE_SYSTEM );
     }
     if (maLocale.Language.isEmpty())
     {
@@ -1488,7 +1488,7 @@ void LanguageTagImpl::convertLangToLocale()
         mbInitializedLangID = true;
     }
     // Resolve system here! The original is remembered as mbSystemLocale.
-    maLocale = MsLangId::Conversion::convertLanguageToLocale( mnLangID, true);
+    maLocale = MsLangId::Conversion::convertLanguageToLocale( mnLangID );
     mbInitializedLocale = true;
 }
 
diff --git a/include/i18nlangtag/mslangid.hxx b/include/i18nlangtag/mslangid.hxx
index c9851e098e1c..fde9087a4f7f 100644
--- a/include/i18nlangtag/mslangid.hxx
+++ b/include/i18nlangtag/mslangid.hxx
@@ -267,15 +267,9 @@ public:
                 const Bcp47CountryEntry * pEntry );
 
 
-        /** Convert a LanguageType to a Locale.
-
-            @param bResolveSystem
-                   If bResolveSystem==true, a LANGUAGE_SYSTEM is resolved.
-                   If bResolveSystem==false, a LANGUAGE_SYSTEM results in an
-                   empty Locale.
-          */
+        /** Convert a LanguageType to a Locale. */
         I18NLANGTAG_DLLPRIVATE static css::lang::Locale convertLanguageToLocale(
-                LanguageType nLang, bool bResolveSystem );
+                LanguageType nLang );
 
         /** Used by convertLanguageToLocale(LanguageType,bool) and
             getLocale(IsoLanguageCountryEntry*) and
diff --git a/include/linguistic/spelldta.hxx b/include/linguistic/spelldta.hxx
index 5c98989059f4..11bb9a1ec9c1 100644
--- a/include/linguistic/spelldta.hxx
+++ b/include/linguistic/spelldta.hxx
@@ -41,8 +41,7 @@ namespace linguistic
 std::vector< OUString >
         MergeProposalSeqs(
                 std::vector< OUString > &rAlt1,
-                std::vector< OUString > &rAlt2,
-                bool bAllowDuplicates );
+                std::vector< OUString > &rAlt2 );
 
 void    SeqRemoveNegEntries(
                 std::vector< OUString > &rSeq,
diff --git a/jvmfwk/source/elements.cxx b/jvmfwk/source/elements.cxx
index 696d6b616d75..96ef388933d4 100644
--- a/jvmfwk/source/elements.cxx
+++ b/jvmfwk/source/elements.cxx
@@ -48,7 +48,7 @@ namespace jfw
 {
 
 OString getElement(OString const & docPath,
-                        xmlChar const * pathExpression, bool bThrowIfEmpty)
+                        xmlChar const * pathExpression)
 {
     //Prepare the xml document and context
     OSL_ASSERT(!docPath.isEmpty());
@@ -70,10 +70,9 @@ OString getElement(OString const & docPath,
     OString sValue;
     if (xmlXPathNodeSetIsEmpty(pathObj->nodesetval))
     {
-        if (bThrowIfEmpty)
-            throw FrameworkException(
-                JFW_E_ERROR,
-                "[Java framework] Error in function getElement (elements.cxx)");
+        throw FrameworkException(
+            JFW_E_ERROR,
+            "[Java framework] Error in function getElement (elements.cxx)");
     }
     else
     {
@@ -85,7 +84,7 @@ OString getElement(OString const & docPath,
 OString getElementUpdated()
 {
     return getElement(jfw::getVendorSettingsPath(),
-                      reinterpret_cast<xmlChar const *>("/jf:javaSelection/jf:updated/text()"), true);
+                      reinterpret_cast<xmlChar const *>("/jf:javaSelection/jf:updated/text()"));
 }
 
 void createSettingsStructure(xmlDoc * document, bool * bNeedsSave)
diff --git a/linguistic/source/spelldta.cxx b/linguistic/source/spelldta.cxx
index 0c8d2a2e1881..fe9f6a4202c0 100644
--- a/linguistic/source/spelldta.cxx
+++ b/linguistic/source/spelldta.cxx
@@ -125,7 +125,7 @@ void SeqRemoveNegEntries( std::vector< OUString > &rSeq,
     {
         std::vector< OUString > aNew;
         // merge sequence without duplicates and empty strings in new empty sequence
-        aNew = MergeProposalSeqs( aNew, rSeq, false );
+        aNew = MergeProposalSeqs( aNew, rSeq );
         rSeq = aNew;
     }
 }
@@ -133,38 +133,30 @@ void SeqRemoveNegEntries( std::vector< OUString > &rSeq,
 
 std::vector< OUString > MergeProposalSeqs(
             std::vector< OUString > &rAlt1,
-            std::vector< OUString > &rAlt2,
-            bool bAllowDuplicates )
+            std::vector< OUString > &rAlt2 )
 {
     std::vector< OUString > aMerged;
 
-    if (rAlt1.empty() && bAllowDuplicates)
-        aMerged = rAlt2;
-    else if (rAlt2.empty() && bAllowDuplicates)
-        aMerged = rAlt1;
-    else
-    {
-        size_t nAltCount1 = rAlt1.size();
-        size_t nAltCount2 = rAlt2.size();
+    size_t nAltCount1 = rAlt1.size();
+    size_t nAltCount2 = rAlt2.size();
 
-        sal_Int32 nCountNew = std::min<sal_Int32>( nAltCount1 + nAltCount2, (sal_Int32) MAX_PROPOSALS );
-        aMerged.resize( nCountNew );
+    sal_Int32 nCountNew = std::min<sal_Int32>( nAltCount1 + nAltCount2, (sal_Int32) MAX_PROPOSALS );
+    aMerged.resize( nCountNew );
 
-        sal_Int32 nIndex = 0;
-        sal_Int32 i = 0;
-        for (int j = 0;  j < 2;  j++)
+    sal_Int32 nIndex = 0;
+    sal_Int32 i = 0;
+    for (int j = 0;  j < 2;  j++)
+    {
+        sal_Int32        nCount  = j == 0 ? nAltCount1 : nAltCount2;
+        std::vector< OUString >& rAlt   = j == 0 ? rAlt1 : rAlt2;
+        for (i = 0;  i < nCount  &&  nIndex < MAX_PROPOSALS;  i++)
         {
-            sal_Int32        nCount  = j == 0 ? nAltCount1 : nAltCount2;
-            std::vector< OUString >& rAlt   = j == 0 ? rAlt1 : rAlt2;
-            for (i = 0;  i < nCount  &&  nIndex < MAX_PROPOSALS;  i++)
-            {
-                if (!rAlt[i].isEmpty() &&
-                    (bAllowDuplicates || !SeqHasEntry(aMerged, rAlt[i] )))
-                    aMerged[ nIndex++ ] = rAlt[ i ];
-            }
+            if (!rAlt[i].isEmpty() &&
+                !SeqHasEntry(aMerged, rAlt[i] ))
+                aMerged[ nIndex++ ] = rAlt[ i ];
         }
-        aMerged.resize( nIndex );
     }
+    aMerged.resize( nIndex );
 
     return aMerged;
 }


More information about the Libreoffice-commits mailing list