Branch data Line data Source code
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 : :
21 : : #include <xmlsecurity/macrosecurity.hxx>
22 : : #include <xmlsecurity/certificatechooser.hxx>
23 : : #include <xmlsecurity/certificateviewer.hxx>
24 : : #include <xmlsecurity/biginteger.hxx>
25 : :
26 : : #include <osl/file.hxx>
27 : : #include <vcl/help.hxx>
28 : :
29 : :
30 : : #include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
31 : : #include <com/sun/star/security/SerialNumberAdapter.hpp>
32 : : #include <comphelper/sequence.hxx>
33 : : #include <sfx2/filedlghelper.hxx>
34 : : #include <comphelper/processfactory.hxx>
35 : : #include <com/sun/star/uno/Exception.hpp>
36 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
37 : : #include <com/sun/star/ui/dialogs/XFolderPicker.hpp>
38 : : #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
39 : : #include <tools/urlobj.hxx>
40 : :
41 : : #include <vcl/msgbox.hxx>
42 : :
43 : : #include "dialogs.hrc"
44 : : #include "resourcemanager.hxx"
45 : :
46 : : /* HACK: disable some warnings for MS-C */
47 : : #ifdef _MSC_VER
48 : : #pragma warning (disable : 4355) // 4355: this used in initializer-list
49 : : #endif
50 : :
51 : : using namespace ::com::sun::star;
52 : :
53 : :
54 : 0 : IMPL_LINK_NOARG(MacroSecurity, OkBtnHdl)
55 : : {
56 : 0 : mpLevelTP->ClosePage();
57 : 0 : mpTrustSrcTP->ClosePage();
58 : :
59 : 0 : EndDialog( RET_OK );
60 : :
61 : 0 : return 0;
62 : : }
63 : :
64 : 0 : MacroSecurity::MacroSecurity( Window* _pParent, const cssu::Reference< cssu::XComponentContext> &_rxCtx, const cssu::Reference< dcss::xml::crypto::XSecurityEnvironment >& _rxSecurityEnvironment )
65 : 0 : :TabDialog ( _pParent, XMLSEC_RES( RID_XMLSECTP_MACROSEC ) )
66 [ # # ]: 0 : ,maTabCtrl ( this, XMLSEC_RES( 1 ) )
67 [ # # ]: 0 : ,maOkBtn ( this, XMLSEC_RES( BTN_OK ) )
68 [ # # ]: 0 : ,maCancelBtn ( this, XMLSEC_RES( BTN_CANCEL ) )
69 [ # # ]: 0 : ,maHelpBtn ( this, XMLSEC_RES( BTN_HELP ) )
70 [ # # ][ # # ]: 0 : ,maResetBtn ( this, XMLSEC_RES( BTN_RESET ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
71 : : {
72 [ # # ]: 0 : FreeResource();
73 : :
74 [ # # ]: 0 : mxCtx = _rxCtx;
75 [ # # ]: 0 : mxSecurityEnvironment = _rxSecurityEnvironment;
76 : :
77 [ # # ][ # # ]: 0 : mpLevelTP = new MacroSecurityLevelTP( &maTabCtrl, this );
78 [ # # ][ # # ]: 0 : mpTrustSrcTP = new MacroSecurityTrustedSourcesTP( &maTabCtrl, this );
79 : :
80 [ # # ]: 0 : maTabCtrl.SetTabPage( RID_XMLSECTP_SECLEVEL, mpLevelTP );
81 [ # # ]: 0 : maTabCtrl.SetTabPage( RID_XMLSECTP_TRUSTSOURCES, mpTrustSrcTP );
82 [ # # ]: 0 : maTabCtrl.SetCurPageId( RID_XMLSECTP_SECLEVEL );
83 : :
84 [ # # ]: 0 : maOkBtn.SetClickHdl( LINK( this, MacroSecurity, OkBtnHdl ) );
85 : 0 : }
86 : :
87 [ # # ][ # # ]: 0 : MacroSecurity::~MacroSecurity()
[ # # ][ # # ]
[ # # ][ # # ]
88 : : {
89 [ # # ][ # # ]: 0 : delete maTabCtrl.GetTabPage( RID_XMLSECTP_TRUSTSOURCES );
[ # # ]
90 [ # # ][ # # ]: 0 : delete maTabCtrl.GetTabPage( RID_XMLSECTP_SECLEVEL );
[ # # ]
91 [ # # ]: 0 : }
92 : :
93 : :
94 : 0 : MacroSecurityTP::MacroSecurityTP( Window* _pParent, const ResId& _rResId, MacroSecurity* _pDlg )
95 : : :TabPage ( _pParent, _rResId )
96 : 0 : ,mpDlg ( _pDlg )
97 : : {
98 : 0 : }
99 : :
100 : 0 : MacroSecurityLevelTP::MacroSecurityLevelTP( Window* _pParent, MacroSecurity* _pDlg )
101 : 0 : :MacroSecurityTP ( _pParent, XMLSEC_RES( RID_XMLSECTP_SECLEVEL ), _pDlg )
102 [ # # ]: 0 : ,maSecLevelFL ( this, XMLSEC_RES( FL_SECLEVEL ) )
103 [ # # ]: 0 : ,maSecReadonlyFI ( this, XMLSEC_RES( FI_SEC_READONLY ))
104 [ # # ]: 0 : ,maVeryHighRB ( this, XMLSEC_RES( RB_VERYHIGH ) )
105 [ # # ]: 0 : ,maHighRB ( this, XMLSEC_RES( RB_HIGH ) )
106 [ # # ]: 0 : ,maMediumRB ( this, XMLSEC_RES( RB_MEDIUM ) )
107 [ # # ][ # # ]: 0 : ,maLowRB ( this, XMLSEC_RES( RB_LOW ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
108 : : {
109 [ # # ]: 0 : FreeResource();
110 : :
111 [ # # ]: 0 : maLowRB.SetClickHdl( LINK( this, MacroSecurityLevelTP, RadioButtonHdl ) );
112 [ # # ]: 0 : maMediumRB.SetClickHdl( LINK( this, MacroSecurityLevelTP, RadioButtonHdl ) );
113 [ # # ]: 0 : maHighRB.SetClickHdl( LINK( this, MacroSecurityLevelTP, RadioButtonHdl ) );
114 [ # # ]: 0 : maVeryHighRB.SetClickHdl( LINK( this, MacroSecurityLevelTP, RadioButtonHdl ) );
115 : :
116 [ # # ]: 0 : mnCurLevel = (sal_uInt16) mpDlg->maSecOptions.GetMacroSecurityLevel();
117 [ # # ]: 0 : sal_Bool bReadonly = mpDlg->maSecOptions.IsReadOnly( SvtSecurityOptions::E_MACRO_SECLEVEL );
118 : :
119 : 0 : RadioButton* pCheck = 0;
120 [ # # # # : 0 : switch( mnCurLevel )
# ]
121 : : {
122 : 0 : case 3: pCheck = &maVeryHighRB; break;
123 : 0 : case 2: pCheck = &maHighRB; break;
124 : 0 : case 1: pCheck = &maMediumRB; break;
125 : 0 : case 0: pCheck = &maLowRB; break;
126 : : }
127 [ # # ]: 0 : if(pCheck)
128 [ # # ]: 0 : pCheck->Check();
129 : : else
130 : : {
131 : : OSL_FAIL("illegal macro security level");
132 : : }
133 [ # # ]: 0 : maSecReadonlyFI.Show(bReadonly);
134 [ # # ]: 0 : if(bReadonly)
135 : : {
136 : : //move to the selected button
137 [ # # ][ # # ]: 0 : if( pCheck && pCheck != &maVeryHighRB)
138 : : {
139 [ # # ][ # # ]: 0 : long nDiff = pCheck->GetPosPixel().Y() - maVeryHighRB.GetPosPixel().Y();
140 [ # # ]: 0 : Point aPos(maSecReadonlyFI.GetPosPixel());
141 : 0 : aPos.Y() += nDiff;
142 [ # # ]: 0 : maSecReadonlyFI.SetPosPixel(aPos);
143 : : }
144 [ # # ]: 0 : maVeryHighRB.Enable(sal_False);
145 [ # # ]: 0 : maHighRB.Enable(sal_False);
146 [ # # ]: 0 : maMediumRB.Enable(sal_False);
147 [ # # ]: 0 : maLowRB.Enable(sal_False);
148 : : }
149 : :
150 : 0 : }
151 : :
152 : 0 : IMPL_LINK_NOARG(MacroSecurityLevelTP, RadioButtonHdl)
153 : : {
154 : 0 : sal_uInt16 nNewLevel = 0;
155 [ # # ]: 0 : if( maVeryHighRB.IsChecked() )
156 : 0 : nNewLevel = 3;
157 [ # # ]: 0 : else if( maHighRB.IsChecked() )
158 : 0 : nNewLevel = 2;
159 [ # # ]: 0 : else if( maMediumRB.IsChecked() )
160 : 0 : nNewLevel = 1;
161 : :
162 [ # # ]: 0 : if ( nNewLevel != mnCurLevel )
163 : : {
164 : 0 : mnCurLevel = nNewLevel;
165 : 0 : mpDlg->EnableReset();
166 : : }
167 : :
168 : 0 : return 0;
169 : : }
170 : :
171 : 0 : void MacroSecurityLevelTP::ClosePage( void )
172 : : {
173 : 0 : mpDlg->maSecOptions.SetMacroSecurityLevel( mnCurLevel );
174 : 0 : }
175 : :
176 : 0 : void MacroSecurityTrustedSourcesTP::ImplCheckButtons()
177 : : {
178 : 0 : bool bCertSelected = maTrustCertLB.FirstSelected() != NULL;
179 : 0 : maViewCertPB.Enable( bCertSelected );
180 [ # # ][ # # ]: 0 : maRemoveCertPB.Enable( bCertSelected && !mbAuthorsReadonly);
181 : :
182 : 0 : bool bLocationSelected = maTrustFileLocLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND;
183 [ # # ][ # # ]: 0 : maRemoveLocPB.Enable( bLocationSelected && !mbURLsReadonly);
184 : 0 : }
185 : :
186 : :
187 : 0 : IMPL_LINK_NOARG(MacroSecurityTrustedSourcesTP, ViewCertPBHdl)
188 : : {
189 [ # # ]: 0 : if( maTrustCertLB.FirstSelected() )
190 : : {
191 [ # # ]: 0 : sal_uInt16 nSelected = sal_uInt16( sal_uIntPtr( maTrustCertLB.FirstSelected()->GetUserData() ) );
192 : :
193 : : uno::Reference< dcss::security::XSerialNumberAdapter > xSerialNumberAdapter =
194 [ # # ]: 0 : ::com::sun::star::security::SerialNumberAdapter::create(mpDlg->mxCtx);
195 : :
196 [ # # ][ # # ]: 0 : uno::Reference< dcss::security::XCertificate > xCert = mpDlg->mxSecurityEnvironment->getCertificate( maTrustedAuthors[nSelected][0], xSerialNumberAdapter->toSequence( maTrustedAuthors[nSelected][1] ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
197 : :
198 : : // If we don't get it, create it from signature data:
199 [ # # ]: 0 : if ( !xCert.is() )
200 [ # # ][ # # ]: 0 : xCert = mpDlg->mxSecurityEnvironment->createCertificateFromAscii( maTrustedAuthors[nSelected][2] ) ;
[ # # ][ # # ]
[ # # ]
201 : :
202 : : DBG_ASSERT( xCert.is(), "*MacroSecurityTrustedSourcesTP::ViewCertPBHdl(): Certificate not found and can't be created!" );
203 : :
204 [ # # ]: 0 : if ( xCert.is() )
205 : : {
206 [ # # ]: 0 : CertificateViewer aViewer( this, mpDlg->mxSecurityEnvironment, xCert, sal_False );
207 [ # # ][ # # ]: 0 : aViewer.Execute();
208 : 0 : }
209 : : }
210 : 0 : return 0;
211 : : }
212 : :
213 : 0 : IMPL_LINK_NOARG(MacroSecurityTrustedSourcesTP, RemoveCertPBHdl)
214 : : {
215 [ # # ]: 0 : if( maTrustCertLB.FirstSelected() )
216 : : {
217 : 0 : sal_uInt16 nAuthor = sal_uInt16( sal_uIntPtr( maTrustCertLB.FirstSelected()->GetUserData() ) );
218 : 0 : ::comphelper::removeElementAt( maTrustedAuthors, nAuthor );
219 : :
220 : 0 : FillCertLB();
221 : 0 : ImplCheckButtons();
222 : : }
223 : :
224 : 0 : return 0;
225 : : }
226 : :
227 : 0 : IMPL_LINK_NOARG(MacroSecurityTrustedSourcesTP, AddLocPBHdl)
228 : : {
229 : : try
230 : : {
231 [ # # ]: 0 : rtl::OUString aService( RTL_CONSTASCII_USTRINGPARAM( FOLDER_PICKER_SERVICE_NAME ) );
232 [ # # ]: 0 : uno::Reference < lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
233 [ # # ][ # # ]: 0 : uno::Reference < ui::dialogs::XFolderPicker > xFolderPicker( xFactory->createInstance( aService ), uno::UNO_QUERY );
[ # # ]
234 : :
235 [ # # ][ # # ]: 0 : short nRet = xFolderPicker->execute();
236 : :
237 [ # # ]: 0 : if( ui::dialogs::ExecutableDialogResults::OK != nRet )
238 : 0 : return 0;
239 : :
240 [ # # ][ # # ]: 0 : rtl::OUString aPathStr = xFolderPicker->getDirectory();
241 [ # # ]: 0 : INetURLObject aNewObj( aPathStr );
242 [ # # ]: 0 : aNewObj.removeFinalSlash();
243 : :
244 : : // then the new path also an URL else system path
245 : 0 : ::rtl::OUString aSystemFileURL = ( aNewObj.GetProtocol() != INET_PROT_NOT_VALID ) ?
246 [ # # ][ # # ]: 0 : aPathStr : aNewObj.getFSysPath( INetURLObject::FSYS_DETECT );
247 : :
248 [ # # ]: 0 : String aNewPathStr(aSystemFileURL);
249 : :
250 [ # # ][ # # ]: 0 : if ( osl::FileBase::getSystemPathFromFileURL( aSystemFileURL, aSystemFileURL ) == osl::FileBase::E_None )
251 [ # # ]: 0 : aNewPathStr = aSystemFileURL;
252 : :
253 [ # # ][ # # ]: 0 : if( maTrustFileLocLB.GetEntryPos( aNewPathStr ) == LISTBOX_ENTRY_NOTFOUND )
254 : : {
255 [ # # ]: 0 : maTrustFileLocLB.InsertEntry( aNewPathStr );
256 : : }
257 : :
258 [ # # ][ # # ]: 0 : ImplCheckButtons();
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
259 : : }
260 : 0 : catch( uno::Exception& )
261 : : {
262 : : SAL_WARN( "xmlsecurity.dialogs", "MacroSecurityTrustedSourcesTP::AddLocPBHdl(): exception from folder picker" );
263 : : }
264 : :
265 : 0 : return 0;
266 : : }
267 : :
268 : 0 : IMPL_LINK_NOARG(MacroSecurityTrustedSourcesTP, RemoveLocPBHdl)
269 : : {
270 : 0 : sal_uInt16 nSel = maTrustFileLocLB.GetSelectEntryPos();
271 [ # # ]: 0 : if( nSel != LISTBOX_ENTRY_NOTFOUND )
272 : : {
273 : 0 : maTrustFileLocLB.RemoveEntry( nSel );
274 : : // Trusted Path could not be removed (#i33584#)
275 : : // after remove an entry, select another one if exists
276 : 0 : sal_uInt16 nNewCount = maTrustFileLocLB.GetEntryCount();
277 [ # # ]: 0 : if ( nNewCount > 0 )
278 : : {
279 [ # # ]: 0 : if ( nSel >= nNewCount )
280 : 0 : nSel = nNewCount - 1;
281 : 0 : maTrustFileLocLB.SelectEntryPos( nSel );
282 : : }
283 : 0 : ImplCheckButtons();
284 : : }
285 : :
286 : 0 : return 0;
287 : : }
288 : :
289 : 0 : IMPL_LINK_NOARG(MacroSecurityTrustedSourcesTP, TrustCertLBSelectHdl)
290 : : {
291 : 0 : ImplCheckButtons();
292 : 0 : return 0;
293 : : }
294 : :
295 : 0 : IMPL_LINK_NOARG(MacroSecurityTrustedSourcesTP, TrustFileLocLBSelectHdl)
296 : : {
297 : 0 : ImplCheckButtons();
298 : 0 : return 0;
299 : : }
300 : :
301 : 0 : void MacroSecurityTrustedSourcesTP::FillCertLB( void )
302 : : {
303 : 0 : maTrustCertLB.Clear();
304 : :
305 : 0 : sal_uInt32 nEntries = maTrustedAuthors.getLength();
306 : :
307 [ # # ][ # # ]: 0 : if ( nEntries && mpDlg->mxSecurityEnvironment.is() )
[ # # ]
308 : : {
309 [ # # ]: 0 : for( sal_uInt32 nEntry = 0 ; nEntry < nEntries ; ++nEntry )
310 : : {
311 [ # # ]: 0 : cssu::Sequence< ::rtl::OUString >& rEntry = maTrustedAuthors[ nEntry ];
312 : 0 : uno::Reference< css::security::XCertificate > xCert;
313 : :
314 : : // create from RawData
315 [ # # ][ # # ]: 0 : xCert = mpDlg->mxSecurityEnvironment->createCertificateFromAscii( rEntry[ 2 ] );
[ # # ][ # # ]
316 : :
317 [ # # ][ # # ]: 0 : SvLBoxEntry* pLBEntry = maTrustCertLB.InsertEntry( XmlSec::GetContentPart( xCert->getSubjectName() ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
318 [ # # ][ # # ]: 0 : maTrustCertLB.SetEntryText( XmlSec::GetContentPart( xCert->getIssuerName() ), pLBEntry, 1 );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
319 [ # # ][ # # ]: 0 : maTrustCertLB.SetEntryText( XmlSec::GetDateTimeString( xCert->getNotValidAfter() ), pLBEntry, 2 );
[ # # ][ # # ]
[ # # ]
320 : 0 : pLBEntry->SetUserData( ( void* ) (sal_IntPtr)nEntry ); // missuse user data as index
321 : 0 : }
322 : : }
323 : 0 : }
324 : :
325 : 0 : MacroSecurityTrustedSourcesTP::MacroSecurityTrustedSourcesTP( Window* _pParent, MacroSecurity* _pDlg )
326 : 0 : :MacroSecurityTP ( _pParent, XMLSEC_RES( RID_XMLSECTP_TRUSTSOURCES ), _pDlg )
327 [ # # ]: 0 : ,maTrustCertFL ( this, XMLSEC_RES( FL_TRUSTCERT ) )
328 [ # # ]: 0 : ,maTrustCertROFI ( this, XMLSEC_RES( FI_TRUSTCERT_RO ) )
329 [ # # ]: 0 : ,m_aTrustCertLBContainer(this, XMLSEC_RES(LB_TRUSTCERT))
330 : : ,maTrustCertLB(m_aTrustCertLBContainer)
331 [ # # ]: 0 : ,maAddCertPB ( this, XMLSEC_RES( PB_ADD_TRUSTCERT ) )
332 [ # # ]: 0 : ,maViewCertPB ( this, XMLSEC_RES( PB_VIEW_TRUSTCERT ) )
333 [ # # ]: 0 : ,maRemoveCertPB ( this, XMLSEC_RES( PB_REMOVE_TRUSTCERT ) )
334 [ # # ]: 0 : ,maTrustFileLocFL ( this, XMLSEC_RES( FL_TRUSTFILELOC ) )
335 [ # # ]: 0 : ,maTrustFileROFI ( this, XMLSEC_RES( FI_TRUSTFILE_RO ) )
336 [ # # ]: 0 : ,maTrustFileLocFI ( this, XMLSEC_RES( FI_TRUSTFILELOC ) )
337 [ # # ]: 0 : ,maTrustFileLocLB ( this, XMLSEC_RES( LB_TRUSTFILELOC ) )
338 [ # # ]: 0 : ,maAddLocPB ( this, XMLSEC_RES( FL_ADD_TRUSTFILELOC ) )
339 [ # # ][ # # ]: 0 : ,maRemoveLocPB ( this, XMLSEC_RES( FL_REMOVE_TRUSTFILELOC ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
340 : : {
341 : : static long nTabs[] = { 3, 0, 35*CS_LB_WIDTH/100, 70*CS_LB_WIDTH/100 };
342 [ # # ]: 0 : maTrustCertLB.SetTabs( &nTabs[ 0 ] );
343 [ # # ][ # # ]: 0 : maTrustCertLB.InsertHeaderEntry( String( XMLSEC_RES( STR_HEADERBAR ) ) );
[ # # ][ # # ]
[ # # ]
344 : :
345 [ # # ]: 0 : FreeResource();
346 : :
347 [ # # ]: 0 : maTrustCertLB.SetSelectHdl( LINK( this, MacroSecurityTrustedSourcesTP, TrustCertLBSelectHdl ) );
348 [ # # ]: 0 : maAddCertPB.Hide(); // not used in the moment...
349 [ # # ]: 0 : maViewCertPB.SetClickHdl( LINK( this, MacroSecurityTrustedSourcesTP, ViewCertPBHdl ) );
350 [ # # ]: 0 : maViewCertPB.Disable();
351 [ # # ]: 0 : maRemoveCertPB.SetClickHdl( LINK( this, MacroSecurityTrustedSourcesTP, RemoveCertPBHdl ) );
352 [ # # ]: 0 : maRemoveCertPB.Disable();
353 : :
354 [ # # ]: 0 : maTrustFileLocLB.SetSelectHdl( LINK( this, MacroSecurityTrustedSourcesTP, TrustFileLocLBSelectHdl ) );
355 [ # # ]: 0 : maAddLocPB.SetClickHdl( LINK( this, MacroSecurityTrustedSourcesTP, AddLocPBHdl ) );
356 [ # # ]: 0 : maRemoveLocPB.SetClickHdl( LINK( this, MacroSecurityTrustedSourcesTP, RemoveLocPBHdl ) );
357 [ # # ]: 0 : maRemoveLocPB.Disable();
358 : :
359 [ # # ][ # # ]: 0 : maTrustedAuthors = mpDlg->maSecOptions.GetTrustedAuthors();
[ # # ]
360 [ # # ]: 0 : mbAuthorsReadonly = mpDlg->maSecOptions.IsReadOnly( SvtSecurityOptions::E_MACRO_TRUSTEDAUTHORS );
361 [ # # ]: 0 : maTrustCertROFI.Show( mbAuthorsReadonly );
362 [ # # ][ # # ]: 0 : mbAuthorsReadonly ? maTrustCertLB.DisableTable() : maTrustCertLB.EnableTable();
[ # # ]
363 : :
364 [ # # ]: 0 : FillCertLB();
365 : :
366 [ # # ]: 0 : cssu::Sequence< rtl::OUString > aSecureURLs = mpDlg->maSecOptions.GetSecureURLs();
367 [ # # ]: 0 : mbURLsReadonly = mpDlg->maSecOptions.IsReadOnly( SvtSecurityOptions::E_SECUREURLS );
368 [ # # ]: 0 : maTrustFileROFI.Show( mbURLsReadonly );
369 [ # # ]: 0 : maTrustFileLocLB.Enable( !mbURLsReadonly );
370 [ # # ]: 0 : maAddLocPB .Enable( !mbURLsReadonly );
371 : :
372 : 0 : sal_Int32 nEntryCnt = aSecureURLs.getLength();
373 [ # # ]: 0 : for( sal_Int32 i = 0 ; i < nEntryCnt ; ++i )
374 : : {
375 [ # # ]: 0 : ::rtl::OUString aSystemFileURL( aSecureURLs[ i ] );
376 [ # # ]: 0 : osl::FileBase::getSystemPathFromFileURL( aSystemFileURL, aSystemFileURL );
377 [ # # ][ # # ]: 0 : maTrustFileLocLB.InsertEntry( aSystemFileURL );
[ # # ]
378 [ # # ]: 0 : }
379 : 0 : }
380 : :
381 : 0 : void MacroSecurityTrustedSourcesTP::ActivatePage()
382 : : {
383 : 0 : mpDlg->EnableReset( false );
384 : 0 : FillCertLB();
385 : 0 : }
386 : :
387 : 0 : void MacroSecurityTrustedSourcesTP::ClosePage( void )
388 : : {
389 : 0 : sal_uInt16 nEntryCnt = maTrustFileLocLB.GetEntryCount();
390 [ # # ]: 0 : if( nEntryCnt )
391 : : {
392 [ # # ]: 0 : cssu::Sequence< rtl::OUString > aSecureURLs( nEntryCnt );
393 [ # # ]: 0 : for( sal_uInt16 i = 0 ; i < nEntryCnt ; ++i )
394 : : {
395 [ # # ][ # # ]: 0 : ::rtl::OUString aURL( maTrustFileLocLB.GetEntry( i ) );
[ # # ]
396 [ # # ]: 0 : osl::FileBase::getFileURLFromSystemPath( aURL, aURL );
397 [ # # ]: 0 : aSecureURLs[ i ] = aURL;
398 : 0 : }
399 : :
400 [ # # ][ # # ]: 0 : mpDlg->maSecOptions.SetSecureURLs( aSecureURLs );
401 : : }
402 : : // Trusted Path could not be removed (#i33584#)
403 : : // don't forget to remove the old saved SecureURLs
404 : : else
405 [ # # ]: 0 : mpDlg->maSecOptions.SetSecureURLs( cssu::Sequence< rtl::OUString >() );
406 : :
407 : 0 : mpDlg->maSecOptions.SetTrustedAuthors( maTrustedAuthors );
408 : 0 : }
409 : :
410 : 0 : ReadOnlyImage::ReadOnlyImage(Window* pParent, const ResId rResId) :
411 : 0 : FixedImage(pParent, rResId)
412 : : {
413 [ # # ][ # # ]: 0 : SetImage( Image(XMLSEC_RES( RID_XMLSECTP_LOCK )));
[ # # ][ # # ]
414 : 0 : }
415 : :
416 : 0 : ReadOnlyImage::~ReadOnlyImage()
417 : : {
418 [ # # ]: 0 : }
419 : :
420 : 0 : void ReadOnlyImage::RequestHelp( const HelpEvent& rHEvt )
421 : : {
422 [ # # ][ # # ]: 0 : if( Help::IsBalloonHelpEnabled() || Help::IsQuickHelpEnabled() )
[ # # ]
423 : : {
424 [ # # ][ # # ]: 0 : Rectangle aLogicPix( LogicToPixel( Rectangle( Point(), GetOutputSize() ) ) );
[ # # ]
425 : 0 : Rectangle aScreenRect( OutputToScreenPixel( aLogicPix.TopLeft() ),
426 [ # # ]: 0 : OutputToScreenPixel( aLogicPix.BottomRight() ) );
[ # # # # ]
[ # # ]
427 : :
428 [ # # ][ # # ]: 0 : String aStr(ReadOnlyImage::GetHelpTip());
429 [ # # ][ # # ]: 0 : if ( Help::IsBalloonHelpEnabled() )
430 [ # # ]: 0 : Help::ShowBalloon( this, rHEvt.GetMousePosPixel(), aScreenRect,
431 [ # # ]: 0 : aStr );
432 [ # # ][ # # ]: 0 : else if ( Help::IsQuickHelpEnabled() )
433 [ # # ][ # # ]: 0 : Help::ShowQuickHelp( this, aScreenRect, aStr );
434 : : }
435 : : else
436 : 0 : Window::RequestHelp( rHEvt );
437 : 0 : }
438 : :
439 : 0 : const String& ReadOnlyImage::GetHelpTip()
440 : : {
441 [ # # ][ # # ]: 0 : static String aStr(XMLSEC_RES( RID_XMLSECTP_READONLY_CONFIG_TIP));
[ # # ][ # # ]
[ # # ]
442 : 0 : return aStr;
443 : : }
444 : :
445 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|