StrAttr.java
4.02 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
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xfa.text;
import com.adobe.xfa.text.Pkg;
import com.adobe.xfa.text.StrItem;
import com.adobe.xfa.text.TextAttr;
import com.adobe.xfa.text.TextGfxSource;
import com.adobe.xfa.text.markup.MarkupOut;
import java.io.PrintStream;
class StrAttr
extends StrItem {
private int meState;
private TextAttr mpoAttr;
StrAttr() {
super(1);
this.meState = 0;
}
StrAttr(TextAttr poNewAttr) {
this(poNewAttr, null, 0);
}
StrAttr(TextAttr poNewAttr, TextGfxSource poGfxSource) {
this(poNewAttr, poGfxSource, 0);
}
StrAttr(TextAttr poNewAttr, TextGfxSource poGfxSource, int eState) {
super(1);
this.meState = eState;
this.connectToAttr(poNewAttr, poGfxSource);
}
@Override
TextAttr markup(MarkupOut oMarkup, int nStart, int nSize, boolean bFlattenFields, TextAttr poPrevAttr) {
if (this.mpoAttr != null) {
if (!oMarkup.suppressAttributes()) {
if (poPrevAttr == null) {
oMarkup.attr(this.mpoAttr);
} else {
TextAttr oAttr = new TextAttr(this.mpoAttr);
oAttr.dropSame(poPrevAttr, false);
oMarkup.attr(oAttr);
}
}
poPrevAttr = this.mpoAttr;
}
return poPrevAttr;
}
@Override
TextAttr attrAt(int nIndex) {
return this.mpoAttr;
}
@Override
boolean isEqual(StrItem poCompare) {
if (!(poCompare instanceof StrAttr)) {
return false;
}
StrAttr poStrAttr = (StrAttr)poCompare;
if (this.mpoAttr == poStrAttr.mpoAttr) {
return true;
}
if (this.mpoAttr == null || poStrAttr.mpoAttr == null) {
return false;
}
return this.mpoAttr.equals(poStrAttr.mpoAttr);
}
@Override
boolean coalesce(StrItem poAfter, int nIndex) {
StrAttr poNext = (StrAttr)poAfter;
assert (this.mpoAttr != null);
assert (poNext.mpoAttr != null);
TextAttr poNewAttr = new TextAttr(this.mpoAttr);
poNewAttr.override(poNext.mpoAttr, null);
this.mpoAttr = poNewAttr;
if (poNext.meState == 1) {
this.meState = 1;
} else if (this.meState != 2) {
this.meState = 0;
}
return false;
}
@Override
boolean canCoalesce(StrItem poAfter) {
StrAttr poNext = (StrAttr)poAfter;
if (this.mpoAttr == null || poNext.mpoAttr == null) {
return false;
}
if (this.meState == 1 && poNext.meState == 2 && this.mpoAttr != poNext.mpoAttr) {
return false;
}
return true;
}
@Override
StrItem cloneItem(TextGfxSource oGfxSource) {
return new StrAttr(this.mpoAttr, oGfxSource, this.meState);
}
@Override
int attrState() {
return this.meState;
}
@Override
void attrState(int eNewState) {
this.meState = eNewState;
}
@Override
void overrideAttr(TextAttr oOverride) {
if (this.mpoAttr != null) {
TextAttr poNewAttr = new TextAttr(this.mpoAttr);
poNewAttr.override(oOverride, null);
this.mpoAttr = poNewAttr;
}
}
@Override
void gfxSource(TextGfxSource oGfxSource) {
if (this.mpoAttr != null && oGfxSource != this.mpoAttr.gfxSource()) {
TextAttr poOldAttr = this.mpoAttr;
this.connectToAttr(poOldAttr, oGfxSource);
}
}
@Override
void debug(int indent) {
String prefix = Pkg.doIndent(indent + 1);
System.out.println(prefix + "Attribute");
if (this.mpoAttr != null) {
this.mpoAttr.debug();
}
}
private void connectToAttr(TextAttr poNewAttr, TextGfxSource poGfxSource) {
this.mpoAttr = poNewAttr == null ? new TextAttr(TextAttr.defaultAttr(false)) : (poGfxSource != null && poNewAttr.gfxSource() != poGfxSource ? new TextAttr(poNewAttr, poGfxSource) : poNewAttr);
}
}