diff options
author | Eike Rathke <erack@redhat.com> | 2012-11-23 23:06:10 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2012-11-23 23:09:16 +0100 |
commit | af60316514f3ae3d4c475819bf86f2af837171e3 (patch) | |
tree | ccfbd673bd4a53047a04dad6457d09c7eea1566c /unotools | |
parent | prepend module local include (diff) | |
download | core-af60316514f3ae3d4c475819bf86f2af837171e3.tar.gz core-af60316514f3ae3d4c475819bf86f2af837171e3.zip |
some i18n wrappers with LanguageTag
Change-Id: I2ceaa3159e8669c2c569fa8559c1e061dcad399d
Diffstat (limited to 'unotools')
-rw-r--r-- | unotools/inc/unotools/charclass.hxx | 15 | ||||
-rw-r--r-- | unotools/inc/unotools/intlwrapper.hxx | 11 | ||||
-rw-r--r-- | unotools/inc/unotools/localedatawrapper.hxx | 16 | ||||
-rw-r--r-- | unotools/source/i18n/charclass.cxx | 57 | ||||
-rw-r--r-- | unotools/source/i18n/intlwrapper.cxx | 23 | ||||
-rw-r--r-- | unotools/source/i18n/localedatawrapper.cxx | 78 | ||||
-rw-r--r-- | unotools/source/i18n/textsearch.cxx | 2 | ||||
-rw-r--r-- | unotools/source/misc/syslocale.cxx | 10 |
8 files changed, 107 insertions, 105 deletions
diff --git a/unotools/inc/unotools/charclass.hxx b/unotools/inc/unotools/charclass.hxx index 744321091230..c08e84c7d0a4 100644 --- a/unotools/inc/unotools/charclass.hxx +++ b/unotools/inc/unotools/charclass.hxx @@ -23,6 +23,7 @@ #include <ctype.h> // isdigit(), isalpha() #include <boost/noncopyable.hpp> +#include <i18npool/languagetag.hxx> #include <tools/string.hxx> #include <tools/solar.h> #include <com/sun/star/i18n/KCharacterType.hpp> @@ -68,7 +69,7 @@ const sal_Int32 nCharClassNumericTypeMask = class UNOTOOLS_DLLPUBLIC CharClass : private boost::noncopyable { - ::com::sun::star::lang::Locale aLocale; + LanguageTag maLanguageTag; ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XCharacterClassification > xCC; mutable ::osl::Mutex aMutex; @@ -76,19 +77,19 @@ public: /// Preferred ctor with service manager specified CharClass( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rxContext, - const ::com::sun::star::lang::Locale& rLocale); + const LanguageTag& rLanguageTag ); /// Depricated ctor, tries to get a process service manager or to load the /// library directly. - CharClass(const ::com::sun::star::lang::Locale& rLocale); + CharClass( const LanguageTag& rLanguageTag ); ~CharClass(); /// set a new Locale - void setLocale( const ::com::sun::star::lang::Locale& rLocale ); + void setLanguageTag( const LanguageTag& rLanguageTag ); /// get current Locale - const ::com::sun::star::lang::Locale& getLocale() const; + const LanguageTag& getLanguageTag() const; /// isdigit() on ascii values @@ -213,6 +214,10 @@ public: sal_Bool isNumeric( const String& rStr ) const; sal_Bool isAlphaNumeric( const String& rStr ) const; sal_Bool isLetterNumeric( const String& rStr ) const; + +private: + + const ::com::sun::star::lang::Locale & getMyLocale() const; }; #endif // _UNOTOOLS_CHARCLASS_HXX diff --git a/unotools/inc/unotools/intlwrapper.hxx b/unotools/inc/unotools/intlwrapper.hxx index fa2625057d24..7d1665264d4d 100644 --- a/unotools/inc/unotools/intlwrapper.hxx +++ b/unotools/inc/unotools/intlwrapper.hxx @@ -48,7 +48,7 @@ class UNOTOOLS_DLLPUBLIC IntlWrapper { private: - LanguageTag aLanguageTag; + LanguageTag maLanguageTag; ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xSMgr; LocaleDataWrapper* pLocaleData; @@ -62,16 +62,11 @@ private: public: IntlWrapper( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & xSF, - const ::com::sun::star::lang::Locale& rLocale - ); - IntlWrapper( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & xSF, - LanguageType eLang + const LanguageTag& rLanguageTag ); ~IntlWrapper(); - LanguageType getLanguage() const { return aLanguageTag.getLanguageType(); } - const ::com::sun::star::lang::Locale& getLocale() const { return aLanguageTag.getLocale(); } + const LanguageTag& getLanguageTag() const { return maLanguageTag; } const LocaleDataWrapper* getLocaleData() const { diff --git a/unotools/inc/unotools/localedatawrapper.hxx b/unotools/inc/unotools/localedatawrapper.hxx index 1198895753d9..1db497abcd3f 100644 --- a/unotools/inc/unotools/localedatawrapper.hxx +++ b/unotools/inc/unotools/localedatawrapper.hxx @@ -26,6 +26,7 @@ #include <com/sun/star/i18n/LocaleItem.hpp> #include <com/sun/star/i18n/reservedWords.hpp> #include <rtl/ustring.hxx> +#include <i18npool/languagetag.hxx> #include <unotools/readwritemutexguard.hxx> #include "unotools/unotoolsdllapi.h" @@ -58,7 +59,7 @@ class UNOTOOLS_DLLPUBLIC LocaleDataWrapper : private boost::noncopyable ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XLocaleData4 > xLD; - ::com::sun::star::lang::Locale aLocale; + LanguageTag maLanguageTag; ::boost::shared_ptr< ::com::sun::star::i18n::Calendar2 > xDefaultCalendar; ::com::sun::star::i18n::LocaleDataItem aLocaleDataItem; ::com::sun::star::uno::Sequence< ::rtl::OUString > aReservedWordSeq; @@ -112,10 +113,10 @@ class UNOTOOLS_DLLPUBLIC LocaleDataWrapper : private boost::noncopyable public: LocaleDataWrapper( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rxContext, - const ::com::sun::star::lang::Locale& rLocale + const LanguageTag& rLanguageTag ); LocaleDataWrapper( - const ::com::sun::star::lang::Locale& rLocale + const LanguageTag& rLanguageTag ); ~LocaleDataWrapper(); @@ -129,13 +130,13 @@ public: const { return m_xContext; } /// set a new Locale to request - void setLocale( const ::com::sun::star::lang::Locale& rLocale ); + void setLanguageTag( const LanguageTag& rLanguageTag ); /// get current requested Locale - const ::com::sun::star::lang::Locale& getLocale() const; + const LanguageTag& getLanguageTag() const; /// get current loaded Locale, which might differ from the requested Locale - ::com::sun::star::lang::Locale getLoadedLocale() const; + LanguageTag getLoadedLanguageTag() const; // Wrapper implementations of service LocaleData @@ -349,6 +350,9 @@ public: static void outputCheckMessage( const char* pStr); private: + + const ::com::sun::star::lang::Locale & getMyLocale() const; + static void evaluateLocaleDataChecking(); }; diff --git a/unotools/source/i18n/charclass.cxx b/unotools/source/i18n/charclass.cxx index fa718cb119d3..bfa85dc81734 100644 --- a/unotools/source/i18n/charclass.cxx +++ b/unotools/source/i18n/charclass.cxx @@ -32,18 +32,20 @@ using namespace ::com::sun::star::uno; CharClass::CharClass( const Reference< uno::XComponentContext > & rxContext, - const lang::Locale& rLocale + const LanguageTag& rLanguageTag ) + : + maLanguageTag( rLanguageTag) { - setLocale( rLocale ); xCC = CharacterClassification::create( rxContext ); } CharClass::CharClass( - const ::com::sun::star::lang::Locale& rLocale ) + const LanguageTag& rLanguageTag ) + : + maLanguageTag( rLanguageTag) { - setLocale( rLocale ); xCC = CharacterClassification::create( comphelper::getProcessComponentContext() ); } @@ -53,19 +55,24 @@ CharClass::~CharClass() } -void CharClass::setLocale( const ::com::sun::star::lang::Locale& rLocale ) +void CharClass::setLanguageTag( const LanguageTag& rLanguageTag ) { ::osl::MutexGuard aGuard( aMutex ); - aLocale.Language = rLocale.Language; - aLocale.Country = rLocale.Country; - aLocale.Variant = rLocale.Variant; + maLanguageTag = rLanguageTag; } -const ::com::sun::star::lang::Locale& CharClass::getLocale() const +const LanguageTag& CharClass::getLanguageTag() const { ::osl::MutexGuard aGuard( aMutex ); - return aLocale; + return maLanguageTag; +} + + +const ::com::sun::star::lang::Locale& CharClass::getMyLocale() const +{ + ::osl::MutexGuard aGuard( aMutex ); + return maLanguageTag.getLocale(); } @@ -111,7 +118,7 @@ sal_Bool CharClass::isAlpha( const String& rStr, xub_StrLen nPos ) const try { if ( xCC.is() ) - return (xCC->getCharacterType( rStr, nPos, getLocale() ) & + return (xCC->getCharacterType( rStr, nPos, getMyLocale() ) & nCharClassAlphaType) != 0; else return sal_False; @@ -134,7 +141,7 @@ sal_Bool CharClass::isLetter( const String& rStr, xub_StrLen nPos ) const try { if ( xCC.is() ) - return (xCC->getCharacterType( rStr, nPos, getLocale() ) & + return (xCC->getCharacterType( rStr, nPos, getMyLocale() ) & nCharClassLetterType) != 0; else return sal_False; @@ -152,7 +159,7 @@ sal_Bool CharClass::isLetter( const String& rStr ) const try { if ( xCC.is() ) - return isLetterType( xCC->getStringType( rStr, 0, rStr.Len(), getLocale() ) ); + return isLetterType( xCC->getStringType( rStr, 0, rStr.Len(), getMyLocale() ) ); else return sal_False; } @@ -173,7 +180,7 @@ sal_Bool CharClass::isDigit( const String& rStr, xub_StrLen nPos ) const try { if ( xCC.is() ) - return (xCC->getCharacterType( rStr, nPos, getLocale() ) & + return (xCC->getCharacterType( rStr, nPos, getMyLocale() ) & KCharacterType::DIGIT) != 0; else return sal_False; @@ -191,7 +198,7 @@ sal_Bool CharClass::isNumeric( const String& rStr ) const try { if ( xCC.is() ) - return isNumericType( xCC->getStringType( rStr, 0, rStr.Len(), getLocale() ) ); + return isNumericType( xCC->getStringType( rStr, 0, rStr.Len(), getMyLocale() ) ); else return sal_False; } @@ -212,7 +219,7 @@ sal_Bool CharClass::isAlphaNumeric( const String& rStr, xub_StrLen nPos ) const try { if ( xCC.is() ) - return (xCC->getCharacterType( rStr, nPos, getLocale() ) & + return (xCC->getCharacterType( rStr, nPos, getMyLocale() ) & (nCharClassAlphaType | KCharacterType::DIGIT)) != 0; else return sal_False; @@ -234,7 +241,7 @@ sal_Bool CharClass::isLetterNumeric( const String& rStr, xub_StrLen nPos ) const try { if ( xCC.is() ) - return (xCC->getCharacterType( rStr, nPos, getLocale() ) & + return (xCC->getCharacterType( rStr, nPos, getMyLocale() ) & (nCharClassLetterType | KCharacterType::DIGIT)) != 0; else return sal_False; @@ -252,7 +259,7 @@ sal_Bool CharClass::isLetterNumeric( const String& rStr ) const try { if ( xCC.is() ) - return isLetterNumericType( xCC->getStringType( rStr, 0, rStr.Len(), getLocale() ) ); + return isLetterNumericType( xCC->getStringType( rStr, 0, rStr.Len(), getMyLocale() ) ); else return sal_False; } @@ -268,7 +275,7 @@ rtl::OUString CharClass::titlecase(const rtl::OUString& rStr, sal_Int32 nPos, sa try { if ( xCC.is() ) - return xCC->toTitle( rStr, nPos, nCount, getLocale() ); + return xCC->toTitle( rStr, nPos, nCount, getMyLocale() ); else return rStr.copy( nPos, nCount ); } @@ -284,7 +291,7 @@ rtl::OUString CharClass::titlecase(const rtl::OUString& rStr, sal_Int32 nPos, sa try { if ( xCC.is() ) - return xCC->toUpper( rStr, nPos, nCount, getLocale() ); + return xCC->toUpper( rStr, nPos, nCount, getMyLocale() ); else return rStr.copy( nPos, nCount ); } @@ -300,7 +307,7 @@ rtl::OUString CharClass::titlecase(const rtl::OUString& rStr, sal_Int32 nPos, sa try { if ( xCC.is() ) - return xCC->toLower( rStr, nPos, nCount, getLocale() ); + return xCC->toLower( rStr, nPos, nCount, getMyLocale() ); else return rStr.copy( nPos, nCount ); } @@ -367,7 +374,7 @@ sal_Int32 CharClass::getCharacterType( const String& rStr, xub_StrLen nPos ) con try { if ( xCC.is() ) - return xCC->getCharacterType( rStr, nPos, getLocale() ); + return xCC->getCharacterType( rStr, nPos, getMyLocale() ); else return 0; } @@ -384,7 +391,7 @@ sal_Int32 CharClass::getStringType( const String& rStr, xub_StrLen nPos, xub_Str try { if ( xCC.is() ) - return xCC->getStringType( rStr, nPos, nCount, getLocale() ); + return xCC->getStringType( rStr, nPos, nCount, getMyLocale() ); else return 0; } @@ -407,7 +414,7 @@ sal_Int32 CharClass::getStringType( const String& rStr, xub_StrLen nPos, xub_Str try { if ( xCC.is() ) - return xCC->parseAnyToken( rStr, nPos, getLocale(), + return xCC->parseAnyToken( rStr, nPos, getMyLocale(), nStartCharFlags, userDefinedCharactersStart, nContCharFlags, userDefinedCharactersCont ); else @@ -433,7 +440,7 @@ sal_Int32 CharClass::getStringType( const String& rStr, xub_StrLen nPos, xub_Str try { if ( xCC.is() ) - return xCC->parsePredefinedToken( nTokenType, rStr, nPos, getLocale(), + return xCC->parsePredefinedToken( nTokenType, rStr, nPos, getMyLocale(), nStartCharFlags, userDefinedCharactersStart, nContCharFlags, userDefinedCharactersCont ); else diff --git a/unotools/source/i18n/intlwrapper.cxx b/unotools/source/i18n/intlwrapper.cxx index 9536798d3b60..075604e92b9c 100644 --- a/unotools/source/i18n/intlwrapper.cxx +++ b/unotools/source/i18n/intlwrapper.cxx @@ -25,22 +25,9 @@ IntlWrapper::IntlWrapper( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & xSF, - const ::com::sun::star::lang::Locale& rLocale ) + const LanguageTag& rLanguageTag ) : - aLanguageTag( rLocale ), - xSMgr( xSF ), - pLocaleData( NULL ), - pCollator( NULL ), - pCaseCollator( NULL ) -{ -} - - -IntlWrapper::IntlWrapper( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & xSF, - LanguageType eLang ) - : - aLanguageTag( eLang ), + maLanguageTag( rLanguageTag ), xSMgr( xSF ), pLocaleData( NULL ), pCollator( NULL ), @@ -60,7 +47,7 @@ IntlWrapper::~IntlWrapper() void IntlWrapper::ImplNewLocaleData() const { ((IntlWrapper*)this)->pLocaleData = new LocaleDataWrapper( - comphelper::getComponentContext(xSMgr), aLanguageTag.getLocale() ); + comphelper::getComponentContext(xSMgr), maLanguageTag ); } @@ -69,12 +56,12 @@ void IntlWrapper::ImplNewCollator( sal_Bool bCaseSensitive ) const CollatorWrapper* p = new CollatorWrapper( xSMgr ); if ( bCaseSensitive ) { - p->loadDefaultCollator( aLanguageTag.getLocale(), 0 ); + p->loadDefaultCollator( maLanguageTag.getLocale(), 0 ); ((IntlWrapper*)this)->pCaseCollator = p; } else { - p->loadDefaultCollator( aLanguageTag.getLocale(), + p->loadDefaultCollator( maLanguageTag.getLocale(), ::com::sun::star::i18n::CollatorOptions::CollatorOptions_IGNORE_CASE ); ((IntlWrapper*)this)->pCollator = p; } diff --git a/unotools/source/i18n/localedatawrapper.cxx b/unotools/source/i18n/localedatawrapper.cxx index c31672b03f21..ceffc85fd9fd 100644 --- a/unotools/source/i18n/localedatawrapper.cxx +++ b/unotools/source/i18n/localedatawrapper.cxx @@ -67,27 +67,29 @@ sal_uInt8 LocaleDataWrapper::nLocaleDataChecking = 0; LocaleDataWrapper::LocaleDataWrapper( const Reference< uno::XComponentContext > & rxContext, - const lang::Locale& rLocale + const LanguageTag& rLanguageTag ) : m_xContext( rxContext ), xLD( LocaleData::create(rxContext) ), + maLanguageTag( rLanguageTag ), bLocaleDataItemValid( sal_False ), bReservedWordValid( sal_False ) { - setLocale( rLocale ); + invalidateData(); } LocaleDataWrapper::LocaleDataWrapper( - const lang::Locale& rLocale + const LanguageTag& rLanguageTag ) : m_xContext( comphelper::getProcessComponentContext() ), xLD( LocaleData::create(m_xContext) ), + maLanguageTag( rLanguageTag ), bLocaleDataItemValid( sal_False ), bReservedWordValid( sal_False ) { - setLocale( rLocale ); + invalidateData(); } LocaleDataWrapper::~LocaleDataWrapper() @@ -95,18 +97,25 @@ LocaleDataWrapper::~LocaleDataWrapper() } -void LocaleDataWrapper::setLocale( const ::com::sun::star::lang::Locale& rLocale ) +void LocaleDataWrapper::setLanguageTag( const LanguageTag& rLanguageTag ) { ::utl::ReadWriteGuard aGuard( aMutex, ::utl::ReadWriteGuardMode::nCriticalChange ); - aLocale = rLocale; + maLanguageTag = rLanguageTag; invalidateData(); } -const ::com::sun::star::lang::Locale& LocaleDataWrapper::getLocale() const +const LanguageTag& LocaleDataWrapper::getLanguageTag() const +{ + ::utl::ReadWriteGuard aGuard( aMutex ); + return maLanguageTag; +} + + +const ::com::sun::star::lang::Locale& LocaleDataWrapper::getMyLocale() const { ::utl::ReadWriteGuard aGuard( aMutex ); - return aLocale; + return maLanguageTag.getLocale(); } @@ -142,7 +151,7 @@ void LocaleDataWrapper::invalidateData() { try { - return xLD->getLanguageCountryInfo( getLocale() ); + return xLD->getLanguageCountryInfo( getMyLocale() ); } catch (const Exception& e) { @@ -156,7 +165,7 @@ void LocaleDataWrapper::invalidateData() { try { - return xLD->getLocaleItem( getLocale() ); + return xLD->getLocaleItem( getMyLocale() ); } catch (const Exception& e) { @@ -170,7 +179,7 @@ void LocaleDataWrapper::invalidateData() { try { - return xLD->getAllCurrencies2( getLocale() ); + return xLD->getAllCurrencies2( getMyLocale() ); } catch (const Exception& e) { @@ -184,7 +193,7 @@ void LocaleDataWrapper::invalidateData() { try { - return xLD->getAllFormats( getLocale() ); + return xLD->getAllFormats( getMyLocale() ); } catch (const Exception& e) { @@ -198,7 +207,7 @@ void LocaleDataWrapper::invalidateData() { try { - return xLD->getForbiddenCharacters( getLocale() ); + return xLD->getForbiddenCharacters( getMyLocale() ); } catch (const Exception& e) { @@ -212,7 +221,7 @@ void LocaleDataWrapper::invalidateData() { try { - return xLD->getReservedWord( getLocale() ); + return xLD->getReservedWord( getMyLocale() ); } catch ( const Exception& e ) { @@ -251,7 +260,7 @@ void LocaleDataWrapper::invalidateData() if ( !rInstalledLocales.getLength() ) { - LocaleDataWrapper aLDW( ::comphelper::getProcessComponentContext(), lang::Locale() ); + LocaleDataWrapper aLDW( ::comphelper::getProcessComponentContext(), LanguageTag( lang::Locale()) ); aLDW.getAllInstalledLocaleNames(); } return rInstalledLocales; @@ -279,11 +288,11 @@ void LocaleDataWrapper::invalidateData() aDebugLocale = xLoc[i].Language; if ( !xLoc[i].Country.isEmpty() ) { - aDebugLocale += '_'; + aDebugLocale += '-'; aDebugLocale += String( xLoc[i].Country); if ( !xLoc[i].Variant.isEmpty() ) { - aDebugLocale += '_'; + aDebugLocale += '-'; aDebugLocale += String( xLoc[i].Variant); } } @@ -299,7 +308,8 @@ void LocaleDataWrapper::invalidateData() } continue; } - LanguageType eLang = LanguageTag( xLoc[i] ).getLanguageType(); + LanguageTag aLanguageTag( xLoc[i] ); + LanguageType eLang = aLanguageTag.getLanguageType(); // In checks, exclude known problems because no MS-LCID defined. if (areChecksEnabled() && eLang == LANGUAGE_DONTKNOW) @@ -317,10 +327,8 @@ void LocaleDataWrapper::invalidateData() } if ( eLang != LANGUAGE_DONTKNOW ) { - LanguageTag aLanguageTag( eLang); - lang::Locale aLocale = aLanguageTag.getLocale(); - if ( xLoc[i].Language != aLocale.Language || - xLoc[i].Country != aLocale.Country ) + LanguageTag aBackLanguageTag( eLang); + if ( aLanguageTag != aBackLanguageTag ) { // In checks, exclude known problems because no MS-LCID defined // and default for Language found. @@ -338,7 +346,7 @@ void LocaleDataWrapper::invalidateData() aMsg.appendAscii(RTL_CONSTASCII_STRINGPARAM( " -> 0x")); aMsg.append(static_cast<sal_Int32>(eLang), 16); aMsg.appendAscii(RTL_CONSTASCII_STRINGPARAM( " -> ")); - aMsg.append(aLanguageTag.getBcp47()); + aMsg.append(aBackLanguageTag.getBcp47()); outputCheckMessage( aMsg.makeStringAndClear() ); } eLang = LANGUAGE_DONTKNOW; @@ -704,7 +712,7 @@ void LocaleDataWrapper::scanCurrFormatImpl( const rtl::OUString& rCode, void LocaleDataWrapper::getCurrFormatsImpl() { - NumberFormatCodeWrapper aNumberFormatCode( m_xContext, getLocale() ); + NumberFormatCodeWrapper aNumberFormatCode( m_xContext, getMyLocale() ); uno::Sequence< NumberFormatCode > aFormatSeq = aNumberFormatCode.getAllFormatCode( KNumberFormatUsage::CURRENCY ); sal_Int32 nCnt = aFormatSeq.getLength(); @@ -961,7 +969,7 @@ DateFormat LocaleDataWrapper::scanDateFormatImpl( const rtl::OUString& rCode ) void LocaleDataWrapper::getDateFormatsImpl() { - NumberFormatCodeWrapper aNumberFormatCode( m_xContext, getLocale() ); + NumberFormatCodeWrapper aNumberFormatCode( m_xContext, getMyLocale() ); uno::Sequence< NumberFormatCode > aFormatSeq = aNumberFormatCode.getAllFormatCode( KNumberFormatUsage::DATE ); sal_Int32 nCnt = aFormatSeq.getLength(); @@ -1751,10 +1759,10 @@ rtl::OUString LocaleDataWrapper::getCurr( sal_Int64 nNumber, sal_uInt16 nDecimal // --- mixed ---------------------------------------------------------- -::com::sun::star::lang::Locale LocaleDataWrapper::getLoadedLocale() const +LanguageTag LocaleDataWrapper::getLoadedLanguageTag() const { LanguageCountryInfo aLCInfo = getLanguageCountryInfo(); - return lang::Locale( aLCInfo.Language, aLCInfo.Country, aLCInfo.Variant ); + return LanguageTag( lang::Locale( aLCInfo.Language, aLCInfo.Country, aLCInfo.Variant )); } @@ -1763,14 +1771,10 @@ rtl::OUString LocaleDataWrapper::appendLocaleInfo(const rtl::OUString& rDebugMsg ::utl::ReadWriteGuard aGuard( aMutex, ::utl::ReadWriteGuardMode::nBlockCritical ); rtl::OUStringBuffer aDebugMsg(rDebugMsg); aDebugMsg.append(static_cast<sal_Unicode>('\n')); - aDebugMsg.append(aLocale.Language); - aDebugMsg.append(static_cast<sal_Unicode>('_')); - aDebugMsg.append(aLocale.Country); + aDebugMsg.append(maLanguageTag.getBcp47()); aDebugMsg.appendAscii(RTL_CONSTASCII_STRINGPARAM(" requested\n")); - lang::Locale aLoaded = getLoadedLocale(); - aDebugMsg.append(aLoaded.Language); - aDebugMsg.append(static_cast<sal_Unicode>('_')); - aDebugMsg.append(aLoaded.Country); + LanguageTag aLoaded = getLoadedLanguageTag(); + aDebugMsg.append(aLoaded.getBcp47()); aDebugMsg.appendAscii(RTL_CONSTASCII_STRINGPARAM(" loaded")); return aDebugMsg.makeStringAndClear(); } @@ -1831,7 +1835,7 @@ void LocaleDataWrapper::evaluateLocaleDataChecking() { try { - return xLD->getAllCalendars2( getLocale() ); + return xLD->getAllCalendars2( getMyLocale() ); } catch (const Exception& e) { @@ -1855,7 +1859,7 @@ void LocaleDataWrapper::evaluateLocaleDataChecking() try { const_cast<LocaleDataWrapper*>(this)->aDateAcceptancePatterns = - xLD->getDateAcceptancePatterns( getLocale() ); + xLD->getDateAcceptancePatterns( getMyLocale() ); return aDateAcceptancePatterns; } catch (const Exception& e) @@ -1876,7 +1880,7 @@ void LocaleDataWrapper::setDateAcceptancePatterns( { try { - aDateAcceptancePatterns = xLD->getDateAcceptancePatterns( getLocale() ); + aDateAcceptancePatterns = xLD->getDateAcceptancePatterns( getMyLocale() ); } catch (const Exception& e) { diff --git a/unotools/source/i18n/textsearch.cxx b/unotools/source/i18n/textsearch.cxx index 4d1d68aad316..a6f851230858 100644 --- a/unotools/source/i18n/textsearch.cxx +++ b/unotools/source/i18n/textsearch.cxx @@ -132,7 +132,7 @@ TextSearch::TextSearch(const SearchParam & rParam, LanguageType eLang ) TextSearch::TextSearch(const SearchParam & rParam, const CharClass& rCClass ) { - Init( rParam, rCClass.getLocale() ); + Init( rParam, rCClass.getLanguageTag().getLocale() ); } TextSearch::TextSearch( const SearchOptions& rPara ) diff --git a/unotools/source/misc/syslocale.cxx b/unotools/source/misc/syslocale.cxx index c8b0fe10e0af..d850dd73aab2 100644 --- a/unotools/source/misc/syslocale.cxx +++ b/unotools/source/misc/syslocale.cxx @@ -55,7 +55,7 @@ private: SvtSysLocale_Impl::SvtSysLocale_Impl() : pCharClass(NULL) { - pLocaleData = new LocaleDataWrapper( aSysLocaleOptions.GetRealLanguageTag().getLocale() ); + pLocaleData = new LocaleDataWrapper( aSysLocaleOptions.GetRealLanguageTag() ); setDateAcceptancePatternsConfig(); // listen for further changes @@ -73,7 +73,7 @@ SvtSysLocale_Impl::~SvtSysLocale_Impl() CharClass* SvtSysLocale_Impl::GetCharClass() { if ( !pCharClass ) - pCharClass = new CharClass( aSysLocaleOptions.GetRealLanguageTag().getLocale() ); + pCharClass = new CharClass( aSysLocaleOptions.GetRealLanguageTag() ); return pCharClass; } @@ -83,9 +83,9 @@ void SvtSysLocale_Impl::ConfigurationChanged( utl::ConfigurationBroadcaster*, sa if ( nHint & SYSLOCALEOPTIONS_HINT_LOCALE ) { - com::sun::star::lang::Locale aLocale( aSysLocaleOptions.GetRealLanguageTag().getLocale() ); - pLocaleData->setLocale( aLocale ); - GetCharClass()->setLocale( aLocale ); + const LanguageTag& rLanguageTag = aSysLocaleOptions.GetRealLanguageTag(); + pLocaleData->setLanguageTag( rLanguageTag ); + GetCharClass()->setLanguageTag( rLanguageTag ); } if ( nHint & SYSLOCALEOPTIONS_HINT_DATEPATTERNS ) { |