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_svtools.hxx" 30 //_________________________________________________________________________________________________________________ 31 // includes 32 //_________________________________________________________________________________________________________________ 33 34 #include <svtools/miscopt.hxx> 35 #include <unotools/configmgr.hxx> 36 #include <unotools/configitem.hxx> 37 #include <tools/debug.hxx> 38 #include <com/sun/star/uno/Any.hxx> 39 #include <com/sun/star/uno/Sequence.hxx> 40 #include <tools/link.hxx> 41 #include <tools/list.hxx> 42 #include <tools/wldcrd.hxx> 43 #include <tools/urlobj.hxx> 44 45 #include <rtl/logfile.hxx> 46 #include "itemholder2.hxx" 47 48 #include <svtools/imgdef.hxx> 49 #include <vcl/svapp.hxx> 50 51 //_________________________________________________________________________________________________________________ 52 // namespaces 53 //_________________________________________________________________________________________________________________ 54 55 using namespace ::utl ; 56 using namespace ::rtl ; 57 using namespace ::osl ; 58 using namespace ::com::sun::star::uno ; 59 using namespace ::com::sun::star; 60 61 //_________________________________________________________________________________________________________________ 62 // const 63 //_________________________________________________________________________________________________________________ 64 65 #define ASCII_STR(s) OUString( RTL_CONSTASCII_USTRINGPARAM(s) ) 66 #define ROOTNODE_MISC ASCII_STR("Office.Common/Misc") 67 #define DEFAULT_PLUGINSENABLED sal_True; 68 69 #define PROPERTYNAME_PLUGINSENABLED ASCII_STR("PluginsEnabled") 70 #define PROPERTYHANDLE_PLUGINSENABLED 0 71 #define PROPERTYNAME_SYMBOLSET ASCII_STR("SymbolSet") 72 #define PROPERTYHANDLE_SYMBOLSET 1 73 #define PROPERTYNAME_TOOLBOXSTYLE ASCII_STR("ToolboxStyle") 74 #define PROPERTYHANDLE_TOOLBOXSTYLE 2 75 #define PROPERTYNAME_USESYSTEMFILEDIALOG ASCII_STR("UseSystemFileDialog") 76 #define PROPERTYHANDLE_USESYSTEMFILEDIALOG 3 77 #define PROPERTYNAME_SYMBOLSTYLE ASCII_STR("SymbolStyle") 78 #define PROPERTYHANDLE_SYMBOLSTYLE 4 79 #define PROPERTYNAME_USESYSTEMPRINTDIALOG ASCII_STR("UseSystemPrintDialog") 80 #define PROPERTYHANDLE_USESYSTEMPRINTDIALOG 5 81 82 #define PROPERTYCOUNT 6 83 84 #define VCL_TOOLBOX_STYLE_FLAT ((sal_uInt16)0x0004) // from <vcl/toolbox.hxx> 85 86 DECLARE_LIST( LinkList, Link * ) 87 88 //_________________________________________________________________________________________________________________ 89 // private declarations! 90 //_________________________________________________________________________________________________________________ 91 92 class SvtMiscOptions_Impl : public ConfigItem 93 { 94 //------------------------------------------------------------------------------------------------------------- 95 // private member 96 //------------------------------------------------------------------------------------------------------------- 97 98 private: 99 LinkList aList; 100 sal_Bool m_bUseSystemFileDialog; 101 sal_Bool m_bIsUseSystemFileDialogRO; 102 sal_Bool m_bPluginsEnabled; 103 sal_Bool m_bIsPluginsEnabledRO; 104 sal_Int16 m_nSymbolsSize; 105 sal_Bool m_bIsSymbolsSizeRO; 106 sal_Bool m_bIsSymbolsStyleRO; 107 sal_Int16 m_nToolboxStyle; 108 sal_Bool m_bIsToolboxStyleRO; 109 sal_Bool m_bUseSystemPrintDialog; 110 sal_Bool m_bIsUseSystemPrintDialogRO; 111 112 //------------------------------------------------------------------------------------------------------------- 113 // public methods 114 //------------------------------------------------------------------------------------------------------------- 115 116 public: 117 118 //--------------------------------------------------------------------------------------------------------- 119 // constructor / destructor 120 //--------------------------------------------------------------------------------------------------------- 121 122 SvtMiscOptions_Impl(); 123 ~SvtMiscOptions_Impl(); 124 125 //--------------------------------------------------------------------------------------------------------- 126 // overloaded methods of baseclass 127 //--------------------------------------------------------------------------------------------------------- 128 129 /*-****************************************************************************************************//** 130 @short called for notify of configmanager 131 @descr These method is called from the ConfigManager before application ends or from the 132 PropertyChangeListener if the sub tree broadcasts changes. You must update your 133 internal values. 134 135 @seealso baseclass ConfigItem 136 137 @param "seqPropertyNames" is the list of properties which should be updated. 138 @return - 139 140 @onerror - 141 *//*-*****************************************************************************************************/ 142 143 virtual void Notify( const Sequence< OUString >& seqPropertyNames ); 144 145 /** loads required data from the configuration. It's called in the constructor to 146 read all entries and form ::Notify to re-read changed settings 147 148 */ 149 void Load( const Sequence< OUString >& rPropertyNames ); 150 151 /*-****************************************************************************************************//** 152 @short write changes to configuration 153 @descr These method writes the changed values into the sub tree 154 and should always called in our destructor to guarantee consistency of config data. 155 156 @seealso baseclass ConfigItem 157 158 @param - 159 @return - 160 161 @onerror - 162 *//*-*****************************************************************************************************/ 163 164 virtual void Commit(); 165 166 //--------------------------------------------------------------------------------------------------------- 167 // public interface 168 //--------------------------------------------------------------------------------------------------------- 169 170 inline sal_Bool UseSystemFileDialog() const 171 { return m_bUseSystemFileDialog; } 172 173 inline void SetUseSystemFileDialog( sal_Bool bSet ) 174 { m_bUseSystemFileDialog = bSet; SetModified(); } 175 176 inline sal_Bool IsUseSystemFileDialogReadOnly() const 177 { return m_bIsUseSystemFileDialogRO; } 178 179 inline sal_Bool IsPluginsEnabled() const 180 { return m_bPluginsEnabled; } 181 182 void SetPluginsEnabled( sal_Bool bEnable ); 183 184 inline sal_Bool IsPluginsEnabledReadOnly() const 185 { return m_bIsPluginsEnabledRO; } 186 187 inline sal_Int16 GetSymbolsSize() 188 { return m_nSymbolsSize; } 189 190 void SetSymbolsSize( sal_Int16 nSet ); 191 192 inline sal_Bool IsGetSymbolsSizeReadOnly() 193 { return m_bIsSymbolsSizeRO; } 194 195 sal_Int16 GetSymbolsStyle() const; 196 ::rtl::OUString GetSymbolsStyleName() const; 197 sal_Int16 GetCurrentSymbolsStyle() const; 198 199 inline void SetSymbolsStyle( sal_Int16 nSet ) 200 { ImplSetSymbolsStyle( true, nSet, ::rtl::OUString() ); } 201 202 inline void SetSymbolsStyleName( ::rtl::OUString &rName ) 203 { ImplSetSymbolsStyle( false, 0, rName ); } 204 205 inline sal_Bool IsGetSymbolsStyleReadOnly() 206 { return m_bIsSymbolsStyleRO; } 207 208 // translate to VCL settings ( "0" = 3D, "1" = FLAT ) 209 inline sal_Int16 GetToolboxStyle() 210 { return m_nToolboxStyle ? VCL_TOOLBOX_STYLE_FLAT : 0; } 211 212 // translate from VCL settings 213 void SetToolboxStyle( sal_Int16 nStyle, bool _bSetModified ); 214 215 inline sal_Bool IsGetToolboxStyleReadOnly() 216 { return m_bIsToolboxStyleRO; } 217 218 inline sal_Bool UseSystemPrintDialog() const 219 { return m_bUseSystemPrintDialog; } 220 221 inline void SetUseSystemPrintDialog( sal_Bool bSet ) 222 { m_bUseSystemPrintDialog = bSet; SetModified(); } 223 224 inline sal_Bool IsUseSystemPrintDialogReadOnly() const 225 { return m_bIsUseSystemPrintDialogRO; } 226 227 void AddListenerLink( const Link& rLink ); 228 void RemoveListenerLink( const Link& rLink ); 229 void CallListeners(); 230 231 //------------------------------------------------------------------------------------------------------------- 232 // private methods 233 //------------------------------------------------------------------------------------------------------------- 234 235 private: 236 237 /*-****************************************************************************************************//** 238 @short return list of key names of ouer configuration management which represent oue module tree 239 @descr These methods return a static const list of key names. We need it to get needed values from our 240 configuration management. 241 242 @seealso - 243 244 @param - 245 @return A list of needed configuration keys is returned. 246 247 @onerror - 248 *//*-*****************************************************************************************************/ 249 250 static Sequence< OUString > GetPropertyNames(); 251 252 protected: 253 void ImplSetSymbolsStyle( bool bValue, sal_Int16 nSet, const ::rtl::OUString &rName ); 254 }; 255 256 //***************************************************************************************************************** 257 // constructor 258 //***************************************************************************************************************** 259 SvtMiscOptions_Impl::SvtMiscOptions_Impl() 260 // Init baseclasses first 261 : ConfigItem( ROOTNODE_MISC ) 262 263 , m_bUseSystemFileDialog( sal_False ) 264 , m_bIsUseSystemFileDialogRO( sal_False ) 265 , m_bPluginsEnabled( sal_False ) 266 , m_bIsPluginsEnabledRO( sal_False ) 267 , m_nSymbolsSize( 0 ) 268 , m_bIsSymbolsSizeRO( sal_False ) 269 , m_bIsSymbolsStyleRO( sal_False ) 270 , m_nToolboxStyle( 1 ) 271 , m_bIsToolboxStyleRO( sal_False ) 272 , m_bUseSystemPrintDialog( sal_False ) 273 , m_bIsUseSystemPrintDialogRO( sal_False ) 274 275 { 276 // Use our static list of configuration keys to get his values. 277 Sequence< OUString > seqNames = GetPropertyNames ( ); 278 Load( seqNames ); 279 Sequence< Any > seqValues = GetProperties ( seqNames ); 280 Sequence< sal_Bool > seqRO = GetReadOnlyStates ( seqNames ); 281 282 // Safe impossible cases. 283 // We need values from ALL configuration keys. 284 // Follow assignment use order of values in relation to our list of key names! 285 DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtMiscOptions_Impl::SvtMiscOptions_Impl()\nI miss some values of configuration keys!\n" ); 286 287 // Copy values from list in right order to ouer internal member. 288 sal_Int32 nPropertyCount = seqValues.getLength(); 289 for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty ) 290 { 291 // Safe impossible cases. 292 // Check any for valid value. 293 DBG_ASSERT( !(seqValues[nProperty].hasValue()==sal_False), "SvtSecurityOptions_Impl::SvtSecurityOptions_Impl()\nInvalid property value detected!\n" ); 294 switch( nProperty ) 295 { 296 case PROPERTYHANDLE_PLUGINSENABLED : 297 { 298 if( !(seqValues[nProperty] >>= m_bPluginsEnabled) ) 299 { 300 DBG_ERROR("Wrong type of \"Misc\\PluginsEnabled\"!" ); 301 } 302 m_bIsPluginsEnabledRO = seqRO[nProperty]; 303 break; 304 } 305 306 case PROPERTYHANDLE_SYMBOLSET : 307 { 308 if( !(seqValues[nProperty] >>= m_nSymbolsSize) ) 309 { 310 DBG_ERROR("Wrong type of \"Misc\\SymbolSet\"!" ); 311 } 312 m_bIsSymbolsSizeRO = seqRO[nProperty]; 313 break; 314 } 315 316 case PROPERTYHANDLE_TOOLBOXSTYLE : 317 { 318 if( !(seqValues[nProperty] >>= m_nToolboxStyle) ) 319 { 320 DBG_ERROR("Wrong type of \"Misc\\ToolboxStyle\"!" ); 321 } 322 m_bIsToolboxStyleRO = seqRO[nProperty]; 323 break; 324 } 325 326 case PROPERTYHANDLE_USESYSTEMFILEDIALOG : 327 { 328 if( !(seqValues[nProperty] >>= m_bUseSystemFileDialog) ) 329 { 330 DBG_ERROR("Wrong type of \"Misc\\UseSystemFileDialog\"!" ); 331 } 332 m_bIsUseSystemFileDialogRO = seqRO[nProperty]; 333 break; 334 } 335 336 case PROPERTYHANDLE_USESYSTEMPRINTDIALOG : 337 { 338 if( !(seqValues[nProperty] >>= m_bUseSystemPrintDialog) ) 339 { 340 DBG_ERROR("Wrong type of \"Misc\\UseSystemPrintDialog\"!" ); 341 } 342 m_bIsUseSystemPrintDialogRO = seqRO[nProperty]; 343 break; 344 } 345 346 case PROPERTYHANDLE_SYMBOLSTYLE : 347 { 348 ::rtl::OUString aSymbolsStyle; 349 if( seqValues[nProperty] >>= aSymbolsStyle ) 350 SetSymbolsStyleName( aSymbolsStyle ); 351 else 352 { 353 DBG_ERROR("Wrong type of \"Misc\\SymbolStyle\"!" ); 354 } 355 m_bIsSymbolsStyleRO = seqRO[nProperty]; 356 break; 357 } 358 } 359 } 360 361 // Enable notification mechanism of ouer baseclass. 362 // We need it to get information about changes outside these class on ouer used configuration keys! 363 EnableNotification( seqNames ); 364 } 365 366 //***************************************************************************************************************** 367 // destructor 368 //***************************************************************************************************************** 369 SvtMiscOptions_Impl::~SvtMiscOptions_Impl() 370 { 371 // We must save our current values .. if user forget it! 372 if( IsModified() == sal_True ) 373 { 374 Commit(); 375 } 376 377 for ( sal_uInt16 n=0; n<aList.Count(); ) 378 delete aList.Remove(n); 379 } 380 381 /*-- 25.02.2005 13:22:04--------------------------------------------------- 382 383 -----------------------------------------------------------------------*/ 384 static int lcl_MapPropertyName( const ::rtl::OUString rCompare, 385 const uno::Sequence< ::rtl::OUString>& aInternalPropertyNames) 386 { 387 for(int nProp = 0; nProp < aInternalPropertyNames.getLength(); ++nProp) 388 { 389 if( aInternalPropertyNames[nProp] == rCompare ) 390 return nProp; 391 } 392 return -1; 393 } 394 395 void SvtMiscOptions_Impl::Load( const Sequence< OUString >& rPropertyNames ) 396 { 397 const uno::Sequence< ::rtl::OUString> aInternalPropertyNames( GetPropertyNames()); 398 Sequence< Any > seqValues = GetProperties( rPropertyNames ); 399 400 // Safe impossible cases. 401 // We need values from ALL configuration keys. 402 // Follow assignment use order of values in relation to our list of key names! 403 DBG_ASSERT( !(rPropertyNames.getLength()!=seqValues.getLength()), "SvtSecurityOptions_Impl::SvtSecurityOptions_Impl()\nI miss some values of configuration keys!\n" ); 404 405 // Copy values from list in right order to ouer internal member. 406 sal_Int32 nPropertyCount = seqValues.getLength(); 407 for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty ) 408 { 409 // Safe impossible cases. 410 // Check any for valid value. 411 DBG_ASSERT( !(seqValues[nProperty].hasValue()==sal_False), "SvtSecurityOptions_Impl::SvtSecurityOptions_Impl()\nInvalid property value detected!\n" ); 412 switch( lcl_MapPropertyName(rPropertyNames[nProperty], aInternalPropertyNames) ) 413 { 414 case PROPERTYHANDLE_PLUGINSENABLED : { 415 if( !(seqValues[nProperty] >>= m_bPluginsEnabled) ) 416 { 417 DBG_ERROR("Wrong type of \"Misc\\PluginsEnabled\"!" ); 418 } 419 } 420 break; 421 case PROPERTYHANDLE_SYMBOLSET : { 422 if( !(seqValues[nProperty] >>= m_nSymbolsSize) ) 423 { 424 DBG_ERROR("Wrong type of \"Misc\\SymbolSet\"!" ); 425 } 426 } 427 break; 428 case PROPERTYHANDLE_TOOLBOXSTYLE : { 429 if( !(seqValues[nProperty] >>= m_nToolboxStyle) ) 430 { 431 DBG_ERROR("Wrong type of \"Misc\\ToolboxStyle\"!" ); 432 } 433 } 434 break; 435 case PROPERTYHANDLE_USESYSTEMFILEDIALOG : { 436 if( !(seqValues[nProperty] >>= m_bUseSystemFileDialog) ) 437 { 438 DBG_ERROR("Wrong type of \"Misc\\UseSystemFileDialog\"!" ); 439 } 440 } 441 break; 442 case PROPERTYHANDLE_USESYSTEMPRINTDIALOG : { 443 if( !(seqValues[nProperty] >>= m_bUseSystemPrintDialog) ) 444 { 445 DBG_ERROR("Wrong type of \"Misc\\UseSystemPrintDialog\"!" ); 446 } 447 } 448 break; 449 case PROPERTYHANDLE_SYMBOLSTYLE : { 450 ::rtl::OUString aSymbolsStyle; 451 if( seqValues[nProperty] >>= aSymbolsStyle ) 452 SetSymbolsStyleName( aSymbolsStyle ); 453 else 454 { 455 DBG_ERROR("Wrong type of \"Misc\\SymbolStyle\"!" ); 456 } 457 } 458 break; 459 } 460 } 461 } 462 463 void SvtMiscOptions_Impl::AddListenerLink( const Link& rLink ) 464 { 465 aList.Insert( new Link( rLink ) ); 466 } 467 468 void SvtMiscOptions_Impl::RemoveListenerLink( const Link& rLink ) 469 { 470 for ( sal_uInt16 n=0; n<aList.Count(); n++ ) 471 { 472 if ( (*aList.GetObject(n) ) == rLink ) 473 { 474 delete aList.Remove(n); 475 break; 476 } 477 } 478 } 479 480 void SvtMiscOptions_Impl::CallListeners() 481 { 482 for ( sal_uInt16 n = 0; n < aList.Count(); ++n ) 483 aList.GetObject(n)->Call( this ); 484 } 485 486 void SvtMiscOptions_Impl::SetToolboxStyle( sal_Int16 nStyle, bool _bSetModified ) 487 { 488 m_nToolboxStyle = nStyle ? 1 : 0; 489 if ( _bSetModified ) 490 SetModified(); 491 CallListeners(); 492 } 493 494 void SvtMiscOptions_Impl::SetSymbolsSize( sal_Int16 nSet ) 495 { 496 m_nSymbolsSize = nSet; 497 SetModified(); 498 CallListeners(); 499 } 500 501 sal_Int16 SvtMiscOptions_Impl::GetSymbolsStyle() const 502 { 503 return (sal_Int16)Application::GetSettings().GetStyleSettings().GetSymbolsStyle(); 504 } 505 506 ::rtl::OUString SvtMiscOptions_Impl::GetSymbolsStyleName() const 507 { 508 return Application::GetSettings().GetStyleSettings().GetSymbolsStyleName(); 509 } 510 511 sal_Int16 SvtMiscOptions_Impl::GetCurrentSymbolsStyle() const 512 { 513 return (sal_Int16)Application::GetSettings().GetStyleSettings().GetCurrentSymbolsStyle(); 514 } 515 516 void SvtMiscOptions_Impl::ImplSetSymbolsStyle( bool bValue, sal_Int16 nSet, const ::rtl::OUString &rName ) 517 { 518 if ( ( bValue && ( nSet != GetSymbolsStyle() ) ) || 519 ( !bValue && ( rName != GetSymbolsStyleName() ) ) ) 520 { 521 AllSettings aAllSettings = Application::GetSettings(); 522 StyleSettings aStyleSettings = aAllSettings.GetStyleSettings(); 523 524 if ( bValue ) 525 aStyleSettings.SetSymbolsStyle( nSet ); 526 else 527 aStyleSettings.SetSymbolsStyleName( rName ); 528 529 aAllSettings.SetStyleSettings(aStyleSettings); 530 Application::MergeSystemSettings( aAllSettings ); 531 Application::SetSettings(aAllSettings); 532 533 SetModified(); 534 CallListeners(); 535 } 536 } 537 538 void SvtMiscOptions_Impl::SetPluginsEnabled( sal_Bool bEnable ) 539 { 540 m_bPluginsEnabled = bEnable; 541 SetModified(); 542 CallListeners(); 543 } 544 545 //***************************************************************************************************************** 546 // public method 547 //***************************************************************************************************************** 548 void SvtMiscOptions_Impl::Notify( const Sequence< OUString >& rPropertyNames ) 549 { 550 Load( rPropertyNames ); 551 CallListeners(); 552 } 553 554 //***************************************************************************************************************** 555 // public method 556 //***************************************************************************************************************** 557 void SvtMiscOptions_Impl::Commit() 558 { 559 // Get names of supported properties, create a list for values and copy current values to it. 560 Sequence< OUString > seqNames = GetPropertyNames (); 561 sal_Int32 nCount = seqNames.getLength(); 562 Sequence< Any > seqValues ( nCount ); 563 for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty ) 564 { 565 switch( nProperty ) 566 { 567 case PROPERTYHANDLE_PLUGINSENABLED : 568 { 569 if ( !m_bIsPluginsEnabledRO ) 570 seqValues[nProperty] <<= m_bPluginsEnabled; 571 break; 572 } 573 574 case PROPERTYHANDLE_SYMBOLSET : 575 { 576 if ( !m_bIsSymbolsSizeRO ) 577 seqValues[nProperty] <<= m_nSymbolsSize; 578 break; 579 } 580 581 case PROPERTYHANDLE_TOOLBOXSTYLE : 582 { 583 if ( !m_bIsToolboxStyleRO ) 584 seqValues[nProperty] <<= m_nToolboxStyle; 585 break; 586 } 587 588 case PROPERTYHANDLE_USESYSTEMFILEDIALOG : 589 { 590 if ( !m_bIsUseSystemFileDialogRO ) 591 seqValues[nProperty] <<= m_bUseSystemFileDialog; 592 break; 593 } 594 595 case PROPERTYHANDLE_SYMBOLSTYLE : 596 { 597 if ( !m_bIsSymbolsStyleRO ) 598 seqValues[nProperty] <<= GetSymbolsStyleName(); 599 break; 600 } 601 602 case PROPERTYHANDLE_USESYSTEMPRINTDIALOG : 603 { 604 if ( !m_bIsUseSystemPrintDialogRO ) 605 seqValues[nProperty] <<= m_bUseSystemPrintDialog; 606 break; 607 } 608 } 609 } 610 // Set properties in configuration. 611 PutProperties( seqNames, seqValues ); 612 } 613 614 //***************************************************************************************************************** 615 // private method 616 //***************************************************************************************************************** 617 Sequence< OUString > SvtMiscOptions_Impl::GetPropertyNames() 618 { 619 // Build static list of configuration key names. 620 static const OUString pProperties[] = 621 { 622 PROPERTYNAME_PLUGINSENABLED, 623 PROPERTYNAME_SYMBOLSET, 624 PROPERTYNAME_TOOLBOXSTYLE, 625 PROPERTYNAME_USESYSTEMFILEDIALOG, 626 PROPERTYNAME_SYMBOLSTYLE, 627 PROPERTYNAME_USESYSTEMPRINTDIALOG 628 }; 629 630 // Initialize return sequence with these list ... 631 static const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT ); 632 // ... and return it. 633 return seqPropertyNames; 634 } 635 636 //***************************************************************************************************************** 637 // initialize static member 638 // DON'T DO IT IN YOUR HEADER! 639 // see definition for further informations 640 //***************************************************************************************************************** 641 SvtMiscOptions_Impl* SvtMiscOptions::m_pDataContainer = NULL ; 642 sal_Int32 SvtMiscOptions::m_nRefCount = 0 ; 643 644 //***************************************************************************************************************** 645 // constructor 646 //***************************************************************************************************************** 647 SvtMiscOptions::SvtMiscOptions() 648 { 649 // Global access, must be guarded (multithreading!). 650 MutexGuard aGuard( GetInitMutex() ); 651 // Increase ouer refcount ... 652 ++m_nRefCount; 653 // ... and initialize ouer data container only if it not already exist! 654 if( m_pDataContainer == NULL ) 655 { 656 RTL_LOGFILE_CONTEXT(aLog, "svtools ( ??? ) ::SvtMiscOptions_Impl::ctor()"); 657 m_pDataContainer = new SvtMiscOptions_Impl; 658 ItemHolder2::holdConfigItem(E_MISCOPTIONS); 659 } 660 } 661 662 //***************************************************************************************************************** 663 // destructor 664 //***************************************************************************************************************** 665 SvtMiscOptions::~SvtMiscOptions() 666 { 667 // Global access, must be guarded (multithreading!) 668 MutexGuard aGuard( GetInitMutex() ); 669 // Decrease ouer refcount. 670 --m_nRefCount; 671 // If last instance was deleted ... 672 // we must destroy ouer static data container! 673 if( m_nRefCount <= 0 ) 674 { 675 delete m_pDataContainer; 676 m_pDataContainer = NULL; 677 } 678 } 679 680 sal_Bool SvtMiscOptions::UseSystemFileDialog() const 681 { 682 return m_pDataContainer->UseSystemFileDialog(); 683 } 684 685 void SvtMiscOptions::SetUseSystemFileDialog( sal_Bool bEnable ) 686 { 687 m_pDataContainer->SetUseSystemFileDialog( bEnable ); 688 } 689 690 sal_Bool SvtMiscOptions::IsUseSystemFileDialogReadOnly() const 691 { 692 return m_pDataContainer->IsUseSystemFileDialogReadOnly(); 693 } 694 695 sal_Bool SvtMiscOptions::IsPluginsEnabled() const 696 { 697 return m_pDataContainer->IsPluginsEnabled(); 698 } 699 700 void SvtMiscOptions::SetPluginsEnabled( sal_Bool bEnable ) 701 { 702 m_pDataContainer->SetPluginsEnabled( bEnable ); 703 } 704 705 sal_Bool SvtMiscOptions::IsPluginsEnabledReadOnly() const 706 { 707 return m_pDataContainer->IsPluginsEnabledReadOnly(); 708 } 709 710 sal_Int16 SvtMiscOptions::GetSymbolsSize() const 711 { 712 return m_pDataContainer->GetSymbolsSize(); 713 } 714 715 void SvtMiscOptions::SetSymbolsSize( sal_Int16 nSet ) 716 { 717 m_pDataContainer->SetSymbolsSize( nSet ); 718 } 719 720 sal_Int16 SvtMiscOptions::GetCurrentSymbolsSize() const 721 { 722 sal_Int16 eOptSymbolsSize = m_pDataContainer->GetSymbolsSize(); 723 724 if ( eOptSymbolsSize == SFX_SYMBOLS_SIZE_AUTO ) 725 { 726 // Use system settings, we have to retrieve the toolbar icon size from the 727 // Application class 728 sal_uLong nStyleIconSize = Application::GetSettings().GetStyleSettings().GetToolbarIconSize(); 729 if ( nStyleIconSize == STYLE_TOOLBAR_ICONSIZE_LARGE ) 730 eOptSymbolsSize = SFX_SYMBOLS_SIZE_LARGE; 731 else 732 eOptSymbolsSize = SFX_SYMBOLS_SIZE_SMALL; 733 } 734 735 return eOptSymbolsSize; 736 } 737 738 bool SvtMiscOptions::AreCurrentSymbolsLarge() const 739 { 740 return ( GetCurrentSymbolsSize() == SFX_SYMBOLS_SIZE_LARGE ); 741 } 742 743 sal_Bool SvtMiscOptions::IsGetSymbolsSizeReadOnly() const 744 { 745 return m_pDataContainer->IsGetSymbolsSizeReadOnly(); 746 } 747 748 sal_Int16 SvtMiscOptions::GetSymbolsStyle() const 749 { 750 return m_pDataContainer->GetSymbolsStyle(); 751 } 752 753 sal_Int16 SvtMiscOptions::GetCurrentSymbolsStyle() const 754 { 755 return m_pDataContainer->GetCurrentSymbolsStyle(); 756 } 757 758 OUString SvtMiscOptions::GetCurrentSymbolsStyleName() const 759 { 760 return Application::GetSettings().GetStyleSettings().GetCurrentSymbolsStyleName(); 761 } 762 763 void SvtMiscOptions::SetSymbolsStyle( sal_Int16 nSet ) 764 { 765 m_pDataContainer->SetSymbolsStyle( nSet ); 766 } 767 768 sal_Bool SvtMiscOptions::IsGetSymbolsStyleReadOnly() const 769 { 770 return m_pDataContainer->IsGetSymbolsStyleReadOnly(); 771 } 772 773 sal_Int16 SvtMiscOptions::GetToolboxStyle() const 774 { 775 return m_pDataContainer->GetToolboxStyle(); 776 } 777 778 void SvtMiscOptions::SetToolboxStyle( sal_Int16 nStyle ) 779 { 780 m_pDataContainer->SetToolboxStyle( nStyle, true ); 781 } 782 783 sal_Bool SvtMiscOptions::IsGetToolboxStyleReadOnly() const 784 { 785 return m_pDataContainer->IsGetToolboxStyleReadOnly(); 786 } 787 788 sal_Bool SvtMiscOptions::UseSystemPrintDialog() const 789 { 790 return m_pDataContainer->UseSystemPrintDialog(); 791 } 792 793 void SvtMiscOptions::SetUseSystemPrintDialog( sal_Bool bEnable ) 794 { 795 m_pDataContainer->SetUseSystemPrintDialog( bEnable ); 796 } 797 798 //***************************************************************************************************************** 799 // private method 800 //***************************************************************************************************************** 801 Mutex & SvtMiscOptions::GetInitMutex() 802 { 803 // Initialize static mutex only for one time! 804 static Mutex* pMutex = NULL; 805 // If these method first called (Mutex not already exist!) ... 806 if( pMutex == NULL ) 807 { 808 // ... we must create a new one. Protect follow code with the global mutex - 809 // It must be - we create a static variable! 810 MutexGuard aGuard( Mutex::getGlobalMutex() ); 811 // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these! 812 if( pMutex == NULL ) 813 { 814 // Create the new mutex and set it for return on static variable. 815 static Mutex aMutex; 816 pMutex = &aMutex; 817 } 818 } 819 // Return new created or already existing mutex object. 820 return *pMutex; 821 } 822 823 void SvtMiscOptions::AddListenerLink( const Link& rLink ) 824 { 825 m_pDataContainer->AddListenerLink( rLink ); 826 } 827 828 void SvtMiscOptions::RemoveListenerLink( const Link& rLink ) 829 { 830 m_pDataContainer->RemoveListenerLink( rLink ); 831 } 832