diff options
author | Eike Rathke <erack@redhat.com> | 2013-09-18 22:39:23 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2013-09-18 22:40:58 +0200 |
commit | 31db11d7efba6f9ee77e9c1cd1f0e82ce9e8feee (patch) | |
tree | bc29f1355c551f37507cf49bd000093e1565362e /include | |
parent | ecaadbf78794174c5f744b4982546901cb7fe8e8 (diff) |
changed to mpImpl
first step to register locales
Change-Id: I1a1f7b3f642cf892e91b17dd30c92a79129f184e
Diffstat (limited to 'include')
-rw-r--r-- | include/i18nlangtag/languagetag.hxx | 114 |
1 files changed, 31 insertions, 83 deletions
diff --git a/include/i18nlangtag/languagetag.hxx b/include/i18nlangtag/languagetag.hxx index 06baf8d27993..aef59d0d738c 100644 --- a/include/i18nlangtag/languagetag.hxx +++ b/include/i18nlangtag/languagetag.hxx @@ -16,6 +16,7 @@ #include <i18nlangtag/i18nlangtagdllapi.h> #include <i18nlangtag/lang.h> +#include <boost/shared_ptr.hpp> #include <vector> typedef struct _rtl_Locale rtl_Locale; // as in rtl/locale.h @@ -35,6 +36,9 @@ typedef struct _rtl_Locale rtl_Locale; // as in rtl/locale.h #define I18NLANGTAG_QLT "qlt" +class LanguageTagImpl; + + /** Wrapper for liblangtag BCP 47 language tags, MS-LangIDs, locales and conversions in between. @@ -47,6 +51,8 @@ typedef struct _rtl_Locale rtl_Locale; // as in rtl/locale.h */ class I18NLANGTAG_DLLPUBLIC LanguageTag { + friend class LanguageTagImpl; + public: /** Init LanguageTag with existing BCP 47 language tag string. @@ -480,97 +486,39 @@ public: private: - enum Decision - { - DECISION_DONTKNOW, - DECISION_NO, - DECISION_YES - }; - - mutable com::sun::star::lang::Locale maLocale; - mutable OUString maBcp47; - mutable OUString maCachedLanguage; ///< cache getLanguage() - mutable OUString maCachedScript; ///< cache getScript() - mutable OUString maCachedCountry; ///< cache getCountry() - mutable OUString maCachedVariants; ///< cache getVariants() - mutable void* mpImplLangtag; ///< actually lt_tag_t pointer, encapsulated - mutable LanguageType mnLangID; - mutable Decision meIsValid; - mutable Decision meIsIsoLocale; - mutable Decision meIsIsoODF; - mutable Decision meIsLiblangtagNeeded; ///< whether processing with liblangtag needed - bool mbSystemLocale : 1; - mutable bool mbInitializedBcp47 : 1; - mutable bool mbInitializedLocale : 1; - mutable bool mbInitializedLangID : 1; - mutable bool mbCachedLanguage : 1; - mutable bool mbCachedScript : 1; - mutable bool mbCachedCountry : 1; - mutable bool mbCachedVariants : 1; - bool mbIsFallback : 1; - - void convertLocaleToBcp47(); - void convertLocaleToLang(); - void convertBcp47ToLocale(); - void convertBcp47ToLang(); - void convertLangToLocale(); - void convertLangToBcp47(); - - void convertFromRtlLocale(); - - /** @return whether BCP 47 language tag string was changed. */ - bool canonicalize(); + mutable com::sun::star::lang::Locale maLocale; + mutable OUString maBcp47; + mutable LanguageType mnLangID; + mutable boost::shared_ptr< LanguageTagImpl > mpImpl; + bool mbSystemLocale : 1; + mutable bool mbInitializedBcp47 : 1; + mutable bool mbInitializedLocale : 1; + mutable bool mbInitializedLangID : 1; + bool mbIsFallback : 1; - /** Canonicalize if not yet done and synchronize initialized conversions. - - @return whether BCP 47 language tag string was changed. - */ - bool synCanonicalize(); + LanguageTagImpl* getImpl() const; + void syncFromImpl(); - OUString getLanguageFromLangtag(); - OUString getScriptFromLangtag(); - OUString getRegionFromLangtag(); - OUString getVariantsFromLangtag(); + void convertLocaleToBcp47(); + void convertLocaleToLang(); + void convertBcp47ToLocale(); + void convertBcp47ToLang(); + void convertLangToLocale(); + void convertLangToBcp47(); - void resetVars(); + void convertFromRtlLocale(); - /** Obtain Language, Script, Country and Variants via simpleExtract() and - assign them to the cached variables if successful. + /** Canonicalize if not yet done and synchronize initialized conversions. - @return return of simpleExtract() + @return whether BCP 47 language tag string was changed. */ - bool cacheSimpleLSCV(); - - static bool isIsoLanguage( const OUString& rLanguage ); - static bool isIsoScript( const OUString& rScript ); - static bool isIsoCountry( const OUString& rRegion ); + bool synCanonicalize(); - enum Extraction - { - EXTRACTED_NONE, - EXTRACTED_LSC, - EXTRACTED_LV, - EXTRACTED_X, - EXTRACTED_X_JOKER - }; + void resetVars(); - /** Of a language tag of the form lll[-Ssss][-CC][-vvvvvvvv] extract the - portions. - - Does not check case or content! - - @return EXTRACTED_LSC if simple tag was detected (i.e. one that - would fulfill the isIsoODF() condition), - EXTRACTED_LV if a tag with variant was detected, - EXTRACTED_X if x-... privateuse tag was detected, - EXTRACTED_X_JOKER if "*" joker was detected, - EXTRACTED_NONE else. - */ - static Extraction simpleExtract( const OUString& rBcp47, - OUString& rLanguage, - OUString& rScript, - OUString& rCountry, - OUString& rVariants ); + static bool isIsoLanguage( const OUString& rLanguage ); + static bool isIsoScript( const OUString& rScript ); + static bool isIsoCountry( const OUString& rRegion ); }; |