diff --git a/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/PBoxPDAnnot.java b/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/PBoxPDAnnot.java index 477abb42..d1d6445f 100644 --- a/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/PBoxPDAnnot.java +++ b/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/PBoxPDAnnot.java @@ -211,6 +211,14 @@ public String getAP() { return this.ap; } + @Override + public Boolean getcontainsAppearances() { + if (this.appearance == null) { + parseAppearance(); + } + return !this.appearance.isEmpty(); + } + @Override public Long getF() { return isFKeyPresent ? Long.valueOf(this.annotationFlag) : null; @@ -292,7 +300,22 @@ public String getstructParentObjectKey() { return null; } - private List getLang() { + @Override + public Boolean getcontainsLang() { + return getLang() != null; + } + + private List getLinkLang() { + String lang = getLang(); + if (lang != null) { + List list = new ArrayList<>(MAX_NUMBER_OF_ELEMENTS); + list.add(new PBCosLang(new COSString(lang))); + return Collections.unmodifiableList(list); + } + return Collections.emptyList(); + } + + private String getLang() { PDStructureTreeRoot structTreeRoot = this.document.getDocumentCatalog().getStructureTreeRoot(); int structParent = ((PDAnnotation) this.simplePDObject).getStructParent(); if (structTreeRoot != null && structParent != 0) { @@ -302,18 +325,13 @@ private List getLang() { PDParentTreeValue treeValue = parentTreeRoot == null ? null : (PDParentTreeValue) parentTreeRoot.getValue(structParent); structureElement = treeValue == null ? null : treeValue.getCOSObject(); } catch (IOException e) { - return Collections.emptyList(); + return null; } if (structureElement instanceof COSDictionary) { - String lang = ((COSDictionary) structureElement).getNameAsString(COSName.LANG); - if (lang != null) { - List list = new ArrayList<>(MAX_NUMBER_OF_ELEMENTS); - list.add(new PBCosLang(new COSString(lang))); - return Collections.unmodifiableList(list); - } + return ((COSDictionary) structureElement).getNameAsString(COSName.LANG); } } - return Collections.emptyList(); + return null; } @Override @@ -373,7 +391,7 @@ public List getLinkedObjects(String link) { case APPEARANCE: return this.getAppearance(); case LANG: - return this.getLang(); + return this.getLinkLang(); case BM: return this.getBM(); default: diff --git a/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/PBoxPDDocument.java b/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/PBoxPDDocument.java index 8017cfaa..4edfa99f 100644 --- a/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/PBoxPDDocument.java +++ b/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/PBoxPDDocument.java @@ -327,6 +327,17 @@ private List getPerms() { return Collections.emptyList(); } + @Override + public Boolean getcontainsMetadata() { + org.apache.pdfbox.pdmodel.common.PDMetadata meta = this.catalog != null ? this.catalog.getMetadata() : null; + return meta != null && PBoxPDMetadata.isMetadataObject(meta.getCOSObject()); + } + + @Override + public Boolean getcontainsStructTreeRoot() { + return this.catalog != null && this.catalog.getStructureTreeRoot() != null; + } + @Override public Boolean getcontainsAlternatePresentations() { if (this.catalog != null) { @@ -371,5 +382,10 @@ private List getLang() { } return Collections.emptyList(); } + + @Override + public Boolean getcontainsLang() { + return this.catalog != null && catalog.getCOSObject().getDictionaryObject(COSName.LANG) instanceof COSString; + } } diff --git a/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/PBoxPDFormField.java b/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/PBoxPDFormField.java index 2a4f8374..0a19a4b8 100644 --- a/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/PBoxPDFormField.java +++ b/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/PBoxPDFormField.java @@ -67,6 +67,11 @@ public Boolean getcontainsAA() { ((COSDictionary) pageObject).containsKey(COSName.AA); } + @Override + public Boolean getcontainsLang() { + return false; + } + @Override public String getTU() { return null; diff --git a/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/PBoxPDPage.java b/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/PBoxPDPage.java index 05540db0..b146e0fe 100644 --- a/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/PBoxPDPage.java +++ b/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/PBoxPDPage.java @@ -126,7 +126,7 @@ public Boolean getcontainsTransparency() { parseContentStream(); } if (this.annotations == null) { - this.annotations = parseAnnotataions(); + this.annotations = parseAnnotations(); } return Boolean.valueOf(this.containsTransparency); } @@ -304,13 +304,22 @@ private List getActions() { private List getAnnotations() { if (this.annotations == null) { - this.annotations = parseAnnotataions(); + this.annotations = parseAnnotations(); } return this.annotations; } - private List parseAnnotataions() { + @Override + public Boolean getcontainsAnnotations() { + if (this.annotations == null) { + this.annotations = parseAnnotations(); + } + + return !this.annotations.isEmpty(); + } + + private List parseAnnotations() { try { List pdfboxAnnotations = ((org.apache.pdfbox.pdmodel.PDPage) this.simplePDObject) .getAnnotations(); diff --git a/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/PBoxPDStructElem.java b/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/PBoxPDStructElem.java index ba3807a3..784444c0 100644 --- a/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/PBoxPDStructElem.java +++ b/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/PBoxPDStructElem.java @@ -163,6 +163,12 @@ public String getstandardType() { return null; } + @Override + public Boolean getcontainsLang() { + COSBase baseLang = ((COSDictionary) this.simplePDObject).getDictionaryObject(COSName.LANG); + return baseLang instanceof COSString; + } + @Override public String getparentLang() { COSDictionary parentDict = (COSDictionary)((COSDictionary) this.simplePDObject).getDictionaryObject(COSName.P); diff --git a/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/font/PBoxPDCMap.java b/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/font/PBoxPDCMap.java index ac179002..d04f3136 100644 --- a/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/font/PBoxPDCMap.java +++ b/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/font/PBoxPDCMap.java @@ -63,6 +63,11 @@ public String getCMapName() { return this.cMap.getName(); } + @Override + public Boolean getcontainsEmbeddedFile() { + return this.simplePDObject instanceof COSStream; + } + @Override public List getLinkedObjects(String link) { switch (link) { diff --git a/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/font/PBoxPDFont.java b/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/font/PBoxPDFont.java index 7f3da766..831f9cbe 100644 --- a/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/font/PBoxPDFont.java +++ b/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/font/PBoxPDFont.java @@ -133,11 +133,22 @@ public List getLinkedObjects(String link) { } private List getFontFile() { + FontProgram fontProgram = getFontProgram(); + if (fontProgram != null) { + return PBoxPDFont.getFontProgramList(fontProgram); + } + return Collections.emptyList(); + } + + @Override + public Boolean getcontainsFontFile() { + return getFontProgram() != null; + } + + private FontProgram getFontProgram() { if (!getSubtype().equals(FontFactory.TYPE_3) && (this.pdFontLike.isEmbedded())) { if (getSubtype().equals(FontFactory.TRUE_TYPE)) { - PBoxTrueTypeFontProgram trueTypeFontProgram = new PBoxTrueTypeFontProgram( - ((PDTrueTypeFont) this.pdFontLike).getTrueTypeFont(), getisSymbolic()); - return PBoxPDFont.getFontProgramList(trueTypeFontProgram); + return new PBoxTrueTypeFontProgram(((PDTrueTypeFont) this.pdFontLike).getTrueTypeFont(), getisSymbolic()); } PDFontDescriptor fontDescriptor = pdFontLike.getFontDescriptor(); PDStream fontFile; @@ -153,10 +164,10 @@ private List getFontFile() { fontFile = fontDescriptor.getFontFile3(); } if (fontFile != null) { - return PBoxPDFont.getFontProgramList(new PBoxFontProgram(fontFile)); + return new PBoxFontProgram(fontFile); } } - return Collections.emptyList(); + return null; } private static List getFontProgramList(FontProgram fontProgram) {