diff --git a/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/gfse/GFSEFactory.java b/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/gfse/GFSEFactory.java index b7525b0ad..f70496355 100644 --- a/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/gfse/GFSEFactory.java +++ b/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/gfse/GFSEFactory.java @@ -156,14 +156,16 @@ public static GFPDStructElem createTypedStructElem(PDStructElem structElemDictio public static StructureType getStructureElementStandardStructureType(PDStructElem pdStructElem) { if (StaticContainers.getFlavour() != null && (StaticContainers.getFlavour().getPart() == PDFAFlavour.Specification.ISO_19005_4 || StaticContainers.getFlavour().getPart() == + PDFAFlavour.Specification.ISO_14289_2 || StaticContainers.getFlavour().getPart() == PDFAFlavour.Specification.WCAG_2_1)) { StructureType defaultStructureType = pdStructElem.getDefaultStructureType(); if (defaultStructureType != null) { return defaultStructureType; } } - if (StaticContainers.getFlavour() == null || StaticContainers.getFlavour().getPart() != - PDFAFlavour.Specification.ISO_19005_4) { + if (StaticContainers.getFlavour() == null || (StaticContainers.getFlavour().getPart() != + PDFAFlavour.Specification.ISO_19005_4 && StaticContainers.getFlavour().getPart() != + PDFAFlavour.Specification.ISO_14289_2)) { StructureType type = pdStructElem.getStructureType(); if (type != null) { return StructureType.createStructureType(ASAtom.getASAtom(StaticResources.getRoleMapHelper().getStandardType(type.getType()))); diff --git a/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/gfse/GFSETable.java b/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/gfse/GFSETable.java index 493f77f1b..b800f3883 100644 --- a/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/gfse/GFSETable.java +++ b/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/gfse/GFSETable.java @@ -20,15 +20,14 @@ */ package org.verapdf.gf.model.impl.pd.gfse; +import org.verapdf.gf.model.impl.containers.StaticContainers; import org.verapdf.gf.model.impl.pd.GFPDStructElem; import org.verapdf.model.selayer.SETable; import org.verapdf.model.pdlayer.PDStructElem; +import org.verapdf.pdfa.flavours.PDFAFlavour; import org.verapdf.tools.TaggedPDFConstants; -import java.util.List; -import java.util.Set; -import java.util.HashSet; -import java.util.LinkedList; +import java.util.*; public class GFSETable extends GFPDStructElem implements SETable { @@ -55,7 +54,8 @@ public Boolean getuseHeadersAndIdOrScope() { } private void checkTable() { - List listTR = getTR(); + List rowGroupingsIndexes = new LinkedList<>(); + List listTR = getTR(rowGroupingsIndexes); int numberOfRows = listTR.size(); this.rowSpan = (long)numberOfRows; if (numberOfRows == 0) { @@ -65,7 +65,7 @@ private void checkTable() { int numberOfColumns = getNumberOfColumns(listTR.get(0)); this.columnSpan = (long)numberOfColumns; GFSETableCell[][] cells = new GFSETableCell[numberOfRows][numberOfColumns]; - if (!checkRegular(listTR, cells, numberOfRows, numberOfColumns)) { + if (!checkRegular(listTR, cells, numberOfRows, numberOfColumns, rowGroupingsIndexes)) { useHeadersAndIdOrScope = true; return; } @@ -98,7 +98,7 @@ private boolean hasScope(GFSETableCell[][] cells, int numberOfRows, int numberOf } private boolean checkRegular(List listTR, GFSETableCell[][] cells, - int numberOfRows, int numberOfColumns) { + int numberOfRows, int numberOfColumns, List rowGroupingsIndexes) { for (int rowNumber = 0; rowNumber < numberOfRows; rowNumber++) { int columnNumber = 0; for (PDStructElem elem : listTR.get(rowNumber).getStructuralSignificanceChildren()) { @@ -120,6 +120,14 @@ private boolean checkRegular(List listTR, GFSETableCell[][] cell this.numberOfColumnWithWrongRowSpan = (long)columnNumber; return false; } + if (StaticContainers.getFlavour() == PDFAFlavour.PDFUA_2) { + for (Integer rowGroupsIndex : rowGroupingsIndexes) { + if (rowNumber + rowSpan > rowGroupsIndex && rowNumber < rowGroupsIndex) { + this.numberOfColumnWithWrongRowSpan = (long)columnNumber; + return false; + } + } + } if (!checkRegular(cells, cell, rowSpan, colSpan, rowNumber, columnNumber)) { return false; } @@ -230,7 +238,7 @@ private boolean hasScope(GFSETableCell cell, int rowNumber, int columnNumber, St return false; } - private List getTR() { + private List getTR(List rowGroupingsIndexes) { List listTR = new LinkedList<>(); for (GFPDStructElem elem : getStructuralSignificanceChildren()) { String type = elem.getstandardType(); @@ -238,11 +246,13 @@ private List getTR() { listTR.add(elem); } else if (TaggedPDFConstants.THEAD.equals(type) || TaggedPDFConstants.TBODY.equals(type) || TaggedPDFConstants.TFOOT.equals(type)) { + rowGroupingsIndexes.add(listTR.size()); for (GFPDStructElem child : elem.getStructuralSignificanceChildren()) { if (TaggedPDFConstants.TR.equals(child.getstandardType())) { listTR.add(child); } } + rowGroupingsIndexes.add(listTR.size()); } } return listTR;