diff options
author | Paul Gardiner <paulg.artifex@glidos.net> | 2012-08-07 15:16:06 +0100 |
---|---|---|
committer | Paul Gardiner <paulg.artifex@glidos.net> | 2012-08-07 15:16:06 +0100 |
commit | 51661f29a5f229f30ae16e16bd0ef6396cd001af (patch) | |
tree | 6ac8485c474b3da23fcaaf81af52e3c9942c2dfc | |
parent | 2a8a6d46868b7a78cab1abc0ab4ef95ad9036914 (diff) | |
download | mupdf-51661f29a5f229f30ae16e16bd0ef6396cd001af.tar.xz |
Forms: simple appearance generation for choice widgets
-rw-r--r-- | pdf/pdf_form.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/pdf/pdf_form.c b/pdf/pdf_form.c index e77a5a02..10b70824 100644 --- a/pdf/pdf_form.c +++ b/pdf/pdf_form.c @@ -1232,6 +1232,56 @@ static void update_text_appearance(pdf_document *doc, pdf_obj *obj, char *eventV } } +static void update_combobox_appearance(pdf_document *doc, pdf_obj *obj) +{ + fz_context *ctx = doc->ctx; + text_widget_info info; + pdf_xobject *form = NULL; + fz_buffer *fzbuf = NULL; + fz_matrix tm; + fz_rect rect; + int has_tm; + pdf_obj *val; + char *text; + + memset(&info, 0, sizeof(info)); + + fz_var(info); + fz_var(form); + fz_var(fzbuf); + fz_try(ctx) + { + get_text_widget_info(doc, obj, &info); + + val = get_inheritable(doc, obj, "V"); + + if (pdf_is_array(val)) + val = pdf_array_get(val, 0); + + text = pdf_to_str_buf(val); + + if (!text) + text = ""; + + form = load_or_create_form(doc, obj, &rect); + + has_tm = get_matrix(doc, form, info.q, &tm); + fzbuf = create_text_appearance(doc, &form->bbox, has_tm ? &tm : NULL, &info, + text?text:""); + update_marked_content(doc, form, fzbuf); + } + fz_always(ctx) + { + pdf_drop_xobject(ctx, form); + fz_drop_buffer(ctx, fzbuf); + font_info_fin(ctx, &info.font_rec); + } + fz_catch(ctx) + { + fz_warn(ctx, "update_text_appearance failed"); + } +} + static void fzbuf_print_color(fz_context *ctx, fz_buffer *fzbuf, pdf_obj *arr, int stroke, float adj) { switch(pdf_array_len(arr)) @@ -1523,6 +1573,12 @@ void pdf_update_appearance(pdf_document *doc, pdf_obj *obj) case FZ_WIDGET_TYPE_PUSHBUTTON: update_pushbutton_appearance(doc, obj); break; + case FZ_WIDGET_TYPE_LISTBOX: + case FZ_WIDGET_TYPE_COMBOBOX: + /* Treating listbox and combobox identically for now, + * and the behaviour is most appropriate for a combobox */ + update_combobox_appearance(doc, obj); + break; } } |