ScriptHandler.java
10.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xfa;
import com.adobe.xfa.*;
import com.adobe.xfa.scripthandler.formcalc.FormCalcScriptHandler;
import com.adobe.xfa.scripthandler.rhino.RhinoScriptHandler;
import com.adobe.xfa.ut.ExFull;
import com.adobe.xfa.ut.MsgFormat;
import com.adobe.xfa.ut.MsgFormatPos;
import com.adobe.xfa.ut.ResId;
import java.util.List;
public abstract class ScriptHandler {
public static final int UNSPECIFIED = 0;
public static final int CALCULATE = 1;
public static final int VALIDATE = 2;
public static final int ACTIVITY_INITIALIZE = 3;
public static final int ACTIVITY_PRESAVE = 4;
public static final int ACTIVITY_POSTSAVE = 5;
public static final int ACTIVITY_PREPRINT = 6;
public static final int ACTIVITY_POSTPRINT = 7;
public static final int ACTIVITY_READY = 8;
public static final int ACTIVITY_DOCREADY = 9;
public static final int ACTIVITY_DOCCLOSE = 10;
public static final int ACTIVITY_PRESUBMIT = 11;
public static final int ACTIVITY_PREEXECUTE = 12;
public static final int ACTIVITY_POSTEXECUTE = 13;
public static final int ACTIVITY_PREOPEN = 14;
public static final int ACTIVITY_INDEXCHANGE = 15;
public static final int PREDICATE = 16;
public static final int ACTIVITY_PRESIGN = 17;
public static final int ACTIVITY_POSTSIGN = 18;
public static final int ACTIVITY_POSTSUBMIT = 19;
public static final int ACTIVITY_POSTOPEN = 20;
public static final int ACTIVITY_VALIDATIONSTATE = 21;
public static final int ObjectInteraction_Start = 22;
public static final int ACTIVITY_ENTER = 23;
public static final int ACTIVITY_EXIT = 24;
public static final int ACTIVITY_MOUSEENTER = 25;
public static final int ACTIVITY_MOUSEEXIT = 26;
public static final int ACTIVITY_CHANGE = 27;
public static final int ACTIVITY_CLICK = 28;
public static final int ACTIVITY_FULL = 29;
public static final int ACTIVITY_MOUSEUP = 30;
public static final int ACTIVITY_MOUSEDOWN = 31;
public static final int ObjectInteraction_End = 32;
public static final int executeReason_LAST = 33;
public static final int ERR_OK = 0;
public static final int ERR_Syntax = 8;
public static final int ERR_BadBreakContinue = 10;
public static final int ERR_FuncBuiltIn = 100;
public static final int ERR_FuncUnknown = 101;
public static final int STEP_OVER = 0;
public static final int STEP_INTO = 1;
public static final int STEP_OUT = 2;
public static final int BREAK = 3;
public static final int HALT = 4;
public static final int BP_SET = 0;
public static final int BP_CLEAR = 1;
public static final int FEATURE_NONE = 0;
public static final int FEATURE_IS_REMOTE = 1;
public static final int FEATURE_CAN_SET_BREAKPOINT = 2;
public static final int FEATURE_CAN_STEP_OVER = 4;
public static final int FEATURE_CAN_STEP_INTO = 8;
public static final int FEATURE_CAN_STEP_OUT = 16;
public static final int FEATURE_CAN_BREAK = 32;
public static final int FEATURE_CAN_HALT = 64;
ScriptDebugger moDebugger;
public ScriptHandler() {
this(null);
}
public ScriptHandler(ScriptDebugger oDebugger) {
this.moDebugger = oDebugger;
if (this.moDebugger != null) {
this.moDebugger.private_attach(this);
}
}
public static ScriptHandler createScriptHandler(String contentType, AppModel appModel, ScriptDebugger debugger) {
if (contentType.length() == 0) {
contentType = "formcalc";
} else if (contentType.startsWith("application/x-")) {
contentType = contentType.substring("application/x-".length());
}
if (contentType.equals("formcalc")) {
return new FormCalcScriptHandler(appModel, debugger);
}
if (contentType.equals("javascript")) {
return new RhinoScriptHandler(appModel, debugger);
}
MsgFormatPos msg = new MsgFormatPos(ResId.UnknownScriptLanguageException);
msg.format(contentType);
msg.format("");
throw new ExFull(msg);
}
public void setDebugger(ScriptDebugger oDebugger) {
if (this.moDebugger != null) {
this.moDebugger.private_detach(this);
assert (this.moDebugger == null);
}
this.moDebugger = oDebugger;
if (this.moDebugger != null) {
this.moDebugger.private_attach(this);
}
}
public abstract void executeOrSyntaxCheck(String var1, Arg var2, int var3, boolean var4, String var5);
public void execute(String script, String locale, Arg returnValue, int eReason) {
this.executeOrSyntaxCheck(script, returnValue, eReason, false, locale);
}
public void syntaxCheck(String script) {
this.executeOrSyntaxCheck(script, new Arg(), 0, true, null);
}
protected void clearExecutionContexts() {
}
public abstract String languageName();
public void setOption(String sOptionName, String sOptionValue) {
}
public String getOption(String sOptionName) {
return "";
}
public boolean wasFatalError() {
return true;
}
public abstract ScriptHandler clone();
public static int stringToExecuteReason(String sReason) {
if (sReason.equals("calculate")) {
return 1;
}
if (sReason.equals("validate")) {
return 2;
}
if (sReason.equals("predicate")) {
return 16;
}
EnumAttr oEnum = EnumAttr.getEnum(EnumType.ACTIVITY_TYPE, sReason.intern());
switch (oEnum.getInt()) {
case 4915200: {
return 3;
}
case 4915201: {
return 23;
}
case 4915202: {
return 24;
}
case 4915203: {
return 25;
}
case 4915204: {
return 26;
}
case 4915205: {
return 27;
}
case 4915206: {
return 28;
}
case 4915207: {
return 4;
}
case 4915208: {
return 5;
}
case 4915209: {
return 6;
}
case 4915210: {
return 7;
}
case 4915211: {
return 8;
}
case 4915216: {
return 29;
}
case 4915214: {
return 30;
}
case 4915215: {
return 31;
}
case 4915212: {
return 9;
}
case 4915213: {
return 10;
}
case 4915217: {
return 11;
}
case 4915218: {
return 12;
}
case 4915219: {
return 13;
}
case 4915220: {
return 14;
}
case 4915221: {
return 15;
}
case 4915222: {
return 17;
}
case 4915223: {
return 18;
}
case 4915224: {
return 19;
}
case 4915225: {
return 20;
}
case 4915226: {
return 21;
}
}
return 0;
}
public static String executeReasonToString(int eReason) {
if (eReason == 1) {
return "calculate";
}
if (eReason == 2) {
return "validate";
}
if (eReason == 16) {
return "predicate";
}
int oEnum = ScriptHandler.executeReasonToXFAEnum(eReason);
if (oEnum == 0) {
return "other";
}
return EnumAttr.getString(oEnum);
}
public static int executeReasonToXFAEnum(int eReason) {
switch (eReason) {
case 3: {
return 4915200;
}
case 23: {
return 4915201;
}
case 24: {
return 4915202;
}
case 25: {
return 4915203;
}
case 26: {
return 4915204;
}
case 27: {
return 4915205;
}
case 28: {
return 4915206;
}
case 4: {
return 4915207;
}
case 5: {
return 4915208;
}
case 6: {
return 4915209;
}
case 7: {
return 4915210;
}
case 8: {
return 4915211;
}
case 30: {
return 4915214;
}
case 31: {
return 4915215;
}
case 9: {
return 4915212;
}
case 10: {
return 4915213;
}
case 29: {
return 4915216;
}
case 11: {
return 4915217;
}
case 12: {
return 4915218;
}
case 13: {
return 4915219;
}
case 14: {
return 4915220;
}
case 15: {
return 4915221;
}
case 17: {
return 4915222;
}
case 18: {
return 4915223;
}
case 19: {
return 4915224;
}
case 20: {
return 4915225;
}
case 21: {
return 4915226;
}
}
return 0;
}
public ScriptDebugger getDebugger() {
return this.moDebugger;
}
public boolean debugCommand(int eCmd) {
return false;
}
public boolean debugBreakPoint(int nScriptID, int nLine, int eSetType) {
return false;
}
public boolean debugGetStack(List<String> oStack) {
return false;
}
public boolean debugGetVariables(List<String> oVarNames, List<Arg> oVarValues) {
return false;
}
protected int debugFeatures() {
return 0;
}
public void removeReference(Node oNode) {
}
public static class ScriptException
extends ExFull {
static final long serialVersionUID = 132047461644242605L;
private final int mnLineNumber;
private final int mnErrorCode;
public ScriptException(MsgFormat oFormat, int nLineNumber, int nErrorCode) {
super(oFormat);
this.mnLineNumber = nLineNumber;
this.mnErrorCode = nErrorCode;
}
public int getLineNumber() {
return this.mnLineNumber;
}
public int getErrorCode() {
return this.mnErrorCode;
}
}
}