diff options
author | Paul Gardiner <paul@glidos.net> | 2012-07-02 16:50:08 +0100 |
---|---|---|
committer | Paul Gardiner <paul@glidos.net> | 2012-07-02 16:50:08 +0100 |
commit | a5ae50d9b3e6f4d05d487076fcd5d63117fd8314 (patch) | |
tree | 257578f3cae03e86aaf4226bc89c75932de507c0 /pdf/pdf_form.c | |
parent | e886d5cf1e3e97f9c3ec9da540c2416e12c0eb50 (diff) | |
download | mupdf-a5ae50d9b3e6f4d05d487076fcd5d63117fd8314.tar.xz |
Form: implement calculation action and javascrip AFSimple_Calculate
Diffstat (limited to 'pdf/pdf_form.c')
-rw-r--r-- | pdf/pdf_form.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/pdf/pdf_form.c b/pdf/pdf_form.c index 65f9392f..3d14208f 100644 --- a/pdf/pdf_form.c +++ b/pdf/pdf_form.c @@ -1743,9 +1743,35 @@ char *pdf_field_getValue(pdf_document *doc, pdf_obj *field) return get_string_or_stream(doc, get_inheritable(doc, field, "V")); } +static void recalculate(pdf_document *doc) +{ + pdf_obj *co = pdf_dict_getp(doc->trailer, "Root/AcroForm/CO"); + + if (co) + { + int i, n = pdf_array_len(co); + + for (i = 0; i < n; i++) + { + pdf_obj *field = pdf_array_get(co, i); + pdf_obj *calc = pdf_dict_getp(field, "AA/C"); + + if (calc) + { + execute_action(doc, field, calc); + /* A calculate action, updates event.value. We need + * to place the value in the field */ + update_text_field_value(doc->ctx, field, pdf_js_getEventValue(doc->js)); + pdf_field_mark_dirty(doc->ctx, field); + } + } + } +} + void pdf_field_setValue(pdf_document *doc, pdf_obj *field, char *text) { update_text_field_value(doc->ctx, field, text); + recalculate(doc); pdf_field_mark_dirty(doc->ctx, field); } |