PDFBookmarkRoot.java
3.17 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.internal.pdftoolkit.core.cos.CosDictionary
* 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.interactive.navigation;
import com.adobe.internal.pdftoolkit.core.cos.CosDictionary;
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.PDFCosObject;
import com.adobe.internal.pdftoolkit.pdf.document.PDFDocument;
import com.adobe.internal.pdftoolkit.pdf.interactive.navigation.PDFBookmark;
import com.adobe.internal.pdftoolkit.pdf.interactive.navigation.PDFBookmarkNode;
import com.adobe.internal.pdftoolkit.pdf.interactive.navigation.PDFBookmarkUtils;
public class PDFBookmarkRoot
extends PDFBookmarkNode {
private PDFBookmarkRoot(CosObject cosObject) throws PDFInvalidDocumentException {
super(cosObject);
}
public static PDFBookmarkRoot getInstance(CosObject cosObject) throws PDFInvalidDocumentException {
if (PDFCosObject.checkNullCosObject(cosObject) == null) {
return null;
}
PDFBookmarkRoot pdfObject = PDFCosObject.getCachedInstance(cosObject, PDFBookmarkRoot.class);
if (pdfObject == null) {
pdfObject = new PDFBookmarkRoot(cosObject);
}
return pdfObject;
}
public static PDFBookmarkRoot newSkeletonInstance(PDFDocument pdfDocument) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosDictionary cosDict = PDFCosObject.newCosDictionary(pdfDocument);
cosDict.put(ASName.k_Type, ASName.k_Outlines);
PDFBookmarkRoot root = new PDFBookmarkRoot((CosObject)cosDict);
root.setCount(0);
return root;
}
public static PDFBookmarkRoot newInstance(PDFDocument pdfDocument, PDFBookmark bookmark) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
PDFBookmarkRoot root = PDFBookmarkRoot.newSkeletonInstance(pdfDocument);
if (bookmark != null) {
PDFBookmarkUtils.appendLastKid(bookmark, root);
}
return root;
}
public PDFBookmark findDepthFirst(String title) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
PDFBookmark b = this.getFirstKid();
if (b != null) {
return b.findDepthFirst(title);
}
return null;
}
public int getCount() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
Integer count = this.getDictionaryIntValue(ASName.k_Count);
if (count != null) {
return count > 0 ? count : 0;
}
return 0;
}
}