fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / svtools / source / config / miscopt.cxx
blob4ac2f9f14ff9e143eff3c24f3fb0069cbb3f7227
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 <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/logfile.hxx>
29 #include <rtl/instance.hxx>
30 #include "itemholder2.hxx"
32 #include <svtools/imgdef.hxx>
33 #include <vcl/svapp.hxx>
35 #include <list>
37 using namespace ::utl ;
38 using namespace ::rtl ;
39 using namespace ::osl ;
40 using namespace ::com::sun::star::uno ;
41 using namespace ::com::sun::star;
43 #define ROOTNODE_MISC "Office.Common/Misc"
45 // PROPERTYHANDLE defines must be sequential from zero for Commit/Load
46 #define PROPERTYNAME_PLUGINSENABLED "PluginsEnabled"
47 #define PROPERTYHANDLE_PLUGINSENABLED 0
48 #define PROPERTYNAME_SYMBOLSET "SymbolSet"
49 #define PROPERTYHANDLE_SYMBOLSET 1
50 #define PROPERTYNAME_TOOLBOXSTYLE "ToolboxStyle"
51 #define PROPERTYHANDLE_TOOLBOXSTYLE 2
52 #define PROPERTYNAME_USESYSTEMFILEDIALOG "UseSystemFileDialog"
53 #define PROPERTYHANDLE_USESYSTEMFILEDIALOG 3
54 #define PROPERTYNAME_SYMBOLSTYLE "SymbolStyle"
55 #define PROPERTYHANDLE_SYMBOLSTYLE 4
56 #define PROPERTYNAME_USESYSTEMPRINTDIALOG "UseSystemPrintDialog"
57 #define PROPERTYHANDLE_USESYSTEMPRINTDIALOG 5
58 #define PROPERTYNAME_SHOWLINKWARNINGDIALOG "ShowLinkWarningDialog"
59 #define PROPERTYHANDLE_SHOWLINKWARNINGDIALOG 6
60 #define PROPERTYNAME_DISABLEUICUSTOMIZATION "DisableUICustomization"
61 #define PROPERTYHANDLE_DISABLEUICUSTOMIZATION 7
62 #define PROPERTYNAME_ALWAYSALLOWSAVE "AlwaysAllowSave"
63 #define PROPERTYHANDLE_ALWAYSALLOWSAVE 8
64 #define PROPERTYNAME_EXPERIMENTALMODE "ExperimentalMode"
65 #define PROPERTYHANDLE_EXPERIMENTALMODE 9
66 #define PROPERTYNAME_MACRORECORDERMODE "MacroRecorderMode"
67 #define PROPERTYHANDLE_MACRORECORDERMODE 10
68 #define PROPERTYNAME_EXPERIMENTALSIDEBAR "ExperimentalSidebar"
69 #define PROPERTYHANDLE_EXPERIMENTALSIDEBAR 11
71 #define VCL_TOOLBOX_STYLE_FLAT ((sal_uInt16)0x0004) // from <vcl/toolbox.hxx>
73 class SvtMiscOptions_Impl : public ConfigItem
75 private:
76 ::std::list<Link> aList;
77 sal_Bool m_bUseSystemFileDialog;
78 sal_Bool m_bIsUseSystemFileDialogRO;
79 sal_Bool m_bPluginsEnabled;
80 sal_Bool m_bIsPluginsEnabledRO;
81 sal_Int16 m_nSymbolsSize;
82 sal_Bool m_bIsSymbolsSizeRO;
83 sal_Bool m_bIsSymbolsStyleRO;
84 sal_Int16 m_nToolboxStyle;
85 sal_Bool m_bIsToolboxStyleRO;
86 sal_Bool m_bUseSystemPrintDialog;
87 sal_Bool m_bIsUseSystemPrintDialogRO;
88 sal_Bool m_bShowLinkWarningDialog;
89 sal_Bool m_bIsShowLinkWarningDialogRO;
90 sal_Bool m_bDisableUICustomization;
91 sal_Bool m_bAlwaysAllowSave;
92 sal_Bool m_bExperimentalMode;
93 sal_Bool m_bExperimentalSidebar;
94 sal_Bool m_bMacroRecorderMode;
96 public:
98 SvtMiscOptions_Impl();
99 ~SvtMiscOptions_Impl();
101 /*-****************************************************************************************************//**
102 @short called for notify of configmanager
103 @descr These method is called from the ConfigManager before application ends or from the
104 PropertyChangeListener if the sub tree broadcasts changes. You must update your
105 internal values.
107 @seealso baseclass ConfigItem
109 @param "seqPropertyNames" is the list of properties which should be updated.
110 @return -
112 @onerror -
113 *//*-*****************************************************************************************************/
115 virtual void Notify( const Sequence< OUString >& seqPropertyNames );
117 /** loads required data from the configuration. It's called in the constructor to
118 read all entries and form ::Notify to re-read changed settings
121 void Load( const Sequence< OUString >& rPropertyNames );
123 /*-****************************************************************************************************//**
124 @short write changes to configuration
125 @descr These method writes the changed values into the sub tree
126 and should always called in our destructor to guarantee consistency of config data.
128 @seealso baseclass ConfigItem
130 @param -
131 @return -
133 @onerror -
134 *//*-*****************************************************************************************************/
136 virtual void Commit();
138 //---------------------------------------------------------------------------------------------------------
139 // public interface
140 //---------------------------------------------------------------------------------------------------------
142 inline sal_Bool UseSystemFileDialog() const
143 { return m_bUseSystemFileDialog; }
145 inline void SetUseSystemFileDialog( sal_Bool bSet )
146 { m_bUseSystemFileDialog = bSet; SetModified(); }
148 inline sal_Bool IsUseSystemFileDialogReadOnly() const
149 { return m_bIsUseSystemFileDialogRO; }
151 inline sal_Bool DisableUICustomization() const
152 { return m_bDisableUICustomization; }
154 inline void SetSaveAlwaysAllowed( sal_Bool bSet )
155 { m_bAlwaysAllowSave = bSet; SetModified(); }
157 inline sal_Bool IsSaveAlwaysAllowed() const
158 { return m_bAlwaysAllowSave; }
160 inline void SetExperimentalMode( sal_Bool bSet )
161 { m_bExperimentalMode = bSet; SetModified(); }
163 inline sal_Bool IsExperimentalMode() const
164 { return m_bExperimentalMode; }
166 inline void SetExperimentalSidebar( sal_Bool bSet )
167 { m_bExperimentalSidebar = bSet; SetModified(); }
169 inline sal_Bool IsExperimentalSidebar() const
170 { return m_bExperimentalSidebar; }
172 inline void SetMacroRecorderMode( sal_Bool bSet )
173 { m_bMacroRecorderMode = bSet; SetModified(); }
175 inline sal_Bool IsMacroRecorderMode() const
176 { return m_bMacroRecorderMode; }
178 inline sal_Bool IsPluginsEnabled() const
179 { return m_bPluginsEnabled; }
181 inline sal_Bool IsPluginsEnabledReadOnly() const
182 { return m_bIsPluginsEnabledRO; }
184 inline sal_Int16 GetSymbolsSize()
185 { return m_nSymbolsSize; }
187 void SetSymbolsSize( sal_Int16 nSet );
189 inline sal_Bool IsGetSymbolsSizeReadOnly()
190 { return m_bIsSymbolsSizeRO; }
192 sal_Int16 GetSymbolsStyle() const;
193 OUString GetSymbolsStyleName() const;
194 sal_Int16 GetCurrentSymbolsStyle() const;
196 inline void SetSymbolsStyle( sal_Int16 nSet )
197 { ImplSetSymbolsStyle( true, nSet, OUString() ); }
199 inline void SetSymbolsStyleName( OUString &rName )
200 { ImplSetSymbolsStyle( false, 0, rName ); }
202 inline sal_Bool IsGetSymbolsStyleReadOnly()
203 { return m_bIsSymbolsStyleRO; }
205 // translate to VCL settings ( "0" = 3D, "1" = FLAT )
206 inline sal_Int16 GetToolboxStyle()
207 { return m_nToolboxStyle ? VCL_TOOLBOX_STYLE_FLAT : 0; }
209 // translate from VCL settings
210 void SetToolboxStyle( sal_Int16 nStyle, bool _bSetModified );
212 inline sal_Bool IsGetToolboxStyleReadOnly()
213 { return m_bIsToolboxStyleRO; }
215 inline sal_Bool UseSystemPrintDialog() const
216 { return m_bUseSystemPrintDialog; }
218 inline void SetUseSystemPrintDialog( sal_Bool bSet )
219 { m_bUseSystemPrintDialog = bSet; SetModified(); }
221 inline sal_Bool IsUseSystemPrintDialogReadOnly() const
222 { return m_bIsUseSystemPrintDialogRO; }
224 inline sal_Bool ShowLinkWarningDialog() const
225 { return m_bShowLinkWarningDialog; }
227 void SetShowLinkWarningDialog( sal_Bool bSet )
228 { m_bShowLinkWarningDialog = bSet; SetModified(); }
230 sal_Bool IsShowLinkWarningDialogReadOnly() const
231 { return m_bIsShowLinkWarningDialogRO; }
233 void AddListenerLink( const Link& rLink );
234 void RemoveListenerLink( const Link& rLink );
235 void CallListeners();
237 //-------------------------------------------------------------------------------------------------------------
238 // private methods
239 //-------------------------------------------------------------------------------------------------------------
241 private:
243 /*-****************************************************************************************************//**
244 @short return list of key names of our configuration management which represent oue module tree
245 @descr These methods return a static const list of key names. We need it to get needed values from our
246 configuration management.
248 @seealso -
250 @param -
251 @return A list of needed configuration keys is returned.
253 @onerror -
254 *//*-*****************************************************************************************************/
256 static Sequence< OUString > GetPropertyNames();
258 protected:
259 void ImplSetSymbolsStyle( bool bValue, sal_Int16 nSet, const OUString &rName );
262 //*****************************************************************************************************************
263 // constructor
264 //*****************************************************************************************************************
265 SvtMiscOptions_Impl::SvtMiscOptions_Impl()
266 // Init baseclasses first
267 : ConfigItem( ROOTNODE_MISC )
269 , m_bUseSystemFileDialog( sal_False )
270 , m_bIsUseSystemFileDialogRO( sal_False )
271 , m_bPluginsEnabled( sal_False )
272 , m_bIsPluginsEnabledRO( sal_False )
273 , m_nSymbolsSize( 0 )
274 , m_bIsSymbolsSizeRO( sal_False )
275 , m_bIsSymbolsStyleRO( sal_False )
276 , m_nToolboxStyle( 1 )
277 , m_bIsToolboxStyleRO( sal_False )
278 , m_bUseSystemPrintDialog( sal_False )
279 , m_bIsUseSystemPrintDialogRO( sal_False )
280 , m_bShowLinkWarningDialog( sal_True )
281 , m_bIsShowLinkWarningDialogRO( sal_False )
282 , m_bAlwaysAllowSave( sal_False )
283 , m_bExperimentalMode( sal_False )
284 , m_bExperimentalSidebar( sal_False )
285 , m_bMacroRecorderMode( sal_False )
288 // Use our static list of configuration keys to get his values.
289 Sequence< OUString > seqNames = GetPropertyNames ( );
290 Load( seqNames );
291 Sequence< Any > seqValues = GetProperties ( seqNames );
292 Sequence< sal_Bool > seqRO = GetReadOnlyStates ( seqNames );
294 // Safe impossible cases.
295 // We need values from ALL configuration keys.
296 // Follow assignment use order of values in relation to our list of key names!
297 DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtMiscOptions_Impl::SvtMiscOptions_Impl()\nI miss some values of configuration keys!\n" );
299 // Copy values from list in right order to our internal member.
300 sal_Int32 nPropertyCount = seqValues.getLength();
301 for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty )
303 if (seqValues[nProperty].hasValue()==sal_False)
304 continue;
305 switch( nProperty )
307 case PROPERTYHANDLE_PLUGINSENABLED :
309 if( !(seqValues[nProperty] >>= m_bPluginsEnabled) )
311 OSL_FAIL("Wrong type of \"Misc\\PluginsEnabled\"!" );
313 m_bIsPluginsEnabledRO = seqRO[nProperty];
314 break;
317 case PROPERTYHANDLE_SYMBOLSET :
319 if( !(seqValues[nProperty] >>= m_nSymbolsSize) )
321 OSL_FAIL("Wrong type of \"Misc\\SymbolSet\"!" );
323 m_bIsSymbolsSizeRO = seqRO[nProperty];
324 break;
327 case PROPERTYHANDLE_TOOLBOXSTYLE :
329 if( !(seqValues[nProperty] >>= m_nToolboxStyle) )
331 OSL_FAIL("Wrong type of \"Misc\\ToolboxStyle\"!" );
333 m_bIsToolboxStyleRO = seqRO[nProperty];
334 break;
337 case PROPERTYHANDLE_USESYSTEMFILEDIALOG :
339 if( !(seqValues[nProperty] >>= m_bUseSystemFileDialog) )
341 OSL_FAIL("Wrong type of \"Misc\\UseSystemFileDialog\"!" );
343 m_bIsUseSystemFileDialogRO = seqRO[nProperty];
344 break;
347 case PROPERTYHANDLE_USESYSTEMPRINTDIALOG :
349 if( !(seqValues[nProperty] >>= m_bUseSystemPrintDialog) )
351 OSL_FAIL("Wrong type of \"Misc\\UseSystemPrintDialog\"!" );
353 m_bIsUseSystemPrintDialogRO = seqRO[nProperty];
354 break;
357 case PROPERTYHANDLE_SHOWLINKWARNINGDIALOG :
359 if( !(seqValues[nProperty] >>= m_bShowLinkWarningDialog) )
361 OSL_FAIL("Wrong type of \"Misc\\ShowLinkWarningDialog\"!" );
363 m_bIsShowLinkWarningDialogRO = seqRO[nProperty];
364 break;
367 case PROPERTYHANDLE_SYMBOLSTYLE :
369 OUString aSymbolsStyle;
370 if( seqValues[nProperty] >>= aSymbolsStyle )
371 SetSymbolsStyleName( aSymbolsStyle );
372 else
374 OSL_FAIL("Wrong type of \"Misc\\SymbolStyle\"!" );
376 m_bIsSymbolsStyleRO = seqRO[nProperty];
377 break;
380 case PROPERTYHANDLE_DISABLEUICUSTOMIZATION :
382 if( !(seqValues[nProperty] >>= m_bDisableUICustomization) )
383 OSL_FAIL("Wrong type of \"Misc\\DisableUICustomization\"!" );
384 break;
386 case PROPERTYHANDLE_ALWAYSALLOWSAVE :
388 if( !(seqValues[nProperty] >>= m_bAlwaysAllowSave) )
389 OSL_FAIL("Wrong type of \"Misc\\AlwaysAllowSave\"!" );
390 break;
392 case PROPERTYHANDLE_EXPERIMENTALMODE :
394 if( !(seqValues[nProperty] >>= m_bExperimentalMode) )
395 OSL_FAIL("Wrong type of \"Misc\\ExperimentalMode\"!" );
396 break;
398 case PROPERTYHANDLE_MACRORECORDERMODE :
400 if( !(seqValues[nProperty] >>= m_bMacroRecorderMode) )
401 OSL_FAIL("Wrong type of \"Misc\\MacroRecorderMode\"!" );
402 break;
404 case PROPERTYHANDLE_EXPERIMENTALSIDEBAR :
406 if( !(seqValues[nProperty] >>= m_bExperimentalSidebar) )
407 OSL_FAIL("Wrong type of \"Misc\\ExperimentalSidebar\"!" );
408 break;
413 // Enable notification mechanism of our baseclass.
414 // We need it to get information about changes outside these class on our used configuration keys!
415 EnableNotification( seqNames );
418 //*****************************************************************************************************************
419 // destructor
420 //*****************************************************************************************************************
421 SvtMiscOptions_Impl::~SvtMiscOptions_Impl()
423 // We must save our current values .. if user forgets it!
424 if( IsModified() == sal_True )
426 Commit();
430 static int lcl_MapPropertyName( const OUString rCompare,
431 const uno::Sequence< OUString>& aInternalPropertyNames)
433 for(int nProp = 0; nProp < aInternalPropertyNames.getLength(); ++nProp)
435 if( aInternalPropertyNames[nProp] == rCompare )
436 return nProp;
438 return -1;
441 void SvtMiscOptions_Impl::Load( const Sequence< OUString >& rPropertyNames )
443 const uno::Sequence< OUString> aInternalPropertyNames( GetPropertyNames());
444 Sequence< Any > seqValues = GetProperties( rPropertyNames );
446 // Safe impossible cases.
447 // We need values from ALL configuration keys.
448 // Follow assignment use order of values in relation to our list of key names!
449 DBG_ASSERT( !(rPropertyNames.getLength()!=seqValues.getLength()), "SvtSecurityOptions_Impl::SvtSecurityOptions_Impl()\nI miss some values of configuration keys!\n" );
451 // Copy values from list in right order to our internal member.
452 sal_Int32 nPropertyCount = seqValues.getLength();
453 for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty )
455 if (seqValues[nProperty].hasValue()==sal_False)
456 continue;
457 switch( lcl_MapPropertyName(rPropertyNames[nProperty], aInternalPropertyNames) )
459 case PROPERTYHANDLE_PLUGINSENABLED : {
460 if( !(seqValues[nProperty] >>= m_bPluginsEnabled) )
462 OSL_FAIL("Wrong type of \"Misc\\PluginsEnabled\"!" );
465 break;
466 case PROPERTYHANDLE_SYMBOLSET : {
467 if( !(seqValues[nProperty] >>= m_nSymbolsSize) )
469 OSL_FAIL("Wrong type of \"Misc\\SymbolSet\"!" );
472 break;
473 case PROPERTYHANDLE_TOOLBOXSTYLE : {
474 if( !(seqValues[nProperty] >>= m_nToolboxStyle) )
476 OSL_FAIL("Wrong type of \"Misc\\ToolboxStyle\"!" );
479 break;
480 case PROPERTYHANDLE_USESYSTEMFILEDIALOG : {
481 if( !(seqValues[nProperty] >>= m_bUseSystemFileDialog) )
483 OSL_FAIL("Wrong type of \"Misc\\UseSystemFileDialog\"!" );
486 break;
487 case PROPERTYHANDLE_USESYSTEMPRINTDIALOG : {
488 if( !(seqValues[nProperty] >>= m_bUseSystemPrintDialog) )
490 OSL_FAIL("Wrong type of \"Misc\\UseSystemPrintDialog\"!" );
493 break;
494 case PROPERTYHANDLE_SHOWLINKWARNINGDIALOG : {
495 if( !(seqValues[nProperty] >>= m_bShowLinkWarningDialog) )
497 OSL_FAIL("Wrong type of \"Misc\\ShowLinkWarningDialog\"!" );
500 break;
501 case PROPERTYHANDLE_SYMBOLSTYLE : {
502 OUString aSymbolsStyle;
503 if( seqValues[nProperty] >>= aSymbolsStyle )
504 SetSymbolsStyleName( aSymbolsStyle );
505 else
507 OSL_FAIL("Wrong type of \"Misc\\SymbolStyle\"!" );
510 break;
511 case PROPERTYHANDLE_DISABLEUICUSTOMIZATION : {
512 if( !(seqValues[nProperty] >>= m_bDisableUICustomization) )
513 OSL_FAIL("Wrong type of \"Misc\\DisableUICustomization\"!" );
515 break;
516 case PROPERTYHANDLE_ALWAYSALLOWSAVE:
518 if( !(seqValues[nProperty] >>= m_bAlwaysAllowSave) )
519 OSL_FAIL("Wrong type of \"Misc\\AlwaysAllowSave\"!" );
521 break;
526 void SvtMiscOptions_Impl::AddListenerLink( const Link& rLink )
528 aList.push_back( rLink );
531 void SvtMiscOptions_Impl::RemoveListenerLink( const Link& rLink )
533 for ( ::std::list<Link>::iterator iter = aList.begin(); iter != aList.end(); ++iter )
535 if ( *iter == rLink )
537 aList.erase(iter);
538 break;
543 void SvtMiscOptions_Impl::CallListeners()
545 for ( ::std::list<Link>::const_iterator iter = aList.begin(); iter != aList.end(); ++iter )
546 iter->Call( this );
549 void SvtMiscOptions_Impl::SetToolboxStyle( sal_Int16 nStyle, bool _bSetModified )
551 m_nToolboxStyle = nStyle ? 1 : 0;
552 if ( _bSetModified )
553 SetModified();
554 CallListeners();
557 void SvtMiscOptions_Impl::SetSymbolsSize( sal_Int16 nSet )
559 m_nSymbolsSize = nSet;
560 SetModified();
561 CallListeners();
564 sal_Int16 SvtMiscOptions_Impl::GetSymbolsStyle() const
566 return (sal_Int16)Application::GetSettings().GetStyleSettings().GetSymbolsStyle();
569 OUString SvtMiscOptions_Impl::GetSymbolsStyleName() const
571 return Application::GetSettings().GetStyleSettings().GetSymbolsStyleName();
574 sal_Int16 SvtMiscOptions_Impl::GetCurrentSymbolsStyle() const
576 return (sal_Int16)Application::GetSettings().GetStyleSettings().GetCurrentSymbolsStyle();
579 void SvtMiscOptions_Impl::ImplSetSymbolsStyle( bool bValue, sal_Int16 nSet, const OUString &rName )
581 if ( ( bValue && ( nSet != GetSymbolsStyle() ) ) ||
582 ( !bValue && ( rName != GetSymbolsStyleName() ) ) )
584 AllSettings aAllSettings = Application::GetSettings();
585 StyleSettings aStyleSettings = aAllSettings.GetStyleSettings();
587 if ( bValue )
588 aStyleSettings.SetSymbolsStyle( nSet );
589 else
590 aStyleSettings.SetSymbolsStyleName( rName );
592 aAllSettings.SetStyleSettings(aStyleSettings);
593 Application::MergeSystemSettings( aAllSettings );
594 Application::SetSettings(aAllSettings);
596 SetModified();
597 CallListeners();
601 //*****************************************************************************************************************
602 // public method
603 //*****************************************************************************************************************
604 void SvtMiscOptions_Impl::Notify( const Sequence< OUString >& rPropertyNames )
606 Load( rPropertyNames );
607 CallListeners();
610 //*****************************************************************************************************************
611 // public method
612 //*****************************************************************************************************************
613 void SvtMiscOptions_Impl::Commit()
615 // Get names of supported properties, create a list for values and copy current values to it.
616 Sequence< OUString > seqNames = GetPropertyNames ();
617 sal_Int32 nCount = seqNames.getLength();
618 Sequence< Any > seqValues ( nCount );
619 for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty )
621 switch( nProperty )
623 case PROPERTYHANDLE_PLUGINSENABLED :
625 if ( !m_bIsPluginsEnabledRO )
626 seqValues[nProperty] <<= m_bPluginsEnabled;
627 break;
630 case PROPERTYHANDLE_SYMBOLSET :
632 if ( !m_bIsSymbolsSizeRO )
633 seqValues[nProperty] <<= m_nSymbolsSize;
634 break;
637 case PROPERTYHANDLE_TOOLBOXSTYLE :
639 if ( !m_bIsToolboxStyleRO )
640 seqValues[nProperty] <<= m_nToolboxStyle;
641 break;
644 case PROPERTYHANDLE_USESYSTEMFILEDIALOG :
646 if ( !m_bIsUseSystemFileDialogRO )
647 seqValues[nProperty] <<= m_bUseSystemFileDialog;
648 break;
651 case PROPERTYHANDLE_SYMBOLSTYLE :
653 if ( !m_bIsSymbolsStyleRO )
654 seqValues[nProperty] <<= GetSymbolsStyleName();
655 break;
658 case PROPERTYHANDLE_USESYSTEMPRINTDIALOG :
660 if ( !m_bIsUseSystemPrintDialogRO )
661 seqValues[nProperty] <<= m_bUseSystemPrintDialog;
662 break;
665 case PROPERTYHANDLE_SHOWLINKWARNINGDIALOG :
667 if ( !m_bIsShowLinkWarningDialogRO )
668 seqValues[nProperty] <<= m_bShowLinkWarningDialog;
669 break;
672 case PROPERTYHANDLE_DISABLEUICUSTOMIZATION :
674 seqValues[nProperty] <<= m_bDisableUICustomization;
675 break;
677 case PROPERTYHANDLE_ALWAYSALLOWSAVE :
679 seqValues[nProperty] <<= m_bAlwaysAllowSave;
680 break;
682 case PROPERTYHANDLE_EXPERIMENTALMODE :
684 seqValues[nProperty] <<= m_bExperimentalMode;
685 break;
687 case PROPERTYHANDLE_MACRORECORDERMODE :
689 seqValues[nProperty] <<= m_bMacroRecorderMode;
690 break;
692 case PROPERTYHANDLE_EXPERIMENTALSIDEBAR :
694 seqValues[nProperty] <<= m_bExperimentalSidebar;
695 break;
699 // Set properties in configuration.
700 PutProperties( seqNames, seqValues );
703 //*****************************************************************************************************************
704 // private method
705 //*****************************************************************************************************************
706 Sequence< OUString > SvtMiscOptions_Impl::GetPropertyNames()
708 // Build list of configuration key names.
709 const OUString pProperties[] =
711 OUString(PROPERTYNAME_PLUGINSENABLED),
712 OUString(PROPERTYNAME_SYMBOLSET),
713 OUString(PROPERTYNAME_TOOLBOXSTYLE),
714 OUString(PROPERTYNAME_USESYSTEMFILEDIALOG),
715 OUString(PROPERTYNAME_SYMBOLSTYLE),
716 OUString(PROPERTYNAME_USESYSTEMPRINTDIALOG),
717 OUString(PROPERTYNAME_SHOWLINKWARNINGDIALOG),
718 OUString(PROPERTYNAME_DISABLEUICUSTOMIZATION),
719 OUString(PROPERTYNAME_ALWAYSALLOWSAVE),
720 OUString(PROPERTYNAME_EXPERIMENTALMODE),
721 OUString(PROPERTYNAME_MACRORECORDERMODE),
722 OUString(PROPERTYNAME_EXPERIMENTALSIDEBAR)
725 // Initialize return sequence with these list ...
726 const Sequence< OUString > seqPropertyNames( pProperties, SAL_N_ELEMENTS( pProperties ) );
727 // ... and return it.
728 return seqPropertyNames;
731 //*****************************************************************************************************************
732 // initialize static member
733 // DON'T DO IT IN YOUR HEADER!
734 // see definition for further information
735 //*****************************************************************************************************************
736 SvtMiscOptions_Impl* SvtMiscOptions::m_pDataContainer = NULL ;
737 sal_Int32 SvtMiscOptions::m_nRefCount = 0 ;
739 //*****************************************************************************************************************
740 // constructor
741 //*****************************************************************************************************************
742 SvtMiscOptions::SvtMiscOptions()
744 // Global access, must be guarded (multithreading!).
745 MutexGuard aGuard( GetInitMutex() );
746 // Increase our refcount ...
747 ++m_nRefCount;
748 // ... and initialize our data container only if it not already exist!
749 if( m_pDataContainer == NULL )
751 RTL_LOGFILE_CONTEXT(aLog, "svtools ( ??? ) ::SvtMiscOptions_Impl::ctor()");
752 m_pDataContainer = new SvtMiscOptions_Impl;
753 svtools::ItemHolder2::holdConfigItem(E_MISCOPTIONS);
757 //*****************************************************************************************************************
758 // destructor
759 //*****************************************************************************************************************
760 SvtMiscOptions::~SvtMiscOptions()
762 // Global access, must be guarded (multithreading!)
763 MutexGuard aGuard( GetInitMutex() );
764 // Decrease our refcount.
765 --m_nRefCount;
766 // If last instance was deleted ...
767 // we must destroy our static data container!
768 if( m_nRefCount <= 0 )
770 delete m_pDataContainer;
771 m_pDataContainer = NULL;
775 sal_Bool SvtMiscOptions::UseSystemFileDialog() const
777 return m_pDataContainer->UseSystemFileDialog();
780 void SvtMiscOptions::SetUseSystemFileDialog( sal_Bool bEnable )
782 m_pDataContainer->SetUseSystemFileDialog( bEnable );
785 sal_Bool SvtMiscOptions::IsUseSystemFileDialogReadOnly() const
787 return m_pDataContainer->IsUseSystemFileDialogReadOnly();
790 sal_Bool SvtMiscOptions::IsPluginsEnabled() const
792 return m_pDataContainer->IsPluginsEnabled();
795 sal_Int16 SvtMiscOptions::GetSymbolsSize() const
797 return m_pDataContainer->GetSymbolsSize();
800 void SvtMiscOptions::SetSymbolsSize( sal_Int16 nSet )
802 m_pDataContainer->SetSymbolsSize( nSet );
805 sal_Int16 SvtMiscOptions::GetCurrentSymbolsSize() const
807 sal_Int16 eOptSymbolsSize = m_pDataContainer->GetSymbolsSize();
809 if ( eOptSymbolsSize == SFX_SYMBOLS_SIZE_AUTO )
811 // Use system settings, we have to retrieve the toolbar icon size from the
812 // Application class
813 sal_uLong nStyleIconSize = Application::GetSettings().GetStyleSettings().GetToolbarIconSize();
814 if ( nStyleIconSize == STYLE_TOOLBAR_ICONSIZE_LARGE )
815 eOptSymbolsSize = SFX_SYMBOLS_SIZE_LARGE;
816 else
817 eOptSymbolsSize = SFX_SYMBOLS_SIZE_SMALL;
820 return eOptSymbolsSize;
823 bool SvtMiscOptions::AreCurrentSymbolsLarge() const
825 return ( GetCurrentSymbolsSize() == SFX_SYMBOLS_SIZE_LARGE );
828 sal_Int16 SvtMiscOptions::GetSymbolsStyle() const
830 return m_pDataContainer->GetSymbolsStyle();
833 sal_Int16 SvtMiscOptions::GetCurrentSymbolsStyle() const
835 return m_pDataContainer->GetCurrentSymbolsStyle();
838 void SvtMiscOptions::SetSymbolsStyle( sal_Int16 nSet )
840 m_pDataContainer->SetSymbolsStyle( nSet );
843 sal_Bool SvtMiscOptions::DisableUICustomization() const
845 return m_pDataContainer->DisableUICustomization();
848 sal_Int16 SvtMiscOptions::GetToolboxStyle() const
850 return m_pDataContainer->GetToolboxStyle();
853 void SvtMiscOptions::SetToolboxStyle( sal_Int16 nStyle )
855 m_pDataContainer->SetToolboxStyle( nStyle, true );
858 sal_Bool SvtMiscOptions::UseSystemPrintDialog() const
860 return m_pDataContainer->UseSystemPrintDialog();
863 void SvtMiscOptions::SetUseSystemPrintDialog( sal_Bool bEnable )
865 m_pDataContainer->SetUseSystemPrintDialog( bEnable );
868 sal_Bool SvtMiscOptions::ShowLinkWarningDialog() const
870 return m_pDataContainer->ShowLinkWarningDialog();
873 void SvtMiscOptions::SetShowLinkWarningDialog( sal_Bool bSet )
875 m_pDataContainer->SetShowLinkWarningDialog( bSet );
878 sal_Bool SvtMiscOptions::IsShowLinkWarningDialogReadOnly() const
880 return m_pDataContainer->IsShowLinkWarningDialogReadOnly();
883 void SvtMiscOptions::SetSaveAlwaysAllowed( sal_Bool bSet )
885 m_pDataContainer->SetSaveAlwaysAllowed( bSet );
888 sal_Bool SvtMiscOptions::IsSaveAlwaysAllowed() const
890 return m_pDataContainer->IsSaveAlwaysAllowed();
893 void SvtMiscOptions::SetExperimentalMode( sal_Bool bSet )
895 m_pDataContainer->SetExperimentalMode( bSet );
898 sal_Bool SvtMiscOptions::IsExperimentalMode() const
900 return m_pDataContainer->IsExperimentalMode();
903 void SvtMiscOptions::SetExperimentalSidebar( sal_Bool bSet )
905 m_pDataContainer->SetExperimentalSidebar( bSet );
908 sal_Bool SvtMiscOptions::IsExperimentalSidebar() const
910 return m_pDataContainer->IsExperimentalSidebar();
913 void SvtMiscOptions::SetMacroRecorderMode( sal_Bool bSet )
915 m_pDataContainer->SetMacroRecorderMode( bSet );
918 sal_Bool SvtMiscOptions::IsMacroRecorderMode() const
920 return m_pDataContainer->IsMacroRecorderMode();
923 namespace
925 class theSvtMiscOptionsMutex :
926 public rtl::Static< osl::Mutex, theSvtMiscOptionsMutex > {};
929 Mutex & SvtMiscOptions::GetInitMutex()
931 return theSvtMiscOptionsMutex::get();
934 void SvtMiscOptions::AddListenerLink( const Link& rLink )
936 m_pDataContainer->AddListenerLink( rLink );
939 void SvtMiscOptions::RemoveListenerLink( const Link& rLink )
941 m_pDataContainer->RemoveListenerLink( rLink );
944 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */