20#include <com/sun/star/uno/Sequence.hxx>
29#include <com/sun/star/uno/Any.hxx>
33#define CFG_READONLY_DEFAULT false
42 std::weak_ptr<SvtSysLocaleOptions_Impl> g_pSysLocaleOptions;
50 static Mutex* persistentMutex(
new Mutex);
52 return *persistentMutex;
85 virtual void Notify(
const css::uno::Sequence< OUString >& aPropertyNames )
override;
121#define PROPERTYHANDLE_LOCALE 0
122#define PROPERTYHANDLE_UILOCALE 1
123#define PROPERTYHANDLE_CURRENCY 2
124#define PROPERTYHANDLE_DECIMALSEPARATOR 3
125#define PROPERTYHANDLE_DATEPATTERNS 4
126#define PROPERTYHANDLE_IGNORELANGCHANGE 5
145 , m_bDecimalSeparator( true )
146 , m_bIgnoreLanguageChange( false)
151 , m_bRODecimalSeparator(false)
152 , m_bROIgnoreLanguageChange(false)
159 const sal_Bool* pROStates = aROStates.getConstArray();
160 DBG_ASSERT( aValues.getLength() == aNames.getLength(),
"GetProperties failed" );
161 DBG_ASSERT( aROStates.getLength() == aNames.getLength(),
"GetReadOnlyStates failed" );
162 if ( aValues.getLength() == aNames.getLength() && aROStates.getLength() == aNames.getLength() )
164 for ( sal_Int32 nProp = 0; nProp < aNames.getLength(); nProp++ )
166 if (
pValues[nProp].hasValue() )
177 SAL_WARN(
"unotools.config",
"Wrong property type!" );
189 SAL_WARN(
"unotools.config",
"Wrong property type!" );
201 SAL_WARN(
"unotools.config",
"Wrong property type!" );
209 if (
pValues[nProp] >>= bValue )
213 SAL_WARN(
"unotools.config",
"Wrong property type!" );
225 SAL_WARN(
"unotools.config",
"Wrong property type!" );
233 if (
pValues[nProp] >>= bValue )
237 SAL_WARN(
"unotools.config",
"Wrong property type!" );
243 SAL_WARN(
"unotools.config",
"Wrong property type!" );
312 sal_Int32 nOrgCount = aOrgNames.getLength();
317 OUString* pNames = aNames.getArray();
319 sal_Int32 nRealCount = 0;
321 for ( sal_Int32 nProp = 0; nProp < nOrgCount; nProp++ )
329 pNames[nRealCount] = aOrgNames[nProp];
339 pNames[nRealCount] = aOrgNames[nProp];
349 pNames[nRealCount] = aOrgNames[nProp];
358 pNames[nRealCount] = aOrgNames[nProp];
366 pNames[nRealCount] = aOrgNames[nProp];
374 pNames[nRealCount] = aOrgNames[nProp];
380 SAL_WARN(
"unotools.config",
"invalid index to save a path" );
383 aNames.realloc(nRealCount);
384 aValues.realloc(nRealCount);
392 MutexGuard aGuard( GetMutex() );
410 MutexGuard aGuard( GetMutex() );
427 MutexGuard aGuard( GetMutex() );
441 MutexGuard aGuard( GetMutex() );
455 MutexGuard aGuard( GetMutex() );
469 MutexGuard aGuard( GetMutex() );
485 sal_Int32
nCount = seqPropertyNames.getLength();
486 for( sal_Int32 nProp = 0; nProp <
nCount; ++nProp )
490 DBG_ASSERT( seqValues[nProp].getValueTypeClass() == TypeClass_STRING,
"Locale property type" );
500 DBG_ASSERT( seqValues[nProp].getValueTypeClass() == TypeClass_STRING,
"Locale property type" );
508 DBG_ASSERT( seqValues[nProp].getValueTypeClass() == TypeClass_STRING,
"Currency property type" );
525 DBG_ASSERT( seqValues[nProp].getValueTypeClass() == TypeClass_STRING,
"DatePatterns property type" );
537 MutexGuard aGuard( GetMutex() );
538 pImpl = g_pSysLocaleOptions.lock();
541 pImpl = std::make_shared<SvtSysLocaleOptions_Impl>();
542 g_pSysLocaleOptions =
pImpl;
546 pImpl->AddListener(
this);
551 MutexGuard aGuard( GetMutex() );
552 pImpl->RemoveListener(
this);
558 MutexGuard aGuard( GetMutex() );
559 return pImpl->IsModified();
564 MutexGuard aGuard( GetMutex() );
570 MutexGuard aGuard( GetMutex() );
571 pImpl->BlockBroadcasts( bBlock );
576 pImpl->SetLocaleString( rStr );
581 pImpl->SetUILocaleString( rStr );
586 MutexGuard aGuard( GetMutex() );
587 return pImpl->GetCurrencyString();
592 pImpl->SetCurrencyString( rStr );
597 MutexGuard aGuard( GetMutex() );
598 return pImpl->GetDatePatternsString();
603 pImpl->SetDatePatternsString( rStr );
608 MutexGuard aGuard( GetMutex() );
609 return pImpl->IsDecimalSeparatorAsLocale();
614 pImpl->SetDecimalSeparatorAsLocale(bSet);
619 MutexGuard aGuard( GetMutex() );
620 return pImpl->IsIgnoreLanguageChange();
625 pImpl->SetIgnoreLanguageChange(bSet);
630 MutexGuard aGuard( GetMutex() );
631 return pImpl->IsReadOnly( eOption );
637 const OUString& rConfigString )
639 sal_Int32 nDelim = rConfigString.indexOf(
'-' );
642 rAbbrev = rConfigString.copy( 0, nDelim );
643 OUString aIsoStr( rConfigString.copy( nDelim+1 ) );
648 rAbbrev = rConfigString;
658 if ( !aIsoStr.isEmpty() )
660 return rAbbrev +
"-" + aIsoStr;
669 MutexGuard aGuard( GetMutex() );
670 DBG_ASSERT( !g_CurrencyChangeLink.IsSet(),
"SvtSysLocaleOptions::SetCurrencyChangeLink: already set" );
671 g_CurrencyChangeLink = rLink;
677 MutexGuard aGuard( GetMutex() );
678 return g_CurrencyChangeLink;
686 rLink.
Call(
nullptr );
694 MutexGuard aGuard( GetMutex() );
700 return pImpl->GetRealLocale();
705 return pImpl->GetRealUILocale();
const PropertyValue * pValues
static void holdConfigItem(EItem eItem)
LanguageType getLanguageType(bool bResolveSystem=true) const
static void setConfiguredSystemLanguage(LanguageType nLang)
LanguageTag & makeFallback()
static OUString convertToBcp47(LanguageType nLangID)
static LanguageType convertToLanguageTypeWithFallback(const OUString &rBcp47)
LanguageTag & reset(const OUString &rBcp47LanguageTag)
static LanguageType getConfiguredSystemUILanguage()
static LanguageType getConfiguredSystemLanguage()
virtual ~SvtSysLocaleOptions_Impl() override
LanguageTag m_aRealUILocale
bool m_bIgnoreLanguageChange
void SetUILocaleString(const OUString &rStr)
OUString m_aDatePatternsString
OUString m_aUILocaleString
bool m_bRODecimalSeparator
void SetCurrencyString(const OUString &rStr)
bool m_bROIgnoreLanguageChange
bool IsIgnoreLanguageChange() const
void SetLocaleString(const OUString &rStr)
const OUString & GetLocaleString() const
SvtSysLocaleOptions_Impl()
OUString m_aCurrencyString
static Sequence< OUString > GetPropertyNames()
virtual void Notify(const css::uno::Sequence< OUString > &aPropertyNames) override
is called from the ConfigManager before application ends of from the PropertyChangeListener if the su...
void SetDatePatternsString(const OUString &rStr)
void SetIgnoreLanguageChange(bool bSet)
virtual void ImplCommit() override
writes the changed values into the sub tree.
const LanguageTag & GetRealUILocale() const
void SetDecimalSeparatorAsLocale(bool bSet)
const OUString & GetDatePatternsString() const
const LanguageTag & GetRealLocale() const
bool IsDecimalSeparatorAsLocale() const
bool IsReadOnly(SvtSysLocaleOptions::EOption eOption) const
const OUString & GetCurrencyString() const
LanguageTag m_aRealLocale
bool IsDecimalSeparatorAsLocale() const
const OUString & GetDatePatternsConfigString() const
The config string may be empty to denote the default DateAcceptancePatterns of the locale.
void SetDatePatternsConfigString(const OUString &rStr)
static void SetCurrencyChangeLink(const Link< LinkParamNone *, void > &rLink)
Set a link to a method to be called whenever the default currency changes.
std::shared_ptr< SvtSysLocaleOptions_Impl > pImpl
const LanguageTag & GetRealUILanguageTag() const
Get UI locale set, always resolved to the real locale.
virtual void BlockBroadcasts(bool bBlock) override
Add a listener to react on config changes which are broadcasted in a SfxSimpleHint.
static OUString CreateCurrencyConfigString(const OUString &rAbbrev, LanguageType eLang)
Create an USD-en-US or EUR-de-DE string.
void SetLocaleConfigString(const OUString &rStr)
The config string may be empty to denote the SYSTEM locale.
static void GetCurrencyAbbrevAndLanguage(OUString &rAbbrev, LanguageType &eLang, const OUString &rConfigString)
Get currency abbreviation and locale from an USD-en-US or EUR-de-DE string.
virtual void ConfigurationChanged(utl::ConfigurationBroadcaster *p, ConfigurationHints nHint) override
bool IsIgnoreLanguageChange() const
static const Link< LinkParamNone *, void > & GetCurrencyChangeLink()
void SetUILocaleConfigString(const OUString &rStr)
The config string may be empty to denote the SYSTEM locale.
void SetCurrencyConfigString(const OUString &rStr)
bool IsReadOnly(EOption eOption) const
return the readonly state of the queried option.
const OUString & GetCurrencyConfigString() const
The config string may be empty to denote the default currency of the locale.
void SetDecimalSeparatorAsLocale(bool bSet)
LanguageTag GetLanguageTag() const
Get locale set, not resolved to the real locale.
void SetIgnoreLanguageChange(bool bSet)
const LanguageTag & GetRealLanguageTag() const
Get locale set, always resolved to the real locale.
virtual ~SvtSysLocaleOptions() override
css::uno::Sequence< css::uno::Any > GetProperties(const css::uno::Sequence< OUString > &rNames)
bool EnableNotification(const css::uno::Sequence< OUString > &rNames, bool bEnableInternalNotification=false)
enables notifications about changes on selected sub nodes/values
bool PutProperties(const css::uno::Sequence< OUString > &rNames, const css::uno::Sequence< css::uno::Any > &rValues)
css::uno::Sequence< sal_Bool > GetReadOnlyStates(const css::uno::Sequence< OUString > &rNames)
void NotifyListeners(ConfigurationHints nHint)
virtual void ConfigurationChanged(::utl::ConfigurationBroadcaster *p, ConfigurationHints nHint) override
#define DBG_ASSERT(sCon, aError)
#define SAL_WARN(area, stream)
constexpr OUStringLiteral PROPERTYNAME_DECIMALSEPARATOR
constexpr OUStringLiteral PROPERTYNAME_DATEPATTERNS
constexpr OUStringLiteral ROOTNODE_SYSLOCALE
constexpr OUStringLiteral PROPERTYNAME_IGNORELANGCHANGE
#define PROPERTYHANDLE_CURRENCY
#define PROPERTYHANDLE_LOCALE
#define PROPERTYHANDLE_DATEPATTERNS
constexpr OUStringLiteral PROPERTYNAME_UILOCALE
#define PROPERTYHANDLE_UILOCALE
#define PROPERTYHANDLE_IGNORELANGCHANGE
#define PROPERTYHANDLE_DECIMALSEPARATOR
constexpr OUStringLiteral PROPERTYNAME_CURRENCY
constexpr OUStringLiteral PROPERTYNAME_LOCALE
#define CFG_READONLY_DEFAULT