1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_unotools.hxx" 30 31 #include <com/sun/star/uno/Sequence.hxx> 32 #include <rtl/ustrbuf.hxx> 33 #include <rtl/instance.hxx> 34 #include <rtl/logfile.hxx> 35 #include <i18npool/mslangid.hxx> 36 #include <tools/string.hxx> 37 #include <tools/debug.hxx> 38 #include <unotools/syslocaleoptions.hxx> 39 #include <unotools/configmgr.hxx> 40 #include <unotools/configitem.hxx> 41 #include <com/sun/star/uno/Any.hxx> 42 43 #include "itemholder1.hxx" 44 45 #define CFG_READONLY_DEFAULT sal_False 46 47 using namespace osl; 48 using namespace utl; 49 using namespace rtl; 50 using namespace com::sun::star::uno; 51 using namespace com::sun::star::lang; 52 53 54 SvtSysLocaleOptions_Impl* SvtSysLocaleOptions::pOptions = NULL; 55 sal_Int32 SvtSysLocaleOptions::nRefCount = 0; 56 namespace 57 { 58 struct CurrencyChangeLink 59 : public rtl::Static<Link, CurrencyChangeLink> {}; 60 } 61 62 com::sun::star::lang::Locale lcl_str_to_locale( const ::rtl::OUString rStr ) 63 { 64 com::sun::star::lang::Locale aRet; 65 if ( rStr.getLength() ) 66 { 67 aRet = com::sun::star::lang::Locale(); 68 sal_Int32 nSep = rStr.indexOf('-'); 69 if (nSep < 0) 70 aRet.Language = rStr; 71 else 72 { 73 aRet.Language = rStr.copy(0, nSep); 74 if (nSep < rStr.getLength()) 75 aRet.Country = rStr.copy(nSep+1, rStr.getLength() - (nSep+1)); 76 } 77 } 78 79 return aRet; 80 } 81 82 class SvtSysLocaleOptions_Impl : public utl::ConfigItem 83 { 84 Locale m_aRealLocale; 85 Locale m_aRealUILocale; 86 LanguageType m_eRealLanguage; 87 LanguageType m_eRealUILanguage; 88 OUString m_aLocaleString; // en-US or de-DE or empty for SYSTEM 89 OUString m_aUILocaleString; // en-US or de-DE or empty for SYSTEM 90 OUString m_aCurrencyString; // USD-en-US or EUR-de-DE 91 sal_uLong m_nBlockedHint; // pending hints 92 sal_Bool m_bDecimalSeparator; //use decimal separator same as locale 93 94 sal_Bool m_bROLocale; 95 sal_Bool m_bROUILocale; 96 sal_Bool m_bROCurrency; 97 sal_Bool m_bRODecimalSeparator; 98 99 static const Sequence< /* const */ OUString > GetPropertyNames(); 100 void MakeRealLocale(); 101 void MakeRealUILocale(); 102 103 public: 104 SvtSysLocaleOptions_Impl(); 105 virtual ~SvtSysLocaleOptions_Impl(); 106 107 virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames ); 108 virtual void Commit(); 109 110 const OUString& GetLocaleString() const 111 { return m_aLocaleString; } 112 void SetLocaleString( const OUString& rStr ); 113 114 const OUString& GetUILocaleString() const 115 { return m_aUILocaleString; } 116 void SetUILocaleString( const OUString& rStr ); 117 118 const OUString& GetCurrencyString() const 119 { return m_aCurrencyString; } 120 void SetCurrencyString( const OUString& rStr ); 121 122 sal_Bool IsDecimalSeparatorAsLocale() const { return m_bDecimalSeparator;} 123 void SetDecimalSeparatorAsLocale( sal_Bool bSet); 124 125 sal_Bool IsReadOnly( SvtSysLocaleOptions::EOption eOption ) const; 126 const Locale& GetRealLocale() { return m_aRealLocale; } 127 const Locale& GetRealUILocale() { return m_aRealUILocale; } 128 LanguageType GetRealLanguage() { return m_eRealLanguage; } 129 LanguageType GetRealUILanguage() { return m_eRealUILanguage; } 130 }; 131 132 133 #define ROOTNODE_SYSLOCALE OUString(RTL_CONSTASCII_USTRINGPARAM("Setup/L10N")) 134 135 #define PROPERTYNAME_LOCALE OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupSystemLocale")) 136 #define PROPERTYNAME_UILOCALE OUString(RTL_CONSTASCII_USTRINGPARAM("ooLocale")) 137 #define PROPERTYNAME_CURRENCY OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupCurrency")) 138 #define PROPERTYNAME_DECIMALSEPARATOR OUString(RTL_CONSTASCII_USTRINGPARAM("DecimalSeparatorAsLocale")) 139 140 #define PROPERTYHANDLE_LOCALE 0 141 #define PROPERTYHANDLE_UILOCALE 1 142 #define PROPERTYHANDLE_CURRENCY 2 143 #define PROPERTYHANDLE_DECIMALSEPARATOR 3 144 145 #define PROPERTYCOUNT 4 146 147 const Sequence< OUString > SvtSysLocaleOptions_Impl::GetPropertyNames() 148 { 149 static const OUString pProperties[] = 150 { 151 PROPERTYNAME_LOCALE, 152 PROPERTYNAME_UILOCALE, 153 PROPERTYNAME_CURRENCY, 154 PROPERTYNAME_DECIMALSEPARATOR 155 }; 156 static const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT ); 157 return seqPropertyNames; 158 } 159 160 // ----------------------------------------------------------------------- 161 162 SvtSysLocaleOptions_Impl::SvtSysLocaleOptions_Impl() 163 : ConfigItem( ROOTNODE_SYSLOCALE ) 164 , m_nBlockedHint( 0 ) 165 , m_bDecimalSeparator( sal_True ) 166 , m_bROLocale(CFG_READONLY_DEFAULT) 167 , m_bROUILocale(CFG_READONLY_DEFAULT) 168 , m_bROCurrency(CFG_READONLY_DEFAULT) 169 , m_bRODecimalSeparator(sal_False) 170 171 { 172 if ( IsValidConfigMgr() ) 173 { 174 const Sequence< OUString > aNames = GetPropertyNames(); 175 Sequence< Any > aValues = GetProperties( aNames ); 176 Sequence< sal_Bool > aROStates = GetReadOnlyStates( aNames ); 177 const Any* pValues = aValues.getConstArray(); 178 const sal_Bool* pROStates = aROStates.getConstArray(); 179 DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties failed" ); 180 DBG_ASSERT( aROStates.getLength() == aNames.getLength(), "GetReadOnlyStates failed" ); 181 if ( aValues.getLength() == aNames.getLength() && aROStates.getLength() == aNames.getLength() ) 182 { 183 for ( sal_Int32 nProp = 0; nProp < aNames.getLength(); nProp++ ) 184 { 185 DBG_ASSERT( pValues[nProp].hasValue(), "property value missing" ); 186 if ( pValues[nProp].hasValue() ) 187 { 188 switch ( nProp ) 189 { 190 case PROPERTYHANDLE_LOCALE : 191 { 192 OUString aStr; 193 if ( pValues[nProp] >>= aStr ) 194 m_aLocaleString = aStr; 195 else 196 { 197 DBG_ERRORFILE( "Wrong property type!" ); 198 } 199 m_bROLocale = pROStates[nProp]; 200 } 201 break; 202 case PROPERTYHANDLE_UILOCALE : 203 { 204 OUString aStr; 205 if ( pValues[nProp] >>= aStr ) 206 m_aUILocaleString = aStr; 207 else 208 { 209 DBG_ERRORFILE( "Wrong property type!" ); 210 } 211 m_bROUILocale = pROStates[nProp]; 212 } 213 break; 214 case PROPERTYHANDLE_CURRENCY : 215 { 216 OUString aStr; 217 if ( pValues[nProp] >>= aStr ) 218 m_aCurrencyString = aStr; 219 else 220 { 221 DBG_ERRORFILE( "Wrong property type!" ); 222 } 223 m_bROCurrency = pROStates[nProp]; 224 } 225 break; 226 case PROPERTYHANDLE_DECIMALSEPARATOR: 227 { 228 sal_Bool bValue = sal_Bool(); 229 if ( pValues[nProp] >>= bValue ) 230 m_bDecimalSeparator = bValue; 231 else 232 { 233 DBG_ERRORFILE( "Wrong property type!" ); 234 } 235 m_bRODecimalSeparator = pROStates[nProp]; 236 } 237 break; 238 default: 239 DBG_ERRORFILE( "Wrong property type!" ); 240 } 241 } 242 } 243 } 244 // UpdateMiscSettings_Impl(); 245 EnableNotification( aNames ); 246 } 247 248 MakeRealLocale(); 249 MakeRealUILocale(); 250 } 251 252 253 SvtSysLocaleOptions_Impl::~SvtSysLocaleOptions_Impl() 254 { 255 if ( IsModified() ) 256 Commit(); 257 } 258 259 void SvtSysLocaleOptions_Impl::MakeRealLocale() 260 { 261 m_aRealLocale = lcl_str_to_locale( m_aLocaleString ); 262 if ( m_aRealLocale.Language.getLength() ) 263 { 264 m_eRealLanguage = MsLangId::convertLocaleToLanguage( m_aRealLocale ); 265 } 266 else 267 { 268 m_eRealLanguage = MsLangId::getSystemLanguage(); 269 MsLangId::convertLanguageToLocale( m_eRealLanguage, m_aRealLocale ); 270 } 271 } 272 273 void SvtSysLocaleOptions_Impl::MakeRealUILocale() 274 { 275 if ( !m_aRealUILocale.Language.getLength() ) 276 { 277 // as we can't switch UILocale at runtime, we only store changes in the configuration 278 m_aRealUILocale = lcl_str_to_locale( m_aUILocaleString ); 279 if ( m_aRealUILocale.Language.getLength() ) 280 { 281 m_eRealUILanguage = MsLangId::convertLocaleToLanguage( m_aRealUILocale ); 282 } 283 else 284 { 285 m_eRealUILanguage = MsLangId::getSystemUILanguage(); 286 MsLangId::convertLanguageToLocale( m_eRealUILanguage, m_aRealUILocale ); 287 } 288 } 289 } 290 291 sal_Bool SvtSysLocaleOptions_Impl::IsReadOnly( SvtSysLocaleOptions::EOption eOption ) const 292 { 293 sal_Bool bReadOnly = CFG_READONLY_DEFAULT; 294 switch(eOption) 295 { 296 case SvtSysLocaleOptions::E_LOCALE : 297 { 298 bReadOnly = m_bROLocale; 299 break; 300 } 301 case SvtSysLocaleOptions::E_UILOCALE : 302 { 303 bReadOnly = m_bROUILocale; 304 break; 305 } 306 case SvtSysLocaleOptions::E_CURRENCY : 307 { 308 bReadOnly = m_bROCurrency; 309 break; 310 } 311 } 312 return bReadOnly; 313 } 314 315 316 void SvtSysLocaleOptions_Impl::Commit() 317 { 318 const Sequence< OUString > aOrgNames = GetPropertyNames(); 319 sal_Int32 nOrgCount = aOrgNames.getLength(); 320 321 Sequence< OUString > aNames( nOrgCount ); 322 Sequence< Any > aValues( nOrgCount ); 323 324 OUString* pNames = aNames.getArray(); 325 Any* pValues = aValues.getArray(); 326 sal_Int32 nRealCount = 0; 327 328 for ( sal_Int32 nProp = 0; nProp < nOrgCount; nProp++ ) 329 { 330 switch ( nProp ) 331 { 332 case PROPERTYHANDLE_LOCALE : 333 { 334 if (!m_bROLocale) 335 { 336 pNames[nRealCount] = aOrgNames[nProp]; 337 pValues[nRealCount] <<= m_aLocaleString; 338 ++nRealCount; 339 } 340 } 341 break; 342 case PROPERTYHANDLE_UILOCALE : 343 { 344 if (!m_bROUILocale) 345 { 346 pNames[nRealCount] = aOrgNames[nProp]; 347 pValues[nRealCount] <<= m_aUILocaleString; 348 ++nRealCount; 349 } 350 } 351 break; 352 case PROPERTYHANDLE_CURRENCY : 353 { 354 if (!m_bROCurrency) 355 { 356 pNames[nRealCount] = aOrgNames[nProp]; 357 pValues[nRealCount] <<= m_aCurrencyString; 358 ++nRealCount; 359 } 360 } 361 break; 362 case PROPERTYHANDLE_DECIMALSEPARATOR: 363 if( !m_bRODecimalSeparator ) 364 { 365 pNames[nRealCount] = aOrgNames[nProp]; 366 pValues[nRealCount] <<= m_bDecimalSeparator; 367 ++nRealCount; 368 } 369 break; 370 default: 371 DBG_ERRORFILE( "invalid index to save a path" ); 372 } 373 } 374 aNames.realloc(nRealCount); 375 aValues.realloc(nRealCount); 376 PutProperties( aNames, aValues ); 377 ClearModified(); 378 } 379 380 381 void SvtSysLocaleOptions_Impl::SetLocaleString( const OUString& rStr ) 382 { 383 if (!m_bROLocale && rStr != m_aLocaleString ) 384 { 385 m_aLocaleString = rStr; 386 MakeRealLocale(); 387 MsLangId::setConfiguredSystemLanguage( m_eRealLanguage ); 388 SetModified(); 389 sal_uLong nHint = SYSLOCALEOPTIONS_HINT_LOCALE; 390 if ( !m_aCurrencyString.getLength() ) 391 nHint |= SYSLOCALEOPTIONS_HINT_CURRENCY; 392 NotifyListeners( nHint ); 393 } 394 } 395 396 void SvtSysLocaleOptions_Impl::SetUILocaleString( const OUString& rStr ) 397 { 398 if (!m_bROUILocale && rStr != m_aUILocaleString ) 399 { 400 m_aUILocaleString = rStr; 401 /* 402 // as we can't switch UILocale at runtime, we only store changes in the configuration 403 MakeRealUILocale(); 404 MsLangId::setConfiguredSystemLanguage( m_eRealUILanguage ); 405 SetModified(); 406 NotifyListeners( SYSLOCALEOPTIONS_HINT_UILOCALE ); 407 */ 408 } 409 } 410 411 void SvtSysLocaleOptions_Impl::SetCurrencyString( const OUString& rStr ) 412 { 413 if (!m_bROCurrency && rStr != m_aCurrencyString ) 414 { 415 m_aCurrencyString = rStr; 416 SetModified(); 417 NotifyListeners( SYSLOCALEOPTIONS_HINT_CURRENCY ); 418 } 419 } 420 421 void SvtSysLocaleOptions_Impl::SetDecimalSeparatorAsLocale( sal_Bool bSet) 422 { 423 if(bSet != m_bDecimalSeparator) 424 { 425 m_bDecimalSeparator = bSet; 426 SetModified(); 427 NotifyListeners( SYSLOCALEOPTIONS_HINT_DECSEP ); 428 } 429 } 430 431 void SvtSysLocaleOptions_Impl::Notify( const Sequence< rtl::OUString >& seqPropertyNames ) 432 { 433 sal_uLong nHint = 0; 434 Sequence< Any > seqValues = GetProperties( seqPropertyNames ); 435 Sequence< sal_Bool > seqROStates = GetReadOnlyStates( seqPropertyNames ); 436 sal_Int32 nCount = seqPropertyNames.getLength(); 437 for( sal_Int32 nProp = 0; nProp < nCount; ++nProp ) 438 { 439 if( seqPropertyNames[nProp] == PROPERTYNAME_LOCALE ) 440 { 441 DBG_ASSERT( seqValues[nProp].getValueTypeClass() == TypeClass_STRING, "Locale property type" ); 442 seqValues[nProp] >>= m_aLocaleString; 443 m_bROLocale = seqROStates[nProp]; 444 nHint |= SYSLOCALEOPTIONS_HINT_LOCALE; 445 if ( !m_aCurrencyString.getLength() ) 446 nHint |= SYSLOCALEOPTIONS_HINT_CURRENCY; 447 MakeRealLocale(); 448 } 449 if( seqPropertyNames[nProp] == PROPERTYNAME_UILOCALE ) 450 { 451 DBG_ASSERT( seqValues[nProp].getValueTypeClass() == TypeClass_STRING, "Locale property type" ); 452 seqValues[nProp] >>= m_aUILocaleString; 453 m_bROUILocale = seqROStates[nProp]; 454 nHint |= SYSLOCALEOPTIONS_HINT_UILOCALE; 455 MakeRealUILocale(); 456 } 457 else if( seqPropertyNames[nProp] == PROPERTYNAME_CURRENCY ) 458 { 459 DBG_ASSERT( seqValues[nProp].getValueTypeClass() == TypeClass_STRING, "Currency property type" ); 460 seqValues[nProp] >>= m_aCurrencyString; 461 m_bROCurrency = seqROStates[nProp]; 462 nHint |= SYSLOCALEOPTIONS_HINT_CURRENCY; 463 } 464 else if( seqPropertyNames[nProp] == PROPERTYNAME_DECIMALSEPARATOR ) 465 { 466 seqValues[nProp] >>= m_bDecimalSeparator; 467 m_bRODecimalSeparator = seqROStates[nProp]; 468 } 469 } 470 if ( nHint ) 471 NotifyListeners( nHint ); 472 } 473 474 // ==================================================================== 475 476 SvtSysLocaleOptions::SvtSysLocaleOptions() 477 { 478 MutexGuard aGuard( GetMutex() ); 479 if ( !pOptions ) 480 { 481 RTL_LOGFILE_CONTEXT(aLog, "svl ( ??? ) ::SvtSysLocaleOptions_Impl::ctor()"); 482 pOptions = new SvtSysLocaleOptions_Impl; 483 484 ItemHolder1::holdConfigItem(E_SYSLOCALEOPTIONS); 485 } 486 ++nRefCount; 487 pOptions->AddListener(this); 488 } 489 490 491 SvtSysLocaleOptions::~SvtSysLocaleOptions() 492 { 493 MutexGuard aGuard( GetMutex() ); 494 pOptions->RemoveListener(this); 495 if ( !--nRefCount ) 496 { 497 delete pOptions; 498 pOptions = NULL; 499 } 500 } 501 502 503 // static 504 Mutex& SvtSysLocaleOptions::GetMutex() 505 { 506 static Mutex* pMutex = NULL; 507 if( !pMutex ) 508 { 509 MutexGuard aGuard( Mutex::getGlobalMutex() ); 510 if( !pMutex ) 511 { 512 // #i77768# Due to a static reference in the toolkit lib 513 // we need a mutex that lives longer than the svl library. 514 // Otherwise the dtor would use a destructed mutex!! 515 pMutex = new Mutex; 516 } 517 } 518 return *pMutex; 519 } 520 521 522 sal_Bool SvtSysLocaleOptions::IsModified() 523 { 524 MutexGuard aGuard( GetMutex() ); 525 return pOptions->IsModified(); 526 } 527 528 529 void SvtSysLocaleOptions::Commit() 530 { 531 MutexGuard aGuard( GetMutex() ); 532 pOptions->Commit(); 533 } 534 535 536 void SvtSysLocaleOptions::BlockBroadcasts( bool bBlock ) 537 { 538 MutexGuard aGuard( GetMutex() ); 539 pOptions->BlockBroadcasts( bBlock ); 540 } 541 542 543 const OUString& SvtSysLocaleOptions::GetLocaleConfigString() const 544 { 545 MutexGuard aGuard( GetMutex() ); 546 return pOptions->GetLocaleString(); 547 } 548 549 void SvtSysLocaleOptions::SetLocaleConfigString( const OUString& rStr ) 550 { 551 MutexGuard aGuard( GetMutex() ); 552 pOptions->SetLocaleString( rStr ); 553 } 554 555 const OUString& SvtSysLocaleOptions::GetUILocaleConfigString() const 556 { 557 MutexGuard aGuard( GetMutex() ); 558 return pOptions->GetUILocaleString(); 559 } 560 561 void SvtSysLocaleOptions::SetUILocaleConfigString( const OUString& rStr ) 562 { 563 MutexGuard aGuard( GetMutex() ); 564 pOptions->SetUILocaleString( rStr ); 565 } 566 567 const OUString& SvtSysLocaleOptions::GetCurrencyConfigString() const 568 { 569 MutexGuard aGuard( GetMutex() ); 570 return pOptions->GetCurrencyString(); 571 } 572 573 574 void SvtSysLocaleOptions::SetCurrencyConfigString( const OUString& rStr ) 575 { 576 MutexGuard aGuard( GetMutex() ); 577 pOptions->SetCurrencyString( rStr ); 578 } 579 580 581 582 /*-- 11.02.2004 13:31:41--------------------------------------------------- 583 584 -----------------------------------------------------------------------*/ 585 sal_Bool SvtSysLocaleOptions::IsDecimalSeparatorAsLocale() const 586 { 587 MutexGuard aGuard( GetMutex() ); 588 return pOptions->IsDecimalSeparatorAsLocale(); 589 } 590 /*-- 11.02.2004 13:31:41--------------------------------------------------- 591 592 -----------------------------------------------------------------------*/ 593 void SvtSysLocaleOptions::SetDecimalSeparatorAsLocale( sal_Bool bSet) 594 { 595 MutexGuard aGuard( GetMutex() ); 596 pOptions->SetDecimalSeparatorAsLocale(bSet); 597 } 598 599 600 sal_Bool SvtSysLocaleOptions::IsReadOnly( EOption eOption ) const 601 { 602 MutexGuard aGuard( GetMutex() ); 603 return pOptions->IsReadOnly( eOption ); 604 } 605 606 // static 607 void SvtSysLocaleOptions::GetCurrencyAbbrevAndLanguage( String& rAbbrev, 608 LanguageType& eLang, const ::rtl::OUString& rConfigString ) 609 { 610 sal_Int32 nDelim = rConfigString.indexOf( '-' ); 611 if ( nDelim >= 0 ) 612 { 613 rAbbrev = rConfigString.copy( 0, nDelim ); 614 String aIsoStr( rConfigString.copy( nDelim+1 ) ); 615 eLang = MsLangId::convertIsoStringToLanguage( aIsoStr ); 616 } 617 else 618 { 619 rAbbrev = rConfigString; 620 eLang = (rAbbrev.Len() ? LANGUAGE_NONE : LANGUAGE_SYSTEM); 621 } 622 } 623 624 625 // static 626 ::rtl::OUString SvtSysLocaleOptions::CreateCurrencyConfigString( 627 const String& rAbbrev, LanguageType eLang ) 628 { 629 String aIsoStr( MsLangId::convertLanguageToIsoString( eLang ) ); 630 if ( aIsoStr.Len() ) 631 { 632 ::rtl::OUStringBuffer aStr( rAbbrev.Len() + 1 + aIsoStr.Len() ); 633 aStr.append( rAbbrev.GetBuffer(), rAbbrev.Len() ); 634 aStr.append( sal_Unicode('-') ); 635 aStr.append( aIsoStr.GetBuffer(), aIsoStr.Len() ); 636 return aStr.makeStringAndClear(); 637 } 638 else 639 return rAbbrev; 640 } 641 642 643 // static 644 void SvtSysLocaleOptions::SetCurrencyChangeLink( const Link& rLink ) 645 { 646 MutexGuard aGuard( GetMutex() ); 647 DBG_ASSERT( !CurrencyChangeLink::get().IsSet(), "SvtSysLocaleOptions::SetCurrencyChangeLink: already set" ); 648 CurrencyChangeLink::get() = rLink; 649 } 650 651 652 // static 653 const Link& SvtSysLocaleOptions::GetCurrencyChangeLink() 654 { 655 MutexGuard aGuard( GetMutex() ); 656 return CurrencyChangeLink::get(); 657 } 658 659 660 void SvtSysLocaleOptions::ConfigurationChanged( utl::ConfigurationBroadcaster* p, sal_uInt32 nHint ) 661 { 662 if ( nHint & SYSLOCALEOPTIONS_HINT_CURRENCY ) 663 { 664 const Link& rLink = GetCurrencyChangeLink(); 665 if ( rLink.IsSet() ) 666 rLink.Call( NULL ); 667 } 668 669 ::utl::detail::Options::ConfigurationChanged( p, nHint ); 670 } 671 672 com::sun::star::lang::Locale SvtSysLocaleOptions::GetLocale() const 673 { 674 return lcl_str_to_locale( GetLocaleConfigString() ); 675 } 676 677 com::sun::star::lang::Locale SvtSysLocaleOptions::GetUILocale() const 678 { 679 return lcl_str_to_locale( GetUILocaleConfigString() ); 680 } 681 682 com::sun::star::lang::Locale SvtSysLocaleOptions::GetRealLocale() const 683 { 684 return pOptions->GetRealLocale(); 685 } 686 687 com::sun::star::lang::Locale SvtSysLocaleOptions::GetRealUILocale() const 688 { 689 return pOptions->GetRealUILocale(); 690 } 691 692 LanguageType SvtSysLocaleOptions::GetRealLanguage() const 693 { 694 return pOptions->GetRealLanguage(); 695 } 696 697 LanguageType SvtSysLocaleOptions::GetRealUILanguage() const 698 { 699 return pOptions->GetRealUILanguage(); 700 } 701 702 703