[poppler] poppler/Form.cc poppler/Form.h qt5/src
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sat Mar 21 22:12:18 UTC 2020
poppler/Form.cc | 5 +++++
poppler/Form.h | 3 ++-
qt5/src/poppler-form.cc | 18 +++++++++++++++++-
qt5/src/poppler-form.h | 10 +++++++++-
4 files changed, 33 insertions(+), 3 deletions(-)
New commits:
commit 5c601c40d84686134d90a0f862e2507bd628e188
Author: Albert Astals Cid <aacid at kde.org>
Date: Tue Mar 17 23:39:53 2020 +0100
qt5: Add option to get choice for export value
diff --git a/poppler/Form.cc b/poppler/Form.cc
index de9077dc..024449ab 100644
--- a/poppler/Form.cc
+++ b/poppler/Form.cc
@@ -423,6 +423,11 @@ const GooString* FormWidgetChoice::getChoice(int i) const
return parent()->getChoice(i);
}
+const GooString* FormWidgetChoice::getExportVal(int i) const
+{
+ return parent()->getExportVal(i);
+}
+
bool FormWidgetChoice::isCombo () const
{
return parent()->isCombo();
diff --git a/poppler/Form.h b/poppler/Form.h
index 77528dda..b4081ea0 100644
--- a/poppler/Form.h
+++ b/poppler/Form.h
@@ -6,7 +6,7 @@
//
// Copyright 2006 Julien Rebetez <julienr at svn.gnome.org>
// Copyright 2007, 2008, 2011 Carlos Garcia Campos <carlosgc at gnome.org>
-// Copyright 2007-2010, 2012, 2015-2019 Albert Astals Cid <aacid at kde.org>
+// Copyright 2007-2010, 2012, 2015-2020 Albert Astals Cid <aacid at kde.org>
// Copyright 2010 Mark Riedesel <mark at klowner.com>
// Copyright 2011 Pino Toscano <pino at kde.org>
// Copyright 2012 Fabio D'Urso <fabiodurso at hotmail.it>
@@ -228,6 +228,7 @@ public:
int getNumChoices() const;
//return the display name of the i-th choice (UTF16BE)
const GooString* getChoice(int i) const;
+ const GooString* getExportVal(int i) const;
//select the i-th choice
void select (int i);
diff --git a/qt5/src/poppler-form.cc b/qt5/src/poppler-form.cc
index 58458b76..1ed419c8 100644
--- a/qt5/src/poppler-form.cc
+++ b/qt5/src/poppler-form.cc
@@ -1,6 +1,6 @@
/* poppler-form.h: qt interface to poppler
* Copyright (C) 2007-2008, 2011, Pino Toscano <pino at kde.org>
- * Copyright (C) 2008, 2011, 2012, 2015-2019 Albert Astals Cid <aacid at kde.org>
+ * Copyright (C) 2008, 2011, 2012, 2015-2020 Albert Astals Cid <aacid at kde.org>
* Copyright (C) 2011 Carlos Garcia Campos <carlosgc at gnome.org>
* Copyright (C) 2012, Adam Reichold <adamreichold at myopera.com>
* Copyright (C) 2016, Hanno Meyer-Thurow <h.mth at web.de>
@@ -513,6 +513,22 @@ QStringList FormFieldChoice::choices() const
return ret;
}
+QVector<QPair<QString,QString>> FormFieldChoice::choicesWithExportValues() const
+{
+ FormWidgetChoice* fwc = static_cast<FormWidgetChoice*>(m_formData->fm);
+ QVector<QPair<QString, QString>> ret;
+ const int num = fwc->getNumChoices();
+ ret.reserve(num);
+ for (int i = 0; i < num; ++i)
+ {
+ const QString display = UnicodeParsedString(fwc->getChoice(i));
+ const GooString *exportValueG = fwc->getExportVal(i);
+ const QString exportValue = exportValueG ? UnicodeParsedString(exportValueG) : display;
+ ret.append({display, exportValue});
+ }
+ return ret;
+}
+
bool FormFieldChoice::isEditable() const
{
FormWidgetChoice* fwc = static_cast<FormWidgetChoice*>(m_formData->fm);
diff --git a/qt5/src/poppler-form.h b/qt5/src/poppler-form.h
index 3918fc7d..44322287 100644
--- a/qt5/src/poppler-form.h
+++ b/qt5/src/poppler-form.h
@@ -1,6 +1,6 @@
/* poppler-form.h: qt interface to poppler
* Copyright (C) 2007-2008, Pino Toscano <pino at kde.org>
- * Copyright (C) 2008, 2011, 2016, 2017, 2019, Albert Astals Cid <aacid at kde.org>
+ * Copyright (C) 2008, 2011, 2016, 2017, 2019, 2020, Albert Astals Cid <aacid at kde.org>
* Copyright (C) 2012, Adam Reichold <adamreichold at myopera.com>
* Copyright (C) 2016, Hanno Meyer-Thurow <h.mth at web.de>
* Copyright (C) 2017, Hans-Ulrich Jüttner <huj at froreich-bioscientia.de>
@@ -410,6 +410,14 @@ namespace Poppler {
*/
QStringList choices() const;
+ /**
+ The possible choices of the choice field.
+ The first value of the pair is the display name of the choice,
+ The second value is the export value (i.e. for use in javascript, etc) of the choice
+ @since 0.87
+ */
+ QVector<QPair<QString,QString>> choicesWithExportValues() const;
+
/**
Whether this FormFieldChoice::ComboBox is editable, i.e. the user
can type in a custom value.
More information about the poppler
mailing list