[Libreoffice-commits] core.git: 4 commits - include/linguistic lingucomponent/source linguistic/source

Eike Rathke erack at redhat.com
Thu Sep 12 10:32:06 PDT 2013


 include/linguistic/misc.hxx                 |    4 ++++
 lingucomponent/source/lingutil/lingutil.cxx |   16 +++++-----------
 linguistic/source/misc.cxx                  |   13 +++++++++++++
 3 files changed, 22 insertions(+), 11 deletions(-)

New commits:
commit b291852c2f907e5d181b1de43af216f7d03db96a
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Sep 12 19:31:04 2013 +0200

    get rid of unnecessary conversion, use LinguIsUnspecified(OUString)
    
    Change-Id: Ib1074e3025680306c0a8bf7dcff651cefdcb90ba

diff --git a/include/linguistic/misc.hxx b/include/linguistic/misc.hxx
index 3d6321e..da5c4dc 100644
--- a/include/linguistic/misc.hxx
+++ b/include/linguistic/misc.hxx
@@ -111,6 +111,10 @@ LNG_DLLPUBLIC ::com::sun::star::lang::Locale LinguLanguageToLocale( LanguageType
  */
 LNG_DLLPUBLIC bool LinguIsUnspecified( LanguageType nLanguage );
 
+/** The same as LinguIsUnspecified(LanguageType) but taking a BCP 47 language
+    tag string instead. */
+LNG_DLLPUBLIC bool LinguIsUnspecified( const OUString & rBcp47 );
+
 ::com::sun::star::uno::Sequence< sal_Int16 >
     LocaleSeqToLangSeq( ::com::sun::star::uno::Sequence<
         ::com::sun::star::lang::Locale > &rLocaleSeq );
diff --git a/lingucomponent/source/lingutil/lingutil.cxx b/lingucomponent/source/lingutil/lingutil.cxx
index 48fe7c5..5543a66 100644
--- a/lingucomponent/source/lingutil/lingutil.cxx
+++ b/lingucomponent/source/lingutil/lingutil.cxx
@@ -208,11 +208,7 @@ void MergeNewStyleDicsAndOldStyleDics(
         DBG_ASSERT( nOldStyleDics, "old style dictionary with more then one language found!");
         if (nOldStyleDics > 0)
         {
-            /* TODO: this conversion exists only to check with
-             * LinguIsUnspecified(), add another check that takes the tag
-             * string instead. */
-            LanguageType nLang = LanguageTag::convertToLanguageTypeWithFallback( aIt2->aLocaleNames[0] );
-            if (nLang == LANGUAGE_DONTKNOW || linguistic::LinguIsUnspecified( nLang))
+            if (linguistic::LinguIsUnspecified( aIt2->aLocaleNames[0]))
             {
                 OSL_FAIL( "old style dictionary with invalid language found!" );
                 continue;
diff --git a/linguistic/source/misc.cxx b/linguistic/source/misc.cxx
index 867dccf..fe24438 100644
--- a/linguistic/source/misc.cxx
+++ b/linguistic/source/misc.cxx
@@ -106,6 +106,19 @@ bool LinguIsUnspecified( LanguageType nLanguage )
     return false;
 }
 
+// When adding anything keep both LinguIsUnspecified() methods in sync!
+// For mappings between language code string and LanguageType see
+// i18nlangtag/source/isolang/isolang.cxx
+
+bool LinguIsUnspecified( const OUString & rBcp47 )
+{
+    if (rBcp47.getLength() != 3)
+        return false;
+    if (rBcp47 == "zxx" || rBcp47 == "und" || rBcp47 == "mul")
+        return true;
+    return false;
+}
+
 static inline sal_Int32 Minimum( sal_Int32 n1, sal_Int32 n2, sal_Int32 n3 )
 {
     sal_Int32 nMin = n1 < n2 ? n1 : n2;
commit 2f6551b0167c2651f900b9c727bd74240b493754
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Sep 12 19:13:53 2013 +0200

    a set of LanguageType fallback converted to is utter nonsense here
    
    Change-Id: I02881a2a7ab3178521388b76e2413b7e1cd6c443

diff --git a/lingucomponent/source/lingutil/lingutil.cxx b/lingucomponent/source/lingutil/lingutil.cxx
index 6afd28c..48fe7c5 100644
--- a/lingucomponent/source/lingutil/lingutil.cxx
+++ b/lingucomponent/source/lingutil/lingutil.cxx
@@ -185,7 +185,7 @@ void MergeNewStyleDicsAndOldStyleDics(
     const std::vector< SvtLinguConfigDictionaryEntry > &rOldStyleDics )
 {
     // get list of languages supported by new style dictionaries
-    std::set< LanguageType > aNewStyleLanguages;
+    std::set< OUString > aNewStyleLanguages;
     std::list< SvtLinguConfigDictionaryEntry >::const_iterator aIt;
     for (aIt = rNewStyleDics.begin() ;  aIt != rNewStyleDics.end();  ++aIt)
     {
@@ -193,8 +193,7 @@ void MergeNewStyleDicsAndOldStyleDics(
         sal_Int32 nLocaleNames = aLocaleNames.getLength();
         for (sal_Int32 k = 0;  k < nLocaleNames; ++k)
         {
-            LanguageType nLang = LanguageTag::convertToLanguageTypeWithFallback( aLocaleNames[k] );
-            aNewStyleLanguages.insert( nLang );
+            aNewStyleLanguages.insert( aLocaleNames[k] );
         }
     }
 
@@ -209,8 +208,10 @@ void MergeNewStyleDicsAndOldStyleDics(
         DBG_ASSERT( nOldStyleDics, "old style dictionary with more then one language found!");
         if (nOldStyleDics > 0)
         {
+            /* TODO: this conversion exists only to check with
+             * LinguIsUnspecified(), add another check that takes the tag
+             * string instead. */
             LanguageType nLang = LanguageTag::convertToLanguageTypeWithFallback( aIt2->aLocaleNames[0] );
-
             if (nLang == LANGUAGE_DONTKNOW || linguistic::LinguIsUnspecified( nLang))
             {
                 OSL_FAIL( "old style dictionary with invalid language found!" );
@@ -218,7 +219,7 @@ void MergeNewStyleDicsAndOldStyleDics(
             }
 
             // language not yet added?
-            if (aNewStyleLanguages.find( nLang ) == aNewStyleLanguages.end())
+            if (aNewStyleLanguages.find( aIt2->aLocaleNames[0] ) == aNewStyleLanguages.end())
                 rNewStyleDics.push_back( *aIt2 );
         }
         else
commit 22dc925e3580de0a33e61f91fbce654016d31343
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Sep 12 19:03:06 2013 +0200

    no need to count, just find
    
    Change-Id: Ia4fa44c2382f6d1f5a6b3fed533f401bcb03be53

diff --git a/lingucomponent/source/lingutil/lingutil.cxx b/lingucomponent/source/lingutil/lingutil.cxx
index a8b3a90..6afd28c 100644
--- a/lingucomponent/source/lingutil/lingutil.cxx
+++ b/lingucomponent/source/lingutil/lingutil.cxx
@@ -218,7 +218,7 @@ void MergeNewStyleDicsAndOldStyleDics(
             }
 
             // language not yet added?
-            if (aNewStyleLanguages.count( nLang ) == 0)
+            if (aNewStyleLanguages.find( nLang ) == aNewStyleLanguages.end())
                 rNewStyleDics.push_back( *aIt2 );
         }
         else
commit 349b2c2de1d3cdcfa809bdd538b3dfb743a8513c
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Sep 12 18:54:48 2013 +0200

    it's a set, so treat it as such
    
    Change-Id: Ia156b27d944bf419a2e0bd45fa65efd4b7f89404

diff --git a/lingucomponent/source/lingutil/lingutil.cxx b/lingucomponent/source/lingutil/lingutil.cxx
index 590206c..a8b3a90 100644
--- a/lingucomponent/source/lingutil/lingutil.cxx
+++ b/lingucomponent/source/lingutil/lingutil.cxx
@@ -160,11 +160,8 @@ std::vector< SvtLinguConfigDictionaryEntry > GetOldStyleDics( const char *pDicTy
                 // Thus we first get the language of the dictionary
                 OUString aLocaleName(aLangTag.getBcp47());
 
-                if (aDicLangInUse.count(aLocaleName) == 0)
+                if (aDicLangInUse.insert(aLocaleName).second)
                 {
-                    // remember the new language in use
-                    aDicLangInUse.insert(aLocaleName);
-
                     // add the dictionary to the resulting vector
                     SvtLinguConfigDictionaryEntry aDicEntry;
                     aDicEntry.aLocations.realloc(1);


More information about the Libreoffice-commits mailing list