sfx2/source/doc/docfile.cxx | 24 +++++++++++-- sfx2/source/doc/objserv.cxx | 5 +- sfx2/source/doc/objstor.cxx | 2 + xmlsecurity/source/component/documentdigitalsignatures.cxx | 5 ++ 4 files changed, 30 insertions(+), 6 deletions(-)
New commits: commit 4eed1d85339f7f7572d5ddff543df447d4411e49 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu Oct 13 16:10:18 2016 +0200 sfx2: initial PDF document signatures dialog This just allows the menu entry in Draw to reach SfxMedium::SignContents_Impl(), and then call signDocumentContent(), which shows the dialog (where the signature itself isn't visible yet). Do this by not assuming a ZIP-based storage at various places when we're not working with an "own" format. Change-Id: I030d0f636d1aab98369024f3f10a975ea2786d59 Reviewed-on: https://gerrit.libreoffice.org/29774 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 cae3a9e..b8efb54 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -3519,8 +3519,18 @@ bool SfxMedium::SignContents_Impl( bool bScriptingContent, const OUString& aODFV if ( !pImpl->xStream.is() ) throw uno::RuntimeException(); - xWriteableZipStor = ::comphelper::OStorageHelper::GetStorageOfFormatFromStream( ZIP_STORAGE_FORMAT_STRING, pImpl->xStream ); - if ( !xWriteableZipStor.is() ) + bool bODF = GetFilter()->IsOwnFormat(); + try + { + xWriteableZipStor = ::comphelper::OStorageHelper::GetStorageOfFormatFromStream( ZIP_STORAGE_FORMAT_STRING, pImpl->xStream ); + } + catch (const io::IOException& rException) + { + if (bODF) + SAL_WARN("sfx.doc", "ODF stream is not a zip storage: " << rException.Message); + } + + if ( !xWriteableZipStor.is() && bODF ) throw uno::RuntimeException(); uno::Reference< embed::XStorage > xMetaInf; @@ -3581,7 +3591,7 @@ bool SfxMedium::SignContents_Impl( bool bScriptingContent, const OUString& aODFV bChanges = true; } } - else + else if (xWriteableZipStor.is()) { // OOXML. uno::Reference<io::XStream> xStream; @@ -3596,6 +3606,14 @@ bool SfxMedium::SignContents_Impl( bool bScriptingContent, const OUString& aODFV bChanges = true; } } + else + { + // Something not based: e.g. PDF. + SvStream* pStream = utl::UcbStreamHelper::CreateStream(GetName(), StreamMode::READ); + uno::Reference<io::XStream> xStream(new utl::OStreamWrapper(*pStream)); + if (xSigner->signDocumentContent(uno::Reference<embed::XStorage>(), xStream)) + bChanges = true; + } } } catch ( const uno::Exception& ) diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index f6243cc..9e1d8ef 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -1371,7 +1371,7 @@ void SfxObjectShell::ImplSign( bool bScriptingContent ) && GetMedium()->GetFilter() && !GetMedium()->GetName().isEmpty() && ( (!GetMedium()->GetFilter()->IsOwnFormat() && !GetMedium()->GetFilter()->GetSupportsSigning()) - || !GetMedium()->HasStorage_Impl() + || (GetMedium()->GetFilter()->IsOwnFormat() && !GetMedium()->HasStorage_Impl()) ) ) { @@ -1382,7 +1382,8 @@ void SfxObjectShell::ImplSign( bool bScriptingContent ) // check whether the document is signed ImplGetSignatureState(); // document signature - ImplGetSignatureState( true ); // script signature + if (GetMedium() && GetMedium()->GetFilter() && GetMedium()->GetFilter()->IsOwnFormat()) + ImplGetSignatureState( true ); // script signature bool bHasSign = ( pImpl->nScriptingSignatureState != SignatureState::NOSIGNATURES || pImpl->nDocumentSignatureState != SignatureState::NOSIGNATURES ); // the target ODF version on saving diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 6edaf11..d4e82fa 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -1871,6 +1871,8 @@ bool SfxObjectShell::ConnectTmpStorage_Impl( SetError( ERRCODE_IO_GENERAL, OSL_LOG_PREFIX ); } } + else if (!GetMedium()->GetFilter()->IsOwnFormat()) + bResult = true; return bResult; } diff --git a/xmlsecurity/source/component/documentdigitalsignatures.cxx b/xmlsecurity/source/component/documentdigitalsignatures.cxx index 17b3783..5d52098 100644 --- a/xmlsecurity/source/component/documentdigitalsignatures.cxx +++ b/xmlsecurity/source/component/documentdigitalsignatures.cxx @@ -228,7 +228,10 @@ bool DocumentDigitalSignatures::ImplViewSignatures( SAL_WARN_IF( !bInit, "xmlsecurity.comp", "Error initializing security context!" ); if ( bInit ) { - aSignaturesDialog->SetStorage( rxStorage ); + if (rxStorage.is()) + // Something ZIP based: ODF or OOXML. + aSignaturesDialog->SetStorage( rxStorage ); + aSignaturesDialog->SetSignatureStream( xSignStream ); if ( aSignaturesDialog->Execute() ) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits