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