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