diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-06-15 09:54:26 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-06-26 08:55:32 +0200 |
commit | f03e70884a236200c4a6e52b5ccdbec40f552fd0 (patch) | |
tree | 01b657e185799c687a4280d9508092c117ff71c0 /sfx2/source/doc/objserv.cxx | |
parent | 745c27088f90eff8bf17dd959a2731fcda5da0e3 (diff) |
sd signature line: create signature with pre-selected cert, if available
This makes the "finish signing" button do what it says. The signature
line shape is not yet in the output, though.
(cherry picked from commit 5e040ad05012f91d0ea5116659e58222eea53668)
Change-Id: I096210fe505b4c9eafb56eae6c4706e454bac45c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97181
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sfx2/source/doc/objserv.cxx')
-rw-r--r-- | sfx2/source/doc/objserv.cxx | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index 96c23314a5cb..09e4bba8bde8 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -122,6 +122,7 @@ #include <cppuhelper/implbase.hxx> #include <unotools/ucbstreamhelper.hxx> #include <unotools/streamwrap.hxx> +#include <comphelper/sequenceashashmap.hxx> #include <svx/unoshape.hxx> #include <svx/xlineit0.hxx> @@ -423,6 +424,36 @@ bool SfxObjectShell::IsSignPDF() const return false; } +uno::Reference<security::XCertificate> SfxObjectShell::GetSignPDFCertificate() const +{ + uno::Reference<frame::XModel> xModel = GetBaseModel(); + if (!xModel.is()) + { + return uno::Reference<security::XCertificate>(); + } + + uno::Reference<drawing::XShapes> xShapes(xModel->getCurrentSelection(), uno::UNO_QUERY); + if (!xShapes.is() || xShapes->getCount() < 1) + { + return uno::Reference<security::XCertificate>(); + } + + uno::Reference<beans::XPropertySet> xShapeProps(xShapes->getByIndex(0), uno::UNO_QUERY); + if (!xShapeProps.is()) + { + return uno::Reference<security::XCertificate>(); + } + + comphelper::SequenceAsHashMap aMap(xShapeProps->getPropertyValue("InteropGrabBag")); + auto it = aMap.find("SignatureCertificate"); + if (it == aMap.end()) + { + return uno::Reference<security::XCertificate>(); + } + + return uno::Reference<security::XCertificate>(it->second, uno::UNO_QUERY); +} + void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) { weld::Window* pDialogParent = rReq.GetFrameWeld(); @@ -440,7 +471,24 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) if( SID_SIGNATURE == nId || SID_MACRO_SIGNATURE == nId ) { if ( QueryHiddenInformation( HiddenWarningFact::WhenSigning, nullptr ) == RET_YES ) - ( SID_SIGNATURE == nId ) ? SignDocumentContent(pDialogParent) : SignScriptingContent(pDialogParent); + { + if (SID_SIGNATURE == nId) + { + uno::Reference<security::XCertificate> xCertificate = GetSignPDFCertificate(); + if (xCertificate.is()) + { + SignDocumentContentUsingCertificate(xCertificate); + } + else + { + SignDocumentContent(pDialogParent); + } + } + else + { + SignScriptingContent(pDialogParent); + } + } return; } |