summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2012-11-21 18:34:53 +0100
committerEike Rathke <erack@redhat.com>2012-11-21 18:35:53 +0100
commitb8a467b70756b83c8aeb77f385ea1e368350d370 (patch)
treeeb0c2a0f560899b634ef8598f9022f4af24f1427 /unotools
parentbe677b568690415ff90e7937d7269d3b41b39c16 (diff)
obtain LanguageTag from SvtSysLocale
Change-Id: Iaee25f1d92349704eaae45e6582d31dfa718ddcb
Diffstat (limited to 'unotools')
-rw-r--r--unotools/inc/unotools/syslocale.hxx9
-rw-r--r--unotools/inc/unotools/syslocaleoptions.hxx14
-rw-r--r--unotools/source/config/compatibility.cxx2
-rw-r--r--unotools/source/config/fontcfg.cxx4
-rw-r--r--unotools/source/config/syslocaleoptions.cxx44
-rw-r--r--unotools/source/misc/syslocale.cxx28
6 files changed, 28 insertions, 73 deletions
diff --git a/unotools/inc/unotools/syslocale.hxx b/unotools/inc/unotools/syslocale.hxx
index d10e2c969329..e148504d0940 100644
--- a/unotools/inc/unotools/syslocale.hxx
+++ b/unotools/inc/unotools/syslocale.hxx
@@ -23,15 +23,14 @@
#include "unotools/unotoolsdllapi.h"
#include <unotools/localedatawrapper.hxx>
#include <unotools/charclass.hxx>
+#include <i18npool/languagetag.hxx>
#include <sal/types.h>
-#include <i18npool/lang.h>
#include <rtl/textenc.h>
class SvtSysLocale_Impl;
class SvtSysLocaleOptions;
namespace osl { class Mutex; }
-class LocaleDataWrapper;
/**
SvtSysLocale provides a refcounted single instance of an application wide
@@ -65,10 +64,8 @@ public:
const LocaleDataWrapper* GetLocaleDataPtr() const;
const CharClass* GetCharClassPtr() const;
SvtSysLocaleOptions& GetOptions() const;
- com::sun::star::lang::Locale GetLocale() const;
- LanguageType GetLanguage() const;
- com::sun::star::lang::Locale GetUILocale() const;
- LanguageType GetUILanguage() const;
+ const LanguageTag& GetLanguageTag() const;
+ const LanguageTag& GetUILanguageTag() const;
/** Get the best MIME encoding matching the system locale, or if that isn't
determinable one that matches the UI locale, or UTF8 if everything else
diff --git a/unotools/inc/unotools/syslocaleoptions.hxx b/unotools/inc/unotools/syslocaleoptions.hxx
index a7d1f84bbe9a..d9bb17e36eda 100644
--- a/unotools/inc/unotools/syslocaleoptions.hxx
+++ b/unotools/inc/unotools/syslocaleoptions.hxx
@@ -26,9 +26,9 @@
#include <tools/solar.h>
#include <tools/link.hxx>
#include <i18npool/lang.h>
+#include <i18npool/languagetag.hxx>
#include <tools/string.hxx>
#include <unotools/options.hxx>
-#include <com/sun/star/lang/Locale.hpp>
// bits for broadcasting hints of changes in a SfxSimpleHint, may be combined
const sal_uLong SYSLOCALEOPTIONS_HINT_LOCALE = 0x00000001;
@@ -99,14 +99,16 @@ public:
/// The config string may be empty to denote the SYSTEM locale
const ::rtl::OUString& GetLocaleConfigString() const;
void SetLocaleConfigString( const ::rtl::OUString& rStr );
- com::sun::star::lang::Locale GetLocale() const;
- com::sun::star::lang::Locale GetRealLocale() const;
- LanguageType GetRealLanguage() const;
+ /** Get locale set, if empty denotes SYSTEM locale, not resolved
+ to the real locale. */
+ LanguageTag GetLanguageTag() const;
+ /** Get locale set, always resolved to the real locale. */
+ const LanguageTag& GetRealLanguageTag() const;
/// The config string may be empty to denote the SYSTEM locale
void SetUILocaleConfigString( const ::rtl::OUString& rStr );
- com::sun::star::lang::Locale GetRealUILocale() const;
- LanguageType GetRealUILanguage() const;
+ /** Get UI locale set, always resolved to the real locale. */
+ const LanguageTag& GetRealUILanguageTag() const;
/// The config string may be empty to denote the default currency of the locale
const ::rtl::OUString& GetCurrencyConfigString() const;
diff --git a/unotools/source/config/compatibility.cxx b/unotools/source/config/compatibility.cxx
index 8278137c61bb..e5079a9886d2 100644
--- a/unotools/source/config/compatibility.cxx
+++ b/unotools/source/config/compatibility.cxx
@@ -404,7 +404,7 @@ SvtCompatibilityOptions_Impl::SvtCompatibilityOptions_Impl()
if ( !bDefaultFound && aItem.sName.equals( COMPATIBILITY_DEFAULT_NAME ) != sal_False )
{
SvtSysLocale aSysLocale;
- com::sun::star::lang::Locale aLocale = aSysLocale.GetLocale();
+ com::sun::star::lang::Locale aLocale = aSysLocale.GetLanguageTag().getLocale();
if ( aLocale.Language == "zh" || aLocale.Language == "ja" || aLocale.Language == "ko" )
aItem.bExpandWordSpace = false;
diff --git a/unotools/source/config/fontcfg.cxx b/unotools/source/config/fontcfg.cxx
index 314fed44faa3..ce1f465f2a6c 100644
--- a/unotools/source/config/fontcfg.cxx
+++ b/unotools/source/config/fontcfg.cxx
@@ -252,7 +252,7 @@ OUString DefaultFontConfiguration::getUserInterfaceFont( const Locale& rLocale )
{
Locale aLocale = rLocale;
if( aLocale.Language.isEmpty() )
- aLocale = SvtSysLocale().GetUILocale();
+ aLocale = SvtSysLocale().GetUILanguageTag().getLocale();
OUString aUIFont = getDefaultFont( aLocale, DEFAULTFONT_UI_SANS );
@@ -1160,7 +1160,7 @@ const FontNameAttr* FontSubstConfiguration::getSubstInfo( const String& rFontNam
aLocale.Variant = rLocale.Variant.toAsciiUpperCase();
if( aLocale.Language.isEmpty() )
- aLocale = SvtSysLocale().GetUILocale();
+ aLocale = SvtSysLocale().GetUILanguageTag().getLocale();
while( !aLocale.Language.isEmpty() )
{
diff --git a/unotools/source/config/syslocaleoptions.cxx b/unotools/source/config/syslocaleoptions.cxx
index 10c7574d5623..785cf33611d0 100644
--- a/unotools/source/config/syslocaleoptions.cxx
+++ b/unotools/source/config/syslocaleoptions.cxx
@@ -49,26 +49,6 @@ namespace
: public rtl::Static<Link, CurrencyChangeLink> {};
}
-static com::sun::star::lang::Locale lcl_str_to_locale( const ::rtl::OUString rStr )
-{
- com::sun::star::lang::Locale aRet;
- if ( !rStr.isEmpty() )
- {
- aRet = com::sun::star::lang::Locale();
- sal_Int32 nSep = rStr.indexOf('-');
- if (nSep < 0)
- aRet.Language = rStr;
- else
- {
- aRet.Language = rStr.copy(0, nSep);
- if (nSep < rStr.getLength())
- aRet.Country = rStr.copy(nSep+1, rStr.getLength() - (nSep+1));
- }
- }
-
- return aRet;
-}
-
class SvtSysLocaleOptions_Impl : public utl::ConfigItem
{
LanguageTag m_aRealLocale;
@@ -121,10 +101,8 @@ public:
void SetIgnoreLanguageChange( sal_Bool bSet);
sal_Bool IsReadOnly( SvtSysLocaleOptions::EOption eOption ) const;
- const Locale& GetRealLocale() { return m_aRealLocale.getLocale(); }
- const Locale& GetRealUILocale() { return m_aRealUILocale.getLocale(); }
- LanguageType GetRealLanguage() { return m_aRealLocale.getLanguageType(); }
- LanguageType GetRealUILanguage() { return m_aRealUILocale.getLanguageType(); }
+ const LanguageTag& GetRealLocale() { return m_aRealLocale; }
+ const LanguageTag& GetRealUILocale() { return m_aRealUILocale; }
};
@@ -755,30 +733,20 @@ void SvtSysLocaleOptions::ConfigurationChanged( utl::ConfigurationBroadcaster* p
::utl::detail::Options::ConfigurationChanged( p, nHint );
}
-com::sun::star::lang::Locale SvtSysLocaleOptions::GetLocale() const
+LanguageTag SvtSysLocaleOptions::GetLanguageTag() const
{
- return lcl_str_to_locale( GetLocaleConfigString() );
+ return LanguageTag( GetLocaleConfigString() );
}
-com::sun::star::lang::Locale SvtSysLocaleOptions::GetRealLocale() const
+const LanguageTag & SvtSysLocaleOptions::GetRealLanguageTag() const
{
return pOptions->GetRealLocale();
}
-com::sun::star::lang::Locale SvtSysLocaleOptions::GetRealUILocale() const
+const LanguageTag & SvtSysLocaleOptions::GetRealUILanguageTag() const
{
return pOptions->GetRealUILocale();
}
-LanguageType SvtSysLocaleOptions::GetRealLanguage() const
-{
- return pOptions->GetRealLanguage();
-}
-
-LanguageType SvtSysLocaleOptions::GetRealUILanguage() const
-{
- return pOptions->GetRealUILanguage();
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/unotools/source/misc/syslocale.cxx b/unotools/source/misc/syslocale.cxx
index a769e8ba4593..c8b0fe10e0af 100644
--- a/unotools/source/misc/syslocale.cxx
+++ b/unotools/source/misc/syslocale.cxx
@@ -20,9 +20,7 @@
#include <unotools/syslocale.hxx>
#include <unotools/syslocaleoptions.hxx>
-#include <unotools/localedatawrapper.hxx>
#include <comphelper/processfactory.hxx>
-#include <i18npool/mslangid.hxx>
#include <rtl/tencinfo.h>
#include <rtl/locale.h>
#include <osl/nlsupport.h>
@@ -57,7 +55,7 @@ private:
SvtSysLocale_Impl::SvtSysLocale_Impl() : pCharClass(NULL)
{
- pLocaleData = new LocaleDataWrapper( aSysLocaleOptions.GetRealLocale() );
+ pLocaleData = new LocaleDataWrapper( aSysLocaleOptions.GetRealLanguageTag().getLocale() );
setDateAcceptancePatternsConfig();
// listen for further changes
@@ -75,7 +73,7 @@ SvtSysLocale_Impl::~SvtSysLocale_Impl()
CharClass* SvtSysLocale_Impl::GetCharClass()
{
if ( !pCharClass )
- pCharClass = new CharClass( aSysLocaleOptions.GetRealLocale() );
+ pCharClass = new CharClass( aSysLocaleOptions.GetRealLanguageTag().getLocale() );
return pCharClass;
}
@@ -85,7 +83,7 @@ void SvtSysLocale_Impl::ConfigurationChanged( utl::ConfigurationBroadcaster*, sa
if ( nHint & SYSLOCALEOPTIONS_HINT_LOCALE )
{
- com::sun::star::lang::Locale aLocale( aSysLocaleOptions.GetRealLocale() );
+ com::sun::star::lang::Locale aLocale( aSysLocaleOptions.GetRealLanguageTag().getLocale() );
pLocaleData->setLocale( aLocale );
GetCharClass()->setLocale( aLocale );
}
@@ -185,24 +183,14 @@ SvtSysLocaleOptions& SvtSysLocale::GetOptions() const
return pImpl->aSysLocaleOptions;
}
-com::sun::star::lang::Locale SvtSysLocale::GetLocale() const
+const LanguageTag& SvtSysLocale::GetLanguageTag() const
{
- return pImpl->aSysLocaleOptions.GetRealLocale();
+ return pImpl->aSysLocaleOptions.GetRealLanguageTag();
}
-LanguageType SvtSysLocale::GetLanguage() const
+const LanguageTag& SvtSysLocale::GetUILanguageTag() const
{
- return pImpl->aSysLocaleOptions.GetRealLanguage();
-}
-
-com::sun::star::lang::Locale SvtSysLocale::GetUILocale() const
-{
- return pImpl->aSysLocaleOptions.GetRealUILocale();
-}
-
-LanguageType SvtSysLocale::GetUILanguage() const
-{
- return pImpl->aSysLocaleOptions.GetRealUILanguage();
+ return pImpl->aSysLocaleOptions.GetRealUILanguageTag();
}
//------------------------------------------------------------------------
@@ -216,7 +204,7 @@ rtl_TextEncoding SvtSysLocale::GetBestMimeEncoding()
{
// If the system locale is unknown to us, e.g. LC_ALL=xx, match the UI
// language if possible.
- ::com::sun::star::lang::Locale aLocale( SvtSysLocale().GetUILocale() );
+ ::com::sun::star::lang::Locale aLocale( SvtSysLocale().GetUILanguageTag().getLocale() );
rtl_Locale * pLocale = rtl_locale_register( aLocale.Language.getStr(),
aLocale.Country.getStr(), aLocale.Variant.getStr() );
rtl_TextEncoding nEnc = osl_getTextEncodingFromLocale( pLocale );