[Libreoffice-commits] core.git: include/vcl vcl/source xmlsecurity/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Tue Jun 16 13:56:11 UTC 2020


 include/vcl/filter/pdfdocument.hxx               |    4 ++++
 vcl/source/filter/ipdf/pdfdocument.cxx           |    7 +++++++
 xmlsecurity/source/helper/pdfsignaturehelper.cxx |    4 ++++
 3 files changed, 15 insertions(+)

New commits:
commit 058c21ac4a552ee6f6ca2f67c0d134a819228d53
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Jun 16 14:31:55 2020 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Jun 16 15:55:38 2020 +0200

    sd signature line: access the pdf shape from the appearance writer
    
    PDFDocument::WriteAppearanceObject() is where we can turn the pdf data
    (containing a single shape only) into a form XObject, later.
    
    Change-Id: Id042c95af4a867d3997d6f7742a18659b8925c12
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96455
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins

diff --git a/include/vcl/filter/pdfdocument.hxx b/include/vcl/filter/pdfdocument.hxx
index 42130eba9d15..8700e4892df2 100644
--- a/include/vcl/filter/pdfdocument.hxx
+++ b/include/vcl/filter/pdfdocument.hxx
@@ -344,6 +344,9 @@ class VCL_DLLPUBLIC PDFDocument
     /// All editing takes place in this buffer, if it happens.
     SvMemoryStream m_aEditBuffer;
 
+    /// Signature line in PDF format, to be consumed by the next Sign() invocation.
+    std::vector<sal_Int8> m_aSignatureLine;
+
     /// Suggest a minimal, yet free signature ID to use for the next signature.
     sal_uInt32 GetNextSignature();
     /// Write the signature object as part of signing.
@@ -397,6 +400,7 @@ public:
     //@{
     /// Read elements from the start of the stream till its end.
     bool Read(SvStream& rStream);
+    void SetSignatureLine(const std::vector<sal_Int8>& rSignatureLine);
     /// Sign the read document with xCertificate in the edit buffer.
     bool Sign(const css::uno::Reference<css::security::XCertificate>& xCertificate,
               const OUString& rDescription, bool bAdES);
diff --git a/vcl/source/filter/ipdf/pdfdocument.cxx b/vcl/source/filter/ipdf/pdfdocument.cxx
index 73d7f452688d..316b8c74d169 100644
--- a/vcl/source/filter/ipdf/pdfdocument.cxx
+++ b/vcl/source/filter/ipdf/pdfdocument.cxx
@@ -151,6 +151,11 @@ bool PDFDocument::RemoveSignature(size_t nPosition)
     return m_aEditBuffer.good();
 }
 
+void PDFDocument::SetSignatureLine(const std::vector<sal_Int8>& rSignatureLine)
+{
+    m_aSignatureLine = rSignatureLine;
+}
+
 sal_uInt32 PDFDocument::GetNextSignature()
 {
     sal_uInt32 nRet = 0;
@@ -233,6 +238,8 @@ sal_Int32 PDFDocument::WriteSignatureObject(const OUString& rDescription, bool b
 
 sal_Int32 PDFDocument::WriteAppearanceObject()
 {
+    m_aSignatureLine.clear();
+
     // Write appearance object.
     sal_Int32 nAppearanceId = m_aXRef.size();
     XRefEntry aAppearanceEntry;
diff --git a/xmlsecurity/source/helper/pdfsignaturehelper.cxx b/xmlsecurity/source/helper/pdfsignaturehelper.cxx
index 614d8e694e07..beb5b7e800bb 100644
--- a/xmlsecurity/source/helper/pdfsignaturehelper.cxx
+++ b/xmlsecurity/source/helper/pdfsignaturehelper.cxx
@@ -202,6 +202,10 @@ bool PDFSignatureHelper::Sign(const uno::Reference<io::XInputStream>& xInputStre
 
     std::vector<sal_Int8> aSignatureLineShape;
     GetSignatureLineShape(aSignatureLineShape);
+    if (!aSignatureLineShape.empty())
+    {
+        aDocument.SetSignatureLine(aSignatureLineShape);
+    }
 
     if (!aDocument.Sign(m_xCertificate, m_aDescription, bAdES))
     {


More information about the Libreoffice-commits mailing list