[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/vcl vcl/inc vcl/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Mon Jun 29 07:10:18 UTC 2020


 include/vcl/filter/pdfdocument.hxx     |   13 +++++++++++--
 vcl/source/filter/ipdf/pdfdocument.cxx |   31 +++++++++++++++++++++++++++++++
 vcl/source/gdi/pdfobjectcopier.cxx     |    3 +--
 vcl/source/gdi/pdfwriter_impl.hxx      |    3 ++-
 4 files changed, 45 insertions(+), 5 deletions(-)

New commits:
commit 3c8fb91228d21fe0ba016831f677fcc7b7e99472
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Thu Jun 18 14:44:53 2020 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Mon Jun 29 09:09:44 2020 +0200

    sd signature line: teach PDFDocument how to use PDFObjectCopier
    
    This will allow using the object copier in
    PDFDocument::WriteAppearanceObject(), so we can include the signature
    line pdf export result in a pdf signature of the original pdf.
    
    (cherry picked from commit f9ac4ab61fa2ebcafa8ea8957db01104a927bff2)
    
    Conflicts:
            include/vcl/filter/pdfdocument.hxx
    
    Change-Id: Iabc508081c5820f4ca997a2d264de9bdb06f82bd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97249
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/include/vcl/filter/pdfdocument.hxx b/include/vcl/filter/pdfdocument.hxx
index 10ce81afa5be..70e6f79641b8 100644
--- a/include/vcl/filter/pdfdocument.hxx
+++ b/include/vcl/filter/pdfdocument.hxx
@@ -16,9 +16,10 @@
 #include <vector>
 
 #include <tools/stream.hxx>
-
 #include <vcl/dllapi.h>
 
+#include <vcl/filter/pdfobjectcontainer.hxx>
+
 namespace com
 {
 namespace sun
@@ -345,7 +346,7 @@ public:
  * elements remember their source offset / length, and based on that it's
  * possible to modify the input file.
  */
-class VCL_DLLPUBLIC PDFDocument
+class VCL_DLLPUBLIC PDFDocument : public PDFObjectContainer
 {
     /// This vector owns all elements.
     std::vector<std::unique_ptr<PDFElement>> m_aElements;
@@ -392,6 +393,7 @@ class VCL_DLLPUBLIC PDFDocument
 
 public:
     PDFDocument();
+    virtual ~PDFDocument();
     PDFDocument& operator=(const PDFDocument&) = delete;
     PDFDocument(const PDFDocument&) = delete;
     /// @name Low-level functions, to be used by PDFElement subclasses.
@@ -437,6 +439,13 @@ public:
     /// Remove the nth signature from read document in the edit buffer.
     bool RemoveSignature(size_t nPosition);
     //@}
+
+    /// See vcl::PDFObjectContainer::createObject().
+    sal_Int32 createObject() override;
+    /// See vcl::PDFObjectContainer::updateObject().
+    bool updateObject(sal_Int32 n) override;
+    /// See vcl::PDFObjectContainer::writeBuffer().
+    bool writeBuffer(const void* pBuffer, sal_uInt64 nBytes) override;
 };
 
 } // namespace pdfio
diff --git a/vcl/inc/pdf/objectcontainer.hxx b/include/vcl/filter/pdfobjectcontainer.hxx
similarity index 100%
rename from vcl/inc/pdf/objectcontainer.hxx
rename to include/vcl/filter/pdfobjectcontainer.hxx
diff --git a/vcl/source/filter/ipdf/pdfdocument.cxx b/vcl/source/filter/ipdf/pdfdocument.cxx
index f19925646f54..85a5d19ca52f 100644
--- a/vcl/source/filter/ipdf/pdfdocument.cxx
+++ b/vcl/source/filter/ipdf/pdfdocument.cxx
@@ -26,6 +26,7 @@
 #include <svl/cryptosign.hxx>
 #include <tools/zcodec.hxx>
 #include <vcl/pdfwriter.hxx>
+#include <o3tl/safeint.hxx>
 
 using namespace com::sun::star;
 
@@ -122,6 +123,8 @@ XRefEntry::XRefEntry() = default;
 
 PDFDocument::PDFDocument() = default;
 
+PDFDocument::~PDFDocument() = default;
+
 bool PDFDocument::RemoveSignature(size_t nPosition)
 {
     std::vector<PDFObjectElement*> aSignatures = GetSignatureWidgets();
@@ -147,6 +150,34 @@ bool PDFDocument::RemoveSignature(size_t nPosition)
     return m_aEditBuffer.good();
 }
 
+sal_Int32 PDFDocument::createObject()
+{
+    sal_Int32 nObject = m_aXRef.size();
+    m_aXRef[nObject] = XRefEntry();
+    return nObject;
+}
+
+bool PDFDocument::updateObject(sal_Int32 nObject)
+{
+    if (static_cast<size_t>(nObject) >= m_aXRef.size())
+    {
+        SAL_WARN("vcl.filter", "PDFDocument::updateObject: invalid nObject");
+        return false;
+    }
+
+    XRefEntry aEntry;
+    aEntry.SetOffset(m_aEditBuffer.Tell());
+    aEntry.SetDirty(true);
+    m_aXRef[nObject] = aEntry;
+    return true;
+}
+
+bool PDFDocument::writeBuffer(const void* pBuffer, sal_uInt64 nBytes)
+{
+    std::size_t nWritten = m_aEditBuffer.WriteBytes(pBuffer, nBytes);
+    return nWritten == nBytes;
+}
+
 void PDFDocument::SetSignatureLine(const std::vector<sal_Int8>& rSignatureLine)
 {
     m_aSignatureLine = rSignatureLine;
diff --git a/vcl/source/gdi/pdfobjectcopier.cxx b/vcl/source/gdi/pdfobjectcopier.cxx
index 4ba93b3a746d..c5ff2eecab19 100644
--- a/vcl/source/gdi/pdfobjectcopier.cxx
+++ b/vcl/source/gdi/pdfobjectcopier.cxx
@@ -14,8 +14,7 @@
 #include <sal/types.h>
 #include <tools/stream.hxx>
 #include <vcl/filter/pdfdocument.hxx>
-
-#include <pdf/objectcontainer.hxx>
+#include <vcl/filter/pdfobjectcontainer.hxx>
 
 namespace vcl
 {
diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx
index d3a7fd8c6c16..43774333a182 100644
--- a/vcl/source/gdi/pdfwriter_impl.hxx
+++ b/vcl/source/gdi/pdfwriter_impl.hxx
@@ -45,7 +45,7 @@
 #include <tools/stream.hxx>
 
 #include <outdata.hxx>
-#include <pdf/objectcontainer.hxx>
+#include <vcl/filter/pdfobjectcontainer.hxx>
 #include "pdffontcache.hxx"
 #include "pdfbuildin_fonts.hxx"
 
@@ -954,6 +954,7 @@ i12626
     /// See vcl::PDFObjectContainer::updateObject().
     bool updateObject( sal_Int32 n ) override;
 
+    /// See vcl::PDFObjectContainer::writeBuffer().
     bool writeBuffer( const void* pBuffer, sal_uInt64 nBytes ) override;
     void beginCompression();
     void endCompression();


More information about the Libreoffice-commits mailing list