AppModel.java
30.5 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
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xfa;
import com.adobe.xfa.*;
import com.adobe.xfa.form.FormModel;
import com.adobe.xfa.service.storage.PacketHandler;
import com.adobe.xfa.template.TemplateModel;
import com.adobe.xfa.ut.ExFull;
import com.adobe.xfa.ut.MsgFormat;
import com.adobe.xfa.ut.ResId;
import com.adobe.xfa.ut.StringUtils;
import org.xml.sax.Attributes;
import java.util.*;
public final class AppModel
extends Model
implements Model.DualDomModel {
public static final LegacyMask XFA_LEGACY_POSITIONING = new LegacyMask(1);
public static final LegacyMask XFA_LEGACY_EVENTMODEL = new LegacyMask(2);
public static final LegacyMask XFA_LEGACY_PLUSPRINT = new LegacyMask(4);
public static final LegacyMask XFA_LEGACY_PERMISSIONS = new LegacyMask(8);
public static final LegacyMask XFA_LEGACY_CALCOVERRIDE = new LegacyMask(16);
public static final LegacyMask XFA_LEGACY_RENDERING = new LegacyMask(32);
public static final LegacyMask XFA_LEGACY_V26_HIDDENPOSITIONED = new LegacyMask(64);
public static final LegacyMask XFA_LEGACY_V27_MULTIRECORDCONTEXTCACHE = new LegacyMask(128);
public static final LegacyMask XFA_LEGACY_V27_LAYOUT = new LegacyMask(256);
public static final LegacyMask XFA_LEGACY_V27_SCRIPTING = new LegacyMask(512);
public static final LegacyMask XFA_LEGACY_V27_EVENTMODEL = new LegacyMask(1024);
public static final LegacyMask XFA_LEGACY_V27_TRAVERSALORDER = new LegacyMask(2048);
public static final LegacyMask XFA_LEGACY_V27_XHTMLVERSIONPROCESSING = new LegacyMask(4096);
public static final LegacyMask XFA_LEGACY_V27_ACCESSIBILITY = new LegacyMask(8192);
public static final LegacyMask XFA_LEGACY_V28_LAYOUT = new LegacyMask(16384);
public static final LegacyMask XFA_LEGACY_V28_SCRIPTING = new LegacyMask(32768);
public static final LegacyMask XFA_LEGACY_V29_LAYOUT = new LegacyMask(65536);
public static final LegacyMask XFA_LEGACY_V29_SCRIPTING = new LegacyMask(131072);
public static final LegacyMask XFA_LEGACY_V30_LAYOUT = new LegacyMask(262144);
public static final LegacyMask XFA_LEGACY_V30_SCRIPTING = new LegacyMask(524288);
public static final LegacyMask XFA_LEGACY_V29_TRAVERSALORDER = new LegacyMask(1048576);
public static final LegacyMask XFA_PATCH_B_02518 = new LegacyMask(2097152);
public static final LegacyMask XFA_LEGACY_V29_FIELDPRESENCE = new LegacyMask(4194304);
public static final LegacyMask XFA_PATCH_W_2393121 = new LegacyMask(8388608);
public static final LegacyMask XFA_PATCH_W_2447677 = new LegacyMask(16777216);
public static final LegacyMask XFA_LEGACY_V32_SCRIPTING = new LegacyMask(33554432);
public static final LegacyMask XFA_LEGACY_V31_LAYOUT = new LegacyMask(67108864);
public static final LegacyMask XFA_LEGACY_V32_LAYOUT = new LegacyMask(134217728);
public static final LegacyMask XFA_LEGACY_V32_RENDERING = new LegacyMask(268435456);
public static final LegacyMask XFA_LEGACY_V32_CANONICALIZATION = new LegacyMask(Integer.MIN_VALUE);
public static final LegacyMask XFA_PATCH_W_2757988 = new LegacyMask(1, 1);
public static final LegacyMask XFA_LEGACY_V34_SCRIPTING = new LegacyMask(2, 1);
public static final LegacyMask XFA_PATCH_W_2693910 = new LegacyMask(16, 1);
public static final LegacyMask XFA_OVERFLOW_TARGET_ALTERNATE = new LegacyMask(256, 1);
public static final LegacyMask XFA_LEGACY_36_DEFAULT = new LegacyMask(0);
public static final LegacyMask XFA_LEGACY_HEAD_DEFAULT = new LegacyMask(XFA_LEGACY_36_DEFAULT);
public static final LegacyMask XFA_LEGACY_35_DEFAULT = new LegacyMask(XFA_LEGACY_36_DEFAULT);
public static final LegacyMask XFA_LEGACY_34_DEFAULT = LegacyMask.or(new LegacyMask[]{XFA_LEGACY_35_DEFAULT, XFA_LEGACY_V34_SCRIPTING});
public static final LegacyMask XFA_LEGACY_33_DEFAULT = new LegacyMask(XFA_LEGACY_34_DEFAULT);
public static final LegacyMask XFA_LEGACY_32_DEFAULT = LegacyMask.or(new LegacyMask[]{XFA_LEGACY_33_DEFAULT, XFA_LEGACY_V32_SCRIPTING, XFA_LEGACY_V32_LAYOUT, XFA_LEGACY_V32_RENDERING, XFA_LEGACY_V32_CANONICALIZATION});
public static final LegacyMask XFA_LEGACY_31_DEFAULT = new LegacyMask(XFA_LEGACY_32_DEFAULT);
public static final LegacyMask XFA_LEGACY_30_DEFAULT = LegacyMask.or(new LegacyMask[]{XFA_LEGACY_31_DEFAULT, XFA_LEGACY_V30_LAYOUT, XFA_LEGACY_V30_SCRIPTING});
public static final LegacyMask XFA_LEGACY_29_DEFAULT = LegacyMask.or(new LegacyMask[]{XFA_LEGACY_30_DEFAULT, XFA_LEGACY_V29_LAYOUT, XFA_LEGACY_V29_SCRIPTING, XFA_LEGACY_V29_TRAVERSALORDER, XFA_LEGACY_V29_FIELDPRESENCE});
public static final LegacyMask XFA_LEGACY_28_DEFAULT = LegacyMask.or(new LegacyMask[]{XFA_LEGACY_29_DEFAULT, XFA_LEGACY_V28_LAYOUT, XFA_LEGACY_V28_SCRIPTING});
public static final LegacyMask XFA_LEGACY_27_DEFAULT = LegacyMask.or(new LegacyMask[]{XFA_LEGACY_28_DEFAULT, XFA_LEGACY_V27_LAYOUT, XFA_LEGACY_V27_SCRIPTING, XFA_LEGACY_V27_EVENTMODEL, XFA_LEGACY_V27_TRAVERSALORDER, XFA_LEGACY_V27_XHTMLVERSIONPROCESSING});
public static final LegacyMask XFA_LEGACY_26_DEFAULT = LegacyMask.or(new LegacyMask[]{XFA_LEGACY_27_DEFAULT, XFA_LEGACY_V26_HIDDENPOSITIONED});
public static final LegacyMask XFA_LEGACY_25_DEFAULT = LegacyMask.or(new LegacyMask[]{XFA_LEGACY_26_DEFAULT});
public static final LegacyMask XFA_LEGACY_24_DEFAULT = LegacyMask.or(new LegacyMask[]{XFA_LEGACY_25_DEFAULT, XFA_LEGACY_PLUSPRINT, XFA_LEGACY_CALCOVERRIDE, XFA_LEGACY_PERMISSIONS});
public static final LegacyMask XFA_LEGACY_23_DEFAULT = LegacyMask.or(new LegacyMask[]{XFA_LEGACY_24_DEFAULT, XFA_LEGACY_EVENTMODEL});
public static final LegacyMask XFA_LEGACY_22_DEFAULT = LegacyMask.or(new LegacyMask[]{XFA_LEGACY_23_DEFAULT});
public static final LegacyMask XFA_LEGACY_21_DEFAULT = LegacyMask.or(new LegacyMask[]{XFA_LEGACY_22_DEFAULT, XFA_LEGACY_POSITIONING});
public static final LegacyMask XFA_LEGACY_21_DEPRECATED;
public static final LegacyMask XFA_LEGACY_22_DEPRECATED;
public static final LegacyMask XFA_LEGACY_23_DEPRECATED;
public static final LegacyMask XFA_LEGACY_24_DEPRECATED;
public static final LegacyMask XFA_LEGACY_25_DEPRECATED;
public static final LegacyMask XFA_LEGACY_26_DEPRECATED;
public static final LegacyMask XFA_LEGACY_27_DEPRECATED;
public static final LegacyMask XFA_LEGACY_28_DEPRECATED;
public static final LegacyMask XFA_LEGACY_29_DEPRECATED;
public static final LegacyMask XFA_LEGACY_30_DEPRECATED;
public static final LegacyMask XFA_LEGACY_31_DEPRECATED;
public static final LegacyMask XFA_LEGACY_32_DEPRECATED;
public static final LegacyMask XFA_LEGACY_33_DEPRECATED;
public static final LegacyMask XFA_LEGACY_34_DEPRECATED;
public static final LegacyMask XFA_LEGACY_35_DEPRECATED;
public static final LegacyMask XFA_LEGACY_36_DEPRECATED;
public static final LegacyMask XFA_LEGACY_HEAD_DEPRECATED;
private static final AppSchema gAppSchema;
private boolean mbExternalProtosAreTransient;
private boolean mbIsFragmentDoc;
private boolean mbResolveAllExternalProtos = true;
private boolean mbUpdateOriginalVersion = true;
private DependencyTracker mDependencyTracker;
private int meOutputBelow = 8323073;
private int meSourceAbove = 8257536;
private int meSourceBelow = 8192000;
private EventManager mEventManager;
private final Map<String, Obj> mExtraShortCuts = new HashMap<String, Obj>();
private final List<ModelFactory> mFactories = new ArrayList<ModelFactory>();
private final List<ScriptHandler> mScriptHandlers = new ArrayList<ScriptHandler>();
private HrefHandler mHrefHandler;
private PacketHandler mPacketHandler;
private Object mHandlerData;
private LogMessenger mMessenger;
private int mnMaxVersionAllowed = 36;
private boolean mbBumpVersionOnRichTextLoad;
private List<String> moFragmentSearchPath;
private String msPackets = "";
private boolean mbAllowThirdPartyXml;
private static final ScriptDynamicPropObj getPseudoModelPropObj;
static Schema getModelSchema() {
return gAppSchema;
}
public static boolean includePacket(String aPacketName, String sInList) {
String sPackets = sInList;
if (StringUtils.isEmpty(sInList)) {
return false;
}
boolean bInclude = true;
if (sPackets.startsWith("-")) {
sPackets = sPackets.substring(1);
bInclude = false;
}
if (sPackets.indexOf(42) != -1) {
return bInclude;
}
String sPacketName = aPacketName;
String[] sTokens = sPackets.split(" ");
for (int i = 0; i < sTokens.length; ++i) {
if (!sTokens[i].equals(sPacketName)) continue;
return bInclude;
}
return !bInclude;
}
public AppModel(LogMessenger messenger) {
super(null, null, "", "xfa", "xfa", "$xfa", XFA.XFATAG, "xfa", AppModel.getModelSchema());
this.setName("xfa");
if (messenger == null) {
messenger = new LogMessenger();
}
this.mMessenger = messenger;
this.mEventManager = new EventManager(this);
new Document(this);
this.setAppModel(this);
ModelPeer xmlPeer = new ModelPeer(null, null, "", "xfa", "xfa", null, this);
xmlPeer.setModel(this);
this.setXmlPeer(xmlPeer);
this.addPseudoModel("$log", new LogPseudoModel(this));
this.addPseudoModel("$event", new EventPseudoModel(this));
}
public void addFactory(ModelFactory factory) {
int count = this.mFactories.size();
for (int i = 0; i < count; ++i) {
if (factory.rootName() != this.mFactories.get(i).rootName()) continue;
this.mFactories.remove(i);
break;
}
this.mFactories.add(factory);
}
public void addPseudoModel(String sShortCutName, Obj obj) {
assert (sShortCutName.startsWith("$"));
assert (this.mExtraShortCuts.get(sShortCutName) == null);
assert (obj != null);
this.mExtraShortCuts.put(sShortCutName, obj);
}
public void addScriptHandler(ScriptHandler handler) {
for (int i = 0; i < this.mScriptHandlers.size(); ++i) {
ScriptHandler oHandler = this.mScriptHandlers.get(i);
if (!oHandler.languageName().equals(handler.languageName())) continue;
this.mScriptHandlers.remove(i);
--i;
}
this.mScriptHandlers.add(handler.clone());
}
public void clearScriptingContexts() {
for (int i = 0; i < this.mScriptHandlers.size(); ++i) {
this.mScriptHandlers.get(i).clearExecutionContexts();
}
while (this.mScriptHandlers.size() > 0) {
this.mScriptHandlers.remove(0);
}
}
public boolean bumpVersionOnRichTextLoad() {
return this.mbBumpVersionOnRichTextLoad;
}
public void bumpVersionOnRichTextLoad(boolean bBumpVersion) {
this.mbBumpVersionOnRichTextLoad = bBumpVersion;
}
@Override
public void appendChild(Node newChild, boolean bValidate) {
assert (newChild != null);
if (newChild instanceof Model) {
Model newModel = (Model)newChild;
super.appendChild(newModel, bValidate);
newModel.setAppModel(this);
} else {
super.appendChild(newChild, bValidate);
}
}
@Override
public void clearErrorList() {
super.clearErrorList();
for (Node child = this.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
if (!(child instanceof Model)) continue;
((Model)child).clearErrorList();
}
}
@Override
public Node createNode(int eTag, Element parent, String aName, String aNS, boolean bDoVersionCheck) {
assert (aName != null);
assert (aNS != null);
if (eTag == XFA.PACKETTAG) {
Packet packet = new Packet(this, null);
ModelPeer modelPeer = new ModelPeer((Element)this.getXmlPeer(), null, aNS, aName, aName, null, packet);
packet.setXmlPeer(modelPeer);
return packet;
}
throw new ExFull(new MsgFormat(ResId.InvalidNodeTypeException, this.getAtom(eTag)));
}
@Override
public Element createElement(Element parent, Node prevSibling, String uri, String localName, String qName, Attributes attributes, int lineNumber, String fileName) {
super.setLineNumber(lineNumber);
if (parent == this || parent instanceof Document) {
String sPackets = this.getPacketList();
if (sPackets.length() > 0) {
boolean bFilterOut;
StringTokenizer sFilter = new StringTokenizer(sPackets);
boolean bl = bFilterOut = sFilter.countTokens() > 0;
while (sFilter.hasMoreTokens()) {
String sToken = sFilter.nextToken();
if (sToken.equals("*") || sToken.equals(localName)) {
bFilterOut = false;
continue;
}
if (sToken.charAt(0) != '-' || !sToken.endsWith(localName)) continue;
break;
}
if (bFilterOut) {
return null;
}
}
for (int i = 0; i < this.mFactories.size(); ++i) {
ModelFactory mf = this.mFactories.get(i);
if (!mf.isRootNode(this, uri, localName)) continue;
if (!mf.getAllowAdd()) {
for (Node child = this.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
if (child.getClassTag() != mf.meClassTag) continue;
throw new ExFull(ResId.DuplicateModelLoadException, XFA.getAtom(mf.meClassTag));
}
}
Model model = mf.newModel(this, prevSibling, uri, localName, qName, attributes);
if (uri == "") {
model.setNeedsNSNormalize(true);
}
return model;
}
Packet packet = new Packet(this, prevSibling);
packet.setXmlPeer(new ModelPeer(parent == this ? (Element)this.getXmlPeer() : parent, null, uri, localName, qName, attributes, packet));
packet.setDOMProperties(uri, localName, qName, null);
return packet;
}
if (parent == null) {
return null;
}
return super.createElement(parent, prevSibling, uri, localName, qName, attributes, lineNumber, fileName);
}
public DependencyTracker dependencyTracker() {
return this.mDependencyTracker;
}
public void dependencyTracker(DependencyTracker oDependencyTracker) {
this.mDependencyTracker = oDependencyTracker;
}
public boolean getAllowThirdPartyXml() {
return this.mbAllowThirdPartyXml;
}
public List<ModelFactory> factories() {
return this.mFactories;
}
@Override
public Attribute getAttribute(int eAttributeTag) {
assert (eAttributeTag == XFA.TIMESTAMPTAG || eAttributeTag == XFA.UUIDTAG);
String aPropertyName = XFA.getAtom(eAttributeTag);
int attr = this.findAttr(null, aPropertyName);
String oAttrValue = "";
if (attr != -1) {
oAttrValue = this.getAttrVal(attr);
}
return new StringAttr(aPropertyName, oAttrValue);
}
@Override
public String getBaseNS() {
return "http://ns.adobe.com/xdp/";
}
@Override
public ScriptDynamicPropObj getDynamicScriptProp(String sPropertyName, boolean bPropertyOverride, boolean bPeek) {
if (!bPropertyOverride && AppModelScript.getPseudoModelFunc(this, null, sPropertyName)) {
return getPseudoModelPropObj;
}
return super.getDynamicScriptProp(sPropertyName, bPropertyOverride, bPeek);
}
@Override
public List<Element> getErrorContextList() {
ArrayList<Element> errList = new ArrayList<Element>(super.getErrorContextList());
for (Node child = this.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
if (!(child instanceof Model)) continue;
Model model = (Model)child;
errList.addAll(model.getErrorContextList());
}
return errList;
}
@Override
public List<ExFull> getErrorList() {
ArrayList<ExFull> errList = new ArrayList<ExFull>(super.getErrorList());
for (Node child = this.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
if (!(child instanceof Model)) continue;
Model model = (Model)child;
errList.addAll(model.getErrorList());
}
return errList;
}
@Override
public EventManager getEventManager() {
return this.mEventManager;
}
public boolean getExternalProtosAreTransient() {
return this.mbExternalProtosAreTransient;
}
public List<String> getFragmentSearchPath() {
return this.moFragmentSearchPath;
}
@Override
public String getHeadNS() {
return "http://ns.adobe.com/xdp/";
}
public HrefHandler getHrefHandler() {
return this.mHrefHandler;
}
public boolean getIsFragmentDoc() {
return this.mbIsFragmentDoc;
}
@Override
public boolean getLegacySetting(LegacyMask nLegacyFlag) {
FormModel formModel;
if (nLegacyFlag == XFA_LEGACY_V30_SCRIPTING && (formModel = (FormModel)Model.getNamedModel(this, "form")) != null && formModel.mergeMode() == 9175041) {
return false;
}
TemplateModel oTemplateModel = (TemplateModel)Model.getNamedModel(this, "template");
if (oTemplateModel == null) {
return false;
}
return oTemplateModel.getLegacySetting(nLegacyFlag);
}
@Override
public LogMessenger getLogMessenger() {
return this.mMessenger;
}
@Override
public String getNS() {
return this.getBaseNS();
}
public int getOutputBelow() {
return this.meOutputBelow;
}
public String getPacketList() {
return this.msPackets;
}
@Override
public Node getPreviousXMLSibling() {
Document parent = this.getDocument();
if (parent == null) {
return null;
}
Node prev = null;
for (Node child = parent.getFirstXMLChild(); child != null; child = child.getNextXMLSibling()) {
if (child == this) {
return prev;
}
prev = child;
}
return null;
}
boolean getResolveAllExternalProtos() {
return this.mbResolveAllExternalProtos;
}
@Override
public int getSchemaType(int eTag) {
for (Node oChild = this.getFirstXFAChild(); oChild != null; oChild = oChild.getNextXFASibling()) {
if (oChild.getClassTag() != eTag) continue;
return 4;
}
return super.getSchemaType(eTag);
}
public List<ScriptHandler> getScriptHandlers() {
return this.mScriptHandlers;
}
@Override
ScriptHandler getScriptHandler(String sLanguageName) {
for (int i = 0; i < this.mScriptHandlers.size(); ++i) {
ScriptHandler scriptHandler = this.mScriptHandlers.get(i);
if (!scriptHandler.languageName().equals(sLanguageName)) continue;
return scriptHandler;
}
return null;
}
@Override
public ScriptTable getScriptTable() {
return AppModelScript.getScriptTable();
}
int getSourceAbove() {
return this.meSourceAbove;
}
@Override
public int getSourceBelow() {
return this.meSourceBelow;
}
Node getThis() {
return this.getContext();
}
public int getVersionRestriction() {
return this.mnMaxVersionAllowed;
}
@Override
public boolean getWillDirty() {
Document document = this.getDocument();
if (document == null) {
return false;
}
return document.getWillDirty();
}
@Override
public void insertChild(Node newChild, Node refChild, boolean bValidate) {
assert (null != newChild);
if (newChild instanceof Model) {
Model newModel = (Model)newChild;
super.insertChild(newModel, refChild, bValidate);
newModel.setAppModel(this);
} else {
super.insertChild(newChild, refChild, bValidate);
}
}
@Override
public boolean isValidAttr(int eTag, boolean bReport, String value) {
if (eTag == XFA.TIMESTAMPTAG || eTag == XFA.UUIDTAG) {
return true;
}
return false;
}
@Override
public boolean isValidChild(int eTag, int nError, boolean bBeforeInsert, boolean bOccurrenceErrorOnly) {
if (eTag == XFA.PACKETTAG) {
return true;
}
return super.isValidChild(eTag, nError, bBeforeInsert, bOccurrenceErrorOnly);
}
public boolean isXFANode(String uri, String localName, String qName) {
if (localName == "xfa" ? uri == "" || uri.startsWith("http://www.xfa.org/schema/") : localName == "xdp" && uri != "" && uri.startsWith("http://ns.adobe.com/xdp/")) {
return true;
}
return false;
}
public static boolean isXFANode(Element node) {
String uri;
String localName = node.getName();
if (localName == "xfa") {
String uri2 = node.getNS();
if (uri2 == "" || uri2.startsWith("http://www.xfa.org/schema/")) {
return true;
}
if (uri2 != "" && uri2.startsWith("http://ns.adobe.com/xdp/")) {
return true;
}
} else if (localName == "xdp" && (uri = node.getNS()) != "" && uri.startsWith("http://ns.adobe.com/xdp/")) {
return true;
}
return false;
}
public Obj lookupPseudoModel(String sShortCutName) {
return this.mExtraShortCuts.get(sShortCutName);
}
public Element newDOM() {
while (this.getFirstXFAChild() != null) {
this.getFirstXFAChild().remove();
}
this.mEventManager.reset();
Document doc = this.getDocument();
while (doc.getFirstXMLChild() != null) {
doc.getFirstXMLChild().remove();
}
doc.isDefaultDocument(false);
ModelPeer xmlPeer = new ModelPeer(doc, null, "", "xfa", "xfa", null, this);
xmlPeer.setModel(this);
this.setXmlPeer(xmlPeer);
this.createDOM((Element)this.getXmlPeer());
return this;
}
@Override
protected void postLoad() {
if (this.mPacketHandler != null) {
Node child = this.getFirstXMLChild();
while (child != null) {
Node nextChild = child.getNextXMLSibling();
this.mPacketHandler.filterPackets(child, this.mHandlerData);
child = nextChild;
}
}
}
@Override
public void preSave(boolean bSaveXMLScript) {
for (Node child = this.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
child.preSave(bSaveXMLScript);
}
}
@Override
public boolean ready(boolean bForced) {
boolean bRet = false;
for (Node child = this.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
if (!(child instanceof Model)) continue;
Model model = (Model)child;
bRet |= model.ready(bForced);
}
return bRet;
}
void preSaveXML() {
}
@Override
public boolean publish(Model.Publisher publisher) {
boolean bRet = true;
for (Node child = this.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
if (!(child instanceof Model)) continue;
bRet &= ((Model)child).publish(publisher);
}
return bRet;
}
public void removePseudoModel(String sShortCutName) {
this.mExtraShortCuts.remove(sShortCutName);
}
void resetPseudoModelEvents() {
for (Obj obj : this.mExtraShortCuts.values()) {
EventManager.resetEventTable(obj.getEventTable(false));
}
}
void setAllowThirdPartyXml(boolean bAllowThirdPartyXml) {
this.mbAllowThirdPartyXml = bAllowThirdPartyXml;
}
@Override
public void setAttribute(Attribute oValue, int eAttributeTag) {
if (eAttributeTag != XFA.TIMESTAMPTAG && eAttributeTag != XFA.UUIDTAG) {
MsgFormat oMessage = new MsgFormat(ResId.InvalidSetPropertyException);
oMessage.format(this.getClassAtom());
oMessage.format(oValue.getLocalName());
throw new ExFull(oMessage);
}
this.updateAttribute(oValue);
}
public void setExternalProtosAreTransient(boolean bExternalProtosAreTransient) {
this.mbExternalProtosAreTransient = bExternalProtosAreTransient;
}
public void setFragmentSearchPath(List<String> oSearchPath) {
this.moFragmentSearchPath = oSearchPath;
}
public void setHrefHandler(HrefHandler handler) {
this.mHrefHandler = handler;
}
public void setIsFragmentDoc(boolean bIsFragmentDoc) {
this.mbIsFragmentDoc = bIsFragmentDoc;
}
@Override
void setLogMessenger(LogMessenger oMessenger) {
if (oMessenger == null) {
return;
}
if (this.mMessenger == oMessenger) {
return;
}
if (oMessenger != null) {
List<LogMessage> oMessages = this.mMessenger.storedMsgArray();
for (int i = 0; i < oMessages.size(); ++i) {
LogMessage oMessage = oMessages.get(i);
oMessenger.sendMessage(oMessage);
}
}
this.mMessenger = oMessenger;
}
public void setPacketHandler(PacketHandler oPacketHandler, Object oHandlerData) {
this.mPacketHandler = oPacketHandler;
this.mHandlerData = oHandlerData;
}
public void setPacketList(String sPackets) {
this.msPackets = sPackets;
}
public void setResolveAllExternalProtos(boolean bResolveAllExternalProtos) {
this.mbResolveAllExternalProtos = bResolveAllExternalProtos;
}
public void setSourceAbove(int eSouceAbove) {
this.meSourceAbove = eSouceAbove;
}
public void setSourceBelow(int eSouceBelow) {
this.meSourceBelow = eSouceBelow;
}
public void setVersionRestriction(int nVersion, int eOutputBelow) {
this.mnMaxVersionAllowed = nVersion;
this.meOutputBelow = eOutputBelow;
}
@Override
public void setWillDirty(boolean bWillDirty) {
this.getDocument().setWillDirty(bWillDirty);
}
public boolean updateOriginalVersion() {
return this.mbUpdateOriginalVersion;
}
public void updateOriginalVersion(boolean bUpdate) {
this.mbUpdateOriginalVersion = bUpdate;
}
static {
XFA_LEGACY_32_DEPRECATED = AppModel.XFA_LEGACY_31_DEPRECATED = (AppModel.XFA_LEGACY_30_DEPRECATED = (AppModel.XFA_LEGACY_29_DEPRECATED = (AppModel.XFA_LEGACY_28_DEPRECATED = (AppModel.XFA_LEGACY_27_DEPRECATED = (AppModel.XFA_LEGACY_26_DEPRECATED = (AppModel.XFA_LEGACY_25_DEPRECATED = (AppModel.XFA_LEGACY_24_DEPRECATED = (AppModel.XFA_LEGACY_23_DEPRECATED = (AppModel.XFA_LEGACY_22_DEPRECATED = (AppModel.XFA_LEGACY_21_DEPRECATED = new LegacyMask(0)))))))))));
XFA_LEGACY_HEAD_DEPRECATED = AppModel.XFA_LEGACY_36_DEPRECATED = (AppModel.XFA_LEGACY_35_DEPRECATED = (AppModel.XFA_LEGACY_34_DEPRECATED = (AppModel.XFA_LEGACY_33_DEPRECATED = LegacyMask.or(new LegacyMask[]{XFA_LEGACY_32_DEPRECATED, XFA_LEGACY_RENDERING, XFA_LEGACY_POSITIONING}))));
gAppSchema = new AppSchema();
getPseudoModelPropObj = new ScriptDynamicPropObj(10, 63){
@Override
public boolean invokeGetProp(Obj scriptThis, Arg retValue, String sPropertyName) {
return AppModelScript.getPseudoModelFunc(scriptThis, retValue, sPropertyName);
}
};
}
public static class LegacyMask {
private static final int LegacyMask_BitSize = 2;
private int[] nBits;
public LegacyMask(int nBitsIdx) {
this(nBitsIdx, 0);
}
public LegacyMask(int nBitsIdx, int nIndex) {
assert (nIndex < 2);
this.nBits = new int[2];
for (int i = 0; i < 2; ++i) {
this.nBits[i] = 0;
}
if (nIndex >= 2) {
return;
}
int[] arrn = this.nBits;
int n = nIndex;
arrn[n] = arrn[n] | nBitsIdx;
}
public LegacyMask(LegacyMask inLegacyMask) {
this.nBits = new int[2];
for (int i = 0; i < 2; ++i) {
this.nBits[i] = inLegacyMask.nBits[i];
}
}
public boolean isNonZero() {
for (int i = 0; i < 2; ++i) {
if (this.nBits[i] == 0) continue;
return true;
}
return false;
}
public LegacyMask and(LegacyMask lm) {
LegacyMask lmRes = new LegacyMask(0);
for (int i = 0; i < 2; ++i) {
lmRes.nBits[i] = lm.nBits[i] & this.nBits[i];
}
return lmRes;
}
public LegacyMask or_n_set(LegacyMask lm) {
for (int i = 0; i < 2; ++i) {
int[] arrn = this.nBits;
int n = i;
arrn[n] = arrn[n] | lm.nBits[i];
}
return this;
}
public void set(LegacyMask lm) {
for (int i = 0; i < 2; ++i) {
this.nBits[i] = lm.nBits[i];
}
}
public LegacyMask not() {
LegacyMask lmRes = new LegacyMask(0);
for (int i = 0; i < 2; ++i) {
lmRes.nBits[i] = ~ this.nBits[i];
}
return lmRes;
}
public LegacyMask or(LegacyMask lmIn) {
LegacyMask lmRes = new LegacyMask(0);
for (int i = 0; i < 2; ++i) {
lmRes.nBits[i] = lmIn.nBits[i] | this.nBits[i];
}
return lmRes;
}
public static LegacyMask or(LegacyMask[] lmArr) {
LegacyMask lmRes = new LegacyMask(0);
for (int i = 0; i < 2; ++i) {
for (int j = 0; j < lmArr.length; ++j) {
int[] arrn = lmRes.nBits;
int n = i;
arrn[n] = arrn[n] | lmArr[j].nBits[i];
}
}
return lmRes;
}
public boolean equals(Object objRight) {
if (!(objRight instanceof LegacyMask)) {
return false;
}
LegacyMask lmRight = (LegacyMask)objRight;
for (int i = 0; i < 2; ++i) {
if (this.nBits[i] == lmRight.nBits[i]) continue;
return false;
}
return true;
}
}
}