summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-10-20 17:07:26 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-10-20 17:08:00 +0200
commit7f671122df8760ca3cccb75c91c21b50d87ff47f (patch)
tree92ab20a6b6b1b962751add72c23697a694e79e59
parentc48cd497b27dfe177256c96c510a72ecadd51ee8 (diff)
xmlsecurity: show PDF signature right after adding it
Also: - handle PDF in DocumentSignatureManager::write(), so the PDF file is not truncated when closing the document signatures dialog, and - handle PDF in DigitalSignaturesDialog::canAddRemove() Change-Id: I77c1fcdcbdcb079ce934f37546129d9d280e5d2e
-rw-r--r--xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx12
-rw-r--r--xmlsecurity/source/helper/documentsignaturemanager.cxx6
2 files changed, 16 insertions, 2 deletions
diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
index c82cff01f3a1..61789f68686f 100644
--- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
+++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
@@ -244,8 +244,12 @@ void DigitalSignaturesDialog::SetSignatureStream( const css::uno::Reference < cs
bool DigitalSignaturesDialog::canAddRemove()
{
- //m56
bool ret = true;
+
+ if (!maSignatureManager.mxStore.is())
+ // It's always possible to append a PDF signature.
+ return ret;
+
OSL_ASSERT(maSignatureManager.mxStore.is());
bool bDoc1_1 = DocumentSignatureHelper::isODFPre_1_2(m_sODFVersion);
SaveODFItem item;
@@ -357,7 +361,11 @@ IMPL_LINK_NOARG(DigitalSignaturesDialog, AddButtonHdl, Button*, void)
return;
mbSignaturesChanged = true;
- sal_Int32 nStatus = maSignatureManager.maSignatureHelper.GetSignatureInformation( nSecurityId ).nStatus;
+ sal_Int32 nStatus = xml::crypto::SecurityOperationStatus_OPERATION_SUCCEEDED;
+
+ if (maSignatureManager.mxStore.is())
+ // In the PDF case the signature information is only available after parsing.
+ nStatus = maSignatureManager.maSignatureHelper.GetSignatureInformation( nSecurityId ).nStatus;
if ( nStatus == css::xml::crypto::SecurityOperationStatus_OPERATION_SUCCEEDED )
{
diff --git a/xmlsecurity/source/helper/documentsignaturemanager.cxx b/xmlsecurity/source/helper/documentsignaturemanager.cxx
index 05fbf3d0f5a7..1db23198dcfc 100644
--- a/xmlsecurity/source/helper/documentsignaturemanager.cxx
+++ b/xmlsecurity/source/helper/documentsignaturemanager.cxx
@@ -385,6 +385,12 @@ void DocumentSignatureManager::read(bool bUseTempStream, bool bCacheLastSignatur
void DocumentSignatureManager::write()
{
+ if (!mxStore.is())
+ {
+ // Something not ZIP based, assume PDF, which is written directly in add() already.
+ return;
+ }
+
// Export all other signatures...
SignatureStreamHelper aStreamHelper = ImplOpenSignatureStream(embed::ElementModes::WRITE|embed::ElementModes::TRUNCATE, false);