summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Astals Cid <aacid@kde.org>2020-03-17 23:39:53 +0100
committerAlbert Astals Cid <aacid@kde.org>2020-03-21 23:07:23 +0100
commit5c601c40d84686134d90a0f862e2507bd628e188 (patch)
tree3b4a5c4c099cee45b318e190331112cfa3ba93d0
parent4813adfada062a9161b55e412e3997b748123f7f (diff)
qt5: Add option to get choice for export value
-rw-r--r--poppler/Form.cc5
-rw-r--r--poppler/Form.h3
-rw-r--r--qt5/src/poppler-form.cc18
-rw-r--r--qt5/src/poppler-form.h10
4 files changed, 33 insertions, 3 deletions
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@svn.gnome.org>
// Copyright 2007, 2008, 2011 Carlos Garcia Campos <carlosgc@gnome.org>
-// Copyright 2007-2010, 2012, 2015-2019 Albert Astals Cid <aacid@kde.org>
+// Copyright 2007-2010, 2012, 2015-2020 Albert Astals Cid <aacid@kde.org>
// Copyright 2010 Mark Riedesel <mark@klowner.com>
// Copyright 2011 Pino Toscano <pino@kde.org>
// Copyright 2012 Fabio D'Urso <fabiodurso@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@kde.org>
- * Copyright (C) 2008, 2011, 2012, 2015-2019 Albert Astals Cid <aacid@kde.org>
+ * Copyright (C) 2008, 2011, 2012, 2015-2020 Albert Astals Cid <aacid@kde.org>
* Copyright (C) 2011 Carlos Garcia Campos <carlosgc@gnome.org>
* Copyright (C) 2012, Adam Reichold <adamreichold@myopera.com>
* Copyright (C) 2016, Hanno Meyer-Thurow <h.mth@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@kde.org>
- * Copyright (C) 2008, 2011, 2016, 2017, 2019, Albert Astals Cid <aacid@kde.org>
+ * Copyright (C) 2008, 2011, 2016, 2017, 2019, 2020, Albert Astals Cid <aacid@kde.org>
* Copyright (C) 2012, Adam Reichold <adamreichold@myopera.com>
* Copyright (C) 2016, Hanno Meyer-Thurow <h.mth@web.de>
* Copyright (C) 2017, Hans-Ulrich Jüttner <huj@froreich-bioscientia.de>
@@ -411,6 +411,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.