]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
The bpd of lines with no real content must collapse to 0
authorLuca Furini <lfurini@apache.org>
Tue, 14 Jun 2005 16:12:08 +0000 (16:12 +0000)
committerLuca Furini <lfurini@apache.org>
Tue, 14 Jun 2005 16:12:08 +0000 (16:12 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198744 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/layoutmgr/LineLayoutManager.java

index f1063ad25337212c9985c0fbb0aaca59f36947d9..13befec2ccb65a39f3ac01f1379a81db855d42ed 100644 (file)
@@ -354,6 +354,10 @@ public class LineLayoutManager extends InlineStackingLayoutManager
             int maxtb = follow;
             // max size of middle alignment before and after the middle baseline
             int middlefollow = maxtb;
+            // true if this line contains only zero-height, auxiliary boxes
+            // and the actual line width is 0; in this case, the line "collapses"
+            // i.e. the line area will have bpd = 0
+            boolean bZeroHeightLine = (difference == iLineWidth);
 
             // if line-stacking-strategy is "font-height", the line height
             // is not affected by its content
@@ -379,6 +383,13 @@ public class LineLayoutManager extends InlineStackingLayoutManager
                             middlefollow += ((KnuthInlineBox) element).getMiddle()
                                             - middlefollow + middleShift;
                         }
+                        if (bZeroHeightLine
+                            && (!element.isAuxiliary()
+                                || ((KnuthInlineBox) element).getTotal() > 0
+                                || ((KnuthInlineBox) element).getLead() > 0
+                                || ((KnuthInlineBox) element).getMiddle() > 0)) {
+                            bZeroHeightLine = false;
+                        }
                     }
                 }
 
@@ -387,19 +398,24 @@ public class LineLayoutManager extends InlineStackingLayoutManager
                 }
             }
 
-            //lineLead += halfLeading;
-            //middlefollow += lineHeight - lead - follow - halfLeading;
-
             constantLineHeight = lineLead + middlefollow + (lineHeight - lead - follow);
-            //System.out.println("desired height: " + lineHeight + " actual height: " + (lineLead + middlefollow + (lineHeight - lead - follow)) + " halfleading = " + halfLeading + " and " + (lineHeight - lead - follow - halfLeading));
-
-            return new LineBreakPosition(thisLLM,
-                                         knuthParagraphs.indexOf(par),
-                                         lastElementIndex,
-                                         availableShrink, availableStretch, difference, ratio, 0, indent,
-                                         lineLead + middlefollow + (lineHeight - lead - follow), iLineWidth,
-                                         lineLead + halfLeading,
-                                         - lineLead, middlefollow);
+
+            if (bZeroHeightLine) {
+                return new LineBreakPosition(thisLLM,
+                                             knuthParagraphs.indexOf(par),
+                                             lastElementIndex,
+                                             availableShrink, availableStretch, difference, ratio, 0, indent,
+                                             0, iLineWidth,
+                                             0, 0, 0);
+            } else {
+                return new LineBreakPosition(thisLLM,
+                                             knuthParagraphs.indexOf(par),
+                                             lastElementIndex,
+                                             availableShrink, availableStretch, difference, ratio, 0, indent,
+                                             lineLead + middlefollow + (lineHeight - lead - follow), iLineWidth,
+                                             lineLead + halfLeading,
+                                             - lineLead, middlefollow);
+            }
         }
 
         public int findBreakingPoints(Paragraph par, int lineWidth,