Skip to content

Commit

Permalink
Add Part to pass through structure tags
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximPlusov committed Nov 8, 2024
1 parent 9089b0e commit 4388b28
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -101,7 +102,7 @@ private static List<String> getChildrenStandardTypes(GFPDStructTreeNode element)
List<String> 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);
Expand All @@ -112,10 +113,10 @@ private static List<String> getChildrenStandardTypes(GFPDStructTreeNode element)

private List<GFPDStructElem> getChildren() {
if (children == null) {
List<org.verapdf.pd.structure.PDStructElem> elements = ((org.verapdf.pd.structure.PDStructTreeNode) simplePDObject).getStructChildren();
List<PDStructElem> elements = ((org.verapdf.pd.structure.PDStructTreeNode) simplePDObject).getStructChildren();
if (!elements.isEmpty()) {
List<GFPDStructElem> 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);
Expand All @@ -130,7 +131,7 @@ public List<GFPDStructElem> getStructuralSignificanceChildren() {
List<GFPDStructElem> children = getChildren();
List<GFPDStructElem> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Object> children = null;

Expand All @@ -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;
Expand Down Expand Up @@ -151,9 +151,9 @@ protected void parseChildren() {
if (!elements.isEmpty()) {
List<IChunk> 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);
Expand Down Expand Up @@ -277,7 +277,7 @@ private static List<String> 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);
Expand All @@ -289,10 +289,10 @@ private static List<String> 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;
Expand Down Expand Up @@ -334,7 +334,7 @@ public Long getlastPage() {
return null;
}

public org.verapdf.pd.structure.PDStructElem getStructElemDictionary() {
public PDStructElem getStructElemDictionary() {
return structElemDictionary;
}
}

0 comments on commit 4388b28

Please sign in to comment.