PDFOCConfig.java
12.6 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.internal.pdftoolkit.core.cos.CosArray
* com.adobe.internal.pdftoolkit.core.cos.CosName
* com.adobe.internal.pdftoolkit.core.cos.CosObject
* 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.graphics.optionalcontent;
import com.adobe.internal.pdftoolkit.core.cos.CosArray;
import com.adobe.internal.pdftoolkit.core.cos.CosName;
import com.adobe.internal.pdftoolkit.core.cos.CosObject;
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.optionalcontent.PDFOCBaseState;
import com.adobe.internal.pdftoolkit.pdf.graphics.optionalcontent.PDFOCGroup;
import com.adobe.internal.pdftoolkit.pdf.graphics.optionalcontent.PDFOCGroupArray;
import com.adobe.internal.pdftoolkit.pdf.graphics.optionalcontent.PDFOCIntentList;
import com.adobe.internal.pdftoolkit.pdf.graphics.optionalcontent.PDFOCListMode;
import com.adobe.internal.pdftoolkit.pdf.graphics.optionalcontent.PDFOCOrderList;
import com.adobe.internal.pdftoolkit.pdf.graphics.optionalcontent.PDFOCRGBGroupsList;
import com.adobe.internal.pdftoolkit.pdf.graphics.optionalcontent.PDFOCUsageApp;
import com.adobe.internal.pdftoolkit.pdf.graphics.optionalcontent.PDFOCUsageAppList;
public class PDFOCConfig
extends PDFCosDictionary {
protected PDFOCConfig(CosObject cosObject) throws PDFInvalidDocumentException {
super(cosObject);
}
public static PDFOCConfig getInstance(CosObject cosObject) throws PDFInvalidDocumentException {
if (PDFCosObject.checkNullCosObject(cosObject) == null) {
return null;
}
PDFOCConfig pdfObject = PDFCosObject.getCachedInstance(cosObject, PDFOCConfig.class);
if (pdfObject == null) {
pdfObject = new PDFOCConfig(cosObject);
}
return pdfObject;
}
public static PDFOCConfig newInstance(PDFDocument pdfDocument) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return new PDFOCConfig((CosObject)PDFCosObject.newCosDictionary(pdfDocument));
}
public static PDFOCConfig defaultInstance(PDFDocument pdfDocument) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
PDFOCConfig configDict = PDFOCConfig.newInstance(pdfDocument);
configDict.setBaseStateON();
configDict.setIntentView();
configDict.setOrderList(PDFOCOrderList.newInstance(pdfDocument));
configDict.setListModeAllPages();
configDict.setRBGroups(PDFOCRGBGroupsList.newInstance(pdfDocument));
configDict.setLocked(PDFOCGroupArray.newInstance(pdfDocument));
return configDict;
}
public void setName(String name) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryStringValue(ASName.k_Name, name);
}
public String getName() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getDictionaryTextStringValue(ASName.k_Name);
}
public void setCreator(String name) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryStringValue(ASName.k_Creator, name);
}
public String getCreator() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getDictionaryTextStringValue(ASName.k_Creator);
}
public void setBaseStateON() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setBaseState(PDFOCBaseState.ON);
}
public void setBaseStateOFF() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setBaseState(PDFOCBaseState.OFF);
}
public void setBaseStateUnchanged() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setBaseState(PDFOCBaseState.Unchanged);
}
public void setBaseState(PDFOCBaseState state) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryNameValue(ASName.k_BaseState, state.getState());
}
public boolean hasBaseState() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.dictionaryContains(ASName.k_BaseState);
}
public PDFOCBaseState getBaseState() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
ASName state = this.getDictionaryNameValue(ASName.k_BaseState);
return PDFOCBaseState.getInstance(state);
}
public void setIntentView() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
PDFOCIntentList intentList;
try {
intentList = PDFOCIntentList.newInstance(this.getPDFDocument(), ASName.k_View);
}
catch (PDFInvalidParameterException e) {
throw new PDFInvalidDocumentException((Throwable)e);
}
this.setIntent(intentList);
}
public void setIntentDesign() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
PDFOCIntentList intentList;
try {
intentList = PDFOCIntentList.newInstance(this.getPDFDocument(), ASName.k_Design);
}
catch (PDFInvalidParameterException e) {
throw new PDFInvalidDocumentException((Throwable)e);
}
this.setIntent(intentList);
}
public void setIntentAll() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
PDFOCIntentList intentList;
try {
intentList = PDFOCIntentList.newInstance(this.getPDFDocument(), ASName.k_All);
}
catch (PDFInvalidParameterException e) {
throw new PDFInvalidDocumentException((Throwable)e);
}
this.setIntent(intentList);
}
public void addIntent(ASName intent) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosObject obj = this.getDictionaryCosObjectValue(ASName.k_Intent);
if (obj instanceof CosName) {
PDFOCIntentList newList;
try {
newList = PDFOCIntentList.newInstance(this.getPDFDocument(), ((CosName)obj).nameValue());
}
catch (PDFInvalidParameterException e) {
throw new PDFInvalidDocumentException((Throwable)e);
}
this.setIntent(newList);
obj = newList.getCosObject();
}
if (obj instanceof CosArray) {
CosArray arrayObj = (CosArray)obj;
arrayObj.addName(intent);
}
}
public void setIntent(PDFOCIntentList intentList) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryValue(ASName.k_Intent, intentList);
}
public PDFOCIntentList getIntent() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosObject obj = this.getDictionaryCosObjectValue(ASName.k_Intent);
return PDFOCIntentList.getInstance(obj);
}
public void setONList(PDFOCGroupArray ocgs) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryArrayValue(ASName.k_ON, ocgs != null ? ocgs.getCosArray() : null);
}
public PDFOCGroupArray getONList() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
PDFOCGroupArray result = null;
CosArray on = this.getDictionaryArrayValue(ASName.k_ON);
if (on != null) {
result = PDFOCGroupArray.getInstance((CosObject)on);
}
return result;
}
public void setOFFList(PDFOCGroupArray ocgs) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryArrayValue(ASName.k_OFF, ocgs != null ? ocgs.getCosArray() : null);
}
public PDFOCGroupArray getOFFList() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
PDFOCGroupArray result = null;
CosArray on = this.getDictionaryArrayValue(ASName.k_OFF);
if (on != null) {
result = PDFOCGroupArray.getInstance((CosObject)on);
}
return result;
}
public void setASList(PDFOCUsageAppList usageList) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryArrayValue(ASName.k_AS, usageList.getCosArray());
}
public PDFOCUsageAppList getASList() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
PDFOCUsageAppList result = null;
CosArray usages = this.getDictionaryArrayValue(ASName.k_AS);
if (usages != null) {
result = PDFOCUsageAppList.getInstance(usages);
}
return result;
}
public void setOrderList(PDFOCOrderList orderList) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (orderList == null) {
this.removeValue(ASName.k_Order);
} else {
this.setDictionaryArrayValue(ASName.k_Order, orderList.getCosArray());
}
}
public PDFOCOrderList getOrderList() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
PDFOCOrderList result = null;
CosArray order = this.getDictionaryArrayValue(ASName.k_Order);
if (order != null) {
result = PDFOCOrderList.getInstance((CosObject)order);
}
return result;
}
public void setListModeAllPages() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setListMode(PDFOCListMode.AllPages);
}
public void setListModeVisiblePages() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setListMode(PDFOCListMode.VisiblePages);
}
public void setListMode(PDFOCListMode mode) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryNameValue(ASName.k_ListMode, mode.getMode());
}
public PDFOCListMode getListMode() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
ASName mode = this.getDictionaryNameValue(ASName.k_ListMode);
return PDFOCListMode.getInstance(mode);
}
public void setLocked(PDFOCGroupArray ocgs) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryArrayValue(ASName.k_Locked, ocgs != null ? ocgs.getCosArray() : null);
}
public PDFOCGroupArray getLocked() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
PDFOCGroupArray result = null;
CosArray locked = this.getDictionaryArrayValue(ASName.k_Locked);
if (locked != null) {
result = PDFOCGroupArray.getInstance((CosObject)locked);
}
return result;
}
public void setRBGroups(PDFOCRGBGroupsList ocgs) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryArrayValue(ASName.k_RBGroups, ocgs != null ? ocgs.getCosArray() : null);
}
public PDFOCRGBGroupsList getRBGroups() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
PDFOCRGBGroupsList result = null;
CosArray rbgs = this.getDictionaryArrayValue(ASName.k_RBGroups);
if (rbgs != null) {
result = PDFOCRGBGroupsList.getInstance(rbgs);
}
return result;
}
public void remove(PDFOCGroup ocg) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
PDFOCGroupArray offOCGs;
PDFOCGroupArray onOCGs = this.getONList();
if (onOCGs != null && onOCGs.contains(ocg)) {
onOCGs.remove(ocg);
}
if ((offOCGs = this.getOFFList()) != null && offOCGs.contains(ocg)) {
offOCGs.remove(ocg);
}
PDFOCOrderList orderList = this.getOrderList();
orderList.remove(ocg);
PDFOCUsageAppList usageAppList = this.getASList();
for (PDFOCUsageApp usageAppDict : usageAppList) {
usageAppDict.getOCGs().remove(ocg);
}
}
}