Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / unotools / source / config / syslocaleoptions.cxx
blob785cf33611d03d0c17f73b85ede4c6910e495a26
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/uno/Sequence.hxx>
21 #include <rtl/ustrbuf.hxx>
22 #include <rtl/instance.hxx>
23 #include <rtl/logfile.hxx>
24 #include <i18npool/mslangid.hxx>
25 #include <i18npool/languagetag.hxx>
26 #include <tools/string.hxx>
27 #include <tools/debug.hxx>
28 #include <unotools/syslocaleoptions.hxx>
29 #include <unotools/configmgr.hxx>
30 #include <unotools/configitem.hxx>
31 #include <com/sun/star/uno/Any.hxx>
33 #include "itemholder1.hxx"
35 #define CFG_READONLY_DEFAULT sal_False
37 using namespace osl;
38 using namespace utl;
39 using namespace com::sun::star::uno;
40 using namespace com::sun::star::lang;
42 using ::rtl::OUString;
44 SvtSysLocaleOptions_Impl* SvtSysLocaleOptions::pOptions = NULL;
45 sal_Int32 SvtSysLocaleOptions::nRefCount = 0;
46 namespace
48 struct CurrencyChangeLink
49 : public rtl::Static<Link, CurrencyChangeLink> {};
52 class SvtSysLocaleOptions_Impl : public utl::ConfigItem
54 LanguageTag m_aRealLocale;
55 LanguageTag m_aRealUILocale;
56 OUString m_aLocaleString; // en-US or de-DE or empty for SYSTEM
57 OUString m_aUILocaleString; // en-US or de-DE or empty for SYSTEM
58 OUString m_aCurrencyString; // USD-en-US or EUR-de-DE
59 OUString m_aDatePatternsString; // "Y-M-D;M-D"
60 sal_Bool m_bDecimalSeparator; //use decimal separator same as locale
61 sal_Bool m_bIgnoreLanguageChange; //OS language change doesn't affect LO document language
63 sal_Bool m_bROLocale;
64 sal_Bool m_bROUILocale;
65 sal_Bool m_bROCurrency;
66 sal_Bool m_bRODatePatterns;
67 sal_Bool m_bRODecimalSeparator;
68 sal_Bool m_bROIgnoreLanguageChange;
70 static const Sequence< /* const */ OUString > GetPropertyNames();
71 void MakeRealLocale();
72 void MakeRealUILocale();
74 public:
75 SvtSysLocaleOptions_Impl();
76 virtual ~SvtSysLocaleOptions_Impl();
78 virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
79 virtual void Commit();
81 const OUString& GetLocaleString() const
82 { return m_aLocaleString; }
83 void SetLocaleString( const OUString& rStr );
85 const OUString& GetUILocaleString() const
86 { return m_aUILocaleString; }
87 void SetUILocaleString( const OUString& rStr );
89 const OUString& GetCurrencyString() const
90 { return m_aCurrencyString; }
91 void SetCurrencyString( const OUString& rStr );
93 const OUString& GetDatePatternsString() const
94 { return m_aDatePatternsString; }
95 void SetDatePatternsString( const OUString& rStr );
97 sal_Bool IsDecimalSeparatorAsLocale() const { return m_bDecimalSeparator;}
98 void SetDecimalSeparatorAsLocale( sal_Bool bSet);
100 sal_Bool IsIgnoreLanguageChange() const { return m_bIgnoreLanguageChange;}
101 void SetIgnoreLanguageChange( sal_Bool bSet);
103 sal_Bool IsReadOnly( SvtSysLocaleOptions::EOption eOption ) const;
104 const LanguageTag& GetRealLocale() { return m_aRealLocale; }
105 const LanguageTag& GetRealUILocale() { return m_aRealUILocale; }
109 #define ROOTNODE_SYSLOCALE OUString(RTL_CONSTASCII_USTRINGPARAM("Setup/L10N"))
111 #define PROPERTYNAME_LOCALE OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupSystemLocale"))
112 #define PROPERTYNAME_UILOCALE OUString(RTL_CONSTASCII_USTRINGPARAM("ooLocale"))
113 #define PROPERTYNAME_CURRENCY OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupCurrency"))
114 #define PROPERTYNAME_DECIMALSEPARATOR OUString(RTL_CONSTASCII_USTRINGPARAM("DecimalSeparatorAsLocale"))
115 #define PROPERTYNAME_DATEPATTERNS OUString(RTL_CONSTASCII_USTRINGPARAM("DateAcceptancePatterns"))
116 #define PROPERTYNAME_IGNORELANGCHANGE OUString(RTL_CONSTASCII_USTRINGPARAM("IgnoreLanguageChange"))
118 #define PROPERTYHANDLE_LOCALE 0
119 #define PROPERTYHANDLE_UILOCALE 1
120 #define PROPERTYHANDLE_CURRENCY 2
121 #define PROPERTYHANDLE_DECIMALSEPARATOR 3
122 #define PROPERTYHANDLE_DATEPATTERNS 4
123 #define PROPERTYHANDLE_IGNORELANGCHANGE 5
125 //#define PROPERTYCOUNT 5
126 #define PROPERTYCOUNT 6
128 const Sequence< OUString > SvtSysLocaleOptions_Impl::GetPropertyNames()
130 const OUString pProperties[] =
132 PROPERTYNAME_LOCALE,
133 PROPERTYNAME_UILOCALE,
134 PROPERTYNAME_CURRENCY,
135 PROPERTYNAME_DECIMALSEPARATOR,
136 PROPERTYNAME_DATEPATTERNS,
137 PROPERTYNAME_IGNORELANGCHANGE
139 const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT );
140 return seqPropertyNames;
143 // -----------------------------------------------------------------------
145 SvtSysLocaleOptions_Impl::SvtSysLocaleOptions_Impl()
146 : ConfigItem( ROOTNODE_SYSLOCALE )
147 , m_aRealLocale( LANGUAGE_SYSTEM)
148 , m_aRealUILocale( LANGUAGE_SYSTEM)
149 , m_bDecimalSeparator( sal_True )
150 , m_bROLocale(CFG_READONLY_DEFAULT)
151 , m_bROUILocale(CFG_READONLY_DEFAULT)
152 , m_bROCurrency(CFG_READONLY_DEFAULT)
153 , m_bRODatePatterns(CFG_READONLY_DEFAULT)
154 , m_bRODecimalSeparator(sal_False)
155 , m_bROIgnoreLanguageChange(sal_False)
158 if ( IsValidConfigMgr() )
160 const Sequence< OUString > aNames = GetPropertyNames();
161 Sequence< Any > aValues = GetProperties( aNames );
162 Sequence< sal_Bool > aROStates = GetReadOnlyStates( aNames );
163 const Any* pValues = aValues.getConstArray();
164 const sal_Bool* pROStates = aROStates.getConstArray();
165 DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties failed" );
166 DBG_ASSERT( aROStates.getLength() == aNames.getLength(), "GetReadOnlyStates failed" );
167 if ( aValues.getLength() == aNames.getLength() && aROStates.getLength() == aNames.getLength() )
169 for ( sal_Int32 nProp = 0; nProp < aNames.getLength(); nProp++ )
171 if ( pValues[nProp].hasValue() )
173 switch ( nProp )
175 case PROPERTYHANDLE_LOCALE :
177 OUString aStr;
178 if ( pValues[nProp] >>= aStr )
179 m_aLocaleString = aStr;
180 else
182 SAL_WARN( "unotools.config", "Wrong property type!" );
184 m_bROLocale = pROStates[nProp];
186 break;
187 case PROPERTYHANDLE_UILOCALE :
189 OUString aStr;
190 if ( pValues[nProp] >>= aStr )
191 m_aUILocaleString = aStr;
192 else
194 SAL_WARN( "unotools.config", "Wrong property type!" );
196 m_bROUILocale = pROStates[nProp];
198 break;
199 case PROPERTYHANDLE_CURRENCY :
201 OUString aStr;
202 if ( pValues[nProp] >>= aStr )
203 m_aCurrencyString = aStr;
204 else
206 SAL_WARN( "unotools.config", "Wrong property type!" );
208 m_bROCurrency = pROStates[nProp];
210 break;
211 case PROPERTYHANDLE_DECIMALSEPARATOR:
213 sal_Bool bValue = sal_Bool();
214 if ( pValues[nProp] >>= bValue )
215 m_bDecimalSeparator = bValue;
216 else
218 SAL_WARN( "unotools.config", "Wrong property type!" );
220 m_bRODecimalSeparator = pROStates[nProp];
222 break;
223 case PROPERTYHANDLE_DATEPATTERNS :
225 OUString aStr;
226 if ( pValues[nProp] >>= aStr )
227 m_aDatePatternsString = aStr;
228 else
230 SAL_WARN( "unotools.config", "Wrong property type!" );
232 m_bRODatePatterns = pROStates[nProp];
234 break;
235 case PROPERTYHANDLE_IGNORELANGCHANGE :
237 sal_Bool bValue = sal_Bool();
238 if ( pValues[nProp] >>= bValue )
239 m_bIgnoreLanguageChange = bValue;
240 else
242 SAL_WARN( "unotools.config", "Wrong property type!" );
244 m_bROIgnoreLanguageChange = pROStates[nProp];
246 break;
247 default:
248 SAL_WARN( "unotools.config", "Wrong property type!" );
253 EnableNotification( aNames );
256 MakeRealLocale();
257 MakeRealUILocale();
261 SvtSysLocaleOptions_Impl::~SvtSysLocaleOptions_Impl()
263 if ( IsModified() )
264 Commit();
267 void SvtSysLocaleOptions_Impl::MakeRealLocale()
269 if (m_aLocaleString.isEmpty())
271 LanguageType nLang = MsLangId::getSystemLanguage();
272 m_aRealLocale.reset( nLang);
274 else
276 m_aRealLocale.reset( m_aLocaleString);
280 void SvtSysLocaleOptions_Impl::MakeRealUILocale()
282 if (m_aUILocaleString.isEmpty())
284 LanguageType nLang = MsLangId::getSystemUILanguage();
285 m_aRealUILocale.reset( nLang);
287 else
289 m_aRealUILocale.reset( m_aUILocaleString);
293 sal_Bool SvtSysLocaleOptions_Impl::IsReadOnly( SvtSysLocaleOptions::EOption eOption ) const
295 sal_Bool bReadOnly = CFG_READONLY_DEFAULT;
296 switch(eOption)
298 case SvtSysLocaleOptions::E_LOCALE :
300 bReadOnly = m_bROLocale;
301 break;
303 case SvtSysLocaleOptions::E_UILOCALE :
305 bReadOnly = m_bROUILocale;
306 break;
308 case SvtSysLocaleOptions::E_CURRENCY :
310 bReadOnly = m_bROCurrency;
311 break;
313 case SvtSysLocaleOptions::E_DATEPATTERNS :
315 bReadOnly = m_bRODatePatterns;
316 break;
319 return bReadOnly;
323 void SvtSysLocaleOptions_Impl::Commit()
325 const Sequence< OUString > aOrgNames = GetPropertyNames();
326 sal_Int32 nOrgCount = aOrgNames.getLength();
328 Sequence< OUString > aNames( nOrgCount );
329 Sequence< Any > aValues( nOrgCount );
331 OUString* pNames = aNames.getArray();
332 Any* pValues = aValues.getArray();
333 sal_Int32 nRealCount = 0;
335 for ( sal_Int32 nProp = 0; nProp < nOrgCount; nProp++ )
337 switch ( nProp )
339 case PROPERTYHANDLE_LOCALE :
341 if (!m_bROLocale)
343 pNames[nRealCount] = aOrgNames[nProp];
344 pValues[nRealCount] <<= m_aLocaleString;
345 ++nRealCount;
348 break;
349 case PROPERTYHANDLE_UILOCALE :
351 if (!m_bROUILocale)
353 pNames[nRealCount] = aOrgNames[nProp];
354 pValues[nRealCount] <<= m_aUILocaleString;
355 ++nRealCount;
358 break;
359 case PROPERTYHANDLE_CURRENCY :
361 if (!m_bROCurrency)
363 pNames[nRealCount] = aOrgNames[nProp];
364 pValues[nRealCount] <<= m_aCurrencyString;
365 ++nRealCount;
368 break;
369 case PROPERTYHANDLE_DECIMALSEPARATOR:
370 if( !m_bRODecimalSeparator )
372 pNames[nRealCount] = aOrgNames[nProp];
373 pValues[nRealCount] <<= m_bDecimalSeparator;
374 ++nRealCount;
376 break;
377 case PROPERTYHANDLE_DATEPATTERNS :
378 if (!m_bRODatePatterns)
380 pNames[nRealCount] = aOrgNames[nProp];
381 pValues[nRealCount] <<= m_aDatePatternsString;
382 ++nRealCount;
384 break;
385 case PROPERTYHANDLE_IGNORELANGCHANGE :
386 if (!m_bROIgnoreLanguageChange)
388 pNames[nRealCount] = aOrgNames[nProp];
389 pValues[nRealCount] <<= m_bIgnoreLanguageChange;
390 ++nRealCount;
392 break;
393 default:
394 SAL_WARN( "unotools.config", "invalid index to save a path" );
397 aNames.realloc(nRealCount);
398 aValues.realloc(nRealCount);
399 PutProperties( aNames, aValues );
400 ClearModified();
404 void SvtSysLocaleOptions_Impl::SetLocaleString( const OUString& rStr )
406 if (!m_bROLocale && rStr != m_aLocaleString )
408 m_aLocaleString = rStr;
409 MakeRealLocale();
410 MsLangId::setConfiguredSystemLanguage( m_aRealLocale.getLanguageType() );
411 SetModified();
412 sal_uLong nHint = SYSLOCALEOPTIONS_HINT_LOCALE;
413 if ( m_aCurrencyString.isEmpty() )
414 nHint |= SYSLOCALEOPTIONS_HINT_CURRENCY;
415 NotifyListeners( nHint );
419 void SvtSysLocaleOptions_Impl::SetUILocaleString( const OUString& rStr )
421 if (!m_bROUILocale && rStr != m_aUILocaleString )
423 m_aUILocaleString = rStr;
425 // as we can't switch UILocale at runtime, we only store changes in the configuration
426 MakeRealUILocale();
427 MsLangId::setConfiguredSystemLanguage( m_aRealUILocale.getLanguageType() );
428 SetModified();
429 NotifyListeners( SYSLOCALEOPTIONS_HINT_UILOCALE );
433 void SvtSysLocaleOptions_Impl::SetCurrencyString( const OUString& rStr )
435 if (!m_bROCurrency && rStr != m_aCurrencyString )
437 m_aCurrencyString = rStr;
438 SetModified();
439 NotifyListeners( SYSLOCALEOPTIONS_HINT_CURRENCY );
443 void SvtSysLocaleOptions_Impl::SetDatePatternsString( const OUString& rStr )
445 if (!m_bRODatePatterns && rStr != m_aDatePatternsString )
447 m_aDatePatternsString = rStr;
448 SetModified();
449 NotifyListeners( SYSLOCALEOPTIONS_HINT_DATEPATTERNS );
453 void SvtSysLocaleOptions_Impl::SetDecimalSeparatorAsLocale( sal_Bool bSet)
455 if(bSet != m_bDecimalSeparator)
457 m_bDecimalSeparator = bSet;
458 SetModified();
459 NotifyListeners( SYSLOCALEOPTIONS_HINT_DECSEP );
463 void SvtSysLocaleOptions_Impl::SetIgnoreLanguageChange( sal_Bool bSet)
465 if(bSet != m_bIgnoreLanguageChange)
467 m_bIgnoreLanguageChange = bSet;
468 SetModified();
469 NotifyListeners( SYSLOCALEOPTIONS_HINT_IGNORELANG );
473 void SvtSysLocaleOptions_Impl::Notify( const Sequence< rtl::OUString >& seqPropertyNames )
475 sal_uLong nHint = 0;
476 Sequence< Any > seqValues = GetProperties( seqPropertyNames );
477 Sequence< sal_Bool > seqROStates = GetReadOnlyStates( seqPropertyNames );
478 sal_Int32 nCount = seqPropertyNames.getLength();
479 for( sal_Int32 nProp = 0; nProp < nCount; ++nProp )
481 if( seqPropertyNames[nProp] == PROPERTYNAME_LOCALE )
483 DBG_ASSERT( seqValues[nProp].getValueTypeClass() == TypeClass_STRING, "Locale property type" );
484 seqValues[nProp] >>= m_aLocaleString;
485 m_bROLocale = seqROStates[nProp];
486 nHint |= SYSLOCALEOPTIONS_HINT_LOCALE;
487 if ( m_aCurrencyString.isEmpty() )
488 nHint |= SYSLOCALEOPTIONS_HINT_CURRENCY;
489 MakeRealLocale();
491 if( seqPropertyNames[nProp] == PROPERTYNAME_UILOCALE )
493 DBG_ASSERT( seqValues[nProp].getValueTypeClass() == TypeClass_STRING, "Locale property type" );
494 seqValues[nProp] >>= m_aUILocaleString;
495 m_bROUILocale = seqROStates[nProp];
496 nHint |= SYSLOCALEOPTIONS_HINT_UILOCALE;
497 MakeRealUILocale();
499 else if( seqPropertyNames[nProp] == PROPERTYNAME_CURRENCY )
501 DBG_ASSERT( seqValues[nProp].getValueTypeClass() == TypeClass_STRING, "Currency property type" );
502 seqValues[nProp] >>= m_aCurrencyString;
503 m_bROCurrency = seqROStates[nProp];
504 nHint |= SYSLOCALEOPTIONS_HINT_CURRENCY;
506 else if( seqPropertyNames[nProp] == PROPERTYNAME_DECIMALSEPARATOR )
508 seqValues[nProp] >>= m_bDecimalSeparator;
509 m_bRODecimalSeparator = seqROStates[nProp];
511 else if( seqPropertyNames[nProp] == PROPERTYNAME_IGNORELANGCHANGE )
513 seqValues[nProp] >>= m_bIgnoreLanguageChange;
514 m_bROIgnoreLanguageChange = seqROStates[nProp];
516 else if( seqPropertyNames[nProp] == PROPERTYNAME_DATEPATTERNS )
518 DBG_ASSERT( seqValues[nProp].getValueTypeClass() == TypeClass_STRING, "DatePatterns property type" );
519 seqValues[nProp] >>= m_aDatePatternsString;
520 m_bRODatePatterns = seqROStates[nProp];
521 nHint |= SYSLOCALEOPTIONS_HINT_DATEPATTERNS;
524 if ( nHint )
525 NotifyListeners( nHint );
528 // ====================================================================
530 SvtSysLocaleOptions::SvtSysLocaleOptions()
532 MutexGuard aGuard( GetMutex() );
533 if ( !pOptions )
535 RTL_LOGFILE_CONTEXT(aLog, "svl ( ??? ) ::SvtSysLocaleOptions_Impl::ctor()");
536 pOptions = new SvtSysLocaleOptions_Impl;
538 ItemHolder1::holdConfigItem(E_SYSLOCALEOPTIONS);
540 ++nRefCount;
541 pOptions->AddListener(this);
545 SvtSysLocaleOptions::~SvtSysLocaleOptions()
547 MutexGuard aGuard( GetMutex() );
548 pOptions->RemoveListener(this);
549 if ( !--nRefCount )
551 delete pOptions;
552 pOptions = NULL;
557 // static
558 Mutex& SvtSysLocaleOptions::GetMutex()
560 static Mutex* pMutex = NULL;
561 if( !pMutex )
563 MutexGuard aGuard( Mutex::getGlobalMutex() );
564 if( !pMutex )
566 // #i77768# Due to a static reference in the toolkit lib
567 // we need a mutex that lives longer than the svl library.
568 // Otherwise the dtor would use a destructed mutex!!
569 pMutex = new Mutex;
572 return *pMutex;
576 sal_Bool SvtSysLocaleOptions::IsModified()
578 MutexGuard aGuard( GetMutex() );
579 return pOptions->IsModified();
583 void SvtSysLocaleOptions::Commit()
585 MutexGuard aGuard( GetMutex() );
586 pOptions->Commit();
590 void SvtSysLocaleOptions::BlockBroadcasts( bool bBlock )
592 MutexGuard aGuard( GetMutex() );
593 pOptions->BlockBroadcasts( bBlock );
597 const OUString& SvtSysLocaleOptions::GetLocaleConfigString() const
599 MutexGuard aGuard( GetMutex() );
600 return pOptions->GetLocaleString();
603 void SvtSysLocaleOptions::SetLocaleConfigString( const OUString& rStr )
605 MutexGuard aGuard( GetMutex() );
606 pOptions->SetLocaleString( rStr );
609 void SvtSysLocaleOptions::SetUILocaleConfigString( const OUString& rStr )
611 MutexGuard aGuard( GetMutex() );
612 pOptions->SetUILocaleString( rStr );
615 const OUString& SvtSysLocaleOptions::GetCurrencyConfigString() const
617 MutexGuard aGuard( GetMutex() );
618 return pOptions->GetCurrencyString();
622 void SvtSysLocaleOptions::SetCurrencyConfigString( const OUString& rStr )
624 MutexGuard aGuard( GetMutex() );
625 pOptions->SetCurrencyString( rStr );
628 const OUString& SvtSysLocaleOptions::GetDatePatternsConfigString() const
630 MutexGuard aGuard( GetMutex() );
631 return pOptions->GetDatePatternsString();
634 void SvtSysLocaleOptions::SetDatePatternsConfigString( const OUString& rStr )
636 MutexGuard aGuard( GetMutex() );
637 pOptions->SetDatePatternsString( rStr );
640 sal_Bool SvtSysLocaleOptions::IsDecimalSeparatorAsLocale() const
642 MutexGuard aGuard( GetMutex() );
643 return pOptions->IsDecimalSeparatorAsLocale();
646 void SvtSysLocaleOptions::SetDecimalSeparatorAsLocale( sal_Bool bSet)
648 MutexGuard aGuard( GetMutex() );
649 pOptions->SetDecimalSeparatorAsLocale(bSet);
652 sal_Bool SvtSysLocaleOptions::IsIgnoreLanguageChange() const
654 MutexGuard aGuard( GetMutex() );
655 return pOptions->IsIgnoreLanguageChange();
658 void SvtSysLocaleOptions::SetIgnoreLanguageChange( sal_Bool bSet)
660 MutexGuard aGuard( GetMutex() );
661 pOptions->SetIgnoreLanguageChange(bSet);
664 sal_Bool SvtSysLocaleOptions::IsReadOnly( EOption eOption ) const
666 MutexGuard aGuard( GetMutex() );
667 return pOptions->IsReadOnly( eOption );
670 // static
671 void SvtSysLocaleOptions::GetCurrencyAbbrevAndLanguage( String& rAbbrev,
672 LanguageType& eLang, const ::rtl::OUString& rConfigString )
674 sal_Int32 nDelim = rConfigString.indexOf( '-' );
675 if ( nDelim >= 0 )
677 rAbbrev = rConfigString.copy( 0, nDelim );
678 String aIsoStr( rConfigString.copy( nDelim+1 ) );
679 eLang = LanguageTag( aIsoStr ).getLanguageType();
681 else
683 rAbbrev = rConfigString;
684 eLang = (rAbbrev.Len() ? LANGUAGE_NONE : LANGUAGE_SYSTEM);
689 // static
690 ::rtl::OUString SvtSysLocaleOptions::CreateCurrencyConfigString(
691 const String& rAbbrev, LanguageType eLang )
693 String aIsoStr( LanguageTag( eLang ).getBcp47() );
694 if ( aIsoStr.Len() )
696 ::rtl::OUStringBuffer aStr( rAbbrev.Len() + 1 + aIsoStr.Len() );
697 aStr.append( rAbbrev );
698 aStr.append( sal_Unicode('-') );
699 aStr.append( aIsoStr );
700 return aStr.makeStringAndClear();
702 else
703 return rAbbrev;
707 // static
708 void SvtSysLocaleOptions::SetCurrencyChangeLink( const Link& rLink )
710 MutexGuard aGuard( GetMutex() );
711 DBG_ASSERT( !CurrencyChangeLink::get().IsSet(), "SvtSysLocaleOptions::SetCurrencyChangeLink: already set" );
712 CurrencyChangeLink::get() = rLink;
716 // static
717 const Link& SvtSysLocaleOptions::GetCurrencyChangeLink()
719 MutexGuard aGuard( GetMutex() );
720 return CurrencyChangeLink::get();
724 void SvtSysLocaleOptions::ConfigurationChanged( utl::ConfigurationBroadcaster* p, sal_uInt32 nHint )
726 if ( nHint & SYSLOCALEOPTIONS_HINT_CURRENCY )
728 const Link& rLink = GetCurrencyChangeLink();
729 if ( rLink.IsSet() )
730 rLink.Call( NULL );
733 ::utl::detail::Options::ConfigurationChanged( p, nHint );
736 LanguageTag SvtSysLocaleOptions::GetLanguageTag() const
738 return LanguageTag( GetLocaleConfigString() );
741 const LanguageTag & SvtSysLocaleOptions::GetRealLanguageTag() const
743 return pOptions->GetRealLocale();
746 const LanguageTag & SvtSysLocaleOptions::GetRealUILanguageTag() const
748 return pOptions->GetRealUILocale();
752 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */