diff options
author | Paul Gardiner <paul@glidos.net> | 2012-04-06 14:51:29 +0100 |
---|---|---|
committer | Paul Gardiner <paul@glidos.net> | 2012-05-08 15:07:12 +0100 |
commit | c51bde81f837da868bde3d5395c9f44ee8c179b3 (patch) | |
tree | 3325fdc303e3978aa1e58495cb409a37f8b7b63b /pdf/pdf_form.c | |
parent | 4a908c019f65ec3b5e50a916e3d209c6ad8ed23c (diff) | |
download | mupdf-c51bde81f837da868bde3d5395c9f44ee8c179b3.tar.xz |
Forms: update field value on text entry
Diffstat (limited to 'pdf/pdf_form.c')
-rw-r--r-- | pdf/pdf_form.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/pdf/pdf_form.c b/pdf/pdf_form.c index d5d7be72..a116e53e 100644 --- a/pdf/pdf_form.c +++ b/pdf/pdf_form.c @@ -348,6 +348,30 @@ static void update_text_appearance(pdf_document *doc, pdf_obj *obj, char *text) } } +static void update_text_field_value(fz_context *ctx, pdf_obj *obj, char *text) +{ + pdf_obj *parent = pdf_dict_gets(obj, "Parent"); + pdf_obj *sobj = NULL; + + if (parent) + obj = parent; + + fz_var(sobj); + fz_try(ctx) + { + sobj = pdf_new_string(ctx, text, strlen(text)); + pdf_dict_puts(obj, "V", sobj); + } + fz_always(ctx) + { + pdf_drop_obj(sobj); + } + fz_catch(ctx) + { + fz_rethrow(ctx); + } +} + static void synthesize_text_widget(pdf_document *doc, pdf_obj *obj) { fz_context *ctx = doc->ctx; @@ -592,6 +616,7 @@ void fz_widget_text_set_text(fz_widget_text *tw, char *text) fz_try(ctx) { update_text_appearance(tw->super.doc, tw->super.obj, text); + update_text_field_value(tw->super.doc->ctx, tw->super.obj, text); fz_free(ctx, tw->text); tw->text = fz_strdup(ctx, text); } |