2010-10-12 15:57:08 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-07-16 17:32:30 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2004-07-16 05:28:08 +00:00
|
|
|
|
2006-09-16 13:35:45 +00:00
|
|
|
|
2004-07-16 05:28:08 +00:00
|
|
|
#include <xmlsecurity/macrosecurity.hxx>
|
2004-07-16 06:52:00 +00:00
|
|
|
#include <xmlsecurity/certificatechooser.hxx>
|
2004-07-16 05:28:08 +00:00
|
|
|
#include <xmlsecurity/certificateviewer.hxx>
|
2004-07-26 06:30:29 +00:00
|
|
|
#include <xmlsecurity/biginteger.hxx>
|
|
|
|
|
2004-07-26 11:13:29 +00:00
|
|
|
#include <osl/file.hxx>
|
2005-01-28 14:22:27 +00:00
|
|
|
#include <vcl/help.hxx>
|
2004-07-26 11:13:29 +00:00
|
|
|
|
2004-07-16 05:28:08 +00:00
|
|
|
|
|
|
|
#include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
|
2008-08-18 12:13:27 +00:00
|
|
|
#include <com/sun/star/security/SerialNumberAdapter.hpp>
|
2004-07-16 05:28:08 +00:00
|
|
|
#include <comphelper/sequence.hxx>
|
2004-07-16 09:26:28 +00:00
|
|
|
#include <sfx2/filedlghelper.hxx>
|
|
|
|
#include <comphelper/processfactory.hxx>
|
|
|
|
#include <com/sun/star/uno/Exception.hpp>
|
|
|
|
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
|
|
|
#include <com/sun/star/ui/dialogs/XFolderPicker.hpp>
|
|
|
|
#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
|
|
|
|
#include <tools/urlobj.hxx>
|
|
|
|
|
2004-07-26 06:30:29 +00:00
|
|
|
#include <vcl/msgbox.hxx>
|
|
|
|
|
2004-07-16 05:28:08 +00:00
|
|
|
#include "dialogs.hrc"
|
|
|
|
#include "resourcemanager.hxx"
|
|
|
|
|
|
|
|
/* HACK: disable some warnings for MS-C */
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma warning (disable : 4355) // 4355: this used in initializer-list
|
|
|
|
#endif
|
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
|
|
|
|
2012-03-01 18:00:32 +01:00
|
|
|
IMPL_LINK_NOARG(MacroSecurity, OkBtnHdl)
|
2004-07-20 14:43:12 +00:00
|
|
|
{
|
|
|
|
mpLevelTP->ClosePage();
|
|
|
|
mpTrustSrcTP->ClosePage();
|
|
|
|
|
2004-07-22 05:28:36 +00:00
|
|
|
EndDialog( RET_OK );
|
2004-07-20 14:43:12 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-08-18 12:13:27 +00:00
|
|
|
MacroSecurity::MacroSecurity( Window* _pParent, const cssu::Reference< cssu::XComponentContext> &_rxCtx, const cssu::Reference< dcss::xml::crypto::XSecurityEnvironment >& _rxSecurityEnvironment )
|
2004-07-16 06:52:00 +00:00
|
|
|
:TabDialog ( _pParent, XMLSEC_RES( RID_XMLSECTP_MACROSEC ) )
|
2007-04-26 07:17:51 +00:00
|
|
|
,maTabCtrl ( this, XMLSEC_RES( 1 ) )
|
|
|
|
,maOkBtn ( this, XMLSEC_RES( BTN_OK ) )
|
|
|
|
,maCancelBtn ( this, XMLSEC_RES( BTN_CANCEL ) )
|
|
|
|
,maHelpBtn ( this, XMLSEC_RES( BTN_HELP ) )
|
|
|
|
,maResetBtn ( this, XMLSEC_RES( BTN_RESET ) )
|
2004-07-16 05:28:08 +00:00
|
|
|
{
|
|
|
|
FreeResource();
|
|
|
|
|
2008-08-18 12:13:27 +00:00
|
|
|
mxCtx = _rxCtx;
|
2004-07-16 05:28:08 +00:00
|
|
|
mxSecurityEnvironment = _rxSecurityEnvironment;
|
|
|
|
|
2004-07-22 05:05:18 +00:00
|
|
|
mpLevelTP = new MacroSecurityLevelTP( &maTabCtrl, this );
|
|
|
|
mpTrustSrcTP = new MacroSecurityTrustedSourcesTP( &maTabCtrl, this );
|
2004-07-20 14:43:12 +00:00
|
|
|
|
|
|
|
maTabCtrl.SetTabPage( RID_XMLSECTP_SECLEVEL, mpLevelTP );
|
|
|
|
maTabCtrl.SetTabPage( RID_XMLSECTP_TRUSTSOURCES, mpTrustSrcTP );
|
2004-07-16 05:28:08 +00:00
|
|
|
maTabCtrl.SetCurPageId( RID_XMLSECTP_SECLEVEL );
|
2004-07-20 14:43:12 +00:00
|
|
|
|
|
|
|
maOkBtn.SetClickHdl( LINK( this, MacroSecurity, OkBtnHdl ) );
|
2004-07-16 05:28:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MacroSecurity::~MacroSecurity()
|
|
|
|
{
|
2004-07-22 06:08:22 +00:00
|
|
|
delete maTabCtrl.GetTabPage( RID_XMLSECTP_TRUSTSOURCES );
|
|
|
|
delete maTabCtrl.GetTabPage( RID_XMLSECTP_SECLEVEL );
|
2004-07-16 05:28:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MacroSecurityTP::MacroSecurityTP( Window* _pParent, const ResId& _rResId, MacroSecurity* _pDlg )
|
|
|
|
:TabPage ( _pParent, _rResId )
|
|
|
|
,mpDlg ( _pDlg )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
MacroSecurityLevelTP::MacroSecurityLevelTP( Window* _pParent, MacroSecurity* _pDlg )
|
|
|
|
:MacroSecurityTP ( _pParent, XMLSEC_RES( RID_XMLSECTP_SECLEVEL ), _pDlg )
|
2007-04-26 07:17:51 +00:00
|
|
|
,maSecLevelFL ( this, XMLSEC_RES( FL_SECLEVEL ) )
|
|
|
|
,maSecReadonlyFI ( this, XMLSEC_RES( FI_SEC_READONLY ))
|
|
|
|
,maVeryHighRB ( this, XMLSEC_RES( RB_VERYHIGH ) )
|
|
|
|
,maHighRB ( this, XMLSEC_RES( RB_HIGH ) )
|
|
|
|
,maMediumRB ( this, XMLSEC_RES( RB_MEDIUM ) )
|
|
|
|
,maLowRB ( this, XMLSEC_RES( RB_LOW ) )
|
2004-07-16 05:28:08 +00:00
|
|
|
{
|
|
|
|
FreeResource();
|
2004-08-04 05:13:56 +00:00
|
|
|
|
|
|
|
maLowRB.SetClickHdl( LINK( this, MacroSecurityLevelTP, RadioButtonHdl ) );
|
|
|
|
maMediumRB.SetClickHdl( LINK( this, MacroSecurityLevelTP, RadioButtonHdl ) );
|
|
|
|
maHighRB.SetClickHdl( LINK( this, MacroSecurityLevelTP, RadioButtonHdl ) );
|
|
|
|
maVeryHighRB.SetClickHdl( LINK( this, MacroSecurityLevelTP, RadioButtonHdl ) );
|
|
|
|
|
2011-01-14 14:16:44 +01:00
|
|
|
mnCurLevel = (sal_uInt16) mpDlg->maSecOptions.GetMacroSecurityLevel();
|
2005-01-28 14:22:27 +00:00
|
|
|
sal_Bool bReadonly = mpDlg->maSecOptions.IsReadOnly( SvtSecurityOptions::E_MACRO_SECLEVEL );
|
2004-08-04 05:13:56 +00:00
|
|
|
|
2005-01-28 14:22:27 +00:00
|
|
|
RadioButton* pCheck = 0;
|
2004-08-04 05:13:56 +00:00
|
|
|
switch( mnCurLevel )
|
|
|
|
{
|
2005-01-28 14:22:27 +00:00
|
|
|
case 3: pCheck = &maVeryHighRB; break;
|
|
|
|
case 2: pCheck = &maHighRB; break;
|
|
|
|
case 1: pCheck = &maMediumRB; break;
|
|
|
|
case 0: pCheck = &maLowRB; break;
|
|
|
|
}
|
|
|
|
if(pCheck)
|
|
|
|
pCheck->Check();
|
|
|
|
else
|
|
|
|
{
|
2011-03-01 17:55:09 +01:00
|
|
|
OSL_FAIL("illegal macro security level");
|
2005-01-28 14:22:27 +00:00
|
|
|
}
|
|
|
|
maSecReadonlyFI.Show(bReadonly);
|
|
|
|
if(bReadonly)
|
|
|
|
{
|
|
|
|
//move to the selected button
|
|
|
|
if( pCheck && pCheck != &maVeryHighRB)
|
|
|
|
{
|
|
|
|
long nDiff = pCheck->GetPosPixel().Y() - maVeryHighRB.GetPosPixel().Y();
|
|
|
|
Point aPos(maSecReadonlyFI.GetPosPixel());
|
|
|
|
aPos.Y() += nDiff;
|
|
|
|
maSecReadonlyFI.SetPosPixel(aPos);
|
|
|
|
}
|
|
|
|
maVeryHighRB.Enable(sal_False);
|
|
|
|
maHighRB.Enable(sal_False);
|
|
|
|
maMediumRB.Enable(sal_False);
|
|
|
|
maLowRB.Enable(sal_False);
|
2004-08-04 05:13:56 +00:00
|
|
|
}
|
2005-01-28 14:22:27 +00:00
|
|
|
|
2004-07-16 05:28:08 +00:00
|
|
|
}
|
|
|
|
|
2012-03-01 18:00:32 +01:00
|
|
|
IMPL_LINK_NOARG(MacroSecurityLevelTP, RadioButtonHdl)
|
2004-07-16 05:28:08 +00:00
|
|
|
{
|
2011-01-14 14:16:44 +01:00
|
|
|
sal_uInt16 nNewLevel = 0;
|
2004-08-04 05:13:56 +00:00
|
|
|
if( maVeryHighRB.IsChecked() )
|
|
|
|
nNewLevel = 3;
|
|
|
|
else if( maHighRB.IsChecked() )
|
|
|
|
nNewLevel = 2;
|
|
|
|
else if( maMediumRB.IsChecked() )
|
|
|
|
nNewLevel = 1;
|
|
|
|
|
|
|
|
if ( nNewLevel != mnCurLevel )
|
|
|
|
{
|
|
|
|
mnCurLevel = nNewLevel;
|
|
|
|
mpDlg->EnableReset();
|
|
|
|
}
|
2004-07-20 14:43:12 +00:00
|
|
|
|
2004-08-04 05:13:56 +00:00
|
|
|
return 0;
|
2004-07-20 14:43:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MacroSecurityLevelTP::ClosePage( void )
|
|
|
|
{
|
2004-08-04 05:13:56 +00:00
|
|
|
mpDlg->maSecOptions.SetMacroSecurityLevel( mnCurLevel );
|
2004-07-16 05:28:08 +00:00
|
|
|
}
|
|
|
|
|
2004-07-26 11:13:29 +00:00
|
|
|
void MacroSecurityTrustedSourcesTP::ImplCheckButtons()
|
2004-07-16 05:28:08 +00:00
|
|
|
{
|
2004-07-26 11:13:29 +00:00
|
|
|
bool bCertSelected = maTrustCertLB.FirstSelected() != NULL;
|
|
|
|
maViewCertPB.Enable( bCertSelected );
|
2005-01-28 14:22:27 +00:00
|
|
|
maRemoveCertPB.Enable( bCertSelected && !mbAuthorsReadonly);
|
2004-07-16 06:52:00 +00:00
|
|
|
|
2004-07-26 11:13:29 +00:00
|
|
|
bool bLocationSelected = maTrustFileLocLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND;
|
2005-01-28 14:22:27 +00:00
|
|
|
maRemoveLocPB.Enable( bLocationSelected && !mbURLsReadonly);
|
2004-07-26 11:13:29 +00:00
|
|
|
}
|
2004-07-16 06:52:00 +00:00
|
|
|
|
2004-07-16 05:28:08 +00:00
|
|
|
|
2012-03-01 18:00:32 +01:00
|
|
|
IMPL_LINK_NOARG(MacroSecurityTrustedSourcesTP, ViewCertPBHdl)
|
2004-07-16 05:28:08 +00:00
|
|
|
{
|
2004-07-16 06:52:00 +00:00
|
|
|
if( maTrustCertLB.FirstSelected() )
|
|
|
|
{
|
2011-01-14 14:16:44 +01:00
|
|
|
sal_uInt16 nSelected = sal_uInt16( sal_uIntPtr( maTrustCertLB.FirstSelected()->GetUserData() ) );
|
2008-08-18 12:13:27 +00:00
|
|
|
|
|
|
|
uno::Reference< dcss::security::XSerialNumberAdapter > xSerialNumberAdapter =
|
|
|
|
::com::sun::star::security::SerialNumberAdapter::create(mpDlg->mxCtx);
|
|
|
|
|
|
|
|
uno::Reference< dcss::security::XCertificate > xCert = mpDlg->mxSecurityEnvironment->getCertificate( maTrustedAuthors[nSelected][0], xSerialNumberAdapter->toSequence( maTrustedAuthors[nSelected][1] ) );
|
2004-07-16 06:52:00 +00:00
|
|
|
|
|
|
|
// If we don't get it, create it from signature data:
|
|
|
|
if ( !xCert.is() )
|
2004-07-26 11:13:29 +00:00
|
|
|
xCert = mpDlg->mxSecurityEnvironment->createCertificateFromAscii( maTrustedAuthors[nSelected][2] ) ;
|
2004-07-16 06:52:00 +00:00
|
|
|
|
|
|
|
DBG_ASSERT( xCert.is(), "*MacroSecurityTrustedSourcesTP::ViewCertPBHdl(): Certificate not found and can't be created!" );
|
|
|
|
|
2004-07-26 11:13:29 +00:00
|
|
|
if ( xCert.is() )
|
|
|
|
{
|
2011-01-14 14:16:44 +01:00
|
|
|
CertificateViewer aViewer( this, mpDlg->mxSecurityEnvironment, xCert, sal_False );
|
2004-07-26 11:13:29 +00:00
|
|
|
aViewer.Execute();
|
|
|
|
}
|
2004-07-16 06:52:00 +00:00
|
|
|
}
|
2004-07-16 05:28:08 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-03-01 18:00:32 +01:00
|
|
|
IMPL_LINK_NOARG(MacroSecurityTrustedSourcesTP, RemoveCertPBHdl)
|
2004-07-16 05:28:08 +00:00
|
|
|
{
|
2004-07-28 08:12:09 +00:00
|
|
|
if( maTrustCertLB.FirstSelected() )
|
2004-07-16 09:26:28 +00:00
|
|
|
{
|
2011-01-14 14:16:44 +01:00
|
|
|
sal_uInt16 nAuthor = sal_uInt16( sal_uIntPtr( maTrustCertLB.FirstSelected()->GetUserData() ) );
|
2004-07-28 08:12:09 +00:00
|
|
|
::comphelper::removeElementAt( maTrustedAuthors, nAuthor );
|
2004-07-16 09:26:28 +00:00
|
|
|
|
|
|
|
FillCertLB();
|
2004-07-26 11:13:29 +00:00
|
|
|
ImplCheckButtons();
|
2004-07-16 09:26:28 +00:00
|
|
|
}
|
|
|
|
|
2004-07-16 05:28:08 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-03-01 18:00:32 +01:00
|
|
|
IMPL_LINK_NOARG(MacroSecurityTrustedSourcesTP, AddLocPBHdl)
|
2004-07-16 05:28:08 +00:00
|
|
|
{
|
2004-07-19 14:47:55 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
rtl::OUString aService( RTL_CONSTASCII_USTRINGPARAM( FOLDER_PICKER_SERVICE_NAME ) );
|
|
|
|
uno::Reference < lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
|
|
|
|
uno::Reference < ui::dialogs::XFolderPicker > xFolderPicker( xFactory->createInstance( aService ), uno::UNO_QUERY );
|
2004-07-16 09:26:28 +00:00
|
|
|
|
2004-07-19 14:47:55 +00:00
|
|
|
short nRet = xFolderPicker->execute();
|
2004-07-16 09:26:28 +00:00
|
|
|
|
2004-07-19 14:47:55 +00:00
|
|
|
if( ui::dialogs::ExecutableDialogResults::OK != nRet )
|
|
|
|
return 0;
|
2004-07-16 09:26:28 +00:00
|
|
|
|
2004-12-13 11:28:36 +00:00
|
|
|
rtl::OUString aPathStr = xFolderPicker->getDirectory();
|
2004-07-19 14:47:55 +00:00
|
|
|
INetURLObject aNewObj( aPathStr );
|
|
|
|
aNewObj.removeFinalSlash();
|
2004-07-16 09:26:28 +00:00
|
|
|
|
2004-07-19 14:47:55 +00:00
|
|
|
// then the new path also an URL else system path
|
2004-12-13 11:28:36 +00:00
|
|
|
::rtl::OUString aSystemFileURL = ( aNewObj.GetProtocol() != INET_PROT_NOT_VALID ) ?
|
|
|
|
aPathStr : aNewObj.getFSysPath( INetURLObject::FSYS_DETECT );
|
|
|
|
|
2012-09-24 16:20:00 +04:00
|
|
|
OUString aNewPathStr(aSystemFileURL);
|
2004-07-16 09:26:28 +00:00
|
|
|
|
2004-07-26 11:13:29 +00:00
|
|
|
if ( osl::FileBase::getSystemPathFromFileURL( aSystemFileURL, aSystemFileURL ) == osl::FileBase::E_None )
|
|
|
|
aNewPathStr = aSystemFileURL;
|
|
|
|
|
2004-07-19 14:47:55 +00:00
|
|
|
if( maTrustFileLocLB.GetEntryPos( aNewPathStr ) == LISTBOX_ENTRY_NOTFOUND )
|
2004-07-16 09:26:28 +00:00
|
|
|
{
|
2004-07-19 14:47:55 +00:00
|
|
|
maTrustFileLocLB.InsertEntry( aNewPathStr );
|
2004-07-16 09:26:28 +00:00
|
|
|
}
|
2004-07-26 11:13:29 +00:00
|
|
|
|
|
|
|
ImplCheckButtons();
|
2004-07-19 14:47:55 +00:00
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
2012-01-16 23:21:15 +01:00
|
|
|
SAL_WARN( "xmlsecurity.dialogs", "MacroSecurityTrustedSourcesTP::AddLocPBHdl(): exception from folder picker" );
|
2004-07-19 14:47:55 +00:00
|
|
|
}
|
2004-07-16 09:26:28 +00:00
|
|
|
|
2004-07-16 05:28:08 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-03-01 18:00:32 +01:00
|
|
|
IMPL_LINK_NOARG(MacroSecurityTrustedSourcesTP, RemoveLocPBHdl)
|
2004-07-16 05:28:08 +00:00
|
|
|
{
|
2011-01-14 14:16:44 +01:00
|
|
|
sal_uInt16 nSel = maTrustFileLocLB.GetSelectEntryPos();
|
2004-07-16 09:26:28 +00:00
|
|
|
if( nSel != LISTBOX_ENTRY_NOTFOUND )
|
|
|
|
{
|
|
|
|
maTrustFileLocLB.RemoveEntry( nSel );
|
2010-11-08 00:44:02 +01:00
|
|
|
// Trusted Path could not be removed (#i33584#)
|
2004-11-26 13:52:31 +00:00
|
|
|
// after remove an entry, select another one if exists
|
2011-01-14 14:16:44 +01:00
|
|
|
sal_uInt16 nNewCount = maTrustFileLocLB.GetEntryCount();
|
2004-11-26 13:52:31 +00:00
|
|
|
if ( nNewCount > 0 )
|
|
|
|
{
|
|
|
|
if ( nSel >= nNewCount )
|
|
|
|
nSel = nNewCount - 1;
|
|
|
|
maTrustFileLocLB.SelectEntryPos( nSel );
|
|
|
|
}
|
2004-07-26 11:13:29 +00:00
|
|
|
ImplCheckButtons();
|
2004-07-16 09:26:28 +00:00
|
|
|
}
|
|
|
|
|
2004-07-16 05:28:08 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-03-01 18:00:32 +01:00
|
|
|
IMPL_LINK_NOARG(MacroSecurityTrustedSourcesTP, TrustCertLBSelectHdl)
|
2004-07-16 06:52:00 +00:00
|
|
|
{
|
2004-07-26 11:13:29 +00:00
|
|
|
ImplCheckButtons();
|
2004-07-16 06:52:00 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-03-01 18:00:32 +01:00
|
|
|
IMPL_LINK_NOARG(MacroSecurityTrustedSourcesTP, TrustFileLocLBSelectHdl)
|
2004-07-16 06:52:00 +00:00
|
|
|
{
|
2004-07-26 11:13:29 +00:00
|
|
|
ImplCheckButtons();
|
2004-07-16 06:52:00 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MacroSecurityTrustedSourcesTP::FillCertLB( void )
|
|
|
|
{
|
|
|
|
maTrustCertLB.Clear();
|
|
|
|
|
2005-04-08 15:20:18 +00:00
|
|
|
sal_uInt32 nEntries = maTrustedAuthors.getLength();
|
|
|
|
|
|
|
|
if ( nEntries && mpDlg->mxSecurityEnvironment.is() )
|
2004-07-20 14:43:12 +00:00
|
|
|
{
|
2005-04-08 15:20:18 +00:00
|
|
|
for( sal_uInt32 nEntry = 0 ; nEntry < nEntries ; ++nEntry )
|
|
|
|
{
|
|
|
|
cssu::Sequence< ::rtl::OUString >& rEntry = maTrustedAuthors[ nEntry ];
|
|
|
|
uno::Reference< css::security::XCertificate > xCert;
|
2004-07-20 14:43:12 +00:00
|
|
|
|
2005-04-08 15:20:18 +00:00
|
|
|
// create from RawData
|
|
|
|
xCert = mpDlg->mxSecurityEnvironment->createCertificateFromAscii( rEntry[ 2 ] );
|
2004-07-20 14:43:12 +00:00
|
|
|
|
2005-04-08 15:20:18 +00:00
|
|
|
SvLBoxEntry* pLBEntry = maTrustCertLB.InsertEntry( XmlSec::GetContentPart( xCert->getSubjectName() ) );
|
|
|
|
maTrustCertLB.SetEntryText( XmlSec::GetContentPart( xCert->getIssuerName() ), pLBEntry, 1 );
|
|
|
|
maTrustCertLB.SetEntryText( XmlSec::GetDateTimeString( xCert->getNotValidAfter() ), pLBEntry, 2 );
|
2011-01-27 11:23:31 +00:00
|
|
|
pLBEntry->SetUserData( ( void* ) (sal_IntPtr)nEntry ); // missuse user data as index
|
2005-04-08 15:20:18 +00:00
|
|
|
}
|
2004-07-20 14:43:12 +00:00
|
|
|
}
|
2004-07-16 06:52:00 +00:00
|
|
|
}
|
|
|
|
|
2004-07-16 05:28:08 +00:00
|
|
|
MacroSecurityTrustedSourcesTP::MacroSecurityTrustedSourcesTP( Window* _pParent, MacroSecurity* _pDlg )
|
|
|
|
:MacroSecurityTP ( _pParent, XMLSEC_RES( RID_XMLSECTP_TRUSTSOURCES ), _pDlg )
|
2007-04-26 07:17:51 +00:00
|
|
|
,maTrustCertFL ( this, XMLSEC_RES( FL_TRUSTCERT ) )
|
|
|
|
,maTrustCertROFI ( this, XMLSEC_RES( FI_TRUSTCERT_RO ) )
|
2011-07-14 14:23:22 +01:00
|
|
|
,m_aTrustCertLBContainer(this, XMLSEC_RES(LB_TRUSTCERT))
|
|
|
|
,maTrustCertLB(m_aTrustCertLBContainer)
|
2007-04-26 07:17:51 +00:00
|
|
|
,maAddCertPB ( this, XMLSEC_RES( PB_ADD_TRUSTCERT ) )
|
|
|
|
,maViewCertPB ( this, XMLSEC_RES( PB_VIEW_TRUSTCERT ) )
|
|
|
|
,maRemoveCertPB ( this, XMLSEC_RES( PB_REMOVE_TRUSTCERT ) )
|
|
|
|
,maTrustFileLocFL ( this, XMLSEC_RES( FL_TRUSTFILELOC ) )
|
|
|
|
,maTrustFileROFI ( this, XMLSEC_RES( FI_TRUSTFILE_RO ) )
|
|
|
|
,maTrustFileLocFI ( this, XMLSEC_RES( FI_TRUSTFILELOC ) )
|
|
|
|
,maTrustFileLocLB ( this, XMLSEC_RES( LB_TRUSTFILELOC ) )
|
|
|
|
,maAddLocPB ( this, XMLSEC_RES( FL_ADD_TRUSTFILELOC ) )
|
|
|
|
,maRemoveLocPB ( this, XMLSEC_RES( FL_REMOVE_TRUSTFILELOC ) )
|
2004-07-16 05:28:08 +00:00
|
|
|
{
|
|
|
|
static long nTabs[] = { 3, 0, 35*CS_LB_WIDTH/100, 70*CS_LB_WIDTH/100 };
|
|
|
|
maTrustCertLB.SetTabs( &nTabs[ 0 ] );
|
2012-09-24 16:20:00 +04:00
|
|
|
maTrustCertLB.InsertHeaderEntry( XMLSEC_RES( STR_HEADERBAR ) );
|
2004-07-16 05:28:08 +00:00
|
|
|
|
|
|
|
FreeResource();
|
2004-07-16 06:52:00 +00:00
|
|
|
|
2004-07-22 12:41:57 +00:00
|
|
|
maTrustCertLB.SetSelectHdl( LINK( this, MacroSecurityTrustedSourcesTP, TrustCertLBSelectHdl ) );
|
2004-07-20 14:43:12 +00:00
|
|
|
maAddCertPB.Hide(); // not used in the moment...
|
2004-07-16 06:52:00 +00:00
|
|
|
maViewCertPB.SetClickHdl( LINK( this, MacroSecurityTrustedSourcesTP, ViewCertPBHdl ) );
|
|
|
|
maViewCertPB.Disable();
|
|
|
|
maRemoveCertPB.SetClickHdl( LINK( this, MacroSecurityTrustedSourcesTP, RemoveCertPBHdl ) );
|
|
|
|
maRemoveCertPB.Disable();
|
2004-07-22 12:41:57 +00:00
|
|
|
|
|
|
|
maTrustFileLocLB.SetSelectHdl( LINK( this, MacroSecurityTrustedSourcesTP, TrustFileLocLBSelectHdl ) );
|
2004-07-16 06:52:00 +00:00
|
|
|
maAddLocPB.SetClickHdl( LINK( this, MacroSecurityTrustedSourcesTP, AddLocPBHdl ) );
|
|
|
|
maRemoveLocPB.SetClickHdl( LINK( this, MacroSecurityTrustedSourcesTP, RemoveLocPBHdl ) );
|
|
|
|
maRemoveLocPB.Disable();
|
2004-07-22 12:41:57 +00:00
|
|
|
|
2004-07-26 11:13:29 +00:00
|
|
|
maTrustedAuthors = mpDlg->maSecOptions.GetTrustedAuthors();
|
2005-01-28 14:22:27 +00:00
|
|
|
mbAuthorsReadonly = mpDlg->maSecOptions.IsReadOnly( SvtSecurityOptions::E_MACRO_TRUSTEDAUTHORS );
|
|
|
|
maTrustCertROFI.Show( mbAuthorsReadonly );
|
2006-06-19 22:13:41 +00:00
|
|
|
mbAuthorsReadonly ? maTrustCertLB.DisableTable() : maTrustCertLB.EnableTable();
|
2004-07-26 11:13:29 +00:00
|
|
|
|
|
|
|
FillCertLB();
|
|
|
|
|
2004-07-22 12:41:57 +00:00
|
|
|
cssu::Sequence< rtl::OUString > aSecureURLs = mpDlg->maSecOptions.GetSecureURLs();
|
2005-01-28 14:22:27 +00:00
|
|
|
mbURLsReadonly = mpDlg->maSecOptions.IsReadOnly( SvtSecurityOptions::E_SECUREURLS );
|
|
|
|
maTrustFileROFI.Show( mbURLsReadonly );
|
|
|
|
maTrustFileLocLB.Enable( !mbURLsReadonly );
|
|
|
|
maAddLocPB .Enable( !mbURLsReadonly );
|
|
|
|
|
2004-07-26 11:13:29 +00:00
|
|
|
sal_Int32 nEntryCnt = aSecureURLs.getLength();
|
2004-07-22 12:41:57 +00:00
|
|
|
for( sal_Int32 i = 0 ; i < nEntryCnt ; ++i )
|
2004-07-26 11:13:29 +00:00
|
|
|
{
|
|
|
|
::rtl::OUString aSystemFileURL( aSecureURLs[ i ] );
|
|
|
|
osl::FileBase::getSystemPathFromFileURL( aSystemFileURL, aSystemFileURL );
|
|
|
|
maTrustFileLocLB.InsertEntry( aSystemFileURL );
|
|
|
|
}
|
2004-07-16 05:28:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MacroSecurityTrustedSourcesTP::ActivatePage()
|
|
|
|
{
|
2004-07-16 09:26:28 +00:00
|
|
|
mpDlg->EnableReset( false );
|
2004-07-20 14:43:12 +00:00
|
|
|
FillCertLB();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MacroSecurityTrustedSourcesTP::ClosePage( void )
|
|
|
|
{
|
2011-01-14 14:16:44 +01:00
|
|
|
sal_uInt16 nEntryCnt = maTrustFileLocLB.GetEntryCount();
|
2004-07-22 12:41:57 +00:00
|
|
|
if( nEntryCnt )
|
|
|
|
{
|
|
|
|
cssu::Sequence< rtl::OUString > aSecureURLs( nEntryCnt );
|
2011-01-14 14:16:44 +01:00
|
|
|
for( sal_uInt16 i = 0 ; i < nEntryCnt ; ++i )
|
2004-07-26 11:13:29 +00:00
|
|
|
{
|
|
|
|
::rtl::OUString aURL( maTrustFileLocLB.GetEntry( i ) );
|
|
|
|
osl::FileBase::getFileURLFromSystemPath( aURL, aURL );
|
|
|
|
aSecureURLs[ i ] = aURL;
|
|
|
|
}
|
2004-07-22 12:41:57 +00:00
|
|
|
|
|
|
|
mpDlg->maSecOptions.SetSecureURLs( aSecureURLs );
|
|
|
|
}
|
2010-11-08 00:44:02 +01:00
|
|
|
// Trusted Path could not be removed (#i33584#)
|
2004-11-26 13:52:31 +00:00
|
|
|
// don't forget to remove the old saved SecureURLs
|
|
|
|
else
|
|
|
|
mpDlg->maSecOptions.SetSecureURLs( cssu::Sequence< rtl::OUString >() );
|
2004-07-22 12:41:57 +00:00
|
|
|
|
2004-07-20 14:43:12 +00:00
|
|
|
mpDlg->maSecOptions.SetTrustedAuthors( maTrustedAuthors );
|
2004-07-16 05:28:08 +00:00
|
|
|
}
|
2005-01-28 14:22:27 +00:00
|
|
|
|
|
|
|
ReadOnlyImage::ReadOnlyImage(Window* pParent, const ResId rResId) :
|
|
|
|
FixedImage(pParent, rResId)
|
|
|
|
{
|
2010-11-16 16:57:17 +00:00
|
|
|
SetImage( Image(XMLSEC_RES( RID_XMLSECTP_LOCK )));
|
2005-01-28 14:22:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ReadOnlyImage::~ReadOnlyImage()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ReadOnlyImage::RequestHelp( const HelpEvent& rHEvt )
|
|
|
|
{
|
|
|
|
if( Help::IsBalloonHelpEnabled() || Help::IsQuickHelpEnabled() )
|
|
|
|
{
|
|
|
|
Rectangle aLogicPix( LogicToPixel( Rectangle( Point(), GetOutputSize() ) ) );
|
|
|
|
Rectangle aScreenRect( OutputToScreenPixel( aLogicPix.TopLeft() ),
|
|
|
|
OutputToScreenPixel( aLogicPix.BottomRight() ) );
|
|
|
|
|
2012-09-24 16:20:00 +04:00
|
|
|
OUString aStr(ReadOnlyImage::GetHelpTip());
|
2005-01-28 14:22:27 +00:00
|
|
|
if ( Help::IsBalloonHelpEnabled() )
|
|
|
|
Help::ShowBalloon( this, rHEvt.GetMousePosPixel(), aScreenRect,
|
|
|
|
aStr );
|
|
|
|
else if ( Help::IsQuickHelpEnabled() )
|
|
|
|
Help::ShowQuickHelp( this, aScreenRect, aStr );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Window::RequestHelp( rHEvt );
|
|
|
|
}
|
|
|
|
|
2012-09-24 16:20:00 +04:00
|
|
|
const OUString& ReadOnlyImage::GetHelpTip()
|
2005-01-28 14:22:27 +00:00
|
|
|
{
|
2012-09-24 16:20:00 +04:00
|
|
|
static OUString aStr(XMLSEC_RES( RID_XMLSECTP_READONLY_CONFIG_TIP));
|
2005-01-28 14:22:27 +00:00
|
|
|
return aStr;
|
|
|
|
}
|
2004-11-26 13:52:31 +00:00
|
|
|
|
2010-10-12 15:57:08 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|