PDFOCUsageApp.java
4.73 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.internal.pdftoolkit.core.cos.CosArray
* com.adobe.internal.pdftoolkit.core.cos.CosDocument
* 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.CosArray;
import com.adobe.internal.pdftoolkit.core.cos.CosDocument;
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.document.PDFDocument;
import com.adobe.internal.pdftoolkit.pdf.graphics.optionalcontent.PDFOCGroupArray;
import java.util.ArrayList;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
public class PDFOCUsageApp
extends PDFCosDictionary {
private PDFOCUsageApp(CosObject cosObject) throws PDFInvalidDocumentException {
super(cosObject);
}
public static PDFOCUsageApp getInstance(CosObject cosObject) throws PDFInvalidDocumentException {
if (PDFCosObject.checkNullCosObject(cosObject) == null) {
return null;
}
PDFOCUsageApp pdfObject = PDFCosObject.getCachedInstance(cosObject, PDFOCUsageApp.class);
if (pdfObject == null) {
pdfObject = new PDFOCUsageApp(cosObject);
}
return pdfObject;
}
public static PDFOCUsageApp newInstance(PDFDocument pdfDocument, ASName event, ArrayList categories) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
PDFOCUsageApp usage = new PDFOCUsageApp((CosObject)PDFCosObject.newCosDictionary(pdfDocument));
if (!(event.equals((Object)ASName.k_View) || event.equals((Object)ASName.k_Print) || event.equals((Object)ASName.k_Export))) {
return null;
}
usage.setEvent(event);
usage.setCategoryList(categories);
usage.setOCGs(null);
return usage;
}
public void setEventView() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setEvent(ASName.k_View);
}
public void setEventPrint() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setEvent(ASName.k_Print);
}
public void setEventExport() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setEvent(ASName.k_Export);
}
private void setEvent(ASName event) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryNameValue(ASName.k_Event, event);
}
public ASName getEvent() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getDictionaryNameValue(ASName.k_Event);
}
public void setOCGs(PDFOCGroupArray ocgs) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryArrayValue(ASName.k_OCGs, ocgs == null ? this.getPDFDocument().getCosDocument().createCosArray() : ocgs.getCosArray());
}
public PDFOCGroupArray getOCGs() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosObject ocgs = this.getDictionaryCosObjectValue(ASName.k_OCGs);
return PDFOCGroupArray.getInstance(ocgs);
}
public void setCategoryList(ArrayList<ASName> categories) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosArray catArray = PDFCosObject.newCosArray(this.getPDFDocument());
for (ASName entry : categories) {
catArray.addName(entry);
}
this.setDictionaryArrayValue(ASName.k_Category, catArray);
}
public ArrayList<ASName> getCategoryList() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosArray entries = this.getDictionaryArrayValue(ASName.k_Category);
if (entries != null) {
int count = entries.size();
ArrayList<ASName> result = new ArrayList<ASName>(count);
for (int i = 0; i < count; ++i) {
result.add(entries.getName(i));
}
return result;
}
return null;
}
}