TextNode.java
5.13 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
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xfa;
import com.adobe.xfa.*;
import com.adobe.xfa.ut.ExFull;
public class TextNode
extends Chars {
private boolean mbIsFragment;
public TextNode(Element parent, Node prevSibling, String text) {
super(parent, prevSibling, text);
this.setClass("#text", XFA.TEXTNODETAG);
}
public TextNode(Element parent, Node prevSibling, char[] text, int start, int length) {
super(parent, prevSibling, text, start, length);
this.setClass("#text", XFA.TEXTNODETAG);
}
@Override
public Node clone(Element parent) {
return new TextNode(parent, null, this.getValue());
}
public TextNode createProto(Element oParent, String text, boolean bFull) {
assert (oParent != null);
boolean bMute = false;
TextNode oRetNode = null;
try {
Model oModel;
if (oParent != null && !bFull) {
bMute = oParent.isMute();
oParent.mute();
}
if ((oRetNode = (oModel = oParent.getModel()).createTextNode(oParent, oParent.getLastXMLChild(), text)) != null) {
if (this.isTransient() || oParent.isTransient()) {
oRetNode.isTransient(true, true);
}
if (!bFull) {
oRetNode.makeDefault();
} else {
oRetNode.makeNonDefault(false);
}
}
if (!bMute && oParent != null) {
oParent.unMute();
}
}
catch (ExFull oEx) {
if (!bMute && oParent != null) {
oParent.unMute();
}
throw oEx;
}
return oRetNode;
}
public void getDeltas(TextNode delta, XFAList list) {
if (this.isSameClass(delta) && list != null) {
Element parent = this.getXFAParent();
Element deltaParent = delta.getXFAParent();
Delta newDelta = null;
newDelta = delta.getModel().getAppModel() != null && !delta.getModel().getAppModel().getLegacySetting(AppModel.XFA_LEGACY_V32_SCRIPTING) ? new Delta(parent, deltaParent, this, delta, "value") : new Delta(parent, deltaParent, this, delta, "");
list.append(newDelta);
}
}
@Override
public ScriptTable getScriptTable() {
return TextNodeScript.getScriptTable();
}
public String getValue() {
return this.getText();
}
public void setValue(String value, boolean bNotify, boolean bDefault) {
this.setText(value);
if (!bDefault) {
this.makeNonDefault(false);
}
if (bNotify) {
this.notifyPeers(2, "", null);
}
}
public boolean isFragment() {
return this.mbIsFragment;
}
public void isFragment(boolean bFragment) {
Element parent;
this.mbIsFragment = bFragment;
if (!bFragment && (parent = this.getXMLParent()) != null && parent.isFragment()) {
parent.isFragment(false, false);
}
}
@Override
public void makeNonDefault(boolean bRecursive) {
super.makeNonDefault(bRecursive);
if (this.isFragment()) {
this.isFragment(false);
this.isTransient(false, false);
}
}
void restoreDelta(TextNode delta) {
Element parent = this.getXFAParent();
if (parent != null) {
delta.remove();
this.remove();
parent.appendChild(delta, false);
delta.makeNonDefault(false);
}
}
String trimTrailingZeros(String sSource) {
int nKeep = sSource.length();
boolean bRadixFound = false;
for (int i = 0; i < sSource.length(); ++i) {
if (sSource.charAt(i) == '.') {
bRadixFound = true;
nKeep = i;
continue;
}
if (!bRadixFound || !Character.isDigit(sSource.charAt(i)) || sSource.charAt(i) == '0') continue;
nKeep = i + 1;
}
return sSource.substring(0, nKeep);
}
@Override
protected boolean compareVersions(Node oRollbackTextNode, Node oContainer, Node.ChangeLogger oChangeLogger, Object oUserData) {
boolean bMatches = this.compareVersionsBasic(oRollbackTextNode, oContainer, oChangeLogger, oUserData);
if (!bMatches) {
return false;
}
String sValue = ((TextNode)oRollbackTextNode).getValue();
if (!this.getValue().equalsIgnoreCase(sValue)) {
String sSanitizedValue;
String sSanitizedRollback;
bMatches = false;
Element oParent = this.getXFAParent();
if (oParent != null && (oParent.isSameClass(XFA.FLOATTAG) || oParent.isSameClass(XFA.DECIMALTAG)) && (sSanitizedValue = this.trimTrailingZeros(this.getValue())).equalsIgnoreCase(sSanitizedRollback = this.trimTrailingZeros(sValue))) {
bMatches = true;
}
if (!bMatches && oChangeLogger != null) {
this.logValueChangeHelper(oContainer, this.getValue(), oChangeLogger, oUserData);
}
}
return bMatches;
}
}