[Libreoffice-commits] core.git: include/oox include/sal include/svl offapi/com oox/source svtools/source writerfilter/source xmlsecurity/inc xmlsecurity/source

Samuel Mehrbrodt Samuel.Mehrbrodt at cib.de
Fri Nov 3 12:57:29 UTC 2017


 include/oox/vml/vmlshape.hxx                                  |    7 
 include/sal/log-areas.dox                                     |    1 
 include/svl/sigstruct.hxx                                     |    6 
 offapi/com/sun/star/security/DocumentSignatureInformation.idl |   17 ++
 oox/source/vml/vmlshape.cxx                                   |   74 ++++++++--
 oox/source/vml/vmlshapecontext.cxx                            |    7 
 svtools/source/graphic/provider.cxx                           |    9 -
 writerfilter/source/ooxml/OOXMLFastContextHandler.cxx         |    8 -
 xmlsecurity/inc/xsecctl.hxx                                   |    3 
 xmlsecurity/source/component/documentdigitalsignatures.cxx    |    9 +
 xmlsecurity/source/helper/ooxmlsecparser.cxx                  |   49 ++++++
 xmlsecurity/source/helper/ooxmlsecparser.hxx                  |    6 
 xmlsecurity/source/helper/xsecverify.cxx                      |   63 ++++++++
 13 files changed, 241 insertions(+), 18 deletions(-)

New commits:
commit bd3c5c4c234e3dc6b89cd235321945a41a08d562
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Date:   Tue Aug 8 16:23:07 2017 +0200

    [API CHANGE] tdf#65393 Import signature line images from ooxml
    
    showing whether the signature behind the signature line is valid or not.
    
    Change-Id: Ia6cca62812019f26d55d234cac767a9b4b7c8175
    Reviewed-on: https://gerrit.libreoffice.org/40980
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>

diff --git a/include/oox/vml/vmlshape.hxx b/include/oox/vml/vmlshape.hxx
index cad99b719c26..3874556ad8df 100644
--- a/include/oox/vml/vmlshape.hxx
+++ b/include/oox/vml/vmlshape.hxx
@@ -208,6 +208,8 @@ struct ShapeModel
     OUString     maControl1;         ///< Bezier control point 1
     OUString     maControl2;         ///< Bezier control point 2
     OUString     maVmlPath;          ///< VML path for this shape
+    bool         mbIsSignatureLine;  ///< Shape is a signature line
+    OUString     maSignatureId;      ///< ID of the signature
 
     explicit            ShapeModel();
                         ~ShapeModel();
@@ -293,9 +295,12 @@ protected:
                             const css::uno::Reference< css::drawing::XShapes >& rxShapes,
                             const css::awt::Rectangle& rShapeRect ) const override;
     /** Used by both RectangleShape and ComplexShape. */
+    css::uno::Reference<css::drawing::XShape>createEmbeddedPictureObject(
+        const css::uno::Reference< css::drawing::XShapes >& rxShapes,
+        const css::awt::Rectangle& rShapeRect, OUString const & rGraphicPath ) const;
     css::uno::Reference<css::drawing::XShape>createPictureObject(
             const css::uno::Reference< css::drawing::XShapes >& rxShapes,
-            const css::awt::Rectangle& rShapeRect, OUString const & rGraphicPath ) const;
+            const css::awt::Rectangle& rShapeRect, OUString const & rGraphicUrl ) const;
 
 private:
     OUString     maService;          ///< Name of the UNO shape service.
diff --git a/include/sal/log-areas.dox b/include/sal/log-areas.dox
index 3ebec81f6112..ed93026f7d6b 100644
--- a/include/sal/log-areas.dox
+++ b/include/sal/log-areas.dox
@@ -241,6 +241,7 @@ certain functionality.
 @li @c oox.ppt - pptx filter
 @li @c oox.shape
 @li @c oox.storage - ZipStorage class
+ at li @c oox.vml - VML
 @li @c oox.xmlstream - XmlStream class
 
 @section forms
