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