1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <xmlsecurity/warnings.hxx>
22 #include <xmlsecurity/certificateviewer.hxx>
23 #include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
24 #include <comphelper/sequence.hxx>
26 // added for password exception
27 #include <vcl/msgbox.hxx>
28 #include <com/sun/star/security/NoPasswordException.hpp>
29 using namespace ::com::sun::star::security
;
32 #include "dialogs.hrc"
33 #include "resourcemanager.hxx"
35 /* HACK: disable some warnings for MS-C */
37 #pragma warning (disable : 4355) // 4355: this used in initializer-list
40 using namespace ::com::sun::star
;
41 using namespace ::com::sun::star
;
44 MacroWarning::MacroWarning( Window
* _pParent
, uno::Reference
< dcss::xml::crypto::XSecurityEnvironment
>& _rxSecurityEnvironment
, cssu::Reference
< dcss::security::XCertificate
>& _rxCert
)
45 :ModalDialog ( _pParent
, XMLSEC_RES( RID_XMLSECTP_MACROWARN
) )
46 ,maDocNameFI ( this, ResId( FI_DOCNAME
) )
47 ,maDescr1aFI ( this, ResId( FI_DESCR1A
) )
48 ,maDescr1bFI ( this, ResId( FI_DESCR1B
) )
49 ,maSignsFI ( this, ResId( FI_SIGNS
) )
50 ,maViewSignsBtn ( this, ResId( PB_VIEWSIGNS
) )
51 ,maDescr2FI ( this, ResId( FI_DESCR2
) )
52 ,maAlwaysTrustCB ( this, ResId( CB_ALWAYSTRUST
) )
53 ,maBottomSepFL ( this, ResId( FL_BOTTOM_SEP
) )
54 ,maEnableBtn ( this, ResId( PB_DISABLE
) )
55 ,maDisableBtn ( this, ResId( PB_DISABLE
) )
56 ,maHelpBtn ( this, ResId( BTN_HELP
) )
57 ,mbSignedMode ( true )
61 mxSecurityEnvironment
= _rxSecurityEnvironment
;
67 maViewSignsBtn
.SetClickHdl( LINK( this, MacroWarning
, ViewSignsBtnHdl
) );
68 maEnableBtn
.SetClickHdl( LINK( this, MacroWarning
, EnableBtnHdl
) );
71 maSignsFI
.SetText( XmlSec::GetContentPart( mxCert
->getSubjectName() ) );
74 maViewSignsBtn
.Disable();
77 MacroWarning::MacroWarning( Window
* _pParent
)
78 :ModalDialog ( _pParent
, XMLSEC_RES( RID_XMLSECTP_MACROWARN
) )
79 ,maDocNameFI ( this, ResId( FI_DOCNAME
) )
80 ,maDescr1aFI ( this, ResId( FI_DESCR1A
) )
81 ,maDescr1bFI ( this, ResId( FI_DESCR1B
) )
82 ,maSignsFI ( this, ResId( FI_SIGNS
) )
83 ,maViewSignsBtn ( this, ResId( PB_VIEWSIGNS
) )
84 ,maDescr2FI ( this, ResId( FI_DESCR2
) )
85 ,maAlwaysTrustCB ( this, ResId( CB_ALWAYSTRUST
) )
86 ,maBottomSepFL ( this, ResId( FL_BOTTOM_SEP
) )
87 ,maEnableBtn ( this, ResId( PB_DISABLE
) )
88 ,maDisableBtn ( this, ResId( PB_DISABLE
) )
89 ,maHelpBtn ( this, ResId( BTN_HELP
) )
90 ,mbSignedMode ( false )
97 maViewSignsBtn
.Hide();
98 maAlwaysTrustCB
.Hide();
101 // move hint up to position of signer list
102 maDescr1bFI
.SetPosPixel( maSignsFI
.GetPosPixel() );
105 MacroWarning::~MacroWarning()
109 IMPL_LINK_NOARG(MacroWarning
, ViewSignsBtnHdl
)
111 DBG_ASSERT( mxCert
.is(), "*MacroWarning::ViewSignsBtnHdl(): no certificate set!" );
113 CertificateViewer
aViewer( this, mxSecurityEnvironment
, mxCert
);
119 IMPL_LINK_NOARG(MacroWarning
, EnableBtnHdl
)
121 if( mbSignedMode
&& maAlwaysTrustCB
.IsChecked() )
122 { // insert path into trusted path list
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */