BindingNode.java
5.03 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
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xfa.template.binding;
import com.adobe.xfa.Attribute;
import com.adobe.xfa.Element;
import com.adobe.xfa.Model;
import com.adobe.xfa.Node;
import com.adobe.xfa.ProtoableNode;
import com.adobe.xfa.StringAttr;
import com.adobe.xfa.XFA;
import com.adobe.xfa.template.containers.Container;
import com.adobe.xfa.ut.StringUtils;
import org.xml.sax.Attributes;
public class BindingNode
extends ProtoableNode {
private String msAbsoluteDataRef;
public BindingNode(Element parent, Node prevSibling, String uri, String name, String qname, Attributes attrs, int classTag, String className) {
super(parent, prevSibling, null, name, qname, attrs, classTag, className);
}
@Override
public Element clone(Element pParent, boolean bDeep) {
BindingNode oClone = (BindingNode)super.clone(pParent, bDeep);
oClone.msAbsoluteDataRef = this.msAbsoluteDataRef;
return oClone;
}
String getAbsoluteDataRef() {
return this.msAbsoluteDataRef;
}
String getBindingContext() {
return "";
}
/*
* Enabled force condition propagation
* Lifted jumps to return sites
*/
String getContextRef(Element oNode, String sConnectionName, int eUsage) {
String sExistingRef = "";
if (oNode == null) {
return "";
}
for (Element oParent = oNode.getXFAParent(); oParent != null && oParent != this.getModel(); oParent = oParent.getXFAParent()) {
if (oParent.isSameClass(XFA.SUBFORMTAG) || oParent.isSameClass(XFA.FIELDTAG) || oParent.isSameClass(XFA.EXCLGROUPTAG)) {
if (StringUtils.isEmpty(sConnectionName)) {
Element oBind = oParent.getElement(XFA.BINDTAG, false, 0, false, false);
int eMatch = oBind.getEnum(XFA.MATCHTAG);
if (eMatch == 2031619) {
String sRef = oBind.getAttribute(XFA.REFTAG).toString();
sRef = this.cleanRelativeRef(sRef);
String sConnector = "";
if (sRef.length() > 0 && sExistingRef.length() > 0) {
sConnector = ".";
}
sExistingRef = sRef + sConnector + sExistingRef;
} else if (eMatch != 2031616 && (eMatch != 2031617 || oParent.getName() != "")) {
if (!oParent.isSameClass(XFA.SUBFORMTAG) || oParent.getXFAParent() != oParent.getModel()) return "";
sExistingRef = sExistingRef.length() > 0 ? "$record." + sExistingRef : "$record";
}
} else {
Element oConnect = null;
if (oParent.isSameClass(XFA.SUBFORMTAG) || oParent.isSameClass(XFA.FIELDTAG) || oParent.isSameClass(XFA.EXCLGROUPTAG)) {
oConnect = ((Container)oParent).getConnectNode(sConnectionName, eUsage, false);
}
if (oConnect == null) continue;
String sRef = oConnect.getAttribute(XFA.REFTAG).toString();
sRef = this.cleanRelativeRef(sRef);
String sConnector = "";
if (sRef.length() > 0 && sExistingRef.length() > 0) {
sConnector = ".";
}
sExistingRef = sRef + sConnector + sExistingRef;
}
}
if (!this.isAbsoluteDataRef(sExistingRef)) continue;
return sExistingRef;
}
return "";
}
private boolean isAbsoluteDataRef(String sDataRef) {
if (StringUtils.isEmpty(sDataRef)) {
return false;
}
if (sDataRef.charAt(0) == '$') {
if (sDataRef.length() > 1 && sDataRef.charAt(1) == '.') {
return false;
}
} else if (sDataRef.charAt(0) == '!') {
return true;
}
if (sDataRef.startsWith("xfa.datasets.")) {
return true;
}
return false;
}
private String cleanRelativeRef(String sDataRef) {
String sCleanRef = sDataRef;
if (sCleanRef.length() > 1 && sCleanRef.charAt(0) == '$' && sCleanRef.charAt(1) == '.') {
sCleanRef = sCleanRef.substring(2);
}
return sCleanRef;
}
void setRef(String sRef) {
this.msAbsoluteDataRef = "";
this.setAttribute(new StringAttr("ref", sRef), XFA.REFTAG);
}
void updateAbsoluteDataRef() {
}
void updateAbsoluteDataRef(String sRef, String sConnection, int eUsage, boolean bIsPropertyBinding) {
this.msAbsoluteDataRef = sRef;
if (sRef.length() != 0 && !this.isAbsoluteDataRef(sRef)) {
String sContextRef = null;
sContextRef = bIsPropertyBinding ? this.getContextRef(this, sConnection, eUsage) : this.getContextRef(this.getXFAParent(), sConnection, eUsage);
if (sContextRef.length() != 0) {
this.msAbsoluteDataRef = sContextRef + "." + this.cleanRelativeRef(sRef);
}
}
}
}