diff --git a/include/svl/sigstruct.hxx b/include/svl/sigstruct.hxx
index a7da2994664c..de5a03497dc4 100644
--- a/include/svl/sigstruct.hxx
+++ b/include/svl/sigstruct.hxx
@@ -22,6 +22,7 @@
 
 #include <rtl/ustring.hxx>
 #include <com/sun/star/util/DateTime.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
 #include <com/sun/star/xml/crypto/SecurityOperationStatus.hpp>
 #include <com/sun/star/xml/crypto/DigestID.hpp>
 #include <com/sun/star/uno/Sequence.hxx>
@@ -105,6 +106,11 @@ struct SignatureInformation
     OUString ouDescriptionPropertyId;
     /// OOXML certificate SHA-256 digest, empty for ODF except when doing XAdES signature.
     OUString ouCertDigest;
+    /// OOXML Valid and invalid signature images
+    css::uno::Reference<css::graphic::XGraphic> aValidSignatureImage;
+    css::uno::Reference<css::graphic::XGraphic> aInvalidSignatureImage;
+    /// OOXML Signature Line Id, used to map signatures to their respective signature line images.
+    OUString ouSignatureLineId;
     /// A full OOXML signature for unchanged roundtrip, empty for ODF.
     css::uno::Sequence<sal_Int8> aSignatureBytes;
     /// For PDF: digest format, from css::xml::crypto::DigestID
diff --git a/offapi/com/sun/star/security/DocumentSignatureInformation.idl b/offapi/com/sun/star/security/DocumentSignatureInformation.idl
index 8c411a7b276f..99c14af09eb9 100644
--- a/offapi/com/sun/star/security/DocumentSignatureInformation.idl
+++ b/offapi/com/sun/star/security/DocumentSignatureInformation.idl
@@ -20,6 +20,7 @@
 #ifndef __com_sun_star_security_DocumentSignatureInformation_idl__
 #define __com_sun_star_security_DocumentSignatureInformation_idl__
 
+#include <com/sun/star/graphic/XGraphic.idl>
 #include <com/sun/star/security/XCertificate.idl>
 #include <com/sun/star/security/CertificateValidity.idl>
 
@@ -66,7 +67,21 @@ struct DocumentSignatureInformation
      *  the fact, that not everything in this document is signed.
      */
     boolean PartialDocumentSignature;
-
+    /**
+     *  The ID of the Signature Line
+     *  @since LibreOffice 6.0
+     */
+    string SignatureLineId;
+    /**
+     *  The Signature Line Image which is shown when the signature is valid
+     *  @since LibreOffice 6.0
+     */
+    com::sun::star::graphic::XGraphic ValidSignatureLineImage;
+    /**
+     *  The Signature Line Image which is shown when the signature is invalid
+     *  @since LibreOffice 6.0
+     */
+    com::sun::star::graphic::XGraphic InvalidSignatureLineImage;
 };
 
 
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 74ae15f848f3..7679ca838f67 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -44,9 +44,11 @@
 #include <com/sun/star/text/XTextContent.hpp>
 #include <com/sun/star/text/XTextDocument.hpp>
 #include <com/sun/star/text/XTextFrame.hpp>
- #include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/text/TextContentAnchorType.hpp>
 #include <com/sun/star/text/GraphicCrop.hpp>
+#include <com/sun/star/security/DocumentDigitalSignatures.hpp>
+#include <com/sun/star/security/XDocumentDigitalSignatures.hpp>
 #include <rtl/math.hxx>
 #include <rtl/ustrbuf.hxx>
 #include <svx/svdtrans.hxx>
@@ -67,7 +69,9 @@
 #include <svx/unoapi.hxx>
 #include <svx/svdoashp.hxx>
 #include <comphelper/sequence.hxx>
+#include <comphelper/processfactory.hxx>
 #include <comphelper/propertyvalue.hxx>
+#include <comphelper/storagehelper.hxx>
 
 using ::com::sun::star::beans::XPropertySet;
 using ::com::sun::star::uno::Any;
@@ -249,7 +253,8 @@ ClientData::ClientData() :
 {
 }
 
-ShapeModel::ShapeModel()
+ShapeModel::ShapeModel() :
+    mbIsSignatureLine(false)
 {
 }
 
@@ -852,17 +857,23 @@ Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes
     return xShape;
 }
 
