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