From: Karen Lease Date: Thu, 5 Jul 2001 20:05:49 +0000 (+0000) Subject: Helper class for spanning rows X-Git-Tag: PRE_CODEFORMATTING~45 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c82713e4e2bbb94f17fb3a19df340ef9f34a1a4a;p=xmlgraphics-fop.git Helper class for spanning rows git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194334 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/org/apache/fop/fo/flow/RowSpanMgr.java b/src/org/apache/fop/fo/flow/RowSpanMgr.java new file mode 100644 index 000000000..96853307d --- /dev/null +++ b/src/org/apache/fop/fo/flow/RowSpanMgr.java @@ -0,0 +1,125 @@ +/*-- $Id$ -- + * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. + * For details on use and redistribution please refer to the + * LICENSE file included with these sources. + */ + +package org.apache.fop.fo.flow; + +import org.apache.fop.layout.Area; +import java.util.Enumeration; + +public class RowSpanMgr { + class SpanInfo { + int cellHeight; + int totalRowHeight; + int rowsRemaining; + //int numCols; // both V and H span + TableCell cell; + + SpanInfo(TableCell cell, int cellHeight, int rowsSpanned) { + this.cell = cell; + this.cellHeight = cellHeight; + this.totalRowHeight = 0; + this.rowsRemaining = rowsSpanned; + } + + /** + * Return the height remaining in the span. + */ + int heightRemaining() { + int hl = cellHeight - totalRowHeight; + return (hl>0)? hl : 0; + } + + boolean isInLastRow() { + return (rowsRemaining == 1); + } + + boolean finishRow(int rowHeight) { + totalRowHeight += rowHeight; + if (--rowsRemaining == 0) { + if (cell != null) { + cell.setRowHeight(totalRowHeight); + } + return true; + } + else return false; + } + } + + private SpanInfo spanInfo[]; + + public RowSpanMgr(int numCols) { + this.spanInfo = new SpanInfo[numCols]; + } + + public void addRowSpan(TableCell cell, int firstCol, int numCols, + int cellHeight, int rowsSpanned) { + spanInfo[firstCol-1] = new SpanInfo(cell, cellHeight, rowsSpanned); + for (int i=0; i