summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2024-09-05 14:44:48 +0200
committerMiklos Vajna <vmiklos@collabora.com>2024-09-05 16:14:25 +0200
commit0255283974894f5ad9ba92c3a52912657ed4bdf6 (patch)
treebbe84e21ad2c1b28ebed975e0ca9615065a4ec98
parent8087f479b373299d45469ff3996dba793a9cdb28 (diff)
cool#9992 lok doc sign: add SfxObjectShell::AfterSignContent()
Currently SfxObjectShell::CheckIsReadonly() has a hack for the LOK case to show the signatures dialog read-only, as only that is async. The first problem for the read-write signatures dialog is that SfxObjectShell::ExecFile_Impl() has code after invoking SfxObjectShell::SignDocumentContent(), which will be executed too early if the dialog is executed async. Fix the problem by moving the code in question into a new SfxObjectShell::AfterSignContent(), and only invoke that as a callback after the async run finished. The message dialog in the moved code is still non-async, but we can deal with that later. Change-Id: I32f0895118ac0da72105ec3a24c0294e18c05545 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172914 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
-rw-r--r--include/sfx2/objsh.hxx3
-rw-r--r--sfx2/source/dialog/dinfdlg.cxx6
-rw-r--r--sfx2/source/doc/objserv.cxx37
3 files changed, 31 insertions, 15 deletions
diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx
index d0cd3e03dd01..ef1c0a5ce992 100644
--- a/include/sfx2/objsh.hxx
+++ b/include/sfx2/objsh.hxx
@@ -361,7 +361,8 @@ public:
void AfterSigning(bool bSignSuccess, bool bSignScriptingContent);
bool HasValidSignatures() const;
SignatureState GetDocumentSignatureState();
- bool SignDocumentContent(weld::Window* pDialogParent);
+ void SignDocumentContent(weld::Window* pDialogParent, const std::function<void(bool)>& rCallback);
+ void AfterSignContent(bool bHaveWeSigned, weld::Window* pDialogParent);
css::uno::Sequence<css::security::DocumentSignatureInformation> GetDocumentSignatureInformation(
bool bScriptingContent,
const css::uno::Reference<css::security::XDocumentDigitalSignatures>& xSigner
diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index b6dd32b13b3f..5ae79ea15eb1 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -871,9 +871,9 @@ IMPL_LINK_NOARG(SfxDocumentPage, SignatureHdl, weld::Button&, void)
SfxObjectShell* pDoc = SfxObjectShell::Current();
if( pDoc )
{
- pDoc->SignDocumentContent(GetFrameWeld());
-
- ImplUpdateSignatures();
+ pDoc->SignDocumentContent(GetFrameWeld(), [this] (bool /*bHaveWeSigned*/) {
+ ImplUpdateSignatures();
+ });
}
}
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 3b0dea6d40ea..47ca96f0338e 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -536,6 +536,16 @@ void SetDocProperties(const uno::Reference<document::XDocumentProperties>& xDP,
}
}
+void SfxObjectShell::AfterSignContent(bool bHaveWeSigned, weld::Window* pDialogParent)
+{
+ if ( bHaveWeSigned && HasValidSignatures() )
+ {
+ std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog( pDialogParent,
+ VclMessageType::Question, VclButtonsType::YesNo, SfxResId(STR_QUERY_REMEMBERSIGNATURE)));
+ SetRememberCurrentSignature(xBox->run() == RET_YES);
+ }
+}
+
void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
{
weld::Window* pDialogParent = rReq.GetFrameWeld();
@@ -588,7 +598,11 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
}
else
{
- bHaveWeSigned |= SignDocumentContent(pDialogParent);
+ // Async, all code before return has to go into the callback.
+ SignDocumentContent(pDialogParent, [this, pDialogParent] (bool bSigned) {
+ AfterSignContent(bSigned, pDialogParent);
+ });
+ return;
}
}
else
@@ -596,12 +610,7 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
bHaveWeSigned |= SignScriptingContent(pDialogParent);
}
- if ( bHaveWeSigned && HasValidSignatures() )
- {
- std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog( pDialogParent,
- VclMessageType::Question, VclButtonsType::YesNo, SfxResId(STR_QUERY_REMEMBERSIGNATURE)));
- SetRememberCurrentSignature(xBox->run() == RET_YES);
- }
+ AfterSignContent(bHaveWeSigned, pDialogParent);
return;
}
@@ -2121,19 +2130,25 @@ SignatureState SfxObjectShell::GetDocumentSignatureState()
return ImplGetSignatureState();
}
-bool SfxObjectShell::SignDocumentContent(weld::Window* pDialogParent)
+void SfxObjectShell::SignDocumentContent(weld::Window* pDialogParent, const std::function<void(bool)>& rCallback)
{
if (!PrepareForSigning(pDialogParent))
- return false;
+ {
+ rCallback(false);
+ return;
+ }
if (CheckIsReadonly(false, pDialogParent))
- return false;
+ {
+ rCallback(false);
+ return;
+ }
bool bSignSuccess = GetMedium()->SignContents_Impl(pDialogParent, false, HasValidSignatures());
AfterSigning(bSignSuccess, false);
- return bSignSuccess;
+ rCallback(bSignSuccess);
}
bool SfxObjectShell::ResignDocument(uno::Sequence< security::DocumentSignatureInformation >& rSignaturesInfo)