summaryrefslogtreecommitdiff
path: root/xmlsecurity
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2018-07-03 15:16:58 +0200
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2018-07-05 08:05:40 +0200
commit7bafb7ca8ef9467f5c55766d2a38ba0d0a60837c (patch)
tree0f05fc92976b40a018c0e3f05d07d419c0536aaa /xmlsecurity
parent961908dde51e44b93567cb59bd398778fe1ece10 (diff)
tdf#117901 Write signature line images as emf to ooxml
Change-Id: Idbf60be3cef2d9dde454da0279d2810488b1e157 Reviewed-on: https://gerrit.libreoffice.org/56871 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'xmlsecurity')
-rw-r--r--xmlsecurity/source/helper/ooxmlsecexporter.cxx35
1 files changed, 35 insertions, 0 deletions
diff --git a/xmlsecurity/source/helper/ooxmlsecexporter.cxx b/xmlsecurity/source/helper/ooxmlsecexporter.cxx
index abb0a648b520..9ca95c5d755e 100644
--- a/xmlsecurity/source/helper/ooxmlsecexporter.cxx
+++ b/xmlsecurity/source/helper/ooxmlsecexporter.cxx
@@ -18,13 +18,16 @@
#include <comphelper/ofopxmlhelper.hxx>
#include <o3tl/make_unique.hxx>
#include <rtl/ref.hxx>
+#include <svx/xoutbmp.hxx>
#include <unotools/datetime.hxx>
+#include <vcl/salctype.hxx>
#include <xmloff/attrlist.hxx>
#include <documentsignaturehelper.hxx>
#include <xsecctl.hxx>
using namespace com::sun::star;
+using namespace css::xml::sax;
struct OOXMLSecExporter::Impl
{
@@ -68,6 +71,7 @@ struct OOXMLSecExporter::Impl
/// Writes <SignatureInfoV1>.
void writeSignatureInfo();
void writePackageSignature();
+ void writeSignatureLineImages();
};
bool OOXMLSecExporter::Impl::isOOXMLBlacklist(const OUString& rStreamName)
@@ -417,6 +421,36 @@ void OOXMLSecExporter::Impl::writePackageSignature()
m_xDocumentHandler->endElement("Object");
}
+void OOXMLSecExporter::Impl::writeSignatureLineImages()
+{
+ if (m_rInformation.aValidSignatureImage.is())
+ {
+ rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
+ pAttributeList->AddAttribute("Id", "idValidSigLnImg");
+ m_xDocumentHandler->startElement(
+ "Object", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+ OUString aGraphicInBase64;
+ Graphic aGraphic(m_rInformation.aValidSignatureImage);
+ if (!XOutBitmap::GraphicToBase64(aGraphic, aGraphicInBase64, false, ConvertDataFormat::EMF))
+ SAL_WARN("xmlsecurity.helper", "could not convert graphic to base64");
+ m_xDocumentHandler->characters(aGraphicInBase64);
+ m_xDocumentHandler->endElement("Object");
+ }
+ if (m_rInformation.aInvalidSignatureImage.is())
+ {
+ rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
+ pAttributeList->AddAttribute("Id", "idInvalidSigLnImg");
+ m_xDocumentHandler->startElement(
+ "Object", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+ OUString aGraphicInBase64;
+ Graphic aGraphic(m_rInformation.aInvalidSignatureImage);
+ if (!XOutBitmap::GraphicToBase64(aGraphic, aGraphicInBase64, false, ConvertDataFormat::EMF))
+ SAL_WARN("xmlsecurity.helper", "could not convert graphic to base64");
+ m_xDocumentHandler->characters(aGraphicInBase64);
+ m_xDocumentHandler->endElement("Object");
+ }
+}
+
OOXMLSecExporter::OOXMLSecExporter(const uno::Reference<uno::XComponentContext>& xComponentContext,
const uno::Reference<embed::XStorage>& xRootStorage,
const uno::Reference<xml::sax::XDocumentHandler>& xDocumentHandler,
@@ -440,6 +474,7 @@ void OOXMLSecExporter::writeSignature()
m_pImpl->writePackageObject();
m_pImpl->writeOfficeObject();
m_pImpl->writePackageSignature();
+ m_pImpl->writeSignatureLineImages();
m_pImpl->m_xDocumentHandler->endElement("Signature");
}