Impress: Implement getPartName.
[LibreOffice.git] / include / unotools / securityoptions.hxx
blob3bd88072ab1f9a13619947a24a2999b3cff4f75a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_UNOTOOLS_SECURITYOPTIONS_HXX
20 #define INCLUDED_UNOTOOLS_SECURITYOPTIONS_HXX
22 #include <unotools/unotoolsdllapi.h>
23 #include <sal/types.h>
24 #include <osl/mutex.hxx>
25 #include <com/sun/star/uno/Sequence.h>
26 #include <rtl/ustring.hxx>
27 #include <unotools/options.hxx>
29 /*-************************************************************************************************************
30 @short forward declaration to our private date container implementation
31 @descr We use these class as internal member to support small memory requirements.
32 You can create the container if it is necessary. The class which use these mechanism
33 is faster and smaller then a complete implementation!
34 *//*-*************************************************************************************************************/
36 class SvtSecurityOptions_Impl;
38 /*-************************************************************************************************************
39 @descr These values present modes to handle StarOffice basic scripts.
40 see GetBasicMode/SetBasicMode() for further information
41 *//*-*************************************************************************************************************/
43 enum EBasicSecurityMode
45 eNEVER_EXECUTE = 0,
46 eFROM_LIST = 1,
47 eALWAYS_EXECUTE = 2
50 /*-************************************************************************************************************
51 @short collect information about security features
52 @ATTENTION This class is partially threadsafe.
54 @devstatus ready to use
55 *//*-*************************************************************************************************************/
57 class UNOTOOLS_DLLPUBLIC SAL_WARN_UNUSED SvtSecurityOptions : public utl::detail::Options
59 public:
61 enum EOption
63 E_SECUREURLS,
64 E_BASICMODE, // xmlsec05 deprecated
65 E_EXECUTEPLUGINS, // xmlsec05 deprecated
66 E_WARNING, // xmlsec05 deprecated
67 E_CONFIRMATION, // xmlsec05 deprecated
68 E_DOCWARN_SAVEORSEND,
69 E_DOCWARN_SIGNING,
70 E_DOCWARN_PRINT,
71 E_DOCWARN_CREATEPDF,
72 E_DOCWARN_REMOVEPERSONALINFO,
73 E_DOCWARN_RECOMMENDPASSWORD,
74 E_MACRO_SECLEVEL,
75 E_MACRO_TRUSTEDAUTHORS,
76 E_MACRO_DISABLE,
77 E_CTRLCLICK_HYPERLINK,
78 E_BLOCKUNTRUSTEDREFERERLINKS
81 enum MacroAction
83 MA_DONTRUN = 0,
84 MA_CONFIRM,
85 MA_RUN
88 typedef ::com::sun::star::uno::Sequence< OUString > Certificate;
91 // MT: Doesn't work for sequence...
92 struct Certificate
94 OUString SubjectName;
95 OUString SerialNumber;
96 OUString RawData;
100 public:
101 /*-****************************************************************************************************
102 @short standard constructor and destructor
103 @descr This will initialize an instance with default values.
104 We implement these class with a refcount mechanism! Every instance of this class increase it
105 at create and decrease it at delete time - but all instances use the same data container!
106 He is implemented as a static member ...
108 @seealso member m_nRefCount
109 @seealso member m_pDataContainer
110 *//*-*****************************************************************************************************/
112 SvtSecurityOptions();
113 virtual ~SvtSecurityOptions();
115 /*-****************************************************************************************************
116 @short returns readonly state
117 @descr It can be called to get information about the readonly state of a provided item.
118 @param "eOption", specify, which item is queried
119 @return <TRUE/> if item is readonly; <FALSE/> otherwise
121 @onerror No error should occur!
122 *//*-*****************************************************************************************************/
124 bool IsReadOnly( EOption eOption ) const;
126 /*-****************************************************************************************************
127 @short interface methods to get and set value of config key "org.openoffice.Office.Common/Security/Scripting/SecureURL"
128 @descr These value displays the list of all trustworthy URLs.
129 zB.: file:/ => All scripts from the local file system including a LAN;
130 private:explorer => Scripts from the Explorer;
131 private:help => Scripts in the help system;
132 private:newmenu => Scripts that are executed by the commands File-New and AutoPilot;
133 private:schedule => Scripts of the scheduler;
134 private:searchfolder => Scripts of the searchfolder;
135 private:user => Scripts that are entered in the URL field.
136 @param "seqURLList", new values to set it in configuration.
137 @return The values which represent current state of internal variable.
139 @onerror No error should occur!
140 *//*-*****************************************************************************************************/
142 ::com::sun::star::uno::Sequence< OUString > GetSecureURLs( ) const;
143 void SetSecureURLs( const ::com::sun::star::uno::Sequence< OUString >& seqURLList );
145 /*-****************************************************************************************************
146 @short interface methods to get and set value of config key "org.openoffice.Office.Common/Security/Scripting/StarOfficeBasic"
147 @descr These value determines how StarOffice Basic scripts should be handled.
148 It exist 3 different modes:
149 0 = never execute
150 1 = from list
151 2 = always execute
153 @ATTENTION These methods don't check for valid or invalid values!
154 Our configuration server can do it ... but these implementation don't get any notifications
155 about wrong commits ...!
156 => If you set an invalid value - nothing will be changed. The information will lost.
158 @seealso enum EBasicSecurityMode
160 @param "eMode" to set new mode ... Value must defined as an enum of type EBasicSecurityMode!
161 @return An enum value, which present current mode.
163 @onerror No error should occur!
164 *//*-*****************************************************************************************************/
166 sal_Int32 GetMacroSecurityLevel ( ) const;
167 void SetMacroSecurityLevel ( sal_Int32 _nLevel );
169 bool IsMacroDisabled ( ) const;
172 Check whether the given uri is either no dangerous macro-execution
173 URI at all or else the given referer is a trusted source.
175 bool isSecureMacroUri(OUString const & uri, OUString const & referer)
176 const;
179 Check whether the given referer URI is untrusted, and links
180 originating from it should not be accessed.
182 bool isUntrustedReferer(OUString const & referer) const;
185 Check whether the given uri is a trusted location.
187 bool isTrustedLocationUri(OUString const & uri) const;
189 ::com::sun::star::uno::Sequence< Certificate > GetTrustedAuthors ( ) const;
190 void SetTrustedAuthors ( const ::com::sun::star::uno::Sequence< Certificate >& rAuthors );
192 // for bool options only!
193 bool IsOptionSet ( EOption eOption ) const;
194 bool SetOption ( EOption eOption, bool bValue );
195 bool IsOptionEnabled ( EOption eOption ) const;
197 // xmlsec05 deprecated methods
198 bool IsExecutePlugins() const;
199 void SetExecutePlugins( bool bSet );
200 EBasicSecurityMode GetBasicMode( ) const;
201 void SetBasicMode( EBasicSecurityMode eMode );
202 bool IsWarningEnabled() const;
203 void SetWarningEnabled( bool bSet );
204 bool IsConfirmationEnabled() const;
205 void SetConfirmationEnabled( bool bSet );
207 // private methods
209 private:
211 /*-****************************************************************************************************
212 @short return a reference to a static mutex
213 @descr These class is partially threadsafe (for de-/initialization only).
214 All access methods are'nt safe!
215 We create a static mutex only for one ime and use at different times.
216 @return A reference to a static mutex member.
217 *//*-*****************************************************************************************************/
219 UNOTOOLS_DLLPRIVATE static ::osl::Mutex& GetInitMutex();
221 // private member
223 private:
225 /*Attention
227 Don't initialize these static members in these headers!
228 a) Double defined symbols will be detected ...
229 b) and unresolved externals exist at linking time.
230 Do it in your source only.
233 static SvtSecurityOptions_Impl* m_pDataContainer;
234 static sal_Int32 m_nRefCount;
236 }; // class SvtSecurityOptions
238 #endif // INCLUDED_UNOTOOLS_SECURITYOPTIONS_HXX
240 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */