summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2012-11-16 12:29:37 +0100
committerEike Rathke <erack@redhat.com>2012-11-16 12:49:40 +0100
commit2814ecb92f9dc1f60094cfa41ab1fa6eaa03471b (patch)
tree85c361ad6c93506e6891508b00a9de8915abed25 /unotools
parentb6c6fc8cedcc7ffc774b8e7373087c7b09479dff (diff)
converted to use LanguageTag
Change-Id: I25c5d965d953146e91903cf2ff8e6b58f978ad20
Diffstat (limited to 'unotools')
-rw-r--r--unotools/inc/unotools/intlwrapper.hxx8
-rw-r--r--unotools/inc/unotools/transliterationwrapper.hxx8
-rw-r--r--unotools/source/config/lingucfg.cxx13
-rw-r--r--unotools/source/config/syslocaleoptions.cxx44
-rw-r--r--unotools/source/i18n/intlwrapper.cxx16
-rw-r--r--unotools/source/i18n/localedatawrapper.cxx19
-rw-r--r--unotools/source/i18n/textsearch.cxx5
-rw-r--r--unotools/source/i18n/transliterationwrapper.cxx22
8 files changed, 63 insertions, 72 deletions
diff --git a/unotools/inc/unotools/intlwrapper.hxx b/unotools/inc/unotools/intlwrapper.hxx
index a6ec4e33522a..aceba1d30410 100644
--- a/unotools/inc/unotools/intlwrapper.hxx
+++ b/unotools/inc/unotools/intlwrapper.hxx
@@ -47,15 +47,13 @@ class UNOTOOLS_DLLPUBLIC IntlWrapper
{
private:
- ::com::sun::star::lang::Locale aLocale;
+ LanguageTag aLanguageTag;
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xSMgr;
LocaleDataWrapper* pLocaleData;
CollatorWrapper* pCollator;
CollatorWrapper* pCaseCollator;
- LanguageType eLanguage;
-
void ImplNewLocaleData() const;
void ImplNewCollator( sal_Bool bCaseSensitive ) const;
@@ -71,8 +69,8 @@ public:
);
~IntlWrapper();
- LanguageType getLanguage() const { return eLanguage; }
- const ::com::sun::star::lang::Locale& getLocale() const { return aLocale; }
+ LanguageType getLanguage() const { return aLanguageTag.getLanguageType(); }
+ const ::com::sun::star::lang::Locale& getLocale() const { return aLanguageTag.getLocale(); }
const LocaleDataWrapper* getLocaleData() const
{
diff --git a/unotools/inc/unotools/transliterationwrapper.hxx b/unotools/inc/unotools/transliterationwrapper.hxx
index 3a0a8de05042..18b7072fdae9 100644
--- a/unotools/inc/unotools/transliterationwrapper.hxx
+++ b/unotools/inc/unotools/transliterationwrapper.hxx
@@ -22,6 +22,7 @@
#define _UNOTOOLS_TRANSLITERATIONWRAPPER_HXX
#include <tools/string.hxx>
#include <tools/solar.h>
+#include <i18npool/languagetag.hxx>
#include <com/sun/star/i18n/XExtendedTransliteration.hpp>
namespace com { namespace sun { namespace star {
@@ -37,9 +38,8 @@ class UNOTOOLS_DLLPUBLIC TransliterationWrapper
{
::com::sun::star::uno::Reference<
::com::sun::star::i18n::XExtendedTransliteration > xTrans;
- ::com::sun::star::lang::Locale aLocale;
+ LanguageTag aLanguageTag;
sal_uInt32 nType;
- sal_uInt16 nLanguage;
mutable sal_Bool bFirstCall;
// not implemented, prevent usage
@@ -57,8 +57,8 @@ public:
~TransliterationWrapper();
// get current Locale / Language
- const ::com::sun::star::lang::Locale& getLocale() const { return aLocale;}
- sal_uInt16 getLanguage() const { return nLanguage; }
+ const ::com::sun::star::lang::Locale& getLocale() const { return aLanguageTag.getLocale();}
+ sal_uInt16 getLanguage() const { return aLanguageTag.getLanguageType(); }
sal_uInt32 getType() const { return nType; }
diff --git a/unotools/source/config/lingucfg.cxx b/unotools/source/config/lingucfg.cxx
index 7407d8289944..7c1893b2a778 100644
--- a/unotools/source/config/lingucfg.cxx
+++ b/unotools/source/config/lingucfg.cxx
@@ -29,6 +29,7 @@
#include <rtl/instance.hxx>
#include <osl/mutex.hxx>
#include <i18npool/mslangid.hxx>
+#include <i18npool/languagetag.hxx>
#include <tools/debug.hxx>
#include <tools/string.hxx>
#include <unotools/lingucfg.hxx>
@@ -61,7 +62,7 @@ static sal_Bool lcl_SetLocale( sal_Int16 &rLanguage, const uno::Any &rVal )
lang::Locale aNew;
if (rVal >>= aNew) // conversion successful?
{
- sal_Int16 nNew = MsLangId::convertLocaleToLanguage( aNew );
+ sal_Int16 nNew = LanguageTag( aNew ).getLanguageType( false);
if (nNew != rLanguage)
{
rLanguage = nNew;
@@ -75,7 +76,7 @@ static inline const OUString lcl_LanguageToCfgLocaleStr( sal_Int16 nLanguage )
{
OUString aRes;
if (LANGUAGE_SYSTEM != nLanguage)
- aRes = MsLangId::convertLanguageToIsoString( nLanguage );
+ aRes = LanguageTag( nLanguage ).getBcp47();
return aRes;
}
@@ -83,7 +84,7 @@ static sal_Int16 lcl_CfgAnyToLanguage( const uno::Any &rVal )
{
OUString aTmp;
rVal >>= aTmp;
- return (aTmp.isEmpty()) ? LANGUAGE_SYSTEM : MsLangId::convertIsoStringToLanguage( aTmp );
+ return (aTmp.isEmpty()) ? LANGUAGE_SYSTEM : LanguageTag( aTmp ).getLanguageType();
}
SvtLinguOptions::SvtLinguOptions()
@@ -365,19 +366,19 @@ uno::Any SvtLinguConfigItem::GetProperty( sal_Int32 nPropertyHandle ) const
}
case UPH_DEFAULT_LOCALE :
{
- lang::Locale aLocale( MsLangId::convertLanguageToLocale( rOpt.nDefaultLanguage, false ) );
+ lang::Locale aLocale( LanguageTag( rOpt.nDefaultLanguage ).getLocale( false ) );
aRes.setValue( &aLocale, ::getCppuType((lang::Locale*)0 ));
break;
}
case UPH_DEFAULT_LOCALE_CJK :
{
- lang::Locale aLocale( MsLangId::convertLanguageToLocale( rOpt.nDefaultLanguage_CJK, false ) );
+ lang::Locale aLocale( LanguageTag( rOpt.nDefaultLanguage_CJK ).getLocale( false ) );
aRes.setValue( &aLocale, ::getCppuType((lang::Locale*)0 ));
break;
}
case UPH_DEFAULT_LOCALE_CTL :
{
- lang::Locale aLocale( MsLangId::convertLanguageToLocale( rOpt.nDefaultLanguage_CTL, false ) );
+ lang::Locale aLocale( LanguageTag( rOpt.nDefaultLanguage_CTL ).getLocale( false ) );
aRes.setValue( &aLocale, ::getCppuType((lang::Locale*)0 ));
break;
}
diff --git a/unotools/source/config/syslocaleoptions.cxx b/unotools/source/config/syslocaleoptions.cxx
index 80946fd9c88a..e37725ffaf89 100644
--- a/unotools/source/config/syslocaleoptions.cxx
+++ b/unotools/source/config/syslocaleoptions.cxx
@@ -22,6 +22,7 @@
#include <rtl/instance.hxx>
#include <rtl/logfile.hxx>
#include <i18npool/mslangid.hxx>
+#include <i18npool/languagetag.hxx>
#include <tools/string.hxx>
#include <tools/debug.hxx>
#include <unotools/syslocaleoptions.hxx>
@@ -70,10 +71,8 @@ static com::sun::star::lang::Locale lcl_str_to_locale( const ::rtl::OUString rSt
class SvtSysLocaleOptions_Impl : public utl::ConfigItem
{
- Locale m_aRealLocale;
- Locale m_aRealUILocale;
- LanguageType m_eRealLanguage;
- LanguageType m_eRealUILanguage;
+ LanguageTag m_aRealLocale;
+ LanguageTag m_aRealUILocale;
OUString m_aLocaleString; // en-US or de-DE or empty for SYSTEM
OUString m_aUILocaleString; // en-US or de-DE or empty for SYSTEM
OUString m_aCurrencyString; // USD-en-US or EUR-de-DE
@@ -122,10 +121,10 @@ public:
void SetIgnoreLanguageChange( sal_Bool bSet);
sal_Bool IsReadOnly( SvtSysLocaleOptions::EOption eOption ) const;
- const Locale& GetRealLocale() { return m_aRealLocale; }
- const Locale& GetRealUILocale() { return m_aRealUILocale; }
- LanguageType GetRealLanguage() { return m_eRealLanguage; }
- LanguageType GetRealUILanguage() { return m_eRealUILanguage; }
+ const Locale& GetRealLocale() { return m_aRealLocale.getLocale(); }
+ const Locale& GetRealUILocale() { return m_aRealUILocale.getLocale(); }
+ LanguageType GetRealLanguage() { return m_eRealLanguage.getLanguageType(); }
+ LanguageType GetRealUILanguage() { return m_eRealUILanguage.getLanguageType(); }
};
@@ -167,6 +166,8 @@ const Sequence< OUString > SvtSysLocaleOptions_Impl::GetPropertyNames()
SvtSysLocaleOptions_Impl::SvtSysLocaleOptions_Impl()
: ConfigItem( ROOTNODE_SYSLOCALE )
+ , m_aRealLocale( LANGUAGE_SYSTEM)
+ , m_aRealUILocale( LANGUAGE_SYSTEM)
, m_bDecimalSeparator( sal_True )
, m_bROLocale(CFG_READONLY_DEFAULT)
, m_bROUILocale(CFG_READONLY_DEFAULT)
@@ -287,30 +288,27 @@ SvtSysLocaleOptions_Impl::~SvtSysLocaleOptions_Impl()
void SvtSysLocaleOptions_Impl::MakeRealLocale()
{
- m_aRealLocale = lcl_str_to_locale( m_aLocaleString );
- if ( !m_aRealLocale.Language.isEmpty() )
+ if (m_aLocaleString.isEmpty())
{
- m_eRealLanguage = MsLangId::convertLocaleToLanguage( m_aRealLocale );
+ LanguageType nLang = MsLangId::getSystemLanguage();
+ m_aRealLocale = LanguageTag( nLang);
}
else
{
- m_eRealLanguage = MsLangId::getSystemLanguage();
- MsLangId::convertLanguageToLocale( m_eRealLanguage, m_aRealLocale );
+ m_aRealLocale = LanguageTag( m_aLocaleString);
}
}
void SvtSysLocaleOptions_Impl::MakeRealUILocale()
{
- // as we can't switch UILocale at runtime, we only store changes in the configuration
- m_aRealUILocale = lcl_str_to_locale( m_aUILocaleString );
- if ( !m_aRealUILocale.Language.isEmpty() )
+ if (m_aUILocaleString.isEmpty())
{
- m_eRealUILanguage = MsLangId::convertLocaleToLanguage( m_aRealUILocale );
+ LanguageType nLang = MsLangId::getSystemUILanguage();
+ m_aRealUILocale = LanguageTag( nLang);
}
else
{
- m_eRealUILanguage = MsLangId::getSystemUILanguage();
- MsLangId::convertLanguageToLocale( m_eRealUILanguage, m_aRealUILocale );
+ m_aRealUILocale = LanguageTag( m_aUILocaleString);
}
}
@@ -431,7 +429,7 @@ void SvtSysLocaleOptions_Impl::SetLocaleString( const OUString& rStr )
{
m_aLocaleString = rStr;
MakeRealLocale();
- MsLangId::setConfiguredSystemLanguage( m_eRealLanguage );
+ MsLangId::setConfiguredSystemLanguage( m_aRealLocale.getLanguageType() );
SetModified();
sal_uLong nHint = SYSLOCALEOPTIONS_HINT_LOCALE;
if ( m_aCurrencyString.isEmpty() )
@@ -448,7 +446,7 @@ void SvtSysLocaleOptions_Impl::SetUILocaleString( const OUString& rStr )
// as we can't switch UILocale at runtime, we only store changes in the configuration
MakeRealUILocale();
- MsLangId::setConfiguredSystemLanguage( m_eRealUILanguage );
+ MsLangId::setConfiguredSystemLanguage( m_aRealUILocale.getLanguageType() );
SetModified();
NotifyListeners( SYSLOCALEOPTIONS_HINT_UILOCALE );
}
@@ -700,7 +698,7 @@ void SvtSysLocaleOptions::GetCurrencyAbbrevAndLanguage( String& rAbbrev,
{
rAbbrev = rConfigString.copy( 0, nDelim );
String aIsoStr( rConfigString.copy( nDelim+1 ) );
- eLang = MsLangId::convertIsoStringToLanguage( aIsoStr );
+ eLang = LanguageTag( aIsoStr ).getLanguageType();
}
else
{
@@ -714,7 +712,7 @@ void SvtSysLocaleOptions::GetCurrencyAbbrevAndLanguage( String& rAbbrev,
::rtl::OUString SvtSysLocaleOptions::CreateCurrencyConfigString(
const String& rAbbrev, LanguageType eLang )
{
- String aIsoStr( MsLangId::convertLanguageToIsoString( eLang ) );
+ String aIsoStr( LanguageTag( eLang ).getBcp47() );
if ( aIsoStr.Len() )
{
::rtl::OUStringBuffer aStr( rAbbrev.Len() + 1 + aIsoStr.Len() );
diff --git a/unotools/source/i18n/intlwrapper.cxx b/unotools/source/i18n/intlwrapper.cxx
index 092c90bb07fd..9536798d3b60 100644
--- a/unotools/source/i18n/intlwrapper.cxx
+++ b/unotools/source/i18n/intlwrapper.cxx
@@ -27,13 +27,12 @@ IntlWrapper::IntlWrapper(
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & xSF,
const ::com::sun::star::lang::Locale& rLocale )
:
- aLocale( rLocale ),
+ aLanguageTag( rLocale ),
xSMgr( xSF ),
pLocaleData( NULL ),
pCollator( NULL ),
pCaseCollator( NULL )
{
- eLanguage = MsLangId::convertLocaleToLanguage( aLocale );
}
@@ -41,13 +40,12 @@ IntlWrapper::IntlWrapper(
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & xSF,
LanguageType eLang )
:
+ aLanguageTag( eLang ),
xSMgr( xSF ),
pLocaleData( NULL ),
pCollator( NULL ),
- pCaseCollator( NULL ),
- eLanguage( eLang )
+ pCaseCollator( NULL )
{
- MsLangId::convertLanguageToLocale( eLanguage, aLocale );
}
@@ -61,7 +59,8 @@ IntlWrapper::~IntlWrapper()
void IntlWrapper::ImplNewLocaleData() const
{
- ((IntlWrapper*)this)->pLocaleData = new LocaleDataWrapper( comphelper::getComponentContext(xSMgr), aLocale );
+ ((IntlWrapper*)this)->pLocaleData = new LocaleDataWrapper(
+ comphelper::getComponentContext(xSMgr), aLanguageTag.getLocale() );
}
@@ -70,12 +69,13 @@ void IntlWrapper::ImplNewCollator( sal_Bool bCaseSensitive ) const
CollatorWrapper* p = new CollatorWrapper( xSMgr );
if ( bCaseSensitive )
{
- p->loadDefaultCollator( aLocale, 0 );
+ p->loadDefaultCollator( aLanguageTag.getLocale(), 0 );
((IntlWrapper*)this)->pCaseCollator = p;
}
else
{
- p->loadDefaultCollator( aLocale, ::com::sun::star::i18n::CollatorOptions::CollatorOptions_IGNORE_CASE );
+ p->loadDefaultCollator( aLanguageTag.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 e224f194a179..c31672b03f21 100644
--- a/unotools/source/i18n/localedatawrapper.cxx
+++ b/unotools/source/i18n/localedatawrapper.cxx
@@ -27,7 +27,7 @@
#include <unotools/digitgroupingiterator.hxx>
#include <tools/string.hxx>
#include <tools/debug.hxx>
-#include <i18npool/mslangid.hxx>
+#include <i18npool/languagetag.hxx>
#include "instance.hxx"
#include <com/sun/star/i18n/KNumberFormatUsage.hpp>
@@ -299,7 +299,7 @@ void LocaleDataWrapper::invalidateData()
}
continue;
}
- LanguageType eLang = MsLangId::convertLocaleToLanguage( xLoc[i] );
+ LanguageType eLang = LanguageTag( xLoc[i] ).getLanguageType();
// In checks, exclude known problems because no MS-LCID defined.
if (areChecksEnabled() && eLang == LANGUAGE_DONTKNOW)
@@ -317,10 +317,10 @@ void LocaleDataWrapper::invalidateData()
}
if ( eLang != LANGUAGE_DONTKNOW )
{
- rtl::OUString aLanguage, aCountry;
- MsLangId::convertLanguageToIsoNames( eLang, aLanguage, aCountry );
- if ( xLoc[i].Language != aLanguage ||
- xLoc[i].Country != aCountry )
+ LanguageTag aLanguageTag( eLang);
+ lang::Locale aLocale = aLanguageTag.getLocale();
+ if ( xLoc[i].Language != aLocale.Language ||
+ xLoc[i].Country != aLocale.Country )
{
// In checks, exclude known problems because no MS-LCID defined
// and default for Language found.
@@ -338,12 +338,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(aLanguage);
- if ( !aCountry.isEmpty() )
- {
- aMsg.append('_');
- aMsg.append(aCountry);
- }
+ aMsg.append(aLanguageTag.getBcp47());
outputCheckMessage( aMsg.makeStringAndClear() );
}
eLang = LANGUAGE_DONTKNOW;
diff --git a/unotools/source/i18n/textsearch.cxx b/unotools/source/i18n/textsearch.cxx
index 05eecd8249e9..4d1d68aad316 100644
--- a/unotools/source/i18n/textsearch.cxx
+++ b/unotools/source/i18n/textsearch.cxx
@@ -17,7 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <i18npool/mslangid.hxx>
+#include <i18npool/languagetag.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/util/TextSearch.hpp>
#include <com/sun/star/util/SearchFlags.hpp>
@@ -125,8 +125,7 @@ TextSearch::TextSearch(const SearchParam & rParam, LanguageType eLang )
{
if( LANGUAGE_NONE == eLang )
eLang = LANGUAGE_SYSTEM;
- ::com::sun::star::lang::Locale aLocale(
- MsLangId::convertLanguageToLocale( LanguageType(eLang)));
+ ::com::sun::star::lang::Locale aLocale( LanguageTag( eLang ).getLocale() );
Init( rParam, aLocale);
}
diff --git a/unotools/source/i18n/transliterationwrapper.cxx b/unotools/source/i18n/transliterationwrapper.cxx
index 517ed48f3449..11f188e89438 100644
--- a/unotools/source/i18n/transliterationwrapper.cxx
+++ b/unotools/source/i18n/transliterationwrapper.cxx
@@ -20,7 +20,7 @@
#include <unotools/transliterationwrapper.hxx>
#include <tools/debug.hxx>
-#include <i18npool/mslangid.hxx>
+#include <i18npool/languagetag.hxx>
#include "instance.hxx"
#include <com/sun/star/i18n/TransliterationModulesExtra.hpp>
@@ -34,8 +34,8 @@ using namespace ::utl;
TransliterationWrapper::TransliterationWrapper(
const Reference< XComponentContext > & rxContext,
sal_uInt32 nTyp )
- : xTrans( Transliteration::create(rxContext) ), nType( nTyp ),
- nLanguage( 0 ), bFirstCall( sal_True )
+ : xTrans( Transliteration::create(rxContext) ),
+ aLanguageTag( LANGUAGE_SYSTEM ), nType( nTyp ), bFirstCall( sal_True )
{
}
@@ -107,10 +107,9 @@ sal_Bool TransliterationWrapper::needLanguageForTheMode() const
void TransliterationWrapper::setLanguageLocaleImpl( sal_uInt16 nLang )
{
- nLanguage = nLang;
- if( LANGUAGE_NONE == nLanguage )
- nLanguage = LANGUAGE_SYSTEM;
- MsLangId::convertLanguageToLocale( nLanguage, aLocale);
+ if( LANGUAGE_NONE == nLang )
+ nLang = LANGUAGE_SYSTEM;
+ aLanguageTag = LanguageTag( nLang);
}
@@ -136,7 +135,7 @@ void TransliterationWrapper::loadModuleIfNeeded( sal_uInt16 nLang )
}
else
{
- if( nLanguage != nLang )
+ if( aLanguageTag.getLanguageType() != nLang )
{
setLanguageLocaleImpl( nLang );
if( !bLoad )
@@ -156,7 +155,7 @@ void TransliterationWrapper::loadModuleImpl() const
try
{
if ( xTrans.is() )
- xTrans->loadModule( (TransliterationModules)nType, aLocale );
+ xTrans->loadModule( (TransliterationModules)nType, aLanguageTag.getLocale() );
}
catch ( const Exception& e )
{
@@ -173,9 +172,10 @@ void TransliterationWrapper::loadModuleByImplName(
try
{
setLanguageLocaleImpl( nLang );
- // Reset LanguageType, so the next call to loadModuleIfNeeded() forces
+ com::sun::star::lang::Locale aLocale( aLanguageTag.getLocale());
+ // Reset LanguageTag, so the next call to loadModuleIfNeeded() forces
// new settings.
- nLanguage = LANGUAGE_DONTKNOW;
+ aLanguageTag = LanguageTag( LANGUAGE_DONTKNOW);
if ( xTrans.is() )
xTrans->loadModuleByImplName( rModuleName, aLocale );
}