ImageValue.java
4.49 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
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xfa.content;
import com.adobe.xfa.AppModel;
import com.adobe.xfa.Attribute;
import com.adobe.xfa.Element;
import com.adobe.xfa.Node;
import com.adobe.xfa.ProtoableNode;
import com.adobe.xfa.ScriptTable;
import com.adobe.xfa.StringAttr;
import com.adobe.xfa.XFA;
import com.adobe.xfa.content.Content;
import com.adobe.xfa.content.ImageScript;
import com.adobe.xfa.ut.Base64;
import com.adobe.xfa.ut.StringUtils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.xml.sax.Attributes;
public final class ImageValue
extends Content {
private List<String> mpoImageSearchPath;
public ImageValue(Element parent, Node prevSibling) {
super(parent, prevSibling, null, "image", "image", null, XFA.IMAGETAG, "image");
}
@Override
public Attribute defaultAttribute(int eTag) {
if (eTag == XFA.CONTENTTYPETAG) {
return new StringAttr("contentType", "image/*");
}
return super.defaultAttribute(eTag);
}
@Override
public ProtoableNode createProto(Element parent, boolean bFull) {
ProtoableNode proto = super.createProto(parent, bFull);
if (proto instanceof ImageValue && this.getAppModel().getIsFragmentDoc()) {
ImageValue imageProto = (ImageValue)proto;
AppModel appModel = this.getAppModel();
List<String> thisSearchPath = this.getImageSearchPath();
List<String> fragmentSearchPath = appModel.getFragmentSearchPath();
if (fragmentSearchPath != null || thisSearchPath != null) {
ArrayList<String> concatenated = new ArrayList<String>();
if (thisSearchPath != null) {
concatenated.addAll(thisSearchPath);
}
if (fragmentSearchPath != null && fragmentSearchPath.size() > 0) {
concatenated.addAll(fragmentSearchPath);
}
imageProto.mpoImageSearchPath = concatenated;
}
}
return proto;
}
@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
return super.equals(object) && this.getValue().equals(((ImageValue)object).getValue());
}
@Override
public int hashCode() {
return super.hashCode() ^ this.getValue().hashCode();
}
private List<String> getImageSearchPath() {
return this.mpoImageSearchPath;
}
@Override
public boolean getIsNull() {
if (this.isPropertySpecified(XFA.HREFTAG, true, 0)) {
Attribute attr;
String sSource = "";
sSource = this.getAttribute(XFA.HREFTAG).toString();
if (!(StringUtils.isEmpty(sSource) || (attr = this.getXsiNilAttribute()) != null && attr.getAttrValue().equals("true"))) {
return false;
}
}
return super.getIsNull();
}
@Override
public ScriptTable getScriptTable() {
return ImageScript.getScriptTable();
}
public String getValue() {
String sSource = "";
boolean bImageIsALink = this.isPropertySpecified(XFA.HREFTAG, true, 0);
if (bImageIsALink) {
sSource = this.getAttribute(XFA.HREFTAG).toString();
}
if (!bImageIsALink || StringUtils.isEmpty(sSource)) {
sSource = this.getStrValue();
}
return sSource;
}
@Override
public void setAttribute(Attribute oAttr, int eTag) {
super.setAttribute(oAttr, eTag);
if (eTag == XFA.HREFTAG && oAttr != null) {
this.setStrValue("", true, false);
}
}
public void setValue(byte[] pImageBuffer, String sContentType) {
this.setAttribute(new StringAttr("href", ""), XFA.HREFTAG);
this.setAttribute(new StringAttr("contentType", sContentType), XFA.CONTENTTYPETAG);
this.setAttribute(3735553, XFA.TRANSFERENCODINGTAG);
String sBase64 = Base64.encode(pImageBuffer, true);
this.setStrValue(sBase64, true, false);
}
public void setValue(String sB64, String sContentType) {
this.setAttribute(new StringAttr("href", ""), XFA.HREFTAG);
if (!StringUtils.isEmpty(sContentType)) {
this.setAttribute(new StringAttr("contentType", sContentType), XFA.CONTENTTYPETAG);
}
this.setAttribute(3735553, XFA.TRANSFERENCODINGTAG);
this.setStrValue(sB64, true, false);
}
@Override
public String toString() {
return this.getValue();
}
}