From 6bccfa5456ce58842d6412e30f0b4e1cb6be6f69 Mon Sep 17 00:00:00 2001 From: Vincent Hennebert Date: Mon, 15 Mar 2010 18:36:21 +0000 Subject: [PATCH] Bugfix: NPE when there is a forced break before a table occurring at an IPD change git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@923380 13f79535-47bb-0310-9956-ffa450edef68 --- .../layoutmgr/table/TableLayoutManager.java | 18 +++++ .../flow_changing-ipd_break-before-table.xml | 74 +++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 test/layoutengine/standard-testcases/flow_changing-ipd_break-before-table.xml diff --git a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java index e12839b0b..7ccab7898 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java @@ -43,7 +43,9 @@ import org.apache.fop.layoutmgr.ConditionalElementListener; import org.apache.fop.layoutmgr.KnuthElement; import org.apache.fop.layoutmgr.KnuthGlue; import org.apache.fop.layoutmgr.LayoutContext; +import org.apache.fop.layoutmgr.LeafPosition; import org.apache.fop.layoutmgr.ListElement; +import org.apache.fop.layoutmgr.Position; import org.apache.fop.layoutmgr.PositionIterator; import org.apache.fop.layoutmgr.RelSide; import org.apache.fop.layoutmgr.TraitSetter; @@ -88,6 +90,8 @@ public class TableLayoutManager extends BlockStackingLayoutManager /** See {@link TableLayoutManager#registerColumnBackgroundArea(TableColumn, Block, int)}. */ private List columnBackgroundAreas; + private Position auxiliaryPosition; + /** * Temporary holder of column background informations for a table-cell's area. * @@ -290,6 +294,20 @@ public class TableLayoutManager extends BlockStackingLayoutManager return returnList; } + /** {@inheritDoc} */ + public Position getAuxiliaryPosition() { + /* + * Redefined to return a LeafPosition instead of a NonLeafPosition. The + * SpaceResolver.SpaceHandlingBreakPosition constructors unwraps all + * NonLeafPositions, which can lead to a NPE when a break in a table occurs at a + * page with different ipd. + */ + if (auxiliaryPosition == null) { + auxiliaryPosition = new LeafPosition(this, 0); + } + return auxiliaryPosition; + } + /** * Registers the given area, that will be used to render the part of column background * covered by a table-cell. If percentages are used to place the background image, the diff --git a/test/layoutengine/standard-testcases/flow_changing-ipd_break-before-table.xml b/test/layoutengine/standard-testcases/flow_changing-ipd_break-before-table.xml new file mode 100644 index 000000000..11496f80e --- /dev/null +++ b/test/layoutengine/standard-testcases/flow_changing-ipd_break-before-table.xml @@ -0,0 +1,74 @@ + + + + + +

+ Bugfix: NPE when a break-before was set on a table. +

+
+ + + + + + + + + + + + + + + + + Before the table + + + + + Cell 1.1 + + + Cell 1.2 + + + + + Cell 2.1 + + + Cell 2.2 + + + + + + + + + + + + + + +
-- 2.39.5