|
37 | 37 | import org.apache.pdfbox.preflight.exception.ValidationException;
|
38 | 38 | import org.apache.pdfbox.preflight.utils.ContextHelper;
|
39 | 39 |
|
40 |
| - |
41 | 40 | import static org.apache.pdfbox.preflight.PreflightConfiguration.ANNOTATIONS_PROCESS;
|
42 | 41 | import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_ACTION_FORBIDDEN_ADDITIONAL_ACTIONS_FIELD;
|
43 | 42 | import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_ACTION_FORBIDDEN_WIDGET_ACTION_FIELD;
|
44 |
| -import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_SYNTAX_BODY; |
45 | 43 | import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_SYNTAX_DICT_INVALID;
|
46 | 44 | import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_SYNTAX_NOCATALOG;
|
47 | 45 |
|
@@ -97,34 +95,17 @@ protected void checkNeedAppearences(PreflightContext ctx, PDAcroForm acroForm)
|
97 | 95 | * @see #validateField(PreflightContext, PDField)
|
98 | 96 | *
|
99 | 97 | * @param ctx the preflight context.
|
100 |
| - * @param lFields the list of fields, can be null. |
| 98 | + * @param fields the list of fields, never null. |
101 | 99 | * @return the result of the validation.
|
102 | 100 | * @throws IOException
|
103 | 101 | */
|
104 |
| - protected boolean exploreFields(PreflightContext ctx, List<PDField> lFields) throws IOException |
| 102 | + protected boolean exploreFields(PreflightContext ctx, List<PDField> fields) throws IOException |
105 | 103 | {
|
106 |
| - if (lFields != null) |
| 104 | + for (PDField field : fields) |
107 | 105 | {
|
108 |
| - // the list can be null if the field doesn't have children |
109 |
| - for (Object obj : lFields) |
| 106 | + if (!validateField(ctx, field)) |
110 | 107 | {
|
111 |
| - if (obj instanceof PDField) |
112 |
| - { |
113 |
| - if (!validateField(ctx, (PDField) obj)) |
114 |
| - { |
115 |
| - return false; |
116 |
| - } |
117 |
| - } |
118 |
| - else if (obj instanceof PDAnnotationWidget) |
119 |
| - { |
120 |
| - // "A field's children in the hierarchy may also include widget annotations" |
121 |
| - ContextHelper.validateElement(ctx, ((PDAnnotationWidget) obj).getCOSObject(), ANNOTATIONS_PROCESS); |
122 |
| - } |
123 |
| - else |
124 |
| - { |
125 |
| - addValidationError(ctx, new ValidationError(ERROR_SYNTAX_BODY, |
126 |
| - "Field can only have fields or widget annotations as KIDS")); |
127 |
| - } |
| 108 | + return false; |
128 | 109 | }
|
129 | 110 | }
|
130 | 111 | return true;
|
|
0 commit comments