summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-06-18 14:44:53 +0200
committerMiklos Vajna <vmiklos@collabora.com>2020-06-18 16:51:59 +0200
commitf9ac4ab61fa2ebcafa8ea8957db01104a927bff2 (patch)
treeb6a5f6c6de1767c264008b53b98e8cf1cb078d4f /vcl/source
parent9197a52c1bd79bbdc0756724c74fd2a679b9f626 (diff)
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 <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/filter/ipdf/pdfdocument.cxx31
-rw-r--r--vcl/source/gdi/pdfobjectcopier.cxx3
-rw-r--r--vcl/source/gdi/pdfwriter_impl.hxx3
3 files changed, 34 insertions, 3 deletions
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();