diff --git a/metadata-fixer/src/main/java/org/verapdf/metadata/fixer/gf/MetadataFixerImpl.java b/metadata-fixer/src/main/java/org/verapdf/metadata/fixer/gf/MetadataFixerImpl.java index d49c57395..2d30360dd 100644 --- a/metadata-fixer/src/main/java/org/verapdf/metadata/fixer/gf/MetadataFixerImpl.java +++ b/metadata-fixer/src/main/java/org/verapdf/metadata/fixer/gf/MetadataFixerImpl.java @@ -67,6 +67,9 @@ abstract class MetadataFixerImpl implements MetadataFixer { private static final Logger LOGGER = Logger.getLogger(MetadataFixerImpl.class.getCanonicalName()); private static final Map attributes = Collections.unmodifiableMap(mkAttsMap()); + + private static final String ADD_PROPERTY_TO_METADATA_FROM_INFO_DICTIONARY = "Added '%s' to metadata from info dictionary"; + private static final String ADD_PROPERTY_TO_INFO_DICTIONARY_FROM_METADATA = "Added '%s' to info dictionary from metadata"; protected MetadataFixerImpl() { // enabled only for nested classes @@ -233,7 +236,7 @@ private static void fixProperty(MetadataFixerResultImpl.Builder resultBuilder, B String key = attributes.get(attribute); if (metaValue == null) { doSaveAction(schema, attribute, infoValue); - resultBuilder.addFix("Added '" + key + "' to metadata from info dictionary"); + resultBuilder.addFix(String.format(ADD_PROPERTY_TO_METADATA_FROM_INFO_DICTIONARY, key)); } else { if (METADATA_AUTHOR.equals(attribute) && ((DublinCore)schema).getAuthorSize() > 1) { doSaveAction(schema, attribute, metaValue); @@ -241,7 +244,7 @@ private static void fixProperty(MetadataFixerResultImpl.Builder resultBuilder, B } if (!metaValue.equals(infoValue)) { doSaveAction(info, attribute, metaValue); - resultBuilder.addFix("Added '" + attribute + "' to info dictionary from metadata"); + resultBuilder.addFix(String.format(ADD_PROPERTY_TO_INFO_DICTIONARY_FROM_METADATA, attribute)); } } } @@ -257,7 +260,7 @@ private static void fixCalendarProperty(MetadataFixerResultImpl.Builder resultBu } if (metaCalendar == null) { doSaveAction(schema, attribute, infoValue); - resultBuilder.addFix("Added '" + attributes.get(attribute) + "' to metadata from info dictionary"); + resultBuilder.addFix(String.format(ADD_PROPERTY_TO_METADATA_FROM_INFO_DICTIONARY, attributes.get(attribute))); } else { if (metaCalendar.get(Calendar.MILLISECOND) != 0) { metaCalendar.set(Calendar.MILLISECOND, 0); @@ -267,7 +270,7 @@ private static void fixCalendarProperty(MetadataFixerResultImpl.Builder resultBu Calendar infoCalendar = DateConverter.toCalendar(infoValue); if (!infoValue.matches(PDF_DATE_FORMAT_REGEX) || metaCalendar.compareTo(infoCalendar) != 0) { doSaveAction(info, attribute, DateConverter.toXMPDateFormat(metaCalendar)); - resultBuilder.addFix("Added '" + attribute + "' to info dictionary from metadata"); + resultBuilder.addFix(String.format(ADD_PROPERTY_TO_INFO_DICTIONARY_FROM_METADATA, attribute)); } } } diff --git a/metadata-fixer/src/main/java/org/verapdf/metadata/fixer/gf/impl/model/MetadataImpl.java b/metadata-fixer/src/main/java/org/verapdf/metadata/fixer/gf/impl/model/MetadataImpl.java index d42c97327..f0c6bd878 100644 --- a/metadata-fixer/src/main/java/org/verapdf/metadata/fixer/gf/impl/model/MetadataImpl.java +++ b/metadata-fixer/src/main/java/org/verapdf/metadata/fixer/gf/impl/model/MetadataImpl.java @@ -58,9 +58,9 @@ public class MetadataImpl implements Metadata { private static final String YEAR_202X = "0000"; private static final String YEAR_REGEX = "^\\d{4}$"; - private static String ADD_PROPERTY_MESSAGE = "Added property %s with value %s to Identification schema"; - private static String REMOVE_PROPERTY_MESSAGE = "Removed property %s from Identification schema"; - private static String SET_PROPERTY_MESSAGE = "Set property %s value to %s in Identification schema"; + private static final String ADD_PROPERTY_MESSAGE = "Added property '%s' with value '%s' to Identification schema"; + private static final String REMOVE_PROPERTY_MESSAGE = "Removed property '%s' from Identification schema"; + private static final String SET_PROPERTY_MESSAGE = "Set property '%s' value to '%s' in Identification schema"; private final VeraPDFMeta metadata; diff --git a/validation-model/src/main/java/org/verapdf/gf/model/factory/operators/OperatorParser.java b/validation-model/src/main/java/org/verapdf/gf/model/factory/operators/OperatorParser.java index 7168a4cc6..988adc087 100644 --- a/validation-model/src/main/java/org/verapdf/gf/model/factory/operators/OperatorParser.java +++ b/validation-model/src/main/java/org/verapdf/gf/model/factory/operators/OperatorParser.java @@ -161,8 +161,7 @@ void parseOperator(List processedOperators, break; case Operators.BDC: PDFAFlavour.Specification specification = StaticContainers.getFlavour().getPart(); - if (specification == PDFAFlavour.Specification.ISO_19005_3 - || specification == PDFAFlavour.Specification.ISO_19005_4) { + if (specification == PDFAFlavour.Specification.ISO_19005_3) { checkAFKey(arguments, resourcesHandler); } GFOp_BDC bdcOp = new GFOp_BDC(arguments, resourcesHandler, getCurrentMarkedContent(), structureElementAccessObject, parentsTags); diff --git a/validation-model/src/main/java/org/verapdf/gf/model/impl/cos/GFCosDocument.java b/validation-model/src/main/java/org/verapdf/gf/model/impl/cos/GFCosDocument.java index 3a20849ef..7c786124b 100644 --- a/validation-model/src/main/java/org/verapdf/gf/model/impl/cos/GFCosDocument.java +++ b/validation-model/src/main/java/org/verapdf/gf/model/impl/cos/GFCosDocument.java @@ -97,8 +97,7 @@ public GFCosDocument(COSDocument cosDocument) { this.lastID = getTrailerID(cosDocument.getLastTrailer().getKey(ASAtom.ID)); this.firstPageID = getTrailerID(cosDocument.getFirstTrailer().getKey(ASAtom.ID)); PDFAFlavour.Specification specification = StaticContainers.getFlavour().getPart(); - if (specification == PDFAFlavour.Specification.ISO_19005_3 - || specification == PDFAFlavour.Specification.ISO_19005_4) { + if (specification == PDFAFlavour.Specification.ISO_19005_3) { FileSpecificationKeysHelper.registerFileSpecificationKeys(cosDocument); } } diff --git a/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/GFPDDocument.java b/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/GFPDDocument.java index 196fd6e52..037856d96 100644 --- a/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/GFPDDocument.java +++ b/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/GFPDDocument.java @@ -321,4 +321,9 @@ public String getmostCommonOrientation() { .collect(Collectors.toList()); return SQUARE_ORIENTATION.equals(twoTheMostFrequent.get(0)) && twoTheMostFrequent.size() == 2 ? twoTheMostFrequent.get(1) : twoTheMostFrequent.get(0); } + + @Override + public Boolean getcontainsXRefStream() { + return document.getDocument().isContainsXRefStream(); + } } diff --git a/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/GFPDStructElem.java b/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/GFPDStructElem.java index 970185015..203b23736 100644 --- a/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/GFPDStructElem.java +++ b/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/GFPDStructElem.java @@ -168,7 +168,7 @@ private boolean hasStandardType(){ if (flavour.getPart() == PDFAFlavour.Specification.ISO_19005_1) { return TaggedPDFHelper.getPdf14StandardRoleTypes().contains(type.getType().getValue()); } - if (flavour.getPart() == PDFAFlavour.Specification.ISO_19005_4) { + if (flavour.getPart() == PDFAFlavour.Specification.ISO_19005_4 || flavour == PDFAFlavour.PDFUA_2) { return TaggedPDFHelper.isStandardType(type); } if (flavour.getPart() == PDFAFlavour.Specification.WCAG_2_1) { diff --git a/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/annotations/GFPDWidgetAnnot.java b/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/annotations/GFPDWidgetAnnot.java index bc288b7c0..b3f56ab5c 100644 --- a/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/annotations/GFPDWidgetAnnot.java +++ b/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/annotations/GFPDWidgetAnnot.java @@ -23,11 +23,16 @@ import org.verapdf.as.ASAtom; import org.verapdf.cos.COSObject; import org.verapdf.gf.model.impl.pd.GFPDAnnot; +import org.verapdf.gf.model.impl.pd.gfse.GFSEFactory; import org.verapdf.gf.model.impl.pd.util.PDResourcesHandler; import org.verapdf.model.pdlayer.PDWidgetAnnot; import org.verapdf.pd.PDAnnotation; import org.verapdf.pd.PDPage; import org.verapdf.pd.annotations.PDWidgetAnnotation; +import org.verapdf.pd.structure.PDStructElem; +import org.verapdf.tools.StaticResources; +import org.verapdf.tools.TaggedPDFConstants; +import org.verapdf.tools.TaggedPDFRoleMapHelper; /** * @author Maxim Plushchov @@ -49,4 +54,23 @@ public String getTU() { return ((PDAnnotation) simplePDObject).getTU(); } + @Override + public Boolean getcontainsLbl() { + TaggedPDFRoleMapHelper taggedPDFRoleMapHelper = StaticResources.getRoleMapHelper(); + if (taggedPDFRoleMapHelper == null) { + return false; + } + COSObject parent = getParentDictionary(); + if (parent != null) { + PDStructElem parentStructElem = new PDStructElem(parent, taggedPDFRoleMapHelper.getRoleMap()); + for (PDStructElem child : parentStructElem.getStructChildren()) { + if (TaggedPDFConstants.LBL.equals(GFSEFactory.getStructureElementStandardType(child)) && + !child.getChildren().isEmpty()) { + return true; + } + } + } + return false; + } + } diff --git a/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/gfse/GFSEContentItem.java b/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/gfse/GFSEContentItem.java index b537bd129..54ae6b166 100644 --- a/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/gfse/GFSEContentItem.java +++ b/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/gfse/GFSEContentItem.java @@ -95,7 +95,7 @@ public String getparentStructureTag() { @Override public String getparentStandardTag() { TaggedPDFRoleMapHelper taggedPDFRoleMapHelper = StaticResources.getRoleMapHelper(); - if (parentStructElem != null) { + if (parentStructElem != null && taggedPDFRoleMapHelper != null) { PDStructElem structElem = new PDStructElem(parentStructElem, taggedPDFRoleMapHelper.getRoleMap()); return GFSEFactory.getStructureElementStandardType(structElem); } @@ -114,7 +114,7 @@ public Boolean getisArtifact() { protected Boolean hasParentWithStandardType(String standardType) { TaggedPDFRoleMapHelper taggedPDFRoleMapHelper = StaticResources.getRoleMapHelper(); - if (parentStructElem != null) { + if (parentStructElem != null && taggedPDFRoleMapHelper != null) { PDStructElem structElem = new PDStructElem(parentStructElem, taggedPDFRoleMapHelper.getRoleMap()); while (structElem != null) { if (standardType.equals(GFSEFactory.getStructureElementStandardType(structElem))) {