Commit 5c601c40 authored by Albert Astals Cid's avatar Albert Astals Cid

qt5: Add option to get choice for export value

parent 4813adfa
......@@ -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();
......
......@@ -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);
......
/* 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);
......
/* 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>
......@@ -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.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment