diff options
author | Keiron Liddle <keiron@apache.org> | 2002-09-13 08:21:55 +0000 |
---|---|---|
committer | Keiron Liddle <keiron@apache.org> | 2002-09-13 08:21:55 +0000 |
commit | 6e820767d19b85e1475c6560a887bda5698120d2 (patch) | |
tree | 123e44a06a1b0c28197d91b9406ea1603d0949d5 /src/org/apache/fop/fo/flow | |
parent | cbfb6d81293a14bee16b2a3c41d7fd72bf92ec85 (diff) | |
download | xmlgraphics-fop-6e820767d19b85e1475c6560a887bda5698120d2.tar.gz xmlgraphics-fop-6e820767d19b85e1475c6560a887bda5698120d2.zip |
starting implementation of tables
fixed some more styling errors
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@195177 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache/fop/fo/flow')
-rw-r--r-- | src/org/apache/fop/fo/flow/Footnote.java | 19 | ||||
-rw-r--r-- | src/org/apache/fop/fo/flow/Leader.java | 12 | ||||
-rw-r--r-- | src/org/apache/fop/fo/flow/RowSpanMgr.java | 126 | ||||
-rw-r--r-- | src/org/apache/fop/fo/flow/Table.java | 167 | ||||
-rw-r--r-- | src/org/apache/fop/fo/flow/TableBody.java | 62 | ||||
-rw-r--r-- | src/org/apache/fop/fo/flow/TableCell.java | 11 | ||||
-rw-r--r-- | src/org/apache/fop/fo/flow/TableColumn.java | 12 | ||||
-rw-r--r-- | src/org/apache/fop/fo/flow/TableRow.java | 211 |
8 files changed, 194 insertions, 426 deletions
diff --git a/src/org/apache/fop/fo/flow/Footnote.java b/src/org/apache/fop/fo/flow/Footnote.java index 9ab5e13e2..4520ce636 100644 --- a/src/org/apache/fop/fo/flow/Footnote.java +++ b/src/org/apache/fop/fo/flow/Footnote.java @@ -22,6 +22,8 @@ import java.util.List; import java.util.ArrayList; public class Footnote extends FObj { + Inline inlineFO = null; + FootnoteBody body; public Footnote(FONode parent) { super(parent); @@ -29,9 +31,22 @@ public class Footnote extends FObj { public void addLayoutManager(List lms) { // add inlines layout manager - //inline.addLayoutManager(lms); - // set start and end footnote reference + if(inlineFO == null) { + getLogger().error("inline required in footnote"); + return; + } + inlineFO.addLayoutManager(lms); } + public void addChild(FONode child) { + String name = child.getName(); + if ("fo:inline".equals(name)) { + inlineFO = (Inline)child; + } else if ("fo:footnote-body".equals(name)) { + body = (FootnoteBody)child; + } else { + getLogger().error("invalid child of footnote: " + name); + } + } } diff --git a/src/org/apache/fop/fo/flow/Leader.java b/src/org/apache/fop/fo/flow/Leader.java index be4274cc3..54779f7ec 100644 --- a/src/org/apache/fop/fo/flow/Leader.java +++ b/src/org/apache/fop/fo/flow/Leader.java @@ -36,8 +36,7 @@ import java.util.ArrayList; /** * Implements fo:leader; main property of leader leader-pattern. - * The following patterns are treated: rule, space, dots. - * The pattern use-content is ignored, i.e. it still must be implemented. + * The following patterns are treated: rule, space, dots and use-content. */ public class Leader extends FObjMixed { int ruleStyle; @@ -61,6 +60,12 @@ public class Leader extends FObjMixed { protected MinOptMax getAllocationIPD(int refIPD) { return getAllocIPD(refIPD); } + + /*protected void offsetArea(LayoutContext context) { + if(leaderPattern == LeaderPattern.DOTS) { + curArea.setOffset(context.getBaseline()); + } + }*/ }; lm.setAlignment(properties.get("leader-alignment").getEnum()); list.add(lm); @@ -87,7 +92,7 @@ public class Leader extends FObjMixed { leaderArea = new Space(); } else if(leaderPattern == LeaderPattern.DOTS) { Word w = new Word(); - char dot = '.'; // userAgent.getLeaderDotChar(); + char dot = '.'; // userAgent.getLeaderDotCharacter(); w.setWord("" + dot); w.addTrait(Trait.FONT_NAME, fontState.getFontName()); @@ -108,6 +113,7 @@ public class Leader extends FObjMixed { if(spacer != null) { fa.addChild(spacer); } + fa.setHeight(fontState.getAscender()); leaderArea = fa; } else if(leaderPattern == LeaderPattern.USECONTENT) { diff --git a/src/org/apache/fop/fo/flow/RowSpanMgr.java b/src/org/apache/fop/fo/flow/RowSpanMgr.java deleted file mode 100644 index aaae9fe53..000000000 --- a/src/org/apache/fop/fo/flow/RowSpanMgr.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * -- $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 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) { - } - 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 < numCols - 1; i++) { - spanInfo[firstCol + i] = new SpanInfo(null, cellHeight, - rowsSpanned); // copy! - } - } - - public boolean isSpanned(int colNum) { - return (spanInfo[colNum - 1] != null); - } - - - public TableCell getSpanningCell(int colNum) { - if (spanInfo[colNum - 1] != null) { - return spanInfo[colNum - 1].cell; - } else - return null; - } - - - /** - * Return true if any column has an unfinished vertical span. - */ - public boolean hasUnfinishedSpans() { - for (int i = 0; i < spanInfo.length; i++) { - if (spanInfo[i] != null) - return true; - } - return false; - } - - /** - * Done with a row. - * Any spans with only one row left are done - * This means that we can now set the total height for this cell box - * Loop over all cells with spans and find number of rows remaining - * if rows remaining = 1, set the height on the cell area and - * then remove the cell from the list of spanned cells. For other - * spans, add the rowHeight to the spanHeight. - */ - public void finishRow(int rowHeight) { - for (int i = 0; i < spanInfo.length; i++) { - if (spanInfo[i] != null && spanInfo[i].finishRow(rowHeight)) - spanInfo[i] = null; - } - } - - /** - * If the cell in this column is in the last row of its vertical - * span, return the height left. If it's not in the last row, or if - * the content height <= the content height of the previous rows - * of the span, return 0. - */ - public int getRemainingHeight(int colNum) { - if (spanInfo[colNum - 1] != null) { - return spanInfo[colNum - 1].heightRemaining(); - } else - return 0; - } - - public boolean isInLastRow(int colNum) { - if (spanInfo[colNum - 1] != null) { - return spanInfo[colNum - 1].isInLastRow(); - } else - return false; - } - -} diff --git a/src/org/apache/fop/fo/flow/Table.java b/src/org/apache/fop/fo/flow/Table.java index 526ff429a..848cf34bc 100644 --- a/src/org/apache/fop/fo/flow/Table.java +++ b/src/org/apache/fop/fo/flow/Table.java @@ -14,13 +14,22 @@ import org.apache.fop.layout.*; import org.apache.fop.datatypes.*; import org.apache.fop.apps.FOPException; +import org.apache.fop.layoutmgr.table.TableLayoutManager; + // Java import java.util.ArrayList; +import java.util.List; import java.util.Iterator; public class Table extends FObj { - private static final int MINCOLWIDTH = 10000; // 10pt + + protected ArrayList columns = null; + TableBody tableHeader = null; + TableBody tableFooter = null; + boolean omitHeaderAtBreak = false; + boolean omitFooterAtBreak = false; + int breakBefore; int breakAfter; int spaceBefore; @@ -28,14 +37,8 @@ public class Table extends FObj { ColorType backgroundColor; LengthRange ipd; int height; - TableHeader tableHeader = null; - TableFooter tableFooter = null; - boolean omitHeaderAtBreak = false; - boolean omitFooterAtBreak = false; - ArrayList columns = new ArrayList(); - int bodyCount = 0; - private boolean bAutoLayout=false; + private boolean bAutoLayout = false; private int contentWidth = 0; // Sum of column widths /** Optimum inline-progression-dimension */ private int optIPD; @@ -48,65 +51,97 @@ public class Table extends FObj { super(parent); } + protected void addChild(FONode child) { + if(child.getName().equals("fo:table-column")) { + if(columns == null) { + columns = new ArrayList(); + } + columns.add(((TableColumn)child).getLayoutManager()); + } else if(child.getName().equals("fo:table-footer")) { + tableFooter = (TableBody)child; + } else if(child.getName().equals("fo:table-header")) { + tableHeader = (TableBody)child; + } else { + // add bodies + children.add(child); + } + } + + /** + * Return a LayoutManager responsible for laying out this FObj's content. + * Must override in subclasses if their content can be laid out. + */ + public void addLayoutManager(List list) { + TableLayoutManager tlm = new TableLayoutManager(this); + tlm.setColumns(columns); + if(tableHeader != null) { + tlm.setTableHeader(tableHeader.getLayoutManager()); + } + if(tableFooter != null) { + tlm.setTableFooter(tableFooter.getLayoutManager()); + } + list.add(tlm); + } + public void setup() { - // Common Accessibility Properties - AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); - - // Common Aural Properties - AuralProps mAurProps = propMgr.getAuralProps(); - - // Common Border, Padding, and Background Properties - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); - - // Common Margin Properties-Block - MarginProps mProps = propMgr.getMarginProps(); - - // Common Relative Position Properties - RelativePositionProps mRelProps = propMgr.getRelativePositionProps(); - - // this.properties.get("block-progression-dimension"); - // this.properties.get("border-after-precendence"); - // this.properties.get("border-before-precedence"); - // this.properties.get("border-collapse"); - // this.properties.get("border-end-precendence"); - // this.properties.get("border-separation"); - // this.properties.get("border-start-precendence"); - // this.properties.get("break-after"); - // this.properties.get("break-before"); - setupID(); - // this.properties.get("inline-progression-dimension"); - // this.properties.get("height"); - // this.properties.get("keep-together"); - // this.properties.get("keep-with-next"); - // this.properties.get("keep-with-previous"); - // this.properties.get("table-layout"); - // this.properties.get("table-omit-footer-at-break"); - // this.properties.get("table-omit-header-at-break"); - // this.properties.get("width"); - // this.properties.get("writing-mode"); - - this.breakBefore = this.properties.get("break-before").getEnum(); - this.breakAfter = this.properties.get("break-after").getEnum(); - this.spaceBefore = - this.properties.get("space-before.optimum").getLength().mvalue(); - this.spaceAfter = - this.properties.get("space-after.optimum").getLength().mvalue(); - this.backgroundColor = - this.properties.get("background-color").getColorType(); - this.ipd = - this.properties.get("inline-progression-dimension"). - getLengthRange(); - this.height = this.properties.get("height").getLength().mvalue(); - this.bAutoLayout = (this.properties.get("table-layout").getEnum() == - TableLayout.AUTO); - - this.omitHeaderAtBreak = - this.properties.get("table-omit-header-at-break").getEnum() - == TableOmitHeaderAtBreak.TRUE; - this.omitFooterAtBreak = - this.properties.get("table-omit-footer-at-break").getEnum() - == TableOmitFooterAtBreak.TRUE; + // Common Accessibility Properties + AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); + + // Common Aural Properties + AuralProps mAurProps = propMgr.getAuralProps(); + + // Common Border, Padding, and Background Properties + BorderAndPadding bap = propMgr.getBorderAndPadding(); + BackgroundProps bProps = propMgr.getBackgroundProps(); + + // Common Margin Properties-Block + MarginProps mProps = propMgr.getMarginProps(); + + // Common Relative Position Properties + RelativePositionProps mRelProps = + propMgr.getRelativePositionProps(); + + // this.properties.get("block-progression-dimension"); + // this.properties.get("border-after-precendence"); + // this.properties.get("border-before-precedence"); + // this.properties.get("border-collapse"); + // this.properties.get("border-end-precendence"); + // this.properties.get("border-separation"); + // this.properties.get("border-start-precendence"); + // this.properties.get("break-after"); + // this.properties.get("break-before"); + setupID(); + // this.properties.get("inline-progression-dimension"); + // this.properties.get("height"); + // this.properties.get("keep-together"); + // this.properties.get("keep-with-next"); + // this.properties.get("keep-with-previous"); + // this.properties.get("table-layout"); + // this.properties.get("table-omit-footer-at-break"); + // this.properties.get("table-omit-header-at-break"); + // this.properties.get("width"); + // this.properties.get("writing-mode"); + + this.breakBefore = this.properties.get("break-before").getEnum(); + this.breakAfter = this.properties.get("break-after").getEnum(); + this.spaceBefore = this.properties.get( + "space-before.optimum").getLength().mvalue(); + this.spaceAfter = this.properties.get( + "space-after.optimum").getLength().mvalue(); + this.backgroundColor = + this.properties.get("background-color").getColorType(); + this.ipd = this.properties.get( + "inline-progression-dimension"). getLengthRange(); + this.height = this.properties.get("height").getLength().mvalue(); + this.bAutoLayout = (this.properties.get("table-layout").getEnum() == + TableLayout.AUTO); + + this.omitHeaderAtBreak = this.properties.get( + "table-omit-header-at-break").getEnum() == + TableOmitHeaderAtBreak.TRUE; + this.omitFooterAtBreak = this.properties.get( + "table-omit-footer-at-break").getEnum() == + TableOmitFooterAtBreak.TRUE; } diff --git a/src/org/apache/fop/fo/flow/TableBody.java b/src/org/apache/fop/fo/flow/TableBody.java index 7d9d07940..b593b2f54 100644 --- a/src/org/apache/fop/fo/flow/TableBody.java +++ b/src/org/apache/fop/fo/flow/TableBody.java @@ -14,8 +14,11 @@ import org.apache.fop.datatypes.*; import org.apache.fop.layout.*; import org.apache.fop.apps.FOPException; +import org.apache.fop.layoutmgr.table.Body; + // Java import java.util.ArrayList; +import java.util.List; import java.util.Iterator; public class TableBody extends FObj { @@ -24,39 +27,46 @@ public class TableBody extends FObj { int spaceAfter; ColorType backgroundColor; - ArrayList columns; - RowSpanMgr rowSpanMgr; // manage information about spanning rows - public TableBody(FONode parent) { super(parent); } - public void setColumns(ArrayList columns) { - this.columns = columns; + /** + * Return a LayoutManager responsible for laying out this FObj's content. + * Must override in subclasses if their content can be laid out. + */ + public void addLayoutManager(List list) { + list.add(getLayoutManager()); + } + + public Body getLayoutManager() { + Body blm = new Body(this); + return blm; } public void setup() throws FOPException { - // Common Accessibility Properties - AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); - - // Common Aural Properties - AuralProps mAurProps = propMgr.getAuralProps(); - - // Common Border, Padding, and Background Properties - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); - - // Common Relative Position Properties - RelativePositionProps mRelProps = propMgr.getRelativePositionProps(); - - setupID(); - - this.spaceBefore = - this.properties.get("space-before.optimum").getLength().mvalue(); - this.spaceAfter = - this.properties.get("space-after.optimum").getLength().mvalue(); - this.backgroundColor = - this.properties.get("background-color").getColorType(); + // Common Accessibility Properties + AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); + + // Common Aural Properties + AuralProps mAurProps = propMgr.getAuralProps(); + + // Common Border, Padding, and Background Properties + BorderAndPadding bap = propMgr.getBorderAndPadding(); + BackgroundProps bProps = propMgr.getBackgroundProps(); + + // Common Relative Position Properties + RelativePositionProps mRelProps = + propMgr.getRelativePositionProps(); + + setupID(); + + this.spaceBefore = this.properties.get( + "space-before.optimum").getLength().mvalue(); + this.spaceAfter = this.properties.get( + "space-after.optimum").getLength().mvalue(); + this.backgroundColor = + this.properties.get("background-color").getColorType(); } diff --git a/src/org/apache/fop/fo/flow/TableCell.java b/src/org/apache/fop/fo/flow/TableCell.java index 21dc31e71..5fe6caad1 100644 --- a/src/org/apache/fop/fo/flow/TableCell.java +++ b/src/org/apache/fop/fo/flow/TableCell.java @@ -14,8 +14,12 @@ import org.apache.fop.layout.*; import org.apache.fop.apps.FOPException; import org.apache.fop.datatypes.*; +import org.apache.fop.layoutmgr.table.Cell; + import org.xml.sax.Attributes; +import java.util.List; + public class TableCell extends FObj { // int spaceBefore; @@ -92,6 +96,13 @@ public class TableCell extends FObj { doSetup(); // init some basic property values } + /** + */ + public void addLayoutManager(List list) { + Cell clm = new Cell(this); + list.add(clm); + } + // Set position relative to table (set by body?) public void setStartOffset(int offset) { startOffset = offset; diff --git a/src/org/apache/fop/fo/flow/TableColumn.java b/src/org/apache/fop/fo/flow/TableColumn.java index 17390e672..cc014323a 100644 --- a/src/org/apache/fop/fo/flow/TableColumn.java +++ b/src/org/apache/fop/fo/flow/TableColumn.java @@ -14,6 +14,10 @@ import org.apache.fop.layout.*; import org.apache.fop.apps.FOPException; import org.apache.fop.datatypes.*; +import org.apache.fop.layoutmgr.LayoutManager; +import org.apache.fop.layoutmgr.table.Column; + + public class TableColumn extends FObj { ColorType backgroundColor; @@ -30,6 +34,11 @@ public class TableColumn extends FObj { super(parent); } + public LayoutManager getLayoutManager() { + doSetup(); + return new Column(this); + } + public Length getColumnWidthAsLength() { return columnWidthPropVal; } @@ -54,7 +63,7 @@ public class TableColumn extends FObj { return numColumnsRepeated; } - public void doSetup() throws FOPException { + public void doSetup() { // Common Border, Padding, and Background Properties // only background apply, border apply if border-collapse @@ -88,3 +97,4 @@ public class TableColumn extends FObj { } } + diff --git a/src/org/apache/fop/fo/flow/TableRow.java b/src/org/apache/fop/fo/flow/TableRow.java index cec10dde9..fdf2284d5 100644 --- a/src/org/apache/fop/fo/flow/TableRow.java +++ b/src/org/apache/fop/fo/flow/TableRow.java @@ -14,8 +14,11 @@ import org.apache.fop.datatypes.*; import org.apache.fop.layout.*; import org.apache.fop.apps.FOPException; +import org.apache.fop.layoutmgr.table.Row; + // Java import java.util.ArrayList; +import java.util.List; import java.util.Iterator; public class TableRow extends FObj { @@ -29,140 +32,17 @@ public class TableRow extends FObj { KeepValue keepWithPrevious; KeepValue keepTogether; - int widthOfCellsSoFar = 0; - int largestCellHeight = 0; int minHeight = 0; // force row height - ArrayList columns; - - boolean areaAdded = false; - - private RowSpanMgr rowSpanMgr = null; - private CellArray cellArray = null; - - private static class CellArray { - public static final byte EMPTY = 0; - public static final byte CELLSTART = 1; - public static final byte CELLSPAN = 2; - - private TableCell[] cells; - private byte[] states; - - public CellArray(RowSpanMgr rsi, int numColumns) { - // Initialize the cell array by marking any cell positions - // occupied by spans from previous rows - cells = new TableCell[numColumns]; - states = new byte[numColumns]; - for (int i = 0; i < numColumns; i++) { - if (rsi.isSpanned(i + 1)) { - cells[i] = rsi.getSpanningCell(i + 1); - states[i] = CELLSPAN; - } else - states[i] = EMPTY; - } - } - - /** - * Return column which doesn't already contain a span or a cell - * If past the end or no free cells after colNum, return -1 - * Otherwise return value >= input value. - */ - int getNextFreeCell(int colNum) { - for (int i = colNum - 1; i < states.length; i++) { - if (states[i] == EMPTY) - return i + 1; - } - return -1; - } - - - /** - * Return type of cell in colNum (1 based) - */ - int getCellType(int colNum) { - if (colNum > 0 && colNum <= cells.length) { - return states[colNum - 1]; - } else - return -1; // probably should throw exception - } - - /** - * Return cell in colNum (1 based) - */ - TableCell getCell(int colNum) { - if (colNum > 0 && colNum <= cells.length) { - return cells[colNum - 1]; - } else - return null; // probably should throw exception - } - - /** - * Store cell starting at cellColNum (1 based) and spanning numCols - * If any of the columns is already occupied, return false, else true - */ - boolean storeCell(TableCell cell, int colNum, int numCols) { - boolean rslt = true; - int index = colNum - 1; - for (int count = 0; index < cells.length && count < numCols; - count++, index++) { - if (cells[index] == null) { - cells[index] = cell; - states[index] = (count == 0) ? CELLSTART : CELLSPAN; - } else { - rslt = false; - // print a message but continue!!! - } - } - return rslt; - } - - // private class EnumCells implements Enumeration { - // private int iNextIndex=0; - // private Object nextCell = null; - // EnumCells() { - // findNextCell(); - // } - - // private void findNextCell() { - // for (; iNextIndex < cells.length; iNextIndex++) { - // if (states[iNextIndex] == CELLSTART) { - // nextCell = cells[iNextIndex]; - // return; - // } - // } - // nextCell = null; - // } - - // public boolean hasMoreElements() { - // return (nextCell != null); - // } - - // public Object nextElement() { - // if (nextCell != null) { - // Object cell = nextCell; - // findNextCell(); - // return cell; - // } - // else throw new java.util.NoSuchElementException("No more cells"); - // } - // } - - // /** - // * Return an enumeration over all cells in this row - // * Return each element in cells whose state is CELLSTART or EMPTY? - // * Skip spanning elements. - // */ - // Enumeration getCells() { - // return new EnumCells(); - // } - } - public TableRow(FONode parent) { super(parent); } - public void setColumns(ArrayList columns) { - this.columns = columns; + /** + */ + public void addLayoutManager(List list) { + Row rlm = new Row(this); + list.add(rlm); } public KeepValue getKeepWithPrevious() { @@ -225,78 +105,5 @@ public class TableRow extends FObj { // break; } } - - /** - * Called by parent FO to initialize information about - * cells started in previous rows which span into this row. - * The layout operation modifies rowSpanMgr - */ - public void setRowSpanMgr(RowSpanMgr rowSpanMgr) { - this.rowSpanMgr = rowSpanMgr; - } - - /** - * Before starting layout for the first time, initialize information - * about spanning rows, empty cells and spanning columns. - */ - private void initCellArray() { - cellArray = new CellArray(rowSpanMgr, columns.size()); - int colNum = 1; - Iterator eCells = children.iterator(); - while (eCells.hasNext()) { - colNum = cellArray.getNextFreeCell(colNum); - // If off the end, the rest of the cells had better be - // explicitly positioned!!! (returns -1) - - TableCell cell = (TableCell)eCells.next(); - int numCols = cell.getNumColumnsSpanned(); - int numRows = cell.getNumRowsSpanned(); - int cellColNum = cell.getColumnNumber(); - - if (cellColNum == 0) { - // Not explicitly specified, so put in next available colummn - // cell.setColumnNumber(colNum); - // If cellColNum "off the end", this cell is in limbo! - if (colNum < 1) { - // ERROR!!! - continue; - } else - cellColNum = colNum; - } else if (cellColNum > columns.size()) { - // Explicit specification out of range! - // Skip it and print an ERROR MESSAGE - continue; - } - // see if it fits and doesn't overwrite anything - if (cellColNum + numCols - 1 > columns.size()) { - // MESSAGE: TOO MANY COLUMNS SPANNED! - numCols = columns.size() - cellColNum + 1; - } - // Check for overwriting other cells (returns false) - if (cellArray.storeCell(cell, cellColNum, numCols) == false) { - // Print out some kind of warning message. - } - if (cellColNum > colNum) { - // Cells are initialized as empty already - colNum = cellColNum; - } else if (cellColNum < colNum) { - // MESSAGE ? cells out of order? - colNum = cellColNum; // CR "to the letter"! - } - int cellWidth = getCellWidth(cellColNum, numCols); - cell.setWidth(cellWidth); - colNum += numCols; // next cell in this column - } - } - - // ATTENTION if startCol + numCols > number of columns in table! - private int getCellWidth(int startCol, int numCols) { - int width = 0; - for (int count = 0; count < numCols; count++) { - width += ((TableColumn)columns.get(startCol + count - - 1)).getColumnWidth(); - } - return width; - } - } + |