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 #ifndef INCLUDED_XMLSECURITY_INC_MACROSECURITY_HXX 21 #define INCLUDED_XMLSECURITY_INC_MACROSECURITY_HXX 22 23 #include <vcl/weld.hxx> 24 #include <unotools/securityoptions.hxx> 25 26 namespace com { 27 namespace sun { 28 namespace star { 29 namespace xml { namespace crypto { 30 class XSecurityEnvironment; }} 31 }}} 32 33 class MacroSecurityTP; 34 35 class MacroSecurity : public weld::GenericDialogController 36 { 37 private: 38 friend class MacroSecurityLevelTP; 39 friend class MacroSecurityTrustedSourcesTP; 40 41 css::uno::Reference<css::xml::crypto::XSecurityEnvironment> m_xSecurityEnvironment; 42 SvtSecurityOptions m_aSecOptions; 43 44 std::unique_ptr<weld::Notebook> m_xTabCtrl; 45 std::unique_ptr<weld::Button> m_xOkBtn; 46 std::unique_ptr<weld::Button> m_xResetBtn; 47 48 std::unique_ptr<MacroSecurityTP> m_xLevelTP; 49 std::unique_ptr<MacroSecurityTP> m_xTrustSrcTP; 50 51 DECL_LINK(ActivatePageHdl, const OString&, void); 52 DECL_LINK(OkBtnHdl, weld::Button&, void); 53 public: 54 MacroSecurity(weld::Window* pParent, 55 const css::uno::Reference<css::xml::crypto::XSecurityEnvironment>& rxSecurityEnvironment); 56 EnableReset(bool bEnable=true)57 void EnableReset(bool bEnable = true) 58 { 59 m_xResetBtn->set_sensitive(bEnable); 60 } 61 }; 62 63 class MacroSecurityTP 64 { 65 protected: 66 std::unique_ptr<weld::Builder> m_xBuilder; 67 std::unique_ptr<weld::Container> m_xContainer; 68 69 MacroSecurity* m_pDlg; 70 public: 71 MacroSecurityTP(weld::Container* pParent, const OUString& rUIXMLDescription, 72 const OString& rID, MacroSecurity* pDlg); 73 virtual ~MacroSecurityTP(); 74 75 virtual void ActivatePage(); 76 virtual void ClosePage() = 0; 77 }; 78 79 class MacroSecurityLevelTP : public MacroSecurityTP 80 { 81 private: 82 sal_uInt16 mnCurLevel; 83 84 std::unique_ptr<weld::RadioButton> m_xVeryHighRB; 85 std::unique_ptr<weld::RadioButton> m_xHighRB; 86 std::unique_ptr<weld::RadioButton> m_xMediumRB; 87 std::unique_ptr<weld::RadioButton> m_xLowRB; 88 std::unique_ptr<weld::Widget> m_xVHighImg; 89 std::unique_ptr<weld::Widget> m_xHighImg; 90 std::unique_ptr<weld::Widget> m_xMedImg; 91 std::unique_ptr<weld::Widget> m_xLowImg; 92 93 DECL_LINK(RadioButtonHdl, weld::ToggleButton&, void); 94 public: 95 MacroSecurityLevelTP(weld::Container* pParent, MacroSecurity* pDlg); 96 virtual void ClosePage() override; 97 }; 98 99 class MacroSecurityTrustedSourcesTP : public MacroSecurityTP 100 { 101 private: 102 css::uno::Sequence< SvtSecurityOptions::Certificate > m_aTrustedAuthors; 103 104 bool mbAuthorsReadonly; 105 bool mbURLsReadonly; 106 107 std::unique_ptr<weld::Image> m_xTrustCertROFI; 108 std::unique_ptr<weld::TreeView> m_xTrustCertLB; 109 std::unique_ptr<weld::Button> m_xViewCertPB; 110 std::unique_ptr<weld::Button> m_xRemoveCertPB; 111 std::unique_ptr<weld::Image> m_xTrustFileROFI; 112 std::unique_ptr<weld::TreeView> m_xTrustFileLocLB; 113 std::unique_ptr<weld::Button> m_xAddLocPB; 114 std::unique_ptr<weld::Button> m_xRemoveLocPB; 115 116 DECL_LINK(ViewCertPBHdl, weld::Button&, void); 117 DECL_LINK(RemoveCertPBHdl, weld::Button&, void); 118 DECL_LINK(AddLocPBHdl, weld::Button&, void); 119 DECL_LINK(RemoveLocPBHdl, weld::Button&, void); 120 DECL_LINK(TrustCertLBSelectHdl, weld::TreeView&, void); 121 DECL_LINK(TrustFileLocLBSelectHdl, weld::TreeView&, void); 122 123 void FillCertLB(const bool bShowWarnings = false); 124 void ImplCheckButtons(); 125 void ShowBrokenCertificateError(const OUString& rData); 126 127 public: 128 MacroSecurityTrustedSourcesTP(weld::Container* pParent, MacroSecurity* pDlg); 129 130 virtual void ActivatePage() override; 131 virtual void ClosePage() override; 132 }; 133 134 135 #endif // INCLUDED_XMLSECURITY_INC_MACROSECURITY_HXX 136 137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 138