PDFAppearanceCharacteristics.java
15.3 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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.internal.pdftoolkit.core.cos.CosArray
* com.adobe.internal.pdftoolkit.core.cos.CosDictionary
* com.adobe.internal.pdftoolkit.core.cos.CosObject
* com.adobe.internal.pdftoolkit.core.cos.CosStream
* com.adobe.internal.pdftoolkit.core.exceptions.PDFIOException
* com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidDocumentException
* com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidParameterException
* com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityException
* com.adobe.internal.pdftoolkit.core.types.ASName
*/
package com.adobe.internal.pdftoolkit.pdf.interactive.annotation;
import com.adobe.internal.pdftoolkit.core.cos.CosArray;
import com.adobe.internal.pdftoolkit.core.cos.CosDictionary;
import com.adobe.internal.pdftoolkit.core.cos.CosObject;
import com.adobe.internal.pdftoolkit.core.cos.CosStream;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFIOException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidDocumentException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidParameterException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityException;
import com.adobe.internal.pdftoolkit.core.types.ASName;
import com.adobe.internal.pdftoolkit.pdf.document.PDFCosDictionary;
import com.adobe.internal.pdftoolkit.pdf.document.PDFCosObject;
import com.adobe.internal.pdftoolkit.pdf.document.PDFDocument;
import com.adobe.internal.pdftoolkit.pdf.graphics.PDFRotation;
import com.adobe.internal.pdftoolkit.pdf.graphics.xobject.PDFXObject;
import com.adobe.internal.pdftoolkit.pdf.graphics.xobject.PDFXObjectFactory;
import com.adobe.internal.pdftoolkit.pdf.graphics.xobject.PDFXObjectForm;
import com.adobe.internal.pdftoolkit.pdf.interactive.annotation.PDFIconFit;
public class PDFAppearanceCharacteristics
extends PDFCosDictionary {
private static final ASName k_R = ASName.create((String)"R");
private static final ASName k_BC = ASName.create((String)"BC");
private static final ASName k_BG = ASName.create((String)"BG");
private static final ASName k_CA = ASName.create((String)"CA");
private static final ASName k_RC = ASName.create((String)"RC");
private static final ASName k_AC = ASName.create((String)"AC");
private static final ASName k_I = ASName.create((String)"I");
private static final ASName k_RI = ASName.create((String)"RI");
private static final ASName k_IX = ASName.create((String)"IX");
private static final ASName k_IF = ASName.create((String)"IF");
private static final ASName k_TP = ASName.create((String)"TP");
private PDFAppearanceCharacteristics(CosObject cosObject) throws PDFInvalidDocumentException {
super(cosObject);
}
public static PDFAppearanceCharacteristics getInstance(CosObject cosObject) throws PDFInvalidDocumentException {
if (PDFCosObject.checkNullCosObject(cosObject) == null) {
return null;
}
PDFAppearanceCharacteristics pdfObject = PDFCosObject.getCachedInstance(cosObject, PDFAppearanceCharacteristics.class);
if (pdfObject == null) {
pdfObject = new PDFAppearanceCharacteristics(cosObject);
}
return pdfObject;
}
public static PDFAppearanceCharacteristics newInstance(PDFDocument pdfDocument) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosDictionary cosObject = PDFCosObject.newCosDictionary(pdfDocument);
return new PDFAppearanceCharacteristics((CosObject)cosObject);
}
public boolean hasRotation() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.dictionaryContains(k_R);
}
public PDFRotation getRotation() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (!this.hasRotation()) {
return PDFRotation.ROTATE_0;
}
try {
return PDFRotation.getInstance(this.getDictionaryIntValue(k_R));
}
catch (PDFInvalidParameterException e) {
throw new PDFInvalidDocumentException("Unable to retrieve rotation value from dictionary.", (Throwable)e);
}
}
public void setRotation(PDFRotation angle) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryIntValue(k_R, angle.getValue());
}
public boolean hasBorderColor() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.dictionaryContains(k_BC);
}
public double[] getBorderColor() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (!this.hasBorderColor()) {
return null;
}
return this.getDictionaryArrayValue(k_BC).getArrayDouble();
}
public void setBorderColor(double[] color) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (color != null) {
CosArray cosArray = PDFCosObject.newCosArray(this.getPDFDocument());
for (int i = 0; i < color.length; ++i) {
cosArray.addDouble(color[i]);
}
this.setDictionaryArrayValue(k_BC, cosArray);
} else {
this.removeValue(k_BC);
}
}
public boolean hasBackgroundColor() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.dictionaryContains(k_BG);
}
public double[] getBackgroundColor() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (!this.hasBackgroundColor()) {
return null;
}
return this.getDictionaryArrayValue(k_BG).getArrayDouble();
}
public void setBackgroundColor(double[] color) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (color != null) {
CosArray cosArray = PDFCosObject.newCosArray(this.getPDFDocument());
for (int i = 0; i < color.length; ++i) {
cosArray.addDouble(color[i]);
}
this.setDictionaryArrayValue(k_BG, cosArray);
} else {
this.removeValue(k_BG);
}
}
public boolean hasNormalCaption() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.dictionaryContains(k_CA);
}
public String getNormalCaption() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (!this.hasNormalCaption()) {
return null;
}
return this.getDictionaryTextStringValue(k_CA);
}
public void setNormalCaption(String caption) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryStringValue(k_CA, caption);
}
public boolean hasRolloverCaption() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.dictionaryContains(k_RC);
}
public String getRolloverCaption() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (!this.hasRolloverCaption()) {
return null;
}
return this.getDictionaryTextStringValue(k_RC);
}
public void setRolloverCaption(String caption) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryStringValue(k_RC, caption);
}
public boolean hasAlternateCaption() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.dictionaryContains(k_AC);
}
public String getAlternateCaption() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (!this.hasAlternateCaption()) {
return null;
}
return this.getDictionaryTextStringValue(k_AC);
}
public void setAlternateCaption(String caption) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryStringValue(k_AC, caption);
}
public boolean hasNormalIcon() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.dictionaryContains(k_I);
}
public PDFXObjectForm getNormalIcon() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (!this.hasNormalIcon()) {
return null;
}
return PDFXObjectForm.getInstance((CosObject)this.getCosDictionary().getCosStream(k_I));
}
public void setNormalIcon(PDFXObject xObject) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (xObject != null) {
this.getCosDictionary().put(k_I, xObject.getCosObject());
} else {
this.removeValue(k_I);
}
}
public boolean hasRolloverIcon() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.dictionaryContains(k_RI);
}
public PDFXObject getRolloverIcon() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (!this.hasRolloverIcon()) {
return null;
}
return PDFXObjectFactory.getInstance((CosObject)this.getCosDictionary().getCosStream(k_RI));
}
public void setRolloverIcon(PDFXObject xObject) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (xObject != null) {
this.getCosDictionary().put(k_RI, xObject.getCosObject());
} else {
this.removeValue(k_RI);
}
}
public boolean hasAlternateIcon() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.dictionaryContains(k_IX);
}
public PDFXObject getAlternateIcon() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (!this.hasAlternateIcon()) {
return null;
}
return PDFXObjectFactory.getInstance((CosObject)this.getCosDictionary().getCosStream(k_IX));
}
public void setAlternateIcon(PDFXObject xObject) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (xObject != null) {
this.getCosDictionary().put(k_IX, xObject.getCosObject());
} else {
this.removeValue(k_IX);
}
}
public boolean hasIconFit() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.dictionaryContains(k_IF);
}
public PDFIconFit getIconFit() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return PDFIconFit.getInstance(this.getDictionaryCosObjectValue(ASName.k_IF));
}
public void setIconFit(PDFIconFit fit) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryValue(k_IF, fit);
}
public boolean hasCaptionPosition() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.dictionaryContains(k_TP);
}
public CaptionPosition getCaptionPosition() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (!this.hasCaptionPosition()) {
return CaptionPosition.kNoIcon_CaptionOnly;
}
int captionPosition = this.getDictionaryIntValue(k_TP);
try {
return CaptionPosition.getInstance(captionPosition);
}
catch (PDFInvalidParameterException e) {
throw new PDFInvalidDocumentException("Invalid Caption Position in document.", (Throwable)e);
}
}
public void setCaptionPosition(int position) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
try {
CaptionPosition.getInstance(position);
}
catch (PDFInvalidParameterException e) {
throw new PDFInvalidDocumentException("Invalid Caption Position in document.", (Throwable)e);
}
}
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
public static enum CaptionPosition {
kNoIcon_CaptionOnly(0, "No icon; caption only"),
kNoCaption_IconOnly(1, "No caption; icon only"),
kCaptionBelowIcon(2, "Caption below the icon"),
kCaptionAboveIcon(3, "Caption above the icon"),
kCaptionRightOfIcon(4, "Caption to the right of icon"),
kCaptionLeftOfIcon(5, "Caption to the left of icon"),
kCaptionOverlaidOnIcon(6, "Caption overlaid directly on the icon");
private final int position;
private final String description;
private CaptionPosition(int value, String description) {
this.position = value;
this.description = description;
}
private static CaptionPosition getInstance(int value) throws PDFInvalidParameterException {
switch (value) {
case 0: {
return kNoIcon_CaptionOnly;
}
case 1: {
return kNoCaption_IconOnly;
}
case 2: {
return kCaptionBelowIcon;
}
case 3: {
return kCaptionAboveIcon;
}
case 4: {
return kCaptionRightOfIcon;
}
case 5: {
return kCaptionLeftOfIcon;
}
case 6: {
return kCaptionOverlaidOnIcon;
}
}
throw new PDFInvalidParameterException("unrecognized caption position value");
}
public int getValue() {
return this.position;
}
public String toString() {
return this.description;
}
}
public static final class NormalCaptionForCheckAndRadio {
private final String value;
public static final NormalCaptionForCheckAndRadio StyleCheck = new NormalCaptionForCheckAndRadio("4");
public static final NormalCaptionForCheckAndRadio StyleCross = new NormalCaptionForCheckAndRadio("8");
public static final NormalCaptionForCheckAndRadio StyleDiamond = new NormalCaptionForCheckAndRadio("u");
public static final NormalCaptionForCheckAndRadio StyleCircle = new NormalCaptionForCheckAndRadio("l");
public static final NormalCaptionForCheckAndRadio StyleStar = new NormalCaptionForCheckAndRadio("H");
public static final NormalCaptionForCheckAndRadio StyleSquare = new NormalCaptionForCheckAndRadio("n");
private NormalCaptionForCheckAndRadio(String value) {
this.value = value;
}
public String getValue() {
return this.value;
}
public static NormalCaptionForCheckAndRadio getInstance(String value) throws PDFInvalidDocumentException {
if (value.equals(StyleCheck.getValue())) {
return StyleCheck;
}
if (value.equals(StyleCross.getValue())) {
return StyleCross;
}
if (value.equals(StyleDiamond.getValue())) {
return StyleDiamond;
}
if (value.equals(StyleCircle.getValue())) {
return StyleCircle;
}
if (value.equals(StyleStar.getValue())) {
return StyleStar;
}
if (value.equals(StyleSquare.getValue())) {
return StyleSquare;
}
throw new PDFInvalidDocumentException("Unknow /CA value for check box or radio button.");
}
}
}