[Libreoffice-commits] core.git: include/vcl vcl/source xmlsecurity/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Thu Nov 19 08:04:27 UTC 2020
include/vcl/filter/PDFiumLibrary.hxx | 4 +++-
vcl/source/pdf/PDFiumLibrary.cxx | 16 ++++++++++++++++
xmlsecurity/source/helper/pdfsignaturehelper.cxx | 8 +++-----
3 files changed, 22 insertions(+), 6 deletions(-)
New commits:
commit 728bfa1879da097b65fd39b1e63c52478a913af0
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Nov 18 21:10:43 2020 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Nov 19 09:03:46 2020 +0100
pdfium: add signature and trailer end getter wrappers
So PDFiumDocument::getPointer() can be retired.
Change-Id: I77c34c3e263bd6f39e06e50f621f2eaff804c716
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106079
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
diff --git a/include/vcl/filter/PDFiumLibrary.hxx b/include/vcl/filter/PDFiumLibrary.hxx
index 014505d7739d..2663a6cf03ae 100644
--- a/include/vcl/filter/PDFiumLibrary.hxx
+++ b/include/vcl/filter/PDFiumLibrary.hxx
@@ -246,11 +246,13 @@ public:
// Page size in points
basegfx::B2DSize getPageSize(int nIndex);
int getPageCount();
+ int getSignatureCount();
int getFileVersion();
bool saveWithVersion(SvMemoryStream& rStream, int nFileVersion);
std::unique_ptr<PDFiumPage> openPage(int nIndex);
- FPDF_DOCUMENT getPointer() { return mpPdfDocument; }
+ FPDF_SIGNATURE getSignature(int nIndex);
+ std::vector<unsigned int> getTrailerEnds();
};
struct PDFiumLibrary final : public rtl::StaticWithInit<std::shared_ptr<PDFium>, PDFiumLibrary>
diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx
index ae1588e4a268..391a93f90ffb 100644
--- a/vcl/source/pdf/PDFiumLibrary.cxx
+++ b/vcl/source/pdf/PDFiumLibrary.cxx
@@ -19,6 +19,7 @@
#include <fpdf_edit.h>
#include <fpdf_text.h>
#include <fpdf_save.h>
+#include <fpdf_signature.h>
#include <osl/endian.h>
#include <vcl/bitmap.hxx>
@@ -212,6 +213,19 @@ std::unique_ptr<PDFiumPage> PDFiumDocument::openPage(int nIndex)
return pPDFiumPage;
}
+FPDF_SIGNATURE PDFiumDocument::getSignature(int nIndex)
+{
+ return FPDF_GetSignatureObject(mpPdfDocument, nIndex);
+}
+
+std::vector<unsigned int> PDFiumDocument::getTrailerEnds()
+{
+ int nNumTrailers = FPDF_GetTrailerEnds(mpPdfDocument, nullptr, 0);
+ std::vector<unsigned int> aTrailerEnds(nNumTrailers);
+ FPDF_GetTrailerEnds(mpPdfDocument, aTrailerEnds.data(), aTrailerEnds.size());
+ return aTrailerEnds;
+}
+
basegfx::B2DSize PDFiumDocument::getPageSize(int nIndex)
{
basegfx::B2DSize aSize;
@@ -225,6 +239,8 @@ basegfx::B2DSize PDFiumDocument::getPageSize(int nIndex)
int PDFiumDocument::getPageCount() { return FPDF_GetPageCount(mpPdfDocument); }
+int PDFiumDocument::getSignatureCount() { return FPDF_GetSignatureCount(mpPdfDocument); }
+
int PDFiumDocument::getFileVersion()
{
int nFileVersion = 0;
diff --git a/xmlsecurity/source/helper/pdfsignaturehelper.cxx b/xmlsecurity/source/helper/pdfsignaturehelper.cxx
index 6b8eefef7099..6e0f1cfb176b 100644
--- a/xmlsecurity/source/helper/pdfsignaturehelper.cxx
+++ b/xmlsecurity/source/helper/pdfsignaturehelper.cxx
@@ -472,7 +472,7 @@ bool PDFSignatureHelper::ReadAndVerifySignatureSvStream(SvStream& rStream)
return false;
}
- int nSignatureCount = FPDF_GetSignatureCount(pPdfDocument->getPointer());
+ int nSignatureCount = pPdfDocument->getSignatureCount();
if (nSignatureCount <= 0)
{
return true;
@@ -480,7 +480,7 @@ bool PDFSignatureHelper::ReadAndVerifySignatureSvStream(SvStream& rStream)
std::vector<Signature> aSignatures(nSignatureCount);
for (int i = 0; i < nSignatureCount; ++i)
{
- FPDF_SIGNATURE pSignature = FPDF_GetSignatureObject(pPdfDocument->getPointer(), i);
+ FPDF_SIGNATURE pSignature = pPdfDocument->getSignature(i);
std::vector<std::pair<size_t, size_t>> aByteRanges;
GetByteRangesFromPDF(pSignature, aByteRanges);
aSignatures[i] = Signature{ pSignature, aByteRanges };
@@ -496,9 +496,7 @@ bool PDFSignatureHelper::ReadAndVerifySignatureSvStream(SvStream& rStream)
}
}
- int nNumTrailers = FPDF_GetTrailerEnds(pPdfDocument->getPointer(), nullptr, 0);
- std::vector<unsigned int> aTrailerEnds(nNumTrailers);
- FPDF_GetTrailerEnds(pPdfDocument->getPointer(), aTrailerEnds.data(), aTrailerEnds.size());
+ std::vector<unsigned int> aTrailerEnds = pPdfDocument->getTrailerEnds();
m_aSignatureInfos.clear();
More information about the Libreoffice-commits
mailing list