Skip to content
This repository was archived by the owner on May 8, 2025. It is now read-only.

Commit 8a5bbb0

Browse files
committed
Add new methods
1 parent cad8b45 commit 8a5bbb0

File tree

7 files changed

+88
-18
lines changed

7 files changed

+88
-18
lines changed

pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/PBoxPDAnnot.java

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,14 @@ public String getAP() {
211211
return this.ap;
212212
}
213213

214+
@Override
215+
public Boolean getcontainsAppearances() {
216+
if (this.appearance == null) {
217+
parseAppearance();
218+
}
219+
return !this.appearance.isEmpty();
220+
}
221+
214222
@Override
215223
public Long getF() {
216224
return isFKeyPresent ? Long.valueOf(this.annotationFlag) : null;
@@ -292,7 +300,22 @@ public String getstructParentObjectKey() {
292300
return null;
293301
}
294302

295-
private List<CosLang> getLang() {
303+
@Override
304+
public Boolean getcontainsLang() {
305+
return getLang() != null;
306+
}
307+
308+
private List<CosLang> getLinkLang() {
309+
String lang = getLang();
310+
if (lang != null) {
311+
List<CosLang> list = new ArrayList<>(MAX_NUMBER_OF_ELEMENTS);
312+
list.add(new PBCosLang(new COSString(lang)));
313+
return Collections.unmodifiableList(list);
314+
}
315+
return Collections.emptyList();
316+
}
317+
318+
private String getLang() {
296319
PDStructureTreeRoot structTreeRoot = this.document.getDocumentCatalog().getStructureTreeRoot();
297320
int structParent = ((PDAnnotation) this.simplePDObject).getStructParent();
298321
if (structTreeRoot != null && structParent != 0) {
@@ -302,18 +325,13 @@ private List<CosLang> getLang() {
302325
PDParentTreeValue treeValue = parentTreeRoot == null ? null : (PDParentTreeValue) parentTreeRoot.getValue(structParent);
303326
structureElement = treeValue == null ? null : treeValue.getCOSObject();
304327
} catch (IOException e) {
305-
return Collections.emptyList();
328+
return null;
306329
}
307330
if (structureElement instanceof COSDictionary) {
308-
String lang = ((COSDictionary) structureElement).getNameAsString(COSName.LANG);
309-
if (lang != null) {
310-
List<CosLang> list = new ArrayList<>(MAX_NUMBER_OF_ELEMENTS);
311-
list.add(new PBCosLang(new COSString(lang)));
312-
return Collections.unmodifiableList(list);
313-
}
331+
return ((COSDictionary) structureElement).getNameAsString(COSName.LANG);
314332
}
315333
}
316-
return Collections.emptyList();
334+
return null;
317335
}
318336

319337
@Override
@@ -373,7 +391,7 @@ public List<? extends Object> getLinkedObjects(String link) {
373391
case APPEARANCE:
374392
return this.getAppearance();
375393
case LANG:
376-
return this.getLang();
394+
return this.getLinkLang();
377395
case BM:
378396
return this.getBM();
379397
default:

pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/PBoxPDDocument.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,17 @@ private List<PDPerms> getPerms() {
327327
return Collections.emptyList();
328328
}
329329

330+
@Override
331+
public Boolean getcontainsMetadata() {
332+
org.apache.pdfbox.pdmodel.common.PDMetadata meta = this.catalog != null ? this.catalog.getMetadata() : null;
333+
return meta != null && PBoxPDMetadata.isMetadataObject(meta.getCOSObject());
334+
}
335+
336+
@Override
337+
public Boolean getcontainsStructTreeRoot() {
338+
return this.catalog != null && this.catalog.getStructureTreeRoot() != null;
339+
}
340+
330341
@Override
331342
public Boolean getcontainsAlternatePresentations() {
332343
if (this.catalog != null) {
@@ -371,5 +382,10 @@ private List<CosLang> getLang() {
371382
}
372383
return Collections.emptyList();
373384
}
385+
386+
@Override
387+
public Boolean getcontainsLang() {
388+
return this.catalog != null && catalog.getCOSObject().getDictionaryObject(COSName.LANG) instanceof COSString;
389+
}
374390

375391
}

pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/PBoxPDFormField.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ public Boolean getcontainsAA() {
6767
((COSDictionary) pageObject).containsKey(COSName.AA);
6868
}
6969

70+
@Override
71+
public Boolean getcontainsLang() {
72+
return false;
73+
}
74+
7075
@Override
7176
public String getTU() {
7277
return null;

pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/PBoxPDPage.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public Boolean getcontainsTransparency() {
126126
parseContentStream();
127127
}
128128
if (this.annotations == null) {
129-
this.annotations = parseAnnotataions();
129+
this.annotations = parseAnnotations();
130130
}
131131
return Boolean.valueOf(this.containsTransparency);
132132
}
@@ -304,13 +304,22 @@ private List<PDAdditionalActions> getActions() {
304304

305305
private List<PDAnnot> getAnnotations() {
306306
if (this.annotations == null) {
307-
this.annotations = parseAnnotataions();
307+
this.annotations = parseAnnotations();
308308
}
309309

310310
return this.annotations;
311311
}
312312

313-
private List<PDAnnot> parseAnnotataions() {
313+
@Override
314+
public Boolean getcontainsAnnotations() {
315+
if (this.annotations == null) {
316+
this.annotations = parseAnnotations();
317+
}
318+
319+
return !this.annotations.isEmpty();
320+
}
321+
322+
private List<PDAnnot> parseAnnotations() {
314323
try {
315324
List<PDAnnotation> pdfboxAnnotations = ((org.apache.pdfbox.pdmodel.PDPage) this.simplePDObject)
316325
.getAnnotations();

pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/PBoxPDStructElem.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@ public String getstandardType() {
163163
return null;
164164
}
165165

166+
@Override
167+
public Boolean getcontainsLang() {
168+
COSBase baseLang = ((COSDictionary) this.simplePDObject).getDictionaryObject(COSName.LANG);
169+
return baseLang instanceof COSString;
170+
}
171+
166172
@Override
167173
public String getparentLang() {
168174
COSDictionary parentDict = (COSDictionary)((COSDictionary) this.simplePDObject).getDictionaryObject(COSName.P);

pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/font/PBoxPDCMap.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ public String getCMapName() {
6363
return this.cMap.getName();
6464
}
6565

66+
@Override
67+
public Boolean getcontainsEmbeddedFile() {
68+
return this.simplePDObject instanceof COSStream;
69+
}
70+
6671
@Override
6772
public List<? extends Object> getLinkedObjects(String link) {
6873
switch (link) {

pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/font/PBoxPDFont.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,22 @@ public List<? extends Object> getLinkedObjects(String link) {
133133
}
134134

135135
private List<FontProgram> getFontFile() {
136+
FontProgram fontProgram = getFontProgram();
137+
if (fontProgram != null) {
138+
return PBoxPDFont.getFontProgramList(fontProgram);
139+
}
140+
return Collections.emptyList();
141+
}
142+
143+
@Override
144+
public Boolean getcontainsFontFile() {
145+
return getFontProgram() != null;
146+
}
147+
148+
private FontProgram getFontProgram() {
136149
if (!getSubtype().equals(FontFactory.TYPE_3) && (this.pdFontLike.isEmbedded())) {
137150
if (getSubtype().equals(FontFactory.TRUE_TYPE)) {
138-
PBoxTrueTypeFontProgram trueTypeFontProgram = new PBoxTrueTypeFontProgram(
139-
((PDTrueTypeFont) this.pdFontLike).getTrueTypeFont(), getisSymbolic());
140-
return PBoxPDFont.getFontProgramList(trueTypeFontProgram);
151+
return new PBoxTrueTypeFontProgram(((PDTrueTypeFont) this.pdFontLike).getTrueTypeFont(), getisSymbolic());
141152
}
142153
PDFontDescriptor fontDescriptor = pdFontLike.getFontDescriptor();
143154
PDStream fontFile;
@@ -153,10 +164,10 @@ private List<FontProgram> getFontFile() {
153164
fontFile = fontDescriptor.getFontFile3();
154165
}
155166
if (fontFile != null) {
156-
return PBoxPDFont.getFontProgramList(new PBoxFontProgram(fontFile));
167+
return new PBoxFontProgram(fontFile);
157168
}
158169
}
159-
return Collections.emptyList();
170+
return null;
160171
}
161172

162173
private static List<FontProgram> getFontProgramList(FontProgram fontProgram) {

0 commit comments

Comments
 (0)