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