fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / include / i18nlangtag / mslangid.hxx
blob8148d1760de0b5fdedac016687eee74e6dbc1cc5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_I18NLANGTAG_MSLANGID_HXX
21 #define INCLUDED_I18NLANGTAG_MSLANGID_HXX
23 #include <sal/config.h>
25 #include "i18nlangtag/i18nlangtagdllapi.h"
26 #include "i18nlangtag/lang.h"
27 #include <com/sun/star/lang/Locale.hpp>
29 /** Methods related to Microsoft language IDs. For details about MS-LANGIDs
30 please see lang.h */
31 class I18NLANGTAG_DLLPUBLIC MsLangId
33 public:
35 /// Create a LangID from a primary and a sublanguage.
36 static inline LanguageType makeLangID( LanguageType nSubLangId, LanguageType nPriLangId)
38 return (nSubLangId << 10) | nPriLangId;
41 /// Get the primary language of a LangID.
42 static inline LanguageType getPrimaryLanguage( LanguageType nLangID)
44 return nLangID & LANGUAGE_MASK_PRIMARY;
47 /// Get the sublanguage of a LangID.
48 static inline LanguageType getSubLanguage( LanguageType nLangID)
50 return (nLangID & ~LANGUAGE_MASK_PRIMARY) >> 10;
53 /** Language/locale of category LC_CTYPE (on Unix, else the system
54 language).
55 Evaluation order: LC_ALL, LC_CTYPE, LANG */
56 static LanguageType getSystemLanguage();
58 /** Language/locale of category LC_MESSAGES (on Unix, else same as
59 GetSystemLanguage()).
60 Evaluation order: LANGUAGE, LC_ALL, LC_MESSAGES, LANG */
61 static LanguageType getSystemUILanguage();
64 /** @short: A proper language/locale if the nLang parameter designates some
65 special value.
67 @descr: NOTE: The "system" values may be overridden by the
68 application's configuration.
70 @returns
71 case LANGUAGE_PROCESS_OR_USER_DEFAULT : configured or system language
72 case LANGUAGE_SYSTEM_DEFAULT : configured or system language
73 case LANGUAGE_SYSTEM : configured or system language
74 case LANGUAGE_HID_HUMAN_INTERFACE_DEVICE : configured or system UI language
75 case LANGUAGE_DONTKNOW : LANGUAGE_ENGLISH_US
76 else: nLang
78 In case the configured language is LANGUAGE_SYSTEM, which is also
79 the initial default, the system language is obtained. In case the
80 configured or resulting system language is LANGUAGE_DONTKNOW,
81 LANGUAGE_ENGLISH_US is returned instead.
83 static LanguageType getRealLanguage( LanguageType nLang );
86 // TODO: refactor to LanguageTag? Used only in
87 // i18npool/source/localedata/localedata.cxx
89 /** Get fall-back Locale for Locale with handling of an empty language name
90 designating the SYSTEM language. Returns the same Locale if an exact
91 match was found.
93 static ::com::sun::star::lang::Locale getFallbackLocale(
94 const ::com::sun::star::lang::Locale & rLocale );
97 // TODO: refactor to LanguageTag, used only in
98 // i18npool/source/isolang/inunx.cxx to convert Unix locale string
100 static LanguageType convertUnxByteStringToLanguage( const OString& rString );
103 static LanguageType resolveSystemLanguageByScriptType( LanguageType nLang, sal_Int16 nType );
106 /** Whether locale has a Right-To-Left orientation. */
107 static bool isRightToLeft( LanguageType nLang );
109 /** Whether locale is a CJK locale */
110 static bool isCJK( LanguageType nLang );
112 /** Whether locale is a chinese locale */
113 static bool isChinese( LanguageType nLang );
115 /** Whether locale is a simplified chinese locale */
116 static bool isSimplifiedChinese( LanguageType nLang );
118 /** Whether locale is a traditional chinese locale */
119 static bool isTraditionalChinese( LanguageType nLang );
121 /** Whether locale is a korean locale */
122 static bool isKorean( LanguageType nLang );
124 /** Whether locale is a simplified chinese locale */
125 static bool isSimplifiedChinese( const ::com::sun::star::lang::Locale & rLocale );
127 /** Whether locale is a traditional chinese locale */
128 static bool isTraditionalChinese( const ::com::sun::star::lang::Locale & rLocale );
130 /** Whether locale is one where family name comes first, e.g. Japan, Hungary, Samoa */
131 static bool isFamilyNameFirst( LanguageType nLang );
133 /** Whether there are "forbidden characters at start or end of line" in
134 this locale. CJK locales.
136 @see offapi/com/sun/star/i18n/ForbiddenCharacters.idl
138 static bool hasForbiddenCharacters( LanguageType nLang );
141 /** Whether locale needs input sequence checking. CTL locales. */
142 static bool needsSequenceChecking( LanguageType nLang );
145 /** Get ::com::sun::star::i18n::ScriptType of locale. */
146 static sal_Int16 getScriptType( LanguageType nLang );
149 /** Map an obsolete user defined LANGID (see lang.h
150 LANGUAGE_OBSOLETE_USER_...) to the new value defined by MS in the
151 meantime.
153 Also used to map UI localizations using reserved ISO codes to something
154 "official" but not identical in order to not pollute documents with
155 invalid ISO codes.
157 @param bUserInterfaceSelection
158 If TRUE, don't replace such UI-only locale. Only use for
159 Tools->Options->LanguageSettings->UserInterface listbox.
160 If FALSE, do replace.
162 static LanguageType getReplacementForObsoleteLanguage( LanguageType nLang,
163 bool bUserInterfaceSelection = false );
166 /** @ATTENTION: these are _ONLY_ to be called by the application's
167 configuration! */
168 static void setConfiguredSystemLanguage( LanguageType nLang );
169 static void setConfiguredSystemUILanguage( LanguageType nLang );
170 static void setConfiguredWesternFallback( LanguageType nLang );
171 static void setConfiguredComplexFallback( LanguageType nLang );
172 static void setConfiguredAsianFallback( LanguageType nLang );
174 // ---------------------------------------------------------------------------
176 /** @internal - Access to fields of an element of the simple conversion table.
177 For resource compiler build environment usage only! */
178 struct IsoLangEntry
180 LanguageType mnLang;
181 sal_Char maLangStr[4];
182 sal_Char maCountry[3];
184 /** Obtain a language tag string with '-' separator. */
185 I18NLANGTAG_DLLPUBLIC OUString getTagString() const;
188 /** @internal - Return a pointer to the IsoLangEntry of the underlying table,
189 matching the offset passed by nIndex. Only meaningful for the resource
190 compiler to build a list of known languages.
192 @returns address of IsoLangEntry, or NULL pointer if nIndex exceeds the
193 table elements' count.
195 static const IsoLangEntry* getIsoLangEntry( size_t nIndex );
197 // ---------------------------------------------------------------------------
199 /** Encapsulated conversion methods used by LanguageTag and conversions,
200 not to be used by anything else.
202 class Conversion
204 private:
206 friend class LanguageTag;
208 friend ::com::sun::star::lang::Locale MsLangId::getFallbackLocale(
209 const ::com::sun::star::lang::Locale & rLocale );
211 friend LanguageType MsLangId::convertUnxByteStringToLanguage(
212 const OString& rString );
215 /** Convert a Locale to a LanguageType with handling of an empty
216 language name designating LANGUAGE_SYSTEM.
218 I18NLANGTAG_DLLPRIVATE static LanguageType convertLocaleToLanguage(
219 const ::com::sun::star::lang::Locale & rLocale );
221 /** Convert x-... privateuse, used by convertLocaleToLanguage(Locale) */
222 I18NLANGTAG_DLLPRIVATE static LanguageType convertPrivateUseToLanguage(
223 const OUString& rPriv );
225 /** Used by convertLocaleToLanguage(Locale) */
226 I18NLANGTAG_DLLPRIVATE static LanguageType convertIsoNamesToLanguage(
227 const OUString& rLang, const OUString& rCountry );
230 /** Used by convertUnxByteStringToLanguage(OString) */
231 I18NLANGTAG_DLLPRIVATE static LanguageType convertIsoNamesToLanguage(
232 const OString& rLang, const OString& rCountry );
235 /** Convert a LanguageType to a Locale.
237 @param bResolveSystem
238 If bResolveSystem==true, a LANGUAGE_SYSTEM is resolved.
239 If bResolveSystem==false, a LANGUAGE_SYSTEM results in an
240 empty Locale.
242 I18NLANGTAG_DLLPRIVATE static ::com::sun::star::lang::Locale convertLanguageToLocale(
243 LanguageType nLang, bool bResolveSystem );
245 /** Convert a LanguageType to a Locale, resolving LANGUAGE_SYSTEM.
247 Used by convertLanguageToLocale(LanguageType,bool)
249 I18NLANGTAG_DLLPRIVATE static void convertLanguageToLocale(
250 LanguageType nLang, ::com::sun::star::lang::Locale & rLocale );
252 /** Used by convertLanguageToLocale(LanguageType,Locale) */
253 I18NLANGTAG_DLLPRIVATE static void convertLanguageToIsoNames(
254 LanguageType nLang, OUString& rLangStr, OUString& rCountry );
257 I18NLANGTAG_DLLPRIVATE static LanguageType lookupFallbackLanguage( LanguageType nLang );
259 I18NLANGTAG_DLLPRIVATE static ::com::sun::star::lang::Locale lookupFallbackLocale(
260 const ::com::sun::star::lang::Locale & rLocale );
263 /** Convert a LanguageType to a Locale, resolving LANGUAGE_SYSTEM,
264 falling back to a default locale if no exact match was found.
266 Used by getFallbackLocale(Locale)
268 I18NLANGTAG_DLLPRIVATE static ::com::sun::star::lang::Locale convertLanguageToLocaleWithFallback(
269 LanguageType nLang );
271 /** Used by convertLanguageToLocaleWithFallback(LanguageType) */
272 I18NLANGTAG_DLLPRIVATE static ::com::sun::star::lang::Locale lookupFallbackLocale(
273 LanguageType nLang );
276 private:
278 static LanguageType nConfiguredSystemLanguage;
279 static LanguageType nConfiguredSystemUILanguage;
281 static LanguageType nConfiguredWesternFallback;
282 static LanguageType nConfiguredAsianFallback;
283 static LanguageType nConfiguredComplexFallback;
285 static LanguageType getPlatformSystemLanguage();
286 static LanguageType getPlatformSystemUILanguage();
288 // Substitute LANGUAGE_SYSTEM for LANGUAGE_SYSTEM_DEFAULT and
289 // LANGUAGE_PROCESS_OR_USER_DEFAULT, other values aren't touched.
290 I18NLANGTAG_DLLPRIVATE static inline LanguageType simplifySystemLanguages( LanguageType nLang );
294 // static
295 inline LanguageType MsLangId::getSystemLanguage()
297 return getPlatformSystemLanguage();
301 // static
302 inline LanguageType MsLangId::getSystemUILanguage()
304 return getPlatformSystemUILanguage();
307 #endif // INCLUDED_I18NLANGTAG_MSLANGID_HXX
309 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */