diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2024-09-10 10:11:54 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2024-09-10 11:27:46 +0200 |
commit | 07df95e75a728fbbce03f6d6efdf9dbceab6c581 (patch) | |
tree | 337f1f072bda7ac4e81e64f0c4016572afba94eb /sfx2/source/doc/docfile.cxx | |
parent | 854107d275aac0f4042a154145b95c34543f24c5 (diff) |
cool#9992 lok doc sign: async DocumentDigitalSignatures::ImplViewSignatures()
Currently SfxObjectShell::CheckIsReadonly() has a hack for the LOK case
to show the signatures dialog read-only, as only that is async.
The next step is to make DocumentDigitalSignatures::ImplViewSignatures()
async, though that requires all callers of the function to be async, so
make DocumentDigitalSignatures::signScriptingContent() async as well.
There is also DocumentDigitalSignatures::signPackage(), but turns out
that's dead code, so just remove it.
Once this is in place, we had a problem that the callbacks tried to
interact with libxmlsec, but the dialog was still alive in
DocumentDigitalSignatures::ImplViewSignatures() by the time the callback
was running, so there were two DocumentSignatureManager instances at the
same time, and both assumes it should call the global libxmlsec
init/uninit, which resulted in failing to verify the just created
signature.
Fix this similar to how Tomaz fixed the same problem around pdfium in
commit 067a8a954c8e1d8d6465a4ab5fb61e93f16c26c2 (pdfium: only init
pdfium library one and destroy on LO exit, 2020-06-03).
Change-Id: I3fb63c06195564732e1576dbd755157e676fb762
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173117
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sfx2/source/doc/docfile.cxx')
-rw-r--r-- | sfx2/source/doc/docfile.cxx | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 2d8290a6476a..ff0380f72b6a 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -4388,6 +4388,8 @@ void SfxMedium::SignContents_Impl(weld::Window* pDialogParent, throw uno::RuntimeException(); } + auto xModelSigner = dynamic_cast<sfx2::DigitalSignatures*>(xSigner.get()); + assert(xModelSigner); if ( bSignScriptingContent ) { // If the signature has already the document signature it will be removed @@ -4401,8 +4403,10 @@ void SfxMedium::SignContents_Impl(weld::Window* pDialogParent, // xWriteableZipStor because a writable storage can't have 2 // instances of sub-storage for the same directory open, but with // independent storages it somehow works - if (xSigner->signScriptingContent(GetScriptingStorageToSign_Impl(), xStream)) - { + xModelSigner->SignScriptingContentAsync( + GetScriptingStorageToSign_Impl(), xStream, + [this, xSigner, xMetaInf, xWriteableZipStor, + onSignDocumentContentFinished](bool bRet) { // remove the document signature if any OUString aDocSigName = xSigner->getDocumentContentSignatureDefaultStreamName(); if ( !aDocSigName.isEmpty() && xMetaInf->hasByName( aDocSigName ) ) @@ -4429,13 +4433,12 @@ void SfxMedium::SignContents_Impl(weld::Window* pDialogParent, || !uno::Reference<util::XModifiable>(pImpl->xStorage, uno::UNO_QUERY_THROW)->isModified()); // the temporary file has been written, commit it to the original file Commit(); - bChanges = true; - } + onSignDocumentContentFinished(bRet); + }); + return; } else { - auto xModelSigner = dynamic_cast<sfx2::DigitalSignatures*>(xSigner.get()); - assert(xModelSigner); if (xMetaInf.is()) { // ODF. |