From 83f9038f807b87dbb77e6b119a1026f9cd0b278f Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Wed, 29 Jun 2005 12:41:31 +0000 Subject: [PATCH] notifyFlowsFinished() indirectly used by multi-column layout to determine the restart point after span changes. getRemainingBPD() is used by the page breaking process in multi-column layout (multiple spans). git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@202361 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/area/BodyRegion.java | 18 +++++++++++ src/java/org/apache/fop/area/Span.java | 33 ++++++++++++++++++-- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/src/java/org/apache/fop/area/BodyRegion.java b/src/java/org/apache/fop/area/BodyRegion.java index ceb28b043..1138f3089 100644 --- a/src/java/org/apache/fop/area/BodyRegion.java +++ b/src/java/org/apache/fop/area/BodyRegion.java @@ -18,6 +18,8 @@ package org.apache.fop.area; +import java.util.List; + import org.apache.fop.fo.pagination.RegionBody; /** @@ -36,6 +38,8 @@ public class BodyRegion extends RegionReference { /** * Constructor which can read traits directly * from an fo:region-body formatting object. + * @param rb the region-body FO node + * @param parent the parent region viewport */ public BodyRegion(RegionBody rb, RegionViewport parent) { super(rb, parent); @@ -103,6 +107,20 @@ public class BodyRegion extends RegionReference { return footnote; } + /** + * @return the available BPD in the main reference area after the previous span reference + * areas are subtracted. + */ + public int getRemainingBPD() { + int usedBPD = 0; + List spans = getMainReference().getSpans(); + int previousSpanCount = spans.size() - 1; + for (int i = 0; i < previousSpanCount; i++) { + usedBPD += ((Span)spans.get(i)).getHeight(); + } + return getBPD() - usedBPD; + } + /** * Clone this object. * diff --git a/src/java/org/apache/fop/area/Span.java b/src/java/org/apache/fop/area/Span.java index 000908c75..bbe9b6db5 100644 --- a/src/java/org/apache/fop/area/Span.java +++ b/src/java/org/apache/fop/area/Span.java @@ -31,7 +31,6 @@ import java.util.List; public class Span extends Area { // the list of flow reference areas in this span area private List flowAreas; - private int height; private int colCount; private int colGap; private int colWidth; // width for each normal flow, calculated value @@ -90,7 +89,7 @@ public class Span extends Area { * @return the height of this span area */ public int getHeight() { - return height; + return getBPD(); } @@ -119,6 +118,11 @@ public class Span extends Area { return getNormalFlow(curFlowIdx); } + /** @return the index of the current normal flow */ + public int getCurrentFlowIndex() { + return curFlowIdx; + } + /** * Indicate to the Span that the next column is being * processed. @@ -143,5 +147,30 @@ public class Span extends Area { public boolean hasMoreFlows() { return (curFlowIdx < colCount - 1); } + + /** + * Called to notify the span that all its flows have been fully generated so it can update + * its own BPD extent. + */ + public void notifyFlowsFinished() { + int maxFlowBPD = 0; + for (int i = 0; i < colCount; i++) { + maxFlowBPD = Math.max(maxFlowBPD, getNormalFlow(i).getAllocBPD()); + } + bpd = maxFlowBPD; + } + + /** @see java.lang.Object#toString() */ + public String toString() { + StringBuffer sb = new StringBuffer(super.toString()); + if (colCount > 1) { + sb.append(" {colCount=").append(colCount); + sb.append(", colWidth=").append(colWidth); + sb.append(", curFlowIdx=").append(this.curFlowIdx); + sb.append("}"); + } + return sb.toString(); + } + } -- 2.39.5