summaryrefslogtreecommitdiff
path: root/source/pdf/pdf-form.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/pdf/pdf-form.c')
-rw-r--r--source/pdf/pdf-form.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/source/pdf/pdf-form.c b/source/pdf/pdf-form.c
index dcb08bc7..ce51ae4f 100644
--- a/source/pdf/pdf-form.c
+++ b/source/pdf/pdf-form.c
@@ -1276,26 +1276,35 @@ int pdf_text_widget_set_text(fz_context *ctx, pdf_document *doc, pdf_widget *tw,
return accepted;
}
-int pdf_choice_widget_options(fz_context *ctx, pdf_document *doc, pdf_widget *tw, char *opts[])
+/* Get either the listed value or the export value. */
+int pdf_choice_widget_options(fz_context *ctx, pdf_document *doc, pdf_widget *tw, int exportval, char *opts[])
{
pdf_annot *annot = (pdf_annot *)tw;
pdf_obj *optarr;
- int i, n;
+ int i, n, m;
if (!annot)
return 0;
optarr = pdf_dict_get(ctx, annot->obj, PDF_NAME_Opt);
n = pdf_array_len(ctx, optarr);
-
+
if (opts)
{
for (i = 0; i < n; i++)
{
- opts[i] = pdf_to_str_buf(ctx, pdf_array_get(ctx, optarr, i));
+ m = pdf_array_len(ctx, pdf_array_get(ctx, optarr, i));
+ /* If it is a two element array, the second item is the one that we want
+ if we want the listing value */
+ if (m == 2)
+ if (exportval)
+ opts[i] = pdf_to_str_buf(ctx, pdf_array_get(ctx, pdf_array_get(ctx, optarr, i), 0));
+ else
+ opts[i] = pdf_to_str_buf(ctx, pdf_array_get(ctx, pdf_array_get(ctx, optarr, i), 1));
+ else
+ opts[i] = pdf_to_str_buf(ctx, pdf_array_get(ctx, optarr, i));
}
}
-
return n;
}