klease 01/09/20 13:29:22 Modified: src/org/apache/fop/fo/flow TableColumn.java Table.java Log: Use column-number property on table-column Revision Changes Path 1.19 +5 -3 xml-fop/src/org/apache/fop/fo/flow/TableColumn.java Index: TableColumn.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/flow/TableColumn.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- TableColumn.java 2001/08/06 09:12:59 1.18 +++ TableColumn.java 2001/09/20 20:29:22 1.19 @@ -1,5 +1,5 @@ /* - * $Id: TableColumn.java,v 1.18 2001/08/06 09:12:59 keiron Exp $ + * $Id: TableColumn.java,v 1.19 2001/09/20 20:29:22 klease Exp $ * 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. @@ -21,6 +21,7 @@ int columnWidth; int columnOffset; int numColumnsRepeated; + int iColumnNumber; boolean setup = false; @@ -48,7 +49,7 @@ } public int getColumnNumber() { - return 0; // not implemented yet + return iColumnNumber; } public int getNumColumnsRepeated() { @@ -63,12 +64,13 @@ BorderAndPadding bap = propMgr.getBorderAndPadding(); BackgroundProps bProps = propMgr.getBackgroundProps(); - // this.properties.get("column-number"); // this.properties.get("column-width"); // this.properties.get("number-columns-repeated"); // this.properties.get("number-columns-spanned"); // this.properties.get("visibility"); + this.iColumnNumber = + this.properties.get("column-number").getNumber().intValue(); this.numColumnsRepeated = this.properties.get("number-columns-repeated").getNumber().intValue(); 1.37 +62 -30 xml-fop/src/org/apache/fop/fo/flow/Table.java Index: Table.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/flow/Table.java,v retrieving revision 1.36 retrieving revision 1.37 diff -u -r1.36 -r1.37 --- Table.java 2001/09/18 10:39:16 1.36 +++ Table.java 2001/09/20 20:29:22 1.37 @@ -1,5 +1,5 @@ /* - * -- $Id: Table.java,v 1.36 2001/09/18 10:39:16 keiron Exp $ -- + * -- $Id: Table.java,v 1.37 2001/09/20 20:29:22 klease Exp $ -- * 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. @@ -16,6 +16,7 @@ // Java import java.util.Vector; +import java.util.Enumeration; public class Table extends FObj { @@ -45,7 +46,6 @@ boolean omitFooterAtBreak = false; Vector columns = new Vector(); - int currentColumnNumber = 0; int bodyCount = 0; AreaContainer areaContainer; @@ -165,34 +165,14 @@ areaContainer.setAbsoluteHeight(area.getAbsoluteHeight()); areaContainer.setIDReferences(area.getIDReferences()); - // added by Eric Schaeffer - currentColumnNumber = 0; - int offset = 0; - boolean addedHeader = false; boolean addedFooter = false; int numChildren = this.children.size(); - for (int i = 0; i < numChildren; i++) { - FONode fo = (FONode)children.elementAt(i); - if (fo instanceof TableColumn) { - TableColumn c = (TableColumn)fo; - c.doSetup(areaContainer); - int numColumnsRepeated = c.getNumColumnsRepeated(); - // int currentColumnNumber = c.getColumnNumber(); - for (int j = 0; j < numColumnsRepeated; j++) { - currentColumnNumber++; - if (currentColumnNumber > columns.size()) { - columns.setSize(currentColumnNumber); - } - columns.setElementAt(c, currentColumnNumber - 1); - c.setColumnOffset(offset); - c.layout(areaContainer); - offset += c.getColumnWidth(); - } - } - } - areaContainer.setAllocationWidth(offset); + // Set up the column vector + findColumns(areaContainer); + // Now layout all the columns and get total offset + areaContainer.setAllocationWidth( layoutColumns(areaContainer)); for (int i = this.marker; i < numChildren; i++) { FONode fo = (FONode)children.elementAt(i); @@ -345,13 +325,65 @@ } protected void setupColumnHeights() { - int numChildren = this.children.size(); - for (int i = 0; i < numChildren; i++) { - FONode fo = (FONode)children.elementAt(i); + Enumeration eCol = columns.elements(); + while (eCol.hasMoreElements()) { + TableColumn c = (TableColumn)eCol.nextElement(); + if ( c != null) { + c.setHeight(areaContainer.getContentHeight()); + } + } + } + + private void findColumns(Area areaContainer) throws FOPException { + int nextColumnNumber = 1; + Enumeration e = children.elements(); + while (e.hasMoreElements()) { + FONode fo = (FONode)e.nextElement(); if (fo instanceof TableColumn) { - ((TableColumn)fo).setHeight(areaContainer.getContentHeight()); + TableColumn c = (TableColumn)fo; + c.doSetup(areaContainer); + int numColumnsRepeated = c.getNumColumnsRepeated(); + int currentColumnNumber = c.getColumnNumber(); + if (currentColumnNumber == 0) { + currentColumnNumber = nextColumnNumber; + } + + for (int j = 0; j < numColumnsRepeated; j++) { + if (currentColumnNumber > columns.size()) { + columns.setSize(currentColumnNumber); + } + if (columns.elementAt(currentColumnNumber - 1) != null) { + log.warn("More than one column object assigned " + + "to column " + + currentColumnNumber); + } + columns.setElementAt(c, currentColumnNumber - 1); + currentColumnNumber++; + } + nextColumnNumber = currentColumnNumber; } } + } + + private int layoutColumns(Area areaContainer) throws FOPException { + int offset = 0; + int nextColumnNumber=1; + Enumeration eCol = columns.elements(); + while (eCol.hasMoreElements()) { + TableColumn c = (TableColumn)eCol.nextElement(); + if (c == null) { + log.warn("No table-column specified in column " + + nextColumnNumber); + } + else { + //c.doSetup(areaContainer); + c.setColumnOffset(offset); + c.layout(areaContainer); + offset += c.getColumnWidth(); + } + nextColumnNumber++; + } + return offset; } public int getAreaHeight() { --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]