summaryrefslogtreecommitdiff
path: root/xmlsecurity
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2018-07-03 15:16:58 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2018-07-06 14:22:48 +0200
commit34c1d80d91b62afa74d0566d88b7f4fbd0dcb433 (patch)
tree31d2078adf60cb6289277ff08dd8dde444491e99 /xmlsecurity
parent07f66a2bdbd50dc4e3c2318a88e7684f67f494d2 (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> (cherry picked from commit 7bafb7ca8ef9467f5c55766d2a38ba0d0a60837c) Reviewed-on: https://gerrit.libreoffice.org/56986 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@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 7d177c8dda15..6f9b2eb946dc 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)
@@ -412,6 +416,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,
@@ -435,6 +469,7 @@ void OOXMLSecExporter::writeSignature()
m_pImpl->writePackageObject();
m_pImpl->writeOfficeObject();
m_pImpl->writePackageSignature();
+ m_pImpl->writeSignatureLineImages();
m_pImpl->m_xDocumentHandler->endElement("Signature");
}