sfx2/source/doc/docfile.cxx |   16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

New commits:
commit ddc107a1fcfc9813c34d67dbafbc1b233c880c83
Author: Miklos Vajna <vmik...@collabora.co.uk>
Date:   Thu Nov 10 15:10:19 2016 +0100

    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 <c...@libreoffice.org>
    Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk>

diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index 0a4f02e..d9a090d7 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& )
             {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to