From c896715f6425ff053f1289a7a88249873b4f1096 Mon Sep 17 00:00:00 2001 From: Maxim Date: Tue, 10 Oct 2023 17:45:08 +0300 Subject: [PATCH] PDF/UA-2. Add new methods --- .../gf/model/impl/pd/GFPDFormField.java | 5 ++++ .../gf/model/impl/pd/GFPDStructElem.java | 2 +- .../gf/model/impl/pd/gfse/GFSEFENote.java | 6 +++++ .../gf/model/impl/pd/gfse/GFSEFormula.java | 5 ++++ .../verapdf/gf/model/impl/pd/gfse/GFSEL.java | 23 +++++++++++++++++++ .../gf/model/impl/pd/gfse/GFSETOCI.java | 20 ++++++++++++++++ 6 files changed, 60 insertions(+), 1 deletion(-) diff --git a/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/GFPDFormField.java b/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/GFPDFormField.java index d3570d620..87ac3f8fc 100644 --- a/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/GFPDFormField.java +++ b/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/GFPDFormField.java @@ -100,6 +100,11 @@ public String getTU() { return ((org.verapdf.pd.form.PDFormField)this.simplePDObject).getTU(); } + @Override + public Long getFf() { + return ((org.verapdf.pd.form.PDFormField)this.simplePDObject).getFf(); + } + @Override public List getLinkedObjects(String link) { switch (link) { 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 f97938777..ea16bf641 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 @@ -241,7 +241,7 @@ public List getLinkedObjects(String link) { } } - private List getChildrenStandardTypes() { + public List getChildrenStandardTypes() { return getChildrenStandardTypes(this); } diff --git a/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/gfse/GFSEFENote.java b/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/gfse/GFSEFENote.java index 155105b23..d6c045a74 100644 --- a/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/gfse/GFSEFENote.java +++ b/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/gfse/GFSEFENote.java @@ -23,6 +23,7 @@ import org.verapdf.gf.model.impl.pd.GFPDStructElem; import org.verapdf.model.selayer.SEFENote; import org.verapdf.pd.structure.PDStructElem; +import org.verapdf.tools.AttributeHelper; import org.verapdf.tools.TaggedPDFConstants; public class GFSEFENote extends GFPDStructElem implements SEFENote { @@ -32,4 +33,9 @@ public class GFSEFENote extends GFPDStructElem implements SEFENote { public GFSEFENote(PDStructElem structElemDictionary) { super(structElemDictionary, TaggedPDFConstants.FENOTE, FE_NOTE_STRUCTURE_ELEMENT_TYPE); } + + @Override + public String getNoteType() { + return AttributeHelper.getNoteType(simplePDObject); + } } diff --git a/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/gfse/GFSEFormula.java b/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/gfse/GFSEFormula.java index dcfa27faa..39accd58f 100644 --- a/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/gfse/GFSEFormula.java +++ b/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/gfse/GFSEFormula.java @@ -32,4 +32,9 @@ public class GFSEFormula extends GFPDStructElem implements SEFormula { public GFSEFormula(PDStructElem structElemDictionary) { super(structElemDictionary, TaggedPDFConstants.FORMULA, FORMULA_STRUCTURE_ELEMENT_TYPE); } + + @Override + public Boolean getisMathFormula() { + return getChildrenStandardTypes().contains(TaggedPDFConstants.MATH_ML); + } } diff --git a/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/gfse/GFSEL.java b/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/gfse/GFSEL.java index 3afb5edca..113aa2087 100644 --- a/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/gfse/GFSEL.java +++ b/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/gfse/GFSEL.java @@ -23,6 +23,7 @@ import org.verapdf.gf.model.impl.pd.GFPDStructElem; import org.verapdf.model.selayer.SEL; import org.verapdf.pd.structure.PDStructElem; +import org.verapdf.tools.AttributeHelper; import org.verapdf.tools.TaggedPDFConstants; public class GFSEL extends GFPDStructElem implements SEL { @@ -32,4 +33,26 @@ public class GFSEL extends GFPDStructElem implements SEL { public GFSEL(PDStructElem structElemDictionary) { super(structElemDictionary, TaggedPDFConstants.L, L_STRUCTURE_ELEMENT_TYPE); } + + @Override + public String getListNumbering() { + return AttributeHelper.getListNumbering(simplePDObject); + } + + @Override + public Boolean getcontainsLabels() { + return containsLabels(this); + } + + private boolean containsLabels(GFPDStructElem elem) { + if (elem.getChildrenStandardTypes().contains(TaggedPDFConstants.LBL)) { + return true; + } + for (GFPDStructElem child : getChildren()) { + if (!TaggedPDFConstants.L.equals(child.getstandardType()) && containsLabels(child)) { + return true; + } + } + return false; + } } diff --git a/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/gfse/GFSETOCI.java b/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/gfse/GFSETOCI.java index c4d1df401..15f40981c 100644 --- a/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/gfse/GFSETOCI.java +++ b/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/gfse/GFSETOCI.java @@ -25,6 +25,8 @@ import org.verapdf.pd.structure.PDStructElem; import org.verapdf.tools.TaggedPDFConstants; +import java.util.List; + public class GFSETOCI extends GFPDStructElem implements SETOCI { public static final String TOCI_STRUCTURE_ELEMENT_TYPE = "SETOCI"; @@ -32,4 +34,22 @@ public class GFSETOCI extends GFPDStructElem implements SETOCI { public GFSETOCI(PDStructElem structElemDictionary) { super(structElemDictionary, TaggedPDFConstants.TOCI, TOCI_STRUCTURE_ELEMENT_TYPE); } + + @Override + public Boolean getcontainsRef() { + return containsRef((PDStructElem)simplePDObject); + } + + private boolean containsRef(PDStructElem elem) { + if (elem.containsRef()) { + return true; + } + List children = elem.getStructChildren(); + for (PDStructElem child : children) { + if (containsRef(child)) { + return true; + } + } + return false; + } }