diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/java/org/apache/fop/fo/FONode.java | 10 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/FObj.java | 7 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/flow/TableBody.java | 9 |
3 files changed, 25 insertions, 1 deletions
diff --git a/src/java/org/apache/fop/fo/FONode.java b/src/java/org/apache/fop/fo/FONode.java index 4f9707c2d..ba7832858 100644 --- a/src/java/org/apache/fop/fo/FONode.java +++ b/src/java/org/apache/fop/fo/FONode.java @@ -198,6 +198,15 @@ public abstract class FONode implements Cloneable { } /** + * Removes a child node. Used by the child nodes to remove themselves, for + * example table-body if it has no children. + * @param child child node to be removed + */ + public void removeChild(FONode child) { + //nop + } + + /** * @return the parent node of this node */ public FONode getParent() { @@ -410,5 +419,6 @@ public abstract class FONode implements Cloneable { public int getNameId() { return Constants.FO_UNKNOWN_NODE; } + } diff --git a/src/java/org/apache/fop/fo/FObj.java b/src/java/org/apache/fop/fo/FObj.java index 87dc3bb1e..b3982bfa5 100644 --- a/src/java/org/apache/fop/fo/FObj.java +++ b/src/java/org/apache/fop/fo/FObj.java @@ -170,6 +170,13 @@ public abstract class FObj extends FONode implements Constants { } } + /** @see org.apache.fop.fo.FONode#removeChild(org.apache.fop.fo.FONode) */ + public void removeChild(FONode child) { + if (childNodes != null) { + childNodes.remove(child); + } + } + /** * Find the nearest parent, grandparent, etc. FONode that is also an FObj * @return FObj the nearest ancestor FONode that is an FObj diff --git a/src/java/org/apache/fop/fo/flow/TableBody.java b/src/java/org/apache/fop/fo/flow/TableBody.java index 28c182424..fd3b42341 100644 --- a/src/java/org/apache/fop/fo/flow/TableBody.java +++ b/src/java/org/apache/fop/fo/flow/TableBody.java @@ -88,6 +88,11 @@ public class TableBody extends FObj { */ protected void endOfNode() throws FOPException { getFOEventHandler().endBody(this); + if (childNodes == null || childNodes.size() == 0) { + getLogger().error("fo:table-body must not be empty. " + + "Expected: (table-row+|table-cell+)"); + getParent().removeChild(this); + } convertCellsToRows(); } @@ -98,7 +103,9 @@ public class TableBody extends FObj { */ private void convertCellsToRows() throws FOPException { try { - if (childNodes.size() == 0 || childNodes.get(0) instanceof TableRow) { + if (childNodes == null + || childNodes.size() == 0 + || childNodes.get(0) instanceof TableRow) { return; } //getLogger().debug("Converting cells to rows..."); |