From 982cb1e1b2b29bd3ac3853c7bff2acb2f55dcf15 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Tue, 22 Feb 2005 15:32:45 +0000 Subject: [PATCH] Should run my own tests.... :-( Bugfix for NPE on empty cells. Skip adding helper areas for border painting when there are no borders to paint. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198455 13f79535-47bb-0310-9956-ffa450edef68 --- .../fop/fo/properties/CommonBorderPaddingBackground.java | 6 ++++++ src/java/org/apache/fop/layoutmgr/table/Cell.java | 4 ++++ src/java/org/apache/fop/layoutmgr/table/Row.java | 4 +++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java b/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java index fcaa0e217..f60b37bca 100755 --- a/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java +++ b/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java @@ -339,6 +339,12 @@ public class CommonBorderPaddingBackground implements Cloneable { return ((backgroundColor != null || getFopImage() != null)); } + /** @return true if border is non-zero. */ + public boolean hasBorder() { + return ((getBorderBeforeWidth(false) + getBorderAfterWidth(false) + + getBorderStartWidth(false) + getBorderEndWidth(false)) > 0); + } + /** @return true if padding is non-zero. */ public boolean hasPadding() { return ((getPaddingBefore(false) + getPaddingAfter(false) diff --git a/src/java/org/apache/fop/layoutmgr/table/Cell.java b/src/java/org/apache/fop/layoutmgr/table/Cell.java index cd2c9a7ba..2c66f6d39 100644 --- a/src/java/org/apache/fop/layoutmgr/table/Cell.java +++ b/src/java/org/apache/fop/layoutmgr/table/Cell.java @@ -324,6 +324,10 @@ public class Cell extends BlockStackingLayoutManager { int lastRowHeight = 0; for (int x = 0; x < gridUnits.size(); x++) { GridUnit gu = (GridUnit)gridUnits.get(x); + if (!gu.effBorders.hasBorder()) { + continue; + } + //Blocks for painting grid unit borders Block block = new Block(); block.addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE); diff --git a/src/java/org/apache/fop/layoutmgr/table/Row.java b/src/java/org/apache/fop/layoutmgr/table/Row.java index 29d1ce281..bd03c5e3b 100644 --- a/src/java/org/apache/fop/layoutmgr/table/Row.java +++ b/src/java/org/apache/fop/layoutmgr/table/Row.java @@ -220,7 +220,9 @@ public class Row extends BlockStackingLayoutManager { //Ending grid unit for current cell GridUnit ending = null; - pos += starting.layoutManager.getFObj().getNumberColumnsSpanned() - 1; + if (starting.layoutManager != null) { + pos += starting.layoutManager.getFObj().getNumberColumnsSpanned() - 1; + } ending = (GridUnit)gridUnits.get(pos - 1); //Neighbouring grid unit at end edge -- 2.39.5