1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_xmlsecurity.hxx"
31 #include <xmlsecurity/warnings.hxx>
32 #include <xmlsecurity/certificateviewer.hxx>
33 #include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
34 #include <comphelper/sequence.hxx>
36 // MM : added for password exception
37 #include <vcl/msgbox.hxx>
38 #include <com/sun/star/security/NoPasswordException.hpp>
39 using namespace ::com::sun::star::security
;
42 #include "dialogs.hrc"
43 #include "resourcemanager.hxx"
45 /* HACK: disable some warnings for MS-C */
47 #pragma warning (disable : 4355) // 4355: this used in initializer-list
50 using namespace ::com::sun::star
;
51 using namespace ::com::sun::star
;
54 MacroWarning::MacroWarning( Window
* _pParent
, uno::Reference
< dcss::xml::crypto::XSecurityEnvironment
>& _rxSecurityEnvironment
, cssu::Reference
< dcss::security::XCertificate
>& _rxCert
)
55 :ModalDialog ( _pParent
, XMLSEC_RES( RID_XMLSECTP_MACROWARN
) )
56 ,maDocNameFI ( this, ResId( FI_DOCNAME
) )
57 ,maDescr1aFI ( this, ResId( FI_DESCR1A
) )
58 ,maDescr1bFI ( this, ResId( FI_DESCR1B
) )
59 ,maSignsFI ( this, ResId( FI_SIGNS
) )
60 ,maViewSignsBtn ( this, ResId( PB_VIEWSIGNS
) )
61 ,maDescr2FI ( this, ResId( FI_DESCR2
) )
62 ,maAlwaysTrustCB ( this, ResId( CB_ALWAYSTRUST
) )
63 ,maBottomSepFL ( this, ResId( FL_BOTTOM_SEP
) )
64 ,maEnableBtn ( this, ResId( PB_DISABLE
) )
65 ,maDisableBtn ( this, ResId( PB_DISABLE
) )
66 ,maHelpBtn ( this, ResId( BTN_HELP
) )
67 ,mbSignedMode ( true )
71 mxSecurityEnvironment
= _rxSecurityEnvironment
;
77 maViewSignsBtn
.SetClickHdl( LINK( this, MacroWarning
, ViewSignsBtnHdl
) );
78 maEnableBtn
.SetClickHdl( LINK( this, MacroWarning
, EnableBtnHdl
) );
79 // maDisableBtn.SetClickHdl( LINK( this, MacroWarning, DisableBtnHdl ) );
82 maSignsFI
.SetText( XmlSec::GetContentPart( mxCert
->getSubjectName() ) );
85 maViewSignsBtn
.Disable();
88 MacroWarning::MacroWarning( Window
* _pParent
)
89 :ModalDialog ( _pParent
, XMLSEC_RES( RID_XMLSECTP_MACROWARN
) )
90 ,maDocNameFI ( this, ResId( FI_DOCNAME
) )
91 ,maDescr1aFI ( this, ResId( FI_DESCR1A
) )
92 ,maDescr1bFI ( this, ResId( FI_DESCR1B
) )
93 ,maSignsFI ( this, ResId( FI_SIGNS
) )
94 ,maViewSignsBtn ( this, ResId( PB_VIEWSIGNS
) )
95 ,maDescr2FI ( this, ResId( FI_DESCR2
) )
96 ,maAlwaysTrustCB ( this, ResId( CB_ALWAYSTRUST
) )
97 ,maBottomSepFL ( this, ResId( FL_BOTTOM_SEP
) )
98 ,maEnableBtn ( this, ResId( PB_DISABLE
) )
99 ,maDisableBtn ( this, ResId( PB_DISABLE
) )
100 ,maHelpBtn ( this, ResId( BTN_HELP
) )
101 ,mbSignedMode ( false )
108 maViewSignsBtn
.Hide();
109 maAlwaysTrustCB
.Hide();
112 // move hint up to position of signer list
113 maDescr1bFI
.SetPosPixel( maSignsFI
.GetPosPixel() );
116 MacroWarning::~MacroWarning()
120 IMPL_LINK( MacroWarning
, ViewSignsBtnHdl
, void*, EMPTYARG
)
122 DBG_ASSERT( mxCert
.is(), "*MacroWarning::ViewSignsBtnHdl(): no certificate set!" );
124 CertificateViewer
aViewer( this, mxSecurityEnvironment
, mxCert
);
130 IMPL_LINK( MacroWarning
, EnableBtnHdl
, void*, EMPTYARG
)
132 if( mbSignedMode
&& maAlwaysTrustCB
.IsChecked() )
133 { // insert path into trusted path list
141 /*IMPL_LINK( MacroWarning, DisableBtnHdl, void*, EMPTYARG )