SVGNode.java
5.46 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
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xfa.svg;
import com.adobe.xfa.Attribute;
import com.adobe.xfa.Element;
import com.adobe.xfa.Node;
import com.adobe.xfa.StringAttr;
import com.adobe.xfa.svg.SVG;
import com.adobe.xfa.svg.SVGSchema;
import com.adobe.xfa.ut.ExFull;
import com.adobe.xfa.ut.ResId;
import com.adobe.xfa.ut.UnitSpan;
import org.xml.sax.Attributes;
public class SVGNode
extends Element {
public SVGNode(Element parent, Node prevSibling) {
super(parent, prevSibling, null, null, null, null, -1, null);
this.inhibitPrettyPrint(true);
}
@Override
public Attribute defaultAttribute(int eTag) {
Element poParentImpl;
if (!(this.getClassTag() != SVG.TSPANTAG && this.getClassTag() != SVG.ALTGLYPHTAG || eTag != SVG.FILLTAG && eTag != SVG.FONTFAMILYTAG && eTag != SVG.FONTSIZETAG && eTag != SVG.FONTSTYLETAG && eTag != SVG.FONTWEIGHTTAG && eTag != SVG.CODEPAGETAG || (poParentImpl = this.getXFAParent()) == null)) {
return poParentImpl.getAttribute(eTag);
}
return super.defaultAttribute(eTag);
}
@Override
public Attribute getAttribute(int eTag, boolean bPeek, boolean bValidate) {
Element poParentImpl;
Attribute a;
if (!((bPeek || this.getClassTag() != SVG.TSPANTAG) && this.getClassTag() != SVG.ALTGLYPHTAG || (a = super.getAttribute(eTag, true, false)) != null || eTag != SVG.FILLTAG && eTag != SVG.FONTFAMILYTAG && eTag != SVG.FONTSIZETAG && eTag != SVG.FONTSTYLETAG && eTag != SVG.FONTWEIGHTTAG && eTag != SVG.CODEPAGETAG || (poParentImpl = this.getXFAParent()) == null)) {
return poParentImpl.getAttribute(eTag, bPeek, bValidate);
}
return super.getAttribute(eTag, bPeek, bValidate);
}
boolean isRegionGroup(boolean bCheckCaption) {
throw new ExFull(ResId.UNSUPPORTED_OPERATION, "SVGNode#isRegionGroup");
}
public SVGNode getRegionGroup(boolean bCheckCaption) {
int eTag = this.getClassTag();
if (eTag == SVG.GTAG) {
if (this.isRegionGroup(bCheckCaption)) {
return this;
}
SVGNode parent = (SVGNode)this.getXFAParent();
if (parent != null) {
return parent.getRegionGroup(bCheckCaption);
}
} else {
if (eTag == SVG.SVGTAG) {
for (SVGNode child = (SVGNode)this.getFirstXFAChild(); child != null; child = (SVGNode)child.getNextXFASibling()) {
if (child.getClassTag() != SVG.GTAG || !child.isRegionGroup(bCheckCaption)) continue;
return child;
}
return null;
}
SVGNode parent = (SVGNode)this.getXFAParent();
while (parent instanceof SVGNode) {
if (parent.getClassTag() == SVG.SVGTAG) {
return parent.getRegionGroup(bCheckCaption);
}
parent = (SVGNode)parent.getXFAParent();
}
}
return null;
}
void setMeasurement(int eTag, UnitSpan value) {
String sTemp = Integer.toString(value.valueAsUnit(19));
this.setAttribute(new StringAttr(SVGSchema.getSVGSchema().getAtom(eTag), sTemp), eTag);
}
public UnitSpan getMeasurement(int eTag) {
String sNum = this.getAttribute(eTag).toString();
int nNum = Integer.parseInt(sNum);
return new UnitSpan(19, 19, nNum);
}
public void parseTransform(UnitSpan x, UnitSpan y, int r) {
throw new ExFull(ResId.UNSUPPORTED_OPERATION, "SVGNode#parseTransform");
}
void setColor(int eTag, int r, int g, int b) {
if (r < 0) {
r = 0;
}
if (r > 255) {
r = 255;
}
if (g < 0) {
g = 0;
}
if (g > 255) {
g = 255;
}
if (b < 0) {
b = 0;
}
if (b > 255) {
b = 255;
}
int nHexNum = b | g << 8 | r << 16;
String cHexNum = Integer.toString(nHexNum, 16);
this.setAttribute(new StringAttr(SVGSchema.getSVGSchema().getAtom(eTag), cHexNum), eTag);
}
void getColor(int eTag, int r, int g, int b) {
throw new ExFull(ResId.UNSUPPORTED_OPERATION, "SVGNode#getColor");
}
public UnitSpan getSVGWidth() {
SVGNode svg;
for (svg = this; svg != null && !svg.isSameClass(SVG.SVGTAG); svg = (SVGNode)svg.getXFAParent()) {
}
if (svg == null) {
return UnitSpan.ZERO;
}
String sW = svg.getAttribute(SVG.WIDTHTAG).toString();
return new UnitSpan(sW);
}
public UnitSpan getSVGHeight() {
SVGNode svg;
for (svg = this; svg != null && !svg.isSameClass(SVG.SVGTAG); svg = (SVGNode)svg.getXFAParent()) {
}
if (svg == null) {
return UnitSpan.ZERO;
}
String sH = svg.getAttribute(SVG.HEIGHTTAG).toString();
return new UnitSpan(sH);
}
public void storeGlyphs(Object oFontInstance, int[] glyphs, int nGlyphs) {
throw new ExFull(ResId.UNSUPPORTED_OPERATION, "SVGNode#storeGlyphs");
}
public void storeText(Object oFontInstance, String text) {
throw new ExFull(ResId.UNSUPPORTED_OPERATION, "SVGNode#storeText");
}
void getGlyphs(Object oFontInstance, int nGlyphs) {
throw new ExFull(ResId.UNSUPPORTED_OPERATION, "SVGNode#getGlyphs");
}
String getText(Object oFontInstance) {
throw new ExFull(ResId.UNSUPPORTED_OPERATION, "SVGNode#getText");
}
}