diff options
author | Jeremias Maerki <jeremias@apache.org> | 2008-08-14 13:03:20 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2008-08-14 13:03:20 +0000 |
commit | 24bf14675b09101f0e0d9687a6882aef40813bea (patch) | |
tree | 1a62dde5e27f86cc7ececcb8d272e665ffa32833 | |
parent | 86e818b9359336bc5eab57e739e5af37999d265f (diff) | |
download | xmlgraphics-fop-24bf14675b09101f0e0d9687a6882aef40813bea.tar.gz xmlgraphics-fop-24bf14675b09101f0e0d9687a6882aef40813bea.zip |
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
-rw-r--r-- | src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java | 26 | ||||
-rw-r--r-- | status.xml | 4 | ||||
-rw-r--r-- | test/layoutengine/standard-testcases/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 @@ <changes> <release version="FOP Trunk" date="TBD"> + <action context="Layout" dev="JM" type="fix"> + Fixed the source for a NullPointerException when the content of an fo:leader with + leader-pattern="use-content" collapses to zero width during layout. + </action> <action context="Renderers" dev="JM" type="fix"> Fixed border trait parsing for the area tree XML when CMYK or ICC colors were used. </action> 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 @@ </fo:instream-foreign-object></fo:leader> Content is svg 20 x 10 which is wider than the leader-length </fo:block> + <fo:block> + <fo:leader leader-length="36pt" leader-pattern="use-content"> </fo:leader> + Content is " " + </fo:block> </fo:flow> </fo:page-sequence> </fo:root> @@ -172,5 +176,9 @@ <eval expected="0" xpath="//flow/block[7]/lineArea/inlineparent/inlineparent[1]/@offset"/> <eval expected="20000" xpath="//flow/block[7]/lineArea/inlineparent/inlineparent[1]/viewport/@ipd"/> <eval expected="-1384" xpath="//flow/block[7]/lineArea/inlineparent/inlineparent[1]/viewport/@offset"/> + + <eval expected="11100" xpath="//flow/block[8]/lineArea/@bpd"/> + <eval expected="36000" xpath="//flow/block[8]/lineArea/space[1]/@ipd"/> + <eval expected="0" xpath="//flow/block[8]/lineArea/space[1]/@offset"/> </checks> </testcase> |