LayoutDriver.java
9.54 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
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xfa.layout;
import com.adobe.xfa.Attribute;
import com.adobe.xfa.Element;
import com.adobe.xfa.Measurement;
import com.adobe.xfa.Model;
import com.adobe.xfa.Node;
import com.adobe.xfa.XFA;
import com.adobe.xfa.content.RectangleValue;
import com.adobe.xfa.font.FontInstance;
import com.adobe.xfa.font.GfxTextAttrs;
import com.adobe.xfa.gfx.GFXColour;
import com.adobe.xfa.gfx.GFXDriver;
import com.adobe.xfa.gfx.GFXEnv;
import com.adobe.xfa.gfx.GFXFillAttr;
import com.adobe.xfa.gfx.GFXLineAttr;
import com.adobe.xfa.gfx.GFXMappingList;
import com.adobe.xfa.gfx.GFXTextAttr;
import com.adobe.xfa.layout.LayoutEnv;
import com.adobe.xfa.layout.LayoutHandler;
import com.adobe.xfa.template.formatting.Color;
import com.adobe.xfa.ut.CoordPair;
import com.adobe.xfa.ut.Rect;
import com.adobe.xfa.ut.UnitSpan;
public class LayoutDriver
extends GFXDriver {
protected Rect moRect = Rect.ZERO;
private LayoutEnv moEnv;
private int mnMappingLevel;
public LayoutDriver() {
super(null);
this.moEnv = null;
this.mnMappingLevel = 0;
this.initDeviceUnitsPerInch(1200, 1200);
}
public LayoutDriver(LayoutEnv oEnv) {
super(oEnv);
this.moEnv = oEnv;
this.mnMappingLevel = 0;
this.initDeviceUnitsPerInch(1200, 1200);
}
public void setLayoutEnv(LayoutEnv oEnv) {
this.moEnv = oEnv;
}
@Override
public void absLine(CoordPair oEnd, int eDrawMode) {
LayoutHandler oLayoutHandler = this.layoutHandler();
if (oLayoutHandler == null) {
return;
}
Model model = oLayoutHandler.getModel();
Element oLine = model.createElement(XFA.LINETAG, "line");
switch (this.lineAttr().hand()) {
case 0: {
oLine.setAttribute(1507328, XFA.HANDTAG);
break;
}
case 1: {
oLine.setAttribute(1507329, XFA.HANDTAG);
break;
}
default: {
oLine.setAttribute(1507330, XFA.HANDTAG);
}
}
Element oEdge = oLine.getElement(XFA.EDGETAG, 0);
switch (this.lineAttr().cap()) {
case 0: {
oEdge.setAttribute(327680, XFA.CAPTAG);
break;
}
case 1: {
oEdge.setAttribute(327681, XFA.CAPTAG);
break;
}
default: {
oEdge.setAttribute(327682, XFA.CAPTAG);
}
}
Color oColor = (Color)oEdge.getElement(XFA.COLORTAG, 0);
oColor.setRed(this.lineAttr().colour().r());
oColor.setGreen(this.lineAttr().colour().g());
oColor.setBlue(this.lineAttr().colour().b());
oEdge.setAttribute(new Measurement(this.lineAttr().width()), XFA.THICKNESSTAG);
switch (this.lineAttr().style()) {
case 0: {
break;
}
case 1: {
break;
}
case 2: {
oEdge.setAttribute(3342336, XFA.STROKETAG);
break;
}
case 9: {
oEdge.setAttribute(3342338, XFA.STROKETAG);
break;
}
case 10: {
oEdge.setAttribute(3342337, XFA.STROKETAG);
break;
}
case 11: {
oEdge.setAttribute(3342343, XFA.STROKETAG);
break;
}
case 12: {
oEdge.setAttribute(3342344, XFA.STROKETAG);
}
}
CoordPair oP1 = this.rotatePoint(this.getAbsPosition());
CoordPair oP2 = this.rotatePoint(oEnd);
oLayoutHandler.drawLine(new Measurement(oP1.x()), new Measurement(oP1.y()), new Measurement(oP2.x().subtract(oP1.x())), new Measurement(oP2.y().subtract(oP1.y())), oLine);
this.setAbsPosition(oEnd);
}
@Override
public void absFillRect(Rect oRect, int eDrawMode) {
LayoutHandler oLayoutHandler = this.layoutHandler();
if (oLayoutHandler == null) {
return;
}
Model model = oLayoutHandler.getModel();
RectangleValue oRectangle = (RectangleValue)model.createElement(XFA.RECTANGLETAG, "rectangle");
oRectangle.setAttribute(1507329, XFA.HANDTAG);
Element oFill = oRectangle.getElement(XFA.FILLTAG, 0);
Color oColor = (Color)model.createElement(XFA.COLORTAG, "color");
oColor.setRed(this.fillAttr().colour().r());
oColor.setGreen(this.fillAttr().colour().g());
oColor.setBlue(this.fillAttr().colour().b());
oFill.setElement(oColor, XFA.COLORTAG, 0);
Element oPattern = null;
switch (this.fillAttr().style()) {
case 0:
case 1: {
break;
}
case 2: {
Element oSolid = model.createElement(XFA.SOLIDTAG, "solid");
oFill.setOneOfChild(oSolid);
break;
}
case 3: {
oPattern = oFill.getElement(XFA.PATTERNTAG, 0);
oPattern.setAttribute(-2144796672, XFA.TYPETAG);
break;
}
case 4: {
oPattern = oFill.getElement(XFA.PATTERNTAG, 0);
oPattern.setAttribute(-2144796671, XFA.TYPETAG);
break;
}
case 5: {
oPattern = oFill.getElement(XFA.PATTERNTAG, 0);
oPattern.setAttribute(-2144796670, XFA.TYPETAG);
break;
}
case 6: {
oPattern = oFill.getElement(XFA.PATTERNTAG, 0);
oPattern.setAttribute(-2144796669, XFA.TYPETAG);
break;
}
case 7: {
oPattern = oFill.getElement(XFA.PATTERNTAG, 0);
oPattern.setAttribute(-2144796668, XFA.TYPETAG);
break;
}
case 8: {
oPattern = oFill.getElement(XFA.PATTERNTAG, 0);
oPattern.setAttribute(-2144796667, XFA.TYPETAG);
}
}
Element oEdge = oRectangle.getElement(XFA.EDGETAG, 0);
oEdge.setAttribute(new Measurement(UnitSpan.ZERO), XFA.THICKNESSTAG);
oLayoutHandler.drawRect(new Measurement(oRect.left()), new Measurement(oRect.top()), new Measurement(oRect.width()), new Measurement(oRect.height()), oRectangle);
}
@Override
public void absText(String oText, int eDrawMode) {
LayoutHandler oLayoutHandler = this.layoutHandler();
if (oLayoutHandler == null) {
return;
}
oLayoutHandler.setClipRect(this.moRect);
FontInstance oFontInstance = this.fontInstance();
assert (oFontInstance != null);
GfxTextAttrs oAttrs = new GfxTextAttrs(this.textAttr().colour(), this.textAttr().underline(), this.textAttr().overline(), this.textAttr().strikeout(), UnitSpan.ZERO, 0);
String sNonConst = oText;
oLayoutHandler.handleTextRun(new Measurement(this.getAbsPosition().x()), new Measurement(this.getAbsPosition().y()), new Measurement(new UnitSpan(0, 19)), new Measurement(new UnitSpan(0, 19)), sNonConst, oFontInstance, oAttrs);
this.moRect = Rect.ZERO;
oLayoutHandler.setClipRect(this.moRect);
}
@Override
public void absGlyphs(int[] nGlyphs, int nSize) {
LayoutHandler oLayoutHandler = this.layoutHandler();
if (oLayoutHandler == null) {
return;
}
oLayoutHandler.setClipRect(this.moRect);
FontInstance oFontInstance = this.fontInstance();
assert (oFontInstance != null);
GfxTextAttrs oAttrs = new GfxTextAttrs(this.textAttr().colour(), this.textAttr().underline(), this.textAttr().overline(), this.textAttr().strikeout(), UnitSpan.ZERO, this.glyphOrientation());
oLayoutHandler.handleGlyphRun(new Measurement(this.getAbsPosition().x()), new Measurement(this.getAbsPosition().y()), new Measurement(new UnitSpan(0, 19)), new Measurement(new UnitSpan(0, 19)), nGlyphs, nSize, oFontInstance, oAttrs);
this.moRect = Rect.ZERO;
oLayoutHandler.setClipRect(this.moRect);
}
public void setUnicodeChars(String text, int nSize) {
LayoutHandler poLayoutHandler = this.layoutHandler();
if (poLayoutHandler == null) {
return;
}
poLayoutHandler.handleUnicodeChars(text, nSize);
}
@Override
public void mapGlyphs(GFXMappingList mappingList, boolean bIsRTL) {
LayoutHandler poLayoutHandler = this.layoutHandler();
if (poLayoutHandler == null) {
return;
}
poLayoutHandler.handleGlyphMapping(mappingList, bIsRTL);
}
@Override
public int getMappingLevel() {
return this.mnMappingLevel;
}
public void setMappingLevel(int nSLevel) {
this.mnMappingLevel = nSLevel;
}
@Override
public int height() {
return this.moRect.height().valueAsUnit(3);
}
@Override
public int width() {
return this.moRect.width().valueAsUnit(3);
}
@Override
public boolean interactive() {
return false;
}
@Override
public void setClipRect(Rect oRect) {
this.moRect = oRect;
}
@Override
public void paraHint() {
LayoutHandler oLayoutHandler = this.layoutHandler();
if (oLayoutHandler != null) {
oLayoutHandler.newPara();
}
}
protected LayoutHandler layoutHandler() {
if (this.moEnv != null) {
return this.moEnv.layoutHandler();
}
return null;
}
protected LayoutEnv layoutEnv() {
return this.moEnv;
}
}