FieldScript.java
15.8 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
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xfa.template.containers;
import com.adobe.xfa.Arg;
import com.adobe.xfa.Node;
import com.adobe.xfa.Obj;
import com.adobe.xfa.ScriptFuncObj;
import com.adobe.xfa.ScriptPropObj;
import com.adobe.xfa.ScriptTable;
import com.adobe.xfa.data.DataNode;
import com.adobe.xfa.template.Items;
import com.adobe.xfa.template.containers.ContainerScript;
import com.adobe.xfa.template.containers.Field;
import com.adobe.xfa.template.containers.Subform;
import com.adobe.xfa.ut.StringUtils;
public class FieldScript
extends ContainerScript {
protected static final ScriptTable moScriptTable = new ScriptTable(ContainerScript.moScriptTable, "field", new ScriptPropObj[]{new ScriptPropObj(FieldScript.class, "rawValue", "getRawValue", "setRawValue", 0, 21, 63, 0), new ScriptPropObj(FieldScript.class, null, "getRawValue", "setRawValue", 0, 21, 9, 0), new ScriptPropObj(FieldScript.class, "formattedValue", "getFormattedValue", "setFormattedValue", 6, 21, 63, 0), new ScriptPropObj(FieldScript.class, "editValue", "getEditValue", "setEditValue", 6, 21, 63, 0), new ScriptPropObj(FieldScript.class, "isNull", "getIsNull", "setIsNull", 3, 21, 63, 0), new ScriptPropObj(FieldScript.class, "mandatory", "getMandatory", "setMandatory", 6, 21, 63, 0), new ScriptPropObj(FieldScript.class, "message", "getValidationMessage", "setValidationMessage", 6, 21, 0, 22), new ScriptPropObj(FieldScript.class, "validationMessage", "getValidationMessage", "setValidationMessage", 6, 21, 63, 0), new ScriptPropObj(FieldScript.class, "mandatoryMessage", "getMandatoryMessage", "setMandatoryMessage", 6, 21, 63, 0), new ScriptPropObj(FieldScript.class, "formatMessage", "getFormatMessage", "setFormatMessage", 6, 21, 63, 0), new ScriptPropObj(FieldScript.class, "foreColor", "getForeColor", "setForeColor", 6, 21, 0, 22), new ScriptPropObj(FieldScript.class, "fontColor", "getForeColor", "setForeColor", 6, 21, 63, 0), new ScriptPropObj(FieldScript.class, "backColor", "getBackColor", "setBackColor", 6, 21, 0, 22), new ScriptPropObj(FieldScript.class, "fillColor", "getBackColor", "setBackColor", 6, 21, 63, 0), new ScriptPropObj(FieldScript.class, "borderColor", "getBorderColor", "setBorderColor", 6, 21, 63, 0), new ScriptPropObj(FieldScript.class, "borderWidth", "getBorderWidth", "setBorderWidth", 6, 21, 63, 0), new ScriptPropObj(FieldScript.class, "parentSubform", "getParentSubform", null, 7, 21, 63, 0), new ScriptPropObj(FieldScript.class, "dataNode", "dataNode", null, 7, 21, 9, 0), new ScriptPropObj(FieldScript.class, "length", "getItemsLength", null, 4, 25, 63, 0), new ScriptPropObj(FieldScript.class, "selectedIndex", "getSelectedIndex", "setSelectedIndex", 4, 25, 63, 0), new ScriptPropObj(FieldScript.class, "errorText", "getErrorText", null, 6, 30, 63, 0)}, new ScriptFuncObj[]{new ScriptFuncObj(FieldScript.class, "addItem", "addItem", 1, new int[]{6, 6}, 1, 21, 63, "addItemPermsCheck", 0), new ScriptFuncObj(FieldScript.class, "setItems", "setItems", 3, new int[]{6, 4}, 1, 28, 63, "clearItemsPermsCheck", 0), new ScriptFuncObj(FieldScript.class, "clearItems", "clearItems", 1, new int[0], 0, 21, 63, "clearItemsPermsCheck", 0), new ScriptFuncObj(FieldScript.class, "deleteItem", "deleteItem", 3, new int[]{4}, 1, 25, 63, "deleteItemPermsCheck", 0), new ScriptFuncObj(FieldScript.class, "boundItem", "boundItem", 6, new int[]{6}, 1, 21, 63, 0), new ScriptFuncObj(FieldScript.class, "execCalculate", "execCalculate", 1, new int[0], 0, 21, 63, 0), new ScriptFuncObj(FieldScript.class, "execValidate", "execValidate", 3, new int[0], 0, 21, 63, 0), new ScriptFuncObj(FieldScript.class, "execInitialize", "execInitialize", 1, new int[0], 0, 21, 63, 0), new ScriptFuncObj(FieldScript.class, "execEvent", "execEvent", 1, new int[]{6}, 1, 21, 63, 0), new ScriptFuncObj(FieldScript.class, "getItemState", "getItemState", 3, new int[]{4}, 1, 25, 63, 0), new ScriptFuncObj(FieldScript.class, "setItemState", "setItemState", 1, new int[]{4, 3}, 2, 25, 63, "setItemStatePermsCheck", 0), new ScriptFuncObj(FieldScript.class, "getDisplayItem", "getDisplayItem", 6, new int[]{4}, 1, 25, 63, 0), new ScriptFuncObj(FieldScript.class, "getSaveItem", "getSaveItem", 6, new int[]{4}, 1, 25, 63, 0)});
private static final String sSkipSet = "\\,";
public static ScriptTable getScriptTable() {
return moScriptTable;
}
public static void getRawValue(Obj pObj, Arg oRetVal) {
if (!((Field)pObj).getIsNull()) {
((Field)pObj).getTypedRawValue(oRetVal);
} else {
oRetVal.setNull();
}
}
public static void setRawValue(Obj pObj, Arg propertyValue) {
String sValue = null;
if (propertyValue.getArgType() != 2) {
sValue = propertyValue.getAsString(false);
}
((Field)pObj).setRawValue(sValue);
}
public static void getFormattedValue(Obj pObj, Arg oRetVal) {
oRetVal.setString(((Field)pObj).getFormattedValue());
}
public static void setFormattedValue(Obj pObj, Arg propertyValue) {
String sValue = null;
if (propertyValue.getArgType() != 2) {
sValue = propertyValue.getAsString(false);
}
((Field)pObj).setFormattedValue(sValue);
}
public static void getEditValue(Obj pObj, Arg oRetVal) {
oRetVal.setString(((Field)pObj).getEditValue());
}
public static void setEditValue(Obj pObj, Arg propertyValue) {
String sValue = null;
if (propertyValue.getArgType() != 2) {
sValue = propertyValue.getAsString(false);
}
((Field)pObj).setEditValue(sValue);
}
public static void getMandatory(Obj pObj, Arg oRetVal) {
oRetVal.setString(((Field)pObj).getMandatory());
}
public static void setMandatory(Obj pObj, Arg propertyValue) {
((Field)pObj).setMandatory(propertyValue.getString());
}
public static void getValidationMessage(Obj pObj, Arg oRetVal) {
oRetVal.setString(((Field)pObj).getMessage("scriptTest"));
}
public static void setValidationMessage(Obj pObj, Arg propertyValue) {
((Field)pObj).setMessage(propertyValue.getString(), "scriptTest");
}
public static void getMandatoryMessage(Obj pObj, Arg oRetVal) {
oRetVal.setString(((Field)pObj).getMessage("nullTest"));
}
public static void setMandatoryMessage(Obj pObj, Arg propertyValue) {
((Field)pObj).setMessage(propertyValue.getString(), "nullTest");
}
public static void getFormatMessage(Obj pObj, Arg oRetVal) {
oRetVal.setString(((Field)pObj).getMessage("formatTest"));
}
public static void setFormatMessage(Obj pObj, Arg propertyValue) {
((Field)pObj).setMessage(propertyValue.getString(), "formatTest");
}
public static void getForeColor(Obj pObj, Arg oRetVal) {
oRetVal.setString(((Field)pObj).getForeColor());
}
public static void setForeColor(Obj pObj, Arg propertyValue) {
((Field)pObj).setForeColor(propertyValue.getString());
}
public static void getBackColor(Obj pObj, Arg oRetVal) {
oRetVal.setString(((Field)pObj).getBackColor());
}
public static void setBackColor(Obj pObj, Arg propertyValue) {
((Field)pObj).setBackColor(propertyValue.getString());
}
public static void getBorderColor(Obj pObj, Arg oRetVal) {
oRetVal.setString(((Field)pObj).getBorderColor());
}
public static void setBorderColor(Obj pObj, Arg propertyValue) {
((Field)pObj).setBorderColor(propertyValue.getString());
}
public static void getBorderWidth(Obj pObj, Arg oRetVal) {
oRetVal.setString(((Field)pObj).getBorderWidth());
}
public static void setBorderWidth(Obj pObj, Arg propertyValue) {
((Field)pObj).setBorderWidth(propertyValue.getString());
}
public static void getParentSubform(Obj pObj, Arg oRetVal) {
oRetVal.setObject(((Field)pObj).getParentSubform());
}
public static void getIsNull(Obj pObj, Arg oRetVal) {
oRetVal.setBool(((Field)pObj).getIsNull());
}
public static void setIsNull(Obj pObj, Arg oArg) {
((Field)pObj).setIsNull(oArg.getBool(), true);
}
public static void dataNode(Obj pObj, Arg oRetVal) {
oRetVal.setObject(((Field)pObj).getDataNode());
}
public static void getItemsLength(Obj pObj, Arg oRetVal) {
oRetVal.setInteger(((Field)pObj).getItemsLength());
}
public static void getErrorText(Obj pObj, Arg oRetVal) {
oRetVal.setString(((Field)pObj).getErrorText());
}
public static void getSelectedIndex(Obj pObj, Arg oRetVal) {
oRetVal.setInteger(((Field)pObj).getSelectedIndex());
}
public static void setSelectedIndex(Obj pObj, Arg oArg) {
((Field)pObj).setSelectedIndex(oArg.getInteger());
}
public static boolean addItemPermsCheck(Obj obj, Arg[] args) {
Node node;
if (obj instanceof Node && !(node = (Node)obj).checkAncestorPerms()) {
return false;
}
return true;
}
public static boolean clearItemsPermsCheck(Obj obj, Arg[] args) {
if (obj instanceof Field) {
Field field = (Field)obj;
if (!field.checkAncestorPerms()) {
return false;
}
Field.ItemPair items = new Field.ItemPair();
field.getItemLists(false, items, false);
if (items.mSaveItems != null && !items.mSaveItems.checkDescendentPerms()) {
return false;
}
if (items.mDisplayItems != null && !items.mDisplayItems.checkDescendentPerms()) {
return false;
}
}
return true;
}
public static boolean deleteItemPermsCheck(Obj obj, Arg[] args) {
Node node;
if (obj instanceof Node && !(node = (Node)obj).checkAncestorPerms()) {
return false;
}
return true;
}
public static boolean setItemStatePermsCheck(Obj obj, Arg[] args) {
Node node;
if (obj instanceof Node && !(node = (Node)obj).checkAncestorPerms()) {
return false;
}
return true;
}
public static void addItem(Obj pObj, Arg oRetVal, Arg[] pArgs) {
String sDisplayVal = null;
String sSaveVal = null;
Field.ItemPair items = new Field.ItemPair();
if (pArgs.length == 1) {
((Field)pObj).getItemLists(false, items, false);
sSaveVal = sDisplayVal = pArgs[0].getAsString(false);
} else if (pArgs.length == 2) {
((Field)pObj).getItemLists(false, items, true);
sDisplayVal = pArgs[0].getAsString(false);
sSaveVal = pArgs[1].getAsString(false);
}
Items oSaveItems = items.mSaveItems;
Items oDisplayItems = items.mDisplayItems;
if (oDisplayItems != null) {
oDisplayItems.addItem(sDisplayVal, false);
}
if (oSaveItems != null && oSaveItems != oDisplayItems) {
oSaveItems.addItem(sSaveVal, false);
}
}
public static void clearItems(Obj pObj, Arg oRetVal, Arg[] pArgs) {
((Field)pObj).clearItems();
}
public static void setItems(Obj pObj, Arg oRetVal, Arg[] pArgs) {
String sDisplayVal = "";
int numColumns = 1;
((Field)pObj).clearItems();
String sItemValueList = pArgs[0].getAsString(false);
StringBuilder sToken = new StringBuilder();
if (pArgs.length == 2) {
numColumns = pArgs[1].getInteger();
}
if (numColumns > 2) {
oRetVal.setBool(false);
return;
}
boolean bMultiColumn = numColumns > 1;
int len = sItemValueList.length();
int nPrevEndToken = 0;
int numDisplayItems = 0;
int numSaveValues = 0;
Field.ItemPair itemPair = new Field.ItemPair();
((Field)pObj).getItemLists(false, itemPair, bMultiColumn);
Items oDisplayItems = itemPair.mDisplayItems;
Items oSaveItems = itemPair.mSaveItems;
int nBeginToken = 0;
while (nBeginToken < len) {
String sSaveVal;
int col = 0;
int nTokenLen = 0;
for (col = 0; col < numColumns - 1; ++col) {
nTokenLen = StringUtils.skipUntil(sItemValueList, "\\,", nBeginToken);
sToken.setLength(0);
sToken.append(sItemValueList.substring(nBeginToken, nTokenLen));
nPrevEndToken = nBeginToken + nTokenLen;
nBeginToken = nPrevEndToken + 1;
while (sItemValueList.charAt(nPrevEndToken) == '\\') {
sToken.append(sItemValueList.charAt(nBeginToken));
nTokenLen = StringUtils.skipUntil(sItemValueList, "\\,", nBeginToken);
sToken.append(sItemValueList.substring(nBeginToken, nTokenLen));
nPrevEndToken = nBeginToken + nTokenLen;
nBeginToken = nPrevEndToken + 1;
}
sDisplayVal = sToken.toString();
++numDisplayItems;
if (oDisplayItems == null) continue;
oDisplayItems.addItem(sDisplayVal, false);
}
if (nBeginToken <= len) {
nTokenLen = StringUtils.skipUntil(sItemValueList, "\\,", nBeginToken);
sToken.setLength(0);
sToken.append(sItemValueList.substring(nBeginToken, nTokenLen));
nPrevEndToken = nBeginToken + nTokenLen;
nBeginToken = nPrevEndToken + 1;
while (sItemValueList.charAt(nPrevEndToken) == '\\') {
sToken.append(sItemValueList.charAt(nBeginToken));
nTokenLen = StringUtils.skipUntil(sItemValueList, "\\,", nBeginToken);
sToken.append(sItemValueList.substring(nBeginToken, nTokenLen));
nPrevEndToken = nBeginToken + nTokenLen;
nBeginToken = nPrevEndToken + 1;
}
++numSaveValues;
}
if ((sSaveVal = sToken.toString()).length() == 0) {
sSaveVal = sDisplayVal;
}
if (!bMultiColumn && oDisplayItems != null) {
oDisplayItems.addItem(sSaveVal, false);
}
if (oSaveItems == null || oSaveItems == oDisplayItems) continue;
oSaveItems.addItem(sSaveVal, false);
}
oRetVal.setBool(true);
if (bMultiColumn && numDisplayItems != (numColumns - 1) * numSaveValues) {
oRetVal.setBool(true);
}
}
public static void deleteItem(Obj pObj, Arg oRetVal, Arg[] pArgs) {
oRetVal.setBool(((Field)pObj).deleteItem(pArgs[0].getInteger()));
}
public static void execCalculate(Obj pObj, Arg oRetVal, Arg[] pArgs) {
((Field)pObj).execEvent("calculate");
}
public static void execValidate(Obj pObj, Arg oRetVal, Arg[] pArgs) {
oRetVal.setBool(((Field)pObj).execValidate());
}
public static void execInitialize(Obj pObj, Arg oRetVal, Arg[] pArgs) {
((Field)pObj).execEvent("initialize");
}
public static void execEvent(Obj pObj, Arg oRetVal, Arg[] pArgs) {
((Field)pObj).execEvent(pArgs[0].getString());
}
public static void boundItem(Obj pObj, Arg oRetVal, Arg[] pArgs) {
oRetVal.setString(((Field)pObj).getBoundItem(pArgs[0].getString()));
}
public static void getItemState(Obj pObj, Arg oRetVal, Arg[] pArgs) {
oRetVal.setBool(((Field)pObj).getItemState(pArgs[0].getInteger()));
}
public static void setItemState(Obj pObj, Arg oRetVal, Arg[] pArgs) {
((Field)pObj).setItemState(pArgs[0].getInteger(), pArgs[1].getBool());
}
public static void getDisplayItem(Obj pObj, Arg oRetVal, Arg[] pArgs) {
oRetVal.setString(((Field)pObj).getDisplayItem(pArgs[0].getInteger()));
}
public static void getSaveItem(Obj pObj, Arg oRetVal, Arg[] pArgs) {
oRetVal.setString(((Field)pObj).getBoundItem(pArgs[0].getInteger()));
}
}