sfx2/source/doc/docfile.cxx | 2 sfx2/source/doc/objserv.cxx | 3 - xmlsecurity/source/component/documentdigitalsignatures.cxx | 33 +++++-------- 3 files changed, 17 insertions(+), 21 deletions(-)
New commits: commit 4cb25fa922f21996d9106c8a40e26613d47cb3b4 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Wed Sep 11 08:26:02 2024 +0200 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Thu Sep 12 13:29:08 2024 +0200 cool#9992 lok doc sign: async read-write DigitalSignaturesDialog This finally allows removing the hack for the LOK case in SfxObjectShell::CheckIsReadonly() to show the signatures dialog read-only. Also fix a case while signing PDFs where the file stream was on the stack, but now that we finish signing in an async callback, signing crashed due to a use-after-free. Fix that by giving the std::unique_ptr to the utl::OStreamWrapper ctor, which knows to take over ownership in this case, and that wrapper is reference-counted. Next problem is that the add/remove buttons in the dialog are still hidden in the LOK case, that's not yet fixed here. (cherry picked from commit 482c7c585160681b263c6245a745c21df70e7507) Change-Id: I71ee50ae55d4e62f5d265a35e3810e3b2b63a9b9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173244 Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 79f89d17cb63..44edea053a8c 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -4519,7 +4519,7 @@ void SfxMedium::SignContents_Impl(weld::Window* pDialogParent, { // Something not ZIP based: e.g. PDF. std::unique_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(GetName(), StreamMode::READ | StreamMode::WRITE)); - uno::Reference<io::XStream> xStream(new utl::OStreamWrapper(*pStream)); + uno::Reference<io::XStream> xStream(new utl::OStreamWrapper(std::move(pStream))); xModelSigner->SignDocumentContentAsync(uno::Reference<embed::XStorage>(), xStream, [onSignDocumentContentFinished](bool bRet) { onSignDocumentContentFinished(bRet); }); diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index 535facf5c81d..870642f5b64f 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -2065,8 +2065,7 @@ void SfxObjectShell::AfterSigning(bool bSignSuccess, bool bSignScriptingContent) bool SfxObjectShell::CheckIsReadonly(bool bSignScriptingContent, weld::Window* pDialogParent) { - // in LOK case we support only viewer / readonly mode so far - if (GetMedium()->IsOriginallyReadOnly() || comphelper::LibreOfficeKit::isActive()) + if (GetMedium()->IsOriginallyReadOnly()) { // If the file is physically read-only, we just show the existing signatures try diff --git a/xmlsecurity/source/component/documentdigitalsignatures.cxx b/xmlsecurity/source/component/documentdigitalsignatures.cxx index e498bd7c2dcc..5b491f20a550 100644 --- a/xmlsecurity/source/component/documentdigitalsignatures.cxx +++ b/xmlsecurity/source/component/documentdigitalsignatures.cxx @@ -450,28 +450,25 @@ void DocumentDigitalSignatures::ImplViewSignatures( xSignaturesDialog->SetSignatureStream( xSignStream ); - if (bReadOnly) - { - xSignaturesDialog->beforeRun(); - weld::DialogController::runAsync(xSignaturesDialog, [] (sal_Int32) {}); - rCallback(false); - return; - } - else if (xSignaturesDialog->run() == RET_OK) - { - if (xSignaturesDialog->SignaturesChanged()) + xSignaturesDialog->beforeRun(); + weld::DialogController::runAsync(xSignaturesDialog, [xSignaturesDialog, rxStorage, xSignStream, rCallback] (sal_Int32 nRet) { + if (nRet == RET_OK) { - bChanges = true; - // If we have a storage and no stream, we are responsible for commit - if ( rxStorage.is() && !xSignStream.is() ) + bool bChanged = false; + if (xSignaturesDialog->SignaturesChanged()) { - uno::Reference< embed::XTransactedObject > xTrans( rxStorage, uno::UNO_QUERY ); - xTrans->commit(); + bChanged = true; + // If we have a storage and no stream, we are responsible for commit + if ( rxStorage.is() && !xSignStream.is() ) + { + uno::Reference< embed::XTransactedObject > xTrans( rxStorage, uno::UNO_QUERY ); + xTrans->commit(); + } } + rCallback(bChanged); } - rCallback(bChanges); - return; - } + }); + return; } else {