From 7bafb7ca8ef9467f5c55766d2a38ba0d0a60837c Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Tue, 3 Jul 2018 15:16:58 +0200 Subject: 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 --- xmlsecurity/source/helper/ooxmlsecexporter.cxx | 35 ++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'xmlsecurity') 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 #include #include +#include #include +#include #include #include #include using namespace com::sun::star; +using namespace css::xml::sax; struct OOXMLSecExporter::Impl { @@ -68,6 +71,7 @@ struct OOXMLSecExporter::Impl /// Writes . 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 pAttributeList(new SvXMLAttributeList()); + pAttributeList->AddAttribute("Id", "idValidSigLnImg"); + m_xDocumentHandler->startElement( + "Object", uno::Reference(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 pAttributeList(new SvXMLAttributeList()); + pAttributeList->AddAttribute("Id", "idInvalidSigLnImg"); + m_xDocumentHandler->startElement( + "Object", uno::Reference(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& xComponentContext, const uno::Reference& xRootStorage, const uno::Reference& 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"); } -- cgit