summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2021-10-20 11:01:41 +0200
committerSzymon Kłos <szymon.klos@collabora.com>2021-10-29 10:23:54 +0200
commit0a298aab1296c65c7b362ec9c34cff9960e5a6cc (patch)
tree1167843d6e23432de22675a419c69568dc31a838 /sfx2
parent8f077de13e78cda0f626fa9ae386496ceba60c69 (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/+/124253 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/doc/objserv.cxx27
1 files changed, 22 insertions, 5 deletions
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 619054815bff..6963f62cf6b5 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -1851,9 +1851,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
@@ -1863,6 +1864,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>());
@@ -1876,6 +1881,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);
@@ -1908,7 +1925,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());
@@ -2005,7 +2022,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,
@@ -2030,7 +2047,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());