-Reference< XShape > SimpleShape::createPictureObject( const Reference< XShapes >& rxShapes, const awt::Rectangle& rShapeRect, OUString const & rGraphicPath ) const
+Reference< XShape > SimpleShape::createEmbeddedPictureObject( const Reference< XShapes >& rxShapes, const awt::Rectangle& rShapeRect, OUString const & rGraphicPath ) const
+{
+    XmlFilterBase& rFilter = mrDrawing.getFilter();
+    OUString aGraphicUrl = rFilter.getGraphicHelper().importEmbeddedGraphicObject( rGraphicPath );
+    return SimpleShape::createPictureObject(rxShapes, rShapeRect, aGraphicUrl);
+}
+
+Reference< XShape > SimpleShape::createPictureObject( const Reference< XShapes >& rxShapes, const awt::Rectangle& rShapeRect, OUString const & rGraphicUrl ) const
 {
     Reference< XShape > xShape = mrDrawing.createAndInsertXShape( "com.sun.star.drawing.GraphicObjectShape", rxShapes, rShapeRect );
     if( xShape.is() )
     {
-        XmlFilterBase& rFilter = mrDrawing.getFilter();
-        OUString aGraphicUrl = rFilter.getGraphicHelper().importEmbeddedGraphicObject( rGraphicPath );
+
         PropertySet aPropSet( xShape );
-        if( !aGraphicUrl.isEmpty() )
+        if( !rGraphicUrl.isEmpty() )
         {
-            aPropSet.setProperty( PROP_GraphicURL, aGraphicUrl );
+            aPropSet.setProperty( PROP_GraphicURL, rGraphicUrl );
         }
         uno::Reference< lang::XServiceInfo > xServiceInfo(rxShapes, uno::UNO_QUERY);
         // If the shape has an absolute position, set the properties accordingly, unless we're inside a group shape.
@@ -912,7 +923,7 @@ Reference<XShape> RectangleShape::implConvertAndInsert(const Reference<XShapes>&
 
     // try to create a picture object
     if(!aGraphicPath.isEmpty())
-        return SimpleShape::createPictureObject(rxShapes, rShapeRect, aGraphicPath);
+        return SimpleShape::createEmbeddedPictureObject(rxShapes, rShapeRect, aGraphicPath);
 
     // default: try to create a rectangle shape
     Reference<XShape> xShape = SimpleShape::implConvertAndInsert(rxShapes, rShapeRect);
@@ -1231,15 +1242,60 @@ Reference< XShape > ComplexShape::implConvertAndInsert( const Reference< XShapes
             return xShape;
     }
 
+
+    if( getShapeModel().mbIsSignatureLine )
+    {
+        // Get the document signatures
+        Reference< security::XDocumentDigitalSignatures > xSignatures(
+            security::DocumentDigitalSignatures::createWithVersion(
+                comphelper::getProcessComponentContext(), "1.2" ) );
+
+        uno::Reference<embed::XStorage> xStorage = comphelper::OStorageHelper::GetStorageOfFormatFromURL(
+            ZIP_STORAGE_FORMAT_STRING, mrDrawing.getFilter().getFileUrl(), embed::ElementModes::READ);
+        SAL_WARN_IF(!xStorage.is(), "oox.vml", "No xStorage!");
+
+        uno::Sequence< security::DocumentSignatureInformation > xSignatureInfo =
+            xSignatures->verifyScriptingContentSignatures(xStorage, uno::Reference< io::XInputStream >());
+
+        for (int i=0; i<xSignatureInfo.getLength(); i++)
+        {
+            // Try to find matching signature line image - if none exists that is fine,
+            // then the signature line is not digitally signed.
+            if (xSignatureInfo[i].SignatureLineId == getShapeModel().maSignatureId)
+            {
+                OUString aGraphicUrl;
+                if (xSignatureInfo[i].SignatureIsValid)
+                {
+                    // Signature is valid, use the 'valid' image
+                    SAL_WARN_IF(!xSignatureInfo[i].ValidSignatureLineImage.is(), "oox.vml", "No ValidSignatureLineImage!");
+                    aGraphicUrl = rFilter.getGraphicHelper().createGraphicObject(xSignatureInfo[i].ValidSignatureLineImage);
+                }
+                else
+                {
+                    // Signature is invalid, use the 'invalid' image
+                    SAL_WARN_IF(!xSignatureInfo[i].InvalidSignatureLineImage.is(), "oox.vml", "No InvalidSignatureLineImage!");
+                    aGraphicUrl = rFilter.getGraphicHelper().createGraphicObject(xSignatureInfo[i].InvalidSignatureLineImage);
+                }
+                Reference< XShape > xShape = SimpleShape::createPictureObject(rxShapes, rShapeRect, aGraphicUrl);
+                PropertySet aPropSet(xShape);
+                aPropSet.setProperty(PROP_GraphicURL, aGraphicUrl);
+
+                return xShape;
+            }
+        }
+        // In case no matching signature line is found, render the unsigned signature line image (next if branch)
+    }
+
     // try to create a picture object
     if( !aGraphicPath.isEmpty() )
     {
-        Reference< XShape > xShape = SimpleShape::createPictureObject(rxShapes, rShapeRect, aGraphicPath);
+        Reference< XShape > xShape = SimpleShape::createEmbeddedPictureObject(rxShapes, rShapeRect, aGraphicPath);
         // AS_CHARACTER shape: vertical orientation default is bottom, MSO default is top.
         if ( maTypeModel.maPosition != "absolute" && maTypeModel.maPosition != "relative" )
             PropertySet( xShape ).setAnyProperty( PROP_VertOrient, makeAny(text::VertOrientation::TOP));
         return xShape;
     }
+
     // default: try to create a custom shape
     return CustomShape::implConvertAndInsert( rxShapes, rShapeRect );
 }
diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx
index 1d1851d87ef1..151f28585a70 100644
--- a/oox/source/vml/vmlshapecontext.cxx
+++ b/oox/source/vml/vmlshapecontext.cxx
@@ -491,6 +491,13 @@ ContextHandlerRef ShapeContext::onCreateContext( sal_Int32 nElement, const Attri
                     "com.sun.star.drawing.RectangleShape");
             mrShapeModel.maLegacyDiagramPath = getFragmentPathFromRelId(rAttribs.getString(XML_id, OUString()));
             break;
+        case O_TOKEN( signatureline ):
+            mrShapeModel.mbIsSignatureLine = true;
+            mrShapeModel.maSignatureId = rAttribs.getString(XML_id, OUString());
+            break;
+        case O_TOKEN( lock ):
+            // TODO
+            break;
     }
     // handle remaining stuff in base class
     return ShapeTypeContext::onCreateContext( nElement, rAttribs );
diff --git a/svtools/source/graphic/provider.cxx b/svtools/source/graphic/provider.cxx
index de7a2dff928c..b70fd5ef4a4e 100644
--- a/svtools/source/graphic/provider.cxx
+++ b/svtools/source/graphic/provider.cxx
@@ -47,6 +47,7 @@
 #include <vcl/dibtools.hxx>
 #include <comphelper/sequence.hxx>
 #include <memory>
+#include <svtools/ehdl.hxx>
 
 using namespace com::sun::star;
 
@@ -418,8 +419,9 @@ uno::Reference< ::graphic::XGraphic > SAL_CALL GraphicProvider::queryGraphic( co
             if ( nExtMapMode > 0 )
                 pExtHeader = &aExtHeader;
 
-            if( ( rFilter.ImportGraphic( aVCLGraphic, aPath, *pIStm,
-                                         GRFILTER_FORMAT_DONTKNOW, nullptr, GraphicFilterImportFlags::NONE, pExtHeader ) == ERRCODE_NONE ) &&
+            ErrCode error = rFilter.ImportGraphic( aVCLGraphic, aPath, *pIStm,
+                GRFILTER_FORMAT_DONTKNOW, nullptr, GraphicFilterImportFlags::NONE, pExtHeader );
+            if( (error == ERRCODE_NONE ) &&
                 ( aVCLGraphic.GetType() != GraphicType::NONE ) )
             {
                 ::unographic::Graphic* pUnoGraphic = new ::unographic::Graphic;
@@ -427,6 +429,9 @@ uno::Reference< ::graphic::XGraphic > SAL_CALL GraphicProvider::queryGraphic( co
                 pUnoGraphic->init( aVCLGraphic );
                 xRet = pUnoGraphic;
             }
+            else{
+                SAL_WARN("svtools", "Could not create graphic: " << error);
+            }
         }
     }
 
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index 175e86435396..e25e7bc40fae 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -1891,13 +1891,15 @@ OOXMLFastContextHandlerWrapper::lcl_createFastChildContext
 
     // We have methods to _add_ individual tokens or whole namespaces to be
     // processed by writerfilter (instead of oox), but we have no method to
-    // filter out a single token. Just hardwire the wrap token here until we
-    // need a more generic solution.
+    // filter out a single token. Just hardwire the 'wrap' and 'signatureline' tokens
+    // here until we need a more generic solution.
     bool bIsWrap = Element == static_cast<sal_Int32>(NMSP_vmlWord | XML_wrap);
+    bool bIsSignatureLine = Element == static_cast<sal_Int32>(NMSP_vmlOffice | XML_signatureline);
+    bool bIsShapeSent = static_cast<OOXMLFastContextHandlerShape*>(mpParent)->isShapeSent();
     bool bSkipImages = getDocument()->IsSkipImages() && oox::getNamespace(Element) == static_cast<sal_Int32>(NMSP_dml) &&
         !((oox::getBaseToken(Element) == XML_linkedTxbx) || (oox::getBaseToken(Element) == XML_txbx));
 
-    if ( bInNamespaces && (!bIsWrap || static_cast<OOXMLFastContextHandlerShape*>(mpParent)->isShapeSent()) )
+    if ( bInNamespaces && ((!bIsWrap && !bIsSignatureLine) || bIsShapeSent) )
         xResult.set(OOXMLFactory::createFastChildContextFromStart(this, Element));
     else if (mxContext.is()  && !bSkipImages)
     {
diff --git a/xmlsecurity/inc/xsecctl.hxx b/xmlsecurity/inc/xsecctl.hxx
index a041bd3b7069..cc3b11db80a7 100644
--- a/xmlsecurity/inc/xsecctl.hxx
+++ b/xmlsecurity/inc/xsecctl.hxx
@@ -273,6 +273,9 @@ private:
     void setDate( OUString const & ouDate );
     void setDescription(const OUString& rDescription);
     void setCertDigest(const OUString& rCertDigest);
+    void setValidSignatureImage(const OUString& rValidSigImg);
+    void setInvalidSignatureImage(const OUString& rInvalidSigImg);
+    void setSignatureLineId(const OUString& rSignatureLineId);
 
 public:
     void setSignatureBytes(const css::uno::Sequence<sal_Int8>& rBytes);
diff --git a/xmlsecurity/source/component/documentdigitalsignatures.cxx b/xmlsecurity/source/component/documentdigitalsignatures.cxx
index 840c4223ce96..bc52bdb30ff1 100644
--- a/xmlsecurity/source/component/documentdigitalsignatures.cxx
+++ b/xmlsecurity/source/component/documentdigitalsignatures.cxx
@@ -368,6 +368,15 @@ DocumentDigitalSignatures::ImplVerifySignatures(
 
             rSigInfo.SignatureIsValid = ( rInfo.nStatus == css::xml::crypto::SecurityOperationStatus_OPERATION_SUCCEEDED );
 
+            // OOXML Signature line info (ID + Images)
+            if (!rInfo.ouSignatureLineId.isEmpty())
+                rSigInfo.SignatureLineId = rInfo.ouSignatureLineId;
+
+            if (rInfo.aValidSignatureImage.is())
+                rSigInfo.ValidSignatureLineImage = rInfo.aValidSignatureImage;
+
+            if (rInfo.aInvalidSignatureImage.is())
+                rSigInfo.InvalidSignatureLineImage = rInfo.aInvalidSignatureImage;
 
             // OOXML intentionally doesn't sign metadata.
             if ( rSigInfo.SignatureIsValid && aStreamHelper.nStorageFormat != embed::StorageFormats::OFOPXML)
diff --git a/xmlsecurity/source/helper/ooxmlsecparser.cxx b/xmlsecurity/source/helper/ooxmlsecparser.cxx
index b936254cc5c3..e9a4b61e8b98 100644
--- a/xmlsecurity/source/helper/ooxmlsecparser.cxx
+++ b/xmlsecurity/source/helper/ooxmlsecparser.cxx
@@ -23,6 +23,8 @@ OOXMLSecParser::OOXMLSecParser(XMLSignatureHelper& rXMLSignatureHelper, XSecCont
     ,m_bInX509IssuerName(false)
     ,m_bInX509SerialNumber(false)
     ,m_bInCertDigest(false)
+    ,m_bInValidSignatureImage(false)
+    ,m_bInInvalidSignatureImage(false)
     ,m_bReferenceUnresolved(false)
     ,m_rXMLSignatureHelper(rXMLSignatureHelper)
 {
@@ -120,6 +122,29 @@ void SAL_CALL OOXMLSecParser::startElement(const OUString& rName, const uno::Ref
         m_aCertDigest.clear();
         m_bInCertDigest = true;
     }
+    else if (rName == "Object")
+    {
+        OUString sId = xAttribs->getValueByName("Id");
+        if (sId == "idValidSigLnImg")
+        {
+            m_aValidSignatureImage.clear();
+            m_bInValidSignatureImage = true;
+        }
+        else if (sId == "idInvalidSigLnImg")
+        {
+            m_aInvalidSignatureImage.clear();
+            m_bInInvalidSignatureImage = true;
+        }
+        else
+        {
+            SAL_INFO("xmlsecurity.ooxml", "Unknown 'Object' child element: " << rName);
+        }
+    }
+    else if (rName == "SetupID")
+    {
+        m_aSignatureLineId.clear();
+        m_bInSignatureLineId = true;
+    }
     else
     {
         SAL_INFO("xmlsecurity.ooxml", "Unknown xml element: " << rName);
@@ -180,6 +205,24 @@ void SAL_CALL OOXMLSecParser::endElement(const OUString& rName)
         m_pXSecController->setCertDigest(m_aCertDigest);
         m_bInCertDigest = false;
     }
+    else if (rName == "Object")
+    {
+        if (m_bInValidSignatureImage)
+        {
+            m_pXSecController->setValidSignatureImage(m_aValidSignatureImage);
+            m_bInValidSignatureImage = false;
+        }
+        else if (m_bInInvalidSignatureImage)
+        {
+            m_pXSecController->setInvalidSignatureImage(m_aInvalidSignatureImage);
+            m_bInInvalidSignatureImage = false;
+        }
+    }
+    else if (rName == "SetupID")
+    {
+        m_pXSecController->setSignatureLineId(m_aSignatureLineId);
+        m_bInSignatureLineId = false;
+    }
 
     if (m_xNextHandler.is())
         m_xNextHandler->endElement(rName);
@@ -203,6 +246,12 @@ void SAL_CALL OOXMLSecParser::characters(const OUString& rChars)
         m_aX509SerialNumber += rChars;
     else if (m_bInCertDigest)
         m_aCertDigest += rChars;
+    else if (m_bInValidSignatureImage)
+        m_aValidSignatureImage += rChars;
+    else if (m_bInInvalidSignatureImage)
+        m_aInvalidSignatureImage += rChars;
+    else if (m_bInSignatureLineId)
+        m_aSignatureLineId += rChars;
 
     if (m_xNextHandler.is())
         m_xNextHandler->characters(rChars);
diff --git a/xmlsecurity/source/helper/ooxmlsecparser.hxx b/xmlsecurity/source/helper/ooxmlsecparser.hxx
index 5da50e3a423a..b425e4c32a0f 100644
--- a/xmlsecurity/source/helper/ooxmlsecparser.hxx
+++ b/xmlsecurity/source/helper/ooxmlsecparser.hxx
@@ -45,6 +45,12 @@ class OOXMLSecParser: public cppu::WeakImplHelper
     OUString m_aX509SerialNumber;
     bool m_bInCertDigest;
     OUString m_aCertDigest;
+    bool m_bInValidSignatureImage;
+    OUString m_aValidSignatureImage;
+    bool m_bInInvalidSignatureImage;
+    OUString m_aInvalidSignatureImage;
+    bool m_bInSignatureLineId;
+    OUString m_aSignatureLineId;
 
     /// Last seen <Reference URI="...">.
     OUString m_aReferenceURI;
diff --git a/xmlsecurity/source/helper/xsecverify.cxx b/xmlsecurity/source/helper/xsecverify.cxx
index 54987c619edd..72474337a7e7 100644
--- a/xmlsecurity/source/helper/xsecverify.cxx
+++ b/xmlsecurity/source/helper/xsecverify.cxx
@@ -26,18 +26,27 @@
 #include <gpg/xmlsignature_gpgimpl.hxx>
 #include <gpg/SEInitializer.hxx>
 
+#include <com/sun/star/uno/Sequence.hxx>
 #include <com/sun/star/xml/crypto/sax/XKeyCollector.hpp>
 #include <com/sun/star/xml/crypto/sax/ElementMarkPriority.hpp>
 #include <com/sun/star/xml/crypto/sax/XReferenceResolvedBroadcaster.hpp>
 #include <com/sun/star/xml/crypto/sax/XReferenceCollector.hpp>
 #include <com/sun/star/xml/crypto/sax/XSignatureVerifyResultBroadcaster.hpp>
 #include <com/sun/star/xml/crypto/XSEInitializer.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
+#include <com/sun/star/graphic/GraphicProvider.hpp>
 #include <com/sun/star/xml/sax/SAXParseException.hpp>
 #include <com/sun/star/embed/StorageFormats.hpp>
 #include <sal/log.hxx>
 #include <unotools/datetime.hxx>
-
-using namespace com::sun::star;
+#include <comphelper/base64.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/sequence.hxx>
+#include <comphelper/seqstream.hxx>
+
+using namespace css;
+using namespace css::uno;
+using namespace css::beans;
 namespace cssu = com::sun::star::uno;
 namespace cssl = com::sun::star::lang;
 namespace cssxc = com::sun::star::xml::crypto;
@@ -344,6 +353,56 @@ void XSecController::setCertDigest(const OUString& rCertDigest)
     rInformation.signatureInfor.ouCertDigest = rCertDigest;
 }
 
+namespace {
+Reference<css::graphic::XGraphic> lcl_getGraphicFromString(const OUString& rImage)
+{
+    Sequence<sal_Int8> seq;
+    comphelper::Base64::decode(seq, rImage);
+
+    Reference< graphic::XGraphic > xGraphic;
+    if( !seq.hasElements() )
+        return Reference<css::graphic::XGraphic>();
+
+    Reference< graphic::XGraphicProvider > xGraphicProvider(
+        graphic::GraphicProvider::create(comphelper::getProcessComponentContext()) );
+    Reference< io::XInputStream > xInputStream( new ::comphelper::SequenceInputStream( seq ) );
+
+    Sequence< PropertyValue > aArgs( 1 );
+    aArgs[ 0 ].Name = "InputStream";
+    aArgs[ 0 ].Value <<= xInputStream;
+    xGraphic = xGraphicProvider->queryGraphic(aArgs);
+
+    return xGraphic;
+}
+}
+
+void XSecController::setValidSignatureImage(const OUString& rValidSigImg)
+{
+    if (m_vInternalSignatureInformations.empty() || rValidSigImg.isEmpty())
+        return;
+
+    InternalSignatureInformation& rInformation = m_vInternalSignatureInformations.back();
+    rInformation.signatureInfor.aValidSignatureImage = lcl_getGraphicFromString(rValidSigImg);
+}
+
+void XSecController::setInvalidSignatureImage(const OUString& rInvalidSigImg)
+{
+    if (m_vInternalSignatureInformations.empty() || rInvalidSigImg.isEmpty())
+        return;
+
+    InternalSignatureInformation& rInformation = m_vInternalSignatureInformations.back();
+    rInformation.signatureInfor.aInvalidSignatureImage = lcl_getGraphicFromString(rInvalidSigImg);
+}
+
+void XSecController::setSignatureLineId(const OUString& rSignatureLineId)
+{
+    if (m_vInternalSignatureInformations.empty())
+        return;
+
+    InternalSignatureInformation& rInformation = m_vInternalSignatureInformations.back();
+    rInformation.signatureInfor.ouSignatureLineId = rSignatureLineId;
+}
+
 void XSecController::addEncapsulatedX509Certificate(const OUString& rEncapsulatedX509Certificate)
 {
     if (m_vInternalSignatureInformations.empty())


More information about the Libreoffice-commits mailing list