diff options
author | Eike Rathke <erack@redhat.com> | 2013-03-13 16:35:46 +0100 |
---|---|---|
committer | Fridrich Strba <fridrich@documentfoundation.org> | 2013-03-13 17:00:32 +0000 |
commit | 1e81d7220990765c0cbc1bdede6ad96bbb399cff (patch) | |
tree | 3b8be05a6b4d0b150c3d90a9be740c469c7fce68 | |
parent | 2f13a6e26d6741688c62decdee91e821ee1bd471 (diff) |
resolved fdo#62278 test for LanguageTag equality resolving system locale
added LanguageTag::equals(), fdo#62278 related
(cherry picked from commit fb26196ce64979ab6dc6c82c0fbdeedb126a3433)
Conflicts:
i18npool/inc/i18npool/languagetag.hxx
i18npool/source/languagetag/languagetag.cxx
resolved fdo#62278 test for LanguageTag equality resolving system locale
(cherry picked from commit dde0dcd553b676abcb41eaf3f9f1bf797907e22f)
Change-Id: I7c6e91518b3afd7a42d21bcae41283b0e00b833a
Reviewed-on: https://gerrit.libreoffice.org/2707
Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org>
Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
-rw-r--r-- | i18npool/inc/i18npool/languagetag.hxx | 24 | ||||
-rw-r--r-- | i18npool/source/languagetag/languagetag.cxx | 7 | ||||
-rw-r--r-- | svl/source/numbers/zforlist.cxx | 2 |
3 files changed, 30 insertions, 3 deletions
diff --git a/i18npool/inc/i18npool/languagetag.hxx b/i18npool/inc/i18npool/languagetag.hxx index bb86b72262f0..1e0ae65c4b4a 100644 --- a/i18npool/inc/i18npool/languagetag.hxx +++ b/i18npool/inc/i18npool/languagetag.hxx @@ -204,10 +204,30 @@ public: */ LanguageTag & makeFallback(); - /* Test equality of two LangageTag. */ + /** Test equality of two LanguageTag, possibly resolving system locale. + + @param bResolveSystem + If TRUE, resolve empty language tags denoting the system + locale to the real locale used before comparing. + If FALSE, the behavior is identical to operator==(), system + locales are not resolved first. + */ + bool equals( const LanguageTag & rLanguageTag, bool bResolveSystem = false ) const; + + /** Test equality of two LanguageTag. + + Does NOT resolve system, i.e. if the system locale is en-US + LanguageTag("")==LanguageTag("en-US") returns false! Use + equals(...,true) instead if system locales shall be resolved. + */ bool operator==( const LanguageTag & rLanguageTag ) const; - /* Test inequality of two LangageTag. */ + /** Test inequality of two LanguageTag. + + Does NOT resolve system, i.e. if the system locale is en-US + LanguageTag("")!=LanguageTag("en-US") returns true! Use + !equals(,...true) instead if system locales shall be resolved. + */ bool operator!=( const LanguageTag & rLanguageTag ) const; private: diff --git a/i18npool/source/languagetag/languagetag.cxx b/i18npool/source/languagetag/languagetag.cxx index bab244371063..9055d2b5dc20 100644 --- a/i18npool/source/languagetag/languagetag.cxx +++ b/i18npool/source/languagetag/languagetag.cxx @@ -995,6 +995,13 @@ LanguageTag & LanguageTag::makeFallback() } +bool LanguageTag::equals( const LanguageTag & rLanguageTag, bool bResolveSystem ) const +{ + // Compare full language tag strings. + return getBcp47( bResolveSystem) == rLanguageTag.getBcp47( bResolveSystem); +} + + bool LanguageTag::operator==( const LanguageTag & rLanguageTag ) const { // Compare full language tag strings but SYSTEM unresolved. diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx index 0440835e9214..3e55e22e5cc2 100644 --- a/svl/source/numbers/zforlist.cxx +++ b/svl/source/numbers/zforlist.cxx @@ -972,7 +972,7 @@ sal_uInt32 SvNumberFormatter::ImpGenerateCL( LanguageType eLnge, bool bNoAdditio if (LocaleDataWrapper::areChecksEnabled()) { const LanguageTag& rLoadedLocale = xLocaleData->getLoadedLanguageTag(); - if ( rLoadedLocale != maLanguageTag ) + if ( !rLoadedLocale.equals( maLanguageTag, true) ) { OUString aMsg("SvNumerFormatter::ImpGenerateCL: locales don't match:"); LocaleDataWrapper::outputCheckMessage( xLocaleData->appendLocaleInfo( aMsg )); |