summaryrefslogtreecommitdiff
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>2022-01-24 09:43:53 +0100
commit71a8bad4b96627fd965b23288dea14aae3f0f468 (patch)
treec35ae6a88cdccd6d695364ecaab6b64b7c923230
parent0c3b8792b712e939d2ad524d554f96616b4844be (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
-rw-r--r--include/sfx2/objsh.hxx2
-rw-r--r--sfx2/source/doc/objserv.cxx27
-rw-r--r--vcl/jsdialog/enabled.cxx3
-rw-r--r--xmlsecurity/inc/digitalsignaturesdialog.hxx1
-rw-r--r--xmlsecurity/source/component/documentdigitalsignatures.cxx19
-rw-r--r--xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx14
6 files changed, 52 insertions, 14 deletions
diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx
index 553489e14aa9..7440674d6656 100644
--- a/include/sfx2/objsh.hxx
+++ b/include/sfx2/objsh.hxx
@@ -344,7 +344,7 @@ public:
/** Returns true if preparing was successful, else false. */
bool PrepareForSigning(weld::Window* pDialogParent);
- bool CheckIsReadonly(bool bSignScriptingContent);
+ bool CheckIsReadonly(bool bSignScriptingContent, weld::Window* pDialogParent = nullptr);
void RecheckSignature(bool bAlsoRecheckScriptingSignature);
void AfterSigning(bool bSignSuccess, bool bSignScriptingContent);
bool HasValidSignatures() const;
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());
diff --git a/vcl/jsdialog/enabled.cxx b/vcl/jsdialog/enabled.cxx
index 4f490861dbfa..e60e31db382c 100644
--- a/vcl/jsdialog/enabled.cxx
+++ b/vcl/jsdialog/enabled.cxx
@@ -50,7 +50,8 @@ bool isBuilderEnabled(std::u16string_view rUIFile, bool bMobile)
|| rUIFile == u"modules/scalc/ui/datafieldoptionsdialog.ui"
|| rUIFile == u"svx/ui/fontworkgallerydialog.ui"
|| rUIFile == u"cui/ui/macroselectordialog.ui" || rUIFile == u"uui/ui/macrowarnmedium.ui"
- || rUIFile == u"modules/scalc/ui/textimportc.ui")
+ || rUIFile == u"modules/scalc/ui/textimportcsv.ui"
+ || rUIFile == u"xmlsec/ui/digitalsignaturesdialog.ui")
{
return true;
}
diff --git a/xmlsecurity/inc/digitalsignaturesdialog.hxx b/xmlsecurity/inc/digitalsignaturesdialog.hxx
index 4c668c9399f2..f8a59adaf9b5 100644
--- a/xmlsecurity/inc/digitalsignaturesdialog.hxx
+++ b/xmlsecurity/inc/digitalsignaturesdialog.hxx
@@ -112,6 +112,7 @@ public:
void SetSignatureStream( const css::uno::Reference < css::io::XStream >& rxStream );
// Execute the dialog...
+ void beforeRun();
short run() override;
// Did signatures change?
diff --git a/xmlsecurity/source/component/documentdigitalsignatures.cxx b/xmlsecurity/source/component/documentdigitalsignatures.cxx
index ec43d5087885..9f20a58fd23f 100644
--- a/xmlsecurity/source/component/documentdigitalsignatures.cxx
+++ b/xmlsecurity/source/component/documentdigitalsignatures.cxx
@@ -433,19 +433,26 @@ bool DocumentDigitalSignatures::ImplViewSignatures(
DocumentSignatureMode eMode, bool bReadOnly )
{
bool bChanges = false;
- DigitalSignaturesDialog aSignaturesDialog(
+ auto xSignaturesDialog = std::make_shared<DigitalSignaturesDialog>(
Application::GetFrameWeld(mxParentWindow), mxCtx, eMode, bReadOnly, m_sODFVersion,
m_bHasDocumentSignature);
- bool bInit = aSignaturesDialog.Init();
+ bool bInit = xSignaturesDialog->Init();
SAL_WARN_IF( !bInit, "xmlsecurity.comp", "Error initializing security context!" );
if ( bInit )
{
- aSignaturesDialog.SetStorage(rxStorage);
+ xSignaturesDialog->SetStorage(rxStorage);
- aSignaturesDialog.SetSignatureStream( xSignStream );
- if (aSignaturesDialog.run() == RET_OK)
+ xSignaturesDialog->SetSignatureStream( xSignStream );
+
+ if (bReadOnly)
+ {
+ xSignaturesDialog->beforeRun();
+ weld::DialogController::runAsync(xSignaturesDialog, [] (sal_Int32) {});
+ return false;
+ }
+ else if (xSignaturesDialog->run() == RET_OK)
{
- if (aSignaturesDialog.SignaturesChanged())
+ if (xSignaturesDialog->SignaturesChanged())
{
bChanges = true;
// If we have a storage and no stream, we are responsible for commit
diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
index 7ffe14da6649..621ea4170649 100644
--- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
+++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
@@ -56,6 +56,7 @@
#include <bitmaps.hlst>
#include <strings.hrc>
#include <resourcemanager.hxx>
+#include <comphelper/lok.hxx>
#include <comphelper/xmlsechelper.hxx>
#include <comphelper/processfactory.hxx>
@@ -192,6 +193,13 @@ DigitalSignaturesDialog::DigitalSignaturesDialog(
m_xHintPackageFT->show();
break;
}
+
+ if (comphelper::LibreOfficeKit::isActive())
+ {
+ m_xAddBtn->hide();
+ m_xRemoveBtn->hide();
+ m_xStartCertMgrBtn->hide();
+ }
}
DigitalSignaturesDialog::~DigitalSignaturesDialog()
@@ -312,7 +320,7 @@ bool DigitalSignaturesDialog::canRemove()
return (bRet && canAddRemove());
}
-short DigitalSignaturesDialog::run()
+void DigitalSignaturesDialog::beforeRun()
{
// Verify Signatures and add certificates to ListBox...
mbVerifySignatures = true;
@@ -337,7 +345,11 @@ short DigitalSignaturesDialog::run()
// Only verify once, content will not change.
// But for refreshing signature information, StartVerifySignatureHdl will be called after each add/remove
mbVerifySignatures = false;
+}
+short DigitalSignaturesDialog::run()
+{
+ beforeRun();
return GenericDialogController::run();
}