MarkupIn.java
4.11 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
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xfa.text.markup;
import com.adobe.xfa.font.FontService;
import com.adobe.xfa.text.TextAttr;
import com.adobe.xfa.text.TextField;
import com.adobe.xfa.text.TextGfxSource;
import com.adobe.xfa.text.TextMarkupBase;
import com.adobe.xfa.ut.Storage;
public abstract class MarkupIn {
private static final Byte NULL_BYTE = Byte.valueOf(0);
private final TextAttr moPrevAttr = new TextAttr();
private final TextAttr moPendingAttr = new TextAttr();
private TextMarkupBase mpoBase;
private boolean mbFirstPara = true;
private Storage<Byte> moMBText;
private TextGfxSource moGfxSource;
private boolean mbLegacyBlankLineMode = true;
public abstract void translate();
public void setup(TextMarkupBase poBase, TextGfxSource poGfxSource) {
this.moPrevAttr.setDefault(false);
this.moPendingAttr.setDefault(false);
this.mpoBase = poBase;
if (poGfxSource != null) {
this.moGfxSource = poGfxSource;
}
}
protected MarkupIn() {
}
protected void text(String sText) {
if (sText.length() == 0) {
return;
}
this.commitPending(true);
this.mpoBase.text(sText);
this.mbFirstPara = false;
}
protected void attr(TextAttr oAttr) {
this.moPendingAttr.override(oAttr);
}
protected void mbText(byte[] cText) {
if (cText[0] == 0) {
return;
}
this.commitPending();
if (this.moMBText == null) {
this.moMBText = new Storage<T>();
}
if (this.moMBText.size() == 0) {
this.moMBText.add(NULL_BYTE);
}
int i = 0;
while (cText[i] != 0) {
this.moMBText.removeLast();
this.moMBText.add(Byte.valueOf(cText[i]));
this.moMBText.add(NULL_BYTE);
++i;
}
}
protected String mbText() {
if (this.hasPendingMBText()) {
byte[] bytes = new byte[this.moMBText.size()];
for (int i = 0; i < this.moMBText.size(); ++i) {
Byte b = this.moMBText.get(i);
bytes[i] = b.byteValue();
}
this.moMBText.clear();
return new String(bytes);
}
return "";
}
protected boolean hasPendingMBText() {
return this.moMBText != null && this.moMBText.size() > 0;
}
protected void para() {
if (this.mpoBase.issueFirstPara() || !this.mbFirstPara) {
this.commitPending();
this.mpoBase.para();
}
this.mbFirstPara = false;
}
protected void field(TextField poField) {
this.commitPending(true);
this.mpoBase.field(poField);
if (!this.mbLegacyBlankLineMode) {
this.mbFirstPara = false;
}
}
protected void openScopedBlock() {
this.mpoBase.openScopedBlock();
}
protected void closeScopedBlock() {
this.mpoBase.closeScopedBlock();
}
protected TextMarkupBase posn() {
return this.mpoBase;
}
protected void commitPending(boolean bForceMBText) {
if ((bForceMBText || !this.moPendingAttr.isEmpty()) && this.moMBText != null && this.moMBText.size() > 0) {
this.mpoBase.text(this.mbText());
}
if (!this.moPendingAttr.isEmpty()) {
TextAttr oDiffs = new TextAttr();
this.moPrevAttr.override(this.moPendingAttr, oDiffs);
if (!oDiffs.isEmpty()) {
this.mpoBase.attr(oDiffs);
}
this.moPendingAttr.setDefault(false);
}
}
protected void commitPending() {
this.commitPending(false);
}
protected FontService fontService() {
return this.moGfxSource.getFontService();
}
protected boolean legacyPositioning() {
return this.mpoBase == null ? false : this.mpoBase.legacyPositioning();
}
protected boolean legacyBlankLineMode() {
return this.mbLegacyBlankLineMode;
}
protected void setLegacyBlankLineMode(boolean bLegacyBlankLineMode) {
this.mbLegacyBlankLineMode = bLegacyBlankLineMode;
}
}