From 1011fe2181fffbf37b806103a28f5ab3e0fe6b9c Mon Sep 17 00:00:00 2001 From: Luca Furini Date: Tue, 14 Jun 2005 16:12:08 +0000 Subject: [PATCH] The bpd of lines with no real content must collapse to 0 git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198744 13f79535-47bb-0310-9956-ffa450edef68 --- .../fop/layoutmgr/LineLayoutManager.java | 40 +++++++++++++------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java index f1063ad25..13befec2c 100644 --- a/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java @@ -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, -- 2.39.5