summaryrefslogtreecommitdiff
path: root/sfx2/source/doc/objserv.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sfx2/source/doc/objserv.cxx')
-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());