CosObject.java
10.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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.internal.io.ByteWriterFactory
* com.adobe.internal.io.ByteWriterFactory$Fixed
* com.adobe.internal.io.stream.InputByteStream
* com.adobe.internal.io.stream.OutputByteStream
* com.adobe.internal.io.stream.StreamManager
*/
package com.adobe.internal.pdftoolkit.core.cos;
import com.adobe.internal.io.ByteWriterFactory;
import com.adobe.internal.io.stream.InputByteStream;
import com.adobe.internal.io.stream.OutputByteStream;
import com.adobe.internal.io.stream.StreamManager;
import com.adobe.internal.pdftoolkit.core.cos.CosContainer;
import com.adobe.internal.pdftoolkit.core.cos.CosDocument;
import com.adobe.internal.pdftoolkit.core.cos.CosLinearization;
import com.adobe.internal.pdftoolkit.core.cos.CosObjectInfo;
import com.adobe.internal.pdftoolkit.core.cos.CosObjectStream;
import com.adobe.internal.pdftoolkit.core.cos.CosString;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFCosParseException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFCosUnexpectedTypeException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFIOException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityException;
import com.adobe.internal.pdftoolkit.core.types.ASHexString;
import com.adobe.internal.pdftoolkit.core.types.ASName;
import com.adobe.internal.pdftoolkit.core.types.ASString;
import com.adobe.internal.pdftoolkit.core.util.ByteOps;
import java.io.IOException;
public abstract class CosObject {
private CosDocument mDoc;
private CosObjectInfo mInfo;
public static final int t_Null = 0;
public static final int t_Numeric = 1;
public static final int t_Boolean = 2;
public static final int t_Name = 3;
public static final int t_String = 4;
public static final int t_Array = 5;
public static final int t_Dictionary = 6;
public static final int t_Stream = 7;
public static final int t_ObjectRef = 8;
public static final int t_KeyAbsent = 9;
public static final int DIRECT = 0;
public static final int INDIRECT = 1;
protected boolean repaired = false;
CosObject(CosDocument doc, CosObjectInfo info) {
this.mDoc = doc;
if (info != null && info.getObjNum() != 0) {
this.mInfo = info;
this.mInfo.setObject(this);
}
}
abstract void writeOut(OutputByteStream var1, boolean var2, boolean var3) throws PDFCosParseException, IOException, PDFSecurityException, PDFIOException;
void writeOut(OutputByteStream outStream) throws PDFCosParseException, IOException, PDFSecurityException, PDFIOException {
this.writeOut(outStream, false, false);
}
void close() throws IOException {
this.mDoc = null;
this.mInfo = null;
}
void release() throws IOException {
this.markNotDirty();
}
public abstract int getType();
public abstract Object getValue() throws PDFCosParseException, PDFIOException, PDFSecurityException;
public boolean isIndirect() {
return this.mInfo != null;
}
public int getObjNum() {
if (this.mInfo != null) {
return this.mInfo.getObjNum();
}
return 0;
}
public int getObjGen() {
if (this.mInfo != null) {
return this.mInfo.getObjGen();
}
return -1;
}
public long getObjEOF() {
if (this.mInfo == null) {
CosContainer parentObj = null;
if (this instanceof CosContainer) {
parentObj = ((CosContainer)this).getParentObj();
}
if (this instanceof CosString) {
parentObj = ((CosString)this).getParentObj();
}
if (parentObj == null) {
return 0;
}
return this.mDoc.getObjEOF(parentObj);
}
return this.mDoc.getObjEOF(this);
}
public int getObjRevision() {
if (this.mInfo == null) {
CosContainer parentObj = null;
if (this instanceof CosContainer) {
parentObj = ((CosContainer)this).getParentObj();
}
if (this instanceof CosString) {
parentObj = ((CosString)this).getParentObj();
}
if (parentObj == null) {
return -1;
}
return this.mDoc.getObjRevision(parentObj);
}
return this.mDoc.getObjRevision(this);
}
public long getObjPos() {
if (this.mInfo == null) {
CosContainer parentObj = null;
if (this instanceof CosContainer) {
parentObj = ((CosContainer)this).getParentObj();
}
if (this instanceof CosString) {
parentObj = ((CosString)this).getParentObj();
}
if (parentObj == null) {
return 0;
}
return this.mDoc.getObjPos(parentObj);
}
return this.mDoc.getObjPos(this);
}
public boolean isCompressed() {
if (this.mInfo == null) {
return false;
}
return this.mInfo.isCompressed();
}
boolean flushCachedObject() {
if (this.mInfo == null) {
return false;
}
if (!this.mInfo.flushCachedObject()) {
return false;
}
this.mInfo = null;
return true;
}
boolean markNotDirty() {
if (this.mInfo == null) {
return false;
}
return this.mInfo.markNotDirty();
}
public int intValue() {
throw new PDFCosUnexpectedTypeException("expected CosNumeric");
}
public long longValue() {
throw new PDFCosUnexpectedTypeException("expected CosNumeric");
}
public double doubleValue() {
throw new PDFCosUnexpectedTypeException("expected CosNumeric");
}
public Number numberValue() {
throw new PDFCosUnexpectedTypeException("expected CosNumeric");
}
public boolean booleanValue() {
throw new PDFCosUnexpectedTypeException("expected CosBoolean");
}
public ASName nameValue() {
throw new PDFCosUnexpectedTypeException("expected CosName");
}
public ASString stringValue() throws PDFSecurityException {
throw new PDFCosUnexpectedTypeException("expected CosString");
}
public ASHexString hexStringValue() throws PDFSecurityException {
throw new PDFCosUnexpectedTypeException("expected CosString");
}
public String textValue() throws PDFSecurityException {
throw new PDFCosUnexpectedTypeException("expected CosString or CosName");
}
byte[] getObjectEncryptionKey(boolean write) {
CosLinearization cosLin;
byte[] key = new byte[5];
int objNum = this.getInfo().getObjNum();
int gen = this.getInfo().getObjGen();
if (!write && (cosLin = this.getDocument().getLinearization()) != null && !(this instanceof CosObjectStream)) {
objNum = cosLin.mapNewToOldObjNum(objNum);
gen = cosLin.mapNewToOldObjGen(objNum);
}
System.arraycopy(ByteOps.splitInt2Bytes(objNum, 3), 0, key, 0, 3);
System.arraycopy(ByteOps.splitInt2Bytes(gen, 2), 0, key, 3, 2);
return key;
}
public CosDocument getDocument() {
return this.mDoc;
}
public StreamManager getStreamManager() {
return this.getDocument().getStreamManager();
}
CosObjectInfo getInfo() {
return this.mInfo;
}
void setInfo(CosObjectInfo info) {
this.mInfo = info;
}
public boolean isDirty() {
if (this.mInfo != null) {
return this.mInfo.isDirty();
}
return false;
}
public String toString() {
return this.toString(false);
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
* Loose catch block
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
* Lifted jumps to return sites
*/
protected String toString(boolean inDebug) {
InputByteStream stream = null;
try {
OutputByteStream outStream = this.getStreamManager().getOutputByteStreamClearTemp(ByteWriterFactory.Fixed.GROWABLE, 10000);
this.writeOut(outStream, true, inDebug);
stream = outStream.closeAndConvert();
StringBuilder string22222 = new StringBuilder((int)stream.length());
while (stream.bytesAvailable() > 0) {
string22222.append((char)stream.read());
}
String string = string22222.toString();
Object var7_10 = null;
if (stream == null) return string;
try {
stream.close();
return string;
}
catch (IOException e) {
return e.toString();
}
catch (PDFException e) {
String string22222 = e.toString();
Object var7_11 = null;
if (stream == null) return string22222;
try {}
catch (IOException e) {
return e.toString();
}
stream.close();
return string22222;
}
catch (IOException e2) {
String string22222 = e2.toString();
Object var7_12 = null;
if (stream == null) return string22222;
try {}
catch (IOException e) {
return e.toString();
}
stream.close();
return string22222;
}
}
catch (Throwable throwable) {
Object var7_13 = null;
if (stream == null) throw throwable;
try {}
catch (IOException e) {
return e.toString();
}
stream.close();
throw throwable;
}
}
public abstract boolean equals(CosObject var1);
public boolean equals(Object value) {
if (!(value instanceof CosObject)) {
return false;
}
return this.equals((CosObject)value);
}
void setRepaired(boolean repaired) {
this.repaired = repaired;
this.mDoc.setDocumentCosLevelRepaired();
}
boolean isRepaired() {
return this.repaired;
}
}