i18nlangtag/source/languagetag/languagetag.cxx | 38 +++++++++++++++++++++++++ include/i18nlangtag/languagetag.hxx | 9 +++++ 2 files changed, 47 insertions(+)
New commits: commit 4467a4a6280306770107488b4a97c4d496c95a43 Author: Eike Rathke <er...@redhat.com> Date: Fri Jul 5 21:01:35 2013 +0200 added convenience ctor for ODF import Change-Id: I80fc2d531b612d9e2e94fc4f5efcca594e35a561 diff --git a/i18nlangtag/source/languagetag/languagetag.cxx b/i18nlangtag/source/languagetag/languagetag.cxx index 68c3aeb..f0333b8 100644 --- a/i18nlangtag/source/languagetag/languagetag.cxx +++ b/i18nlangtag/source/languagetag/languagetag.cxx @@ -206,6 +206,44 @@ LanguageTag::LanguageTag( LanguageType nLanguage ) } +LanguageTag::LanguageTag( const OUString& rBcp47, const OUString& rLanguage, + const OUString& rScript, const OUString& rCountry ) + : + maBcp47( rBcp47), + mpImplLangtag( NULL), + mnLangID( LANGUAGE_DONTKNOW), + meIsValid( DECISION_DONTKNOW), + meIsIsoLocale( DECISION_DONTKNOW), + meIsIsoODF( DECISION_DONTKNOW), + meIsLiblangtagNeeded( DECISION_DONTKNOW), + mbSystemLocale( rBcp47.isEmpty() && rLanguage.isEmpty()), + mbInitializedBcp47( !rBcp47.isEmpty()), + mbInitializedLocale( false), + mbInitializedLangID( false), + mbCachedLanguage( false), + mbCachedScript( false), + mbCachedCountry( false), + mbIsFallback( false) +{ + if (!mbSystemLocale && !mbInitializedBcp47) + { + if (rScript.isEmpty()) + { + maLocale = lang::Locale( rLanguage, rCountry, ""); + mbInitializedLocale = true; + } + else + { + if (rCountry.isEmpty()) + maBcp47 = rLanguage + "-" + rScript; + else + maBcp47 = rLanguage + "-" + rScript + "-" + rCountry; + mbInitializedBcp47 = true; + } + } +} + + LanguageTag::LanguageTag( const OUString& rLanguage, const OUString& rCountry ) : maLocale( rLanguage, rCountry, ""), diff --git a/include/i18nlangtag/languagetag.hxx b/include/i18nlangtag/languagetag.hxx index 15ca4ec..1a9f499 100644 --- a/include/i18nlangtag/languagetag.hxx +++ b/include/i18nlangtag/languagetag.hxx @@ -53,6 +53,15 @@ public: /** Init LanguageTag with LanguageType MS-LangID. */ explicit LanguageTag( LanguageType nLanguage ); + /** Init LanguageTag with either BCP 47 language tag (precedence if not + empty), or a combination of language, script and country. + + This is a convenience ctor to be used in ODF import where these are + distinct attributes. + */ + explicit LanguageTag( const OUString& rBcp47, const OUString& rLanguage, + const OUString& rScript, const OUString& rCountry ); + /** Init LanguageTag with language and country strings. This is a convenience ctor for places that so far use only language and _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits