From ddc107a1fcfc9813c34d67dbafbc1b233c880c83 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 10 Nov 2016 15:10:19 +0100 Subject: sfx2: fix showing PDF signatures A ZIP storage was unconditionally assumed when calling showDocumentContentSignatures() for "originally" read-only documents, i.e. in case the file itself is read-only at a filesystem level. Change-Id: Iba69000fc396afaf5ab34699e811b5d2c216e2bb Reviewed-on: https://gerrit.libreoffice.org/30758 Tested-by: Jenkins Reviewed-by: Miklos Vajna --- sfx2/source/doc/docfile.cxx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'sfx2') diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 0a4f02e0374b..d9a090d7c4db 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -3605,8 +3605,8 @@ bool SfxMedium::SignContents_Impl( bool bScriptingContent, const OUString& aODFV } else { - // Something not based: e.g. PDF. - SvStream* pStream = utl::UcbStreamHelper::CreateStream(GetName(), StreamMode::READ | StreamMode::WRITE); + // Something not ZIP based: e.g. PDF. + std::unique_ptr pStream(utl::UcbStreamHelper::CreateStream(GetName(), StreamMode::READ | StreamMode::WRITE)); uno::Reference xStream(new utl::OStreamWrapper(*pStream)); if (xSigner->signDocumentContent(uno::Reference(), xStream)) bChanges = true; @@ -3627,7 +3627,17 @@ bool SfxMedium::SignContents_Impl( bool bScriptingContent, const OUString& aODFV if ( bScriptingContent ) xSigner->showScriptingContentSignatures( GetZipStorageToSign_Impl(), uno::Reference< io::XInputStream >() ); else - xSigner->showDocumentContentSignatures( GetZipStorageToSign_Impl(), uno::Reference< io::XInputStream >() ); + { + uno::Reference xStorage = GetZipStorageToSign_Impl(); + if (xStorage.is()) + xSigner->showDocumentContentSignatures(xStorage, uno::Reference()); + else + { + std::unique_ptr pStream(utl::UcbStreamHelper::CreateStream(GetName(), StreamMode::READ)); + uno::Reference xStream(new utl::OStreamWrapper(*pStream)); + xSigner->showDocumentContentSignatures(uno::Reference(), xStream); + } + } } catch( const uno::Exception& ) { -- cgit