aboutsummaryrefslogtreecommitdiffstats
path: root/fop-core
diff options
context:
space:
mode:
authorSimon Steiner <ssteiner@apache.org>2021-04-22 10:45:11 +0000
committerSimon Steiner <ssteiner@apache.org>2021-04-22 10:45:11 +0000
commit5ce5fe50a74b9e3f84cabcffee46f860c86dbd47 (patch)
tree406c831e285c8157dda3226918a28bb7db479594 /fop-core
parent678d6c0e04fd6a5464012be0241bb771cf9bb506 (diff)
downloadxmlgraphics-fop-5ce5fe50a74b9e3f84cabcffee46f860c86dbd47.tar.gz
xmlgraphics-fop-5ce5fe50a74b9e3f84cabcffee46f860c86dbd47.zip
FOP-3008: Table with linefeed-treatment may give ClassCastException
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1889102 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'fop-core')
-rw-r--r--fop-core/src/main/java/org/apache/fop/fo/flow/Wrapper.java2
-rw-r--r--fop-core/src/main/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java2
-rw-r--r--fop-core/src/main/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java4
-rw-r--r--fop-core/src/main/java/org/apache/fop/layoutmgr/ElementListUtils.java3
-rw-r--r--fop-core/src/main/java/org/apache/fop/layoutmgr/KnuthPenalty.java4
-rw-r--r--fop-core/src/main/java/org/apache/fop/util/ListUtil.java10
6 files changed, 19 insertions, 6 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/fo/flow/Wrapper.java b/fop-core/src/main/java/org/apache/fop/fo/flow/Wrapper.java
index 39f472cbb..809125088 100644
--- a/fop-core/src/main/java/org/apache/fop/fo/flow/Wrapper.java
+++ b/fop-core/src/main/java/org/apache/fop/fo/flow/Wrapper.java
@@ -121,7 +121,7 @@ public class Wrapper extends FObjMixed implements CommonAccessibilityHolder {
while (ancestor.getNameId() == Constants.FO_WRAPPER) {
ancestor = ancestor.getParent();
}
- if (!(ancestor instanceof FObjMixed)) {
+ if (!(ancestor instanceof FObjMixed) && !child.toString().trim().isEmpty()) {
invalidChildError(
getLocator(),
getLocalName(),
diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java
index d731ab62a..e341078de 100644
--- a/fop-core/src/main/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java
+++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java
@@ -65,7 +65,7 @@ public final class AreaAdditionUtil {
}
lastPos = pos;
}
- if (pos instanceof NonLeafPosition) {
+ if (pos instanceof NonLeafPosition && pos.getPosition() != null) {
// pos was created by a child of this FlowLM
positionList.add(pos.getPosition());
lastLM = (pos.getPosition().getLM());
diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
index 4dddbcf11..1e55edd07 100644
--- a/fop-core/src/main/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
+++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
@@ -535,8 +535,8 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
return;
}
- ListElement last = ListUtil.getLast(contentList);
- if (last.isGlue()) {
+ ListElement last = ListUtil.getLastListElement(contentList);
+ if (last == null || last.isGlue()) {
// the last element in contentList is a glue;
// it is a feasible breakpoint, there is no need to add
// a penalty
diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/ElementListUtils.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/ElementListUtils.java
index 9b964843e..3920481e7 100644
--- a/fop-core/src/main/java/org/apache/fop/layoutmgr/ElementListUtils.java
+++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/ElementListUtils.java
@@ -178,7 +178,8 @@ public final class ElementListUtils {
* @return true if the list ends with a forced break
*/
public static boolean endsWithForcedBreak(List elems) {
- return ((ListElement) ListUtil.getLast(elems)).isForcedBreak();
+ ListElement last = ListUtil.getLastListElement(elems);
+ return last == null || last.isForcedBreak();
}
/**
diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/KnuthPenalty.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/KnuthPenalty.java
index 220f9c35d..c80cb389b 100644
--- a/fop-core/src/main/java/org/apache/fop/layoutmgr/KnuthPenalty.java
+++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/KnuthPenalty.java
@@ -19,6 +19,8 @@
package org.apache.fop.layoutmgr;
+import org.apache.fop.fo.Constants;
+
/**
* An instance of this class represents information about a feasible
* breaking point; it does not represent any piece of content.
@@ -47,7 +49,7 @@ public class KnuthPenalty extends KnuthElement {
private int penalty;
private boolean penaltyFlagged;
- private int breakClass = -1;
+ private int breakClass = Constants.EN_AUTO;
/**
* Create a new KnuthPenalty.
diff --git a/fop-core/src/main/java/org/apache/fop/util/ListUtil.java b/fop-core/src/main/java/org/apache/fop/util/ListUtil.java
index 8e88e4cbf..45af2b5c3 100644
--- a/fop-core/src/main/java/org/apache/fop/util/ListUtil.java
+++ b/fop-core/src/main/java/org/apache/fop/util/ListUtil.java
@@ -21,6 +21,8 @@ package org.apache.fop.util;
import java.util.List;
+import org.apache.fop.layoutmgr.ListElement;
+
/**
* Provides helper functions for {@link java.util.List}.
*
@@ -42,6 +44,14 @@ public final class ListUtil {
return list.get(list.size() - 1);
}
+ public static ListElement getLastListElement(List list) {
+ Object last = getLast(list);
+ if (last instanceof ListElement) {
+ return (ListElement) last;
+ }
+ return null;
+ }
+
/**
* Retrieve and remove the last element from a list.
*