PDFStructureElement.java
7.09 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.internal.pdftoolkit.core.cos.CosDictionary
* 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.PDFInvalidStructureException
* com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityException
* com.adobe.internal.pdftoolkit.core.types.ASName
* com.adobe.internal.pdftoolkit.core.types.ASString
*/
package com.adobe.internal.pdftoolkit.pdf.interchange.structure;
import com.adobe.internal.pdftoolkit.core.cos.CosDictionary;
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.PDFInvalidStructureException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityException;
import com.adobe.internal.pdftoolkit.core.types.ASName;
import com.adobe.internal.pdftoolkit.core.types.ASString;
import com.adobe.internal.pdftoolkit.pdf.document.PDFCosObject;
import com.adobe.internal.pdftoolkit.pdf.document.PDFDocument;
import com.adobe.internal.pdftoolkit.pdf.interchange.structure.PDFStructureContentArray;
import com.adobe.internal.pdftoolkit.pdf.interchange.structure.PDFStructureContentInterface;
import com.adobe.internal.pdftoolkit.pdf.interchange.structure.PDFStructureContentScalar;
import com.adobe.internal.pdftoolkit.pdf.interchange.structure.PDFStructureMCID;
import com.adobe.internal.pdftoolkit.pdf.interchange.structure.PDFStructureNode;
import com.adobe.internal.pdftoolkit.pdf.interchange.structure.PDFStructureRoot;
import com.adobe.internal.pdftoolkit.pdf.interchange.structure.PDFStructureType;
import com.adobe.internal.pdftoolkit.pdf.page.PDFPage;
public class PDFStructureElement
extends PDFStructureContentScalar {
public static final ASName k_ActualText = ASName.create((String)"ActualText");
private PDFStructureElement(CosObject cosObj) throws PDFInvalidDocumentException {
super(cosObj);
}
public static PDFStructureElement getInstance(CosObject cosObject) throws PDFInvalidStructureException, PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (PDFCosObject.checkNullCosObject(cosObject) == null) {
return null;
}
return new PDFStructureElement(cosObject);
}
public static PDFStructureElement getInstance(CosDictionary cosObject) throws PDFInvalidDocumentException {
if (PDFCosObject.checkNullCosObject((CosObject)cosObject) == null) {
return null;
}
PDFStructureElement pdfObject = PDFCosObject.getCachedInstance((CosObject)cosObject, PDFStructureElement.class);
if (pdfObject == null) {
pdfObject = new PDFStructureElement((CosObject)cosObject);
}
return pdfObject;
}
public static PDFStructureElement newInstance(PDFDocument pdfDoc, ASName type, PDFStructureNode parent) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosDictionary cosElem = pdfDoc.getCosDocument().createCosDictionary();
cosElem.put(ASName.k_S, type);
if (parent != null) {
cosElem.put(ASName.k_P, parent.getCosObject());
}
return new PDFStructureElement((CosObject)cosElem);
}
public PDFStructureNode getParent() throws PDFInvalidStructureException, PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosDictionary parent = (CosDictionary)((CosDictionary)this.getCosObject()).get(ASName.k_P);
if (parent == null) {
throw new PDFInvalidStructureException("Invalid Structure: Structure element does not have a parent");
}
ASName type = null;
if (parent.containsKey((Object)ASName.k_Type)) {
type = parent.getName(ASName.k_Type);
}
if (type == null || type.equals((Object)ASName.k_StructElem)) {
return PDFStructureElement.getInstance(parent);
}
if (type.equals((Object)ASName.k_StructTreeRoot)) {
return PDFStructureRoot.getInstance(parent);
}
return null;
}
public String getActualText() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getDictionaryTextStringValue(k_ActualText);
}
public void setActualText(String text) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryStringValue(k_ActualText, text);
}
public PDFStructureElement delete() {
return null;
}
public PDFPage getPage() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return PDFPage.getInstance(((CosDictionary)this.getCosObject()).get(ASName.k_Pg));
}
public void setPage(PDFPage page) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryValue(ASName.k_Pg, page);
}
public void addMCID(PDFStructureContentArray parentContent, int mcid) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
PDFStructureMCID mcidChild = PDFStructureMCID.newInstance(this.getPDFDocument(), mcid);
this.addContent(mcidChild);
parentContent.add(mcid, this);
}
public ASString getID() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosObject cosObject = this.getCosObject();
if (cosObject instanceof CosDictionary) {
return this.getDictionaryStringValue(ASName.k_ID);
}
return null;
}
public void setID(ASString id) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryASStringValue(ASName.k_ID, id);
}
public ASName requireStructureType() throws PDFInvalidStructureException, PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
ASName type = this.getDictionaryNameValue(ASName.k_S);
if (type == null) {
throw new PDFInvalidStructureException("Required instance");
}
return type;
}
public String getAlt() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getDictionaryTextStringValue(ASName.k_Alt);
}
public void setAlt(String text) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryStringValue(ASName.k_Alt, text);
}
public String getLang() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getDictionaryTextStringValue(ASName.k_Lang);
}
public void setLang(String text) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryStringValue(ASName.k_Lang, text);
}
public PDFStructureType getStructureType() {
return PDFStructureType.Element;
}
}