PDFOCGroup.java
6.48 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
/*
* 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.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.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.PDFInvalidParameterException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityException;
import com.adobe.internal.pdftoolkit.core.types.ASName;
import com.adobe.internal.pdftoolkit.pdf.document.PDFCatalog;
import com.adobe.internal.pdftoolkit.pdf.document.PDFCosObject;
import com.adobe.internal.pdftoolkit.pdf.document.PDFDocument;
import com.adobe.internal.pdftoolkit.pdf.graphics.optionalcontent.PDFOCIntentList;
import com.adobe.internal.pdftoolkit.pdf.graphics.optionalcontent.PDFOCObject;
import com.adobe.internal.pdftoolkit.pdf.graphics.optionalcontent.PDFOCOrderListContent;
import com.adobe.internal.pdftoolkit.pdf.graphics.optionalcontent.PDFOCProperties;
import com.adobe.internal.pdftoolkit.pdf.graphics.optionalcontent.PDFOCUsage;
public class PDFOCGroup
extends PDFOCObject
implements PDFOCOrderListContent {
protected PDFOCGroup(CosObject cosObject) throws PDFInvalidDocumentException {
super(cosObject);
}
public static PDFOCGroup getInstance(CosObject cosObject) throws PDFInvalidDocumentException {
if (PDFCosObject.checkNullCosObject(cosObject) == null) {
return null;
}
PDFOCGroup pdfObject = PDFCosObject.getCachedInstance(cosObject, PDFOCGroup.class);
if (pdfObject == null) {
pdfObject = new PDFOCGroup(cosObject);
}
return pdfObject;
}
public static PDFOCGroup newInstance(PDFDocument pdfDoc, String name) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
PDFOCGroup ocg = new PDFOCGroup((CosObject)PDFCosObject.newCosDictionary(pdfDoc));
ocg.setName(name);
ocg.setDictionaryNameValue(ASName.k_Type, ASName.k_OCG);
PDFOCProperties props = pdfDoc.requireCatalog().getOCProperties();
if (props == null) {
props = PDFOCProperties.newInstance(pdfDoc);
pdfDoc.requireCatalog().setOCProperties(props);
}
props.addOCG(ocg);
return ocg;
}
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 ASName getType() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getDictionaryNameValue(ASName.k_Type);
}
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 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);
}
}
private 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 setUsage(PDFOCUsage usage) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryValue(ASName.k_Usage, usage);
}
public PDFOCUsage getUsage() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosDictionary usage = this.getDictionaryDictionaryValue(ASName.k_Usage);
return PDFOCUsage.getInstance((CosObject)usage);
}
public String toString() {
try {
return "[object OCG=\"" + this.getName() + "\"]";
}
catch (PDFInvalidDocumentException e) {
throw new IllegalArgumentException("PDF document is invalid", (Throwable)e);
}
catch (PDFIOException e) {
throw new RuntimeException((Throwable)e);
}
catch (PDFSecurityException e) {
throw new RuntimeException((Throwable)e);
}
}
}