[poppler] poppler/PDFDoc.cc
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Jan 7 14:33:21 UTC 2022
poppler/PDFDoc.cc | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
New commits:
commit 3e5737bfa1fc00dd6ee6895f19cab6d4c768421a
Author: Marek Kasik <mkasik at redhat.com>
Date: Fri Jan 7 14:48:33 2022 +0100
PDFDoc: Count only signature fields in getNumSignatureFields
Previous version returned number of all fields instead of just the ones
with signatures.
diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc
index 71360a50..dab2add1 100644
--- a/poppler/PDFDoc.cc
+++ b/poppler/PDFDoc.cc
@@ -50,7 +50,7 @@
// Copyright (C) 2021 Mahmoud Khalil <mahmoudkhalil11 at gmail.com>
// Copyright (C) 2021 RM <rm+git at arcsin.org>
// Copyright (C) 2021 Georgiy Sgibnev <georgiy at sgibnev.com>. Work sponsored by lab50.net.
-// Copyright (C) 2021 Marek Kasik <mkasik at redhat.com>
+// Copyright (C) 2021-2022 Marek Kasik <mkasik at redhat.com>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
@@ -633,6 +633,23 @@ std::vector<FormFieldSignature *> PDFDoc::getSignatureFields()
return res;
}
+static int sumSignatureFields(FormField *ff)
+{
+ int sum = 0;
+
+ if (ff->getNumChildren() == 0) {
+ if (ff->getType() == formSignature) {
+ sum = 1;
+ }
+ } else {
+ for (int i = 0; i < ff->getNumChildren(); ++i) {
+ FormField *children = ff->getChildren(i);
+ sum += sumSignatureFields(children);
+ }
+ }
+ return sum;
+}
+
int PDFDoc::getNumSignatureFields()
{
const Form *f = catalog->getForm();
@@ -640,7 +657,13 @@ int PDFDoc::getNumSignatureFields()
if (!f)
return 0;
- return f->getNumFields();
+ const int nRootFields = f->getNumFields();
+ int sum = 0;
+ for (int i = 0; i < nRootFields; ++i) {
+ FormField *ff = f->getRootField(i);
+ sum += sumSignatureFields(ff);
+ }
+ return sum;
}
void PDFDoc::displayPage(OutputDev *out, int page, double hDPI, double vDPI, int rotate, bool useMediaBox, bool crop, bool printing, bool (*abortCheckCbk)(void *data), void *abortCheckCbkData,
More information about the poppler
mailing list