update credits
[LibreOffice.git] / xmlsecurity / source / dialogs / warnings.cxx
blobac441dc56d2544af8cac3175ebb694ce2181c17d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 */
36 #ifdef _MSC_VER
37 #pragma warning (disable : 4355) // 4355: this used in initializer-list
38 #endif
40 using namespace ::com::sun::star;
43 MacroWarning::MacroWarning( Window* _pParent, uno::Reference< css::xml::crypto::XSecurityEnvironment >& _rxSecurityEnvironment, css::uno::Reference< css::security::XCertificate >& _rxCert )
44 :ModalDialog ( _pParent, XMLSEC_RES( RID_XMLSECTP_MACROWARN ) )
45 ,maDocNameFI ( this, ResId( FI_DOCNAME ) )
46 ,maDescr1aFI ( this, ResId( FI_DESCR1A ) )
47 ,maDescr1bFI ( this, ResId( FI_DESCR1B ) )
48 ,maSignsFI ( this, ResId( FI_SIGNS ) )
49 ,maViewSignsBtn ( this, ResId( PB_VIEWSIGNS ) )
50 ,maDescr2FI ( this, ResId( FI_DESCR2 ) )
51 ,maAlwaysTrustCB ( this, ResId( CB_ALWAYSTRUST ) )
52 ,maBottomSepFL ( this, ResId( FL_BOTTOM_SEP ) )
53 ,maEnableBtn ( this, ResId( PB_DISABLE ) )
54 ,maDisableBtn ( this, ResId( PB_DISABLE ) )
55 ,maHelpBtn ( this, ResId( BTN_HELP ) )
56 ,mbSignedMode ( true )
58 FreeResource();
60 mxSecurityEnvironment = _rxSecurityEnvironment;
61 mxCert = _rxCert;
63 // hide unused parts
64 maDescr1bFI.Hide();
66 maViewSignsBtn.SetClickHdl( LINK( this, MacroWarning, ViewSignsBtnHdl ) );
67 maEnableBtn.SetClickHdl( LINK( this, MacroWarning, EnableBtnHdl ) );
69 if( mxCert.is() )
70 maSignsFI.SetText( XmlSec::GetContentPart( mxCert->getSubjectName() ) );
71 else
72 // nothing to view!
73 maViewSignsBtn.Disable();
76 MacroWarning::MacroWarning( Window* _pParent )
77 :ModalDialog ( _pParent, XMLSEC_RES( RID_XMLSECTP_MACROWARN ) )
78 ,maDocNameFI ( this, ResId( FI_DOCNAME ) )
79 ,maDescr1aFI ( this, ResId( FI_DESCR1A ) )
80 ,maDescr1bFI ( this, ResId( FI_DESCR1B ) )
81 ,maSignsFI ( this, ResId( FI_SIGNS ) )
82 ,maViewSignsBtn ( this, ResId( PB_VIEWSIGNS ) )
83 ,maDescr2FI ( this, ResId( FI_DESCR2 ) )
84 ,maAlwaysTrustCB ( this, ResId( CB_ALWAYSTRUST ) )
85 ,maBottomSepFL ( this, ResId( FL_BOTTOM_SEP ) )
86 ,maEnableBtn ( this, ResId( PB_DISABLE ) )
87 ,maDisableBtn ( this, ResId( PB_DISABLE ) )
88 ,maHelpBtn ( this, ResId( BTN_HELP ) )
89 ,mbSignedMode ( false )
91 FreeResource();
93 // hide unused parts
94 maDescr1aFI.Hide();
95 maSignsFI.Hide();
96 maViewSignsBtn.Hide();
97 maAlwaysTrustCB.Hide();
98 maDescr2FI.Hide();
100 // move hint up to position of signer list
101 maDescr1bFI.SetPosPixel( maSignsFI.GetPosPixel() );
104 MacroWarning::~MacroWarning()
108 IMPL_LINK_NOARG(MacroWarning, ViewSignsBtnHdl)
110 DBG_ASSERT( mxCert.is(), "*MacroWarning::ViewSignsBtnHdl(): no certificate set!" );
112 CertificateViewer aViewer( this, mxSecurityEnvironment, mxCert );
113 aViewer.Execute();
115 return 0;
118 IMPL_LINK_NOARG(MacroWarning, EnableBtnHdl)
120 if( mbSignedMode && maAlwaysTrustCB.IsChecked() )
121 { // insert path into trusted path list
125 EndDialog( RET_OK );
126 return 0;
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */