Kaydet (Commit) 31db11d7 authored tarafından Eike Rathke's avatar Eike Rathke

changed to mpImpl

first step to register locales

Change-Id: I1a1f7b3f642cf892e91b17dd30c92a79129f184e
üst ecaadbf7
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <i18nlangtag/i18nlangtagdllapi.h> #include <i18nlangtag/i18nlangtagdllapi.h>
#include <i18nlangtag/lang.h> #include <i18nlangtag/lang.h>
#include <boost/shared_ptr.hpp>
#include <vector> #include <vector>
typedef struct _rtl_Locale rtl_Locale; // as in rtl/locale.h 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 ...@@ -35,6 +36,9 @@ typedef struct _rtl_Locale rtl_Locale; // as in rtl/locale.h
#define I18NLANGTAG_QLT "qlt" #define I18NLANGTAG_QLT "qlt"
class LanguageTagImpl;
/** Wrapper for liblangtag BCP 47 language tags, MS-LangIDs, locales and /** Wrapper for liblangtag BCP 47 language tags, MS-LangIDs, locales and
conversions in between. conversions in between.
...@@ -47,6 +51,8 @@ typedef struct _rtl_Locale rtl_Locale; // as in rtl/locale.h ...@@ -47,6 +51,8 @@ typedef struct _rtl_Locale rtl_Locale; // as in rtl/locale.h
*/ */
class I18NLANGTAG_DLLPUBLIC LanguageTag class I18NLANGTAG_DLLPUBLIC LanguageTag
{ {
friend class LanguageTagImpl;
public: public:
/** Init LanguageTag with existing BCP 47 language tag string. /** Init LanguageTag with existing BCP 47 language tag string.
...@@ -480,97 +486,39 @@ public: ...@@ -480,97 +486,39 @@ public:
private: private:
enum Decision mutable com::sun::star::lang::Locale maLocale;
{ mutable OUString maBcp47;
DECISION_DONTKNOW, mutable LanguageType mnLangID;
DECISION_NO, mutable boost::shared_ptr< LanguageTagImpl > mpImpl;
DECISION_YES bool mbSystemLocale : 1;
}; mutable bool mbInitializedBcp47 : 1;
mutable bool mbInitializedLocale : 1;
mutable com::sun::star::lang::Locale maLocale; mutable bool mbInitializedLangID : 1;
mutable OUString maBcp47; bool mbIsFallback : 1;
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();
/** Canonicalize if not yet done and synchronize initialized conversions. LanguageTagImpl* getImpl() const;
void syncFromImpl();
@return whether BCP 47 language tag string was changed.
*/
bool synCanonicalize();
OUString getLanguageFromLangtag(); void convertLocaleToBcp47();
OUString getScriptFromLangtag(); void convertLocaleToLang();
OUString getRegionFromLangtag(); void convertBcp47ToLocale();
OUString getVariantsFromLangtag(); void convertBcp47ToLang();
void convertLangToLocale();
void convertLangToBcp47();
void resetVars(); void convertFromRtlLocale();
/** Obtain Language, Script, Country and Variants via simpleExtract() and /** Canonicalize if not yet done and synchronize initialized conversions.
assign them to the cached variables if successful.
@return return of simpleExtract() @return whether BCP 47 language tag string was changed.
*/ */
bool cacheSimpleLSCV(); bool synCanonicalize();
static bool isIsoLanguage( const OUString& rLanguage );
static bool isIsoScript( const OUString& rScript );
static bool isIsoCountry( const OUString& rRegion );
enum Extraction void resetVars();
{
EXTRACTED_NONE,
EXTRACTED_LSC,
EXTRACTED_LV,
EXTRACTED_X,
EXTRACTED_X_JOKER
};
/** Of a language tag of the form lll[-Ssss][-CC][-vvvvvvvv] extract the static bool isIsoLanguage( const OUString& rLanguage );
portions. static bool isIsoScript( const OUString& rScript );
static bool isIsoCountry( const OUString& rRegion );
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 );
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment