From 4388b28523f8b63dd53bf18ee0dd836d9c0e937f Mon Sep 17 00:00:00 2001 From: Maxim Date: Fri, 8 Nov 2024 01:30:21 +0300 Subject: [PATCH] Add Part to pass through structure tags --- .../gf/model/impl/pd/GFPDStructElem.java | 2 +- .../gf/model/impl/pd/GFPDStructTreeNode.java | 9 +++++---- .../gf/model/impl/sa/GFSAStructElem.java | 18 +++++++++--------- 3 files changed, 15 insertions(+), 14 deletions(-) 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 30b163950..f4173459a 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 @@ -104,7 +104,7 @@ public String getparentStandardType() { if (parent != null) { StructureType parentStandardStructureType = org.verapdf.pd.structure.PDStructElem.getStructureElementStandardStructureType(parent); String parentStandardType = parentStandardStructureType != null ? parentStandardStructureType.getType().getValue() : null; - while (TaggedPDFConstants.NON_STRUCT.equals(parentStandardType) || TaggedPDFConstants.DIV.equals(parentStandardType)) { + while (org.verapdf.pd.structure.PDStructElem.isPassThroughTag(parentStandardType)) { parent = parent.getParent(); if (parent == null) { return null; diff --git a/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/GFPDStructTreeNode.java b/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/GFPDStructTreeNode.java index 024a0f9da..e941580a5 100644 --- a/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/GFPDStructTreeNode.java +++ b/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/GFPDStructTreeNode.java @@ -26,6 +26,7 @@ import org.verapdf.gf.model.impl.pd.gfse.GFSEFactory; import org.verapdf.model.baselayer.Object; import org.verapdf.model.pdlayer.PDStructTreeNode; +import org.verapdf.pd.structure.PDStructElem; import org.verapdf.pdfa.flavours.PDFFlavours; import org.verapdf.tools.TaggedPDFConstants; import org.verapdf.tools.TaggedPDFHelper; @@ -101,7 +102,7 @@ private static List getChildrenStandardTypes(GFPDStructTreeNode element) List res = new ArrayList<>(); for (GFPDStructElem child : element.getChildren()) { String elementStandardType = child.getstandardType(); - if (TaggedPDFConstants.NON_STRUCT.equals(elementStandardType) || TaggedPDFConstants.DIV.equals(elementStandardType)) { + if (PDStructElem.isPassThroughTag(elementStandardType)) { res.addAll(getChildrenStandardTypes(child)); } else { res.add(elementStandardType); @@ -112,10 +113,10 @@ private static List getChildrenStandardTypes(GFPDStructTreeNode element) private List getChildren() { if (children == null) { - List elements = ((org.verapdf.pd.structure.PDStructTreeNode) simplePDObject).getStructChildren(); + List elements = ((org.verapdf.pd.structure.PDStructTreeNode) simplePDObject).getStructChildren(); if (!elements.isEmpty()) { List res = new ArrayList<>(elements.size()); - for (org.verapdf.pd.structure.PDStructElem element : elements) { + for (PDStructElem element : elements) { res.add(GFSEFactory.createTypedStructElem(element)); } children = Collections.unmodifiableList(res); @@ -130,7 +131,7 @@ public List getStructuralSignificanceChildren() { List children = getChildren(); List result = new LinkedList<>(); for (GFPDStructElem child : children) { - if (TaggedPDFConstants.NON_STRUCT.equals(child.getstandardType()) || TaggedPDFConstants.DIV.equals(child.getstandardType())) { + if (PDStructElem.isPassThroughTag(child.getstandardType())) { result.addAll(child.getStructuralSignificanceChildren()); } else { result.add(child); diff --git a/wcag-validation/src/main/java/org/verapdf/gf/model/impl/sa/GFSAStructElem.java b/wcag-validation/src/main/java/org/verapdf/gf/model/impl/sa/GFSAStructElem.java index fa943ef5a..92f9e4d16 100644 --- a/wcag-validation/src/main/java/org/verapdf/gf/model/impl/sa/GFSAStructElem.java +++ b/wcag-validation/src/main/java/org/verapdf/gf/model/impl/sa/GFSAStructElem.java @@ -49,7 +49,7 @@ public class GFSAStructElem extends GFSAObject implements SAStructElem { public static final String CHILDREN = "children"; - protected final org.verapdf.pd.structure.PDStructElem structElemDictionary; + protected final PDStructElem structElemDictionary; protected List children = null; @@ -61,8 +61,8 @@ public class GFSAStructElem extends GFSAObject implements SAStructElem { private boolean isLeafNode = true; private final String parentsStandardTypes; - public GFSAStructElem(org.verapdf.pd.structure.PDStructElem structElemDictionary, String standardType, - String type, String parentsStandardTypes) { + public GFSAStructElem(PDStructElem structElemDictionary, String standardType, + String type, String parentsStandardTypes) { super(type); this.structElemDictionary = structElemDictionary; this.standardType = standardType; @@ -151,9 +151,9 @@ protected void parseChildren() { if (!elements.isEmpty()) { List chunks = new LinkedList<>(); for (java.lang.Object element : elements) { - if (element instanceof org.verapdf.pd.structure.PDStructElem) { + if (element instanceof PDStructElem) { addChunksToChildren(chunks); - GFSAStructElem structElem = GFSAFactory.createTypedStructElem((org.verapdf.pd.structure.PDStructElem)element, + GFSAStructElem structElem = GFSAFactory.createTypedStructElem((PDStructElem)element, (parentsStandardTypes.isEmpty() ? "" : (parentsStandardTypes + '&')) + standardType); INode childNode = new GFSANode(structElem); structElem.setNode(childNode); @@ -277,7 +277,7 @@ private static List getChildrenStandardTypes(GFSAStructElem element) { for (Object child : element.children) { if (child instanceof GFSAStructElem) { String elementStandardType = ((GFSAStructElem) child).getstandardType(); - if (TaggedPDFConstants.NON_STRUCT.equals(elementStandardType) || TaggedPDFConstants.DIV.equals(elementStandardType)) { + if (PDStructElem.isPassThroughTag(elementStandardType)) { res.addAll(getChildrenStandardTypes((GFSAStructElem) child)); } else { res.add(elementStandardType); @@ -289,10 +289,10 @@ private static List getChildrenStandardTypes(GFSAStructElem element) { @Override public String getparentStandardType() { - org.verapdf.pd.structure.PDStructElem parent = this.structElemDictionary.getParent(); + PDStructElem parent = this.structElemDictionary.getParent(); if (parent != null) { String parentStandardType = PDStructElem.getStructureElementStandardType(parent); - while (TaggedPDFConstants.NON_STRUCT.equals(parentStandardType) || TaggedPDFConstants.DIV.equals(parentStandardType)) { + while (PDStructElem.isPassThroughTag(parentStandardType)) { parent = parent.getParent(); if (parent == null) { return null; @@ -334,7 +334,7 @@ public Long getlastPage() { return null; } - public org.verapdf.pd.structure.PDStructElem getStructElemDictionary() { + public PDStructElem getStructElemDictionary() { return structElemDictionary; } }