aboutsummaryrefslogtreecommitdiffstats
path: root/fop-core/src/main
diff options
context:
space:
mode:
authorSimon Steiner <ssteiner@apache.org>2022-09-09 14:52:08 +0000
committerSimon Steiner <ssteiner@apache.org>2022-09-09 14:52:08 +0000
commit142ae43d6333de7bbd17aa98d6a3107a02c759c8 (patch)
treea4e2419a045c476a200d66bd12411a37521f8e58 /fop-core/src/main
parentb76f5ecf37ff2548cbc2d4700baefaf15d69559c (diff)
downloadxmlgraphics-fop-142ae43d6333de7bbd17aa98d6a3107a02c759c8.tar.gz
xmlgraphics-fop-142ae43d6333de7bbd17aa98d6a3107a02c759c8.zip
FOP-3092: PDF/UA NPE when using external pdf
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1903941 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'fop-core/src/main')
-rw-r--r--fop-core/src/main/java/org/apache/fop/pdf/PDFStructElem.java15
1 files changed, 7 insertions, 8 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/pdf/PDFStructElem.java b/fop-core/src/main/java/org/apache/fop/pdf/PDFStructElem.java
index 603402ac2..8386241c8 100644
--- a/fop-core/src/main/java/org/apache/fop/pdf/PDFStructElem.java
+++ b/fop-core/src/main/java/org/apache/fop/pdf/PDFStructElem.java
@@ -37,6 +37,8 @@ import org.apache.fop.util.LanguageTags;
*/
public class PDFStructElem extends StructureHierarchyMember
implements StructureTreeElement, CompressedObject, Serializable {
+ private static final List<StructureType> BLSE = Arrays.asList(StandardStructureTypes.Table.TABLE,
+ StandardStructureTypes.List.L, StandardStructureTypes.Paragraphlike.P);
private static final long serialVersionUID = -3055241807589202532L;
private StructureType structureType;
@@ -253,12 +255,9 @@ public class PDFStructElem extends StructureHierarchyMember
put("Alt", "No alternate text specified");
} else if (kids != null) {
for (PDFObject kid : kids) {
- if (kid instanceof PDFStructElem
- && !(kid instanceof Placeholder)
- && structureType.toString().equals("P")
- && isBSLE(((PDFStructElem) kid).getStructureType().toString())) {
+ if (kid instanceof PDFStructElem && isBSLE(((PDFStructElem) kid))) {
structureType = StandardStructureTypes.Grouping.DIV;
- put("S", StandardStructureTypes.Grouping.DIV.getName());
+ put("S", structureType.getName());
break;
}
}
@@ -267,9 +266,9 @@ public class PDFStructElem extends StructureHierarchyMember
return super.output(stream);
}
- private boolean isBSLE(String type) {
- String[] blseValues = {"Table", "L", "P"};
- return Arrays.asList(blseValues).contains(type);
+ private boolean isBSLE(PDFStructElem kid) {
+ boolean pType = !(kid instanceof Placeholder) && structureType == StandardStructureTypes.Paragraphlike.P;
+ return pType && BLSE.contains(kid.getStructureType());
}
/**