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 <unotools/securityoptions.hxx>
21 : #include <unotools/configmgr.hxx>
22 : #include <unotools/configitem.hxx>
23 : #include <unotools/ucbhelper.hxx>
24 : #include <tools/debug.hxx>
25 : #include <com/sun/star/uno/Any.hxx>
26 : #include <com/sun/star/uno/Sequence.hxx>
27 :
28 : #include <com/sun/star/beans/PropertyValue.hpp>
29 : #include <comphelper/sequenceasvector.hxx>
30 : #include <tools/urlobj.hxx>
31 :
32 : #include <unotools/pathoptions.hxx>
33 :
34 : #include "itemholder1.hxx"
35 :
36 : // namespaces
37 :
38 : using namespace ::utl;
39 : using namespace ::osl;
40 : using namespace ::com::sun::star::uno;
41 :
42 : #define ROOTNODE_SECURITY OUString("Office.Common/Security/Scripting")
43 : #define DEFAULT_SECUREURL Sequence< OUString >()
44 : #define DEFAULT_TRUSTEDAUTHORS Sequence< SvtSecurityOptions::Certificate >()
45 :
46 : // xmlsec05 deprecated
47 : #define DEFAULT_STAROFFICEBASIC eALWAYS_EXECUTE
48 :
49 : #define PROPERTYNAME_SECUREURL "SecureURL"
50 : #define PROPERTYNAME_DOCWARN_SAVEORSEND "WarnSaveOrSendDoc"
51 : #define PROPERTYNAME_DOCWARN_SIGNING "WarnSignDoc"
52 : #define PROPERTYNAME_DOCWARN_PRINT "WarnPrintDoc"
53 : #define PROPERTYNAME_DOCWARN_CREATEPDF "WarnCreatePDF"
54 : #define PROPERTYNAME_DOCWARN_REMOVEPERSONALINFO "RemovePersonalInfoOnSaving"
55 : #define PROPERTYNAME_DOCWARN_RECOMMENDPASSWORD "RecommendPasswordProtection"
56 : #define PROPERTYNAME_CTRLCLICK_HYPERLINK "HyperlinksWithCtrlClick"
57 : #define PROPERTYNAME_BLOCKUNTRUSTEDREFERERLINKS "BlockUntrustedRefererLinks"
58 : #define PROPERTYNAME_MACRO_SECLEVEL "MacroSecurityLevel"
59 : #define PROPERTYNAME_MACRO_TRUSTEDAUTHORS "TrustedAuthors"
60 : #define PROPERTYNAME_MACRO_DISABLE "DisableMacrosExecution"
61 : #define PROPERTYNAME_TRUSTEDAUTHOR_SUBJECTNAME "SubjectName"
62 : #define PROPERTYNAME_TRUSTEDAUTHOR_SERIALNUMBER "SerialNumber"
63 : #define PROPERTYNAME_TRUSTEDAUTHOR_RAWDATA "RawData"
64 :
65 : // xmlsec05 deprecated
66 : #define PROPERTYNAME_STAROFFICEBASIC "OfficeBasic"
67 : #define PROPERTYNAME_EXECUTEPLUGINS "ExecutePlugins"
68 : #define PROPERTYNAME_WARNINGENABLED "Warning"
69 : #define PROPERTYNAME_CONFIRMATIONENABLED "Confirmation"
70 : // xmlsec05 deprecated
71 :
72 : #define PROPERTYHANDLE_SECUREURL 0
73 :
74 : // xmlsec05 deprecated
75 : #define PROPERTYHANDLE_STAROFFICEBASIC 1
76 : #define PROPERTYHANDLE_EXECUTEPLUGINS 2
77 : #define PROPERTYHANDLE_WARNINGENABLED 3
78 : #define PROPERTYHANDLE_CONFIRMATIONENABLED 4
79 : // xmlsec05 deprecated
80 :
81 : #define PROPERTYHANDLE_DOCWARN_SAVEORSEND 5
82 : #define PROPERTYHANDLE_DOCWARN_SIGNING 6
83 : #define PROPERTYHANDLE_DOCWARN_PRINT 7
84 : #define PROPERTYHANDLE_DOCWARN_CREATEPDF 8
85 : #define PROPERTYHANDLE_DOCWARN_REMOVEPERSONALINFO 9
86 : #define PROPERTYHANDLE_DOCWARN_RECOMMENDPASSWORD 10
87 : #define PROPERTYHANDLE_CTRLCLICK_HYPERLINK 11
88 : #define PROPERTYHANDLE_BLOCKUNTRUSTEDREFERERLINKS 12
89 : #define PROPERTYHANDLE_MACRO_SECLEVEL 13
90 : #define PROPERTYHANDLE_MACRO_TRUSTEDAUTHORS 14
91 : #define PROPERTYHANDLE_MACRO_DISABLE 15
92 :
93 : #define PROPERTYCOUNT 16
94 : #define PROPERTYHANDLE_INVALID -1
95 :
96 : #define CFG_READONLY_DEFAULT false
97 :
98 : // private declarations!
99 :
100 : class SvtSecurityOptions_Impl : public ConfigItem
101 : {
102 :
103 : // public methods
104 :
105 : public:
106 :
107 : // constructor / destructor
108 :
109 : SvtSecurityOptions_Impl();
110 : virtual ~SvtSecurityOptions_Impl();
111 :
112 : // overloaded methods of baseclass
113 :
114 : /*-****************************************************************************************************
115 : @short called for notify of configmanager
116 : @descr These method is called from the ConfigManager before application ends or from the
117 : PropertyChangeListener if the sub tree broadcasts changes. You must update your
118 : internal values.
119 :
120 : @seealso baseclass ConfigItem
121 :
122 : @param "seqPropertyNames" is the list of properties which should be updated.
123 : *//*-*****************************************************************************************************/
124 :
125 : virtual void Notify( const Sequence< OUString >& seqPropertyNames ) SAL_OVERRIDE;
126 :
127 : /*-****************************************************************************************************
128 : @short write changes to configuration
129 : @descr These method writes the changed values into the sub tree
130 : and should always called in our destructor to guarantee consistency of config data.
131 :
132 : @seealso baseclass ConfigItem
133 : *//*-*****************************************************************************************************/
134 :
135 : virtual void Commit() SAL_OVERRIDE;
136 :
137 : // public interface
138 :
139 : bool IsReadOnly ( SvtSecurityOptions::EOption eOption ) const;
140 :
141 0 : Sequence< OUString > GetSecureURLs ( ) const { return m_seqSecureURLs;}
142 : void SetSecureURLs ( const Sequence< OUString >& seqURLList );
143 : inline sal_Int32 GetMacroSecurityLevel ( ) const;
144 : void SetMacroSecurityLevel ( sal_Int32 _nLevel );
145 :
146 : inline bool IsMacroDisabled ( ) const;
147 :
148 0 : Sequence< SvtSecurityOptions::Certificate > GetTrustedAuthors ( ) const { return m_seqTrustedAuthors;}
149 : void SetTrustedAuthors ( const Sequence< SvtSecurityOptions::Certificate >& rAuthors );
150 :
151 : bool IsOptionSet ( SvtSecurityOptions::EOption eOption ) const;
152 : bool SetOption ( SvtSecurityOptions::EOption eOption, bool bValue );
153 : bool IsOptionEnabled ( SvtSecurityOptions::EOption eOption ) const;
154 :
155 : /*-****************************************************************************************************
156 : @short return list of key names of our configuration management which represent our module tree
157 : @descr These methods return a static const list of key names. We need it to get needed values from our
158 : configuration management.
159 : @return A list of needed configuration keys is returned.
160 : *//*-*****************************************************************************************************/
161 :
162 : void SetProperty( sal_Int32 nHandle, const Any& rValue, bool bReadOnly );
163 : void LoadAuthors( void );
164 : static sal_Int32 GetHandle( const OUString& rPropertyName );
165 : bool GetOption( SvtSecurityOptions::EOption eOption, bool*& rpValue, bool*& rpRO );
166 :
167 : static Sequence< OUString > GetPropertyNames();
168 :
169 : Sequence< OUString > m_seqSecureURLs;
170 : bool m_bSaveOrSend;
171 : bool m_bSigning;
172 : bool m_bPrint;
173 : bool m_bCreatePDF;
174 : bool m_bRemoveInfo;
175 : bool m_bRecommendPwd;
176 : bool m_bCtrlClickHyperlink;
177 : bool m_bBlockUntrustedRefererLinks;
178 : sal_Int32 m_nSecLevel;
179 : Sequence< SvtSecurityOptions::Certificate > m_seqTrustedAuthors;
180 : bool m_bDisableMacros;
181 :
182 : bool m_bROSecureURLs;
183 : bool m_bROSaveOrSend;
184 : bool m_bROSigning;
185 : bool m_bROPrint;
186 : bool m_bROCreatePDF;
187 : bool m_bRORemoveInfo;
188 : bool m_bRORecommendPwd;
189 : bool m_bROCtrlClickHyperlink;
190 : bool m_bROBlockUntrustedRefererLinks;
191 : bool m_bROSecLevel;
192 : bool m_bROTrustedAuthors;
193 : bool m_bRODisableMacros;
194 :
195 : // xmlsec05 deprecated
196 : EBasicSecurityMode m_eBasicMode;
197 : bool m_bExecutePlugins;
198 : bool m_bWarning;
199 : bool m_bConfirmation;
200 :
201 : bool m_bROConfirmation;
202 : bool m_bROWarning;
203 : bool m_bROExecutePlugins;
204 : bool m_bROBasicMode;
205 : public:
206 0 : bool IsWarningEnabled() const { return m_bWarning;}
207 : void SetWarningEnabled( bool bSet );
208 0 : bool IsConfirmationEnabled() const { return m_bConfirmation;}
209 : void SetConfirmationEnabled( bool bSet );
210 0 : bool IsExecutePlugins() const { return m_bExecutePlugins;}
211 : void SetExecutePlugins( bool bSet );
212 : // xmlsec05 deprecated
213 0 : EBasicSecurityMode GetBasicMode ( ) const { return m_eBasicMode;}
214 : void SetBasicMode ( EBasicSecurityMode eMode );
215 : };
216 :
217 : // constructor
218 :
219 199 : SvtSecurityOptions_Impl::SvtSecurityOptions_Impl()
220 : :ConfigItem ( ROOTNODE_SECURITY )
221 : ,m_seqSecureURLs ( DEFAULT_SECUREURL )
222 : ,m_bSaveOrSend ( true )
223 : ,m_bSigning ( true )
224 : ,m_bPrint ( true )
225 : ,m_bCreatePDF ( true )
226 : ,m_bRemoveInfo ( true )
227 : ,m_bRecommendPwd(false)
228 : ,m_bCtrlClickHyperlink(false)
229 : ,m_bBlockUntrustedRefererLinks(false)
230 : ,m_nSecLevel ( sal_True )
231 : ,m_seqTrustedAuthors ( DEFAULT_TRUSTEDAUTHORS )
232 : ,m_bDisableMacros ( false )
233 : ,m_bROSecureURLs ( CFG_READONLY_DEFAULT )
234 : ,m_bROSaveOrSend ( CFG_READONLY_DEFAULT )
235 : ,m_bROSigning ( CFG_READONLY_DEFAULT )
236 : ,m_bROPrint ( CFG_READONLY_DEFAULT )
237 : ,m_bROCreatePDF ( CFG_READONLY_DEFAULT )
238 : ,m_bRORemoveInfo ( CFG_READONLY_DEFAULT )
239 : ,m_bRORecommendPwd(CFG_READONLY_DEFAULT)
240 : ,m_bROCtrlClickHyperlink(CFG_READONLY_DEFAULT)
241 : ,m_bROBlockUntrustedRefererLinks(CFG_READONLY_DEFAULT)
242 : ,m_bROSecLevel ( CFG_READONLY_DEFAULT )
243 : ,m_bROTrustedAuthors ( CFG_READONLY_DEFAULT )
244 : ,m_bRODisableMacros ( true ) // currently is not intended to be changed
245 :
246 : // xmlsec05 deprecated
247 : , m_eBasicMode ( DEFAULT_STAROFFICEBASIC )
248 : , m_bExecutePlugins ( true )
249 : , m_bWarning ( true )
250 : , m_bConfirmation ( true )
251 : , m_bROConfirmation ( CFG_READONLY_DEFAULT )
252 : , m_bROWarning ( CFG_READONLY_DEFAULT )
253 : , m_bROExecutePlugins ( CFG_READONLY_DEFAULT )
254 199 : , m_bROBasicMode ( CFG_READONLY_DEFAULT )
255 : // xmlsec05 deprecated
256 :
257 : {
258 199 : Sequence< OUString > seqNames = GetPropertyNames ( );
259 398 : Sequence< Any > seqValues = GetProperties ( seqNames );
260 398 : Sequence< sal_Bool > seqRO = GetReadOnlyStates ( seqNames );
261 :
262 : // Safe impossible cases.
263 : // We need values from ALL configuration keys.
264 : // Follow assignment use order of values in relation to our list of key names!
265 : DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtSecurityOptions_Impl::SvtSecurityOptions_Impl()\nI miss some values of configuration keys!\n" );
266 :
267 : // Copy values from list in right order to our internal member.
268 199 : sal_Int32 nPropertyCount = seqValues.getLength();
269 3383 : for( sal_Int32 nProperty = 0; nProperty < nPropertyCount; ++nProperty )
270 3184 : SetProperty( nProperty, seqValues[ nProperty ], seqRO[ nProperty ] );
271 :
272 199 : LoadAuthors();
273 :
274 : // Enable notification mechanism of our baseclass.
275 : // We need it to get information about changes outside these class on our used configuration keys!*/
276 :
277 398 : EnableNotification( seqNames );
278 199 : }
279 :
280 : // destructor
281 :
282 585 : SvtSecurityOptions_Impl::~SvtSecurityOptions_Impl()
283 : {
284 195 : if( IsModified() )
285 0 : Commit();
286 390 : }
287 :
288 3184 : void SvtSecurityOptions_Impl::SetProperty( sal_Int32 nProperty, const Any& rValue, bool bRO )
289 : {
290 3184 : switch( nProperty )
291 : {
292 : case PROPERTYHANDLE_SECUREURL:
293 : {
294 199 : m_seqSecureURLs.realloc( 0 );
295 199 : rValue >>= m_seqSecureURLs;
296 199 : SvtPathOptions aOpt;
297 199 : sal_uInt32 nCount = m_seqSecureURLs.getLength();
298 199 : for( sal_uInt32 nItem = 0; nItem < nCount; ++nItem )
299 0 : m_seqSecureURLs[ nItem ] = aOpt.SubstituteVariable( m_seqSecureURLs[ nItem ] );
300 199 : m_bROSecureURLs = bRO;
301 : }
302 199 : break;
303 :
304 : case PROPERTYHANDLE_DOCWARN_SAVEORSEND:
305 : {
306 199 : rValue >>= m_bSaveOrSend;
307 199 : m_bROSaveOrSend = bRO;
308 : }
309 199 : break;
310 :
311 : case PROPERTYHANDLE_DOCWARN_SIGNING:
312 : {
313 199 : rValue >>= m_bSigning;
314 199 : m_bROSigning = bRO;
315 : }
316 199 : break;
317 :
318 : case PROPERTYHANDLE_DOCWARN_PRINT:
319 : {
320 199 : rValue >>= m_bPrint;
321 199 : m_bROPrint = bRO;
322 : }
323 199 : break;
324 :
325 : case PROPERTYHANDLE_DOCWARN_CREATEPDF:
326 : {
327 199 : rValue >>= m_bCreatePDF;
328 199 : m_bROCreatePDF = bRO;
329 : }
330 199 : break;
331 :
332 : case PROPERTYHANDLE_DOCWARN_REMOVEPERSONALINFO:
333 : {
334 199 : rValue >>= m_bRemoveInfo;
335 199 : m_bRORemoveInfo = bRO;
336 : }
337 199 : break;
338 :
339 : case PROPERTYHANDLE_DOCWARN_RECOMMENDPASSWORD:
340 : {
341 199 : rValue >>= m_bRecommendPwd;
342 199 : m_bRORecommendPwd = bRO;
343 : }
344 199 : break;
345 :
346 : case PROPERTYHANDLE_CTRLCLICK_HYPERLINK:
347 : {
348 199 : rValue >>= m_bCtrlClickHyperlink;
349 199 : m_bROCtrlClickHyperlink = bRO;
350 : }
351 199 : break;
352 :
353 : case PROPERTYHANDLE_BLOCKUNTRUSTEDREFERERLINKS:
354 : {
355 199 : rValue >>= m_bBlockUntrustedRefererLinks;
356 199 : m_bROBlockUntrustedRefererLinks = bRO;
357 : }
358 199 : break;
359 :
360 : case PROPERTYHANDLE_MACRO_SECLEVEL:
361 : {
362 199 : rValue >>= m_nSecLevel;
363 199 : m_bROSecLevel = bRO;
364 : }
365 199 : break;
366 :
367 : case PROPERTYHANDLE_MACRO_TRUSTEDAUTHORS:
368 : {
369 : // don't care about value here...
370 199 : m_bROTrustedAuthors = bRO;
371 : }
372 199 : break;
373 :
374 : case PROPERTYHANDLE_MACRO_DISABLE:
375 : {
376 199 : rValue >>= m_bDisableMacros;
377 199 : m_bRODisableMacros = bRO;
378 : }
379 199 : break;
380 :
381 : // xmlsec05 deprecated
382 : case PROPERTYHANDLE_STAROFFICEBASIC:
383 : {
384 199 : sal_Int32 nMode = 0;
385 199 : rValue >>= nMode;
386 199 : m_eBasicMode = (EBasicSecurityMode)nMode;
387 199 : m_bROBasicMode = bRO;
388 : }
389 199 : break;
390 : case PROPERTYHANDLE_EXECUTEPLUGINS:
391 : {
392 199 : rValue >>= m_bExecutePlugins;
393 199 : m_bROExecutePlugins = bRO;
394 : }
395 199 : break;
396 : case PROPERTYHANDLE_WARNINGENABLED:
397 : {
398 199 : rValue >>= m_bWarning;
399 199 : m_bROWarning = bRO;
400 : }
401 199 : break;
402 : case PROPERTYHANDLE_CONFIRMATIONENABLED:
403 : {
404 199 : rValue >>= m_bConfirmation;
405 199 : m_bROConfirmation = bRO;
406 : }
407 199 : break;
408 : // xmlsec05 deprecated
409 :
410 : #if OSL_DEBUG_LEVEL > 1
411 : default:
412 : DBG_ASSERT( false, "SvtSecurityOptions_Impl::SetProperty()\nUnknown property!\n" );
413 : #endif
414 : }
415 3184 : }
416 :
417 199 : void SvtSecurityOptions_Impl::LoadAuthors( void )
418 : {
419 199 : m_seqTrustedAuthors.realloc( 0 ); // first clear
420 199 : Sequence< OUString > lAuthors = GetNodeNames( PROPERTYNAME_MACRO_TRUSTEDAUTHORS );
421 199 : sal_Int32 c1 = lAuthors.getLength();
422 199 : if( c1 )
423 : {
424 0 : sal_Int32 c2 = c1 * 3; // 3 Properties inside Struct TrustedAuthor
425 0 : Sequence< OUString > lAllAuthors( c2 );
426 :
427 : sal_Int32 i1;
428 : sal_Int32 i2;
429 0 : OUString aSep( "/" );
430 0 : for( i1 = 0, i2 = 0; i1 < c1; ++i1 )
431 : {
432 0 : lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + lAuthors[ i1 ] + aSep + PROPERTYNAME_TRUSTEDAUTHOR_SUBJECTNAME;
433 0 : ++i2;
434 0 : lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + lAuthors[ i1 ] + aSep + PROPERTYNAME_TRUSTEDAUTHOR_SERIALNUMBER;
435 0 : ++i2;
436 0 : lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + lAuthors[ i1 ] + aSep + PROPERTYNAME_TRUSTEDAUTHOR_RAWDATA;
437 0 : ++i2;
438 : }
439 :
440 0 : Sequence< Any > lValues = GetProperties( lAllAuthors );
441 0 : if( lValues.getLength() == c2 )
442 : {
443 0 : comphelper::SequenceAsVector< SvtSecurityOptions::Certificate > v;
444 0 : SvtSecurityOptions::Certificate aCert( 3 );
445 0 : for( i1 = 0, i2 = 0; i1 < c1; ++i1 )
446 : {
447 0 : lValues[ i2 ] >>= aCert[ 0 ];
448 0 : ++i2;
449 0 : lValues[ i2 ] >>= aCert[ 1 ];
450 0 : ++i2;
451 0 : lValues[ i2 ] >>= aCert[ 2 ];
452 0 : ++i2;
453 : // Filter out TrustedAuthor entries with empty RawData, which
454 : // would cause an unexpected std::bad_alloc in
455 : // SecurityEnvironment_NssImpl::createCertificateFromAscii and
456 : // have been observed in the wild (fdo#55019):
457 0 : if( !aCert[ 2 ].isEmpty() )
458 : {
459 0 : v.push_back( aCert );
460 : }
461 : }
462 0 : m_seqTrustedAuthors = v.getAsConstList();
463 0 : }
464 199 : }
465 199 : }
466 :
467 0 : sal_Int32 SvtSecurityOptions_Impl::GetHandle( const OUString& rName )
468 : {
469 : sal_Int32 nHandle;
470 :
471 0 : if( rName == PROPERTYNAME_SECUREURL )
472 0 : nHandle = PROPERTYHANDLE_SECUREURL;
473 0 : else if( rName == PROPERTYNAME_DOCWARN_SAVEORSEND )
474 0 : nHandle = PROPERTYHANDLE_DOCWARN_SAVEORSEND;
475 0 : else if( rName == PROPERTYNAME_DOCWARN_SIGNING )
476 0 : nHandle = PROPERTYHANDLE_DOCWARN_SIGNING;
477 0 : else if( rName == PROPERTYNAME_DOCWARN_PRINT )
478 0 : nHandle = PROPERTYHANDLE_DOCWARN_PRINT;
479 0 : else if( rName == PROPERTYNAME_DOCWARN_CREATEPDF )
480 0 : nHandle = PROPERTYHANDLE_DOCWARN_CREATEPDF;
481 0 : else if( rName == PROPERTYNAME_DOCWARN_REMOVEPERSONALINFO )
482 0 : nHandle = PROPERTYHANDLE_DOCWARN_REMOVEPERSONALINFO;
483 0 : else if( rName == PROPERTYNAME_DOCWARN_RECOMMENDPASSWORD )
484 0 : nHandle = PROPERTYHANDLE_DOCWARN_RECOMMENDPASSWORD;
485 0 : else if( rName == PROPERTYNAME_CTRLCLICK_HYPERLINK )
486 0 : nHandle = PROPERTYHANDLE_CTRLCLICK_HYPERLINK;
487 0 : else if( rName == PROPERTYNAME_BLOCKUNTRUSTEDREFERERLINKS )
488 0 : nHandle = PROPERTYHANDLE_BLOCKUNTRUSTEDREFERERLINKS;
489 0 : else if( rName == PROPERTYNAME_MACRO_SECLEVEL )
490 0 : nHandle = PROPERTYHANDLE_MACRO_SECLEVEL;
491 0 : else if( rName == PROPERTYNAME_MACRO_TRUSTEDAUTHORS )
492 0 : nHandle = PROPERTYHANDLE_MACRO_TRUSTEDAUTHORS;
493 0 : else if( rName == PROPERTYNAME_MACRO_DISABLE )
494 0 : nHandle = PROPERTYHANDLE_MACRO_DISABLE;
495 :
496 : // xmlsec05 deprecated
497 0 : else if( rName == PROPERTYNAME_STAROFFICEBASIC )
498 0 : nHandle = PROPERTYHANDLE_STAROFFICEBASIC;
499 0 : else if( rName == PROPERTYNAME_EXECUTEPLUGINS )
500 0 : nHandle = PROPERTYHANDLE_EXECUTEPLUGINS;
501 0 : else if( rName == PROPERTYNAME_WARNINGENABLED )
502 0 : nHandle = PROPERTYHANDLE_WARNINGENABLED;
503 0 : else if( rName == PROPERTYNAME_CONFIRMATIONENABLED )
504 0 : nHandle = PROPERTYHANDLE_CONFIRMATIONENABLED;
505 : // xmlsec05 deprecated
506 :
507 : else
508 0 : nHandle = PROPERTYHANDLE_INVALID;
509 :
510 0 : return nHandle;
511 : }
512 :
513 15453 : bool SvtSecurityOptions_Impl::GetOption( SvtSecurityOptions::EOption eOption, bool*& rpValue, bool*& rpRO )
514 : {
515 15453 : switch( eOption )
516 : {
517 : case SvtSecurityOptions::E_DOCWARN_SAVEORSEND:
518 0 : rpValue = &m_bSaveOrSend;
519 0 : rpRO = &m_bROSaveOrSend;
520 0 : break;
521 : case SvtSecurityOptions::E_DOCWARN_SIGNING:
522 0 : rpValue = &m_bSigning;
523 0 : rpRO = &m_bROSigning;
524 0 : break;
525 : case SvtSecurityOptions::E_DOCWARN_PRINT:
526 0 : rpValue = &m_bPrint;
527 0 : rpRO = &m_bROPrint;
528 0 : break;
529 : case SvtSecurityOptions::E_DOCWARN_CREATEPDF:
530 0 : rpValue = &m_bCreatePDF;
531 0 : rpRO = &m_bROCreatePDF;
532 0 : break;
533 : case SvtSecurityOptions::E_DOCWARN_REMOVEPERSONALINFO:
534 1250 : rpValue = &m_bRemoveInfo;
535 1250 : rpRO = &m_bRORemoveInfo;
536 1250 : break;
537 : case SvtSecurityOptions::E_DOCWARN_RECOMMENDPASSWORD:
538 0 : rpValue = &m_bRecommendPwd;
539 0 : rpRO = &m_bRORecommendPwd;
540 0 : break;
541 : case SvtSecurityOptions::E_CTRLCLICK_HYPERLINK:
542 3634 : rpValue = &m_bCtrlClickHyperlink;
543 3634 : rpRO = &m_bROCtrlClickHyperlink;
544 3634 : break;
545 : case SvtSecurityOptions::E_BLOCKUNTRUSTEDREFERERLINKS:
546 10569 : rpValue = &m_bBlockUntrustedRefererLinks;
547 10569 : rpRO = &m_bROBlockUntrustedRefererLinks;
548 10569 : break;
549 : default:
550 0 : rpValue = NULL;
551 0 : rpRO = NULL;
552 0 : break;
553 : }
554 :
555 15453 : return rpValue != NULL;
556 : }
557 :
558 0 : void SvtSecurityOptions_Impl::Notify( const Sequence< OUString >& seqPropertyNames )
559 : {
560 : // Use given list of updated properties to get his values from configuration directly!
561 0 : Sequence< Any > seqValues = GetProperties( seqPropertyNames );
562 0 : Sequence< sal_Bool > seqRO = GetReadOnlyStates( seqPropertyNames );
563 : // Safe impossible cases.
564 : // We need values from ALL notified configuration keys.
565 : DBG_ASSERT( !(seqPropertyNames.getLength()!=seqValues.getLength()), "SvtSecurityOptions_Impl::Notify()\nI miss some values of configuration keys!\n" );
566 : // Step over list of property names and get right value from coreesponding value list to set it on internal members!
567 0 : sal_Int32 nCount = seqPropertyNames.getLength();
568 0 : for( sal_Int32 nProperty = 0; nProperty < nCount; ++nProperty )
569 0 : SetProperty( GetHandle( seqPropertyNames[ nProperty ] ), seqValues[ nProperty ], seqRO[ nProperty ] );
570 :
571 : // read set of trusted authors separately
572 0 : LoadAuthors();
573 0 : }
574 :
575 0 : void SvtSecurityOptions_Impl::Commit()
576 : {
577 : // Get names of supported properties, create a list for values and copy current values to it.
578 0 : Sequence< OUString > lOrgNames = GetPropertyNames();
579 0 : sal_Int32 nOrgCount = lOrgNames.getLength();
580 :
581 0 : Sequence< OUString > lNames(nOrgCount);
582 0 : Sequence< Any > lValues(nOrgCount);
583 0 : sal_Int32 nRealCount = 0;
584 : bool bDone;
585 :
586 0 : ClearNodeSet( PROPERTYNAME_MACRO_TRUSTEDAUTHORS );
587 :
588 0 : for( sal_Int32 nProperty = 0; nProperty < nOrgCount; ++nProperty )
589 : {
590 0 : switch( nProperty )
591 : {
592 : case PROPERTYHANDLE_SECUREURL:
593 : {
594 0 : bDone = !m_bROSecureURLs;
595 0 : if( bDone )
596 : {
597 0 : Sequence< OUString > lURLs( m_seqSecureURLs );
598 0 : SvtPathOptions aOpt;
599 0 : sal_Int32 nURLsCnt = lURLs.getLength();
600 0 : for( sal_Int32 nItem = 0; nItem < nURLsCnt; ++nItem )
601 0 : lURLs[ nItem ] = aOpt.UseVariable( lURLs[ nItem ] );
602 0 : lValues[ nRealCount ] <<= lURLs;
603 : }
604 : }
605 0 : break;
606 :
607 : case PROPERTYHANDLE_DOCWARN_SAVEORSEND:
608 : {
609 0 : bDone = !m_bROSaveOrSend;
610 0 : if( bDone )
611 0 : lValues[ nRealCount ] <<= m_bSaveOrSend;
612 : }
613 0 : break;
614 :
615 : case PROPERTYHANDLE_DOCWARN_SIGNING:
616 : {
617 0 : bDone = !m_bROSigning;
618 0 : if( bDone )
619 0 : lValues[ nRealCount ] <<= m_bSigning;
620 : }
621 0 : break;
622 :
623 : case PROPERTYHANDLE_DOCWARN_PRINT:
624 : {
625 0 : bDone = !m_bROPrint;
626 0 : if( bDone )
627 0 : lValues[ nRealCount ] <<= m_bPrint;
628 : }
629 0 : break;
630 :
631 : case PROPERTYHANDLE_DOCWARN_CREATEPDF:
632 : {
633 0 : bDone = !m_bROCreatePDF;
634 0 : if( bDone )
635 0 : lValues[ nRealCount ] <<= m_bCreatePDF;
636 : }
637 0 : break;
638 :
639 : case PROPERTYHANDLE_DOCWARN_REMOVEPERSONALINFO:
640 : {
641 0 : bDone = !m_bRORemoveInfo;
642 0 : if( bDone )
643 0 : lValues[ nRealCount ] <<= m_bRemoveInfo;
644 : }
645 0 : break;
646 :
647 : case PROPERTYHANDLE_DOCWARN_RECOMMENDPASSWORD:
648 : {
649 0 : bDone = !m_bRORecommendPwd;
650 0 : if( bDone )
651 0 : lValues[ nRealCount ] <<= m_bRecommendPwd;
652 : }
653 0 : break;
654 :
655 : case PROPERTYHANDLE_CTRLCLICK_HYPERLINK:
656 : {
657 0 : bDone = !m_bROCtrlClickHyperlink;
658 0 : if( bDone )
659 0 : lValues[ nRealCount ] <<= m_bCtrlClickHyperlink;
660 : }
661 0 : break;
662 :
663 : case PROPERTYHANDLE_BLOCKUNTRUSTEDREFERERLINKS:
664 : {
665 0 : bDone = !m_bROBlockUntrustedRefererLinks;
666 0 : if( bDone )
667 0 : lValues[ nRealCount ] <<= m_bBlockUntrustedRefererLinks;
668 : }
669 0 : break;
670 :
671 : case PROPERTYHANDLE_MACRO_SECLEVEL:
672 : {
673 0 : bDone = !m_bROSecLevel;
674 0 : if( bDone )
675 0 : lValues[ nRealCount ] <<= m_nSecLevel;
676 : }
677 0 : break;
678 :
679 : case PROPERTYHANDLE_MACRO_TRUSTEDAUTHORS:
680 : {
681 0 : bDone = !m_bROTrustedAuthors;
682 0 : if( bDone )
683 : {
684 0 : sal_Int32 nCnt = m_seqTrustedAuthors.getLength();
685 0 : if( nCnt )
686 : {
687 0 : for( sal_Int32 i = 0; i < nCnt; ++i )
688 : {
689 : OUString aPrefix(
690 : PROPERTYNAME_MACRO_TRUSTEDAUTHORS "/a"
691 0 : + OUString::number(i) + "/");
692 0 : Sequence< com::sun::star::beans::PropertyValue > lPropertyValues( 3 );
693 0 : lPropertyValues[ 0 ].Name = aPrefix + PROPERTYNAME_TRUSTEDAUTHOR_SUBJECTNAME;
694 0 : lPropertyValues[ 0 ].Value <<= m_seqTrustedAuthors[ i ][0];
695 0 : lPropertyValues[ 1 ].Name = aPrefix + PROPERTYNAME_TRUSTEDAUTHOR_SERIALNUMBER;
696 0 : lPropertyValues[ 1 ].Value <<= m_seqTrustedAuthors[ i ][1];
697 0 : lPropertyValues[ 2 ].Name = aPrefix + PROPERTYNAME_TRUSTEDAUTHOR_RAWDATA;
698 0 : lPropertyValues[ 2 ].Value <<= m_seqTrustedAuthors[ i ][2];
699 :
700 0 : SetSetProperties( PROPERTYNAME_MACRO_TRUSTEDAUTHORS, lPropertyValues );
701 0 : }
702 :
703 0 : bDone = false; // because we save in loop above!
704 : }
705 : else
706 0 : bDone = false;
707 : }
708 : }
709 0 : break;
710 :
711 : case PROPERTYHANDLE_MACRO_DISABLE:
712 : {
713 0 : bDone = !m_bRODisableMacros;
714 0 : if( bDone )
715 0 : lValues[ nRealCount ] <<= m_bDisableMacros;
716 : }
717 0 : break;
718 :
719 : // xmlsec05 deprecated
720 : case PROPERTYHANDLE_STAROFFICEBASIC:
721 : {
722 0 : bDone = !m_bROBasicMode;
723 0 : if( bDone )
724 0 : lValues[ nRealCount ] <<= (sal_Int32)m_eBasicMode;
725 : }
726 0 : break;
727 : case PROPERTYHANDLE_EXECUTEPLUGINS:
728 : {
729 0 : bDone = !m_bROExecutePlugins;
730 0 : if( bDone )
731 0 : lValues[ nRealCount ] <<= m_bExecutePlugins;
732 : }
733 0 : break;
734 : case PROPERTYHANDLE_WARNINGENABLED:
735 : {
736 0 : bDone = !m_bROWarning;
737 0 : if( bDone )
738 0 : lValues[ nRealCount ] <<= m_bWarning;
739 : }
740 0 : break;
741 : case PROPERTYHANDLE_CONFIRMATIONENABLED:
742 : {
743 0 : bDone = !m_bROConfirmation;
744 0 : if( bDone )
745 0 : lValues[ nRealCount ] <<= m_bConfirmation;
746 : }
747 0 : break;
748 : // xmlsec05 deprecated
749 :
750 : default:
751 0 : bDone = false;
752 : }
753 :
754 0 : if( bDone )
755 : {
756 0 : lNames[ nRealCount ] = lOrgNames[ nProperty ];
757 0 : ++nRealCount;
758 : }
759 : }
760 : // Set properties in configuration.
761 0 : lNames.realloc(nRealCount);
762 0 : lValues.realloc(nRealCount);
763 0 : PutProperties( lNames, lValues );
764 0 : }
765 :
766 0 : bool SvtSecurityOptions_Impl::IsReadOnly( SvtSecurityOptions::EOption eOption ) const
767 : {
768 : bool bReadonly;
769 0 : switch(eOption)
770 : {
771 : case SvtSecurityOptions::E_SECUREURLS :
772 0 : bReadonly = m_bROSecureURLs;
773 0 : break;
774 : case SvtSecurityOptions::E_DOCWARN_SAVEORSEND:
775 0 : bReadonly = m_bROSaveOrSend;
776 0 : break;
777 : case SvtSecurityOptions::E_DOCWARN_SIGNING:
778 0 : bReadonly = m_bROSigning;
779 0 : break;
780 : case SvtSecurityOptions::E_DOCWARN_PRINT:
781 0 : bReadonly = m_bROPrint;
782 0 : break;
783 : case SvtSecurityOptions::E_DOCWARN_CREATEPDF:
784 0 : bReadonly = m_bROCreatePDF;
785 0 : break;
786 : case SvtSecurityOptions::E_DOCWARN_REMOVEPERSONALINFO:
787 0 : bReadonly = m_bRORemoveInfo;
788 0 : break;
789 : case SvtSecurityOptions::E_DOCWARN_RECOMMENDPASSWORD:
790 0 : bReadonly = m_bRORecommendPwd;
791 0 : break;
792 : case SvtSecurityOptions::E_MACRO_SECLEVEL:
793 0 : bReadonly = m_bROSecLevel;
794 0 : break;
795 : case SvtSecurityOptions::E_MACRO_TRUSTEDAUTHORS:
796 0 : bReadonly = m_bROTrustedAuthors;
797 0 : break;
798 : case SvtSecurityOptions::E_MACRO_DISABLE:
799 0 : bReadonly = m_bRODisableMacros;
800 0 : break;
801 : case SvtSecurityOptions::E_CTRLCLICK_HYPERLINK:
802 0 : bReadonly = m_bROCtrlClickHyperlink;
803 0 : break;
804 : case SvtSecurityOptions::E_BLOCKUNTRUSTEDREFERERLINKS:
805 0 : bReadonly = m_bROBlockUntrustedRefererLinks;
806 0 : break;
807 :
808 : // xmlsec05 deprecated
809 : case SvtSecurityOptions::E_BASICMODE:
810 0 : bReadonly = m_bROBasicMode;
811 0 : break;
812 : case SvtSecurityOptions::E_EXECUTEPLUGINS:
813 0 : bReadonly = m_bROExecutePlugins;
814 0 : break;
815 : case SvtSecurityOptions::E_WARNING:
816 0 : bReadonly = m_bROWarning;
817 0 : break;
818 : case SvtSecurityOptions::E_CONFIRMATION:
819 0 : bReadonly = m_bROConfirmation;
820 0 : break;
821 : // xmlsec05 deprecated
822 :
823 : default:
824 0 : bReadonly = true;
825 : }
826 :
827 0 : return bReadonly;
828 : }
829 :
830 :
831 0 : void SvtSecurityOptions_Impl::SetSecureURLs( const Sequence< OUString >& seqURLList )
832 : {
833 : DBG_ASSERT(!m_bROSecureURLs, "SvtSecurityOptions_Impl::SetSecureURLs()\nYou tried to write on a readonly value!\n");
834 0 : if (!m_bROSecureURLs && m_seqSecureURLs!=seqURLList)
835 : {
836 0 : m_seqSecureURLs = seqURLList;
837 0 : SetModified();
838 : }
839 0 : }
840 :
841 0 : inline sal_Int32 SvtSecurityOptions_Impl::GetMacroSecurityLevel() const
842 : {
843 0 : return m_nSecLevel;
844 : }
845 :
846 10562 : inline bool SvtSecurityOptions_Impl::IsMacroDisabled() const
847 : {
848 10562 : return m_bDisableMacros;
849 : }
850 :
851 0 : void SvtSecurityOptions_Impl::SetMacroSecurityLevel( sal_Int32 _nLevel )
852 : {
853 0 : if( !m_bROSecLevel )
854 : {
855 0 : if( _nLevel > 3 || _nLevel < 0 )
856 0 : _nLevel = 3;
857 :
858 0 : if( m_nSecLevel != _nLevel )
859 : {
860 0 : m_nSecLevel = _nLevel;
861 0 : SetModified();
862 : }
863 : }
864 0 : }
865 :
866 :
867 0 : void SvtSecurityOptions_Impl::SetTrustedAuthors( const Sequence< SvtSecurityOptions::Certificate >& rAuthors )
868 : {
869 : DBG_ASSERT(!m_bROTrustedAuthors, "SvtSecurityOptions_Impl::SetTrustedAuthors()\nYou tried to write on a readonly value!\n");
870 0 : if( !m_bROTrustedAuthors && rAuthors != m_seqTrustedAuthors )
871 : {
872 0 : m_seqTrustedAuthors = rAuthors;
873 0 : SetModified();
874 : }
875 0 : }
876 :
877 15453 : bool SvtSecurityOptions_Impl::IsOptionSet( SvtSecurityOptions::EOption eOption ) const
878 : {
879 : bool* pValue;
880 : bool* pRO;
881 15453 : bool bRet = false;
882 :
883 15453 : if( ( const_cast< SvtSecurityOptions_Impl* >( this ) )->GetOption( eOption, pValue, pRO ) )
884 15453 : bRet = *pValue;
885 :
886 15453 : return bRet;
887 : }
888 :
889 0 : bool SvtSecurityOptions_Impl::SetOption( SvtSecurityOptions::EOption eOption, bool bValue )
890 : {
891 : bool* pValue;
892 : bool* pRO;
893 0 : bool bRet = false;
894 :
895 0 : if( GetOption( eOption, pValue, pRO ) )
896 : {
897 0 : if( !*pRO )
898 : {
899 0 : bRet = true;
900 0 : if( *pValue != bValue )
901 : {
902 0 : *pValue = bValue;
903 0 : SetModified();
904 : }
905 : }
906 : }
907 :
908 0 : return bRet;
909 : }
910 :
911 0 : bool SvtSecurityOptions_Impl::IsOptionEnabled( SvtSecurityOptions::EOption eOption ) const
912 : {
913 : bool* pValue;
914 : bool* pRO;
915 0 : bool bRet = false;
916 :
917 0 : if( ( const_cast< SvtSecurityOptions_Impl* >( this ) )->GetOption( eOption, pValue, pRO ) )
918 0 : bRet = !*pRO;
919 :
920 0 : return bRet;
921 : }
922 :
923 199 : Sequence< OUString > SvtSecurityOptions_Impl::GetPropertyNames()
924 : {
925 : // Build static list of configuration key names.
926 : const OUString pProperties[] =
927 : {
928 : OUString(PROPERTYNAME_SECUREURL),
929 : OUString(PROPERTYNAME_STAROFFICEBASIC),
930 : OUString(PROPERTYNAME_EXECUTEPLUGINS),
931 : OUString(PROPERTYNAME_WARNINGENABLED),
932 : OUString(PROPERTYNAME_CONFIRMATIONENABLED),
933 : OUString(PROPERTYNAME_DOCWARN_SAVEORSEND),
934 : OUString(PROPERTYNAME_DOCWARN_SIGNING),
935 : OUString(PROPERTYNAME_DOCWARN_PRINT),
936 : OUString(PROPERTYNAME_DOCWARN_CREATEPDF),
937 : OUString(PROPERTYNAME_DOCWARN_REMOVEPERSONALINFO),
938 : OUString(PROPERTYNAME_DOCWARN_RECOMMENDPASSWORD),
939 : OUString(PROPERTYNAME_CTRLCLICK_HYPERLINK),
940 : OUString(PROPERTYNAME_BLOCKUNTRUSTEDREFERERLINKS),
941 : OUString(PROPERTYNAME_MACRO_SECLEVEL),
942 : OUString(PROPERTYNAME_MACRO_TRUSTEDAUTHORS),
943 : OUString(PROPERTYNAME_MACRO_DISABLE)
944 3383 : };
945 : // Initialize return sequence with these list ...
946 199 : const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT );
947 : // ... and return it.
948 3383 : return seqPropertyNames;
949 : }
950 :
951 : // initialize static member
952 : // DON'T DO IT IN YOUR HEADER!
953 : // see definition for further information
954 :
955 : SvtSecurityOptions_Impl* SvtSecurityOptions::m_pDataContainer = NULL;
956 : sal_Int32 SvtSecurityOptions::m_nRefCount = 0;
957 :
958 26214 : SvtSecurityOptions::SvtSecurityOptions()
959 : {
960 : // Global access, must be guarded (multithreading!).
961 26214 : MutexGuard aGuard( GetInitMutex() );
962 : // Increase our refcount ...
963 26214 : ++m_nRefCount;
964 : // ... and initialize our data container only if it not already exist!
965 26214 : if( m_pDataContainer == NULL )
966 : {
967 199 : m_pDataContainer = new SvtSecurityOptions_Impl;
968 :
969 199 : ItemHolder1::holdConfigItem(E_SECURITYOPTIONS);
970 26214 : }
971 26214 : }
972 :
973 52615 : SvtSecurityOptions::~SvtSecurityOptions()
974 : {
975 : // Global access, must be guarded (multithreading!)
976 26210 : MutexGuard aGuard( GetInitMutex() );
977 : // Decrease our refcount.
978 26210 : --m_nRefCount;
979 : // If last instance was deleted ...
980 : // we must destroy our static data container!
981 26210 : if( m_nRefCount <= 0 )
982 : {
983 195 : delete m_pDataContainer;
984 195 : m_pDataContainer = NULL;
985 26210 : }
986 26405 : }
987 :
988 0 : bool SvtSecurityOptions::IsReadOnly( EOption eOption ) const
989 : {
990 0 : MutexGuard aGuard( GetInitMutex() );
991 0 : return m_pDataContainer->IsReadOnly(eOption);
992 : }
993 :
994 0 : Sequence< OUString > SvtSecurityOptions::GetSecureURLs() const
995 : {
996 0 : MutexGuard aGuard( GetInitMutex() );
997 0 : return m_pDataContainer->GetSecureURLs();
998 : }
999 :
1000 0 : void SvtSecurityOptions::SetSecureURLs( const Sequence< OUString >& seqURLList )
1001 : {
1002 0 : MutexGuard aGuard( GetInitMutex() );
1003 0 : m_pDataContainer->SetSecureURLs( seqURLList );
1004 0 : }
1005 :
1006 0 : bool SvtSecurityOptions::isSecureMacroUri(
1007 : OUString const & uri, OUString const & referer) const
1008 : {
1009 0 : switch (INetURLObject(uri).GetProtocol()) {
1010 : case INET_PROT_MACRO:
1011 0 : if (uri.startsWithIgnoreAsciiCase("macro:///")) {
1012 : // Denotes an App-BASIC macro (see SfxMacroLoader::loadMacro), which
1013 : // is considered safe:
1014 0 : return true;
1015 : }
1016 : // fall through
1017 : case INET_PROT_SLOT:
1018 0 : return referer.equalsIgnoreAsciiCase("private:user")
1019 0 : || isTrustedLocationUri(referer);
1020 : default:
1021 0 : return true;
1022 : }
1023 : }
1024 :
1025 10569 : bool SvtSecurityOptions::isUntrustedReferer(OUString const & referer) const {
1026 10569 : MutexGuard g(GetInitMutex());
1027 10569 : return m_pDataContainer->IsOptionSet(E_BLOCKUNTRUSTEDREFERERLINKS)
1028 10569 : && !(referer.isEmpty() || referer.startsWithIgnoreAsciiCase("private:")
1029 10569 : || isTrustedLocationUri(referer));
1030 : }
1031 :
1032 0 : bool SvtSecurityOptions::isTrustedLocationUri(OUString const & uri) const {
1033 0 : MutexGuard g(GetInitMutex());
1034 0 : for (sal_Int32 i = 0; i != m_pDataContainer->m_seqSecureURLs.getLength();
1035 : ++i)
1036 : {
1037 0 : if (UCBContentHelper::IsSubPath(
1038 0 : m_pDataContainer->m_seqSecureURLs[i], uri))
1039 : {
1040 0 : return true;
1041 : }
1042 : }
1043 0 : return false;
1044 : }
1045 :
1046 0 : sal_Int32 SvtSecurityOptions::GetMacroSecurityLevel() const
1047 : {
1048 0 : MutexGuard aGuard( GetInitMutex() );
1049 0 : return m_pDataContainer->GetMacroSecurityLevel();
1050 : }
1051 :
1052 0 : void SvtSecurityOptions::SetMacroSecurityLevel( sal_Int32 _nLevel )
1053 : {
1054 0 : MutexGuard aGuard( GetInitMutex() );
1055 0 : m_pDataContainer->SetMacroSecurityLevel( _nLevel );
1056 0 : }
1057 :
1058 10562 : bool SvtSecurityOptions::IsMacroDisabled() const
1059 : {
1060 10562 : MutexGuard aGuard( GetInitMutex() );
1061 10562 : return m_pDataContainer->IsMacroDisabled();
1062 : }
1063 :
1064 0 : Sequence< SvtSecurityOptions::Certificate > SvtSecurityOptions::GetTrustedAuthors() const
1065 : {
1066 0 : MutexGuard aGuard( GetInitMutex() );
1067 0 : return m_pDataContainer->GetTrustedAuthors();
1068 : }
1069 :
1070 0 : void SvtSecurityOptions::SetTrustedAuthors( const Sequence< Certificate >& rAuthors )
1071 : {
1072 0 : MutexGuard aGuard( GetInitMutex() );
1073 0 : m_pDataContainer->SetTrustedAuthors( rAuthors );
1074 0 : }
1075 :
1076 4884 : bool SvtSecurityOptions::IsOptionSet( EOption eOption ) const
1077 : {
1078 4884 : MutexGuard aGuard( GetInitMutex() );
1079 4884 : return m_pDataContainer->IsOptionSet( eOption );
1080 : }
1081 :
1082 0 : bool SvtSecurityOptions::SetOption( EOption eOption, bool bValue )
1083 : {
1084 0 : MutexGuard aGuard( GetInitMutex() );
1085 0 : return m_pDataContainer->SetOption( eOption, bValue );
1086 : }
1087 :
1088 0 : bool SvtSecurityOptions::IsOptionEnabled( EOption eOption ) const
1089 : {
1090 0 : MutexGuard aGuard( GetInitMutex() );
1091 0 : return m_pDataContainer->IsOptionEnabled( eOption );
1092 : }
1093 :
1094 : namespace
1095 : {
1096 : class theSecurityOptionsMutex : public rtl::Static<osl::Mutex, theSecurityOptionsMutex>{};
1097 : }
1098 :
1099 78439 : Mutex& SvtSecurityOptions::GetInitMutex()
1100 : {
1101 78439 : return theSecurityOptionsMutex::get();
1102 : }
1103 :
1104 0 : void SvtSecurityOptions_Impl::SetBasicMode( EBasicSecurityMode eMode )
1105 : {
1106 : DBG_ASSERT(!m_bROBasicMode, "SvtSecurityOptions_Impl::SetBasicMode()\nYou tried to write on a readonly value!\n");
1107 0 : if (!m_bROBasicMode && m_eBasicMode!=eMode)
1108 : {
1109 0 : m_eBasicMode = eMode;
1110 0 : SetModified();
1111 : }
1112 0 : }
1113 :
1114 :
1115 0 : void SvtSecurityOptions_Impl::SetExecutePlugins( bool bSet )
1116 : {
1117 : DBG_ASSERT(!m_bROExecutePlugins, "SvtSecurityOptions_Impl::SetExecutePlugins()\nYou tried to write on a readonly value!\n");
1118 0 : if (!m_bROExecutePlugins && m_bExecutePlugins!=bSet)
1119 : {
1120 0 : m_bExecutePlugins = bSet;
1121 0 : SetModified();
1122 : }
1123 0 : }
1124 :
1125 :
1126 0 : void SvtSecurityOptions_Impl::SetWarningEnabled( bool bSet )
1127 : {
1128 : DBG_ASSERT(!m_bROWarning, "SvtSecurityOptions_Impl::SetWarningEnabled()\nYou tried to write on a readonly value!\n");
1129 0 : if (!m_bROWarning && m_bWarning!=bSet)
1130 : {
1131 0 : m_bWarning = bSet;
1132 0 : SetModified();
1133 : }
1134 0 : }
1135 :
1136 :
1137 0 : void SvtSecurityOptions_Impl::SetConfirmationEnabled( bool bSet )
1138 : {
1139 : DBG_ASSERT(!m_bROConfirmation, "SvtSecurityOptions_Impl::SetConfirmationEnabled()\nYou tried to write on a readonly value!\n");
1140 0 : if (!m_bROConfirmation && m_bConfirmation!=bSet)
1141 : {
1142 0 : m_bConfirmation = bSet;
1143 0 : SetModified();
1144 : }
1145 0 : }
1146 :
1147 0 : bool SvtSecurityOptions::IsExecutePlugins() const
1148 : {
1149 0 : MutexGuard aGuard( GetInitMutex() );
1150 0 : return m_pDataContainer->IsExecutePlugins();
1151 : }
1152 :
1153 0 : void SvtSecurityOptions::SetExecutePlugins( bool bSet )
1154 : {
1155 0 : MutexGuard aGuard( GetInitMutex() );
1156 0 : m_pDataContainer->SetExecutePlugins( bSet );
1157 0 : }
1158 :
1159 0 : bool SvtSecurityOptions::IsWarningEnabled() const
1160 : {
1161 0 : MutexGuard aGuard( GetInitMutex() );
1162 0 : return m_pDataContainer->IsWarningEnabled();
1163 : }
1164 :
1165 0 : void SvtSecurityOptions::SetWarningEnabled( bool bSet )
1166 : {
1167 0 : MutexGuard aGuard( GetInitMutex() );
1168 0 : m_pDataContainer->SetWarningEnabled( bSet );
1169 0 : }
1170 :
1171 0 : bool SvtSecurityOptions::IsConfirmationEnabled() const
1172 : {
1173 0 : MutexGuard aGuard( GetInitMutex() );
1174 0 : return m_pDataContainer->IsConfirmationEnabled();
1175 : }
1176 :
1177 0 : void SvtSecurityOptions::SetConfirmationEnabled( bool bSet )
1178 : {
1179 0 : MutexGuard aGuard( GetInitMutex() );
1180 0 : m_pDataContainer->SetConfirmationEnabled( bSet );
1181 0 : }
1182 :
1183 0 : void SvtSecurityOptions::SetBasicMode( EBasicSecurityMode eMode )
1184 : {
1185 0 : MutexGuard aGuard( GetInitMutex() );
1186 0 : m_pDataContainer->SetBasicMode( eMode );
1187 0 : }
1188 :
1189 0 : EBasicSecurityMode SvtSecurityOptions::GetBasicMode() const
1190 : {
1191 0 : MutexGuard aGuard( GetInitMutex() );
1192 0 : return m_pDataContainer->GetBasicMode();
1193 : }
1194 :
1195 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|