summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gardiner <paulg.artifex@glidos.net>2012-08-09 15:12:05 +0100
committerPaul Gardiner <paulg.artifex@glidos.net>2012-08-10 10:07:26 +0100
commit2fba705a0b45b1192578de71c969f056a77bd789 (patch)
treebddcda375a486982bc1ba92157e77e43cc2d9171
parentbdcfc3fe13e819db0f29eebdb0e46c4aaa6a27b1 (diff)
downloadmupdf-2fba705a0b45b1192578de71c969f056a77bd789.tar.xz
Forms: move js-side event setup out of execute_action
Makes it easier to alter the setup for some action types
-rw-r--r--pdf/pdf_form.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/pdf/pdf_form.c b/pdf/pdf_form.c
index b505de25..68559ac8 100644
--- a/pdf/pdf_form.c
+++ b/pdf/pdf_form.c
@@ -1498,11 +1498,6 @@ static void execute_action(pdf_document *doc, pdf_obj *obj, pdf_obj *a)
char *code = pdf_to_utf8(doc, js);
fz_try(ctx)
{
- pdf_js_event e;
-
- e.target = obj;
- e.value = pdf_field_getValue(doc, obj);
- pdf_js_setup_event(doc->js, &e);
pdf_js_execute(doc->js, code);
}
fz_always(ctx)
@@ -1566,6 +1561,11 @@ void pdf_update_appearance(pdf_document *doc, pdf_obj *obj)
if (formatting)
{
/* Apply formatting */
+ pdf_js_event e;
+
+ e.target = obj;
+ e.value = pdf_field_getValue(doc, obj);
+ pdf_js_setup_event(doc->js, &e);
execute_action(doc, obj, formatting);
/* Update appearance from JS event.value */
update_text_appearance(doc, obj, pdf_js_get_event(doc->js)->value);
@@ -1875,6 +1875,11 @@ static void recalculate(pdf_document *doc)
if (calc)
{
+ pdf_js_event e;
+
+ e.target = field;
+ e.value = pdf_field_getValue(doc, field);
+ pdf_js_setup_event(doc->js, &e);
execute_action(doc, field, calc);
/* A calculate action, updates event.value. We need
* to place the value in the field */