Version 4.0.2.1, tag libreoffice-4.0.2.1
[LibreOffice.git] / xmlsecurity / source / dialogs / warnings.cxx
blob24369cc47f15c5a79e27c38dc0b2689c847144b9
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;
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 )
59 FreeResource();
61 mxSecurityEnvironment = _rxSecurityEnvironment;
62 mxCert = _rxCert;
64 // hide unused parts
65 maDescr1bFI.Hide();
67 maViewSignsBtn.SetClickHdl( LINK( this, MacroWarning, ViewSignsBtnHdl ) );
68 maEnableBtn.SetClickHdl( LINK( this, MacroWarning, EnableBtnHdl ) );
70 if( mxCert.is() )
71 maSignsFI.SetText( XmlSec::GetContentPart( mxCert->getSubjectName() ) );
72 else
73 // nothing to view!
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 )
92 FreeResource();
94 // hide unused parts
95 maDescr1aFI.Hide();
96 maSignsFI.Hide();
97 maViewSignsBtn.Hide();
98 maAlwaysTrustCB.Hide();
99 maDescr2FI.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 );
114 aViewer.Execute();
116 return 0;
119 IMPL_LINK_NOARG(MacroWarning, EnableBtnHdl)
121 if( mbSignedMode && maAlwaysTrustCB.IsChecked() )
122 { // insert path into trusted path list
126 EndDialog( RET_OK );
127 return 0;
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */