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 <[email protected]>
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 <[email protected]>
 // Copyright 2007, 2008, 2011 Carlos Garcia Campos <[email protected]>
-// Copyright 2007-2010, 2012, 2015-2019 Albert Astals Cid <[email protected]>
+// Copyright 2007-2010, 2012, 2015-2020 Albert Astals Cid <[email protected]>
 // Copyright 2010 Mark Riedesel <[email protected]>
 // Copyright 2011 Pino Toscano <[email protected]>
 // Copyright 2012 Fabio D'Urso <[email protected]>
@@ -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 <[email protected]>
- * Copyright (C) 2008, 2011, 2012, 2015-2019 Albert Astals Cid <[email protected]>
+ * Copyright (C) 2008, 2011, 2012, 2015-2020 Albert Astals Cid <[email protected]>
  * Copyright (C) 2011 Carlos Garcia Campos <[email protected]>
  * Copyright (C) 2012, Adam Reichold <[email protected]>
  * Copyright (C) 2016, Hanno Meyer-Thurow <[email protected]>
@@ -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 <[email protected]>
- * Copyright (C) 2008, 2011, 2016, 2017, 2019, Albert Astals Cid 
<[email protected]>
+ * Copyright (C) 2008, 2011, 2016, 2017, 2019, 2020, Albert Astals Cid 
<[email protected]>
  * Copyright (C) 2012, Adam Reichold <[email protected]>
  * Copyright (C) 2016, Hanno Meyer-Thurow <[email protected]>
  * Copyright (C) 2017, Hans-Ulrich Jüttner <[email protected]>
@@ -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.
_______________________________________________
poppler mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/poppler

Reply via email to