1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: miscopt.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
33 //_________________________________________________________________________________________________________________
35 //_________________________________________________________________________________________________________________
36 #ifdef SVL_DLLIMPLEMENTATION
37 #undef SVL_DLLIMPLEMENTATION
39 #define SVT_DLLIMPLEMENTATION
41 #include <svtools/miscopt.hxx>
42 #include <unotools/configmgr.hxx>
43 #include <unotools/configitem.hxx>
44 #include <tools/debug.hxx>
45 #include <com/sun/star/uno/Any.hxx>
46 #include <com/sun/star/uno/Sequence.hxx>
47 #include <tools/link.hxx>
48 #include <tools/list.hxx>
49 #include <tools/wldcrd.hxx>
50 #include <tools/urlobj.hxx>
52 #include <rtl/logfile.hxx>
53 #include "itemholder2.hxx"
56 #include <vcl/svapp.hxx>
58 //_________________________________________________________________________________________________________________
60 //_________________________________________________________________________________________________________________
62 using namespace ::utl
;
63 using namespace ::rtl
;
64 using namespace ::osl
;
65 using namespace ::com::sun::star::uno
;
66 using namespace ::com::sun::star
;
68 //_________________________________________________________________________________________________________________
70 //_________________________________________________________________________________________________________________
72 #define ASCII_STR(s) OUString( RTL_CONSTASCII_USTRINGPARAM(s) )
73 #define ROOTNODE_MISC ASCII_STR("Office.Common/Misc")
74 #define DEFAULT_PLUGINSENABLED sal_True;
76 #define PROPERTYNAME_PLUGINSENABLED ASCII_STR("PluginsEnabled")
77 #define PROPERTYHANDLE_PLUGINSENABLED 0
78 #define PROPERTYNAME_SYMBOLSET ASCII_STR("SymbolSet")
79 #define PROPERTYHANDLE_SYMBOLSET 1
80 #define PROPERTYNAME_TOOLBOXSTYLE ASCII_STR("ToolboxStyle")
81 #define PROPERTYHANDLE_TOOLBOXSTYLE 2
82 #define PROPERTYNAME_USESYSTEMFILEDIALOG ASCII_STR("UseSystemFileDialog")
83 #define PROPERTYHANDLE_USESYSTEMFILEDIALOG 3
84 #define PROPERTYNAME_SYMBOLSTYLE ASCII_STR("SymbolStyle")
85 #define PROPERTYHANDLE_SYMBOLSTYLE 4
86 #define PROPERTYNAME_USESYSTEMPRINTDIALOG ASCII_STR("UseSystemPrintDialog")
87 #define PROPERTYHANDLE_USESYSTEMPRINTDIALOG 5
88 #define PROPERTYNAME_TRYODMADIALOG ASCII_STR("TryODMADialog")
89 #define PROPERTYHANDLE_TRYODMADIALOG 6
90 #define PROPERTYNAME_SHOWLINKWARNINGDIALOG ASCII_STR("ShowLinkWarningDialog")
91 #define PROPERTYHANDLE_SHOWLINKWARNINGDIALOG 7
92 #define PROPERTYNAME_DISABLEUICUSTOMIZATION ASCII_STR("DisableUICustomization")
93 #define PROPERTYHANDLE_DISABLEUICUSTOMIZATION 8
95 #define PROPERTYCOUNT 9
97 #define VCL_TOOLBOX_STYLE_FLAT ((USHORT)0x0004) // from <vcl/toolbox.hxx>
99 DECLARE_LIST( LinkList
, Link
* )
101 //_________________________________________________________________________________________________________________
102 // private declarations!
103 //_________________________________________________________________________________________________________________
105 class SvtMiscOptions_Impl
: public ConfigItem
107 //-------------------------------------------------------------------------------------------------------------
109 //-------------------------------------------------------------------------------------------------------------
113 sal_Bool m_bUseSystemFileDialog
;
114 sal_Bool m_bIsUseSystemFileDialogRO
;
115 sal_Bool m_bTryODMADialog
;
116 sal_Bool m_bIsTryODMADialogRO
;
117 sal_Bool m_bPluginsEnabled
;
118 sal_Bool m_bIsPluginsEnabledRO
;
119 sal_Int16 m_nSymbolsSize
;
120 sal_Bool m_bIsSymbolsSizeRO
;
121 sal_Bool m_bIsSymbolsStyleRO
;
122 sal_Int16 m_nToolboxStyle
;
123 sal_Bool m_bIsToolboxStyleRO
;
124 sal_Bool m_bUseSystemPrintDialog
;
125 sal_Bool m_bIsUseSystemPrintDialogRO
;
126 sal_Bool m_bShowLinkWarningDialog
;
127 sal_Bool m_bIsShowLinkWarningDialogRO
;
128 sal_Bool m_bDisableUICustomization
;
130 //-------------------------------------------------------------------------------------------------------------
132 //-------------------------------------------------------------------------------------------------------------
136 //---------------------------------------------------------------------------------------------------------
137 // constructor / destructor
138 //---------------------------------------------------------------------------------------------------------
140 SvtMiscOptions_Impl();
141 ~SvtMiscOptions_Impl();
143 //---------------------------------------------------------------------------------------------------------
144 // overloaded methods of baseclass
145 //---------------------------------------------------------------------------------------------------------
147 /*-****************************************************************************************************//**
148 @short called for notify of configmanager
149 @descr These method is called from the ConfigManager before application ends or from the
150 PropertyChangeListener if the sub tree broadcasts changes. You must update your
153 @seealso baseclass ConfigItem
155 @param "seqPropertyNames" is the list of properties which should be updated.
159 *//*-*****************************************************************************************************/
161 virtual void Notify( const Sequence
< OUString
>& seqPropertyNames
);
163 /** loads required data from the configuration. It's called in the constructor to
164 read all entries and form ::Notify to re-read changed settings
167 void Load( const Sequence
< OUString
>& rPropertyNames
);
169 /*-****************************************************************************************************//**
170 @short write changes to configuration
171 @descr These method writes the changed values into the sub tree
172 and should always called in our destructor to guarantee consistency of config data.
174 @seealso baseclass ConfigItem
180 *//*-*****************************************************************************************************/
182 virtual void Commit();
184 //---------------------------------------------------------------------------------------------------------
186 //---------------------------------------------------------------------------------------------------------
188 inline sal_Bool
UseSystemFileDialog() const
189 { return m_bUseSystemFileDialog
; }
191 inline void SetUseSystemFileDialog( sal_Bool bSet
)
192 { m_bUseSystemFileDialog
= bSet
; SetModified(); }
194 inline sal_Bool
IsUseSystemFileDialogReadOnly() const
195 { return m_bIsUseSystemFileDialogRO
; }
197 inline sal_Bool
TryODMADialog() const
198 { return m_bTryODMADialog
; }
200 inline void SetTryODMADialog( sal_Bool bSet
)
201 { m_bTryODMADialog
= bSet
; SetModified(); }
203 inline sal_Bool
IsTryUseODMADialogReadOnly() const
204 { return m_bIsTryODMADialogRO
; }
206 inline sal_Bool
DisableUICustomization() const
207 { return m_bDisableUICustomization
; }
209 inline sal_Bool
IsPluginsEnabled() const
210 { return m_bPluginsEnabled
; }
212 void SetPluginsEnabled( sal_Bool bEnable
);
214 inline sal_Bool
IsPluginsEnabledReadOnly() const
215 { return m_bIsPluginsEnabledRO
; }
217 inline sal_Int16
GetSymbolsSize()
218 { return m_nSymbolsSize
; }
220 void SetSymbolsSize( sal_Int16 nSet
);
222 inline sal_Bool
IsGetSymbolsSizeReadOnly()
223 { return m_bIsSymbolsSizeRO
; }
225 sal_Int16
GetSymbolsStyle() const;
226 ::rtl::OUString
GetSymbolsStyleName() const;
227 sal_Int16
GetCurrentSymbolsStyle() const;
229 inline void SetSymbolsStyle( sal_Int16 nSet
)
230 { ImplSetSymbolsStyle( true, nSet
, ::rtl::OUString() ); }
232 inline void SetSymbolsStyleName( ::rtl::OUString
&rName
)
233 { ImplSetSymbolsStyle( false, 0, rName
); }
235 inline sal_Bool
IsGetSymbolsStyleReadOnly()
236 { return m_bIsSymbolsStyleRO
; }
238 // translate to VCL settings ( "0" = 3D, "1" = FLAT )
239 inline sal_Int16
GetToolboxStyle()
240 { return m_nToolboxStyle
? VCL_TOOLBOX_STYLE_FLAT
: 0; }
242 // translate from VCL settings
243 void SetToolboxStyle( sal_Int16 nStyle
, bool _bSetModified
);
245 inline sal_Bool
IsGetToolboxStyleReadOnly()
246 { return m_bIsToolboxStyleRO
; }
248 inline sal_Bool
UseSystemPrintDialog() const
249 { return m_bUseSystemPrintDialog
; }
251 inline void SetUseSystemPrintDialog( sal_Bool bSet
)
252 { m_bUseSystemPrintDialog
= bSet
; SetModified(); }
254 inline sal_Bool
IsUseSystemPrintDialogReadOnly() const
255 { return m_bIsUseSystemPrintDialogRO
; }
257 inline sal_Bool
ShowLinkWarningDialog() const
258 { return m_bShowLinkWarningDialog
; }
260 void SetShowLinkWarningDialog( sal_Bool bSet
)
261 { m_bShowLinkWarningDialog
= bSet
; SetModified(); }
263 sal_Bool
IsShowLinkWarningDialogReadOnly() const
264 { return m_bIsShowLinkWarningDialogRO
; }
266 void AddListener( const Link
& rLink
);
267 void RemoveListener( const Link
& rLink
);
268 void CallListeners();
270 //-------------------------------------------------------------------------------------------------------------
272 //-------------------------------------------------------------------------------------------------------------
276 /*-****************************************************************************************************//**
277 @short return list of key names of ouer configuration management which represent oue module tree
278 @descr These methods return a static const list of key names. We need it to get needed values from our
279 configuration management.
284 @return A list of needed configuration keys is returned.
287 *//*-*****************************************************************************************************/
289 static Sequence
< OUString
> GetPropertyNames();
292 void ImplSetSymbolsStyle( bool bValue
, sal_Int16 nSet
, const ::rtl::OUString
&rName
);
295 //_________________________________________________________________________________________________________________
297 //_________________________________________________________________________________________________________________
299 static sal_Int16
implSymbolsStyleFromVCL( ULONG nStyle
)
303 case STYLE_SYMBOLS_AUTO
: return SFX_SYMBOLS_STYLE_AUTO
;
304 case STYLE_SYMBOLS_DEFAULT
: return SFX_SYMBOLS_STYLE_DEFAULT
;
305 case STYLE_SYMBOLS_HICONTRAST
: return SFX_SYMBOLS_STYLE_HICONTRAST
;
306 case STYLE_SYMBOLS_INDUSTRIAL
: return SFX_SYMBOLS_STYLE_INDUSTRIAL
;
307 case STYLE_SYMBOLS_CRYSTAL
: return SFX_SYMBOLS_STYLE_CRYSTAL
;
308 case STYLE_SYMBOLS_TANGO
: return SFX_SYMBOLS_STYLE_TANGO
;
309 case STYLE_SYMBOLS_CLASSIC
: return SFX_SYMBOLS_STYLE_CLASSIC
;
310 case STYLE_SYMBOLS_OXYGEN
: return SFX_SYMBOLS_STYLE_OXYGEN
;
313 return SFX_SYMBOLS_STYLE_AUTO
;
316 static ULONG
implSymbolsStyleToVCL( sal_Int16 nStyle
)
320 case SFX_SYMBOLS_STYLE_AUTO
: return STYLE_SYMBOLS_AUTO
;
321 case SFX_SYMBOLS_STYLE_DEFAULT
: return STYLE_SYMBOLS_DEFAULT
;
322 case SFX_SYMBOLS_STYLE_HICONTRAST
: return STYLE_SYMBOLS_HICONTRAST
;
323 case SFX_SYMBOLS_STYLE_INDUSTRIAL
: return STYLE_SYMBOLS_INDUSTRIAL
;
324 case SFX_SYMBOLS_STYLE_CRYSTAL
: return STYLE_SYMBOLS_CRYSTAL
;
325 case SFX_SYMBOLS_STYLE_TANGO
: return STYLE_SYMBOLS_TANGO
;
326 case SFX_SYMBOLS_STYLE_CLASSIC
: return STYLE_SYMBOLS_CLASSIC
;
327 case SFX_SYMBOLS_STYLE_OXYGEN
: return STYLE_SYMBOLS_OXYGEN
;
330 return STYLE_SYMBOLS_AUTO
;
333 //*****************************************************************************************************************
335 //*****************************************************************************************************************
336 SvtMiscOptions_Impl::SvtMiscOptions_Impl()
337 // Init baseclasses first
338 : ConfigItem( ROOTNODE_MISC
)
340 , m_bUseSystemFileDialog( sal_False
)
341 , m_bIsUseSystemFileDialogRO( sal_False
)
342 , m_bTryODMADialog( sal_False
)
343 , m_bIsTryODMADialogRO( sal_False
)
344 , m_bPluginsEnabled( sal_False
)
345 , m_bIsPluginsEnabledRO( sal_False
)
346 , m_nSymbolsSize( 0 )
347 , m_bIsSymbolsSizeRO( sal_False
)
348 , m_bIsSymbolsStyleRO( sal_False
)
349 , m_nToolboxStyle( 1 )
350 , m_bIsToolboxStyleRO( sal_False
)
351 , m_bUseSystemPrintDialog( sal_False
)
352 , m_bIsUseSystemPrintDialogRO( sal_False
)
353 , m_bShowLinkWarningDialog( sal_True
)
354 , m_bIsShowLinkWarningDialogRO( sal_False
)
357 // Use our static list of configuration keys to get his values.
358 Sequence
< OUString
> seqNames
= GetPropertyNames ( );
360 Sequence
< Any
> seqValues
= GetProperties ( seqNames
);
361 Sequence
< sal_Bool
> seqRO
= GetReadOnlyStates ( seqNames
);
363 // Safe impossible cases.
364 // We need values from ALL configuration keys.
365 // Follow assignment use order of values in relation to our list of key names!
366 DBG_ASSERT( !(seqNames
.getLength()!=seqValues
.getLength()), "SvtMiscOptions_Impl::SvtMiscOptions_Impl()\nI miss some values of configuration keys!\n" );
368 // Copy values from list in right order to ouer internal member.
369 sal_Int32 nPropertyCount
= seqValues
.getLength();
370 for( sal_Int32 nProperty
=0; nProperty
<nPropertyCount
; ++nProperty
)
372 // Safe impossible cases.
373 // Check any for valid value.
374 DBG_ASSERT( !(seqValues
[nProperty
].hasValue()==sal_False
), "SvtSecurityOptions_Impl::SvtSecurityOptions_Impl()\nInvalid property value detected!\n" );
377 case PROPERTYHANDLE_PLUGINSENABLED
:
379 if( !(seqValues
[nProperty
] >>= m_bPluginsEnabled
) )
381 DBG_ERROR("Wrong type of \"Misc\\PluginsEnabled\"!" );
383 m_bIsPluginsEnabledRO
= seqRO
[nProperty
];
387 case PROPERTYHANDLE_SYMBOLSET
:
389 if( !(seqValues
[nProperty
] >>= m_nSymbolsSize
) )
391 DBG_ERROR("Wrong type of \"Misc\\SymbolSet\"!" );
393 m_bIsSymbolsSizeRO
= seqRO
[nProperty
];
397 case PROPERTYHANDLE_TOOLBOXSTYLE
:
399 if( !(seqValues
[nProperty
] >>= m_nToolboxStyle
) )
401 DBG_ERROR("Wrong type of \"Misc\\ToolboxStyle\"!" );
403 m_bIsToolboxStyleRO
= seqRO
[nProperty
];
407 case PROPERTYHANDLE_USESYSTEMFILEDIALOG
:
409 if( !(seqValues
[nProperty
] >>= m_bUseSystemFileDialog
) )
411 DBG_ERROR("Wrong type of \"Misc\\UseSystemFileDialog\"!" );
413 m_bIsUseSystemFileDialogRO
= seqRO
[nProperty
];
417 case PROPERTYHANDLE_USESYSTEMPRINTDIALOG
:
419 if( !(seqValues
[nProperty
] >>= m_bUseSystemPrintDialog
) )
421 DBG_ERROR("Wrong type of \"Misc\\UseSystemPrintDialog\"!" );
423 m_bIsUseSystemPrintDialogRO
= seqRO
[nProperty
];
427 case PROPERTYHANDLE_TRYODMADIALOG
:
429 if( !(seqValues
[nProperty
] >>= m_bTryODMADialog
) )
431 DBG_ERROR("Wrong type of \"Misc\\TryODMADialog\"!" );
433 m_bIsTryODMADialogRO
= seqRO
[nProperty
];
437 case PROPERTYHANDLE_SHOWLINKWARNINGDIALOG
:
439 if( !(seqValues
[nProperty
] >>= m_bShowLinkWarningDialog
) )
441 DBG_ERROR("Wrong type of \"Misc\\ShowLinkWarningDialog\"!" );
443 m_bIsShowLinkWarningDialogRO
= seqRO
[nProperty
];
447 case PROPERTYHANDLE_SYMBOLSTYLE
:
449 ::rtl::OUString aSymbolsStyle
;
450 if( seqValues
[nProperty
] >>= aSymbolsStyle
)
451 SetSymbolsStyleName( aSymbolsStyle
);
454 DBG_ERROR("Wrong type of \"Misc\\SymbolStyle\"!" );
456 m_bIsSymbolsStyleRO
= seqRO
[nProperty
];
460 case PROPERTYHANDLE_DISABLEUICUSTOMIZATION
:
462 if( !(seqValues
[nProperty
] >>= m_bDisableUICustomization
) )
463 DBG_ERROR("Wrong type of \"Misc\\DisableUICustomization\"!" );
469 // Enable notification mechanism of ouer baseclass.
470 // We need it to get information about changes outside these class on ouer used configuration keys!
471 EnableNotification( seqNames
);
474 //*****************************************************************************************************************
476 //*****************************************************************************************************************
477 SvtMiscOptions_Impl::~SvtMiscOptions_Impl()
479 // We must save our current values .. if user forget it!
480 if( IsModified() == sal_True
)
485 for ( USHORT n
=0; n
<aList
.Count(); )
486 delete aList
.Remove(n
);
489 /*-- 25.02.2005 13:22:04---------------------------------------------------
491 -----------------------------------------------------------------------*/
492 static int lcl_MapPropertyName( const ::rtl::OUString rCompare
,
493 const uno::Sequence
< ::rtl::OUString
>& aInternalPropertyNames
)
495 for(int nProp
= 0; nProp
< aInternalPropertyNames
.getLength(); ++nProp
)
497 if( aInternalPropertyNames
[nProp
] == rCompare
)
503 void SvtMiscOptions_Impl::Load( const Sequence
< OUString
>& rPropertyNames
)
505 const uno::Sequence
< ::rtl::OUString
> aInternalPropertyNames( GetPropertyNames());
506 Sequence
< Any
> seqValues
= GetProperties( rPropertyNames
);
508 // Safe impossible cases.
509 // We need values from ALL configuration keys.
510 // Follow assignment use order of values in relation to our list of key names!
511 DBG_ASSERT( !(rPropertyNames
.getLength()!=seqValues
.getLength()), "SvtSecurityOptions_Impl::SvtSecurityOptions_Impl()\nI miss some values of configuration keys!\n" );
513 // Copy values from list in right order to ouer internal member.
514 sal_Int32 nPropertyCount
= seqValues
.getLength();
515 for( sal_Int32 nProperty
=0; nProperty
<nPropertyCount
; ++nProperty
)
517 // Safe impossible cases.
518 // Check any for valid value.
519 DBG_ASSERT( !(seqValues
[nProperty
].hasValue()==sal_False
), "SvtSecurityOptions_Impl::SvtSecurityOptions_Impl()\nInvalid property value detected!\n" );
520 switch( lcl_MapPropertyName(rPropertyNames
[nProperty
], aInternalPropertyNames
) )
522 case PROPERTYHANDLE_PLUGINSENABLED
: {
523 if( !(seqValues
[nProperty
] >>= m_bPluginsEnabled
) )
525 DBG_ERROR("Wrong type of \"Misc\\PluginsEnabled\"!" );
529 case PROPERTYHANDLE_SYMBOLSET
: {
530 if( !(seqValues
[nProperty
] >>= m_nSymbolsSize
) )
532 DBG_ERROR("Wrong type of \"Misc\\SymbolSet\"!" );
536 case PROPERTYHANDLE_TOOLBOXSTYLE
: {
537 if( !(seqValues
[nProperty
] >>= m_nToolboxStyle
) )
539 DBG_ERROR("Wrong type of \"Misc\\ToolboxStyle\"!" );
543 case PROPERTYHANDLE_USESYSTEMFILEDIALOG
: {
544 if( !(seqValues
[nProperty
] >>= m_bUseSystemFileDialog
) )
546 DBG_ERROR("Wrong type of \"Misc\\UseSystemFileDialog\"!" );
550 case PROPERTYHANDLE_USESYSTEMPRINTDIALOG
: {
551 if( !(seqValues
[nProperty
] >>= m_bUseSystemPrintDialog
) )
553 DBG_ERROR("Wrong type of \"Misc\\UseSystemPrintDialog\"!" );
557 case PROPERTYHANDLE_TRYODMADIALOG
: {
558 if( !(seqValues
[nProperty
] >>= m_bTryODMADialog
) )
560 DBG_ERROR("Wrong type of \"Misc\\TryODMADialog\"!" );
564 case PROPERTYHANDLE_SHOWLINKWARNINGDIALOG
: {
565 if( !(seqValues
[nProperty
] >>= m_bShowLinkWarningDialog
) )
567 DBG_ERROR("Wrong type of \"Misc\\ShowLinkWarningDialog\"!" );
571 case PROPERTYHANDLE_SYMBOLSTYLE
: {
572 ::rtl::OUString aSymbolsStyle
;
573 if( seqValues
[nProperty
] >>= aSymbolsStyle
)
574 SetSymbolsStyleName( aSymbolsStyle
);
577 DBG_ERROR("Wrong type of \"Misc\\SymbolStyle\"!" );
581 case PROPERTYHANDLE_DISABLEUICUSTOMIZATION
: {
582 if( !(seqValues
[nProperty
] >>= m_bDisableUICustomization
) )
583 DBG_ERROR("Wrong type of \"Misc\\DisableUICustomization\"!" );
590 void SvtMiscOptions_Impl::AddListener( const Link
& rLink
)
592 aList
.Insert( new Link( rLink
) );
595 void SvtMiscOptions_Impl::RemoveListener( const Link
& rLink
)
597 for ( USHORT n
=0; n
<aList
.Count(); n
++ )
599 if ( (*aList
.GetObject(n
) ) == rLink
)
601 delete aList
.Remove(n
);
607 void SvtMiscOptions_Impl::CallListeners()
609 for ( USHORT n
= 0; n
< aList
.Count(); ++n
)
610 aList
.GetObject(n
)->Call( this );
613 void SvtMiscOptions_Impl::SetToolboxStyle( sal_Int16 nStyle
, bool _bSetModified
)
615 m_nToolboxStyle
= nStyle
? 1 : 0;
621 void SvtMiscOptions_Impl::SetSymbolsSize( sal_Int16 nSet
)
623 m_nSymbolsSize
= nSet
;
628 sal_Int16
SvtMiscOptions_Impl::GetSymbolsStyle() const
630 return implSymbolsStyleFromVCL( Application::GetSettings().GetStyleSettings().GetSymbolsStyle() );
633 ::rtl::OUString
SvtMiscOptions_Impl::GetSymbolsStyleName() const
635 return Application::GetSettings().GetStyleSettings().GetSymbolsStyleName();
638 sal_Int16
SvtMiscOptions_Impl::GetCurrentSymbolsStyle() const
640 return implSymbolsStyleFromVCL( Application::GetSettings().GetStyleSettings().GetCurrentSymbolsStyle() );
643 void SvtMiscOptions_Impl::ImplSetSymbolsStyle( bool bValue
, sal_Int16 nSet
, const ::rtl::OUString
&rName
)
645 if ( ( bValue
&& ( nSet
!= GetSymbolsStyle() ) ) ||
646 ( !bValue
&& ( rName
!= GetSymbolsStyleName() ) ) )
648 AllSettings aAllSettings
= Application::GetSettings();
649 StyleSettings aStyleSettings
= aAllSettings
.GetStyleSettings();
652 aStyleSettings
.SetSymbolsStyle( implSymbolsStyleToVCL( nSet
) );
654 aStyleSettings
.SetSymbolsStyleName( rName
);
656 aAllSettings
.SetStyleSettings(aStyleSettings
);
657 Application::MergeSystemSettings( aAllSettings
);
658 Application::SetSettings(aAllSettings
);
665 void SvtMiscOptions_Impl::SetPluginsEnabled( sal_Bool bEnable
)
667 m_bPluginsEnabled
= bEnable
;
672 //*****************************************************************************************************************
674 //*****************************************************************************************************************
675 void SvtMiscOptions_Impl::Notify( const Sequence
< OUString
>& rPropertyNames
)
677 Load( rPropertyNames
);
681 //*****************************************************************************************************************
683 //*****************************************************************************************************************
684 void SvtMiscOptions_Impl::Commit()
686 // Get names of supported properties, create a list for values and copy current values to it.
687 Sequence
< OUString
> seqNames
= GetPropertyNames ();
688 sal_Int32 nCount
= seqNames
.getLength();
689 Sequence
< Any
> seqValues ( nCount
);
690 for( sal_Int32 nProperty
=0; nProperty
<nCount
; ++nProperty
)
694 case PROPERTYHANDLE_PLUGINSENABLED
:
696 if ( !m_bIsPluginsEnabledRO
)
697 seqValues
[nProperty
] <<= m_bPluginsEnabled
;
701 case PROPERTYHANDLE_SYMBOLSET
:
703 if ( !m_bIsSymbolsSizeRO
)
704 seqValues
[nProperty
] <<= m_nSymbolsSize
;
708 case PROPERTYHANDLE_TOOLBOXSTYLE
:
710 if ( !m_bIsToolboxStyleRO
)
711 seqValues
[nProperty
] <<= m_nToolboxStyle
;
715 case PROPERTYHANDLE_USESYSTEMFILEDIALOG
:
717 if ( !m_bIsUseSystemFileDialogRO
)
718 seqValues
[nProperty
] <<= m_bUseSystemFileDialog
;
722 case PROPERTYHANDLE_TRYODMADIALOG
:
724 if ( !m_bIsTryODMADialogRO
)
725 seqValues
[nProperty
] <<= m_bTryODMADialog
;
729 case PROPERTYHANDLE_SYMBOLSTYLE
:
731 if ( !m_bIsSymbolsStyleRO
)
732 seqValues
[nProperty
] <<= GetSymbolsStyleName();
736 case PROPERTYHANDLE_USESYSTEMPRINTDIALOG
:
738 if ( !m_bIsUseSystemPrintDialogRO
)
739 seqValues
[nProperty
] <<= m_bUseSystemPrintDialog
;
743 case PROPERTYHANDLE_SHOWLINKWARNINGDIALOG
:
745 if ( !m_bIsShowLinkWarningDialogRO
)
746 seqValues
[nProperty
] <<= m_bShowLinkWarningDialog
;
750 case PROPERTYHANDLE_DISABLEUICUSTOMIZATION
:
752 seqValues
[nProperty
] <<= m_bDisableUICustomization
;
757 // Set properties in configuration.
758 PutProperties( seqNames
, seqValues
);
761 //*****************************************************************************************************************
763 //*****************************************************************************************************************
764 Sequence
< OUString
> SvtMiscOptions_Impl::GetPropertyNames()
766 // Build static list of configuration key names.
767 static const OUString pProperties
[] =
769 PROPERTYNAME_PLUGINSENABLED
,
770 PROPERTYNAME_SYMBOLSET
,
771 PROPERTYNAME_TOOLBOXSTYLE
,
772 PROPERTYNAME_USESYSTEMFILEDIALOG
,
773 PROPERTYNAME_SYMBOLSTYLE
,
774 PROPERTYNAME_USESYSTEMPRINTDIALOG
,
775 PROPERTYNAME_TRYODMADIALOG
,
776 PROPERTYNAME_SHOWLINKWARNINGDIALOG
,
777 PROPERTYNAME_DISABLEUICUSTOMIZATION
780 // Initialize return sequence with these list ...
781 static const Sequence
< OUString
> seqPropertyNames( pProperties
, PROPERTYCOUNT
);
782 // ... and return it.
783 return seqPropertyNames
;
786 //*****************************************************************************************************************
787 // initialize static member
788 // DON'T DO IT IN YOUR HEADER!
789 // see definition for further informations
790 //*****************************************************************************************************************
791 SvtMiscOptions_Impl
* SvtMiscOptions::m_pDataContainer
= NULL
;
792 sal_Int32
SvtMiscOptions::m_nRefCount
= 0 ;
794 //*****************************************************************************************************************
796 //*****************************************************************************************************************
797 SvtMiscOptions::SvtMiscOptions()
799 // Global access, must be guarded (multithreading!).
800 MutexGuard
aGuard( GetInitMutex() );
801 // Increase ouer refcount ...
803 // ... and initialize ouer data container only if it not already exist!
804 if( m_pDataContainer
== NULL
)
806 RTL_LOGFILE_CONTEXT(aLog
, "svtools ( ??? ) ::SvtMiscOptions_Impl::ctor()");
807 m_pDataContainer
= new SvtMiscOptions_Impl
;
808 ItemHolder2::holdConfigItem(E_MISCOPTIONS
);
812 //*****************************************************************************************************************
814 //*****************************************************************************************************************
815 SvtMiscOptions::~SvtMiscOptions()
817 // Global access, must be guarded (multithreading!)
818 MutexGuard
aGuard( GetInitMutex() );
819 // Decrease ouer refcount.
821 // If last instance was deleted ...
822 // we must destroy ouer static data container!
823 if( m_nRefCount
<= 0 )
825 delete m_pDataContainer
;
826 m_pDataContainer
= NULL
;
830 sal_Bool
SvtMiscOptions::UseSystemFileDialog() const
832 return m_pDataContainer
->UseSystemFileDialog();
835 void SvtMiscOptions::SetUseSystemFileDialog( sal_Bool bEnable
)
837 m_pDataContainer
->SetUseSystemFileDialog( bEnable
);
840 sal_Bool
SvtMiscOptions::IsUseSystemFileDialogReadOnly() const
842 return m_pDataContainer
->IsUseSystemFileDialogReadOnly();
845 sal_Bool
SvtMiscOptions::TryODMADialog() const
847 return m_pDataContainer
->TryODMADialog();
850 void SvtMiscOptions::SetTryODMADialog( sal_Bool bEnable
)
852 m_pDataContainer
->SetTryODMADialog( bEnable
);
855 sal_Bool
SvtMiscOptions::IsTryUseODMADialogReadOnly() const
857 return m_pDataContainer
->IsTryUseODMADialogReadOnly();
860 sal_Bool
SvtMiscOptions::IsPluginsEnabled() const
862 return m_pDataContainer
->IsPluginsEnabled();
865 void SvtMiscOptions::SetPluginsEnabled( sal_Bool bEnable
)
867 m_pDataContainer
->SetPluginsEnabled( bEnable
);
870 sal_Bool
SvtMiscOptions::IsPluginsEnabledReadOnly() const
872 return m_pDataContainer
->IsPluginsEnabledReadOnly();
875 sal_Int16
SvtMiscOptions::GetSymbolsSize() const
877 return m_pDataContainer
->GetSymbolsSize();
880 void SvtMiscOptions::SetSymbolsSize( sal_Int16 nSet
)
882 m_pDataContainer
->SetSymbolsSize( nSet
);
885 sal_Int16
SvtMiscOptions::GetCurrentSymbolsSize() const
887 sal_Int16 eOptSymbolsSize
= m_pDataContainer
->GetSymbolsSize();
889 if ( eOptSymbolsSize
== SFX_SYMBOLS_SIZE_AUTO
)
891 // Use system settings, we have to retrieve the toolbar icon size from the
893 ULONG nStyleIconSize
= Application::GetSettings().GetStyleSettings().GetToolbarIconSize();
894 if ( nStyleIconSize
== STYLE_TOOLBAR_ICONSIZE_LARGE
)
895 eOptSymbolsSize
= SFX_SYMBOLS_SIZE_LARGE
;
897 eOptSymbolsSize
= SFX_SYMBOLS_SIZE_SMALL
;
900 return eOptSymbolsSize
;
903 bool SvtMiscOptions::AreCurrentSymbolsLarge() const
905 return ( GetCurrentSymbolsSize() == SFX_SYMBOLS_SIZE_LARGE
);
908 sal_Bool
SvtMiscOptions::IsGetSymbolsSizeReadOnly() const
910 return m_pDataContainer
->IsGetSymbolsSizeReadOnly();
913 sal_Int16
SvtMiscOptions::GetSymbolsStyle() const
915 return m_pDataContainer
->GetSymbolsStyle();
918 sal_Int16
SvtMiscOptions::GetCurrentSymbolsStyle() const
920 return m_pDataContainer
->GetCurrentSymbolsStyle();
923 OUString
SvtMiscOptions::GetCurrentSymbolsStyleName() const
925 return Application::GetSettings().GetStyleSettings().GetCurrentSymbolsStyleName();
928 void SvtMiscOptions::SetSymbolsStyle( sal_Int16 nSet
)
930 m_pDataContainer
->SetSymbolsStyle( nSet
);
933 sal_Bool
SvtMiscOptions::IsGetSymbolsStyleReadOnly() const
935 return m_pDataContainer
->IsGetSymbolsStyleReadOnly();
938 sal_Bool
SvtMiscOptions::DisableUICustomization() const
940 return m_pDataContainer
->DisableUICustomization();
943 sal_Int16
SvtMiscOptions::GetToolboxStyle() const
945 return m_pDataContainer
->GetToolboxStyle();
948 void SvtMiscOptions::SetToolboxStyle( sal_Int16 nStyle
)
950 m_pDataContainer
->SetToolboxStyle( nStyle
, true );
953 sal_Bool
SvtMiscOptions::IsGetToolboxStyleReadOnly() const
955 return m_pDataContainer
->IsGetToolboxStyleReadOnly();
958 sal_Bool
SvtMiscOptions::UseSystemPrintDialog() const
960 return m_pDataContainer
->UseSystemPrintDialog();
963 void SvtMiscOptions::SetUseSystemPrintDialog( sal_Bool bEnable
)
965 m_pDataContainer
->SetUseSystemPrintDialog( bEnable
);
968 sal_Bool
SvtMiscOptions::ShowLinkWarningDialog() const
970 return m_pDataContainer
->ShowLinkWarningDialog();
973 void SvtMiscOptions::SetShowLinkWarningDialog( sal_Bool bSet
)
975 m_pDataContainer
->SetShowLinkWarningDialog( bSet
);
978 sal_Bool
SvtMiscOptions::IsShowLinkWarningDialogReadOnly() const
980 return m_pDataContainer
->IsShowLinkWarningDialogReadOnly();
983 //*****************************************************************************************************************
985 //*****************************************************************************************************************
986 Mutex
& SvtMiscOptions::GetInitMutex()
988 // Initialize static mutex only for one time!
989 static Mutex
* pMutex
= NULL
;
990 // If these method first called (Mutex not already exist!) ...
993 // ... we must create a new one. Protect follow code with the global mutex -
994 // It must be - we create a static variable!
995 MutexGuard
aGuard( Mutex::getGlobalMutex() );
996 // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
999 // Create the new mutex and set it for return on static variable.
1000 static Mutex aMutex
;
1004 // Return new created or already existing mutex object.
1008 void SvtMiscOptions::AddListener( const Link
& rLink
)
1010 m_pDataContainer
->AddListener( rLink
);
1013 void SvtMiscOptions::RemoveListener( const Link
& rLink
)
1015 m_pDataContainer
->RemoveListener( rLink
);