Kaydet (Commit) 976ec559 authored tarafından Miklos Vajna's avatar Miklos Vajna

xmlsecurity: write origin.sigs when exporting OOXML signature

It's an empty file, with the only purpose to have relations, referencing
the individual signature streams. The only tricky part is that a temp
file needs closeOutput() to flush its contents, flush() is not enough.

Change-Id: I92ac61bce201c97a727ff02b1bb74599573a1807
üst 19ec3c5e
......@@ -184,6 +184,8 @@ public:
bool ReadAndVerifySignatureStorageStream(const css::uno::Reference<css::io::XInputStream>& xInputStream);
/// Adds an OOXML digital signature relation to _rels/.rels if there wasn't any before.
void EnsureSignaturesRelation(css::uno::Reference<css::embed::XStorage> xStorage);
/// Given that xStorage is an OOXML _xmlsignatures storage, create origin.sigs and its relations.
static void ExportSignatureRelations(css::uno::Reference<css::embed::XStorage> xStorage, int nSignatureCount);
};
#endif // INCLUDED_XMLSECURITY_INC_XMLSECURITY_XMLSIGNATUREHELPER_HXX
......
......@@ -516,6 +516,16 @@ IMPL_LINK_NOARG_TYPED(DigitalSignaturesDialog, AddButtonHdl, Button*, void)
{
// OOXML
maSignatureHelper.EnsureSignaturesRelation(mxStore);
// Old signatures + the new one.
int nSignatureCount = maCurrentSignatureInformations.size() + 1;
XMLSignatureHelper::ExportSignatureRelations(aStreamHelper.xSignatureStorage, nSignatureCount);
// Flush objects.
uno::Reference<embed::XTransactedObject> xTransact(aStreamHelper.xSignatureStorage, uno::UNO_QUERY);
xTransact->commit();
uno::Reference<io::XOutputStream> xOutputStream(aStreamHelper.xSignatureStream, uno::UNO_QUERY);
xOutputStream->closeOutput();
}
maSignatureHelper.EndMission();
......
......@@ -465,4 +465,13 @@ void XMLSignatureHelper::EnsureSignaturesRelation(css::uno::Reference<css::embed
xTransact->commit();
}
void XMLSignatureHelper::ExportSignatureRelations(css::uno::Reference<css::embed::XStorage> xStorage, int /*nSignatureCount*/)
{
sal_Int32 nOpenMode = embed::ElementModes::READWRITE;
uno::Reference<io::XOutputStream> xOriginStream(xStorage->openStreamElement("origin.sigs", nOpenMode), uno::UNO_QUERY);
uno::Reference<io::XTruncate> xTruncate(xOriginStream, uno::UNO_QUERY);
xTruncate->truncate();
xOriginStream->closeOutput();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment