Kaydet (Commit) bb9481a4 authored tarafından Caolán McNamara's avatar Caolán McNamara

weld DigitalSignaturesDialog

Change-Id: I197f4805558b07aeb9e66734d0fb5c250c41ad3e
Reviewed-on: https://gerrit.libreoffice.org/67796
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 3157a3a8
......@@ -58,6 +58,11 @@ class SfxFrame;
class Timer;
class DateTime;
namespace weld
{
class Window;
}
class SFX2_DLLPUBLIC SfxMedium : public SvRefBase
{
std::unique_ptr< SfxMedium_Impl > pImpl;
......@@ -263,7 +268,8 @@ public:
const css::uno::Reference< css::ucb::XCommandEnvironment >& xComEnv );
SAL_DLLPRIVATE bool
SignContents_Impl(bool bSignScriptingContent, bool bHasValidDocumentSignature,
SignContents_Impl(weld::Window* pDialogParent,
bool bSignScriptingContent, bool bHasValidDocumentSignature,
const OUString& aSignatureLineId = OUString(),
const css::uno::Reference<css::security::XCertificate>& xCert
= css::uno::Reference<css::security::XCertificate>(),
......
......@@ -129,6 +129,7 @@
#include <openflag.hxx>
#include <officecfg/Office/Common.hxx>
#include <comphelper/propertysequence.hxx>
#include <vcl/weld.hxx>
#include <com/sun/star/io/WrongFormatException.hpp>
......@@ -3888,7 +3889,9 @@ bool SfxMedium::SignDocumentContentUsingCertificate(bool bHasValidDocumentSignat
return bChanges;
}
bool SfxMedium::SignContents_Impl(bool bSignScriptingContent, bool bHasValidDocumentSignature,
bool SfxMedium::SignContents_Impl(weld::Window* pDialogParent,
bool bSignScriptingContent,
bool bHasValidDocumentSignature,
const OUString& aSignatureLineId,
const Reference<XCertificate>& xCert,
const Reference<XGraphic>& xValidGraphic,
......@@ -3909,6 +3912,8 @@ bool SfxMedium::SignContents_Impl(bool bSignScriptingContent, bool bHasValidDocu
uno::Reference< security::XDocumentDigitalSignatures > xSigner(
security::DocumentDigitalSignatures::createWithVersionAndValidSignature(
comphelper::getProcessComponentContext(), aODFVersion, bHasValidDocumentSignature ) );
if (pDialogParent)
xSigner->setParentWindow(pDialogParent->GetXWindow());
uno::Reference< embed::XStorage > xWriteableZipStor;
......
......@@ -1740,7 +1740,7 @@ void SfxObjectShell::SignDocumentContent(weld::Window* pDialogParent)
if (CheckIsReadonly(false))
return;
bool bSignSuccess = GetMedium()->SignContents_Impl(false, HasValidSignatures());
bool bSignSuccess = GetMedium()->SignContents_Impl(pDialogParent, false, HasValidSignatures());
AfterSigning(bSignSuccess, false);
}
......@@ -1836,7 +1836,7 @@ void SfxObjectShell::SignSignatureLine(weld::Window* pDialogParent,
if (CheckIsReadonly(false))
return;
bool bSignSuccess = GetMedium()->SignContents_Impl(
bool bSignSuccess = GetMedium()->SignContents_Impl(pDialogParent,
false, HasValidSignatures(), aSignatureLineId, xCert, xValidGraphic, xInvalidGraphic, aComment);
AfterSigning(bSignSuccess, false);
......@@ -1861,7 +1861,7 @@ void SfxObjectShell::SignScriptingContent(weld::Window* pDialogParent)
if (CheckIsReadonly(true))
return;
bool bSignSuccess = GetMedium()->SignContents_Impl(true, HasValidSignatures());
bool bSignSuccess = GetMedium()->SignContents_Impl(pDialogParent, true, HasValidSignatures());
AfterSigning(bSignSuccess, true);
}
......
......@@ -15,6 +15,10 @@
#define BMP_CERT_OK "xmlsecurity/res/certificate_16.png"
#define BMP_CERT_NOT_OK "xmlsecurity/res/notcertificate_16.png"
#define BMP_SIG_VALID "xmlsecurity/res/signet_11x16.png"
#define BMP_SIG_INVALID "svx/res/caution_11x16.png"
#define BMP_SIG_NOT_VALIDATED "xmlsecurity/res/notcertificate_16.png"
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
......@@ -20,10 +20,7 @@
#ifndef INCLUDED_XMLSECURITY_INC_DIGITALSIGNATURESDIALOG_HXX
#define INCLUDED_XMLSECURITY_INC_DIGITALSIGNATURESDIALOG_HXX
#include <vcl/dialog.hxx>
#include <vcl/fixed.hxx>
#include <vcl/button.hxx>
#include <svtools/simptabl.hxx>
#include <vcl/weld.hxx>
#include <com/sun/star/beans/PropertyValue.hpp>
#include "documentsignaturehelper.hxx"
......@@ -48,7 +45,7 @@ namespace xml { namespace dom {
class HeaderBar;
class DigitalSignaturesDialog : public ModalDialog
class DigitalSignaturesDialog : public weld::GenericDialogController
{
private:
css::uno::Reference< css::uno::XComponentContext >& mxCtx;
......@@ -57,28 +54,6 @@ private:
bool mbVerifySignatures;
bool mbSignaturesChanged;
VclPtr<FixedText> m_pHintDocFT;
VclPtr<FixedText> m_pHintBasicFT;
VclPtr<FixedText> m_pHintPackageFT;
VclPtr<SvSimpleTable> m_pSignaturesLB;
VclPtr<FixedImage> m_pSigsValidImg;
VclPtr<FixedText> m_pSigsValidFI;
VclPtr<FixedImage> m_pSigsInvalidImg;
VclPtr<FixedText> m_pSigsInvalidFI;
VclPtr<FixedImage> m_pSigsNotvalidatedImg;
VclPtr<FixedText> m_pSigsNotvalidatedFI;
VclPtr<FixedImage> m_pSigsOldSignatureImg;
VclPtr<FixedText> m_pSigsOldSignatureFI;
VclPtr<CheckBox> m_pAdESCompliantCB;
VclPtr<PushButton> m_pViewBtn;
VclPtr<PushButton> m_pAddBtn;
VclPtr<PushButton> m_pRemoveBtn;
VclPtr<PushButton> m_pStartCertMgrBtn;
VclPtr<CloseButton> m_pCloseBtn;
OUString const m_sODFVersion;
//Signals if the document contains already a document signature. This is only
//important when we are signing macros and if the value is true.
......@@ -87,15 +62,34 @@ private:
bool m_bAdESCompliant;
DECL_LINK(AdESCompliantCheckBoxHdl, CheckBox&, void);
DECL_LINK(ViewButtonHdl, Button*, void);
DECL_LINK(AddButtonHdl, Button*, void);
DECL_LINK(RemoveButtonHdl, Button*, void);
DECL_LINK(SignatureHighlightHdl, SvTreeListBox*, void );
DECL_LINK(SignatureSelectHdl, SvTreeListBox*, bool );
DECL_LINK(StartVerifySignatureHdl, LinkParamNone*, bool );
DECL_LINK(OKButtonHdl, Button*, void );
DECL_STATIC_LINK(DigitalSignaturesDialog, CertMgrButtonHdl, Button*, void );
std::unique_ptr<weld::Label> m_xHintDocFT;
std::unique_ptr<weld::Label> m_xHintBasicFT;
std::unique_ptr<weld::Label> m_xHintPackageFT;
std::unique_ptr<weld::TreeView> m_xSignaturesLB;
std::unique_ptr<weld::Image> m_xSigsValidImg;
std::unique_ptr<weld::Label> m_xSigsValidFI;
std::unique_ptr<weld::Image> m_xSigsInvalidImg;
std::unique_ptr<weld::Label> m_xSigsInvalidFI;
std::unique_ptr<weld::Image> m_xSigsNotvalidatedImg;
std::unique_ptr<weld::Label> m_xSigsNotvalidatedFI;
std::unique_ptr<weld::Image> m_xSigsOldSignatureImg;
std::unique_ptr<weld::Label> m_xSigsOldSignatureFI;
std::unique_ptr<weld::CheckButton> m_xAdESCompliantCB;
std::unique_ptr<weld::Button> m_xViewBtn;
std::unique_ptr<weld::Button> m_xAddBtn;
std::unique_ptr<weld::Button> m_xRemoveBtn;
std::unique_ptr<weld::Button> m_xStartCertMgrBtn;
std::unique_ptr<weld::Button> m_xCloseBtn;
DECL_LINK(AdESCompliantCheckBoxHdl, weld::ToggleButton&, void);
DECL_LINK(ViewButtonHdl, weld::Button&, void);
DECL_LINK(AddButtonHdl, weld::Button&, void);
DECL_LINK(RemoveButtonHdl, weld::Button&, void);
DECL_LINK(SignatureHighlightHdl, weld::TreeView&, void);
DECL_LINK(SignatureSelectHdl, weld::TreeView&, void);
DECL_LINK(StartVerifySignatureHdl, LinkParamNone*, bool);
DECL_LINK(OKButtonHdl, weld::Button&, void);
DECL_LINK(CertMgrButtonHdl, weld::Button&, void);
void ImplGetSignatureInformations(bool bUseTempStream, bool bCacheLastSignature);
void ImplFillSignaturesBox();
......@@ -114,11 +108,10 @@ private:
bool canAddRemove();
public:
DigitalSignaturesDialog( vcl::Window* pParent, css::uno::Reference<
DigitalSignaturesDialog(weld::Window* pParent, css::uno::Reference<
css::uno::XComponentContext >& rxCtx, DocumentSignatureMode eMode,
bool bReadOnly, const OUString& sODFVersion, bool bHasDocumentSignature);
virtual ~DigitalSignaturesDialog() override;
virtual void dispose() override;
// Initialize the dialog and the security environment, returns TRUE on success
bool Init();
......@@ -127,8 +120,8 @@ public:
void SetStorage( const css::uno::Reference < css::embed::XStorage >& rxStore );
void SetSignatureStream( const css::uno::Reference < css::io::XStream >& rxStream );
// Execute the dialog...
short Execute() override;
// Execute the dialog...
short run() override;
// Did signatures change?
bool SignaturesChanged() const { return mbSignaturesChanged; }
......
......@@ -398,19 +398,19 @@ bool DocumentDigitalSignatures::ImplViewSignatures(
DocumentSignatureMode eMode, bool bReadOnly )
{
bool bChanges = false;
ScopedVclPtrInstance<DigitalSignaturesDialog> aSignaturesDialog(
nullptr, mxCtx, eMode, bReadOnly, m_sODFVersion,
DigitalSignaturesDialog aSignaturesDialog(
Application::GetFrameWeld(mxParentWindow), mxCtx, eMode, bReadOnly, m_sODFVersion,
m_bHasDocumentSignature);
bool bInit = aSignaturesDialog->Init();
bool bInit = aSignaturesDialog.Init();
SAL_WARN_IF( !bInit, "xmlsecurity.comp", "Error initializing security context!" );
if ( bInit )
{
aSignaturesDialog->SetStorage(rxStorage);
aSignaturesDialog.SetStorage(rxStorage);
aSignaturesDialog->SetSignatureStream( xSignStream );
if ( aSignaturesDialog->Execute() )
aSignaturesDialog.SetSignatureStream( xSignStream );
if (aSignaturesDialog.run() == RET_OK)
{
if ( aSignaturesDialog->SignaturesChanged() )
if (aSignaturesDialog.SignaturesChanged())
{
bChanges = true;
// If we have a storage and no stream, we are responsible for commit
......
......@@ -138,6 +138,7 @@
<property name="model">liststore3</property>
<property name="search_column">0</property>
<property name="show_expanders">False</property>
<property name="headers_visible">True</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="Macro Library List-selection2"/>
</child>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment