TextContext.java
4.65 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.text;
import com.adobe.xfa.gfx.GFXMappingList;
import com.adobe.xfa.text.AFEAttrMap;
import com.adobe.xfa.text.DispLineWrapped;
import com.adobe.xfa.text.DispMapSet;
import com.adobe.xfa.text.LineDesc;
import com.adobe.xfa.text.LocaleInfo;
import com.adobe.xfa.text.MappingManager;
import com.adobe.xfa.text.TextFrame;
import com.adobe.xfa.text.TextIntArray;
import com.adobe.xfa.ut.LcLocale;
import java.io.FileWriter;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class TextContext {
private static final int BREAK_CANDIDATE_MIN = 100;
private DispMapSet mpoDisposableMaps;
private boolean mbMapsCheckedOut;
private boolean[] moBreakCandidates;
private final Map<String, LocaleInfo> moLocalePool = new HashMap<String, LocaleInfo>();
private final TextIntArray moAccentRun = new TextIntArray();
private final TextIntArray moGlyphArray = new TextIntArray();
private GFXMappingList mpoMappingList;
private MappingManager mMappingManager;
private AFEAttrMap mAFEAttrMap;
private FileWriter mDebugFile;
private static final boolean gEnableDebug = false;
public TextContext() {
this.mAFEAttrMap = new AFEAttrMap(this);
}
public void detach() {
if (this.mDebugFile != null) {
try {
this.mDebugFile.write(this.mAFEAttrMap.toString());
this.mDebugFile.write(10);
}
catch (IOException e) {
// empty catch block
}
try {
this.mDebugFile.close();
}
catch (IOException e) {
// empty catch block
}
}
}
LocaleInfo lookupLocale(String sLocaleName) {
LocaleInfo oLocaleInfo = this.moLocalePool.get(sLocaleName);
if (oLocaleInfo != null) {
return oLocaleInfo;
}
LcLocale poLocale = new LcLocale(sLocaleName);
oLocaleInfo = new LocaleInfo(poLocale, poLocale.isBIDI(), poLocale.isIdeographic(), poLocale.needsDictionaryBreaking(), 1);
this.moLocalePool.put(sLocaleName, oLocaleInfo);
return oLocaleInfo;
}
DispMapSet getDisposableMaps() {
if (this.mpoDisposableMaps == null) {
this.mpoDisposableMaps = new DispMapSet();
}
if (this.mbMapsCheckedOut) {
return new DispMapSet();
}
this.mbMapsCheckedOut = true;
return this.mpoDisposableMaps;
}
void releaseDisposableMaps(DispMapSet poMaps) {
if (poMaps == this.mpoDisposableMaps) {
this.mbMapsCheckedOut = false;
}
}
boolean[] getBreakCandidates(int nCount, int nPreserve) {
if (nCount < 100) {
nCount = 100;
}
if (this.moBreakCandidates == null) {
assert (nPreserve == 0);
this.moBreakCandidates = new boolean[nCount];
} else if (nCount > this.moBreakCandidates.length) {
assert (nPreserve <= this.moBreakCandidates.length);
boolean[] newCandidates = new boolean[nCount];
for (int i = 0; i < nPreserve; ++i) {
newCandidates[i] = this.moBreakCandidates[i];
}
this.moBreakCandidates = newCandidates;
}
return this.moBreakCandidates;
}
int[] getAccentRun(int size) {
return this.moAccentRun.setSize(size, true);
}
int[] getGlyphArray() {
return this.moGlyphArray.getArray();
}
int[] getGlyphArray(int size) {
return this.moGlyphArray.setSize(size, true);
}
GFXMappingList getMappingList() {
if (this.mpoMappingList == null) {
this.mpoMappingList = new GFXMappingList();
}
return this.mpoMappingList;
}
DispLineWrapped allocateWrappedLine(TextFrame poFrame, LineDesc oLineDesc) {
DispLineWrapped poLine = new DispLineWrapped();
poLine.initialize(poFrame, oLineDesc);
return poLine;
}
void releaseWrappedLine(DispLineWrapped poLine) {
}
MappingManager getMappingManager() {
if (this.mMappingManager == null) {
this.mMappingManager = new MappingManager();
}
return this.mMappingManager;
}
AFEAttrMap getAFEAttrMap() {
return this.mAFEAttrMap;
}
boolean debug() {
return this.mDebugFile != null;
}
void debug(String data) {
if (this.mDebugFile != null) {
try {
this.mDebugFile.write(data);
this.mDebugFile.write(10);
}
catch (IOException e) {
// empty catch block
}
}
}
}