1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <svtools/miscopt.hxx>
21 #include <unotools/configmgr.hxx>
22 #include <unotools/configitem.hxx>
23 #include <tools/debug.hxx>
24 #include <com/sun/star/uno/Any.hxx>
25 #include <com/sun/star/uno/Sequence.hxx>
26 #include <tools/link.hxx>
28 #include <rtl/instance.hxx>
29 #include "itemholder2.hxx"
31 #include <svtools/imgdef.hxx>
32 #include <vcl/svapp.hxx>
33 #include <vcl/settings.hxx>
37 using namespace ::utl
;
38 using namespace ::osl
;
39 using namespace ::com::sun::star::uno
;
40 using namespace ::com::sun::star
;
42 #define ROOTNODE_MISC "Office.Common/Misc"
44 // PROPERTYHANDLE defines must be sequential from zero for Commit/Load
45 #define PROPERTYNAME_PLUGINSENABLED "PluginsEnabled"
46 #define PROPERTYHANDLE_PLUGINSENABLED 0
47 #define PROPERTYNAME_SYMBOLSET "SymbolSet"
48 #define PROPERTYHANDLE_SYMBOLSET 1
49 #define PROPERTYNAME_TOOLBOXSTYLE "ToolboxStyle"
50 #define PROPERTYHANDLE_TOOLBOXSTYLE 2
51 #define PROPERTYNAME_USESYSTEMFILEDIALOG "UseSystemFileDialog"
52 #define PROPERTYHANDLE_USESYSTEMFILEDIALOG 3
53 #define PROPERTYNAME_ICONTHEME "SymbolStyle"
54 #define PROPERTYHANDLE_SYMBOLSTYLE 4
55 #define PROPERTYNAME_USESYSTEMPRINTDIALOG "UseSystemPrintDialog"
56 #define PROPERTYHANDLE_USESYSTEMPRINTDIALOG 5
57 #define PROPERTYNAME_SHOWLINKWARNINGDIALOG "ShowLinkWarningDialog"
58 #define PROPERTYHANDLE_SHOWLINKWARNINGDIALOG 6
59 #define PROPERTYNAME_DISABLEUICUSTOMIZATION "DisableUICustomization"
60 #define PROPERTYHANDLE_DISABLEUICUSTOMIZATION 7
61 #define PROPERTYNAME_ALWAYSALLOWSAVE "AlwaysAllowSave"
62 #define PROPERTYHANDLE_ALWAYSALLOWSAVE 8
63 #define PROPERTYNAME_EXPERIMENTALMODE "ExperimentalMode"
64 #define PROPERTYHANDLE_EXPERIMENTALMODE 9
65 #define PROPERTYNAME_MACRORECORDERMODE "MacroRecorderMode"
66 #define PROPERTYHANDLE_MACRORECORDERMODE 10
68 #define VCL_TOOLBOX_STYLE_FLAT ((sal_uInt16)0x0004) // from <vcl/toolbox.hxx>
70 class SvtMiscOptions_Impl
: public ConfigItem
73 ::std::list
<Link
<>> aList
;
74 bool m_bUseSystemFileDialog
;
75 bool m_bIsUseSystemFileDialogRO
;
76 bool m_bPluginsEnabled
;
77 bool m_bIsPluginsEnabledRO
;
78 sal_Int16 m_nSymbolsSize
;
79 bool m_bIsSymbolsSizeRO
;
80 bool m_bIsSymbolsStyleRO
;
81 sal_Int16 m_nToolboxStyle
;
82 bool m_bIsToolboxStyleRO
;
83 bool m_bUseSystemPrintDialog
;
84 bool m_bIsUseSystemPrintDialogRO
;
85 bool m_bShowLinkWarningDialog
;
86 bool m_bIsShowLinkWarningDialogRO
;
87 bool m_bDisableUICustomization
;
88 bool m_bAlwaysAllowSave
;
89 bool m_bExperimentalMode
;
90 bool m_bMacroRecorderMode
;
91 bool m_bIconThemeWasSetAutomatically
;
93 virtual void ImplCommit() SAL_OVERRIDE
;
97 SvtMiscOptions_Impl();
98 virtual ~SvtMiscOptions_Impl();
100 /*-****************************************************************************************************
101 @short called for notify of configmanager
102 @descr These method is called from the ConfigManager before application ends or from the
103 PropertyChangeListener if the sub tree broadcasts changes. You must update your
106 @seealso baseclass ConfigItem
108 @param "seqPropertyNames" is the list of properties which should be updated.
109 *//*-*****************************************************************************************************/
111 virtual void Notify( const Sequence
< OUString
>& seqPropertyNames
) SAL_OVERRIDE
;
113 /** loads required data from the configuration. It's called in the constructor to
114 read all entries and form ::Notify to re-read changed settings
117 void Load( const Sequence
< OUString
>& rPropertyNames
);
122 inline bool UseSystemFileDialog() const
123 { return m_bUseSystemFileDialog
; }
125 inline void SetUseSystemFileDialog( bool bSet
)
126 { m_bUseSystemFileDialog
= bSet
; SetModified(); }
128 inline bool IsUseSystemFileDialogReadOnly() const
129 { return m_bIsUseSystemFileDialogRO
; }
131 inline bool DisableUICustomization() const
132 { return m_bDisableUICustomization
; }
134 inline void SetSaveAlwaysAllowed( bool bSet
)
135 { m_bAlwaysAllowSave
= bSet
; SetModified(); }
137 inline bool IsSaveAlwaysAllowed() const
138 { return m_bAlwaysAllowSave
; }
140 inline void SetExperimentalMode( bool bSet
)
141 { m_bExperimentalMode
= bSet
; SetModified(); }
143 inline bool IsExperimentalMode() const
144 { return m_bExperimentalMode
; }
146 inline void SetMacroRecorderMode( bool bSet
)
147 { m_bMacroRecorderMode
= bSet
; SetModified(); }
149 inline bool IsMacroRecorderMode() const
150 { return m_bMacroRecorderMode
; }
152 inline bool IsPluginsEnabled() const
153 { return m_bPluginsEnabled
; }
155 inline sal_Int16
GetSymbolsSize()
156 { return m_nSymbolsSize
; }
158 void SetSymbolsSize( sal_Int16 nSet
);
160 static OUString
GetIconTheme();
162 enum SetModifiedFlag
{ SET_MODIFIED
, DONT_SET_MODIFIED
};
164 /** Set the icon theme
167 * The name of the icon theme to use.
170 * Whether to call SetModified() and CallListeners().
173 * The @p setModified flag was introduced because the unittests fail if we call SetModified()
174 * during initialization in the constructor.
177 SetIconTheme(const OUString
&theme
, SetModifiedFlag setModified
= SET_MODIFIED
);
179 bool IconThemeWasSetAutomatically()
180 {return m_bIconThemeWasSetAutomatically
;}
182 /** Set the icon theme automatically by detecting the best theme for the desktop environment.
183 * The parameter setModified controls whether SetModified() will be called.
185 void SetIconThemeAutomatically(SetModifiedFlag
= SET_MODIFIED
);
187 // translate to VCL settings ( "0" = 3D, "1" = FLAT )
188 inline sal_Int16
GetToolboxStyle()
189 { return m_nToolboxStyle
? VCL_TOOLBOX_STYLE_FLAT
: 0; }
191 // translate from VCL settings
192 void SetToolboxStyle( sal_Int16 nStyle
, bool _bSetModified
);
194 inline bool UseSystemPrintDialog() const
195 { return m_bUseSystemPrintDialog
; }
197 inline void SetUseSystemPrintDialog( bool bSet
)
198 { m_bUseSystemPrintDialog
= bSet
; SetModified(); }
200 inline bool ShowLinkWarningDialog() const
201 { return m_bShowLinkWarningDialog
; }
203 void SetShowLinkWarningDialog( bool bSet
)
204 { m_bShowLinkWarningDialog
= bSet
; SetModified(); }
206 bool IsShowLinkWarningDialogReadOnly() const
207 { return m_bIsShowLinkWarningDialogRO
; }
209 void AddListenerLink( const Link
<>& rLink
);
210 void RemoveListenerLink( const Link
<>& rLink
);
211 void CallListeners();
219 /*-****************************************************************************************************
220 @short return list of key names of our configuration management which represent oue module tree
221 @descr These methods return a static const list of key names. We need it to get needed values from our
222 configuration management.
223 @return A list of needed configuration keys is returned.
224 *//*-*****************************************************************************************************/
226 static Sequence
< OUString
> GetPropertyNames();
232 SvtMiscOptions_Impl::SvtMiscOptions_Impl()
233 // Init baseclasses first
234 : ConfigItem( ROOTNODE_MISC
)
236 , m_bUseSystemFileDialog( false )
237 , m_bIsUseSystemFileDialogRO( false )
238 , m_bPluginsEnabled( false )
239 , m_bIsPluginsEnabledRO( false )
240 , m_nSymbolsSize( 0 )
241 , m_bIsSymbolsSizeRO( false )
242 , m_bIsSymbolsStyleRO( false )
243 , m_nToolboxStyle( 1 )
244 , m_bIsToolboxStyleRO( false )
245 , m_bUseSystemPrintDialog( false )
246 , m_bIsUseSystemPrintDialogRO( false )
247 , m_bShowLinkWarningDialog( true )
248 , m_bIsShowLinkWarningDialogRO( false )
249 , m_bAlwaysAllowSave( false )
250 , m_bExperimentalMode( false )
251 , m_bMacroRecorderMode( false )
252 , m_bIconThemeWasSetAutomatically( false )
254 // Use our static list of configuration keys to get his values.
255 Sequence
< OUString
> seqNames
= GetPropertyNames ( );
257 Sequence
< Any
> seqValues
= GetProperties ( seqNames
);
258 Sequence
< sal_Bool
> seqRO
= GetReadOnlyStates ( seqNames
);
260 // Safe impossible cases.
261 // We need values from ALL configuration keys.
262 // Follow assignment use order of values in relation to our list of key names!
263 DBG_ASSERT( !(seqNames
.getLength()!=seqValues
.getLength()), "SvtMiscOptions_Impl::SvtMiscOptions_Impl()\nI miss some values of configuration keys!\n" );
265 // Copy values from list in right order to our internal member.
266 sal_Int32 nPropertyCount
= seqValues
.getLength();
267 for( sal_Int32 nProperty
=0; nProperty
<nPropertyCount
; ++nProperty
)
269 if (!seqValues
[nProperty
].hasValue())
273 case PROPERTYHANDLE_PLUGINSENABLED
:
275 if( !(seqValues
[nProperty
] >>= m_bPluginsEnabled
) )
277 OSL_FAIL("Wrong type of \"Misc\\PluginsEnabled\"!" );
279 m_bIsPluginsEnabledRO
= seqRO
[nProperty
];
283 case PROPERTYHANDLE_SYMBOLSET
:
285 if( !(seqValues
[nProperty
] >>= m_nSymbolsSize
) )
287 OSL_FAIL("Wrong type of \"Misc\\SymbolSet\"!" );
289 m_bIsSymbolsSizeRO
= seqRO
[nProperty
];
293 case PROPERTYHANDLE_TOOLBOXSTYLE
:
295 if( !(seqValues
[nProperty
] >>= m_nToolboxStyle
) )
297 OSL_FAIL("Wrong type of \"Misc\\ToolboxStyle\"!" );
299 m_bIsToolboxStyleRO
= seqRO
[nProperty
];
303 case PROPERTYHANDLE_USESYSTEMFILEDIALOG
:
305 if( !(seqValues
[nProperty
] >>= m_bUseSystemFileDialog
) )
307 OSL_FAIL("Wrong type of \"Misc\\UseSystemFileDialog\"!" );
309 m_bIsUseSystemFileDialogRO
= seqRO
[nProperty
];
313 case PROPERTYHANDLE_USESYSTEMPRINTDIALOG
:
315 if( !(seqValues
[nProperty
] >>= m_bUseSystemPrintDialog
) )
317 OSL_FAIL("Wrong type of \"Misc\\UseSystemPrintDialog\"!" );
319 m_bIsUseSystemPrintDialogRO
= seqRO
[nProperty
];
323 case PROPERTYHANDLE_SHOWLINKWARNINGDIALOG
:
325 if( !(seqValues
[nProperty
] >>= m_bShowLinkWarningDialog
) )
327 OSL_FAIL("Wrong type of \"Misc\\ShowLinkWarningDialog\"!" );
329 m_bIsShowLinkWarningDialogRO
= seqRO
[nProperty
];
333 case PROPERTYHANDLE_SYMBOLSTYLE
:
336 if( seqValues
[nProperty
] >>= aIconTheme
) {
337 if (aIconTheme
== "auto") {
338 SetIconThemeAutomatically(DONT_SET_MODIFIED
);
341 SetIconTheme(aIconTheme
, DONT_SET_MODIFIED
);
346 OSL_FAIL("Wrong type of \"Misc\\SymbolStyle\"!" );
348 m_bIsSymbolsStyleRO
= seqRO
[nProperty
];
352 case PROPERTYHANDLE_DISABLEUICUSTOMIZATION
:
354 if( !(seqValues
[nProperty
] >>= m_bDisableUICustomization
) )
355 OSL_FAIL("Wrong type of \"Misc\\DisableUICustomization\"!" );
358 case PROPERTYHANDLE_ALWAYSALLOWSAVE
:
360 if( !(seqValues
[nProperty
] >>= m_bAlwaysAllowSave
) )
361 OSL_FAIL("Wrong type of \"Misc\\AlwaysAllowSave\"!" );
364 case PROPERTYHANDLE_EXPERIMENTALMODE
:
366 if( !(seqValues
[nProperty
] >>= m_bExperimentalMode
) )
367 OSL_FAIL("Wrong type of \"Misc\\ExperimentalMode\"!" );
370 case PROPERTYHANDLE_MACRORECORDERMODE
:
372 if( !(seqValues
[nProperty
] >>= m_bMacroRecorderMode
) )
373 OSL_FAIL("Wrong type of \"Misc\\MacroRecorderMode\"!" );
379 // Enable notification mechanism of our baseclass.
380 // We need it to get information about changes outside these class on our used configuration keys!
381 EnableNotification( seqNames
);
387 SvtMiscOptions_Impl::~SvtMiscOptions_Impl()
389 assert(!IsModified()); // should have been committed
392 static int lcl_MapPropertyName( const OUString
& rCompare
,
393 const uno::Sequence
< OUString
>& aInternalPropertyNames
)
395 for(int nProp
= 0; nProp
< aInternalPropertyNames
.getLength(); ++nProp
)
397 if( aInternalPropertyNames
[nProp
] == rCompare
)
403 void SvtMiscOptions_Impl::Load( const Sequence
< OUString
>& rPropertyNames
)
405 const uno::Sequence
< OUString
> aInternalPropertyNames( GetPropertyNames());
406 Sequence
< Any
> seqValues
= GetProperties( rPropertyNames
);
408 // Safe impossible cases.
409 // We need values from ALL configuration keys.
410 // Follow assignment use order of values in relation to our list of key names!
411 DBG_ASSERT( !(rPropertyNames
.getLength()!=seqValues
.getLength()), "SvtSecurityOptions_Impl::SvtSecurityOptions_Impl()\nI miss some values of configuration keys!\n" );
413 // Copy values from list in right order to our internal member.
414 sal_Int32 nPropertyCount
= seqValues
.getLength();
415 for( sal_Int32 nProperty
=0; nProperty
<nPropertyCount
; ++nProperty
)
417 if (!seqValues
[nProperty
].hasValue())
419 switch( lcl_MapPropertyName(rPropertyNames
[nProperty
], aInternalPropertyNames
) )
421 case PROPERTYHANDLE_PLUGINSENABLED
: {
422 if( !(seqValues
[nProperty
] >>= m_bPluginsEnabled
) )
424 OSL_FAIL("Wrong type of \"Misc\\PluginsEnabled\"!" );
428 case PROPERTYHANDLE_SYMBOLSET
: {
429 if( !(seqValues
[nProperty
] >>= m_nSymbolsSize
) )
431 OSL_FAIL("Wrong type of \"Misc\\SymbolSet\"!" );
435 case PROPERTYHANDLE_TOOLBOXSTYLE
: {
436 if( !(seqValues
[nProperty
] >>= m_nToolboxStyle
) )
438 OSL_FAIL("Wrong type of \"Misc\\ToolboxStyle\"!" );
442 case PROPERTYHANDLE_USESYSTEMFILEDIALOG
: {
443 if( !(seqValues
[nProperty
] >>= m_bUseSystemFileDialog
) )
445 OSL_FAIL("Wrong type of \"Misc\\UseSystemFileDialog\"!" );
449 case PROPERTYHANDLE_USESYSTEMPRINTDIALOG
: {
450 if( !(seqValues
[nProperty
] >>= m_bUseSystemPrintDialog
) )
452 OSL_FAIL("Wrong type of \"Misc\\UseSystemPrintDialog\"!" );
456 case PROPERTYHANDLE_SHOWLINKWARNINGDIALOG
: {
457 if( !(seqValues
[nProperty
] >>= m_bShowLinkWarningDialog
) )
459 OSL_FAIL("Wrong type of \"Misc\\ShowLinkWarningDialog\"!" );
463 case PROPERTYHANDLE_SYMBOLSTYLE
: {
465 if( seqValues
[nProperty
] >>= aIconTheme
) {
466 if (aIconTheme
== "auto") {
467 SetIconThemeAutomatically(DONT_SET_MODIFIED
);
470 SetIconTheme(aIconTheme
, DONT_SET_MODIFIED
);
474 OSL_FAIL("Wrong type of \"Misc\\SymbolStyle\"!" );
478 case PROPERTYHANDLE_DISABLEUICUSTOMIZATION
: {
479 if( !(seqValues
[nProperty
] >>= m_bDisableUICustomization
) )
480 OSL_FAIL("Wrong type of \"Misc\\DisableUICustomization\"!" );
483 case PROPERTYHANDLE_ALWAYSALLOWSAVE
:
485 if( !(seqValues
[nProperty
] >>= m_bAlwaysAllowSave
) )
486 OSL_FAIL("Wrong type of \"Misc\\AlwaysAllowSave\"!" );
493 void SvtMiscOptions_Impl::AddListenerLink( const Link
<>& rLink
)
495 aList
.push_back( rLink
);
498 void SvtMiscOptions_Impl::RemoveListenerLink( const Link
<>& rLink
)
500 for ( ::std::list
<Link
<>>::iterator iter
= aList
.begin(); iter
!= aList
.end(); ++iter
)
502 if ( *iter
== rLink
)
510 void SvtMiscOptions_Impl::CallListeners()
512 for ( ::std::list
<Link
<>>::const_iterator iter
= aList
.begin(); iter
!= aList
.end(); ++iter
)
516 void SvtMiscOptions_Impl::SetToolboxStyle( sal_Int16 nStyle
, bool _bSetModified
)
518 m_nToolboxStyle
= nStyle
? 1 : 0;
524 void SvtMiscOptions_Impl::SetSymbolsSize( sal_Int16 nSet
)
526 m_nSymbolsSize
= nSet
;
531 OUString
SvtMiscOptions_Impl::GetIconTheme()
533 return Application::GetSettings().GetStyleSettings().DetermineIconTheme();
537 SvtMiscOptions_Impl::SetIconTheme(const OUString
&rName
, SetModifiedFlag setModified
)
539 AllSettings aAllSettings
= Application::GetSettings();
540 StyleSettings aStyleSettings
= aAllSettings
.GetStyleSettings();
541 aStyleSettings
.SetIconTheme( rName
);
542 m_bIconThemeWasSetAutomatically
= false;
544 aAllSettings
.SetStyleSettings(aStyleSettings
);
545 Application::MergeSystemSettings( aAllSettings
);
546 Application::SetSettings(aAllSettings
);
548 if (setModified
== SET_MODIFIED
) {
557 void SvtMiscOptions_Impl::Notify( const Sequence
< OUString
>& rPropertyNames
)
559 Load( rPropertyNames
);
566 void SvtMiscOptions_Impl::ImplCommit()
568 // Get names of supported properties, create a list for values and copy current values to it.
569 Sequence
< OUString
> seqNames
= GetPropertyNames ();
570 sal_Int32 nCount
= seqNames
.getLength();
571 Sequence
< Any
> seqValues ( nCount
);
572 for( sal_Int32 nProperty
=0; nProperty
<nCount
; ++nProperty
)
576 case PROPERTYHANDLE_PLUGINSENABLED
:
578 if ( !m_bIsPluginsEnabledRO
)
579 seqValues
[nProperty
] <<= m_bPluginsEnabled
;
583 case PROPERTYHANDLE_SYMBOLSET
:
585 if ( !m_bIsSymbolsSizeRO
)
586 seqValues
[nProperty
] <<= m_nSymbolsSize
;
590 case PROPERTYHANDLE_TOOLBOXSTYLE
:
592 if ( !m_bIsToolboxStyleRO
)
593 seqValues
[nProperty
] <<= m_nToolboxStyle
;
597 case PROPERTYHANDLE_USESYSTEMFILEDIALOG
:
599 if ( !m_bIsUseSystemFileDialogRO
)
600 seqValues
[nProperty
] <<= m_bUseSystemFileDialog
;
604 case PROPERTYHANDLE_SYMBOLSTYLE
:
606 if ( !m_bIsSymbolsStyleRO
) {
608 if (m_bIconThemeWasSetAutomatically
) {
612 value
= GetIconTheme();
614 seqValues
[nProperty
] <<= value
;
619 case PROPERTYHANDLE_USESYSTEMPRINTDIALOG
:
621 if ( !m_bIsUseSystemPrintDialogRO
)
622 seqValues
[nProperty
] <<= m_bUseSystemPrintDialog
;
626 case PROPERTYHANDLE_SHOWLINKWARNINGDIALOG
:
628 if ( !m_bIsShowLinkWarningDialogRO
)
629 seqValues
[nProperty
] <<= m_bShowLinkWarningDialog
;
633 case PROPERTYHANDLE_DISABLEUICUSTOMIZATION
:
635 seqValues
[nProperty
] <<= m_bDisableUICustomization
;
638 case PROPERTYHANDLE_ALWAYSALLOWSAVE
:
640 seqValues
[nProperty
] <<= m_bAlwaysAllowSave
;
643 case PROPERTYHANDLE_EXPERIMENTALMODE
:
645 seqValues
[nProperty
] <<= m_bExperimentalMode
;
648 case PROPERTYHANDLE_MACRORECORDERMODE
:
650 seqValues
[nProperty
] <<= m_bMacroRecorderMode
;
655 // Set properties in configuration.
656 PutProperties( seqNames
, seqValues
);
662 Sequence
< OUString
> SvtMiscOptions_Impl::GetPropertyNames()
664 // Build list of configuration key names.
665 const OUString pProperties
[] =
667 OUString(PROPERTYNAME_PLUGINSENABLED
),
668 OUString(PROPERTYNAME_SYMBOLSET
),
669 OUString(PROPERTYNAME_TOOLBOXSTYLE
),
670 OUString(PROPERTYNAME_USESYSTEMFILEDIALOG
),
671 OUString(PROPERTYNAME_ICONTHEME
),
672 OUString(PROPERTYNAME_USESYSTEMPRINTDIALOG
),
673 OUString(PROPERTYNAME_SHOWLINKWARNINGDIALOG
),
674 OUString(PROPERTYNAME_DISABLEUICUSTOMIZATION
),
675 OUString(PROPERTYNAME_ALWAYSALLOWSAVE
),
676 OUString(PROPERTYNAME_EXPERIMENTALMODE
),
677 OUString(PROPERTYNAME_MACRORECORDERMODE
)
680 // Initialize return sequence with these list ...
681 const Sequence
< OUString
> seqPropertyNames( pProperties
, SAL_N_ELEMENTS( pProperties
) );
682 // ... and return it.
683 return seqPropertyNames
;
687 // initialize static member
688 // DON'T DO IT IN YOUR HEADER!
689 // see definition for further information
691 SvtMiscOptions_Impl
* SvtMiscOptions::m_pDataContainer
= NULL
;
692 sal_Int32
SvtMiscOptions::m_nRefCount
= 0 ;
697 SvtMiscOptions::SvtMiscOptions()
699 // SvtMiscOptions_Impl ctor indirectly calls code that requires locked
700 // SolarMutex; lock it first:
702 // Global access, must be guarded (multithreading!).
703 MutexGuard
aGuard( GetInitMutex() );
704 // Increase our refcount ...
706 // ... and initialize our data container only if it not already exist!
707 if( m_pDataContainer
== NULL
)
709 m_pDataContainer
= new SvtMiscOptions_Impl
;
710 svtools::ItemHolder2::holdConfigItem(E_MISCOPTIONS
);
717 SvtMiscOptions::~SvtMiscOptions()
719 // Global access, must be guarded (multithreading!)
720 MutexGuard
aGuard( GetInitMutex() );
721 // Decrease our refcount.
723 // If last instance was deleted ...
724 // we must destroy our static data container!
725 if( m_nRefCount
<= 0 )
727 delete m_pDataContainer
;
728 m_pDataContainer
= NULL
;
732 bool SvtMiscOptions::UseSystemFileDialog() const
734 return m_pDataContainer
->UseSystemFileDialog();
737 void SvtMiscOptions::SetUseSystemFileDialog( bool bEnable
)
739 m_pDataContainer
->SetUseSystemFileDialog( bEnable
);
742 bool SvtMiscOptions::IsUseSystemFileDialogReadOnly() const
744 return m_pDataContainer
->IsUseSystemFileDialogReadOnly();
747 bool SvtMiscOptions::IsPluginsEnabled() const
749 return m_pDataContainer
->IsPluginsEnabled();
752 sal_Int16
SvtMiscOptions::GetSymbolsSize() const
754 return m_pDataContainer
->GetSymbolsSize();
757 void SvtMiscOptions::SetSymbolsSize( sal_Int16 nSet
)
759 m_pDataContainer
->SetSymbolsSize( nSet
);
762 sal_Int16
SvtMiscOptions::GetCurrentSymbolsSize() const
764 sal_Int16 eOptSymbolsSize
= m_pDataContainer
->GetSymbolsSize();
766 if ( eOptSymbolsSize
== SFX_SYMBOLS_SIZE_AUTO
)
768 // Use system settings, we have to retrieve the toolbar icon size from the
770 ToolbarIconSize nStyleIconSize
= Application::GetSettings().GetStyleSettings().GetToolbarIconSize();
771 if ( nStyleIconSize
== ToolbarIconSize::Large
)
772 eOptSymbolsSize
= SFX_SYMBOLS_SIZE_LARGE
;
774 eOptSymbolsSize
= SFX_SYMBOLS_SIZE_SMALL
;
777 return eOptSymbolsSize
;
780 bool SvtMiscOptions::AreCurrentSymbolsLarge() const
782 return ( GetCurrentSymbolsSize() == SFX_SYMBOLS_SIZE_LARGE
);
785 OUString
SvtMiscOptions::GetIconTheme() const
787 return SvtMiscOptions_Impl::GetIconTheme();
790 void SvtMiscOptions::SetIconTheme(const OUString
& iconTheme
)
792 m_pDataContainer
->SetIconTheme(iconTheme
);
795 bool SvtMiscOptions::DisableUICustomization() const
797 return m_pDataContainer
->DisableUICustomization();
800 sal_Int16
SvtMiscOptions::GetToolboxStyle() const
802 return m_pDataContainer
->GetToolboxStyle();
805 void SvtMiscOptions::SetToolboxStyle( sal_Int16 nStyle
)
807 m_pDataContainer
->SetToolboxStyle( nStyle
, true );
810 bool SvtMiscOptions::UseSystemPrintDialog() const
812 return m_pDataContainer
->UseSystemPrintDialog();
815 void SvtMiscOptions::SetUseSystemPrintDialog( bool bEnable
)
817 m_pDataContainer
->SetUseSystemPrintDialog( bEnable
);
820 bool SvtMiscOptions::ShowLinkWarningDialog() const
822 return m_pDataContainer
->ShowLinkWarningDialog();
825 void SvtMiscOptions::SetShowLinkWarningDialog( bool bSet
)
827 m_pDataContainer
->SetShowLinkWarningDialog( bSet
);
830 bool SvtMiscOptions::IsShowLinkWarningDialogReadOnly() const
832 return m_pDataContainer
->IsShowLinkWarningDialogReadOnly();
835 void SvtMiscOptions::SetSaveAlwaysAllowed( bool bSet
)
837 m_pDataContainer
->SetSaveAlwaysAllowed( bSet
);
840 bool SvtMiscOptions::IsSaveAlwaysAllowed() const
842 return m_pDataContainer
->IsSaveAlwaysAllowed();
845 void SvtMiscOptions::SetExperimentalMode( bool bSet
)
847 m_pDataContainer
->SetExperimentalMode( bSet
);
850 bool SvtMiscOptions::IsExperimentalMode() const
852 return m_pDataContainer
->IsExperimentalMode();
855 void SvtMiscOptions::SetMacroRecorderMode( bool bSet
)
857 m_pDataContainer
->SetMacroRecorderMode( bSet
);
860 bool SvtMiscOptions::IsMacroRecorderMode() const
862 return m_pDataContainer
->IsMacroRecorderMode();
867 class theSvtMiscOptionsMutex
:
868 public rtl::Static
< osl::Mutex
, theSvtMiscOptionsMutex
> {};
871 Mutex
& SvtMiscOptions::GetInitMutex()
873 return theSvtMiscOptionsMutex::get();
876 void SvtMiscOptions::AddListenerLink( const Link
<>& rLink
)
878 m_pDataContainer
->AddListenerLink( rLink
);
881 void SvtMiscOptions::RemoveListenerLink( const Link
<>& rLink
)
883 m_pDataContainer
->RemoveListenerLink( rLink
);
887 SvtMiscOptions_Impl::SetIconThemeAutomatically(enum SetModifiedFlag setModified
)
889 OUString theme
= Application::GetSettings().GetStyleSettings().GetAutomaticallyChosenIconTheme();
890 SetIconTheme(theme
, setModified
);
891 m_bIconThemeWasSetAutomatically
= true;
895 SvtMiscOptions::SetIconThemeAutomatically()
897 m_pDataContainer
->SetIconThemeAutomatically();
901 SvtMiscOptions::IconThemeWasSetAutomatically()
903 return m_pDataContainer
->IconThemeWasSetAutomatically();
906 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */