LeaderFill.java
7.43 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
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xfa.text;
import com.adobe.xfa.gfx.GFXDriver;
import com.adobe.xfa.text.DispLine;
import com.adobe.xfa.text.DispLineWrapped;
import com.adobe.xfa.text.DispTab;
import com.adobe.xfa.text.DrawParm;
import com.adobe.xfa.text.Glyph;
import com.adobe.xfa.text.GlyphLoc;
import com.adobe.xfa.text.LineHeight;
import com.adobe.xfa.text.TextAttr;
import com.adobe.xfa.text.TextDrawInfo;
import com.adobe.xfa.text.TextMeasurement;
import com.adobe.xfa.text.Units;
import com.adobe.xfa.ut.Angle;
import com.adobe.xfa.ut.CoordPair;
import com.adobe.xfa.ut.Rect;
import com.adobe.xfa.ut.UnitSpan;
abstract class LeaderFill {
private final DrawParm moDrawParm;
private boolean mbSetup;
private DispLineWrapped mpoLine;
private TextAttr mpoAttr;
private DispTab mpoDispTab;
private GlyphLoc mpoGlyphLoc;
private UnitSpan moBasePatternWidth;
private UnitSpan moPatternWidth = UnitSpan.ZERO;
private UnitSpan moPatternStart = UnitSpan.ZERO;
private UnitSpan moTabX;
private UnitSpan moTabWidth;
private UnitSpan moTextOffset;
private boolean mbRenderGlyph;
private boolean mbSuppressAlign;
LeaderFill(DrawParm oDrawParm) {
this.moDrawParm = oDrawParm;
}
boolean setup(DispLineWrapped poLine, TextAttr poAttr, DispTab poDispTab, GlyphLoc poGlyphLoc) {
this.mpoLine = poLine;
this.mpoAttr = poAttr;
this.mpoDispTab = poDispTab;
this.mpoGlyphLoc = poGlyphLoc;
this.moTabWidth = poDispTab.getFillWidth();
if (this.moTabWidth.value() <= 0) {
return false;
}
Glyph oGlyph = this.mpoLine.getGlyph(poGlyphLoc.getGlyphIndex());
float oTabXBase = oGlyph.getDrawX(this.mpoLine) + Units.toFloat(this.mpoLine.getAMin());
this.moTabX = Units.toUnitSpan(oTabXBase);
this.moTextOffset = Units.toUnitSpan(this.mpoLine.dispHeight().textOffset(0));
if (poAttr.leaderPatternWidthEnable()) {
this.moPatternWidth = poAttr.leaderPatternWidth().getLength();
}
if (!this.onSetup()) {
return false;
}
if (this.moPatternWidth.lt(this.moBasePatternWidth)) {
this.moPatternWidth = this.moBasePatternWidth;
}
if (poAttr.leaderAlignEnable() && poAttr.leaderAlign() == 1 && !this.mbSuppressAlign && this.moPatternWidth.value() > 0) {
UnitSpan oRawStart;
CoordPair oAbsPoint = this.driver().offset(false);
oAbsPoint = new CoordPair(oAbsPoint.x().add(this.moTabX), oAbsPoint.y().add(this.textOffset()));
oAbsPoint = this.driver().rotatePoint(oAbsPoint);
UnitSpan oLeft = UnitSpan.ZERO;
UnitSpan oTop = UnitSpan.ZERO;
UnitSpan oRight = UnitSpan.ZERO;
UnitSpan oBottom = UnitSpan.ZERO;
Rect oPage = this.moDrawParm.drawInfo().getPage();
if (oPage != null) {
oLeft = oPage.left();
oTop = oPage.top();
oRight = oPage.right();
oBottom = oPage.bottom();
}
boolean bRTL = this.mpoLine.isRTL();
int nDegrees = this.driver().angle(false).degrees();
if (45 <= nDegrees && nDegrees < 135) {
oRawStart = bRTL ? oAbsPoint.y().subtract(oTop) : oBottom.subtract(oAbsPoint.y());
} else if (135 <= nDegrees && nDegrees < 225) {
oRawStart = bRTL ? oAbsPoint.x().subtract(oLeft) : oRight.subtract(oAbsPoint.x());
} else if (225 <= nDegrees && nDegrees < 315) {
oRawStart = bRTL ? oBottom.subtract(oAbsPoint.y()) : oAbsPoint.y().subtract(oTop);
} else {
UnitSpan unitSpan = oRawStart = bRTL ? oRight.subtract(oAbsPoint.x()) : oAbsPoint.x().subtract(oLeft);
}
if (bRTL) {
oRawStart = oRawStart.subtract(this.moTabWidth);
}
UnitSpan oGrid = new UnitSpan(this.moPatternWidth.units(), - this.moPatternWidth.value());
this.moPatternStart = oRawStart.grid(oGrid);
this.moPatternStart = this.moPatternStart.subtract(oRawStart);
}
if (this.moPatternStart.add(this.moBasePatternWidth).gt(this.moTabWidth)) {
return false;
}
UnitSpan oPatternOffset = UnitSpan.ZERO;
UnitSpan oPatternGap = this.moPatternWidth.subtract(this.moBasePatternWidth);
switch (this.alignment()) {
case 5:
case 11: {
if (!this.mpoLine.isRTL()) break;
oPatternOffset = oPatternGap;
break;
}
case 6:
case 12: {
oPatternOffset = oPatternGap.divide(2);
break;
}
case 7:
case 13: {
if (this.mpoLine.isRTL()) break;
oPatternOffset = oPatternGap;
}
}
this.moPatternStart = this.moPatternStart.add(oPatternOffset);
assert (this.moPatternWidth.value() > 0);
this.mbSetup = true;
return true;
}
boolean render() {
assert (this.mbSetup);
UnitSpan oPatternEnd = this.moPatternStart.add(this.moBasePatternWidth);
do {
UnitSpan oOffsetX = this.mpoLine.isRTL() ? this.moTabWidth.subtract(oPatternEnd) : this.moPatternStart;
this.onRender(this.moTabX.add(oOffsetX));
this.moPatternStart = this.moPatternStart.add(this.moPatternWidth);
} while ((oPatternEnd = this.moPatternStart.add(this.moBasePatternWidth)).lt(this.moTabWidth));
this.mbSetup = false;
return this.mbRenderGlyph;
}
DispLineWrapped line() {
return this.mpoLine;
}
TextAttr attr() {
return this.mpoAttr;
}
DrawParm drawParm() {
return this.moDrawParm;
}
DispTab dispTab() {
return this.mpoDispTab;
}
GlyphLoc glyphLoc() {
return this.mpoGlyphLoc;
}
UnitSpan basePatternWidth() {
return this.moBasePatternWidth;
}
void setBasePatternWidth(UnitSpan oBasePatternWidth) {
this.moBasePatternWidth = oBasePatternWidth;
}
UnitSpan patternWidth() {
return this.moPatternWidth;
}
void setPatternWidth(UnitSpan oPatternWidth) {
this.moPatternWidth = oPatternWidth;
}
UnitSpan patternStart() {
return this.moPatternStart;
}
void setPatternStart(UnitSpan oPatternStart) {
this.moPatternStart = oPatternStart;
}
UnitSpan tabX() {
return this.moTabX;
}
void setTabX(UnitSpan oTabX) {
this.moTabX = oTabX;
}
UnitSpan tabWidth() {
return this.moTabWidth;
}
void setTabWidth(UnitSpan oTabWidth) {
this.moTabWidth = oTabWidth;
}
UnitSpan textOffset() {
return this.moTextOffset;
}
void setTextOffset(UnitSpan oTextOffset) {
this.moTextOffset = oTextOffset;
}
boolean renderGlyph() {
return this.mbRenderGlyph;
}
void setRenderGlyph(boolean bRenderGlyph) {
this.mbRenderGlyph = bRenderGlyph;
}
boolean suppressAlign() {
return this.mbSuppressAlign;
}
void setSuppressAlign(boolean bSuppressAlign) {
this.mbSuppressAlign = bSuppressAlign;
}
GFXDriver driver() {
return this.moDrawParm.driver();
}
int alignment() {
return this.mpoAttr.justifyH();
}
abstract boolean onSetup();
abstract void onRender(UnitSpan var1);
}