1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <vcl/weld.hxx>
23 #include <unotools/securityoptions.hxx>
25 namespace com::sun::star::xml::crypto
{ class XSecurityEnvironment
; }
26 class MacroSecurityTP
;
28 class MacroSecurity final
: public weld::GenericDialogController
31 friend class MacroSecurityLevelTP
;
32 friend class MacroSecurityTrustedSourcesTP
;
34 css::uno::Reference
<css::xml::crypto::XSecurityEnvironment
> m_xSecurityEnvironment
;
36 std::unique_ptr
<weld::Notebook
> m_xTabCtrl
;
37 std::unique_ptr
<weld::Button
> m_xOkBtn
;
38 std::unique_ptr
<weld::Button
> m_xResetBtn
;
40 std::unique_ptr
<MacroSecurityTP
> m_xLevelTP
;
41 std::unique_ptr
<MacroSecurityTP
> m_xTrustSrcTP
;
43 DECL_LINK(ActivatePageHdl
, const OUString
&, void);
44 DECL_LINK(OkBtnHdl
, weld::Button
&, void);
46 MacroSecurity(weld::Window
* pParent
,
47 css::uno::Reference
<css::xml::crypto::XSecurityEnvironment
> xSecurityEnvironment
);
49 void EnableReset(bool bEnable
= true)
51 m_xResetBtn
->set_sensitive(bEnable
);
58 std::unique_ptr
<weld::Builder
> m_xBuilder
;
59 std::unique_ptr
<weld::Container
> m_xContainer
;
61 MacroSecurity
* m_pDlg
;
63 MacroSecurityTP(weld::Container
* pParent
, const OUString
& rUIXMLDescription
,
64 const OUString
& rID
, MacroSecurity
* pDlg
);
65 virtual ~MacroSecurityTP();
67 virtual void ActivatePage();
68 virtual void ClosePage() = 0;
71 class MacroSecurityLevelTP
: public MacroSecurityTP
74 sal_uInt16 mnCurLevel
;
75 // Stores the security level when the dialog opens. Used to check if the value changed
76 sal_uInt16 mnInitialLevel
;
78 std::unique_ptr
<weld::RadioButton
> m_xVeryHighRB
;
79 std::unique_ptr
<weld::RadioButton
> m_xHighRB
;
80 std::unique_ptr
<weld::RadioButton
> m_xMediumRB
;
81 std::unique_ptr
<weld::RadioButton
> m_xLowRB
;
82 std::unique_ptr
<weld::Widget
> m_xVHighImg
;
83 std::unique_ptr
<weld::Widget
> m_xHighImg
;
84 std::unique_ptr
<weld::Widget
> m_xMedImg
;
85 std::unique_ptr
<weld::Widget
> m_xLowImg
;
86 std::unique_ptr
<weld::Label
> m_xWarningLb
;
87 std::unique_ptr
<weld::Image
> m_xWarningImg
;
88 std::unique_ptr
<weld::Box
> m_xWarningBox
;
90 void SetWarningLabel(const OUString
& sMsg
);
92 DECL_LINK(RadioButtonHdl
, weld::Toggleable
&, void);
94 MacroSecurityLevelTP(weld::Container
* pParent
, MacroSecurity
* pDlg
);
95 virtual void ClosePage() override
;
98 class MacroSecurityTrustedSourcesTP
: public MacroSecurityTP
101 std::vector
< SvtSecurityOptions::Certificate
> m_aTrustedAuthors
;
103 bool mbAuthorsReadonly
;
106 std::unique_ptr
<weld::Image
> m_xTrustCertROFI
;
107 std::unique_ptr
<weld::TreeView
> m_xTrustCertLB
;
108 std::unique_ptr
<weld::Button
> m_xViewCertPB
;
109 std::unique_ptr
<weld::Button
> m_xRemoveCertPB
;
110 std::unique_ptr
<weld::Image
> m_xTrustFileROFI
;
111 std::unique_ptr
<weld::TreeView
> m_xTrustFileLocLB
;
112 std::unique_ptr
<weld::Button
> m_xAddLocPB
;
113 std::unique_ptr
<weld::Button
> m_xRemoveLocPB
;
115 DECL_LINK(ViewCertPBHdl
, weld::Button
&, void);
116 DECL_LINK(RemoveCertPBHdl
, weld::Button
&, void);
117 DECL_LINK(AddLocPBHdl
, weld::Button
&, void);
118 DECL_LINK(RemoveLocPBHdl
, weld::Button
&, void);
119 DECL_LINK(TrustCertLBSelectHdl
, weld::TreeView
&, void);
120 DECL_LINK(TrustFileLocLBSelectHdl
, weld::TreeView
&, void);
122 void FillCertLB(const bool bShowWarnings
= false);
123 void ImplCheckButtons();
124 void ShowBrokenCertificateError(std::u16string_view rData
);
127 MacroSecurityTrustedSourcesTP(weld::Container
* pParent
, MacroSecurity
* pDlg
);
129 virtual void ActivatePage() override
;
130 virtual void ClosePage() override
;
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */