diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-06-18 14:44:53 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-06-18 16:51:59 +0200 |
commit | f9ac4ab61fa2ebcafa8ea8957db01104a927bff2 (patch) | |
tree | b6a5f6c6de1767c264008b53b98e8cf1cb078d4f /vcl/source/filter | |
parent | 9197a52c1bd79bbdc0756724c74fd2a679b9f626 (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/filter')
-rw-r--r-- | vcl/source/filter/ipdf/pdfdocument.cxx | 31 |
1 files changed, 31 insertions, 0 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; |