Skip to content

Commit

Permalink
Add WCAG2.2 flavour
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximPlusov committed Dec 12, 2023
1 parent 6131be4 commit 631c3f1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
39 changes: 29 additions & 10 deletions src/main/java/org/verapdf/parser/PDFFlavour.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ public enum PDFFlavour {
PDFA_4_E(Specification.ISO_19005_4),
PDFUA_1(Specification.ISO_14289_1),
PDFUA_2(Specification.ISO_14289_2),
WCAG2_1(Specification.WCAG_2_1);
WCAG2_1(Specification.WCAG2_1),
WCAG2_2(Specification.WCAG2_2);

private final Specification specification;

private PDFFlavour(final Specification specification) {
this.specification = specification;
}
Expand All @@ -28,13 +29,31 @@ public Specification getSpecification() {
}

public enum Specification {
NO_STANDARD,
ISO_14289_1,
ISO_14289_2,
ISO_19005_1,
ISO_19005_2,
ISO_19005_3,
ISO_19005_4,
WCAG_2_1
NO_STANDARD(SpecificationFamily.NONE),
ISO_14289_1(SpecificationFamily.PDF_UA),
ISO_14289_2(SpecificationFamily.PDF_UA),
ISO_19005_1(SpecificationFamily.PDF_A),
ISO_19005_2(SpecificationFamily.PDF_A),
ISO_19005_3(SpecificationFamily.PDF_A),
ISO_19005_4(SpecificationFamily.PDF_A),
WCAG2_1(SpecificationFamily.WCAG),
WCAG2_2(SpecificationFamily.WCAG);

private final SpecificationFamily family;

Specification(final SpecificationFamily family) {
this.family = family;
}

public SpecificationFamily getFamily() {
return family;
}
}

public enum SpecificationFamily {
NONE,
PDF_A,
PDF_UA,
WCAG
}
}
4 changes: 2 additions & 2 deletions src/main/java/org/verapdf/pd/structure/PDStructElem.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ public List<Object> getChildren() {

public static StructureType getStructureElementStandardStructureType(PDStructElem pdStructElem) {
PDFFlavour flavour = StaticResources.getFlavour();
if (flavour.getSpecification() == PDFFlavour.Specification.ISO_19005_4 ||
flavour == PDFFlavour.PDFUA_2 || flavour == PDFFlavour.WCAG2_1) {
if (flavour.getSpecification() == PDFFlavour.Specification.ISO_19005_4 || flavour == PDFFlavour.PDFUA_2 ||
flavour.getSpecification().getFamily() == PDFFlavour.SpecificationFamily.WCAG) {
StructureType defaultStructureType = pdStructElem.getDefaultStructureType();
if (defaultStructureType != null) {
return defaultStructureType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public String getStandardType(ASAtom type) {
currentStandardTypes = TaggedPDFHelper.getPdf14StandardRoleTypes();
isFastStop = true;
} else {
if (StaticResources.getFlavour() == PDFFlavour.WCAG2_1) {
if (StaticResources.getFlavour().getSpecification().getFamily() == PDFFlavour.SpecificationFamily.WCAG) {
currentStandardTypes = TaggedPDFHelper.getWcagStandardRoleTypes();
} else {
currentStandardTypes = TaggedPDFHelper.getPdf17StandardRoleTypes();
Expand Down

0 comments on commit 631c3f1

Please sign in to comment.