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