LCOV - code coverage report
Current view: top level - i18npool/source/isolang - isolang.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 167 212 78.8 %
Date: 2012-08-25 Functions: 14 15 93.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 109 202 54.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * This file is part of the LibreOffice project.
       4                 :            :  *
       5                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       6                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8                 :            :  *
       9                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      11                 :            :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12                 :            :  *   contributor license agreements. See the NOTICE file distributed
      13                 :            :  *   with this work for additional information regarding copyright
      14                 :            :  *   ownership. The ASF licenses this file to you under the Apache
      15                 :            :  *   License, Version 2.0 (the "License"); you may not use this file
      16                 :            :  *   except in compliance with the License. You may obtain a copy of
      17                 :            :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18                 :            :  */
      19                 :            : 
      20                 :            : #include <rtl/ustring.hxx>
      21                 :            : #include <rtl/string.hxx>
      22                 :            : #include <rtl/ustrbuf.hxx>
      23                 :            : #include <rtl/strbuf.hxx>
      24                 :            : 
      25                 :            : #include "i18npool/mslangid.hxx"
      26                 :            : 
      27                 :            : // =======================================================================
      28                 :            : 
      29                 :            : struct IsoLangEngEntry
      30                 :            : {
      31                 :            :     LanguageType        mnLang;
      32                 :            :     sal_Char            maCountry[3];
      33                 :            : };
      34                 :            : 
      35                 :            : struct IsoLangNoneStdEntry
      36                 :            : {
      37                 :            :     LanguageType        mnLang;
      38                 :            :     sal_Char            maLangStr[4];
      39                 :            :     sal_Char            maCountry[9];
      40                 :            : };
      41                 :            : 
      42                 :            : struct IsoLangOtherEntry
      43                 :            : {
      44                 :            :     LanguageType        mnLang;
      45                 :            :     const sal_Char*     mpLangStr;
      46                 :            : };
      47                 :            : 
      48                 :            : // -----------------------------------------------------------------------
      49                 :            : 
      50                 :            : // Entries for languages are lower case, for countries upper case, as
      51                 :            : // recommended by rfc4646 (obsoletes rfc3066 (obsoletes rfc1766)).
      52                 :            : // convertIsoNamesToLanguage() is case insensitive
      53                 :            : //
      54                 :            : // Sort order: Most used first.
      55                 :            : //
      56                 :            : // The default entry for a LangID <-> ISO mapping has to be first. For
      57                 :            : // conversion of legacy mappings one LangID can map to multiple ISO codes, and
      58                 :            : // one ISO code combination can map to multiple LangIDs. For compatibility with
      59                 :            : // already existing calls it can also be a sequence as follows:
      60                 :            : 
      61                 :            : // LANGUAGE_ENGLISH,    "en", ""
      62                 :            : // LANGUAGE_ENGLISH_US, "en", "US"
      63                 :            : 
      64                 :            : // Here, in a convertIsoNamesToLanguage() call "en-US" is converted to
      65                 :            : // LANGUAGE_ENGLISH_US and "en" is converted to LANGUAGE_ENGLISH. A call with
      66                 :            : // "en-ZZ" (not in table) would result in LANGUAGE_ENGLISH because the first
      67                 :            : // entry matching the language and not having a country is returned, regardless
      68                 :            : // of whether being sorted before or after other entries of the same language
      69                 :            : // with some country. To obtain a _locale_ (not language only) in the order
      70                 :            : // given, convertLocaleToLanguageWithFallback() must be called.
      71                 :            : 
      72                 :            : // If the sequence instead was
      73                 :            : 
      74                 :            : // LANGUAGE_ENGLISH_US, "en", "US"
      75                 :            : // LANGUAGE_ENGLISH,    "en", ""
      76                 :            : 
      77                 :            : // in a convertIsoNamesToLanguage() call "en-US" is still converted to
      78                 :            : // LANGUAGE_ENGLISH_US, but "en" is _also_ converted to LANGUAGE_ENGLISH_US
      79                 :            : // because no country was passed and it is the first entry to match the
      80                 :            : // language, see code. A call with "en-ZZ" (not in table) would still result in
      81                 :            : // LANGUAGE_ENGLISH.
      82                 :            : 
      83                 :            : /* erAck: 2007-07-05T20:01+0200  TODO: The entire suite's "primary language
      84                 :            :  * only" usage and locale fall back should be cleaned up and made consistent. I
      85                 :            :  * strongly doubt that most callers exactly expect the behavior described.
      86                 :            :  * Currently these primary LangIDs are used literally in OOo code:
      87                 :            :  * LANGUAGE_ENGLISH LANGUAGE_CHINESE LANGUAGE_MALAY
      88                 :            :  * LANGUAGE_AZERI LANGUAGE_URDU LANGUAGE_KASHMIRI
      89                 :            :  */
      90                 :            : 
      91                 :            : static MsLangId::IsoLangEntry const aImplIsoLangEntries[] =
      92                 :            : {
      93                 :            :     // MS-LANGID codes               ISO639-1/2/3 ISO3166
      94                 :            :     { LANGUAGE_ENGLISH,                     "en", ""   },
      95                 :            :     { LANGUAGE_ENGLISH_US,                  "en", "US" },
      96                 :            :     { LANGUAGE_ENGLISH_UK,                  "en", "GB" },
      97                 :            :     { LANGUAGE_ENGLISH_AUS,                 "en", "AU" },
      98                 :            :     { LANGUAGE_ENGLISH_CAN,                 "en", "CA" },
      99                 :            :     { LANGUAGE_FRENCH,                      "fr", "FR" },
     100                 :            :     { LANGUAGE_FRENCH,                      "fr", ""   },
     101                 :            :     { LANGUAGE_GERMAN,                      "de", "DE" },
     102                 :            :     { LANGUAGE_ITALIAN,                     "it", "IT" },
     103                 :            :     { LANGUAGE_DUTCH,                       "nl", "NL" },
     104                 :            :     { LANGUAGE_SPANISH_MODERN,              "es", "ES" },
     105                 :            :     { LANGUAGE_SPANISH_DATED,               "es", "ES" },
     106                 :            :     { LANGUAGE_PORTUGUESE,                  "pt", "PT" },
     107                 :            :     { LANGUAGE_PORTUGUESE_BRAZILIAN,        "pt", "BR" },
     108                 :            :     { LANGUAGE_DANISH,                      "da", "DK" },
     109                 :            :     { LANGUAGE_GREEK,                       "el", "GR" },
     110                 :            :     { LANGUAGE_CHINESE,                     "zh", ""   },
     111                 :            :     { LANGUAGE_CHINESE_SIMPLIFIED,          "zh", "CN" },
     112                 :            :     { LANGUAGE_CHINESE_TRADITIONAL,         "zh", "TW" },
     113                 :            :     { LANGUAGE_CHINESE_HONGKONG,            "zh", "HK" },
     114                 :            :     { LANGUAGE_CHINESE_SINGAPORE,           "zh", "SG" },
     115                 :            :     { LANGUAGE_CHINESE_MACAU,               "zh", "MO" },
     116                 :            :     { LANGUAGE_ENGLISH_HONG_KONG_SAR,       "en", "HK" },
     117                 :            :     { LANGUAGE_JAPANESE,                    "ja", "JP" },
     118                 :            :     { LANGUAGE_KOREAN,                      "ko", "KR" },
     119                 :            :     { LANGUAGE_KOREAN_JOHAB,                "ko", "KR" },
     120                 :            :     { LANGUAGE_USER_KOREAN_NORTH,           "ko", "KP" },
     121                 :            :     { LANGUAGE_SWEDISH,                     "sv", "SE" },
     122                 :            :     { LANGUAGE_SWEDISH_FINLAND,             "sv", "FI" },
     123                 :            :     { LANGUAGE_FINNISH,                     "fi", "FI" },
     124                 :            :     { LANGUAGE_RUSSIAN,                     "ru", "RU" },
     125                 :            :     { LANGUAGE_TATAR,                       "tt", "RU" },
     126                 :            :     { LANGUAGE_ENGLISH_NZ,                  "en", "NZ" },
     127                 :            :     { LANGUAGE_ENGLISH_EIRE,                "en", "IE" },
     128                 :            :     { LANGUAGE_DUTCH_BELGIAN,               "nl", "BE" },
     129                 :            :     { LANGUAGE_FRENCH_BELGIAN,              "fr", "BE" },
     130                 :            :     { LANGUAGE_FRENCH_CANADIAN,             "fr", "CA" },
     131                 :            :     { LANGUAGE_FRENCH_SWISS,                "fr", "CH" },
     132                 :            :     { LANGUAGE_GERMAN_SWISS,                "de", "CH" },
     133                 :            :     { LANGUAGE_GERMAN_AUSTRIAN,             "de", "AT" },
     134                 :            :     { LANGUAGE_ITALIAN_SWISS,               "it", "CH" },
     135                 :            :     { LANGUAGE_ALBANIAN,                    "sq", "AL" },
     136                 :            :     { LANGUAGE_ARABIC_SAUDI_ARABIA,         "ar", "SA" },
     137                 :            :     { LANGUAGE_ARABIC_EGYPT,                "ar", "EG" },
     138                 :            :     { LANGUAGE_ARABIC_UAE,                  "ar", "AE" },
     139                 :            :     { LANGUAGE_ARABIC_IRAQ,                 "ar", "IQ" },
     140                 :            :     { LANGUAGE_ARABIC_LIBYA,                "ar", "LY" },
     141                 :            :     { LANGUAGE_ARABIC_ALGERIA,              "ar", "DZ" },
     142                 :            :     { LANGUAGE_ARABIC_MOROCCO,              "ar", "MA" },
     143                 :            :     { LANGUAGE_ARABIC_TUNISIA,              "ar", "TN" },
     144                 :            :     { LANGUAGE_ARABIC_OMAN,                 "ar", "OM" },
     145                 :            :     { LANGUAGE_ARABIC_YEMEN,                "ar", "YE" },
     146                 :            :     { LANGUAGE_ARABIC_SYRIA,                "ar", "SY" },
     147                 :            :     { LANGUAGE_ARABIC_JORDAN,               "ar", "JO" },
     148                 :            :     { LANGUAGE_ARABIC_LEBANON,              "ar", "LB" },
     149                 :            :     { LANGUAGE_ARABIC_KUWAIT,               "ar", "KW" },
     150                 :            :     { LANGUAGE_ARABIC_BAHRAIN,              "ar", "BH" },
     151                 :            :     { LANGUAGE_ARABIC_QATAR,                "ar", "QA" },
     152                 :            :     { LANGUAGE_USER_ARABIC_CHAD,            "ar", "TD" },
     153                 :            :     { LANGUAGE_USER_ARABIC_COMOROS,         "ar", "KM" },
     154                 :            :     { LANGUAGE_USER_ARABIC_DJIBOUTI,        "ar", "DJ" },
     155                 :            :     { LANGUAGE_USER_ARABIC_ERITREA,         "ar", "ER" },
     156                 :            :     { LANGUAGE_USER_ARABIC_ISRAEL,          "ar", "IL" },
     157                 :            :     { LANGUAGE_USER_ARABIC_MAURITANIA,      "ar", "MR" },
     158                 :            :     { LANGUAGE_USER_ARABIC_PALESTINE,       "ar", "PS" },
     159                 :            :     { LANGUAGE_USER_ARABIC_SOMALIA,         "ar", "SO" },
     160                 :            :     { LANGUAGE_USER_ARABIC_SUDAN,           "ar", "SD" },
     161                 :            :     { LANGUAGE_ARABIC_PRIMARY_ONLY,         "ar", ""   },
     162                 :            :     { LANGUAGE_BASQUE,                      "eu", ""   },
     163                 :            :     { LANGUAGE_BULGARIAN,                   "bg", "BG" },
     164                 :            :     { LANGUAGE_CZECH,                       "cs", "CZ" },
     165                 :            :     { LANGUAGE_CZECH,                       "cz", ""   },
     166                 :            :     { LANGUAGE_ENGLISH_JAMAICA,             "en", "JM" },
     167                 :            :     { LANGUAGE_ENGLISH_CARRIBEAN,           "en", "BS" },   // not 100%, because AG is Bahamas
     168                 :            :     { LANGUAGE_ENGLISH_BELIZE,              "en", "BZ" },
     169                 :            :     { LANGUAGE_ENGLISH_TRINIDAD,            "en", "TT" },
     170                 :            :     { LANGUAGE_ENGLISH_ZIMBABWE,            "en", "ZW" },
     171                 :            :     { LANGUAGE_ENGLISH_INDONESIA,           "en", "ID" },
     172                 :            :     { LANGUAGE_ESTONIAN,                    "et", "EE" },
     173                 :            :     { LANGUAGE_FAEROESE,                    "fo", "FO" },
     174                 :            :     { LANGUAGE_FARSI,                       "fa", "IR" },
     175                 :            :     { LANGUAGE_FRENCH_LUXEMBOURG,           "fr", "LU" },
     176                 :            :     { LANGUAGE_FRENCH_MONACO,               "fr", "MC" },
     177                 :            :     { LANGUAGE_GERMAN_LUXEMBOURG,           "de", "LU" },
     178                 :            :     { LANGUAGE_GERMAN_LIECHTENSTEIN,        "de", "LI" },
     179                 :            :     { LANGUAGE_HEBREW,                      "he", "IL" },   // new: old was "iw"
     180                 :            :     { LANGUAGE_HEBREW,                      "iw", "IL" },   // old: new is "he"
     181                 :            :     { LANGUAGE_HUNGARIAN,                   "hu", "HU" },
     182                 :            :     { LANGUAGE_ICELANDIC,                   "is", "IS" },
     183                 :            :     { LANGUAGE_INDONESIAN,                  "id", "ID" },   // new: old was "in"
     184                 :            :     { LANGUAGE_INDONESIAN,                  "in", "ID" },   // old: new is "id"
     185                 :            :     { LANGUAGE_NORWEGIAN,                   "no", "NO" },
     186                 :            :     { LANGUAGE_NORWEGIAN_BOKMAL,            "nb", "NO" },
     187                 :            :     { LANGUAGE_NORWEGIAN_NYNORSK,           "nn", "NO" },
     188                 :            :     { LANGUAGE_POLISH,                      "pl", "PL" },
     189                 :            :     { LANGUAGE_RHAETO_ROMAN,                "rm", "CH" },
     190                 :            :     { LANGUAGE_ROMANIAN,                    "ro", "RO" },
     191                 :            :     { LANGUAGE_ROMANIAN_MOLDOVA,            "ro", "MD" },
     192                 :            :     { LANGUAGE_SLOVAK,                      "sk", "SK" },
     193                 :            :     { LANGUAGE_SLOVENIAN,                   "sl", "SI" },
     194                 :            :     { LANGUAGE_SPANISH_MEXICAN,             "es", "MX" },
     195                 :            :     { LANGUAGE_SPANISH_GUATEMALA,           "es", "GT" },
     196                 :            :     { LANGUAGE_SPANISH_COSTARICA,           "es", "CR" },
     197                 :            :     { LANGUAGE_SPANISH_PANAMA,              "es", "PA" },
     198                 :            :     { LANGUAGE_SPANISH_DOMINICAN_REPUBLIC,  "es", "DO" },
     199                 :            :     { LANGUAGE_SPANISH_VENEZUELA,           "es", "VE" },
     200                 :            :     { LANGUAGE_SPANISH_COLOMBIA,            "es", "CO" },
     201                 :            :     { LANGUAGE_SPANISH_PERU,                "es", "PE" },
     202                 :            :     { LANGUAGE_SPANISH_ARGENTINA,           "es", "AR" },
     203                 :            :     { LANGUAGE_SPANISH_ECUADOR,             "es", "EC" },
     204                 :            :     { LANGUAGE_SPANISH_CHILE,               "es", "CL" },
     205                 :            :     { LANGUAGE_SPANISH_URUGUAY,             "es", "UY" },
     206                 :            :     { LANGUAGE_SPANISH_PARAGUAY,            "es", "PY" },
     207                 :            :     { LANGUAGE_SPANISH_BOLIVIA,             "es", "BO" },
     208                 :            :     { LANGUAGE_SPANISH_EL_SALVADOR,         "es", "SV" },
     209                 :            :     { LANGUAGE_SPANISH_HONDURAS,            "es", "HN" },
     210                 :            :     { LANGUAGE_SPANISH_NICARAGUA,           "es", "NI" },
     211                 :            :     { LANGUAGE_SPANISH_PUERTO_RICO,         "es", "PR" },
     212                 :            :     { LANGUAGE_SPANISH_UNITED_STATES,       "es", "US" },
     213                 :            :     { LANGUAGE_SPANISH_LATIN_AMERICA,       "es", ""   },
     214                 :            :     { LANGUAGE_TURKISH,                     "tr", "TR" },
     215                 :            :     { LANGUAGE_UKRAINIAN,                   "uk", "UA" },
     216                 :            :     { LANGUAGE_VIETNAMESE,                  "vi", "VN" },
     217                 :            :     { LANGUAGE_LATVIAN,                     "lv", "LV" },
     218                 :            :     { LANGUAGE_MACEDONIAN,                  "mk", "MK" },
     219                 :            :     { LANGUAGE_MALAY,                       "ms", ""   },
     220                 :            :     { LANGUAGE_MALAY_MALAYSIA,              "ms", "MY" },
     221                 :            :     { LANGUAGE_MALAY_BRUNEI_DARUSSALAM,     "ms", "BN" },
     222                 :            :     { LANGUAGE_ENGLISH_MALAYSIA,            "en", "MY" },
     223                 :            :     { LANGUAGE_THAI,                        "th", "TH" },
     224                 :            :     { LANGUAGE_LITHUANIAN,                  "lt", "LT" },
     225                 :            :     { LANGUAGE_LITHUANIAN_CLASSIC,          "lt", "LT" },
     226                 :            :     { LANGUAGE_CROATIAN,                    "hr", "HR" },   // Croatian in Croatia
     227                 :            :     { LANGUAGE_CROATIAN_BOSNIA_HERZEGOVINA, "hr", "BA" },
     228                 :            :     { LANGUAGE_BOSNIAN_LATIN_BOSNIA_HERZEGOVINA,        "bs", "BA" },
     229                 :            : //  { LANGUAGE_BOSNIAN_CYRILLIC_BOSNIA_AND_HERZEGOVINA, "bs", "BA" },   // script codes not supported yet
     230                 :            :     { LANGUAGE_USER_SERBIAN_CYRILLIC_SERBIA,        "sr", "RS" },   // Serbian Cyrillic in Serbia
     231                 :            :     { LANGUAGE_SERBIAN_CYRILLIC,                    "sr", "YU" },   // legacy Serbian Cyrillic in Serbia and Montenegro (former Yugoslavia); kludge, needed to be sr_CS instead, sr_CS not supported by ICU 2.6 (3.4 does)
     232                 :            :     { LANGUAGE_SERBIAN_CYRILLIC,                    "sr", "CS" },   // alias to be able to integrate localizations, rsc needs it
     233                 :            :     { LANGUAGE_USER_SERBIAN_CYRILLIC_MONTENEGRO,    "sr", "ME" },
     234                 :            :     { LANGUAGE_SERBIAN_CYRILLIC_BOSNIA_HERZEGOVINA, "sr", "BA" },
     235                 :            :     { LANGUAGE_SERBIAN,                             "sr", ""   },   // SERBIAN is only LID, MS-LCID not defined (was dupe of CROATIAN)
     236                 :            :     { LANGUAGE_USER_SERBIAN_LATIN_SERBIA,           "sh", "RS" },   // Serbian Latin in Serbia; kludge, needed to be sr_Latn_RS instead, script codes not supported yet
     237                 :            :     { LANGUAGE_SERBIAN_LATIN,                       "sh", "YU" },   // legacy Serbian Latin in Serbia and Montenegro (former Yugoslavia); kludge, needed to be sr_Latn_CS instead, script codes not supported yet
     238                 :            :     { LANGUAGE_SERBIAN_LATIN,                       "sh", "CS" },   // Serbian Latin in Serbia and Montenegro; kludge, needed to be sr_Latn_CS instead, script codes not supported yet
     239                 :            :     { LANGUAGE_USER_SERBIAN_LATIN_MONTENEGRO,       "sh", "ME" },   // Serbian Latin in Montenegro; kludge, needed to be sr_Latn_ME instead, script codes not supported yet
     240                 :            :     { LANGUAGE_SERBIAN_LATIN_BOSNIA_HERZEGOVINA,    "sh", "BA" },
     241                 :            :     { LANGUAGE_SERBIAN_LATIN_NEUTRAL,               "sh", ""   },   // kludge, needed to be sr_Latn instead, script codes not supported yet
     242                 :            :     { LANGUAGE_ARMENIAN,                    "hy", "AM" },
     243                 :            :     { LANGUAGE_AZERI,                       "az", ""   },
     244                 :            :     { LANGUAGE_AZERI_LATIN,                 "az", "AZ" },
     245                 :            : //  { LANGUAGE_AZERI_CYRILLIC,              "az", "AZ" },   // script codes not supported yet
     246                 :            :     { LANGUAGE_UZBEK_LATIN,                 "uz", "UZ" },
     247                 :            : //  { LANGUAGE_UZBEK_CYRILLIC,              "uz", "UZ" },   // script codes not supported yet
     248                 :            :     { LANGUAGE_BENGALI_BANGLADESH,          "bn", "BD" },
     249                 :            :     { LANGUAGE_BENGALI,                     "bn", "IN" },
     250                 :            :     { LANGUAGE_BURMESE,                     "my", "MM" },
     251                 :            :     { LANGUAGE_KAZAK,                       "kk", "KZ" },
     252                 :            :     { LANGUAGE_ENGLISH_INDIA,               "en", "IN" },
     253                 :            :     { LANGUAGE_URDU,                        "ur", ""   },
     254                 :            :     { LANGUAGE_URDU_INDIA,                  "ur", "IN" },
     255                 :            :     { LANGUAGE_URDU_PAKISTAN,               "ur", "PK" },
     256                 :            :     { LANGUAGE_HINDI,                       "hi", "IN" },
     257                 :            :     { LANGUAGE_GUJARATI,                    "gu", "IN" },
     258                 :            :     { LANGUAGE_KANNADA,                     "kn", "IN" },
     259                 :            :     { LANGUAGE_ASSAMESE,                    "as", "IN" },
     260                 :            :     { LANGUAGE_KASHMIRI,                    "ks", ""   },
     261                 :            :     { LANGUAGE_KASHMIRI_INDIA,              "ks", "IN" },
     262                 :            :     { LANGUAGE_MALAYALAM,                   "ml", "IN" },
     263                 :            :     { LANGUAGE_MANIPURI,                   "mni", "IN" },
     264                 :            :     { LANGUAGE_MARATHI,                     "mr", "IN" },
     265                 :            :     { LANGUAGE_KONKANI,                    "kok", "IN" },
     266                 :            :     { LANGUAGE_NEPALI,                      "ne", "NP" },
     267                 :            :     { LANGUAGE_NEPALI_INDIA,                "ne", "IN" },
     268                 :            :     { LANGUAGE_ORIYA,                       "or", "IN" },
     269                 :            :     { LANGUAGE_PUNJABI,                     "pa", "IN" },
     270                 :            :     { LANGUAGE_SANSKRIT,                    "sa", "IN" },
     271                 :            :     { LANGUAGE_SINDHI,                      "sd", "IN" },
     272                 :            :     { LANGUAGE_TAMIL,                       "ta", "IN" },
     273                 :            :     { LANGUAGE_TELUGU,                      "te", "IN" },
     274                 :            :     { LANGUAGE_PUNJABI_PAKISTAN,           "lah", "PK" },   // preferring "lah" over "pa" for Western Punjabi, see http://www.ethnologue.com/show_language.asp?code=PNB
     275                 :            :     { LANGUAGE_PUNJABI_PAKISTAN,            "pa", "PK" },
     276                 :            :     { LANGUAGE_SINDHI_PAKISTAN,             "sd", "PK" },
     277                 :            :     { LANGUAGE_BELARUSIAN,                  "be", "BY" },
     278                 :            :     { LANGUAGE_CATALAN,                     "ca", "ES" },   // Spain (default)
     279                 :            :     { LANGUAGE_CATALAN,                     "ca", "AD" },   // Andorra
     280                 :            :     { LANGUAGE_USER_CATALAN_VALENCIAN,                     "ca", "XV" },   // XV: ISO 3166 user-assigned; workaround for UI localization only, do not use in document content!
     281                 :            :     { LANGUAGE_CATALAN,                    "qcv", "ES" },   // qcv: ISO 639-3 reserved-for-local-use; UI localization quirk only, do not use in document content!
     282                 :            : //    { LANGUAGE_USER_CATALAN_VALENCIAN,      "ca", "ES" },   // In case MS format files escaped into the wild, map them back.
     283                 :            :     { LANGUAGE_FRENCH_CAMEROON,             "fr", "CM" },
     284                 :            :     { LANGUAGE_FRENCH_COTE_D_IVOIRE,        "fr", "CI" },
     285                 :            :     { LANGUAGE_FRENCH_MALI,                 "fr", "ML" },
     286                 :            :     { LANGUAGE_FRENCH_SENEGAL,              "fr", "SN" },
     287                 :            :     { LANGUAGE_FRENCH_ZAIRE,                "fr", "CD" },   // Democratic Republic Of Congo
     288                 :            :     { LANGUAGE_FRENCH_MOROCCO,              "fr", "MA" },
     289                 :            :     { LANGUAGE_FRENCH_REUNION,              "fr", "RE" },
     290                 :            :     { LANGUAGE_FRENCH_NORTH_AFRICA,         "fr", ""   },
     291                 :            :     { LANGUAGE_FRENCH_WEST_INDIES,          "fr", ""   },   // unknown ISO country code
     292                 :            :     { LANGUAGE_FRISIAN_NETHERLANDS,         "fy", "NL" },
     293                 :            :     { LANGUAGE_GAELIC_IRELAND,              "ga", "IE" },
     294                 :            :     { LANGUAGE_GAELIC_SCOTLAND,             "gd", "GB" },
     295                 :            :     { LANGUAGE_GALICIAN,                    "gl", "ES" },
     296                 :            :     { LANGUAGE_GEORGIAN,                    "ka", "GE" },
     297                 :            :     { LANGUAGE_KHMER,                       "km", "KH" },
     298                 :            :     { LANGUAGE_KIRGHIZ,                     "ky", "KG" },
     299                 :            :     { LANGUAGE_LAO,                         "lo", "LA" },
     300                 :            :     { LANGUAGE_MALTESE,                     "mt", "MT" },
     301                 :            :     { LANGUAGE_MONGOLIAN,                   "mn", "MN" },   // Cyrillic script
     302                 :            :     { LANGUAGE_MONGOLIAN_MONGOLIAN,         "mn", "MN" },
     303                 :            :     { LANGUAGE_RUSSIAN_MOLDOVA,             "mo", "MD" },
     304                 :            :     { LANGUAGE_SWAHILI,                     "sw", "KE" },
     305                 :            :     { LANGUAGE_USER_SWAHILI_TANZANIA,       "sw", "TZ" },
     306                 :            :     { LANGUAGE_TAJIK,                       "tg", "TJ" },
     307                 :            :     { LANGUAGE_TIBETAN,                     "bo", "CN" },   // CN politically correct?
     308                 :            :     { LANGUAGE_DZONGKHA,                    "dz", "BT" },
     309                 :            :     { LANGUAGE_TURKMEN,                     "tk", "TM" },
     310                 :            :     { LANGUAGE_WELSH,                       "cy", "GB" },
     311                 :            :     { LANGUAGE_SESOTHO,                     "st", "ZA" },
     312                 :            :     { LANGUAGE_SEPEDI,                     "nso", "ZA" },
     313                 :            :     { LANGUAGE_SEPEDI,                      "ns", "ZA" },   // fake "ns" for compatibility with existing OOo1.1.x localization to be able to read those documents
     314                 :            :     { LANGUAGE_TSONGA,                      "ts", "ZA" },
     315                 :            :     { LANGUAGE_TSWANA,                      "tn", "ZA" },
     316                 :            :     { LANGUAGE_ENGLISH_SAFRICA,             "en", "ZA" },
     317                 :            :     { LANGUAGE_AFRIKAANS,                   "af", "ZA" },
     318                 :            :     { LANGUAGE_VENDA,                       "ve", "ZA" },   // default 639-1
     319                 :            :     { LANGUAGE_VENDA,                      "ven", "ZA" },   // 639-2 may have been used temporarily since 2004-07-23
     320                 :            :     { LANGUAGE_XHOSA,                       "xh", "ZA" },
     321                 :            :     { LANGUAGE_ZULU,                        "zu", "ZA" },
     322                 :            :     { LANGUAGE_QUECHUA_ECUADOR,             "qu", "EC" },
     323                 :            :     { LANGUAGE_QUECHUA_PERU,                "qu", "PE" },
     324                 :            :     { LANGUAGE_QUECHUA_BOLIVIA,             "qu", "BO" },   // macro: quh-BO, qul-BO
     325                 :            :     { LANGUAGE_PASHTO,                      "ps", "AF" },
     326                 :            :     { LANGUAGE_OROMO,                       "om", "ET" },
     327                 :            :     { LANGUAGE_DHIVEHI,                     "dv", "MV" },
     328                 :            :     { LANGUAGE_UIGHUR_CHINA,                "ug", "CN" },
     329                 :            :     { LANGUAGE_TIGRIGNA_ETHIOPIA,           "ti", "ET" },
     330                 :            :     { LANGUAGE_TIGRIGNA_ERITREA,            "ti", "ER" },
     331                 :            :     { LANGUAGE_AMHARIC_ETHIOPIA,            "am", "ET" },
     332                 :            :     { LANGUAGE_GUARANI_PARAGUAY,           "gug", "PY" },
     333                 :            :     { LANGUAGE_HAWAIIAN_UNITED_STATES,     "haw", "US" },
     334                 :            :     { LANGUAGE_EDO,                        "bin", "NG" },
     335                 :            :     { LANGUAGE_FULFULDE_NIGERIA,            "ff", "NG" },
     336                 :            :     { LANGUAGE_HAUSA_NIGERIA,               "ha", "NG" },
     337                 :            :     { LANGUAGE_USER_HAUSA_GHANA,            "ha", "GH" },
     338                 :            :     { LANGUAGE_IGBO_NIGERIA,                "ig", "NG" },
     339                 :            :     { LANGUAGE_KANURI_NIGERIA,              "kr", "NG" },
     340                 :            :     { LANGUAGE_YORUBA,                      "yo", "NG" },
     341                 :            :     { LANGUAGE_SOMALI,                      "so", "SO" },
     342                 :            :     { LANGUAGE_PAPIAMENTU,                 "pap", "AN" },
     343                 :            :     { LANGUAGE_USER_PAPIAMENTU_ARUBA,      "pap", "AW" },
     344                 :            :     { LANGUAGE_USER_PAPIAMENTU_CURACAO,    "pap", "CW" },
     345                 :            :     { LANGUAGE_USER_PAPIAMENTU_BONAIRE,    "pap", "BQ" },
     346                 :            :     { LANGUAGE_ENGLISH_SINGAPORE,           "en", "SG" },
     347                 :            :     { LANGUAGE_USER_YIDDISH_US,             "yi", "US" },
     348                 :            :     { LANGUAGE_YIDDISH,                     "yi", "IL" },   // new: old was "ji"
     349                 :            :     { LANGUAGE_YIDDISH,                     "ji", "IL" },   // old: new is "yi"
     350                 :            :     { LANGUAGE_SYRIAC,                     "syr", "TR" },   // "TR" according to http://www.ethnologue.com/show_language.asp?code=SYC
     351                 :            :     { LANGUAGE_SINHALESE_SRI_LANKA,         "si", "LK" },
     352                 :            :     { LANGUAGE_CHEROKEE_UNITED_STATES,     "chr", "US" },
     353                 :            :     { LANGUAGE_INUKTITUT_LATIN_CANADA,      "iu", "CA" },
     354                 :            : //  { LANGUAGE_INUKTITUT_SYLLABICS_CANADA,  "iu", "CA" },   // script codes not supported yet
     355                 :            :     { LANGUAGE_SAMI_NORTHERN_NORWAY,        "se", "NO" },
     356                 :            :     { LANGUAGE_SAMI_INARI,                 "smn", "FI" },
     357                 :            :     { LANGUAGE_SAMI_LULE_NORWAY,           "smj", "NO" },
     358                 :            :     { LANGUAGE_SAMI_LULE_SWEDEN,           "smj", "SE" },
     359                 :            :     { LANGUAGE_SAMI_NORTHERN_FINLAND,       "se", "FI" },
     360                 :            :     { LANGUAGE_SAMI_NORTHERN_SWEDEN,        "se", "SE" },
     361                 :            :     { LANGUAGE_SAMI_SKOLT,                 "sms", "FI" },
     362                 :            :     { LANGUAGE_SAMI_SOUTHERN_NORWAY,       "sma", "NO" },
     363                 :            :     { LANGUAGE_SAMI_SOUTHERN_SWEDEN,       "sma", "SE" },
     364                 :            :     { LANGUAGE_USER_SAMI_KILDIN_RUSSIA,    "sjd", "RU" },
     365                 :            :     { LANGUAGE_MAPUDUNGUN_CHILE,           "arn", "CL" },
     366                 :            :     { LANGUAGE_CORSICAN_FRANCE,             "co", "FR" },
     367                 :            :     { LANGUAGE_ALSATIAN_FRANCE,            "gsw", "FR" },   // in fact 'gsw' is Schwyzerduetsch (Swiss German), which is a dialect of Alemannic German, as is Alsatian. They aren't distinct languages and share this code.
     368                 :            :     { LANGUAGE_YAKUT_RUSSIA,               "sah", "RU" },
     369                 :            :     { LANGUAGE_MOHAWK_CANADA,              "moh", "CA" },
     370                 :            :     { LANGUAGE_BASHKIR_RUSSIA,              "ba", "RU" },
     371                 :            :     { LANGUAGE_KICHE_GUATEMALA,            "qut", "GT" },
     372                 :            :     { LANGUAGE_DARI_AFGHANISTAN,           "gbz", "AF" },
     373                 :            :     { LANGUAGE_WOLOF_SENEGAL,               "wo", "SN" },
     374                 :            :     { LANGUAGE_FILIPINO,                   "fil", "PH" },
     375                 :            :     { LANGUAGE_USER_TAGALOG,                "tl", "PH" },
     376                 :            :     { LANGUAGE_ENGLISH_PHILIPPINES,         "en", "PH" },
     377                 :            : //  { LANGUAGE_IBIBIO_NIGERIA,             "nic", "NG" },   // ISO "nic" is only a collective language code
     378                 :            :     { LANGUAGE_YI,                          "ii", "CN" },
     379                 :            :     { LANGUAGE_TAMAZIGHT_LATIN,            "kab", "DZ" },   // In practice Kabyle is the language used for this
     380                 :            :     { LANGUAGE_OBSOLETE_USER_KABYLE,       "kab", "DZ" },
     381                 :            :     { LANGUAGE_TAMAZIGHT_LATIN,            "ber", "DZ" },   // In practice Algeria has standardized on Kabyle as the member of the "ber" collective which gets used there.
     382                 :            :     { LANGUAGE_TAMAZIGHT_TIFINAGH,         "ber", "MA" },   // Morocco is officially using Tifinagh for its Berber languages so store it to distinguish explicitly from LANGUAGE_TAMAZIGHT_LATIN, even though as a collective language its not of much use
     383                 :            : //  { LANGUAGE_TAMAZIGHT_ARABIC,           "ber", ""   },   // ISO "ber" only collective!
     384                 :            :     { LANGUAGE_LATIN,                       "la", "VA" },
     385                 :            :     { LANGUAGE_OBSOLETE_USER_LATIN,         "la", "VA" },
     386                 :            :     { LANGUAGE_USER_ESPERANTO,              "eo", ""   },
     387                 :            :     { LANGUAGE_USER_INTERLINGUA,            "ia", ""   },
     388                 :            :     { LANGUAGE_MAORI_NEW_ZEALAND,           "mi", "NZ" },
     389                 :            :     { LANGUAGE_OBSOLETE_USER_MAORI,         "mi", "NZ" },
     390                 :            :     { LANGUAGE_KINYARWANDA_RWANDA,          "rw", "RW" },
     391                 :            :     { LANGUAGE_OBSOLETE_USER_KINYARWANDA,   "rw", "RW" },
     392                 :            :     { LANGUAGE_UPPER_SORBIAN_GERMANY,      "hsb", "DE" },   // MS maps this to 'wen-DE', which is nonsense. 'wen' is a collective language code, 'WEN' is a SIL code, see http://www.ethnologue.com/14/show_iso639.asp?code=wen and http://www.ethnologue.com/14/show_language.asp?code=WEN
     393                 :            :     { LANGUAGE_OBSOLETE_USER_UPPER_SORBIAN,"hsb", "DE" },
     394                 :            :     { LANGUAGE_LOWER_SORBIAN_GERMANY,      "dsb", "DE" },   // MS maps this to 'wee-DE', which is nonsense. 'WEE' is a SIL code, see http://www.ethnologue.com/14/show_language.asp?code=WEE
     395                 :            :     { LANGUAGE_OBSOLETE_USER_LOWER_SORBIAN,"dsb", "DE" },
     396                 :            :     { LANGUAGE_OCCITAN_FRANCE,              "oc", "FR" },
     397                 :            :     { LANGUAGE_OBSOLETE_USER_OCCITAN,       "oc", "FR" },
     398                 :            :     { LANGUAGE_USER_KURDISH_TURKEY,         "ku", "TR" },
     399                 :            :     { LANGUAGE_USER_KURDISH_SYRIA,          "ku", "SY" },
     400                 :            :     { LANGUAGE_USER_KURDISH_IRAQ,           "ku", "IQ" },
     401                 :            :     { LANGUAGE_USER_KURDISH_IRAN,           "ku", "IR" },
     402                 :            :     { LANGUAGE_USER_SARDINIAN,              "sc", "IT" },   // macrolanguage code
     403                 :            :     { LANGUAGE_USER_SARDINIAN_CAMPIDANESE, "sro", "IT" },
     404                 :            :     { LANGUAGE_USER_SARDINIAN_GALLURESE,   "sdn", "IT" },
     405                 :            :     { LANGUAGE_USER_SARDINIAN_LOGUDORESE,  "src", "IT" },
     406                 :            :     { LANGUAGE_USER_SARDINIAN_SASSARESE,   "sdc", "IT" },
     407                 :            :     { LANGUAGE_BRETON_FRANCE,               "br", "FR" },
     408                 :            :     { LANGUAGE_OBSOLETE_USER_BRETON,        "br", "FR" },
     409                 :            :     { LANGUAGE_KALAALLISUT_GREENLAND,       "kl", "GL" },
     410                 :            :     { LANGUAGE_OBSOLETE_USER_KALAALLISUT,   "kl", "GL" },
     411                 :            :     { LANGUAGE_USER_SWAZI,                  "ss", "ZA" },
     412                 :            :     { LANGUAGE_USER_NDEBELE_SOUTH,          "nr", "ZA" },
     413                 :            :     { LANGUAGE_USER_TSWANA_BOTSWANA,        "tn", "BW" },
     414                 :            :     { LANGUAGE_USER_MOORE,                 "mos", "BF" },
     415                 :            :     { LANGUAGE_USER_BAMBARA,                "bm", "ML" },
     416                 :            :     { LANGUAGE_USER_AKAN,                   "ak", "GH" },
     417                 :            :     { LANGUAGE_LUXEMBOURGISH_LUXEMBOURG,    "lb", "LU" },
     418                 :            :     { LANGUAGE_OBSOLETE_USER_LUXEMBOURGISH, "lb", "LU" },
     419                 :            :     { LANGUAGE_USER_FRIULIAN,              "fur", "IT" },
     420                 :            :     { LANGUAGE_USER_FIJIAN,                 "fj", "FJ" },
     421                 :            :     { LANGUAGE_USER_AFRIKAANS_NAMIBIA,      "af", "NA" },
     422                 :            :     { LANGUAGE_USER_ENGLISH_NAMIBIA,        "en", "NA" },
     423                 :            :     { LANGUAGE_USER_WALLOON,                "wa", "BE" },
     424                 :            :     { LANGUAGE_USER_COPTIC,                "cop", "EG" },
     425                 :            :     { LANGUAGE_USER_GASCON,                "gsc", "FR" },
     426                 :            :     { LANGUAGE_USER_GERMAN_BELGIUM,         "de", "BE" },
     427                 :            :     { LANGUAGE_USER_CHUVASH,                "cv", "RU" },
     428                 :            :     { LANGUAGE_USER_EWE_GHANA,              "ee", "GH" },
     429                 :            :     { LANGUAGE_USER_ENGLISH_GHANA,          "en", "GH" },
     430                 :            :     { LANGUAGE_USER_SANGO,                  "sg", "CF" },
     431                 :            :     { LANGUAGE_USER_GANDA,                  "lg", "UG" },
     432                 :            :     { LANGUAGE_USER_LINGALA_DRCONGO,        "ln", "CD" },
     433                 :            :     { LANGUAGE_USER_LOW_GERMAN,            "nds", "DE" },
     434                 :            :     { LANGUAGE_USER_HILIGAYNON,            "hil", "PH" },
     435                 :            :     { LANGUAGE_USER_ENGLISH_MALAWI,         "en", "MW" },   /* en default for MW */
     436                 :            :     { LANGUAGE_USER_NYANJA,                 "ny", "MW" },
     437                 :            :     { LANGUAGE_USER_KASHUBIAN,             "csb", "PL" },
     438                 :            :     { LANGUAGE_USER_SPANISH_CUBA,           "es", "CU" },
     439                 :            :     { LANGUAGE_USER_QUECHUA_NORTH_BOLIVIA, "qul", "BO" },
     440                 :            :     { LANGUAGE_USER_QUECHUA_SOUTH_BOLIVIA, "quh", "BO" },
     441                 :            :     { LANGUAGE_USER_BODO_INDIA,            "brx", "IN" },
     442                 :            :     { LANGUAGE_USER_DOGRI_INDIA,           "dgo", "IN" },
     443                 :            :     { LANGUAGE_USER_MAITHILI_INDIA,        "mai", "IN" },
     444                 :            :     { LANGUAGE_USER_SANTALI_INDIA,         "sat", "IN" },
     445                 :            :     { LANGUAGE_USER_TETUN,                 "tet", "ID" },
     446                 :            :     { LANGUAGE_USER_TETUN_TIMOR_LESTE,     "tet", "TL" },
     447                 :            :     { LANGUAGE_USER_TOK_PISIN,             "tpi", "PG" },
     448                 :            :     { LANGUAGE_USER_SHUSWAP,               "shs", "CA" },
     449                 :            :     { LANGUAGE_USER_ANCIENT_GREEK,         "grc", "GR" },
     450                 :            :     { LANGUAGE_USER_ASTURIAN,              "ast", "ES" },
     451                 :            :     { LANGUAGE_USER_LATGALIAN,             "ltg", "LV" },
     452                 :            :     { LANGUAGE_USER_MAORE,                 "swb", "YT" },
     453                 :            :     { LANGUAGE_USER_BUSHI,                 "buc", "YT" },
     454                 :            :     { LANGUAGE_USER_TAHITIAN,               "ty", "PF" },
     455                 :            :     { LANGUAGE_USER_MALAGASY_PLATEAU,      "plt", "MG" },
     456                 :            :     { LANGUAGE_USER_MALAGASY_PLATEAU,       "mg", "MG" },
     457                 :            :     { LANGUAGE_USER_BAFIA,                 "ksf", "CM" },
     458                 :            :     { LANGUAGE_USER_GIKUYU,                 "ki", "KE" },
     459                 :            :     { LANGUAGE_USER_RUSYN_UKRAINE,         "rue", "UA" },
     460                 :            :     { LANGUAGE_USER_RUSYN_SLOVAKIA,        "rue", "SK" },
     461                 :            :     { LANGUAGE_USER_LIMBU,                 "lif", "NP" },
     462                 :            :     { LANGUAGE_USER_LOJBAN,                "jbo", ""   },
     463                 :            :     { LANGUAGE_USER_HAITIAN,                "ht", "HT" },
     464                 :            :     { LANGUAGE_FRENCH_HAITI,                "fr", "HT" },
     465                 :            :     { LANGUAGE_USER_BEEMBE,                "beq", "CG" },
     466                 :            :     { LANGUAGE_USER_BEKWEL,                "bkw", "CG" },
     467                 :            :     { LANGUAGE_USER_KITUBA,                "mkw", "CG" },
     468                 :            :     { LANGUAGE_USER_LARI,                  "ldi", "CG" },
     469                 :            :     { LANGUAGE_USER_MBOCHI,                "mdw", "CG" },
     470                 :            :     { LANGUAGE_USER_TEKE_EBOO,             "ebo", "CG" },
     471                 :            :     { LANGUAGE_USER_TEKE_IBALI,            "tek", "CG" },
     472                 :            :     { LANGUAGE_USER_TEKE_TYEE,             "tyx", "CG" },
     473                 :            :     { LANGUAGE_USER_VILI,                  "vif", "CG" },
     474                 :            :     { LANGUAGE_USER_PORTUGUESE_ANGOLA,      "pt", "AO" },
     475                 :            :     { LANGUAGE_USER_MANX,                   "gv", "GB" },
     476                 :            :     { LANGUAGE_USER_ARAGONESE,              "an", "ES" },
     477                 :            :     { LANGUAGE_USER_KEYID,                 "qtz", ""   },   // key id pseudolanguage used for UI testing
     478                 :            :     { LANGUAGE_USER_PALI_LATIN,            "pli", ""   },   // Pali with Latin script
     479                 :            :     { LANGUAGE_USER_KYRGYZ_CHINA,           "ky", "CN" },
     480                 :            :     { LANGUAGE_USER_KOMI_ZYRIAN,           "kpv", "RU" },
     481                 :            :     { LANGUAGE_USER_KOMI_PERMYAK,          "koi", "RU" },
     482                 :            :     { LANGUAGE_USER_PITJANTJATJARA,        "pjt", "AU" },
     483                 :            :     { LANGUAGE_USER_ERZYA,                 "myv", "RU" },
     484                 :            :     { LANGUAGE_USER_MARI_MEADOW,           "mhr", "RU" },
     485                 :            :     { LANGUAGE_NONE,                       "zxx", ""   },   // added to ISO 639-2 on 2006-01-11: Used to declare the absence of linguistic information
     486                 :            :     { LANGUAGE_DONTKNOW,                    "",   ""   }    // marks end of table
     487                 :            : };
     488                 :            : 
     489                 :            : static MsLangId::IsoLangEntry aLastResortFallbackEntry =
     490                 :            : { LANGUAGE_ENGLISH_US, "en", "US" };
     491                 :            : 
     492                 :            : // -----------------------------------------------------------------------
     493                 :            : 
     494                 :            : // In this table are the countries which should mapped to a specific
     495                 :            : // english language
     496                 :            : static IsoLangEngEntry const aImplIsoLangEngEntries[] =
     497                 :            : {
     498                 :            :     { LANGUAGE_ENGLISH_UK,                  "AO" },         // Angola
     499                 :            :     { LANGUAGE_ENGLISH_UK,                  "BJ" },         // Benin
     500                 :            :     { LANGUAGE_ENGLISH_UK,                  "BW" },         // Botswana
     501                 :            :     { LANGUAGE_ENGLISH_UK,                  "BI" },         // Burundi
     502                 :            :     { LANGUAGE_ENGLISH_UK,                  "CM" },         // Cameroon
     503                 :            :     { LANGUAGE_ENGLISH_UK,                  "GA" },         // Gabon
     504                 :            :     { LANGUAGE_ENGLISH_UK,                  "GM" },         // Gambia
     505                 :            :     { LANGUAGE_ENGLISH_UK,                  "GH" },         // Ghana
     506                 :            :     { LANGUAGE_ENGLISH_UK,                  "GN" },         // Guinea
     507                 :            :     { LANGUAGE_ENGLISH_UK,                  "LS" },         // Lesotho
     508                 :            :     { LANGUAGE_ENGLISH_UK,                  "MW" },         // Malawi
     509                 :            :     { LANGUAGE_ENGLISH_UK,                  "MT" },         // Malta
     510                 :            :     { LANGUAGE_ENGLISH_UK,                  "NA" },         // Namibia
     511                 :            :     { LANGUAGE_ENGLISH_UK,                  "NG" },         // Nigeria
     512                 :            :     { LANGUAGE_ENGLISH_UK,                  "UG" },         // Uganda
     513                 :            :     { LANGUAGE_ENGLISH_UK,                  "ZM" },         // Zambia
     514                 :            :     { LANGUAGE_ENGLISH_UK,                  "ZW" },         // Zimbabwe
     515                 :            :     { LANGUAGE_ENGLISH_UK,                  "SZ" },         // Swaziland
     516                 :            :     { LANGUAGE_ENGLISH_UK,                  "NG" },         // Sierra Leone
     517                 :            :     { LANGUAGE_ENGLISH_UK,                  "KN" },         // Saint Kitts and Nevis
     518                 :            :     { LANGUAGE_ENGLISH_UK,                  "SH" },         // St. Helena
     519                 :            :     { LANGUAGE_ENGLISH_UK,                  "IO" },         // British Indian Oceanic Territory
     520                 :            :     { LANGUAGE_ENGLISH_UK,                  "FK" },         // Falkland Islands
     521                 :            :     { LANGUAGE_ENGLISH_UK,                  "GI" },         // Gibraltar
     522                 :            :     { LANGUAGE_ENGLISH_UK,                  "KI" },         // Kiribati
     523                 :            :     { LANGUAGE_ENGLISH_UK,                  "VG" },         // Virgin Islands
     524                 :            :     { LANGUAGE_ENGLISH_UK,                  "MU" },         // Mauritius
     525                 :            :     { LANGUAGE_ENGLISH_UK,                  "FJ" },         // Fiji
     526                 :            :     { LANGUAGE_ENGLISH_US,                  "KI" },         // Kiribati
     527                 :            :     { LANGUAGE_ENGLISH_US,                  "LR" },         // Liberia
     528                 :            :     { LANGUAGE_ENGLISH_US,                  "GU" },         // Guam
     529                 :            :     { LANGUAGE_ENGLISH_US,                  "MH" },         // Marshall Islands
     530                 :            :     { LANGUAGE_ENGLISH_US,                  "PW" },         // Palau
     531                 :            :     { LANGUAGE_ENGLISH_CARRIBEAN,           "AI" },         // Anguilla
     532                 :            :     { LANGUAGE_ENGLISH_CARRIBEAN,           "AG" },         // Antigua and Barbuda
     533                 :            :     { LANGUAGE_ENGLISH_CARRIBEAN,           "BS" },         // Bahamas
     534                 :            :     { LANGUAGE_ENGLISH_CARRIBEAN,           "BB" },         // Barbedos
     535                 :            :     { LANGUAGE_ENGLISH_CARRIBEAN,           "BM" },         // Bermuda
     536                 :            :     { LANGUAGE_ENGLISH_CARRIBEAN,           "KY" },         // Cayman Islands
     537                 :            :     { LANGUAGE_ENGLISH_CARRIBEAN,           "GD" },         // Grenada
     538                 :            :     { LANGUAGE_ENGLISH_CARRIBEAN,           "DM" },         // Dominica
     539                 :            :     { LANGUAGE_ENGLISH_CARRIBEAN,           "HT" },         // Haiti
     540                 :            :     { LANGUAGE_ENGLISH_CARRIBEAN,           "MS" },         // Montserrat
     541                 :            :     { LANGUAGE_ENGLISH_CARRIBEAN,           "FM" },         // Micronesia
     542                 :            :     { LANGUAGE_ENGLISH_CARRIBEAN,           "VC" },         // St. Vincent / Grenadines
     543                 :            :     { LANGUAGE_ENGLISH_CARRIBEAN,           "LC" },         // Saint Lucia
     544                 :            :     { LANGUAGE_ENGLISH_CARRIBEAN,           "TC" },         // Turks & Caicos Islands
     545                 :            :     { LANGUAGE_ENGLISH_CARRIBEAN,           "GY" },         // Guyana
     546                 :            :     { LANGUAGE_ENGLISH_CARRIBEAN,           "TT" },         // Trinidad and Tobago
     547                 :            :     { LANGUAGE_ENGLISH_AUS,                 "CX" },         // Christmas Islands
     548                 :            :     { LANGUAGE_ENGLISH_AUS,                 "CC" },         // Cocos (Keeling) Islands
     549                 :            :     { LANGUAGE_ENGLISH_AUS,                 "NF" },         // Norfolk Island
     550                 :            :     { LANGUAGE_ENGLISH_AUS,                 "PG" },         // Papua New Guinea
     551                 :            :     { LANGUAGE_ENGLISH_AUS,                 "SB" },         // Solomon Islands
     552                 :            :     { LANGUAGE_ENGLISH_AUS,                 "TV" },         // Tuvalu
     553                 :            :     { LANGUAGE_ENGLISH_AUS,                 "NR" },         // Nauru
     554                 :            :     { LANGUAGE_ENGLISH_NZ,                  "CK" },         // Cook Islands
     555                 :            :     { LANGUAGE_ENGLISH_NZ,                  "NU" },         // Niue
     556                 :            :     { LANGUAGE_ENGLISH_NZ,                  "TK" },         // Tokelau
     557                 :            :     { LANGUAGE_ENGLISH_NZ,                  "TO" },         // Tonga
     558                 :            :     { LANGUAGE_DONTKNOW,                    ""   }          // marks end of table
     559                 :            : };
     560                 :            : 
     561                 :            : // -----------------------------------------------------------------------
     562                 :            : 
     563                 :            : static IsoLangNoneStdEntry const aImplIsoNoneStdLangEntries[] =
     564                 :            : {
     565                 :            :     { LANGUAGE_NORWEGIAN_BOKMAL,            "no", "BOK"      }, // registered subtags for "no" in rfc1766
     566                 :            :     { LANGUAGE_NORWEGIAN_NYNORSK,           "no", "NYN"      }, // registered subtags for "no" in rfc1766
     567                 :            :     { LANGUAGE_SERBIAN_LATIN,               "sr", "latin"    },
     568                 :            :     { LANGUAGE_SERBIAN_CYRILLIC,            "sr", "cyrillic" },
     569                 :            :     { LANGUAGE_AZERI_LATIN,                 "az", "latin"    },
     570                 :            :     { LANGUAGE_AZERI_CYRILLIC,              "az", "cyrillic" },
     571                 :            :     { LANGUAGE_DONTKNOW,                    "",   ""         }  // marks end of table
     572                 :            : };
     573                 :            : 
     574                 :            : // -----------------------------------------------------------------------
     575                 :            : 
     576                 :            : // in this table are only names to find the best language
     577                 :            : static IsoLangNoneStdEntry const aImplIsoNoneStdLangEntries2[] =
     578                 :            : {
     579                 :            :     { LANGUAGE_NORWEGIAN_BOKMAL,            "no", "bokmaal"  },
     580                 :            :     { LANGUAGE_NORWEGIAN_BOKMAL,            "no", "bokmal"   },
     581                 :            :     { LANGUAGE_NORWEGIAN_NYNORSK,           "no", "nynorsk"  },
     582                 :            :     { LANGUAGE_DONTKNOW,                    "",   ""         }  // marks end of table
     583                 :            : };
     584                 :            : 
     585                 :            : // -----------------------------------------------------------------------
     586                 :            : 
     587                 :            : // in this table are only names to find the best language
     588                 :            : static IsoLangOtherEntry const aImplOtherEntries[] =
     589                 :            : {
     590                 :            :     { LANGUAGE_ENGLISH_US,                  "c"              },
     591                 :            :     { LANGUAGE_CHINESE,                     "chinese"        },
     592                 :            :     { LANGUAGE_GERMAN,                      "german"         },
     593                 :            :     { LANGUAGE_JAPANESE,                    "japanese"       },
     594                 :            :     { LANGUAGE_KOREAN,                      "korean"         },
     595                 :            :     { LANGUAGE_ENGLISH_US,                  "posix"          },
     596                 :            :     { LANGUAGE_CHINESE_TRADITIONAL,         "tchinese"       },
     597                 :            :     { LANGUAGE_DONTKNOW,                    NULL             }  // marks end of table
     598                 :            : };
     599                 :            : 
     600                 :            : // =======================================================================
     601                 :            : 
     602                 :            : // static
     603                 :     916940 : void MsLangId::convertLanguageToIsoNames( LanguageType nLang,
     604                 :            :         rtl::OUString& rLangStr, rtl::OUString& rCountry )
     605                 :            : {
     606         [ +  + ]:     916940 :     if ( nLang == LANGUAGE_SYSTEM )
     607                 :     113712 :         nLang = MsLangId::getSystemLanguage();
     608                 :            : 
     609                 :            :     // Search for LangID (in this table we find only defined ISO combinations)
     610                 :     916940 :     const IsoLangEntry* pEntry = aImplIsoLangEntries;
     611         [ +  + ]:   52462265 :     do
     612                 :            :     {
     613         [ +  + ]:   53300284 :         if ( pEntry->mnLang == nLang )
     614                 :            :         {
     615                 :     838019 :             rLangStr = rtl::OUString::createFromAscii( pEntry->maLangStr );
     616                 :     838019 :             rCountry = rtl::OUString::createFromAscii( pEntry->maCountry );
     617                 :     838019 :             return;
     618                 :            :         }
     619                 :   52462265 :         ++pEntry;
     620                 :            :     }
     621                 :            :     while ( pEntry->mnLang != LANGUAGE_DONTKNOW );
     622                 :            : 
     623                 :            :     // Search for LangID if we didn't find a specific ISO combination.
     624                 :            :     // All entries in this table are allowed for mime specifications,
     625                 :            :     // but not defined ISO combinations.
     626                 :      78921 :     const IsoLangNoneStdEntry* pNoneStdEntry = aImplIsoNoneStdLangEntries;
     627         [ +  + ]:     473526 :     do
     628                 :            :     {
     629         [ -  + ]:     473526 :         if ( pNoneStdEntry->mnLang == nLang )
     630                 :            :         {
     631                 :          0 :             rLangStr = rtl::OUString::createFromAscii( pNoneStdEntry->maLangStr );
     632                 :          0 :             rCountry = rtl::OUString::createFromAscii( pNoneStdEntry->maCountry );
     633                 :          0 :             return;
     634                 :            :         }
     635                 :     473526 :         ++pNoneStdEntry;
     636                 :            :     }
     637                 :            :     while ( pNoneStdEntry->mnLang != LANGUAGE_DONTKNOW );
     638                 :            : 
     639                 :            :     // not found
     640                 :      78921 :     rLangStr = rtl::OUString();
     641                 :     916940 :     rCountry = rtl::OUString();
     642                 :            : }
     643                 :            : 
     644                 :            : // -----------------------------------------------------------------------
     645                 :            : 
     646                 :            : // static
     647                 :      10932 : void MsLangId::convertLanguageToIsoNames( LanguageType nLang,
     648                 :            :         rtl::OString& rLangStr, rtl::OString& rCountry )
     649                 :            : {
     650         [ +  + ]:      10932 :     if ( nLang == LANGUAGE_SYSTEM )
     651                 :        269 :         nLang = MsLangId::getSystemLanguage();
     652                 :            : 
     653                 :            :     // Search for LangID (in this table we find only defined ISO combinations)
     654                 :      10932 :     const IsoLangEntry* pEntry = aImplIsoLangEntries;
     655         [ +  + ]:    2672905 :     do
     656                 :            :     {
     657         [ +  + ]:    2677141 :         if ( pEntry->mnLang == nLang )
     658                 :            :         {                          // avoid embedded \0 warning
     659                 :       4236 :             rLangStr = rtl::OString( static_cast< const char* >( pEntry->maLangStr ));
     660                 :       4236 :             rCountry = rtl::OString( static_cast< const char* >( pEntry->maCountry ));
     661                 :       4236 :             return;
     662                 :            :         }
     663                 :    2672905 :         ++pEntry;
     664                 :            :     }
     665                 :            :     while ( pEntry->mnLang != LANGUAGE_DONTKNOW );
     666                 :            : 
     667                 :            :     // Search for LangID if we didn't find a specific ISO combination.
     668                 :            :     // All entries in this table are allowed for mime specifications,
     669                 :            :     // but not defined ISO combinations.
     670                 :       6696 :     const IsoLangNoneStdEntry* pNoneStdEntry = aImplIsoNoneStdLangEntries;
     671         [ +  + ]:      40176 :     do
     672                 :            :     {
     673         [ -  + ]:      40176 :         if ( pNoneStdEntry->mnLang == nLang )
     674                 :            :         {                          // avoid embedded \0 warning
     675                 :          0 :             rLangStr = rtl::OString( static_cast< const char* >( pNoneStdEntry->maLangStr ));
     676                 :          0 :             rCountry = rtl::OString( static_cast< const char* >( pNoneStdEntry->maCountry ));
     677                 :          0 :             return;
     678                 :            :         }
     679                 :      40176 :         ++pNoneStdEntry;
     680                 :            :     }
     681                 :            :     while ( pNoneStdEntry->mnLang != LANGUAGE_DONTKNOW );
     682                 :            : 
     683                 :            :     // not found
     684                 :       6696 :     rLangStr = rtl::OString();
     685                 :      10932 :     rCountry = rtl::OString();
     686                 :            : }
     687                 :            : 
     688                 :            : // -----------------------------------------------------------------------
     689                 :            : 
     690                 :     150809 : static const MsLangId::IsoLangEntry & lcl_lookupFallbackEntry( LanguageType nLang )
     691                 :            : {
     692                 :     150809 :     LanguageType nPrimary = MsLangId::getPrimaryLanguage( nLang);
     693                 :            : 
     694                 :            :     // Search for LangID and remember first lang-only.
     695                 :     150809 :     const MsLangId::IsoLangEntry* pFirstPrimary = NULL;
     696                 :     150809 :     const MsLangId::IsoLangEntry* pEntry = aImplIsoLangEntries;
     697         [ +  - ]:     150809 :     do
     698                 :            :     {
     699         [ +  + ]:     301618 :         if (pEntry->mnLang == nLang)
     700                 :            :         {
     701         [ +  - ]:     150809 :             if (*pEntry->maCountry)
     702                 :     150809 :                 return *pEntry;
     703         [ #  # ]:          0 :             switch (nLang)
     704                 :            :             {
     705                 :            :                 // These are known to have no country assigned.
     706                 :            :                 case LANGUAGE_BASQUE:
     707                 :            :                 case LANGUAGE_USER_ESPERANTO:
     708                 :            :                 case LANGUAGE_USER_INTERLINGUA:
     709                 :            :                 case LANGUAGE_USER_LOJBAN:
     710                 :          0 :                     return *pEntry;
     711                 :            :                 default:
     712                 :            :                     ;   // nothing
     713                 :            :             }
     714                 :            :         }
     715   [ +  -  +  - ]:     301618 :         if (!pFirstPrimary &&
                 [ +  - ]
     716                 :     150809 :                 MsLangId::getPrimaryLanguage( pEntry->mnLang) == nPrimary)
     717                 :     150809 :             pFirstPrimary = pEntry;
     718                 :     150809 :         ++pEntry;
     719                 :            :     }
     720                 :            :     while ( pEntry->mnLang != LANGUAGE_DONTKNOW );
     721                 :            : 
     722                 :            :     // Language not found at all => use default.
     723         [ #  # ]:          0 :     if (!pFirstPrimary)
     724                 :          0 :         return aLastResortFallbackEntry;
     725                 :            : 
     726                 :            :     // Search for first entry of primary language with any country.
     727                 :          0 :     pEntry = pFirstPrimary;
     728         [ #  # ]:          0 :     do
     729                 :            :     {
     730         [ #  # ]:          0 :         if (MsLangId::getPrimaryLanguage( pEntry->mnLang) == nLang)
     731                 :            :         {
     732         [ #  # ]:          0 :             if (*pEntry->maCountry)
     733                 :          0 :                 return *pEntry;
     734                 :            :         }
     735                 :          0 :         ++pEntry;
     736                 :            :     }
     737                 :            :     while ( pEntry->mnLang != LANGUAGE_DONTKNOW );
     738                 :            : 
     739                 :     150809 :     return aLastResortFallbackEntry;
     740                 :            : }
     741                 :            : 
     742                 :            : // static
     743                 :          0 : LanguageType MsLangId::lookupFallbackLanguage( LanguageType nLang )
     744                 :            : {
     745                 :          0 :     return lcl_lookupFallbackEntry( nLang).mnLang;
     746                 :            : }
     747                 :            : 
     748                 :            : 
     749                 :            : // static
     750                 :     150809 : ::com::sun::star::lang::Locale MsLangId::lookupFallbackLocale( LanguageType nLang )
     751                 :            : {
     752                 :     150809 :     const MsLangId::IsoLangEntry& rEntry = lcl_lookupFallbackEntry( nLang);
     753                 :            :     return ::com::sun::star::lang::Locale(
     754                 :            :             rtl::OUString::createFromAscii( rEntry.maLangStr),
     755                 :            :             rtl::OUString::createFromAscii( rEntry.maCountry),
     756                 :     150809 :             rtl::OUString());
     757                 :            : }
     758                 :            : 
     759                 :            : // -----------------------------------------------------------------------
     760                 :            : 
     761                 :        604 : static const MsLangId::IsoLangEntry & lcl_lookupFallbackEntry(
     762                 :            :         const ::com::sun::star::lang::Locale & rLocale )
     763                 :            : {
     764                 :            :     // language is lower case in table
     765                 :        604 :     rtl::OUString aLowerLang = rLocale.Language.toAsciiLowerCase();
     766                 :            :     // country is upper case in table
     767                 :        604 :     rtl::OUString aUpperCountry = rLocale.Country.toAsciiUpperCase();
     768                 :        604 :     sal_Int32 nCountryLen = aUpperCountry.getLength();
     769                 :            : 
     770                 :            :     // Search for locale and remember first lang-only.
     771                 :        604 :     const MsLangId::IsoLangEntry* pFirstLang = NULL;
     772                 :        604 :     const MsLangId::IsoLangEntry* pEntry = aImplIsoLangEntries;
     773         [ +  + ]:     128020 :     do
     774                 :            :     {
     775         [ +  + ]:     128619 :         if (aLowerLang.equalsAscii( pEntry->maLangStr))
     776                 :            :         {
     777         [ +  + ]:        804 :             if (*pEntry->maCountry)
     778                 :            :             {
     779 [ +  + ][ +  - ]:        200 :                 if (nCountryLen && aUpperCountry.equalsAscii( pEntry->maCountry))
                 [ +  + ]
     780                 :         95 :                     return *pEntry;
     781                 :            :             }
     782                 :            :             else
     783                 :            :             {
     784         [ +  + ]:        604 :                 switch (pEntry->mnLang)
     785                 :            :                 {
     786                 :            :                     // These are known to have no country assigned.
     787                 :            :                     case LANGUAGE_BASQUE:
     788                 :            :                     case LANGUAGE_USER_ESPERANTO:
     789                 :            :                     case LANGUAGE_USER_INTERLINGUA:
     790                 :            :                     case LANGUAGE_USER_LOJBAN:
     791                 :        504 :                         return *pEntry;
     792                 :            :                     default:
     793                 :            :                         ;   // nothing
     794                 :            :                 }
     795                 :            :             }
     796         [ +  + ]:        205 :             if (!pFirstLang)
     797                 :        100 :                 pFirstLang = pEntry;
     798                 :            :         }
     799                 :     128020 :         ++pEntry;
     800                 :            :     }
     801                 :            :     while ( pEntry->mnLang != LANGUAGE_DONTKNOW );
     802                 :            : 
     803                 :            :     // Language not found at all => use default.
     804         [ -  + ]:          5 :     if (!pFirstLang)
     805                 :          0 :         return aLastResortFallbackEntry;
     806                 :            : 
     807                 :            :     // Search for first entry of language with any country.
     808                 :          5 :     pEntry = pFirstLang;
     809         [ +  - ]:          5 :     do
     810                 :            :     {
     811         [ +  - ]:         10 :         if (aLowerLang.equalsAscii( pEntry->maLangStr))
     812                 :            :         {
     813         [ +  + ]:         10 :             if (*pEntry->maCountry)
     814                 :          5 :                 return *pEntry;
     815                 :            :         }
     816                 :          5 :         ++pEntry;
     817                 :            :     }
     818                 :            :     while ( pEntry->mnLang != LANGUAGE_DONTKNOW );
     819                 :            : 
     820                 :        604 :     return aLastResortFallbackEntry;
     821                 :            : }
     822                 :            : 
     823                 :            : // static
     824                 :         95 : LanguageType MsLangId::lookupFallbackLanguage(
     825                 :            :         const ::com::sun::star::lang::Locale & rLocale )
     826                 :            : {
     827                 :         95 :     return lcl_lookupFallbackEntry( rLocale).mnLang;
     828                 :            : }
     829                 :            : 
     830                 :            : 
     831                 :            : // static
     832                 :        509 : ::com::sun::star::lang::Locale MsLangId::lookupFallbackLocale(
     833                 :            :         const ::com::sun::star::lang::Locale & rLocale )
     834                 :            : {
     835                 :        509 :     const MsLangId::IsoLangEntry& rEntry = lcl_lookupFallbackEntry( rLocale);
     836                 :            :     return ::com::sun::star::lang::Locale(
     837                 :            :             rtl::OUString::createFromAscii( rEntry.maLangStr),
     838                 :            :             rtl::OUString::createFromAscii( rEntry.maCountry),
     839                 :        509 :             rtl::OUString());
     840                 :            : }
     841                 :            : 
     842                 :            : // -----------------------------------------------------------------------
     843                 :            : 
     844                 :            : // static
     845                 :      19893 : rtl::OUString MsLangId::convertLanguageToIsoString( LanguageType nLang,
     846                 :            :         sal_Unicode cSep )
     847                 :            : {
     848                 :      19893 :     rtl::OUString   aLangStr;
     849                 :      19893 :     rtl::OUString   aCountry;
     850         [ +  - ]:      19893 :     convertLanguageToIsoNames( nLang, aLangStr, aCountry );
     851         [ +  + ]:      19893 :     if ( !aCountry.isEmpty() )
     852                 :            :     {
     853         [ +  - ]:      19577 :         rtl::OUStringBuffer aBuf( aLangStr);
     854         [ +  - ]:      19577 :         aBuf.append( cSep );
     855         [ +  - ]:      19577 :         aBuf.append( aCountry );
     856         [ +  - ]:      19577 :         return aBuf.makeStringAndClear();
     857                 :            :     }
     858                 :            :     else
     859                 :      19893 :         return aLangStr;
     860                 :            : }
     861                 :            : 
     862                 :            : // -----------------------------------------------------------------------
     863                 :            : 
     864                 :            : // static
     865                 :      10932 : rtl::OString MsLangId::convertLanguageToIsoByteString( LanguageType nLang,
     866                 :            :         sal_Char cSep )
     867                 :            : {
     868                 :      10932 :     rtl::OString  aLangStr;
     869                 :      10932 :     rtl::OString  aCountry;
     870         [ +  - ]:      10932 :     convertLanguageToIsoNames( nLang, aLangStr, aCountry );
     871         [ +  + ]:      10932 :     if ( !aCountry.isEmpty() )
     872                 :            :     {
     873         [ +  - ]:       4163 :         rtl::OStringBuffer aBuf( aLangStr);
     874         [ +  - ]:       4163 :         aBuf.append( cSep );
     875         [ +  - ]:       4163 :         aBuf.append( aCountry );
     876                 :       4163 :         return aBuf.makeStringAndClear();
     877                 :            :     }
     878                 :      10932 :     return aLangStr;
     879                 :            : }
     880                 :            : 
     881                 :            : // =======================================================================
     882                 :            : 
     883                 :            : // static
     884                 :     646642 : LanguageType MsLangId::convertIsoNamesToLanguage( const rtl::OUString& rLang,
     885                 :            :         const rtl::OUString& rCountry )
     886                 :            : {
     887                 :            :     // language is lower case in table
     888                 :     646642 :     rtl::OUString aLowerLang = rLang.toAsciiLowerCase();
     889                 :            :     // country is upper case in table
     890                 :     646642 :     rtl::OUString aUpperCountry = rCountry.toAsciiUpperCase();
     891                 :            : 
     892                 :            :     //  first look for exact match
     893                 :     646642 :     const IsoLangEntry* pFirstLang = NULL;
     894                 :     646642 :     const IsoLangEntry* pEntry = aImplIsoLangEntries;
     895         [ +  + ]:   20657764 :     do
     896                 :            :     {
     897         [ +  + ]:   21303960 :         if ( aLowerLang.equalsAscii( pEntry->maLangStr ) )
     898                 :            :         {
     899   [ +  +  +  + ]:    3980345 :             if ( aUpperCountry.isEmpty() ||
                 [ +  + ]
     900                 :    1987965 :                  aUpperCountry.equalsAscii( pEntry->maCountry ) )
     901                 :     646196 :                 return pEntry->mnLang;
     902         [ +  + ]:    1346184 :             if ( !pFirstLang )
     903                 :     533149 :                 pFirstLang = pEntry;
     904         [ +  + ]:     813035 :             else if ( !*pEntry->maCountry )
     905                 :       9606 :                 pFirstLang = pEntry;
     906                 :            :         }
     907                 :   20657764 :         ++pEntry;
     908                 :            :     }
     909                 :            :     while ( pEntry->mnLang != LANGUAGE_DONTKNOW );
     910                 :            : 
     911                 :            :     // some eng countries should be mapped to a specific english language
     912         [ +  + ]:        446 :     if ( aLowerLang == "en" )
     913                 :            :     {
     914                 :        322 :         const IsoLangEngEntry* pEngEntry = aImplIsoLangEngEntries;
     915         [ +  + ]:       9430 :         do
     916                 :            :         {
     917         [ +  + ]:       9660 :             if ( aUpperCountry.equalsAscii( pEngEntry->maCountry ) )
     918                 :        230 :                 return pEngEntry->mnLang;
     919                 :       9430 :             ++pEngEntry;
     920                 :            :         }
     921                 :            :         while ( pEngEntry->mnLang != LANGUAGE_DONTKNOW );
     922                 :            :     }
     923                 :            : 
     924                 :            :     // test for specific languages which are not used standard ISO 3166 codes
     925                 :        216 :     const IsoLangNoneStdEntry* pNoneStdEntry = aImplIsoNoneStdLangEntries;
     926         [ +  + ]:       1296 :     do
     927                 :            :     {
     928         [ -  + ]:       1296 :         if ( aLowerLang.equalsAscii( pNoneStdEntry->maLangStr ) )
     929                 :            :         {
     930                 :            :             // The countries in this table are not all in upper case
     931         [ #  # ]:          0 :             if ( aUpperCountry.equalsIgnoreAsciiCaseAscii( pNoneStdEntry->maCountry ) )
     932                 :          0 :                 return pNoneStdEntry->mnLang;
     933                 :            :         }
     934                 :       1296 :         ++pNoneStdEntry;
     935                 :            :     }
     936                 :            :     while ( pNoneStdEntry->mnLang != LANGUAGE_DONTKNOW );
     937                 :        216 :     pNoneStdEntry = aImplIsoNoneStdLangEntries2;
     938         [ +  + ]:        648 :     do
     939                 :            :     {
     940         [ -  + ]:        648 :         if ( aLowerLang.equalsAscii( pNoneStdEntry->maLangStr ) )
     941                 :            :         {
     942                 :            :             // The countries in this table are not all in upper case
     943         [ #  # ]:          0 :             if ( aUpperCountry.equalsIgnoreAsciiCaseAscii( pNoneStdEntry->maCountry ) )
     944                 :          0 :                 return pNoneStdEntry->mnLang;
     945                 :            :         }
     946                 :        648 :         ++pNoneStdEntry;
     947                 :            :     }
     948                 :            :     while ( pNoneStdEntry->mnLang != LANGUAGE_DONTKNOW );
     949                 :            : 
     950                 :            :     // If the language is correct, than we return the default language
     951         [ +  + ]:        216 :     if ( pFirstLang )
     952                 :         92 :         return pFirstLang->mnLang;
     953                 :            : 
     954                 :            :     //  if only the country is set, look for any entry matching the country
     955                 :            :     //  (to allow reading country and language in separate steps, in any order)
     956 [ +  + ][ -  + ]:        124 :     if ( !rCountry.isEmpty() && rLang.isEmpty() )
                 [ -  + ]
     957                 :            :     {
     958                 :          0 :         const IsoLangEntry* pEntry2 = aImplIsoLangEntries;
     959         [ #  # ]:          0 :         do
     960                 :            :         {
     961         [ #  # ]:          0 :             if ( aUpperCountry.equalsAscii( pEntry2->maCountry ) )
     962                 :          0 :                 return pEntry2->mnLang;
     963                 :          0 :             ++pEntry2;
     964                 :            :         }
     965                 :            :         while ( pEntry2->mnLang != LANGUAGE_DONTKNOW );
     966                 :            : 
     967                 :          0 :         aLowerLang = aUpperCountry.toAsciiLowerCase();
     968                 :            :     }
     969                 :            : 
     970                 :            :     // Now look for all other definitions, which are not standard
     971                 :        124 :     const IsoLangOtherEntry* pOtherEntry = aImplOtherEntries;
     972         [ +  + ]:        868 :     do
     973                 :            :     {
     974         [ -  + ]:        868 :         if ( aLowerLang.equalsAscii( pOtherEntry->mpLangStr ) )
     975                 :          0 :             return pOtherEntry->mnLang;
     976                 :        868 :         ++pOtherEntry;
     977                 :            :     }
     978                 :            :     while ( pOtherEntry->mnLang != LANGUAGE_DONTKNOW );
     979                 :            : 
     980                 :     646642 :     return LANGUAGE_DONTKNOW;
     981                 :            : }
     982                 :            : 
     983                 :            : // -----------------------------------------------------------------------
     984                 :            : 
     985                 :            : // static
     986                 :        649 : LanguageType MsLangId::convertIsoNamesToLanguage( const rtl::OString& rLang,
     987                 :            :         const rtl::OString& rCountry )
     988                 :            : {
     989         [ +  - ]:        649 :     rtl::OUString aLang = OStringToOUString( rLang, RTL_TEXTENCODING_ASCII_US);
     990         [ +  - ]:        649 :     rtl::OUString aCountry = OStringToOUString( rCountry, RTL_TEXTENCODING_ASCII_US);
     991         [ +  - ]:        649 :     return convertIsoNamesToLanguage( aLang, aCountry);
     992                 :            : }
     993                 :            : 
     994                 :            : // -----------------------------------------------------------------------
     995                 :            : 
     996                 :            : // static
     997                 :      32614 : LanguageType MsLangId::convertIsoStringToLanguage(
     998                 :            :         const rtl::OUString& rString, sal_Unicode cSep )
     999                 :            : {
    1000                 :      32614 :     rtl::OUString   aLang;
    1001                 :      32614 :     rtl::OUString   aCountry;
    1002                 :      32614 :     sal_Int32  nSepPos = rString.indexOf( cSep );
    1003         [ +  + ]:      32614 :     if ( nSepPos >= 0 )
    1004                 :            :     {
    1005                 :      32059 :         aLang = rString.copy( 0, nSepPos );
    1006                 :      32059 :         aCountry = rString.copy( nSepPos+1 );
    1007                 :            :     }
    1008                 :            :     else
    1009                 :        555 :         aLang = rString;
    1010                 :            : 
    1011         [ +  - ]:      32614 :     return convertIsoNamesToLanguage( aLang, aCountry );
    1012                 :            : }
    1013                 :            : 
    1014                 :            : // -----------------------------------------------------------------------
    1015                 :            : 
    1016                 :            : struct IsoLangGLIBCModifiersEntry
    1017                 :            : {
    1018                 :            :     LanguageType  mnLang;
    1019                 :            :     sal_Char      maLangStr[4];
    1020                 :            :     sal_Char      maCountry[3];
    1021                 :            :     sal_Char      maAtString[9];
    1022                 :            : };
    1023                 :            : 
    1024                 :            : static IsoLangGLIBCModifiersEntry const aImplIsoLangGLIBCModifiersEntries[] =
    1025                 :            : {
    1026                 :            :     // MS-LANGID codes               ISO639-1/2/3 ISO3166            glibc modifier
    1027                 :            :     { LANGUAGE_BOSNIAN_CYRILLIC_BOSNIA_HERZEGOVINA, "bs", "BA", "cyrillic" },
    1028                 :            :     { LANGUAGE_USER_SERBIAN_LATIN_SERBIA,           "sr", "RS", "latin" },   // Serbian Latin in Serbia
    1029                 :            :     { LANGUAGE_SERBIAN_LATIN,                       "sr", "CS", "latin" },   // Serbian Latin in Serbia and Montenegro
    1030                 :            :     { LANGUAGE_USER_SERBIAN_LATIN_MONTENEGRO,       "sr", "ME", "latin" },   // Serbian Latin in Montenegro
    1031                 :            :     { LANGUAGE_SERBIAN_LATIN_NEUTRAL,               "sr", "",   "latin" },
    1032                 :            :     { LANGUAGE_AZERI_CYRILLIC,                      "az", "AZ", "cyrillic" },
    1033                 :            :     { LANGUAGE_UZBEK_CYRILLIC,                      "uz", "UZ", "cyrillic" },
    1034                 :            :     { LANGUAGE_DONTKNOW,                            "",   "",   ""   }       // marks end of table
    1035                 :            : };
    1036                 :            : 
    1037                 :            : // convert a unix locale string into LanguageType
    1038                 :            : 
    1039                 :            : // static
    1040                 :        649 : LanguageType MsLangId::convertUnxByteStringToLanguage(
    1041                 :            :         const rtl::OString& rString )
    1042                 :            : {
    1043                 :        649 :     rtl::OString  aLang;
    1044                 :        649 :     rtl::OString  aCountry;
    1045                 :        649 :     rtl::OString  aAtString;
    1046                 :            : 
    1047                 :        649 :     sal_Int32  nLangSepPos    = rString.indexOf( (sal_Char)'_' );
    1048                 :        649 :     sal_Int32  nCountrySepPos = rString.indexOf( (sal_Char)'.' );
    1049                 :        649 :     sal_Int32  nAtPos         = rString.indexOf( (sal_Char)'@' );
    1050                 :            : 
    1051         [ -  + ]:        649 :     if (nCountrySepPos < 0)
    1052                 :          0 :         nCountrySepPos = nAtPos;
    1053         [ -  + ]:        649 :     if (nCountrySepPos < 0)
    1054                 :          0 :         nCountrySepPos = rString.getLength();
    1055                 :            : 
    1056         [ -  + ]:        649 :     if (nAtPos >= 0)
    1057                 :          0 :         aAtString = rString.copy( nAtPos+1 );
    1058                 :            : 
    1059 [ +  - ][ +  - ]:        649 :     if (   ((nLangSepPos >= 0) && (nLangSepPos > nCountrySepPos))
                 [ -  + ]
    1060                 :            :         || ((nLangSepPos < 0)) )
    1061                 :            :     {
    1062                 :            :         // eg. "el.sun_eu_greek", "tchinese", "es.ISO8859-15"
    1063                 :          0 :         aLang    = rString.copy( 0, nCountrySepPos );
    1064                 :            :     }
    1065         [ +  - ]:        649 :     else if ( nLangSepPos >= 0 )
    1066                 :            :     {
    1067                 :            :         // well formed iso names like "en_US.UTF-8", "sh_BA.ISO8859-2@bosnia"
    1068                 :        649 :         aLang    = rString.copy( 0, nLangSepPos );
    1069                 :        649 :         aCountry = rString.copy( nLangSepPos+1, nCountrySepPos - nLangSepPos - 1);
    1070                 :            :     }
    1071                 :            : 
    1072                 :            :     //  if there is a glibc modifier, first look for exact match in modifier table
    1073         [ -  + ]:        649 :     if (!aAtString.isEmpty())
    1074                 :            :     {
    1075                 :            :         // language is lower case in table
    1076                 :          0 :         rtl::OString aLowerLang = aLang.toAsciiLowerCase();
    1077                 :            :         // country is upper case in table
    1078                 :          0 :         rtl::OString aUpperCountry = aCountry.toAsciiUpperCase();
    1079                 :          0 :         const IsoLangGLIBCModifiersEntry* pGLIBCModifiersEntry = aImplIsoLangGLIBCModifiersEntries;
    1080         [ #  # ]:          0 :         do
    1081                 :            :         {                         // avoid embedded \0 warning
    1082   [ #  #  #  # ]:          0 :             if (( aLowerLang.equals( static_cast< const char* >( pGLIBCModifiersEntry->maLangStr ))) &&
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1083 [ #  # ][ #  # ]:          0 :                ( aAtString.equals( static_cast< const char* >( pGLIBCModifiersEntry->maAtString ))))
                 [ #  # ]
    1084                 :            :             {
    1085   [ #  #  #  # ]:          0 :                 if ( aUpperCountry.isEmpty() ||
                 [ #  # ]
    1086 [ #  # ][ #  # ]:          0 :                      aUpperCountry.equals( static_cast< const char* >( pGLIBCModifiersEntry->maCountry )))
                 [ #  # ]
    1087                 :            :                {
    1088                 :          0 :                     return pGLIBCModifiersEntry->mnLang;
    1089                 :            :                }
    1090                 :            :             }
    1091                 :          0 :             ++pGLIBCModifiersEntry;
    1092                 :            :         }
    1093 [ #  # ][ #  # ]:          0 :         while ( pGLIBCModifiersEntry->mnLang != LANGUAGE_DONTKNOW );
    1094                 :            :     }
    1095                 :            : 
    1096         [ +  - ]:        649 :     return convertIsoNamesToLanguage( aLang, aCountry );
    1097                 :            : }
    1098                 :            : 
    1099                 :            : // -----------------------------------------------------------------------
    1100                 :            : // pass one IsoLangEntry to the outer world of the resource compiler
    1101                 :            : 
    1102                 :            : // static
    1103                 :     555840 : const MsLangId::IsoLangEntry* MsLangId::getIsoLangEntry( size_t nIndex )
    1104                 :            : {
    1105         [ +  - ]:     555840 :     if (nIndex < SAL_N_ELEMENTS(aImplIsoLangEntries))
    1106                 :     555840 :         return &aImplIsoLangEntries[ nIndex];
    1107                 :     555840 :     return 0;
    1108                 :            : }
    1109                 :            : 
    1110                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10