diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-02-05 16:09:44 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-02-05 16:25:13 +0100 |
commit | b79ab2835681e0e44f8a41d8f442ca6601b87191 (patch) | |
tree | bdd245831393c378159d462c647264c5a98e988b | |
parent | f26019532bb03ea1a3d276be90adbecca6759a77 (diff) |
xmlsecurity: write initial OOXML signature streams
It's just the root element so far.
Change-Id: If32e9e5bf339f639a20fa88d85e826e14f65dac2
-rw-r--r-- | xmlsecurity/inc/xmlsecurity/xmlsignaturehelper.hxx | 2 | ||||
-rw-r--r-- | xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx | 3 | ||||
-rw-r--r-- | xmlsecurity/source/helper/xmlsignaturehelper.cxx | 21 |
3 files changed, 26 insertions, 0 deletions
diff --git a/xmlsecurity/inc/xmlsecurity/xmlsignaturehelper.hxx b/xmlsecurity/inc/xmlsecurity/xmlsignaturehelper.hxx index a7947ed8dade..031c4b0263f1 100644 --- a/xmlsecurity/inc/xmlsecurity/xmlsignaturehelper.hxx +++ b/xmlsecurity/inc/xmlsecurity/xmlsignaturehelper.hxx @@ -186,6 +186,8 @@ public: void EnsureSignaturesRelation(css::uno::Reference<css::embed::XStorage> xStorage); /// Given that xStorage is an OOXML _xmlsignatures storage, create origin.sigs and its relations. void ExportSignatureRelations(css::uno::Reference<css::embed::XStorage> xStorage, int nSignatureCount); + /// Given that xStorage is an OOXML _xmlsignatures storage, create and write a new signature. + bool CreateAndWriteOOXMLSignature(css::uno::Reference<css::embed::XStorage> xStorage, int nSignatureIndex); }; #endif // INCLUDED_XMLSECURITY_INC_XMLSECURITY_XMLSIGNATUREHELPER_HXX diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx index fa3f37734379..58fb01f86a13 100644 --- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx +++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx @@ -522,6 +522,9 @@ IMPL_LINK_NOARG_TYPED(DigitalSignaturesDialog, AddButtonHdl, Button*, void) int nSignatureCount = maCurrentSignatureInformations.size() + 1; maSignatureHelper.ExportSignatureRelations(aStreamHelper.xSignatureStorage, nSignatureCount); + // Create a new signature. + maSignatureHelper.CreateAndWriteOOXMLSignature(aStreamHelper.xSignatureStorage, nSignatureCount); + // Flush objects. uno::Reference<embed::XTransactedObject> xTransact(aStreamHelper.xSignatureStorage, uno::UNO_QUERY); xTransact->commit(); diff --git a/xmlsecurity/source/helper/xmlsignaturehelper.cxx b/xmlsecurity/source/helper/xmlsignaturehelper.cxx index 43afcdcfd55b..bea6ed7ffbdb 100644 --- a/xmlsecurity/source/helper/xmlsignaturehelper.cxx +++ b/xmlsecurity/source/helper/xmlsignaturehelper.cxx @@ -492,4 +492,25 @@ void XMLSignatureHelper::ExportSignatureRelations(css::uno::Reference<css::embed xTransact->commit(); } +bool XMLSignatureHelper::CreateAndWriteOOXMLSignature(css::uno::Reference<css::embed::XStorage> xStorage, int nSignatureIndex) +{ + sal_Int32 nOpenMode = embed::ElementModes::READWRITE; + uno::Reference<io::XOutputStream> xOutputStream(xStorage->openStreamElement("sig" + OUString::number(nSignatureIndex) + ".xml", nOpenMode), uno::UNO_QUERY); + uno::Reference<xml::sax::XWriter> xSaxWriter = xml::sax::Writer::create(mxCtx); + xSaxWriter->setOutputStream(xOutputStream); + xSaxWriter->startDocument(); + + SvXMLAttributeList* pAttributeList = new SvXMLAttributeList(); + pAttributeList->AddAttribute(ATTR_XMLNS, NS_XMLDSIG); + pAttributeList->AddAttribute(ATTR_ID, "idPackageSignature"); + xSaxWriter->startElement(TAG_SIGNATURE, uno::Reference<xml::sax::XAttributeList>(pAttributeList)); + + mbError = false; + + xSaxWriter->endElement(TAG_SIGNATURE); + xSaxWriter->endDocument(); + + return !mbError; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |