Skip to content

Commit

Permalink
Add Kids link to GFPDFormField
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximPlusov committed Apr 10, 2024
1 parent 6ca2b9b commit cba668e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class GFPDFormField extends GFPDObject implements PDFormField {
public static final String ADDITIONAL_ACTION = "AA";

public static final String LANG = "Lang";
public static final String KIDS = "Kids";

public GFPDFormField(org.verapdf.pd.form.PDFormField simplePDObject) {
super(simplePDObject, FORM_FIELD_TYPE);
Expand Down Expand Up @@ -114,6 +115,8 @@ public List<? extends Object> getLinkedObjects(String link) {
return this.getAdditionalAction();
case LANG:
return this.getLang();
case KIDS:
return this.getKids();
default:
return super.getLinkedObjects(link);
}
Expand All @@ -130,4 +133,16 @@ private List<PDAdditionalActions> getAdditionalAction() {

return Collections.emptyList();
}

private List<PDFormField> getKids() {
List<org.verapdf.pd.form.PDFormField> childFormFields = ((org.verapdf.pd.form.PDFormField) this.simplePDObject).getChildFormFields();
if (childFormFields != null && !childFormFields.isEmpty()) {
List<PDFormField> res = new ArrayList<>();
for (org.verapdf.pd.form.PDFormField field : childFormFields) {
res.add(GFPDFormField.createTypedFormField(field));
}
return res;
}
return Collections.emptyList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.verapdf.pd.PDAnnotation;
import org.verapdf.pd.PDPage;
import org.verapdf.pd.annotations.PDWidgetAnnotation;
import org.verapdf.pd.form.PDFormField;
import org.verapdf.pd.structure.PDStructElem;
import org.verapdf.tools.StaticResources;
import org.verapdf.tools.TaggedPDFConstants;
Expand All @@ -54,21 +55,12 @@ public String getTU() {
}

private boolean isField() {
return ((PDWidgetAnnotation) simplePDObject).getT() != null;
return PDFormField.isField(simplePDObject.getObject());
}

@Override
protected boolean isSignature() {
ASAtom FT = null;
if (!isField()) {
COSObject parent = ((PDWidgetAnnotation) simplePDObject).getParent();
if (parent != null) {
FT = parent.getNameKey(ASAtom.FT);
}
} else {
FT = ((PDAnnotation) simplePDObject).getFT();
}
return ASAtom.SIG.equals(FT);
return ASAtom.SIG.equals(((PDAnnotation) simplePDObject).getFT());
}

@Override
Expand Down

0 comments on commit cba668e

Please sign in to comment.