diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2021-10-20 11:01:41 +0200 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2022-01-24 09:43:53 +0100 |
commit | 71a8bad4b96627fd965b23288dea14aae3f0f468 (patch) | |
tree | c35ae6a88cdccd6d695364ecaab6b64b7c923230 /sfx2/source | |
parent | 0c3b8792b712e939d2ad524d554f96616b4844be (diff) |
jsdialog: enable Digital Signatures dialog
In LOK case run it in the readonly mode.
In readonly mode we can run it asynchronously.
Change-Id: I721dd14fa23d4e30255dd976e0cc2a4f30470a3b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124058
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128838
Tested-by: Jenkins
Diffstat (limited to 'sfx2/source')
-rw-r--r-- | sfx2/source/doc/objserv.cxx | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index ac6717b921fe..d3db98802433 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -1888,9 +1888,10 @@ void SfxObjectShell::AfterSigning(bool bSignSuccess, bool bSignScriptingContent) EnableSetModified(); } -bool SfxObjectShell::CheckIsReadonly(bool bSignScriptingContent) +bool SfxObjectShell::CheckIsReadonly(bool bSignScriptingContent, weld::Window* pDialogParent) { - if (GetMedium()->IsOriginallyReadOnly()) + // in LOK case we support only viewer / readonly mode so far + if (GetMedium()->IsOriginallyReadOnly() || comphelper::LibreOfficeKit::isActive()) { // If the file is physically read-only, we just show the existing signatures try @@ -1900,6 +1901,10 @@ bool SfxObjectShell::CheckIsReadonly(bool bSignScriptingContent) uno::Reference<security::XDocumentDigitalSignatures> xSigner( security::DocumentDigitalSignatures::createWithVersionAndValidSignature( comphelper::getProcessComponentContext(), aODFVersion, HasValidSignatures())); + + if (pDialogParent) + xSigner->setParentWindow(pDialogParent->GetXWindow()); + if (bSignScriptingContent) xSigner->showScriptingContentSignatures(GetMedium()->GetZipStorageToSign_Impl(), uno::Reference<io::XInputStream>()); @@ -1913,6 +1918,18 @@ bool SfxObjectShell::CheckIsReadonly(bool bSignScriptingContent) { std::unique_ptr<SvStream> pStream( utl::UcbStreamHelper::CreateStream(GetName(), StreamMode::READ)); + + if (!pStream) + { + pStream = utl::UcbStreamHelper::CreateStream(GetMedium()->GetName(), StreamMode::READ); + + if (!pStream) + { + SAL_WARN( "sfx.doc", "Couldn't use signing functionality!" ); + return true; + } + } + uno::Reference<io::XInputStream> xStream(new utl::OStreamWrapper(*pStream)); xSigner->showDocumentContentSignatures(uno::Reference<embed::XStorage>(), xStream); @@ -1945,7 +1962,7 @@ void SfxObjectShell::SignDocumentContent(weld::Window* pDialogParent) if (!PrepareForSigning(pDialogParent)) return; - if (CheckIsReadonly(false)) + if (CheckIsReadonly(false, pDialogParent)) return; bool bSignSuccess = GetMedium()->SignContents_Impl(pDialogParent, false, HasValidSignatures()); @@ -2041,7 +2058,7 @@ void SfxObjectShell::SignSignatureLine(weld::Window* pDialogParent, if (!PrepareForSigning(pDialogParent)) return; - if (CheckIsReadonly(false)) + if (CheckIsReadonly(false, pDialogParent)) return; bool bSignSuccess = GetMedium()->SignContents_Impl(pDialogParent, @@ -2066,7 +2083,7 @@ void SfxObjectShell::SignScriptingContent(weld::Window* pDialogParent) if (!PrepareForSigning(pDialogParent)) return; - if (CheckIsReadonly(true)) + if (CheckIsReadonly(true, pDialogParent)) return; bool bSignSuccess = GetMedium()->SignContents_Impl(pDialogParent, true, HasValidSignatures()); |