summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-11-10 15:10:19 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-11-10 16:47:57 +0000
commitddc107a1fcfc9813c34d67dbafbc1b233c880c83 (patch)
tree8adddf56e47984eef3e31ece1c6607080f52bae8
parent3b3fb8cfc8a35eb0fb4da77a8c77aac14d86085c (diff)
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 <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--sfx2/source/doc/docfile.cxx16
1 files changed, 13 insertions, 3 deletions
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<SvStream> pStream(utl::UcbStreamHelper::CreateStream(GetName(), StreamMode::READ | StreamMode::WRITE));
uno::Reference<io::XStream> xStream(new utl::OStreamWrapper(*pStream));
if (xSigner->signDocumentContent(uno::Reference<embed::XStorage>(), 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<embed::XStorage> xStorage = GetZipStorageToSign_Impl();
+ if (xStorage.is())
+ xSigner->showDocumentContentSignatures(xStorage, uno::Reference<io::XInputStream>());
+ else
+ {
+ std::unique_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(GetName(), StreamMode::READ));
+ uno::Reference<io::XInputStream> xStream(new utl::OStreamWrapper(*pStream));
+ xSigner->showDocumentContentSignatures(uno::Reference<embed::XStorage>(), xStream);
+ }
+ }
}
catch( const uno::Exception& )
{