]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Fixed the source for a division by zero when the content of an fo:leader with leader...
authorJeremias Maerki <jeremias@apache.org>
Thu, 14 Aug 2008 13:03:20 +0000 (13:03 +0000)
committerJeremias Maerki <jeremias@apache.org>
Thu, 14 Aug 2008 13:03:20 +0000 (13:03 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@685879 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java
status.xml
test/layoutengine/standard-testcases/leader_leader-pattern_use-content.xml

index 1e163bef825dbe4e7796d357f9e60a6ebd52291d..f3bbc454a0095bef5c1c563455581241fbb39bb8 100644 (file)
@@ -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;
index 3b9d8d750b18f7bd6f8ea76d3217118b978a6663..4183f9a65fc51bf51961e92c0f3cdb661db0c511 100644 (file)
 
   <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>
index c98bd45116aeef826c63ea39abe1bd9b3107cda4..2a5c72c14cb29db530313ddfb7de867601211b7e 100644 (file)
                 </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>
     <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>