summaryrefslogtreecommitdiff
path: root/pdf/pdf_js.c
diff options
context:
space:
mode:
authorPaul Gardiner <paulg.artifex@glidos.net>2012-08-10 10:09:34 +0100
committerPaul Gardiner <paulg.artifex@glidos.net>2012-08-10 10:09:34 +0100
commit465ddf7b0e7e9ffb8345117dc19fbd9576ad73ff (patch)
treeb692d3e4632b5464d0a7b2b90f3444a968939eea /pdf/pdf_js.c
parent2fba705a0b45b1192578de71c969f056a77bd789 (diff)
downloadmupdf-465ddf7b0e7e9ffb8345117dc19fbd9576ad73ff.tar.xz
Forms: handle Keystroke and Validate actions
Diffstat (limited to 'pdf/pdf_js.c')
-rw-r--r--pdf/pdf_js.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/pdf/pdf_js.c b/pdf/pdf_js.c
index 953d7965..2b2d479b 100644
--- a/pdf/pdf_js.c
+++ b/pdf/pdf_js.c
@@ -154,9 +154,8 @@ static void field_setValue(void *jsctx, void *obj, pdf_jsimp_obj *val)
static pdf_jsimp_obj *event_getTarget(void *jsctx, void *obj)
{
pdf_js *js = (pdf_js *)jsctx;
- pdf_js_event *e = (pdf_js_event *)obj;
- return pdf_jsimp_new_obj(js->imp, js->fieldtype, e->target);
+ return pdf_jsimp_new_obj(js->imp, js->fieldtype, js->event.target);
}
static void event_setTarget(void *jsctx, void *obj, pdf_jsimp_obj *val)
@@ -168,7 +167,6 @@ static void event_setTarget(void *jsctx, void *obj, pdf_jsimp_obj *val)
static pdf_jsimp_obj *event_getValue(void *jsctx, void *obj)
{
pdf_js *js = (pdf_js *)jsctx;
- pdf_js_event *e = (pdf_js_event *)obj;
char *v = js->event.value;
return pdf_jsimp_fromString(js->imp, v?v:"");
@@ -183,6 +181,33 @@ static void event_setValue(void *jsctx, void *obj, pdf_jsimp_obj *val)
js->event.value = fz_strdup(ctx, pdf_jsimp_toString(js->imp, val));
}
+static pdf_jsimp_obj *event_getWillCommit(void *jsctx, void *obj)
+{
+ pdf_js *js = (pdf_js *)jsctx;
+
+ return pdf_jsimp_fromNumber(js->imp, 1.0);
+}
+
+static void event_setWillCommit(void *jsctx, void *obj, pdf_jsimp_obj *val)
+{
+ pdf_js *js = (pdf_js *)jsctx;
+ fz_warn(js->doc->ctx, "Unexpected call to event_setWillCommit");
+}
+
+static pdf_jsimp_obj *event_getRC(void *jsctx, void *obj)
+{
+ pdf_js *js = (pdf_js *)jsctx;
+
+ return pdf_jsimp_fromNumber(js->imp, (double)js->event.rc);
+}
+
+static void event_setRC(void *jsctx, void *obj, pdf_jsimp_obj *val)
+{
+ pdf_js *js = (pdf_js *)jsctx;
+
+ js->event.rc = (int)pdf_jsimp_toNumber(js->imp, val);
+}
+
static pdf_jsimp_obj *doc_getEvent(void *jsctx, void *obj)
{
pdf_js *js = (pdf_js *)jsctx;
@@ -258,6 +283,8 @@ static void declare_dom(pdf_js *js)
js->eventtype = pdf_jsimp_new_type(imp, NULL);
pdf_jsimp_addproperty(imp, js->eventtype, "target", event_getTarget, event_setTarget);
pdf_jsimp_addproperty(imp, js->eventtype, "value", event_getValue, event_setValue);
+ pdf_jsimp_addproperty(imp, js->eventtype, "willCommit", event_getWillCommit, event_setWillCommit);
+ pdf_jsimp_addproperty(imp, js->eventtype, "rc", event_getRC, event_setRC);
/* Create the field type */
js->fieldtype = pdf_jsimp_new_type(imp, NULL);
@@ -384,6 +411,8 @@ void pdf_js_setup_event(pdf_js *js, pdf_js_event *e)
js->event.value = NULL;
js->event.value = fz_strdup(ctx, e->value);
}
+
+ js->event.rc = 1;
}
}