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