PDFOCObject.java
5.16 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.internal.pdftoolkit.core.cos.CosDictionary
* 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.PDFSecurityException
* com.adobe.internal.pdftoolkit.core.types.ASName
*/
package com.adobe.internal.pdftoolkit.pdf.graphics.optionalcontent;
import com.adobe.internal.pdftoolkit.core.cos.CosDictionary;
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.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.graphics.optionalcontent.PDFOCGroup;
import com.adobe.internal.pdftoolkit.pdf.graphics.optionalcontent.PDFOCMembership;
import com.adobe.internal.pdftoolkit.pdf.graphics.xobject.PDFXObject;
import com.adobe.internal.pdftoolkit.pdf.interactive.annotation.PDFAnnotation;
public abstract class PDFOCObject
extends PDFCosDictionary {
protected PDFOCObject(CosObject cosObject) throws PDFInvalidDocumentException {
super(cosObject);
}
public static PDFOCObject getInstance(CosObject cosObject) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (PDFCosObject.checkNullCosObject(cosObject) == null) {
return null;
}
if (!(cosObject instanceof CosDictionary)) {
throw new PDFInvalidDocumentException("CosDictionary expected");
}
ASName type = ((CosDictionary)cosObject).getName(ASName.k_Type);
if (type == null) {
return null;
}
PDFOCObject result = null;
if (type.equals((Object)ASName.k_OCG)) {
result = PDFOCGroup.getInstance(cosObject);
} else if (type.equals((Object)ASName.k_OCMD)) {
result = PDFOCMembership.getInstance(cosObject);
}
return result;
}
public static boolean isOCObject(CosObject cosObject) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
boolean result = false;
if (cosObject instanceof CosDictionary) {
CosObject typeObj;
ASName type = null;
if (((CosDictionary)cosObject).containsKey((Object)ASName.k_Type) && (typeObj = ((CosDictionary)cosObject).get(ASName.k_Type)) instanceof CosName) {
type = typeObj.nameValue();
}
if (type != null && (type.equals((Object)ASName.k_OCG) || type.equals((Object)ASName.k_OCMD))) {
result = true;
}
}
return result;
}
public static boolean hasOC(PDFXObject xObject) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return xObject.dictionaryContains(ASName.k_OC);
}
public static PDFOCObject getOC(PDFXObject xObject) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return PDFOCObject.getInstance(xObject.getDictionaryCosObjectValue(ASName.k_OC));
}
public static void setOC(PDFXObject xObject, PDFOCObject ocObj) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
xObject.setDictionaryValue(ASName.k_OC, ocObj);
}
public static boolean removeOC(PDFXObject xObject) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return xObject.removeValue(ASName.k_OC);
}
public static boolean hasOC(PDFAnnotation annot) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return annot.dictionaryContains(ASName.k_OC);
}
public static PDFOCObject getOC(PDFAnnotation annot) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return PDFOCObject.getInstance(annot.getDictionaryCosObjectValue(ASName.k_OC));
}
public static void setOC(PDFAnnotation annot, PDFOCObject ocObj) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
annot.setDictionaryValue(ASName.k_OC, ocObj);
}
public static boolean removeOC(PDFAnnotation annot) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return annot.removeValue(ASName.k_OC);
}
public boolean isOCG() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return ASName.k_OCG.equals((Object)this.getDictionaryNameValue(ASName.k_Type));
}
public boolean isOCMD() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return ASName.k_OCMD.equals((Object)this.getDictionaryNameValue(ASName.k_Type));
}
public abstract ASName getType() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException;
}