From 67785148837b4ba5ebef1b2cdf249a8f8cad8b9d Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 11 Feb 2016 09:20:24 +0100 Subject: xmlsecurity: export OOXML signature relations to persistent storage With this, _xmlsignatures/_rels/origin.sigs.rels and _xmlsignatures/origin.sigs is written to the destination file. Change-Id: I8d63a182e7cf05ed20195f88c90fba2a9a05379e --- .../source/dialogs/digitalsignaturesdialog.cxx | 21 ++++++++++++++------- xmlsecurity/source/helper/xmlsignaturehelper.cxx | 7 +++++++ 2 files changed, 21 insertions(+), 7 deletions(-) (limited to 'xmlsecurity') diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx index d3262bb5bb88..6132e845c95d 100644 --- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx +++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx @@ -411,13 +411,20 @@ IMPL_LINK_NOARG_TYPED(DigitalSignaturesDialog, OKButtonHdl, Button*, void) XMLSignatureHelper::CloseDocumentHandler( xDocumentHandler); - // If stream was not provided, we are responsible for committing it.... - if ( !mxSignatureStream.is() ) - { - uno::Reference< embed::XTransactedObject > xTrans( - aStreamHelper.xSignatureStorage, uno::UNO_QUERY ); - xTrans->commit(); - } + } + else if (aStreamHelper.xSignatureStorage.is() && aStreamHelper.nStorageFormat == embed::StorageFormats::OFOPXML) + { + // OOXML + size_t nSignatureCount = maCurrentSignatureInformations.size(); + maSignatureHelper.ExportSignatureRelations(aStreamHelper.xSignatureStorage, nSignatureCount); + } + + // If stream was not provided, we are responsible for committing it.... + if ( !mxSignatureStream.is() ) + { + uno::Reference< embed::XTransactedObject > xTrans( + aStreamHelper.xSignatureStorage, uno::UNO_QUERY ); + xTrans->commit(); } EndDialog(RET_OK); diff --git a/xmlsecurity/source/helper/xmlsignaturehelper.cxx b/xmlsecurity/source/helper/xmlsignaturehelper.cxx index 5ed47a83fbd4..b778d9aec460 100644 --- a/xmlsecurity/source/helper/xmlsignaturehelper.cxx +++ b/xmlsecurity/source/helper/xmlsignaturehelper.cxx @@ -377,6 +377,13 @@ bool XMLSignatureHelper::ReadAndVerifySignatureStorage(const uno::Reference::iterator it = std::find_if(aRelation.begin(), aRelation.end(), [](const beans::StringPair& rPair) { return rPair.First == "Target"; }); if (it != aRelation.end()) { + uno::Reference xNameAccess(xStorage, uno::UNO_QUERY); + if (xNameAccess.is() && !xNameAccess->hasByName(it->Second)) + { + SAL_WARN("xmlsecurity.helper", "expected stream, but not found: " << it->Second); + continue; + } + uno::Reference xInputStream(xStorage->openStreamElement(it->Second, nOpenMode), uno::UNO_QUERY); if (!ReadAndVerifySignatureStorageStream(xInputStream)) return false; -- cgit