FormInstanceManager.java
27 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
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xfa.form;
import com.adobe.xfa.AppModel;
import com.adobe.xfa.Attribute;
import com.adobe.xfa.Element;
import com.adobe.xfa.EnumAttr;
import com.adobe.xfa.Int;
import com.adobe.xfa.Model;
import com.adobe.xfa.Node;
import com.adobe.xfa.Obj;
import com.adobe.xfa.ProtoableNode;
import com.adobe.xfa.ScriptHandler;
import com.adobe.xfa.ScriptTable;
import com.adobe.xfa.XFA;
import com.adobe.xfa.XFAList;
import com.adobe.xfa.data.DataNode;
import com.adobe.xfa.form.FormDataListener;
import com.adobe.xfa.form.FormExclGroup;
import com.adobe.xfa.form.FormField;
import com.adobe.xfa.form.FormInstanceManagerScript;
import com.adobe.xfa.form.FormModel;
import com.adobe.xfa.form.FormSubform;
import com.adobe.xfa.form.FormSubformSet;
import com.adobe.xfa.template.containers.Container;
import com.adobe.xfa.template.containers.Subform;
import com.adobe.xfa.ut.BooleanHolder;
import com.adobe.xfa.ut.ExFull;
import com.adobe.xfa.ut.MsgFormatPos;
import com.adobe.xfa.ut.Peer;
import com.adobe.xfa.ut.ResId;
import java.util.ArrayList;
import java.util.List;
import org.xml.sax.Attributes;
public class FormInstanceManager
extends ProtoableNode {
private final List<Element> mInstances = new ArrayList<Element>();
private ProtoableNode mTemplateNode;
private boolean mbMatchDescendantsOnly;
private InstanceListener mListener;
private boolean mbInitializingNewInstance;
public FormInstanceManager(Element parent, Node prevSibling) {
super(parent, prevSibling, "", "instanceManager", "instanceManager", null, XFA.INSTANCEMANAGERTAG, "instanceManager");
}
public void setInstances(int nNumber, boolean bThrow) {
int nMax = this.getMax();
FormModel formModel = (FormModel)this.getModel();
if (formModel.mergeMode() == 9175041) {
if (bThrow) {
throw new ExFull(ResId.InstanceManagmentNotAllowed);
}
return;
}
if (nNumber < 0) {
if (bThrow) {
throw new ExFull(new MsgFormatPos(ResId.OccurrenceViolationException, "min"));
}
return;
}
if (nNumber > nMax && nMax != -1) {
if (bThrow) {
throw new ExFull(new MsgFormatPos(ResId.OccurrenceViolationException, "max"));
}
return;
}
if (nNumber < this.getMin()) {
if (bThrow) {
throw new ExFull(new MsgFormatPos(ResId.OccurrenceViolationException, "min"));
}
return;
}
if (nNumber > this.getCount()) {
int nManagerIndex = this.getIndex();
for (int i = 0; i < (nNumber -= this.getCount()); ++i) {
this.addChild(nManagerIndex, this.getCount(), true);
}
} else if (nNumber < this.getCount()) {
nNumber = this.getCount() - nNumber;
for (int i = 0; i < nNumber; ++i) {
this.removeInstance(this.mInstances.size() - 1, false);
}
}
this.clearDefaults();
this.notifyPeers(0, "", null);
}
public Node addInstance(boolean bMerge) {
return this.addInstance(this.getCount(), bMerge);
}
Node addInstance(int nInstance, boolean bMerge) {
int nMax = this.getMax();
Node bRet = null;
FormModel formModel = (FormModel)this.getModel();
if (formModel.mergeMode() == 9175041) {
throw new ExFull(ResId.InstanceManagmentNotAllowed);
}
if (nInstance > this.getCount()) {
throw new ExFull(ResId.IndexOutOfBoundsException);
}
if (nMax != -1 && nMax <= this.getCount()) {
throw new ExFull(new MsgFormatPos(ResId.OccurrenceViolationException, "max"));
}
int nManagerIndex = this.getIndex();
bRet = this.addChild(nManagerIndex, nInstance, bMerge);
this.clearDefaults();
this.notifyPeers(0, "", null);
return bRet;
}
void addInstance(Node instance, boolean bValidate) {
int nMax;
if (bValidate && (nMax = this.getMax()) != -1 && nMax < this.getCount()) {
throw new ExFull(new MsgFormatPos(ResId.OccurrenceViolationException, "max"));
}
if (instance instanceof FormSubform) {
FormSubform formSubformInstance = (FormSubform)instance;
formSubformInstance.setInstanceManager(this);
this.mInstances.add(formSubformInstance);
} else if (instance instanceof FormSubformSet) {
FormSubformSet formSubformSetInstance = (FormSubformSet)instance;
formSubformSetInstance.setInstanceManager(this);
this.mInstances.add(formSubformSetInstance);
}
}
public void removeInstance(int nInstance, boolean bNotifyPeers) {
Element instance;
Model model;
if (nInstance >= this.getCount()) {
throw new ExFull(ResId.IndexOutOfBoundsException);
}
if (this.getCount() - 1 < this.getMin()) {
throw new ExFull(new MsgFormatPos(ResId.OccurrenceViolationException, "min"));
}
FormModel formModel = (FormModel)this.getModel();
if (formModel.mergeMode() == 9175041) {
throw new ExFull(ResId.InstanceManagmentNotAllowed);
}
Element removedFormNode = instance = this.mInstances.get(nInstance);
if (null != this.mListener) {
this.mListener.preRemoveInstance(removedFormNode);
}
List<ScriptHandler> handlers = this.getAppModel().getScriptHandlers();
for (int i = 0; i < handlers.size(); ++i) {
handlers.get(i).removeReference(removedFormNode);
}
boolean bLegacy = this.getAppModel().getLegacySetting(AppModel.XFA_LEGACY_V27_SCRIPTING);
this.cleanDataNodes(instance, bLegacy);
if (instance instanceof FormSubform) {
FormSubform formSubformInstance = (FormSubform)instance;
formSubformInstance.setInstanceManager(null);
} else if (instance instanceof FormSubformSet) {
FormSubformSet formSubformSetInstance = (FormSubformSet)instance;
formSubformSetInstance.setInstanceManager(null);
}
instance.remove();
this.mInstances.remove(nInstance);
if (null != this.mListener) {
this.mListener.postRemoveInstance(removedFormNode);
}
if (bNotifyPeers) {
if (nInstance < this.getCount()) {
this.broadcastIndexChange(nInstance, this.getCount() - 1, true);
}
this.clearDefaults();
this.notifyPeers(0, "", null);
}
if ((model = this.getModel()) != null) {
model.removeReferences(instance);
}
}
private static void arrangeProtos(ProtoableNode templateNode, int nInstance, int nPosition) {
if (templateNode == null) {
return;
}
boolean bContainer = templateNode.isContainer();
boolean bField = templateNode.isSameClass(XFA.FIELDTAG);
if (bField || bContainer) {
templateNode.moveProtos(nInstance, nPosition);
}
if (bContainer) {
int len = templateNode.getXFAChildCount();
for (int i = 0; i < len; ++i) {
FormInstanceManager.arrangeProtos((ProtoableNode)templateNode.getXFAChild(i), nInstance, nPosition);
}
}
}
public void moveInstance(int nInstance, int nPosition, boolean bNotify) {
FormModel formModel = (FormModel)this.getModel();
if (formModel.mergeMode() == 9175041) {
throw new ExFull(ResId.InstanceManagmentNotAllowed);
}
if (nInstance == nPosition) {
return;
}
if (this.getCount() < 2 || nPosition < 0 || nPosition >= this.getCount() || nInstance < 0 || nInstance >= this.getCount()) {
throw new ExFull(ResId.IndexOutOfBoundsException);
}
int nMax = this.getMax();
if (nMax == 0 || nMax == 1) {
throw new ExFull(new MsgFormatPos(ResId.OccurrenceViolationException, "max"));
}
Element instance = this.mInstances.get(nInstance);
Element position = this.mInstances.get(nPosition);
Element movedFormNode = instance;
if (null != this.mListener) {
this.mListener.preMoveInstance(movedFormNode);
}
this.mInstances.remove(nInstance);
Element parent = this.getXFAParent();
Node refNode = null;
if (this.getCount() > nPosition) {
refNode = this.mInstances.get(nPosition);
this.mInstances.add(nPosition, instance);
} else {
int nRefIndex = this.getIndex() + this.getCount() + 2;
int nCount = 0;
Node child = parent.getFirstXFAChild();
while (child != null) {
if (nCount == nRefIndex) {
refNode = child;
break;
}
child = child.getNextXFASibling();
++nCount;
}
this.mInstances.add(instance);
}
if (refNode == null) {
parent.appendChild(instance, false);
} else {
parent.insertChild(instance, refNode, false);
}
if (null != this.mListener) {
this.mListener.postMoveInstance(movedFormNode);
}
this.moveDataNodes(nInstance, nPosition);
ProtoableNode poInstanceProto = ((ProtoableNode)instance).getProto();
ProtoableNode poPositionProto = ((ProtoableNode)position).getProto();
if (poInstanceProto == poPositionProto) {
FormInstanceManager.arrangeProtos(poInstanceProto, nInstance, nPosition);
}
if (bNotify) {
boolean bUseRange = !this.getAppModel().getLegacySetting(AppModel.XFA_LEGACY_V27_SCRIPTING);
this.broadcastIndexChange(nInstance, nPosition, bUseRange);
this.clearDefaults();
this.notifyPeers(0, "", null);
}
}
private void addDataNodes(int nIndex) {
}
public void setInstanceListener(InstanceListener listener) {
this.mListener = listener;
}
void cleanup(Node node) {
for (int i = 0; i < this.mInstances.size(); ++i) {
Element poInstance = this.mInstances.get(i);
if (node != poInstance) continue;
this.mInstances.remove(i);
break;
}
}
int getCount() {
return this.mInstances.size();
}
int getMin() {
Element occur = this.getElement(XFA.OCCURTAG, 0);
Int min = (Int)occur.getAttribute(XFA.MINTAG);
return min.getValue();
}
int getMax() {
Element occur = this.getElement(XFA.OCCURTAG, 0);
Int max = (Int)occur.getAttribute(XFA.MAXTAG);
return max.getValue();
}
void setTemplateNode(ProtoableNode templateNode) {
String aName = templateNode.getName();
aName = aName == "" ? "_" : ("_" + aName).intern();
this.privateSetName(aName);
this.mTemplateNode = templateNode;
ProtoableNode occur = (ProtoableNode)templateNode.getElement(XFA.OCCURTAG, true, 0, false, false);
if (occur != null) {
occur.createProto(this, false);
}
}
int findIndex(Node instance) {
for (int i = 0; i < this.mInstances.size(); ++i) {
if (this.mInstances.get(i) != instance) continue;
return i;
}
return 0;
}
private void clearDefaults() {
for (int i = 0; i < this.mInstances.size(); ++i) {
this.mInstances.get(i).makeNonDefault(false);
}
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
private Node addChild(int nManagerIndex, int nInsertIndex, boolean bMerge) {
if (this.mbInitializingNewInstance) {
MsgFormatPos formatPos = new MsgFormatPos(ResId.XFAAddInstanceRecursiveException);
ProtoableNode node = this.getTemplateNode();
if (null != node) {
formatPos.format(node.getName());
}
throw new ExFull(formatPos);
}
FormModel formModel = (FormModel)this.getModel();
Element parent = this.getXFAParent();
if (null != this.mListener) {
this.mListener.preAddInstance();
}
Element mappedParent = parent.isMapped() ? parent : FormModel.getMappedParent(parent);
boolean bMatchDescendantsOnly = formModel.getMatchDescendantsOnly();
formModel.setMatchDescendantsOnly(this.getMatchDescendantsOnly());
DataNode dataParent = FormModel.getDataNode(mappedParent);
Element newFormNode = null;
formModel.setAllowNewNodes(true);
if (!bMerge) {
formModel.setEmptyMerge(true);
if (formModel.mergeMode() == 9175040) {
newFormNode = formModel.createEmptyFormNode(this.getTemplateNode(), parent, null, this);
}
} else {
formModel.setEmptyMerge(false);
if (this.getTemplateNode() instanceof Subform) {
Container.FormInfo info = formModel.getFormInfo(this.getTemplateNode(), dataParent, null);
DataNode matched = formModel.findMatch(info, true, FormModel.DatasetSelector.MAIN_DATASET);
if (matched != null) {
newFormNode = formModel.createFormNode(this.getTemplateNode(), parent, this);
formModel.bindNodes(newFormNode, matched, false);
formModel.consumeDataNode(null, matched, FormModel.DatasetSelector.MAIN_DATASET);
formModel.createAndMatchChildren(this.getTemplateNode(), matched, newFormNode, null);
} else if (info != null && (info.eMergeType == 2031618 || info.eMergeType == 2031619) && formModel.mergeMode() == 9175040) {
newFormNode = formModel.createEmptyFormNode(this.getTemplateNode(), parent, null, this);
}
}
if (newFormNode == null) {
newFormNode = formModel.createFormNode(this.getTemplateNode(), parent, this);
if (formModel.mergeMode() == 9175041) {
int eMergeType = formModel.mergeType(this.getTemplateNode(), "", null);
DataNode dataNode = formModel.createDataNode(newFormNode, dataParent, eMergeType, true);
formModel.bindNodes(newFormNode, dataNode, true);
formModel.consumeDataNode(null, dataNode, FormModel.DatasetSelector.MAIN_DATASET);
dataParent = dataNode;
}
formModel.createAndMatchChildren(this.getTemplateNode(), dataParent, newFormNode, null);
}
}
formModel.setAllowNewNodes(false);
Node refNode = null;
int nRefIndex = nManagerIndex + this.getCount();
if (parent.getXFAChildCount() > nRefIndex + 1) {
refNode = parent.getXFAChild(nRefIndex);
}
if (refNode != null) {
parent.insertChild(newFormNode, refNode, true);
}
if (!formModel.isLoading() || !formModel.getIgnoreCheckSum()) {
formModel.mergeSecondPass(parent, dataParent);
}
if (newFormNode instanceof Container) {
formModel.setDynamicProperties((Container)newFormNode, "", true);
}
this.addDataNodes(nInsertIndex);
formModel.setMatchDescendantsOnly(bMatchDescendantsOnly);
if (null != this.mListener) {
Element oNewFormNode = newFormNode;
this.mListener.postAddInstance(oNewFormNode);
}
this.moveInstance(this.getCount() - 1, nInsertIndex, false);
assert (!this.mbInitializingNewInstance);
if (!this.mbInitializingNewInstance) {
this.mbInitializingNewInstance = true;
try {
String sInitialize = EnumAttr.getString(4915200);
formModel.eventOccurred(sInitialize, newFormNode);
}
finally {
this.mbInitializingNewInstance = false;
}
}
if (this.getCount() > 0) {
this.broadcastIndexChange(this.getCount() - 1, nInsertIndex, true);
}
assert (!this.mbInitializingNewInstance);
return newFormNode;
}
private static void insertNodeAfter(Node newNode, Node prevRefNode) {
Element parent = prevRefNode.getXFAParent();
if (parent == null) {
throw new ExFull(ResId.InsertFailedException);
}
Node refNode = prevRefNode.getNextXFASibling();
if (refNode != null) {
if (newNode != refNode) {
parent.insertChild(newNode, refNode, true);
}
} else {
parent.appendChild(newNode, true);
}
}
private void moveDataNodes(int nFrom, int nTo) {
Element refNode;
Element instance = this.mInstances.get(nTo);
ArrayList<Element> dataNodes = new ArrayList<Element>();
ArrayList<Element> prevRefDataNodes = new ArrayList<Element>();
ArrayList<Element> postRefDataNodes = new ArrayList<Element>();
this.getDataNodes(instance, dataNodes);
int nNodeSet = dataNodes.size();
boolean bGiveWarning = false;
if (nTo > 0) {
refNode = this.mInstances.get(nTo - 1);
this.getDataNodes(refNode, prevRefDataNodes);
int nPrevSet = prevRefDataNodes.size();
if (nNodeSet == nPrevSet && nNodeSet == 1) {
FormInstanceManager.insertNodeAfter(dataNodes.get(0), prevRefDataNodes.get(0));
return;
}
if (nNodeSet > nPrevSet) {
bGiveWarning = true;
}
boolean bFound = false;
for (int i = nNodeSet; i > 0; --i) {
Element node = dataNodes.get(i - 1);
for (int j = nPrevSet; j > 0; --j) {
Element node2 = prevRefDataNodes.get(j - 1);
if (!node2.isSameClass(node) || node.getName() != node2.getName()) continue;
bFound = true;
FormInstanceManager.insertNodeAfter(node, node2);
break;
}
if (bFound) continue;
bGiveWarning = true;
}
}
if (nTo + 1 < this.getCount()) {
refNode = this.mInstances.get(nTo + 1);
this.getDataNodes(refNode, postRefDataNodes);
int nPostSet = postRefDataNodes.size();
if (nNodeSet == nPostSet && nNodeSet == 1 && nTo == 0) {
postRefDataNodes.get(0).getXFAParent().insertChild(dataNodes.get(0), postRefDataNodes.get(0), true);
return;
}
if (nNodeSet < nPostSet) {
bGiveWarning = true;
}
block2 : for (int i = 0; i < nNodeSet; ++i) {
Element node = dataNodes.get(i);
for (int j = 0; j < nPostSet; ++j) {
Element node2 = postRefDataNodes.get(j);
if (!node2.isSameClass(node) || node.getName() != node2.getName() || nTo != 0) continue;
node.getXFAParent().insertChild(node, node2, true);
continue block2;
}
}
}
if (bGiveWarning) {
MsgFormatPos msgFormatPos = new MsgFormatPos(ResId.XFAMoveInstanceException);
msgFormatPos.format(instance.getClassAtom());
msgFormatPos.format(instance.getName());
msgFormatPos.format(Integer.toString(nFrom));
msgFormatPos.format(Integer.toString(nTo));
throw new ExFull(msgFormatPos);
}
}
private void getDataNodes(Node formNode, List<Element> dataNodes) {
boolean bGetChildren = false;
DataNode dataNode = null;
if (formNode instanceof FormSubform) {
bGetChildren = true;
dataNode = ((FormSubform)formNode).getDataNode();
} else if (formNode instanceof FormSubformSet) {
bGetChildren = true;
} else if (formNode instanceof FormField) {
dataNode = ((FormField)formNode).getDataNode();
} else if (formNode instanceof FormExclGroup) {
bGetChildren = true;
dataNode = ((FormExclGroup)formNode).getDataNode();
}
if (dataNode != null) {
if (dataNode.getXFAParent() != null) {
dataNodes.add(dataNode);
}
return;
}
if (bGetChildren) {
for (Node childNode = formNode.getFirstXFAChild(); childNode != null; childNode = childNode.getNextXFASibling()) {
if (!(childNode instanceof Element)) continue;
this.getDataNodes((Element)childNode, dataNodes);
}
}
}
private int getIndex() {
Element parent = this.getXFAParent();
int index = 0;
Node child = parent.getFirstXFAChild();
while (child != null && child != this) {
child = child.getNextXFASibling();
++index;
}
return index;
}
private void broadcastIndexChange(int nStart, int nEnd, boolean bRange) {
FormModel formModel = (FormModel)this.getModel();
String sIndexChange = EnumAttr.getString(4915221);
if (bRange) {
int nMin = Math.min(nStart, nEnd);
int nMax = Math.max(nStart, nEnd);
for (int i = nMin; i <= nMax; ++i) {
formModel.eventOccurred(sIndexChange, this.mInstances.get(i));
}
} else {
formModel.eventOccurred(sIndexChange, this.mInstances.get(nStart));
if (nStart != nEnd) {
formModel.eventOccurred(sIndexChange, this.mInstances.get(nEnd));
}
}
}
private boolean canRestoreCount(Element node, FormModel model) {
if (model.getIgnoreCheckSum()) {
return true;
}
int eRetValue = model.mergeType(node, "", null);
if (eRetValue != 2031616 && eRetValue != 2031618) {
return false;
}
if (node.isContainer()) {
for (Node childNode = node.getFirstXFAChild(); childNode != null; childNode = childNode.getNextXFASibling()) {
if (!(childNode instanceof Element) || this.canRestoreCount((Element)childNode, model)) continue;
return false;
}
}
return true;
}
private void cleanDataNodes(Node formNode, boolean bLegacyMode) {
boolean bGetChildren = false;
DataNode dataNode = null;
if (formNode instanceof FormSubform) {
bGetChildren = true;
FormSubform formSubform = (FormSubform)formNode;
dataNode = formSubform.getDataNode();
formSubform.cleanupListeners();
} else if (formNode instanceof FormSubformSet) {
bGetChildren = true;
} else if (formNode instanceof FormField) {
FormField formField = (FormField)formNode;
dataNode = formField.getDataNode();
formField.cleanupListeners();
} else if (formNode instanceof FormExclGroup) {
bGetChildren = true;
FormExclGroup formExclGroup = (FormExclGroup)formNode;
dataNode = formExclGroup.getDataNode();
formExclGroup.cleanupListeners();
}
if (dataNode != null && dataNode.getXFAParent() != null) {
int nPeer = 0;
int nListenerCount = 0;
Peer peer = dataNode.getPeer(nPeer);
while (peer != null) {
if (peer instanceof FormDataListener) {
++nListenerCount;
}
peer = dataNode.getPeer(++nPeer);
}
if (nListenerCount == 0) {
dataNode.remove();
}
if (bLegacyMode) {
return;
}
}
if (bGetChildren) {
for (Node child = formNode.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
this.cleanDataNodes(child, bLegacyMode);
}
}
}
@Override
public void getDeltas(Element delta, XFAList list) {
if (!this.isSameClass(delta)) {
return;
}
FormModel model = (FormModel)this.getModel();
if (model.isLoading()) {
Element deltaOccur;
FormInstanceManager deltaManager = (FormInstanceManager)delta;
ProtoableNode templateNode = this.mTemplateNode;
int nNewCount = 0;
int nStartIndex = deltaManager.getIndex() + 1;
Element deltaParent = deltaManager.getXFAParent();
Node deltaChild = deltaParent.getFirstXFAChild();
for (int nChildIndex = 0; deltaChild != null && nChildIndex != nStartIndex; deltaChild = deltaChild.getNextXFASibling(), ++nChildIndex) {
}
while (deltaChild != null && !deltaChild.isSameClass(XFA.INSTANCEMANAGERTAG)) {
if (deltaChild.isSameClass(templateNode)) {
++nNewCount;
}
deltaChild = deltaChild.getNextXFASibling();
}
if (list != null && delta instanceof Element && (deltaOccur = delta.getElement(XFA.OCCURTAG, true, 0, false, false)) != null) {
Element thisOccur = this.getElement(XFA.OCCURTAG, 0);
Int value = (Int)deltaOccur.getAttribute(XFA.MINTAG, true, false);
if (value != null) {
thisOccur.setAttribute(value, XFA.MINTAG);
}
if ((value = (Int)deltaOccur.getAttribute(XFA.MAXTAG, true, false)) != null) {
thisOccur.setAttribute(value, XFA.MAXTAG);
}
if ((value = (Int)deltaOccur.getAttribute(XFA.INITIALTAG, true, false)) != null) {
thisOccur.setAttribute(value, XFA.INITIALTAG);
}
}
if (nNewCount != this.getCount() && this.canRestoreCount(templateNode, model)) {
this.setInstances(nNewCount, false);
}
}
super.getDeltas(delta, list);
}
boolean instanceManagerPermsCheck() {
if (!this.checkAncestorPerms()) {
return false;
}
for (int nIndex = 0; nIndex < this.mInstances.size(); ++nIndex) {
Element instance = this.mInstances.get(nIndex);
if (instance == null || instance.checkDescendentPerms()) continue;
return false;
}
return true;
}
@Override
public ScriptTable getScriptTable() {
return FormInstanceManagerScript.getScriptTable();
}
private ProtoableNode getTemplateNode() {
return this.mTemplateNode;
}
public void setMatchDescendantsOnly(boolean bDescendantsOnly) {
this.mbMatchDescendantsOnly = bDescendantsOnly;
}
public boolean getMatchDescendantsOnly() {
return this.mbMatchDescendantsOnly;
}
public static interface InstanceListener {
public void preAddInstance();
public void preRemoveInstance(Node var1);
public void preMoveInstance(Node var1);
public void postAddInstance(Node var1);
public void postRemoveInstance(Node var1);
public void postMoveInstance(Node var1);
}
}