aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKaren Lease <klease@apache.org>2001-09-20 20:29:22 +0000
committerKaren Lease <klease@apache.org>2001-09-20 20:29:22 +0000
commit8cd93b6a759c8fdc0b5873b5d43bbc69c37046fa (patch)
treec7e352681e171ea8a9912ec31e73e6cb5206314c /src
parent1b7e067ce9289dd31492650b13e3defc078d8711 (diff)
downloadxmlgraphics-fop-8cd93b6a759c8fdc0b5873b5d43bbc69c37046fa.tar.gz
xmlgraphics-fop-8cd93b6a759c8fdc0b5873b5d43bbc69c37046fa.zip
Use column-number property on table-column
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194471 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/org/apache/fop/fo/flow/Table.java90
-rw-r--r--src/org/apache/fop/fo/flow/TableColumn.java6
2 files changed, 65 insertions, 31 deletions
diff --git a/src/org/apache/fop/fo/flow/Table.java b/src/org/apache/fop/fo/flow/Table.java
index 99f69e5f2..cc8f5ac14 100644
--- a/src/org/apache/fop/fo/flow/Table.java
+++ b/src/org/apache/fop/fo/flow/Table.java
@@ -16,6 +16,7 @@ import org.apache.fop.apps.FOPException;
// Java
import java.util.Vector;
+import java.util.Enumeration;
public class Table extends FObj {
@@ -45,7 +46,6 @@ public class Table extends FObj {
boolean omitFooterAtBreak = false;
Vector columns = new Vector();
- int currentColumnNumber = 0;
int bodyCount = 0;
AreaContainer areaContainer;
@@ -165,34 +165,14 @@ public class Table extends FObj {
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,15 +325,67 @@ public class Table extends FObj {
}
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() {
return areaContainer.getHeight();
}
diff --git a/src/org/apache/fop/fo/flow/TableColumn.java b/src/org/apache/fop/fo/flow/TableColumn.java
index 2afe6cafc..f4eddc5dd 100644
--- a/src/org/apache/fop/fo/flow/TableColumn.java
+++ b/src/org/apache/fop/fo/flow/TableColumn.java
@@ -21,6 +21,7 @@ public class TableColumn extends FObj {
int columnWidth;
int columnOffset;
int numColumnsRepeated;
+ int iColumnNumber;
boolean setup = false;
@@ -48,7 +49,7 @@ public class TableColumn extends FObj {
}
public int getColumnNumber() {
- return 0; // not implemented yet
+ return iColumnNumber;
}
public int getNumColumnsRepeated() {
@@ -63,12 +64,13 @@ public class TableColumn extends FObj {
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();