tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / include / unotools / securityoptions.hxx
blob5322f2615ba32269b52caf4180149cea6bcf4896
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 #pragma once
21 #include <unotools/unotoolsdllapi.h>
22 #include <sal/types.h>
23 #include <rtl/ustring.hxx>
24 #include <vector>
25 #include <unordered_map>
27 /*-************************************************************************************************************
28 @short collect information about security features
29 @ATTENTION This class is partially threadsafe.
31 @devstatus ready to use
32 *//*-*************************************************************************************************************/
34 namespace SvtSecurityOptions
36 enum class EOption
38 SecureUrls,
39 DocWarnSaveOrSend,
40 DocWarnSigning,
41 DocWarnPrint,
42 DocWarnCreatePdf,
43 DocWarnRemovePersonalInfo,
44 DocWarnKeepRedlineInfo,
45 DocWarnKeepDocUserInfo,
46 DocWarnKeepNoteAuthorDateInfo,
47 DocWarnKeepDocVersionInfo,
48 DocKeepPrinterSettings,
49 DocWarnRecommendPassword,
50 MacroSecLevel,
51 MacroTrustedAuthors,
52 CtrlClickHyperlink,
53 BlockUntrustedRefererLinks,
54 DisableActiveContent
57 struct Certificate
59 OUString SubjectName;
60 OUString SerialNumber;
61 OUString RawData;
63 bool operator==(const Certificate& other) const
65 return SubjectName == other.SubjectName && SerialNumber == other.SerialNumber && RawData == other.RawData;
70 /*-****************************************************************************************************
71 @short returns readonly state
72 @descr It can be called to get information about the readonly state of a provided item.
73 @param "eOption", specify, which item is queried
74 @return <TRUE/> if item is readonly; <FALSE/> otherwise
76 @onerror No error should occur!
77 *//*-*****************************************************************************************************/
79 UNOTOOLS_DLLPUBLIC bool IsReadOnly( EOption eOption );
81 /*-****************************************************************************************************
82 @short interface methods to get and set value of config key "org.openoffice.Office.Common/Security/Scripting/SecureURL"
83 @descr These value displays the list of all trustworthy URLs.
84 zB.: file:/ => All scripts from the local file system including a LAN;
85 private:explorer => Scripts from the Explorer;
86 private:help => Scripts in the help system;
87 private:newmenu => Scripts that are executed by the commands File-New and AutoPilot;
88 private:schedule => Scripts of the scheduler;
89 private:searchfolder => Scripts of the searchfolder;
90 private:user => Scripts that are entered in the URL field.
91 @param "seqURLList", new values to set it in configuration.
92 @return The values which represent current state of internal variable.
94 @onerror No error should occur!
95 *//*-*****************************************************************************************************/
97 UNOTOOLS_DLLPUBLIC std::vector< OUString > GetSecureURLs();
98 UNOTOOLS_DLLPUBLIC void SetSecureURLs( std::vector< OUString >&& seqURLList );
100 /*-****************************************************************************************************
101 @short interface methods to get and set value of config key "org.openoffice.Office.Common/Security/Scripting/MacroSecurityLevel"
102 @descr These value determines how StarOffice Basic scripts should be handled.
103 It exist 3 different modes:
104 0 = never execute
105 1 = from list
106 2 = always execute
108 @ATTENTION These methods don't check for valid or invalid values!
109 Our configuration server can do it ... but these implementation don't get any notifications
110 about wrong commits ...!
111 => If you set an invalid value - nothing will be changed. The information will lost.
113 @seealso enum EBasicSecurityMode
115 @param "eMode" to set new mode ... Value must defined as an enum of type EBasicSecurityMode!
116 @return An enum value, which present current mode.
118 @onerror No error should occur!
119 *//*-*****************************************************************************************************/
121 UNOTOOLS_DLLPUBLIC sal_Int32 GetMacroSecurityLevel();
122 UNOTOOLS_DLLPUBLIC void SetMacroSecurityLevel( sal_Int32 _nLevel );
124 UNOTOOLS_DLLPUBLIC bool IsMacroDisabled();
127 Check whether the given uri is either no dangerous macro-execution
128 URI at all or else the given referer is a trusted source.
130 UNOTOOLS_DLLPUBLIC bool isSecureMacroUri(OUString const & uri, OUString const & referer);
133 Check whether the given referer URI is untrusted, and links
134 originating from it should not be accessed.
136 UNOTOOLS_DLLPUBLIC bool isUntrustedReferer(OUString const & referer);
139 Check whether the given uri is a trusted location.
141 UNOTOOLS_DLLPUBLIC bool isTrustedLocationUri(OUString const & uri);
143 UNOTOOLS_DLLPUBLIC bool isTrustedLocationUriForUpdatingLinks(OUString const & uri);
145 UNOTOOLS_DLLPUBLIC std::vector< Certificate > GetTrustedAuthors();
146 UNOTOOLS_DLLPUBLIC void SetTrustedAuthors( const std::vector< Certificate >& rAuthors );
148 // for bool options only!
149 UNOTOOLS_DLLPUBLIC bool IsOptionSet ( EOption eOption );
150 UNOTOOLS_DLLPUBLIC void SetOption ( EOption eOption, bool bValue );
152 } // namespace SvtSecurityOptions
154 // map personal info strings, e.g. authors to 1, 2, 3... for removing personal info
156 class UNOTOOLS_DLLPUBLIC SvtSecurityMapPersonalInfo
158 std::unordered_map< OUString, size_t > aInfoIDs;
159 public:
160 size_t GetInfoID( const OUString& sPersonalInfo );
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */