diff options
author | Michael Vrhel <michael.vrhel@artifex.com> | 2015-10-12 11:35:56 -0700 |
---|---|---|
committer | Michael Vrhel <michael.vrhel@artifex.com> | 2015-10-14 08:02:10 -0700 |
commit | 74dac977aedf60e1fdd0ce4165828cf24c52c1d7 (patch) | |
tree | 8b91f4bc182baf79de51fc83bcbfc304068d52f1 /source/pdf/pdf-form.c | |
parent | a4e5c65145e5cbf2b89fd77e93acbc208b8a43a1 (diff) | |
download | mupdf-74dac977aedf60e1fdd0ce4165828cf24c52c1d7.tar.xz |
Add proper support for when a combobox widget has options that are 2-element arrays
The list box and combo box can have values that are 2-element arrays. The first element
is the "export" value and the second element is the value that should be shown
in the list box UI. This fix ensures that we get the proper value to show in the UI.
Also, it adds the option to get the export values. These are needed if you wish to
update the field dictionary's V (value) entry, which is the currently selected values(s).
This fix works well with gsview. The other viewers will now display the proper content
in their UI, (unlike before this fix) but may need a bit more work to ensure that the
proper V (value) is updated with changes in the selections. In addition, we add
selection rectangles to the selected list box items.
Diffstat (limited to 'source/pdf/pdf-form.c')
-rw-r--r-- | source/pdf/pdf-form.c | 19 |
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; } |