From 24bf14675b09101f0e0d9687a6882aef40813bea Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Thu, 14 Aug 2008 13:03:20 +0000 Subject: Fixed the source for a division by zero when the content of an fo:leader with leader-pattern="use-content" collapses to zero width during layout. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@685879 13f79535-47bb-0310-9956-ffa450edef68 --- .../fop/layoutmgr/inline/LeaderLayoutManager.java | 26 +++++++++++++--------- status.xml | 4 ++++ .../leader_leader-pattern_use-content.xml | 8 +++++++ 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java index 1e163bef8..f3bbc454a 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java @@ -183,17 +183,23 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { childContext.setAlignmentContext(context.getAlignmentContext()); contentList = clm.getNextKnuthElements(childContext, 0); int width = clm.getStackingSize(); - Space spacer = null; - if (fobj.getLeaderPatternWidth().getValue(this) > width) { - spacer = new Space(); - spacer.setIPD(fobj.getLeaderPatternWidth().getValue(this) - width); - width = fobj.getLeaderPatternWidth().getValue(this); - } - fa.setUnitWidth(width); - if (spacer != null) { - fa.addChildArea(spacer); + if (width != 0) { + Space spacer = null; + if (fobj.getLeaderPatternWidth().getValue(this) > width) { + spacer = new Space(); + spacer.setIPD(fobj.getLeaderPatternWidth().getValue(this) - width); + width = fobj.getLeaderPatternWidth().getValue(this); + } + fa.setUnitWidth(width); + if (spacer != null) { + fa.addChildArea(spacer); + } + leaderArea = fa; + } else { + //Content collapsed to nothing, so use a space + leaderArea = new Space(); + leaderArea.setBPD(1); } - leaderArea = fa; } TraitSetter.setProducerID(leaderArea, fobj.getId()); return leaderArea; diff --git a/status.xml b/status.xml index 3b9d8d750..4183f9a65 100644 --- a/status.xml +++ b/status.xml @@ -53,6 +53,10 @@ + + Fixed the source for a NullPointerException when the content of an fo:leader with + leader-pattern="use-content" collapses to zero width during layout. + Fixed border trait parsing for the area tree XML when CMYK or ICC colors were used. diff --git a/test/layoutengine/standard-testcases/leader_leader-pattern_use-content.xml b/test/layoutengine/standard-testcases/leader_leader-pattern_use-content.xml index c98bd4511..2a5c72c14 100644 --- a/test/layoutengine/standard-testcases/leader_leader-pattern_use-content.xml +++ b/test/layoutengine/standard-testcases/leader_leader-pattern_use-content.xml @@ -69,6 +69,10 @@ Content is svg 20 x 10 which is wider than the leader-length + + + Content is " " + @@ -172,5 +176,9 @@ + + + + -- cgit v1.2.3