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 f9ac4ab61fa2ebcafa8ea8957db01104a927bff2 Author: Miklos Vajna <[email protected]> AuthorDate: Thu Jun 18 14:44:53 2020 +0200 Commit: Miklos Vajna <[email protected]> CommitDate: Thu Jun 18 16:51:59 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. Change-Id: Iabc508081c5820f4ca997a2d264de9bdb06f82bd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96607 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Jenkins diff --git a/include/vcl/filter/pdfdocument.hxx b/include/vcl/filter/pdfdocument.hxx index aaf64ae908fe..70ca731d1d19 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::sun::star::security { class XCertificate; @@ -325,7 +326,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; @@ -372,6 +373,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. @@ -417,6 +419,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 vcl::filter 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 ca6d8aa6e486..09439604996d 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; @@ -126,6 +127,8 @@ XRefEntry::XRefEntry() = default; PDFDocument::PDFDocument() = default; +PDFDocument::~PDFDocument() = default; + bool PDFDocument::RemoveSignature(size_t nPosition) { std::vector<PDFObjectElement*> aSignatures = GetSignatureWidgets(); @@ -151,6 +154,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 (o3tl::make_unsigned(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 4aaa6c873ce1..eb53db7d5877 100644 --- a/vcl/source/gdi/pdfwriter_impl.hxx +++ b/vcl/source/gdi/pdfwriter_impl.hxx @@ -51,7 +51,7 @@ #include <tools/stream.hxx> #include <outdata.hxx> -#include <pdf/objectcontainer.hxx> +#include <vcl/filter/pdfobjectcontainer.hxx> #include "pdffontcache.hxx" #include "pdfbuildin_fonts.hxx" @@ -949,6 +949,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(); _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
