Update ooo320-m1
[ooovba.git] / svtools / source / config / securityoptions.cxx
blob3b9dc1c1f6f896e58f0b73190fc4b11840712263
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: securityoptions.cxx,v $
10 * $Revision: 1.33 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
33 #ifndef GCC
34 #endif
36 //_________________________________________________________________________________________________________________
37 // includes
38 //_________________________________________________________________________________________________________________
40 #include <svtools/securityoptions.hxx>
41 #include <unotools/configmgr.hxx>
42 #include <unotools/configitem.hxx>
43 #include <tools/debug.hxx>
44 #include <com/sun/star/uno/Any.hxx>
45 #include <com/sun/star/uno/Sequence.hxx>
47 #include <com/sun/star/beans/PropertyValue.hpp>
48 #include <tools/urlobj.hxx>
49 #include <tools/wldcrd.hxx>
51 #include <svtools/pathoptions.hxx>
53 #include <rtl/logfile.hxx>
54 #include "itemholder1.hxx"
56 //_________________________________________________________________________________________________________________
57 // namespaces
58 //_________________________________________________________________________________________________________________
60 using namespace ::utl ;
61 using namespace ::rtl ;
62 using namespace ::osl ;
63 using namespace ::com::sun::star::uno ;
65 //_________________________________________________________________________________________________________________
66 // const
67 //_________________________________________________________________________________________________________________
69 #define ROOTNODE_SECURITY OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/Security/Scripting"))
70 #define DEFAULT_SECUREURL Sequence< OUString >()
71 #define DEFAULT_SECLEVEL 3
72 #define DEFAULT_TRUSTEDAUTHORS Sequence< SvtSecurityOptions::Certificate >()
74 // xmlsec05 depricated
75 #define DEFAULT_STAROFFICEBASIC eALWAYS_EXECUTE
77 #define CSTR_SECUREURL "SecureURL"
78 #define CSTR_DOCWARN_SAVEORSEND "WarnSaveOrSendDoc"
79 #define CSTR_DOCWARN_SIGNING "WarnSignDoc"
80 #define CSTR_DOCWARN_PRINT "WarnPrintDoc"
81 #define CSTR_DOCWARN_CREATEPDF "WarnCreatePDF"
82 #define CSTR_DOCWARN_REMOVEPERSONALINFO "RemovePersonalInfoOnSaving"
83 #define CSTR_DOCWARN_RECOMMENDPASSWORD "RecommendPasswordProtection"
84 #define CSTR_CTRLCLICK_HYPERLINK "HyperlinksWithCtrlClick"
85 #define CSTR_MACRO_SECLEVEL "MacroSecurityLevel"
86 #define CSTR_MACRO_TRUSTEDAUTHORS "TrustedAuthors"
87 #define CSTR_MACRO_DISABLE "DisableMacrosExecution"
88 #define CSTR_TRUSTEDAUTHOR_SUBJECTNAME "SubjectName"
89 #define CSTR_TRUSTEDAUTHOR_SERIALNUMBER "SerialNumber"
90 #define CSTR_TRUSTEDAUTHOR_RAWDATA "RawData"
92 #define PROPERTYNAME_SECUREURL OUString(RTL_CONSTASCII_USTRINGPARAM(CSTR_SECUREURL ))
93 #define PROPERTYNAME_DOCWARN_SAVEORSEND OUString(RTL_CONSTASCII_USTRINGPARAM(CSTR_DOCWARN_SAVEORSEND ))
94 #define PROPERTYNAME_DOCWARN_SIGNING OUString(RTL_CONSTASCII_USTRINGPARAM(CSTR_DOCWARN_SIGNING ))
95 #define PROPERTYNAME_DOCWARN_PRINT OUString(RTL_CONSTASCII_USTRINGPARAM(CSTR_DOCWARN_PRINT ))
96 #define PROPERTYNAME_DOCWARN_CREATEPDF OUString(RTL_CONSTASCII_USTRINGPARAM(CSTR_DOCWARN_CREATEPDF ))
97 #define PROPERTYNAME_DOCWARN_REMOVEPERSONALINFO OUString(RTL_CONSTASCII_USTRINGPARAM(CSTR_DOCWARN_REMOVEPERSONALINFO ))
98 #define PROPERTYNAME_DOCWARN_RECOMMENDPASSWORD OUString(RTL_CONSTASCII_USTRINGPARAM(CSTR_DOCWARN_RECOMMENDPASSWORD ))
99 #define PROPERTYNAME_CTRLCLICK_HYPERLINK OUString(RTL_CONSTASCII_USTRINGPARAM(CSTR_CTRLCLICK_HYPERLINK ))
100 #define PROPERTYNAME_MACRO_SECLEVEL OUString(RTL_CONSTASCII_USTRINGPARAM(CSTR_MACRO_SECLEVEL ))
101 #define PROPERTYNAME_MACRO_TRUSTEDAUTHORS OUString(RTL_CONSTASCII_USTRINGPARAM(CSTR_MACRO_TRUSTEDAUTHORS ))
102 #define PROPERTYNAME_MACRO_DISABLE OUString(RTL_CONSTASCII_USTRINGPARAM(CSTR_MACRO_DISABLE ))
103 #define PROPERTYNAME_TRUSTEDAUTHOR_SUBJECTNAME OUString(RTL_CONSTASCII_USTRINGPARAM(CSTR_TRUSTEDAUTHOR_SUBJECTNAME))
104 #define PROPERTYNAME_TRUSTEDAUTHOR_SERIALNUMBER OUString(RTL_CONSTASCII_USTRINGPARAM(CSTR_TRUSTEDAUTHOR_SERIALNUMBER))
105 #define PROPERTYNAME_TRUSTEDAUTHOR_RAWDATA OUString(RTL_CONSTASCII_USTRINGPARAM(CSTR_TRUSTEDAUTHOR_RAWDATA))
107 // xmlsec05 depricated
108 #define PROPERTYNAME_STAROFFICEBASIC OUString(RTL_CONSTASCII_USTRINGPARAM("OfficeBasic" ))
109 #define PROPERTYNAME_EXECUTEPLUGINS OUString(RTL_CONSTASCII_USTRINGPARAM("ExecutePlugins" ))
110 #define PROPERTYNAME_WARNINGENABLED OUString(RTL_CONSTASCII_USTRINGPARAM("Warning" ))
111 #define PROPERTYNAME_CONFIRMATIONENABLED OUString(RTL_CONSTASCII_USTRINGPARAM("Confirmation" ))
112 // xmlsec05 depricated
115 #define PROPERTYHANDLE_SECUREURL 0
117 // xmlsec05 depricated
118 #define PROPERTYHANDLE_STAROFFICEBASIC 1
119 #define PROPERTYHANDLE_EXECUTEPLUGINS 2
120 #define PROPERTYHANDLE_WARNINGENABLED 3
121 #define PROPERTYHANDLE_CONFIRMATIONENABLED 4
122 // xmlsec05 depricated
124 #define PROPERTYHANDLE_DOCWARN_SAVEORSEND 5
125 #define PROPERTYHANDLE_DOCWARN_SIGNING 6
126 #define PROPERTYHANDLE_DOCWARN_PRINT 7
127 #define PROPERTYHANDLE_DOCWARN_CREATEPDF 8
128 #define PROPERTYHANDLE_DOCWARN_REMOVEPERSONALINFO 9
129 #define PROPERTYHANDLE_DOCWARN_RECOMMENDPASSWORD 10
130 #define PROPERTYHANDLE_CTRLCLICK_HYPERLINK 11
131 #define PROPERTYHANDLE_MACRO_SECLEVEL 12
132 #define PROPERTYHANDLE_MACRO_TRUSTEDAUTHORS 13
133 #define PROPERTYHANDLE_MACRO_DISABLE 14
135 #define PROPERTYCOUNT 15
136 #define PROPERTYHANDLE_INVALID -1
138 #define CFG_READONLY_DEFAULT sal_False
140 //_________________________________________________________________________________________________________________
141 // private declarations!
142 //_________________________________________________________________________________________________________________
144 class SvtSecurityOptions_Impl : public ConfigItem
146 //-------------------------------------------------------------------------------------------------------------
147 // public methods
148 //-------------------------------------------------------------------------------------------------------------
150 public:
152 //---------------------------------------------------------------------------------------------------------
153 // constructor / destructor
154 //---------------------------------------------------------------------------------------------------------
156 SvtSecurityOptions_Impl();
157 ~SvtSecurityOptions_Impl();
159 //---------------------------------------------------------------------------------------------------------
160 // overloaded methods of baseclass
161 //---------------------------------------------------------------------------------------------------------
163 /*-****************************************************************************************************//**
164 @short called for notify of configmanager
165 @descr These method is called from the ConfigManager before application ends or from the
166 PropertyChangeListener if the sub tree broadcasts changes. You must update your
167 internal values.
169 @seealso baseclass ConfigItem
171 @param "seqPropertyNames" is the list of properties which should be updated.
172 @return -
174 @onerror -
175 *//*-*****************************************************************************************************/
177 virtual void Notify( const Sequence< OUString >& seqPropertyNames );
179 /*-****************************************************************************************************//**
180 @short write changes to configuration
181 @descr These method writes the changed values into the sub tree
182 and should always called in our destructor to guarantee consistency of config data.
184 @seealso baseclass ConfigItem
186 @param -
187 @return -
189 @onerror -
190 *//*-*****************************************************************************************************/
192 virtual void Commit();
194 //---------------------------------------------------------------------------------------------------------
195 // public interface
196 //---------------------------------------------------------------------------------------------------------
198 sal_Bool IsReadOnly ( SvtSecurityOptions::EOption eOption ) const ;
200 Sequence< OUString > GetSecureURLs ( ) const ;
201 void SetSecureURLs ( const Sequence< OUString >& seqURLList ) ;
202 sal_Bool IsSecureURL ( const OUString& sURL,
203 const OUString& sReferer ) const ;
204 inline sal_Int32 GetMacroSecurityLevel ( ) const ;
205 void SetMacroSecurityLevel ( sal_Int32 _nLevel ) ;
207 inline sal_Bool IsMacroDisabled ( ) const ;
209 Sequence< SvtSecurityOptions::Certificate > GetTrustedAuthors ( ) const ;
210 void SetTrustedAuthors ( const Sequence< SvtSecurityOptions::Certificate >& rAuthors ) ;
211 sal_Bool IsTrustedAuthorsEnabled ( ) ;
213 sal_Bool IsOptionSet ( SvtSecurityOptions::EOption eOption ) const ;
214 sal_Bool SetOption ( SvtSecurityOptions::EOption eOption, sal_Bool bValue ) ;
215 sal_Bool IsOptionEnabled ( SvtSecurityOptions::EOption eOption ) const ;
216 private:
218 /*-****************************************************************************************************//**
219 @short return list of key names of ouer configuration management which represent our module tree
220 @descr These methods return a static const list of key names. We need it to get needed values from our
221 configuration management.
223 @seealso -
225 @param -
226 @return A list of needed configuration keys is returned.
228 @onerror -
229 *//*-*****************************************************************************************************/
231 void SetProperty( sal_Int32 nHandle, const Any& rValue, sal_Bool bReadOnly );
232 void LoadAuthors( void );
233 static sal_Int32 GetHandle( const OUString& rPropertyName );
234 bool GetOption( SvtSecurityOptions::EOption eOption, sal_Bool*& rpValue, sal_Bool*& rpRO );
236 static Sequence< OUString > GetPropertyNames();
238 Sequence< OUString > m_seqSecureURLs;
239 sal_Bool m_bSaveOrSend;
240 sal_Bool m_bSigning;
241 sal_Bool m_bPrint;
242 sal_Bool m_bCreatePDF;
243 sal_Bool m_bRemoveInfo;
244 sal_Bool m_bRecommendPwd;
245 sal_Bool m_bCtrlClickHyperlink;
246 sal_Int32 m_nSecLevel;
247 Sequence< SvtSecurityOptions::Certificate > m_seqTrustedAuthors;
248 sal_Bool m_bDisableMacros;
250 sal_Bool m_bROSecureURLs;
251 sal_Bool m_bROSaveOrSend;
252 sal_Bool m_bROSigning;
253 sal_Bool m_bROPrint;
254 sal_Bool m_bROCreatePDF;
255 sal_Bool m_bRORemoveInfo;
256 sal_Bool m_bRORecommendPwd;
257 sal_Bool m_bROCtrlClickHyperlink;
258 sal_Bool m_bROSecLevel;
259 sal_Bool m_bROTrustedAuthors;
260 sal_Bool m_bRODisableMacros;
263 // xmlsec05 depricated
264 EBasicSecurityMode m_eBasicMode;
265 sal_Bool m_bExecutePlugins;
266 sal_Bool m_bWarning;
267 sal_Bool m_bConfirmation;
269 sal_Bool m_bROConfirmation;
270 sal_Bool m_bROWarning;
271 sal_Bool m_bROExecutePlugins;
272 sal_Bool m_bROBasicMode;
273 public:
274 sal_Bool IsWarningEnabled() const;
275 void SetWarningEnabled( sal_Bool bSet );
276 sal_Bool IsConfirmationEnabled() const;
277 void SetConfirmationEnabled( sal_Bool bSet );
278 sal_Bool IsExecutePlugins() const;
279 void SetExecutePlugins( sal_Bool bSet );
280 EBasicSecurityMode GetBasicMode ( ) const ;
281 void SetBasicMode ( EBasicSecurityMode eMode ) ;
284 //_________________________________________________________________________________________________________________
285 // definitions
286 //_________________________________________________________________________________________________________________
288 //*****************************************************************************************************************
289 // constructor
290 //*****************************************************************************************************************
291 SvtSecurityOptions_Impl::SvtSecurityOptions_Impl()
292 :ConfigItem ( ROOTNODE_SECURITY )
293 ,m_seqSecureURLs ( DEFAULT_SECUREURL )
294 ,m_bSaveOrSend ( sal_True )
295 ,m_bSigning ( sal_True )
296 ,m_bPrint ( sal_True )
297 ,m_bCreatePDF ( sal_True )
298 ,m_bRemoveInfo ( sal_True )
299 ,m_nSecLevel ( sal_True )
300 ,m_seqTrustedAuthors ( DEFAULT_TRUSTEDAUTHORS )
301 ,m_bDisableMacros ( sal_False )
302 ,m_bROSecureURLs ( CFG_READONLY_DEFAULT )
303 ,m_bROSaveOrSend ( CFG_READONLY_DEFAULT )
304 ,m_bROSigning ( CFG_READONLY_DEFAULT )
305 ,m_bROPrint ( CFG_READONLY_DEFAULT )
306 ,m_bROCreatePDF ( CFG_READONLY_DEFAULT )
307 ,m_bRORemoveInfo ( CFG_READONLY_DEFAULT )
308 ,m_bROSecLevel ( CFG_READONLY_DEFAULT )
309 ,m_bROTrustedAuthors ( CFG_READONLY_DEFAULT )
310 ,m_bRODisableMacros ( sal_True ) // currently is not intended to be changed
312 // xmlsec05 depricated
313 , m_eBasicMode ( DEFAULT_STAROFFICEBASIC )
314 , m_bExecutePlugins ( sal_True )
315 , m_bWarning ( sal_True )
316 , m_bConfirmation ( sal_True )
317 , m_bROConfirmation ( CFG_READONLY_DEFAULT )
318 , m_bROWarning ( CFG_READONLY_DEFAULT )
319 , m_bROExecutePlugins ( CFG_READONLY_DEFAULT )
320 , m_bROBasicMode ( CFG_READONLY_DEFAULT )
321 // xmlsec05 depricated
324 Sequence< OUString > seqNames = GetPropertyNames ( );
325 Sequence< Any > seqValues = GetProperties ( seqNames );
326 Sequence< sal_Bool > seqRO = GetReadOnlyStates ( seqNames );
328 // Safe impossible cases.
329 // We need values from ALL configuration keys.
330 // Follow assignment use order of values in relation to our list of key names!
331 DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtSecurityOptions_Impl::SvtSecurityOptions_Impl()\nI miss some values of configuration keys!\n" );
333 // Copy values from list in right order to our internal member.
334 sal_Int32 nPropertyCount = seqValues.getLength();
335 for( sal_Int32 nProperty = 0 ; nProperty < nPropertyCount ; ++nProperty )
336 SetProperty( nProperty, seqValues[ nProperty ], seqRO[ nProperty ] );
338 LoadAuthors();
340 // Enable notification mechanism of our baseclass.
341 // We need it to get information about changes outside these class on our used configuration keys!*/
343 EnableNotification( seqNames );
346 //*****************************************************************************************************************
347 // destructor
348 //*****************************************************************************************************************
349 SvtSecurityOptions_Impl::~SvtSecurityOptions_Impl()
351 if( IsModified() )
352 Commit();
355 void SvtSecurityOptions_Impl::SetProperty( sal_Int32 nProperty, const Any& rValue, sal_Bool bRO )
357 switch( nProperty )
359 case PROPERTYHANDLE_SECUREURL:
361 m_seqSecureURLs.realloc( 0 );
362 rValue >>= m_seqSecureURLs;
363 SvtPathOptions aOpt;
364 sal_uInt32 nCount = m_seqSecureURLs.getLength();
365 for( sal_uInt32 nItem = 0 ; nItem < nCount ; ++nItem )
366 m_seqSecureURLs[ nItem ] = aOpt.SubstituteVariable( m_seqSecureURLs[ nItem ] );
367 m_bROSecureURLs = bRO;
369 break;
371 case PROPERTYHANDLE_DOCWARN_SAVEORSEND:
373 rValue >>= m_bSaveOrSend;
374 m_bROSaveOrSend = bRO;
376 break;
378 case PROPERTYHANDLE_DOCWARN_SIGNING:
380 rValue >>= m_bSigning;
381 m_bROSigning = bRO;
383 break;
385 case PROPERTYHANDLE_DOCWARN_PRINT:
387 rValue >>= m_bPrint;
388 m_bROPrint = bRO;
390 break;
392 case PROPERTYHANDLE_DOCWARN_CREATEPDF:
394 rValue >>= m_bCreatePDF;
395 m_bROCreatePDF = bRO;
397 break;
399 case PROPERTYHANDLE_DOCWARN_REMOVEPERSONALINFO:
401 rValue >>= m_bRemoveInfo;
402 m_bRORemoveInfo = bRO;
404 break;
406 case PROPERTYHANDLE_DOCWARN_RECOMMENDPASSWORD:
408 rValue >>= m_bRecommendPwd;
409 m_bRORecommendPwd = bRO;
411 break;
413 case PROPERTYHANDLE_CTRLCLICK_HYPERLINK:
415 rValue >>= m_bCtrlClickHyperlink;
416 m_bROCtrlClickHyperlink = bRO;
418 break;
420 case PROPERTYHANDLE_MACRO_SECLEVEL:
422 rValue >>= m_nSecLevel;
423 m_bROSecLevel = bRO;
425 break;
427 case PROPERTYHANDLE_MACRO_TRUSTEDAUTHORS:
429 // don't care about value here...
430 m_bROTrustedAuthors = bRO;
432 break;
434 case PROPERTYHANDLE_MACRO_DISABLE:
436 rValue >>= m_bDisableMacros;
437 m_bRODisableMacros = bRO;
439 break;
442 // xmlsec05 depricated
443 case PROPERTYHANDLE_STAROFFICEBASIC:
445 sal_Int32 nMode = 0;
446 rValue >>= nMode;
447 m_eBasicMode = (EBasicSecurityMode)nMode;
448 m_bROBasicMode = bRO;
450 break;
451 case PROPERTYHANDLE_EXECUTEPLUGINS:
453 rValue >>= m_bExecutePlugins;
454 m_bROExecutePlugins = bRO;
456 break;
457 case PROPERTYHANDLE_WARNINGENABLED:
459 rValue >>= m_bWarning;
460 m_bROWarning = bRO;
462 break;
463 case PROPERTYHANDLE_CONFIRMATIONENABLED:
465 rValue >>= m_bConfirmation;
466 m_bROConfirmation = bRO;
468 break;
469 // xmlsec05 depricated
472 #if OSL_DEBUG_LEVEL > 1
473 default:
474 DBG_ASSERT( false, "SvtSecurityOptions_Impl::SetProperty()\nUnkown property!\n" );
475 #endif
479 void SvtSecurityOptions_Impl::LoadAuthors( void )
481 m_seqTrustedAuthors.realloc( 0 ); // first clear
482 Sequence< OUString > lAuthors = GetNodeNames( PROPERTYNAME_MACRO_TRUSTEDAUTHORS );
483 sal_Int32 c1 = lAuthors.getLength();
484 if( c1 )
486 sal_Int32 c2 = c1 * 3; // 3 Properties inside Struct TrustedAuthor
487 Sequence< OUString > lAllAuthors( c2 );
489 sal_Int32 i1;
490 sal_Int32 i2;
491 OUString aSep( RTL_CONSTASCII_USTRINGPARAM( "/" ) );
492 for( i1 = 0, i2 = 0 ; i1 < c1 ; ++i1 )
494 lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + lAuthors[ i1 ] + aSep + PROPERTYNAME_TRUSTEDAUTHOR_SUBJECTNAME;
495 ++i2;
496 lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + lAuthors[ i1 ] + aSep + PROPERTYNAME_TRUSTEDAUTHOR_SERIALNUMBER;
497 ++i2;
498 lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + lAuthors[ i1 ] + aSep + PROPERTYNAME_TRUSTEDAUTHOR_RAWDATA;
499 ++i2;
502 Sequence< Any > lValues = GetProperties( lAllAuthors );
503 if( lValues.getLength() == c2 )
505 m_seqTrustedAuthors.realloc( c1 );
506 SvtSecurityOptions::Certificate aCert( 3 );
507 for( i1 = 0, i2 = 0 ; i1 < c1 ; ++i1 )
509 lValues[ i2 ] >>= aCert[ 0 ];
510 ++i2;
511 lValues[ i2 ] >>= aCert[ 1 ];
512 ++i2;
513 lValues[ i2 ] >>= aCert[ 2 ];
514 ++i2;
515 m_seqTrustedAuthors[ i1 ] = aCert;
521 sal_Int32 SvtSecurityOptions_Impl::GetHandle( const OUString& rName )
523 sal_Int32 nHandle;
525 if( rName.compareToAscii( CSTR_SECUREURL ) == 0 )
526 nHandle = PROPERTYHANDLE_SECUREURL;
527 else if( rName.compareToAscii( CSTR_DOCWARN_SAVEORSEND ) == 0 )
528 nHandle = PROPERTYHANDLE_DOCWARN_SAVEORSEND;
529 else if( rName.compareToAscii( CSTR_DOCWARN_SIGNING ) == 0 )
530 nHandle = PROPERTYHANDLE_DOCWARN_SIGNING;
531 else if( rName.compareToAscii( CSTR_DOCWARN_PRINT ) == 0 )
532 nHandle = PROPERTYHANDLE_DOCWARN_PRINT;
533 else if( rName.compareToAscii( CSTR_DOCWARN_CREATEPDF ) == 0 )
534 nHandle = PROPERTYHANDLE_DOCWARN_CREATEPDF;
535 else if( rName.compareToAscii( CSTR_DOCWARN_REMOVEPERSONALINFO ) == 0 )
536 nHandle = PROPERTYHANDLE_DOCWARN_REMOVEPERSONALINFO;
537 else if( rName.compareToAscii( CSTR_DOCWARN_RECOMMENDPASSWORD ) == 0 )
538 nHandle = PROPERTYHANDLE_DOCWARN_RECOMMENDPASSWORD;
539 else if( rName.compareToAscii( CSTR_CTRLCLICK_HYPERLINK ) == 0 )
540 nHandle = PROPERTYHANDLE_CTRLCLICK_HYPERLINK;
541 else if( rName.compareToAscii( CSTR_MACRO_SECLEVEL ) == 0 )
542 nHandle = PROPERTYHANDLE_MACRO_SECLEVEL;
543 else if( rName.compareToAscii( CSTR_MACRO_TRUSTEDAUTHORS ) == 0 )
544 nHandle = PROPERTYHANDLE_MACRO_TRUSTEDAUTHORS;
545 else if( rName.compareToAscii( CSTR_MACRO_DISABLE ) == 0 )
546 nHandle = PROPERTYHANDLE_MACRO_DISABLE;
548 // xmlsec05 depricated
549 else if( rName == PROPERTYNAME_STAROFFICEBASIC )
550 nHandle = PROPERTYHANDLE_STAROFFICEBASIC;
551 else if( rName == PROPERTYNAME_EXECUTEPLUGINS )
552 nHandle = PROPERTYHANDLE_EXECUTEPLUGINS;
553 else if( rName == PROPERTYNAME_WARNINGENABLED )
554 nHandle = PROPERTYHANDLE_WARNINGENABLED;
555 else if( rName == PROPERTYNAME_CONFIRMATIONENABLED )
556 nHandle = PROPERTYHANDLE_CONFIRMATIONENABLED;
557 // xmlsec05 depricated
559 else
560 nHandle = PROPERTYHANDLE_INVALID;
562 return nHandle;
565 bool SvtSecurityOptions_Impl::GetOption( SvtSecurityOptions::EOption eOption, sal_Bool*& rpValue, sal_Bool*& rpRO )
567 switch( eOption )
569 case SvtSecurityOptions::E_DOCWARN_SAVEORSEND:
570 rpValue = &m_bSaveOrSend;
571 rpRO = &m_bROSaveOrSend;
572 break;
573 case SvtSecurityOptions::E_DOCWARN_SIGNING:
574 rpValue = &m_bSigning;
575 rpRO = &m_bROSigning;
576 break;
577 case SvtSecurityOptions::E_DOCWARN_PRINT:
578 rpValue = &m_bPrint;
579 rpRO = &m_bROPrint;
580 break;
581 case SvtSecurityOptions::E_DOCWARN_CREATEPDF:
582 rpValue = &m_bCreatePDF;
583 rpRO = &m_bROCreatePDF;
584 break;
585 case SvtSecurityOptions::E_DOCWARN_REMOVEPERSONALINFO:
586 rpValue = &m_bRemoveInfo;
587 rpRO = &m_bRORemoveInfo;
588 break;
589 case SvtSecurityOptions::E_DOCWARN_RECOMMENDPASSWORD:
590 rpValue = &m_bRecommendPwd;
591 rpRO = &m_bRORecommendPwd;
592 break;
593 case SvtSecurityOptions::E_CTRLCLICK_HYPERLINK:
594 rpValue = &m_bCtrlClickHyperlink;
595 rpRO = &m_bROCtrlClickHyperlink;
596 break;
597 default:
598 rpValue = NULL;
599 rpRO = NULL;
600 break;
603 return rpValue != NULL;
606 void SvtSecurityOptions_Impl::Notify( const Sequence< OUString >& seqPropertyNames )
608 // Use given list of updated properties to get his values from configuration directly!
609 Sequence< Any > seqValues = GetProperties( seqPropertyNames );
610 Sequence< sal_Bool > seqRO = GetReadOnlyStates( seqPropertyNames );
611 // Safe impossible cases.
612 // We need values from ALL notified configuration keys.
613 DBG_ASSERT( !(seqPropertyNames.getLength()!=seqValues.getLength()), "SvtSecurityOptions_Impl::Notify()\nI miss some values of configuration keys!\n" );
614 // Step over list of property names and get right value from coreesponding value list to set it on internal members!
615 sal_Int32 nCount = seqPropertyNames.getLength();
616 for( sal_Int32 nProperty = 0 ; nProperty < nCount ; ++nProperty )
617 SetProperty( GetHandle( seqPropertyNames[ nProperty ] ), seqValues[ nProperty ], seqRO[ nProperty ] );
619 // read set of trusted authors separately
620 LoadAuthors();
623 void SvtSecurityOptions_Impl::Commit()
625 // Get names of supported properties, create a list for values and copy current values to it.
626 Sequence< OUString > lOrgNames = GetPropertyNames();
627 sal_Int32 nOrgCount = lOrgNames.getLength();
629 Sequence< OUString > lNames(nOrgCount);
630 Sequence< Any > lValues(nOrgCount);
631 sal_Int32 nRealCount = 0;
632 bool bDone;
634 ClearNodeSet( PROPERTYNAME_MACRO_TRUSTEDAUTHORS );
636 for( sal_Int32 nProperty = 0 ; nProperty < nOrgCount ; ++nProperty )
638 switch( nProperty )
640 case PROPERTYHANDLE_SECUREURL:
642 bDone = !m_bROSecureURLs;
643 if( bDone )
645 Sequence< OUString > lURLs( m_seqSecureURLs );
646 SvtPathOptions aOpt;
647 sal_Int32 nURLsCnt = lURLs.getLength();
648 for( sal_Int32 nItem = 0 ; nItem < nURLsCnt ; ++nItem )
649 lURLs[ nItem ] = aOpt.UseVariable( lURLs[ nItem ] );
650 lValues[ nRealCount ] <<= lURLs;
653 break;
655 case PROPERTYHANDLE_DOCWARN_SAVEORSEND:
657 bDone = !m_bROSaveOrSend;
658 if( bDone )
659 lValues[ nRealCount ] <<= m_bSaveOrSend;
661 break;
663 case PROPERTYHANDLE_DOCWARN_SIGNING:
665 bDone = !m_bROSigning;
666 if( bDone )
667 lValues[ nRealCount ] <<= m_bSigning;
669 break;
671 case PROPERTYHANDLE_DOCWARN_PRINT:
673 bDone = !m_bROPrint;
674 if( bDone )
675 lValues[ nRealCount ] <<= m_bPrint;
677 break;
679 case PROPERTYHANDLE_DOCWARN_CREATEPDF:
681 bDone = !m_bROCreatePDF;
682 if( bDone )
683 lValues[ nRealCount ] <<= m_bCreatePDF;
685 break;
687 case PROPERTYHANDLE_DOCWARN_REMOVEPERSONALINFO:
689 bDone = !m_bRORemoveInfo;
690 if( bDone )
691 lValues[ nRealCount ] <<= m_bRemoveInfo;
693 break;
695 case PROPERTYHANDLE_DOCWARN_RECOMMENDPASSWORD:
697 bDone = !m_bRORecommendPwd;
698 if( bDone )
699 lValues[ nRealCount ] <<= m_bRecommendPwd;
701 break;
703 case PROPERTYHANDLE_CTRLCLICK_HYPERLINK:
705 bDone = !m_bROCtrlClickHyperlink;
706 if( bDone )
707 lValues[ nRealCount ] <<= m_bCtrlClickHyperlink;
709 break;
711 case PROPERTYHANDLE_MACRO_SECLEVEL:
713 bDone = !m_bROSecLevel;
714 if( bDone )
715 lValues[ nRealCount ] <<= m_nSecLevel;
717 break;
719 case PROPERTYHANDLE_MACRO_TRUSTEDAUTHORS:
721 bDone = !m_bROTrustedAuthors;
722 if( bDone )
724 sal_Int32 nCnt = m_seqTrustedAuthors.getLength();
725 if( nCnt )
727 String s;
728 s.AppendAscii( CSTR_MACRO_TRUSTEDAUTHORS );
729 s.AppendAscii( "/a" );
731 Sequence< Sequence< com::sun::star::beans::PropertyValue > > lPropertyValuesSeq( nCnt );
732 for( sal_Int32 i = 0 ; i < nCnt ; ++i )
734 String aPrefix( s );
735 aPrefix += String::CreateFromInt32( i );
736 aPrefix.AppendAscii( "/" );
737 Sequence< com::sun::star::beans::PropertyValue > lPropertyValues( 3 );
738 lPropertyValues[ 0 ].Name = aPrefix + PROPERTYNAME_TRUSTEDAUTHOR_SUBJECTNAME;
739 lPropertyValues[ 0 ].Value <<= m_seqTrustedAuthors[ i ][0];
740 lPropertyValues[ 1 ].Name = aPrefix + PROPERTYNAME_TRUSTEDAUTHOR_SERIALNUMBER;
741 lPropertyValues[ 1 ].Value <<= m_seqTrustedAuthors[ i ][1];
742 lPropertyValues[ 2 ].Name = aPrefix + PROPERTYNAME_TRUSTEDAUTHOR_RAWDATA;
743 lPropertyValues[ 2 ].Value <<= m_seqTrustedAuthors[ i ][2];
746 SetSetProperties( PROPERTYNAME_MACRO_TRUSTEDAUTHORS, lPropertyValues );
749 bDone = false; // because we save in loop above!
751 else
752 bDone = false;
755 break;
757 case PROPERTYHANDLE_MACRO_DISABLE:
759 bDone = !m_bRODisableMacros;
760 if( bDone )
761 lValues[ nRealCount ] <<= (sal_Bool)m_bDisableMacros;
763 break;
766 // xmlsec05 depricated
767 case PROPERTYHANDLE_STAROFFICEBASIC:
769 bDone = !m_bROBasicMode;
770 if( bDone )
771 lValues[ nRealCount ] <<= (sal_Int32)m_eBasicMode;
773 break;
774 case PROPERTYHANDLE_EXECUTEPLUGINS:
776 bDone = !m_bROExecutePlugins;
777 if( bDone )
778 lValues[ nRealCount ] <<= m_bExecutePlugins;
780 break;
781 case PROPERTYHANDLE_WARNINGENABLED:
783 bDone = !m_bROWarning;
784 if( bDone )
785 lValues[ nRealCount ] <<= m_bWarning;
787 break;
788 case PROPERTYHANDLE_CONFIRMATIONENABLED:
790 bDone = !m_bROConfirmation;
791 if( bDone )
792 lValues[ nRealCount ] <<= m_bConfirmation;
794 break;
795 // xmlsec05 depricated
798 default:
799 bDone = false;
802 if( bDone )
804 lNames[ nRealCount ] = lOrgNames[ nProperty ];
805 ++nRealCount;
808 // Set properties in configuration.
809 lNames.realloc(nRealCount);
810 lValues.realloc(nRealCount);
811 PutProperties( lNames, lValues );
814 sal_Bool SvtSecurityOptions_Impl::IsReadOnly( SvtSecurityOptions::EOption eOption ) const
816 sal_Bool bReadonly;
817 switch(eOption)
819 case SvtSecurityOptions::E_SECUREURLS :
820 bReadonly = m_bROSecureURLs;
821 break;
822 case SvtSecurityOptions::E_DOCWARN_SAVEORSEND:
823 bReadonly = m_bROSaveOrSend;
824 break;
825 case SvtSecurityOptions::E_DOCWARN_SIGNING:
826 bReadonly = m_bROSigning;
827 break;
828 case SvtSecurityOptions::E_DOCWARN_PRINT:
829 bReadonly = m_bROPrint;
830 break;
831 case SvtSecurityOptions::E_DOCWARN_CREATEPDF:
832 bReadonly = m_bROCreatePDF;
833 break;
834 case SvtSecurityOptions::E_DOCWARN_REMOVEPERSONALINFO:
835 bReadonly = m_bRORemoveInfo;
836 break;
837 case SvtSecurityOptions::E_DOCWARN_RECOMMENDPASSWORD:
838 bReadonly = m_bRORecommendPwd;
839 break;
840 case SvtSecurityOptions::E_MACRO_SECLEVEL:
841 bReadonly = m_bROSecLevel;
842 break;
843 case SvtSecurityOptions::E_MACRO_TRUSTEDAUTHORS:
844 bReadonly = m_bROTrustedAuthors;
845 break;
846 case SvtSecurityOptions::E_MACRO_DISABLE:
847 bReadonly = m_bRODisableMacros;
848 break;
849 case SvtSecurityOptions::E_CTRLCLICK_HYPERLINK:
850 bReadonly = m_bROCtrlClickHyperlink;
851 break;
854 // xmlsec05 depricated
855 case SvtSecurityOptions::E_BASICMODE:
856 bReadonly = m_bROBasicMode;
857 break;
858 case SvtSecurityOptions::E_EXECUTEPLUGINS:
859 bReadonly = m_bROExecutePlugins;
860 break;
861 case SvtSecurityOptions::E_WARNING:
862 bReadonly = m_bROWarning;
863 break;
864 case SvtSecurityOptions::E_CONFIRMATION:
865 bReadonly = m_bROConfirmation;
866 break;
867 // xmlsec05 depricated
870 default:
871 bReadonly = sal_True;
874 return bReadonly;
877 Sequence< OUString > SvtSecurityOptions_Impl::GetSecureURLs() const
879 return m_seqSecureURLs;
882 void SvtSecurityOptions_Impl::SetSecureURLs( const Sequence< OUString >& seqURLList )
884 DBG_ASSERT(!m_bROSecureURLs, "SvtSecurityOptions_Impl::SetSecureURLs()\nYou tried to write on a readonly value!\n");
885 if (!m_bROSecureURLs && m_seqSecureURLs!=seqURLList)
887 m_seqSecureURLs = seqURLList;
888 SetModified();
892 sal_Bool SvtSecurityOptions_Impl::IsSecureURL( const OUString& sURL ,
893 const OUString& sReferer) const
895 sal_Bool bState = sal_False;
897 // Check for uncritical protocols first
898 // All protocols different from "macro..." and "slot..." are secure per definition and must not be checked.
899 // "macro://#..." means AppBasic macros that are considered safe
900 INetURLObject aURL ( sURL );
901 INetProtocol aProtocol = aURL.GetProtocol();
903 // All other URLs must checked in combination with referer and internal information about security
904 if ( (aProtocol != INET_PROT_MACRO && aProtocol != INET_PROT_SLOT) ||
905 aURL.GetMainURL( INetURLObject::NO_DECODE ).matchIgnoreAsciiCaseAsciiL( "macro:///", 9 ) == 0)
907 // security check only for "macro" ( without app basic ) or "slot" protocols
908 bState = sal_True;
910 else
912 // check list of allowed URL patterns
913 // Trusted referer given?
914 // NO => bState will be false per default
915 // YES => search for it in our internal url list
916 if( sReferer.getLength() > 0 )
918 // Search in internal list
919 ::rtl::OUString sRef = sReferer.toAsciiLowerCase();
920 sal_uInt32 nCount = m_seqSecureURLs.getLength();
921 for( sal_uInt32 nItem=0; nItem<nCount; ++nItem )
923 OUString sCheckURL = m_seqSecureURLs[nItem].toAsciiLowerCase();
924 sCheckURL += OUString(RTL_CONSTASCII_USTRINGPARAM("*"));
925 if( WildCard( sCheckURL ).Matches( sRef ) == sal_True )
927 bState = sal_True;
928 break;
932 if ( !bState )
933 bState = sRef.compareToAscii("private:user") == COMPARE_EQUAL;
937 // Return result of operation.
938 return bState;
941 inline sal_Int32 SvtSecurityOptions_Impl::GetMacroSecurityLevel() const
943 return m_nSecLevel;
946 inline sal_Bool SvtSecurityOptions_Impl::IsMacroDisabled() const
948 return m_bDisableMacros;
951 void SvtSecurityOptions_Impl::SetMacroSecurityLevel( sal_Int32 _nLevel )
953 if( !m_bROSecLevel )
955 if( _nLevel > 3 || _nLevel < 0 )
956 _nLevel = 3;
958 if( m_nSecLevel != _nLevel )
960 m_nSecLevel = _nLevel;
961 SetModified();
966 Sequence< SvtSecurityOptions::Certificate > SvtSecurityOptions_Impl::GetTrustedAuthors() const
968 return m_seqTrustedAuthors;
971 void SvtSecurityOptions_Impl::SetTrustedAuthors( const Sequence< SvtSecurityOptions::Certificate >& rAuthors )
973 DBG_ASSERT(!m_bROTrustedAuthors, "SvtSecurityOptions_Impl::SetTrustedAuthors()\nYou tried to write on a readonly value!\n");
974 if( !m_bROTrustedAuthors && rAuthors != m_seqTrustedAuthors )
976 m_seqTrustedAuthors = rAuthors;
977 SetModified();
981 sal_Bool SvtSecurityOptions_Impl::IsTrustedAuthorsEnabled()
983 return m_bROTrustedAuthors;
986 sal_Bool SvtSecurityOptions_Impl::IsOptionSet( SvtSecurityOptions::EOption eOption ) const
988 sal_Bool* pValue;
989 sal_Bool* pRO;
990 sal_Bool bRet = sal_False;
992 if( ( const_cast< SvtSecurityOptions_Impl* >( this ) )->GetOption( eOption, pValue, pRO ) )
993 bRet = *pValue;
995 return bRet;
998 sal_Bool SvtSecurityOptions_Impl::SetOption( SvtSecurityOptions::EOption eOption, sal_Bool bValue )
1000 sal_Bool* pValue;
1001 sal_Bool* pRO;
1002 sal_Bool bRet = sal_False;
1004 if( GetOption( eOption, pValue, pRO ) )
1006 if( !*pRO )
1008 bRet = sal_True;
1009 if( *pValue != bValue )
1011 *pValue = bValue;
1012 SetModified();
1017 return bRet;
1020 sal_Bool SvtSecurityOptions_Impl::IsOptionEnabled( SvtSecurityOptions::EOption eOption ) const
1022 sal_Bool* pValue;
1023 sal_Bool* pRO;
1024 sal_Bool bRet = sal_False;
1026 if( ( const_cast< SvtSecurityOptions_Impl* >( this ) )->GetOption( eOption, pValue, pRO ) )
1027 bRet = !*pRO;
1029 return bRet;
1032 Sequence< OUString > SvtSecurityOptions_Impl::GetPropertyNames()
1034 // Build static list of configuration key names.
1035 static const OUString pProperties[] =
1037 PROPERTYNAME_SECUREURL,
1038 PROPERTYNAME_STAROFFICEBASIC,
1039 PROPERTYNAME_EXECUTEPLUGINS,
1040 PROPERTYNAME_WARNINGENABLED,
1041 PROPERTYNAME_CONFIRMATIONENABLED,
1042 PROPERTYNAME_DOCWARN_SAVEORSEND,
1043 PROPERTYNAME_DOCWARN_SIGNING,
1044 PROPERTYNAME_DOCWARN_PRINT,
1045 PROPERTYNAME_DOCWARN_CREATEPDF,
1046 PROPERTYNAME_DOCWARN_REMOVEPERSONALINFO,
1047 PROPERTYNAME_DOCWARN_RECOMMENDPASSWORD,
1048 PROPERTYNAME_CTRLCLICK_HYPERLINK,
1049 PROPERTYNAME_MACRO_SECLEVEL,
1050 PROPERTYNAME_MACRO_TRUSTEDAUTHORS,
1051 PROPERTYNAME_MACRO_DISABLE
1053 // Initialize return sequence with these list ...
1054 static const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT );
1055 // ... and return it.
1056 return seqPropertyNames;
1059 //*****************************************************************************************************************
1060 // initialize static member
1061 // DON'T DO IT IN YOUR HEADER!
1062 // see definition for further informations
1063 //*****************************************************************************************************************
1064 SvtSecurityOptions_Impl* SvtSecurityOptions::m_pDataContainer = NULL ;
1065 sal_Int32 SvtSecurityOptions::m_nRefCount = 0 ;
1067 SvtSecurityOptions::SvtSecurityOptions()
1069 // Global access, must be guarded (multithreading!).
1070 MutexGuard aGuard( GetInitMutex() );
1071 // Increase ouer refcount ...
1072 ++m_nRefCount;
1073 // ... and initialize ouer data container only if it not already exist!
1074 if( m_pDataContainer == NULL )
1076 RTL_LOGFILE_CONTEXT(aLog, "svtools ( ??? ) ::SvtSecurityOptions_Impl::ctor()");
1077 m_pDataContainer = new SvtSecurityOptions_Impl;
1079 ItemHolder1::holdConfigItem(E_SECURITYOPTIONS);
1083 SvtSecurityOptions::~SvtSecurityOptions()
1085 // Global access, must be guarded (multithreading!)
1086 MutexGuard aGuard( GetInitMutex() );
1087 // Decrease ouer refcount.
1088 --m_nRefCount;
1089 // If last instance was deleted ...
1090 // we must destroy ouer static data container!
1091 if( m_nRefCount <= 0 )
1093 delete m_pDataContainer;
1094 m_pDataContainer = NULL;
1098 sal_Bool SvtSecurityOptions::IsReadOnly( EOption eOption ) const
1100 MutexGuard aGuard( GetInitMutex() );
1101 return m_pDataContainer->IsReadOnly(eOption);
1104 Sequence< OUString > SvtSecurityOptions::GetSecureURLs() const
1106 MutexGuard aGuard( GetInitMutex() );
1107 return m_pDataContainer->GetSecureURLs();
1110 void SvtSecurityOptions::SetSecureURLs( const Sequence< OUString >& seqURLList )
1112 MutexGuard aGuard( GetInitMutex() );
1113 m_pDataContainer->SetSecureURLs( seqURLList );
1116 sal_Bool SvtSecurityOptions::IsSecureURL( const OUString& sURL ,
1117 const OUString& sReferer ) const
1119 MutexGuard aGuard( GetInitMutex() );
1120 return m_pDataContainer->IsSecureURL( sURL, sReferer );
1123 sal_Int32 SvtSecurityOptions::GetMacroSecurityLevel() const
1125 MutexGuard aGuard( GetInitMutex() );
1126 return m_pDataContainer->GetMacroSecurityLevel();
1129 void SvtSecurityOptions::SetMacroSecurityLevel( sal_Int32 _nLevel )
1131 MutexGuard aGuard( GetInitMutex() );
1132 m_pDataContainer->SetMacroSecurityLevel( _nLevel );
1135 sal_Bool SvtSecurityOptions::IsMacroDisabled() const
1137 MutexGuard aGuard( GetInitMutex() );
1138 return m_pDataContainer->IsMacroDisabled();
1141 Sequence< SvtSecurityOptions::Certificate > SvtSecurityOptions::GetTrustedAuthors() const
1143 MutexGuard aGuard( GetInitMutex() );
1144 return m_pDataContainer->GetTrustedAuthors();
1147 void SvtSecurityOptions::SetTrustedAuthors( const Sequence< Certificate >& rAuthors )
1149 MutexGuard aGuard( GetInitMutex() );
1150 m_pDataContainer->SetTrustedAuthors( rAuthors );
1153 sal_Bool SvtSecurityOptions::IsTrustedAuthorsEnabled()
1155 MutexGuard aGuard( GetInitMutex() );
1156 return m_pDataContainer->IsTrustedAuthorsEnabled();
1159 bool SvtSecurityOptions::IsOptionSet( EOption eOption ) const
1161 MutexGuard aGuard( GetInitMutex() );
1162 return m_pDataContainer->IsOptionSet( eOption );
1165 bool SvtSecurityOptions::SetOption( EOption eOption, bool bValue )
1167 MutexGuard aGuard( GetInitMutex() );
1168 return m_pDataContainer->SetOption( eOption, bValue );
1171 bool SvtSecurityOptions::IsOptionEnabled( EOption eOption ) const
1173 MutexGuard aGuard( GetInitMutex() );
1174 return m_pDataContainer->IsOptionEnabled( eOption );
1177 Mutex& SvtSecurityOptions::GetInitMutex()
1179 // Initialize static mutex only for one time!
1180 static Mutex* pMutex = NULL;
1181 // If these method first called (Mutex not already exist!) ...
1182 if( pMutex == NULL )
1184 // ... we must create a new one. Protect follow code with the global mutex -
1185 // It must be - we create a static variable!
1186 MutexGuard aGuard( Mutex::getGlobalMutex() );
1187 // We must check our pointer again - because it can be that another instance of ouer class will be faster then these!
1188 if( pMutex == NULL )
1190 // Create the new mutex and set it for return on static variable.
1191 static Mutex aMutex;
1192 pMutex = &aMutex;
1195 // Return new created or already existing mutex object.
1196 return *pMutex;
1202 // xmlsec05 depricated
1204 EBasicSecurityMode SvtSecurityOptions_Impl::GetBasicMode() const
1206 return m_eBasicMode;
1209 void SvtSecurityOptions_Impl::SetBasicMode( EBasicSecurityMode eMode )
1211 DBG_ASSERT(!m_bROBasicMode, "SvtSecurityOptions_Impl::SetBasicMode()\nYou tried to write on a readonly value!\n");
1212 if (!m_bROBasicMode && m_eBasicMode!=eMode)
1214 m_eBasicMode = eMode;
1215 SetModified();
1219 sal_Bool SvtSecurityOptions_Impl::IsExecutePlugins() const
1221 return m_bExecutePlugins;
1224 void SvtSecurityOptions_Impl::SetExecutePlugins( sal_Bool bSet )
1226 DBG_ASSERT(!m_bROExecutePlugins, "SvtSecurityOptions_Impl::SetExecutePlugins()\nYou tried to write on a readonly value!\n");
1227 if (!m_bROExecutePlugins && m_bExecutePlugins!=bSet)
1229 m_bExecutePlugins = bSet;
1230 SetModified();
1234 sal_Bool SvtSecurityOptions_Impl::IsWarningEnabled() const
1236 return m_bWarning;
1239 void SvtSecurityOptions_Impl::SetWarningEnabled( sal_Bool bSet )
1241 DBG_ASSERT(!m_bROWarning, "SvtSecurityOptions_Impl::SetWarningEnabled()\nYou tried to write on a readonly value!\n");
1242 if (!m_bROWarning && m_bWarning!=bSet)
1244 m_bWarning = bSet;
1245 SetModified();
1249 sal_Bool SvtSecurityOptions_Impl::IsConfirmationEnabled() const
1251 return m_bConfirmation;
1254 void SvtSecurityOptions_Impl::SetConfirmationEnabled( sal_Bool bSet )
1256 DBG_ASSERT(!m_bROConfirmation, "SvtSecurityOptions_Impl::SetConfirmationEnabled()\nYou tried to write on a readonly value!\n");
1257 if (!m_bROConfirmation && m_bConfirmation!=bSet)
1259 m_bConfirmation = bSet;
1260 SetModified();
1265 sal_Bool SvtSecurityOptions::IsExecutePlugins() const
1267 MutexGuard aGuard( GetInitMutex() );
1268 return m_pDataContainer->IsExecutePlugins();
1271 void SvtSecurityOptions::SetExecutePlugins( sal_Bool bSet )
1273 MutexGuard aGuard( GetInitMutex() );
1274 m_pDataContainer->SetExecutePlugins( bSet );
1277 sal_Bool SvtSecurityOptions::IsWarningEnabled() const
1279 MutexGuard aGuard( GetInitMutex() );
1280 return m_pDataContainer->IsWarningEnabled();
1283 void SvtSecurityOptions::SetWarningEnabled( sal_Bool bSet )
1285 MutexGuard aGuard( GetInitMutex() );
1286 m_pDataContainer->SetWarningEnabled( bSet );
1289 sal_Bool SvtSecurityOptions::IsConfirmationEnabled() const
1291 MutexGuard aGuard( GetInitMutex() );
1292 return m_pDataContainer->IsConfirmationEnabled();
1295 void SvtSecurityOptions::SetConfirmationEnabled( sal_Bool bSet )
1297 MutexGuard aGuard( GetInitMutex() );
1298 m_pDataContainer->SetConfirmationEnabled( bSet );
1301 void SvtSecurityOptions::SetBasicMode( EBasicSecurityMode eMode )
1303 MutexGuard aGuard( GetInitMutex() );
1304 m_pDataContainer->SetBasicMode( eMode );
1307 EBasicSecurityMode SvtSecurityOptions::GetBasicMode() const
1309 MutexGuard aGuard( GetInitMutex() );
1310 return m_pDataContainer->GetBasicMode();