1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _XMLSECURITY_MACROSECURITY_HXX
29 #define _XMLSECURITY_MACROSECURITY_HXX
30 
31 #include <vcl/fixed.hxx>
32 #include <vcl/button.hxx>
33 #include <vcl/lstbox.hxx>
34 #include <vcl/tabdlg.hxx>
35 #include <vcl/tabctrl.hxx>
36 #include <vcl/tabpage.hxx>
37 #include <svtools/stdctrl.hxx>
38 #include <svx/simptabl.hxx>
39 #include <unotools/securityoptions.hxx>
40 
41 namespace com {
42 namespace sun {
43 namespace star {
44 namespace xml { namespace crypto {
45     class XSecurityEnvironment; }}
46 }}}
47 
48 namespace css = com::sun::star;
49 namespace cssu = com::sun::star::uno;
50 namespace dcss = ::com::sun::star;
51 
52 class MacroSecurityTP;
53 
54 class ReadOnlyImage : public FixedImage
55 {
56 public:
57     ReadOnlyImage(Window* pParent, const ResId rResId);
58     ~ReadOnlyImage();
59 
60     virtual void        RequestHelp( const HelpEvent& rHEvt );
61     static const String& GetHelpTip();
62 };
63 
64 class MacroSecurity : public TabDialog
65 {
66 private:
67 	friend class MacroSecurityLevelTP;
68 	friend class MacroSecurityTrustedSourcesTP;
69 
70 	TabControl			maTabCtrl;
71 	OKButton			maOkBtn;
72 	CancelButton		maCancelBtn;
73 	HelpButton			maHelpBtn;
74 	PushButton			maResetBtn;
75 
76 	cssu::Reference< cssu::XComponentContext >	mxCtx;
77 	cssu::Reference< dcss::xml::crypto::XSecurityEnvironment >	mxSecurityEnvironment;
78 	SvtSecurityOptions											maSecOptions;
79 
80     MacroSecurityTP*	mpLevelTP;
81 	MacroSecurityTP*	mpTrustSrcTP;
82 
83 	DECL_LINK(			OkBtnHdl, void* );
84 public:
85 	MacroSecurity( Window* pParent, const cssu::Reference< cssu::XComponentContext>& rxCtx, const cssu::Reference< dcss::xml::crypto::XSecurityEnvironment >& rxSecurityEnvironment );
86 	virtual				~MacroSecurity();
87 
88 	inline void		EnableReset( bool _bEnable = true );
89 };
90 
91 inline void MacroSecurity::EnableReset( bool _bEnable )
92 {
93 	maResetBtn.Enable ( _bEnable );
94 }
95 
96 class MacroSecurityTP : public TabPage
97 {
98 protected:
99 	MacroSecurity*		mpDlg;
100 public:
101 						MacroSecurityTP( Window* _pParent, const ResId& _rResId, MacroSecurity* _pDlg );
102 	inline void			SetTabDlg( MacroSecurity* pTabDlg );
103 
104 	virtual void		ClosePage( void ) = 0;
105 };
106 
107 inline void MacroSecurityTP::SetTabDlg( MacroSecurity* _pTabDlg )
108 {
109 	mpDlg = _pTabDlg;
110 }
111 
112 
113 class MacroSecurityLevelTP : public MacroSecurityTP
114 {
115 private:
116 	FixedLine			maSecLevelFL;
117     ReadOnlyImage       maSecReadonlyFI;
118     RadioButton         maVeryHighRB;
119 	RadioButton			maHighRB;
120 	RadioButton			maMediumRB;
121 	RadioButton			maLowRB;
122 
123 	sal_uInt16              mnCurLevel;
124 
125 protected:
126 	DECL_LINK(			RadioButtonHdl, RadioButton* );
127 
128 public:
129 						MacroSecurityLevelTP( Window* pParent, MacroSecurity* _pDlg );
130 
131 	virtual void		ClosePage( void );
132 };
133 
134 
135 class MacroSecurityTrustedSourcesTP : public MacroSecurityTP
136 {
137 private:
138 	FixedLine			maTrustCertFL;
139     ReadOnlyImage       maTrustCertROFI;
140     SvxSimpleTable      maTrustCertLB;  // PB 2006/02/02 #i48648 now SvHeaderTabListBox
141 	PushButton			maAddCertPB;
142 	PushButton			maViewCertPB;
143 	PushButton			maRemoveCertPB;
144 	FixedLine			maTrustFileLocFL;
145     ReadOnlyImage       maTrustFileROFI;
146     FixedInfo           maTrustFileLocFI;
147 	ListBox				maTrustFileLocLB;
148 	PushButton			maAddLocPB;
149 	PushButton			maRemoveLocPB;
150 
151     cssu::Sequence< SvtSecurityOptions::Certificate > maTrustedAuthors;
152 
153     sal_Bool            mbAuthorsReadonly;
154     sal_Bool            mbURLsReadonly;
155 
156 	DECL_LINK(			ViewCertPBHdl, void* );
157 	DECL_LINK(			RemoveCertPBHdl, void* );
158 	DECL_LINK(			AddLocPBHdl, void* );
159 	DECL_LINK(			RemoveLocPBHdl, void* );
160 	DECL_LINK(			TrustCertLBSelectHdl, void* );
161 	DECL_LINK(			TrustFileLocLBSelectHdl, void* );
162 
163 	void				FillCertLB( void );
164     void                ImplCheckButtons();
165 
166 public:
167 						MacroSecurityTrustedSourcesTP( Window* pParent, MacroSecurity* _pDlg );
168 
169 	virtual void		ActivatePage();
170 	virtual void		ClosePage( void );
171 };
172 
173 
174 #endif // _XMLSECURITY_MACROSECURITY_HXX
175 
176