diff options
Diffstat (limited to 'src/org/apache/fop/fo/flow')
-rw-r--r-- | src/org/apache/fop/fo/flow/Block.java | 48 | ||||
-rw-r--r-- | src/org/apache/fop/fo/flow/Table.java | 80 | ||||
-rw-r--r-- | src/org/apache/fop/fo/flow/TableBody.java | 44 | ||||
-rw-r--r-- | src/org/apache/fop/fo/flow/TableCell.java | 81 | ||||
-rw-r--r-- | src/org/apache/fop/fo/flow/TableColumn.java | 66 | ||||
-rw-r--r-- | src/org/apache/fop/fo/flow/TableRow.java | 60 |
6 files changed, 247 insertions, 132 deletions
diff --git a/src/org/apache/fop/fo/flow/Block.java b/src/org/apache/fop/fo/flow/Block.java index 76599ca23..8d743ee41 100644 --- a/src/org/apache/fop/fo/flow/Block.java +++ b/src/org/apache/fop/fo/flow/Block.java @@ -88,7 +88,11 @@ public class Block extends FObjMixed { int paddingBottom; int paddingLeft; int paddingRight; - + + ColorType borderColor; + int borderWidth; + int borderStyle; + BlockArea blockArea; // this may be helpful on other FOs too @@ -142,14 +146,27 @@ public class Block extends FObjMixed { this.backgroundColor = this.properties.get("background-color").getColorType(); this.paddingTop = - this.properties.get("padding-top").getLength().mvalue(); - this.paddingLeft = - this.properties.get("padding-left").getLength().mvalue(); - this.paddingBottom = - this.properties.get("padding-bottom").getLength().mvalue(); - this.paddingRight = - this.properties.get("padding-right").getLength().mvalue(); - + this.properties.get("padding").getLength().mvalue(); + this.paddingLeft = this.paddingTop; + this.paddingRight = this.paddingTop; + this.paddingBottom = this.paddingTop; + if (this.paddingTop == 0) { + this.paddingTop = + this.properties.get("padding-top").getLength().mvalue(); + this.paddingLeft = + this.properties.get("padding-left").getLength().mvalue(); + this.paddingBottom = + this.properties.get("padding-bottom").getLength().mvalue(); + this.paddingRight = + this.properties.get("padding-right").getLength().mvalue(); + } + this.borderColor = + this.properties.get("border-color").getColorType(); + this.borderWidth = + this.properties.get("border-width").getLength().mvalue(); + this.borderStyle = + this.properties.get("border-style").getEnum(); + if (area instanceof BlockArea) { area.end(); } @@ -164,12 +181,6 @@ public class Block extends FObjMixed { startIndent += bodyIndent + distanceBetweenStarts; } - if (this.isInTableCell) { - startIndent += forcedStartOffset; - endIndent = area.getAllocationWidth() - forcedWidth - - forcedStartOffset; - } - this.marker = 0; if (breakBefore == BreakBefore.PAGE) { @@ -195,12 +206,17 @@ public class Block extends FObjMixed { this.blockArea = new BlockArea(fs, area.getAllocationWidth(), - area.spaceLeft(), startIndent, endIndent, + area.spaceLeft(), + startIndent, + endIndent, textIndent, align, alignLast, lineHeight); blockArea.setPage(area.getPage()); blockArea.setBackgroundColor(backgroundColor); blockArea.setPadding(paddingTop, paddingLeft, paddingBottom, paddingRight); + blockArea.setBorderStyle(borderStyle, borderStyle, borderStyle, borderStyle); + blockArea.setBorderWidth(borderWidth, borderWidth, borderWidth, borderWidth); + blockArea.setBorderColor(borderColor, borderColor, borderColor, borderColor); blockArea.start(); int numChildren = this.children.size(); diff --git a/src/org/apache/fop/fo/flow/Table.java b/src/org/apache/fop/fo/flow/Table.java index cca3e44d2..01b3f5f3a 100644 --- a/src/org/apache/fop/fo/flow/Table.java +++ b/src/org/apache/fop/fo/flow/Table.java @@ -77,16 +77,20 @@ public class Table extends FObj { FontState fs; int breakBefore; int breakAfter; - int startIndent; - int endIndent; int spaceBefore; int spaceAfter; ColorType backgroundColor; + int width; + int height; + ColorType borderColor; + int borderWidth; + int borderStyle; + Vector columns = new Vector(); int currentColumnNumber = 0; - BlockArea blockArea; + AreaContainer areaContainer; public Table(FObj parent, PropertyList propertyList) { super(parent, propertyList); @@ -114,25 +118,28 @@ public class Table extends FObj { this.properties.get("break-before").getEnum(); this.breakAfter = this.properties.get("break-after").getEnum(); - this.startIndent = - this.properties.get("start-indent").getLength().mvalue(); - this.endIndent = - this.properties.get("end-indent").getLength().mvalue(); 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.width = + this.properties.get("width").getLength().mvalue(); + this.height = + this.properties.get("height").getLength().mvalue(); + + this.borderColor = + this.properties.get("border-color").getColorType(); + this.borderWidth = + this.properties.get("border-width").getLength().mvalue(); + this.borderStyle = + this.properties.get("border-style").getEnum(); if (area instanceof BlockArea) { area.end(); } - if (this.isInListBody) { - startIndent += bodyIndent + distanceBetweenStarts; - } - this.marker = 0; if (breakBefore == BreakBefore.PAGE) { @@ -152,16 +159,19 @@ public class Table extends FObj { area.addDisplaySpace(spaceBefore); } - this.blockArea = - new BlockArea(fs, area.getAllocationWidth(), - area.spaceLeft(), startIndent, endIndent, 0, - 0, 0, 0); - blockArea.setPage(area.getPage()); - blockArea.setBackgroundColor(backgroundColor); - blockArea.start(); + this.areaContainer = + new AreaContainer(fs, 0, 0, area.getAllocationWidth(), + area.spaceLeft(), Position.STATIC); + areaContainer.setPage(area.getPage()); + areaContainer.setBackgroundColor(backgroundColor); + areaContainer.setBorderStyle(borderStyle, borderStyle, borderStyle, borderStyle); + areaContainer.setBorderWidth(borderWidth, borderWidth, borderWidth, borderWidth); + areaContainer.setBorderColor(borderColor, borderColor, borderColor, borderColor); + areaContainer.start(); // added by Eric Schaeffer currentColumnNumber = 0; + int offset = 0; int numChildren = this.children.size(); for (int i = this.marker; i < numChildren; i++) { @@ -177,39 +187,45 @@ public class Table extends FObj { columns.setSize(num); } columns.setElementAt(c, num-1); + c.setColumnOffset(offset); + fo.layout(areaContainer); + offset += c.getColumnWidth(); } else if (fo instanceof TableBody) { if (columns.size() == 0) { System.err.println("WARNING: current implementation of tables requires a table-column for each column, indicating column-width"); return new Status(Status.OK); } - //if (this.isInListBody) { - //fo.setIsInListBody(); - //fo.setDistanceBetweenStarts(this.distanceBetweenStarts); - //fo.setBodyIndent(this.bodyIndent); - //} - ((TableBody) fo).setColumns(columns); Status status; - if ((status = fo.layout(blockArea)).isIncomplete()) { + if ((status = fo.layout(areaContainer)).isIncomplete()) { this.marker = i; if ((i != 0) && (status.getCode() == Status.AREA_FULL_NONE)) { status = new Status(Status.AREA_FULL_SOME); } - //blockArea.end(); - area.addChild(blockArea); - area.increaseHeight(blockArea.getHeight()); + //areaContainer.end(); + area.addChild(areaContainer); + area.increaseHeight(areaContainer.getHeight()); return status; } } } + if (height != 0) + areaContainer.setHeight(height); + + for (int i = 0; i < numChildren; i++) { + FONode fo = (FONode) children.elementAt(i); + if (fo instanceof TableColumn) { + ((TableColumn)fo).setHeight(areaContainer.getHeight()); + } + } - blockArea.end(); - area.addChild(blockArea); + areaContainer.end(); + area.addChild(areaContainer); /* should this be combined into above? */ - area.increaseHeight(blockArea.getHeight()); + area.increaseHeight(areaContainer.getHeight()); if (spaceAfter != 0) { area.addDisplaySpace(spaceAfter); @@ -238,6 +254,6 @@ public class Table extends FObj { } public int getAreaHeight() { - return blockArea.getHeight(); + return areaContainer.getHeight(); } } diff --git a/src/org/apache/fop/fo/flow/TableBody.java b/src/org/apache/fop/fo/flow/TableBody.java index f7d64f8fe..440a53b4a 100644 --- a/src/org/apache/fop/fo/flow/TableBody.java +++ b/src/org/apache/fop/fo/flow/TableBody.java @@ -75,15 +75,13 @@ public class TableBody extends FObj { } FontState fs; - int startIndent; - int endIndent; int spaceBefore; int spaceAfter; ColorType backgroundColor; Vector columns; - BlockArea blockArea; + AreaContainer areaContainer; public TableBody(FObj parent, PropertyList propertyList) { super(parent, propertyList); @@ -111,10 +109,6 @@ public class TableBody extends FObj { this.fs = new FontState(area.getFontInfo(), fontFamily, fontStyle, fontWeight, fontSize); - this.startIndent = - this.properties.get("start-indent").getLength().mvalue(); - this.endIndent = - this.properties.get("end-indent").getLength().mvalue(); this.spaceBefore = this.properties.get("space-before.optimum").getLength().mvalue(); this.spaceAfter = @@ -138,44 +132,36 @@ public class TableBody extends FObj { area.addDisplaySpace(spaceBefore); } - this.blockArea = - new BlockArea(fs, area.getAllocationWidth(), - area.spaceLeft(), startIndent, endIndent, 0, - 0, 0, 0); - blockArea.setPage(area.getPage()); - blockArea.setBackgroundColor(backgroundColor); - blockArea.start(); + this.areaContainer = + new AreaContainer(fs, -area.borderWidthLeft, -area.borderWidthTop, area.getAllocationWidth(), + area.spaceLeft(), Position.RELATIVE); + areaContainer.setPage(area.getPage()); + areaContainer.setBackgroundColor(backgroundColor); + areaContainer.start(); int numChildren = this.children.size(); for (int i = this.marker; i < numChildren; i++) { TableRow row = (TableRow) children.elementAt(i); - //if (this.isInListBody) { - //fo.setIsInListBody(); - //fo.setDistanceBetweenStarts(this.distanceBetweenStarts); - //fo.setBodyIndent(this.bodyIndent); - //} - row.setColumns(columns); Status status; - if ((status = row.layout(blockArea)).isIncomplete()) { + if ((status = row.layout(areaContainer)).isIncomplete()) { this.marker = i; if ((i != 0) && (status.getCode() == Status.AREA_FULL_NONE)) { status = new Status(Status.AREA_FULL_SOME); } - //blockArea.end(); - area.addChild(blockArea); - area.increaseHeight(blockArea.getHeight()); + area.addChild(areaContainer); + //areaContainer.end(); + area.increaseHeight(areaContainer.getHeight()); return status; } } - - blockArea.end(); - area.addChild(blockArea); + area.addChild(areaContainer); + areaContainer.end(); /* should this be combined into above? */ - area.increaseHeight(blockArea.getHeight()); + area.increaseHeight(areaContainer.getHeight()); if (spaceAfter != 0) { area.addDisplaySpace(spaceAfter); @@ -189,6 +175,6 @@ public class TableBody extends FObj { } public int getAreaHeight() { - return blockArea.getHeight(); + return areaContainer.getHeight(); } } diff --git a/src/org/apache/fop/fo/flow/TableCell.java b/src/org/apache/fop/fo/flow/TableCell.java index d40e2e92b..784d205f7 100644 --- a/src/org/apache/fop/fo/flow/TableCell.java +++ b/src/org/apache/fop/fo/flow/TableCell.java @@ -70,18 +70,25 @@ public class TableCell extends FObj { return new TableCell.Maker(); } - FontState fs; - int startIndent; - int endIndent; int spaceBefore; int spaceAfter; ColorType backgroundColor; + FontState fs; + ColorType borderColor; + int borderWidth; + int borderStyle; + int paddingTop; + int paddingBottom; + int paddingLeft; + int paddingRight; + int position; + protected int startOffset; protected int width; protected int height = 0; - BlockArea blockArea; + AreaContainer areaContainer; public TableCell(FObj parent, PropertyList propertyList) { super(parent, propertyList); @@ -113,10 +120,28 @@ public class TableCell extends FObj { this.fs = new FontState(area.getFontInfo(), fontFamily, fontStyle, fontWeight, fontSize); - this.startIndent = - this.properties.get("start-indent").getLength().mvalue(); - this.endIndent = - this.properties.get("end-indent").getLength().mvalue(); + this.borderColor = + this.properties.get("border-color").getColorType(); + this.borderWidth = + this.properties.get("border-width").getLength().mvalue(); + this.borderStyle = + this.properties.get("border-style").getEnum(); + this.paddingTop = + this.properties.get("padding").getLength().mvalue(); + this.paddingLeft = this.paddingTop; + this.paddingRight = this.paddingTop; + this.paddingBottom = this.paddingTop; + if (this.paddingTop == 0) { + this.paddingTop = + this.properties.get("padding-top").getLength().mvalue(); + this.paddingLeft = + this.properties.get("padding-left").getLength().mvalue(); + this.paddingBottom = + this.properties.get("padding-bottom").getLength().mvalue(); + this.paddingRight = + this.properties.get("padding-right").getLength().mvalue(); + } + this.spaceBefore = this.properties.get("space-before.optimum").getLength().mvalue(); this.spaceAfter = @@ -140,25 +165,26 @@ public class TableCell extends FObj { area.addDisplaySpace(spaceBefore); } - this.blockArea = - new BlockArea(fs, area.getAllocationWidth(), - area.spaceLeft(), startIndent, endIndent, 0, - 0, 0, 0); - blockArea.setPage(area.getPage()); - blockArea.setBackgroundColor(backgroundColor); - blockArea.start(); - - // added by Eric Schaeffer - height = 0; + this.areaContainer = + new AreaContainer(fs, startOffset - area.borderWidthLeft, + - area.borderWidthTop, + width, area.spaceLeft(), Position.RELATIVE); + areaContainer.setPage(area.getPage()); + areaContainer.setPadding(paddingTop, paddingLeft, paddingBottom, + paddingRight); + areaContainer.setBackgroundColor(backgroundColor); + areaContainer.setBorderStyle(borderStyle, borderStyle, borderStyle, borderStyle); + areaContainer.setBorderWidth(borderWidth, borderWidth, borderWidth, borderWidth); + areaContainer.setBorderColor(borderColor, borderColor, borderColor, borderColor); + areaContainer.start(); int numChildren = this.children.size(); for (int i = this.marker; i < numChildren; i++) { FObj fo = (FObj) children.elementAt(i); fo.setIsInTableCell(); - fo.forceStartOffset(startOffset); fo.forceWidth(width); Status status; - if ((status = fo.layout(blockArea)).isIncomplete()) { + if ((status = fo.layout(areaContainer)).isIncomplete()) { this.marker = i; if ((i == 0) && (status.getCode() == Status.AREA_FULL_NONE)) { return new Status(Status.AREA_FULL_NONE); @@ -166,18 +192,19 @@ public class TableCell extends FObj { return new Status(Status.AREA_FULL_SOME); } } - // bug fix from Eric Schaeffer - // height += blockArea.getHeight(); - height = blockArea.getHeight(); - } - blockArea.end(); - area.addChild(blockArea); + areaContainer.end(); + area.addChild(areaContainer); return new Status(Status.OK); } public int getHeight() { - return height; + return areaContainer.getHeight();; + } + + public void setHeight(int height) { + areaContainer.setMaxHeight(height); + areaContainer.setHeight(height); } } diff --git a/src/org/apache/fop/fo/flow/TableColumn.java b/src/org/apache/fop/fo/flow/TableColumn.java index 82ba4af6c..fe0ca4064 100644 --- a/src/org/apache/fop/fo/flow/TableColumn.java +++ b/src/org/apache/fop/fo/flow/TableColumn.java @@ -56,9 +56,20 @@ import org.apache.fop.fo.*; import org.apache.fop.fo.properties.*; import org.apache.fop.layout.*; import org.apache.fop.apps.FOPException; +import org.apache.fop.datatypes.*; public class TableColumn extends FObj { + FontState fs; + ColorType backgroundColor; + ColorType borderColor; + int borderWidth; + int borderStyle; + int columnWidth; + int columnOffset; + + AreaContainer areaContainer; + public static class Maker extends FObj.Maker { public FObj make(FObj parent, PropertyList propertyList) throws FOPException { @@ -76,10 +87,63 @@ public class TableColumn extends FObj { } public int getColumnWidth() { - return this.properties.get("column-width").getLength().mvalue(); + return columnWidth; } public int getColumnNumber() { return 0; // not implemented yet } + + public Status layout(Area area) throws FOPException { + if (this.marker == BREAK_AFTER) { + return new Status(Status.OK); + } + + if (this.marker == START) { + String fontFamily = + this.properties.get("font-family").getString(); + String fontStyle = + this.properties.get("font-style").getString(); + String fontWeight = + this.properties.get("font-weight").getString(); + int fontSize = + this.properties.get("font-size").getLength().mvalue(); + + this.fs = new FontState(area.getFontInfo(), fontFamily, + fontStyle, fontWeight, fontSize); + this.backgroundColor = + this.properties.get("background-color").getColorType(); + this.borderColor = + this.properties.get("border-color").getColorType(); + this.borderWidth = + this.properties.get("border-width").getLength().mvalue(); + this.borderStyle = + this.properties.get("border-style").getEnum(); + this.columnWidth = + this.properties.get("column-width").getLength().mvalue(); + } + + this.areaContainer = + new AreaContainer(fs, columnOffset - area.borderWidthLeft, -area.borderWidthTop, columnWidth, + area.getHeight(), Position.RELATIVE); + areaContainer.setPage(area.getPage()); + areaContainer.setBackgroundColor(backgroundColor); + areaContainer.setBorderStyle(borderStyle, borderStyle, borderStyle, borderStyle); + areaContainer.setBorderWidth(borderWidth, borderWidth, borderWidth, borderWidth); + areaContainer.setBorderColor(borderColor, borderColor, borderColor, borderColor); + areaContainer.setHeight(area.getHeight()); + area.addChild(areaContainer); + + return new Status(Status.OK); + } + + public void setColumnOffset(int columnOffset) { + this.columnOffset = columnOffset; + } + + public void setHeight(int height) { + areaContainer.setMaxHeight(height); + areaContainer.setHeight(height); + } + } diff --git a/src/org/apache/fop/fo/flow/TableRow.java b/src/org/apache/fop/fo/flow/TableRow.java index 3c8b53ce6..5fd80a5ad 100644 --- a/src/org/apache/fop/fo/flow/TableRow.java +++ b/src/org/apache/fop/fo/flow/TableRow.java @@ -75,18 +75,20 @@ public class TableRow extends FObj { } FontState fs; - int startIndent; - int endIndent; int spaceBefore; int spaceAfter; ColorType backgroundColor; + + ColorType borderColor; + int borderWidth; + int borderStyle; int widthOfCellsSoFar = 0; int largestCellHeight = 0; Vector columns; - BlockArea blockArea; + AreaContainer areaContainer; public TableRow(FObj parent, PropertyList propertyList) { super(parent, propertyList); @@ -114,25 +116,23 @@ public class TableRow extends FObj { this.fs = new FontState(area.getFontInfo(), fontFamily, fontStyle, fontWeight, fontSize); - this.startIndent = - this.properties.get("start-indent").getLength().mvalue(); - this.endIndent = - this.properties.get("end-indent").getLength().mvalue(); 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.borderColor = + this.properties.get("border-color").getColorType(); + this.borderWidth = + this.properties.get("border-width").getLength().mvalue(); + this.borderStyle = + this.properties.get("border-style").getEnum(); if (area instanceof BlockArea) { area.end(); } - //if (this.isInListBody) { - //startIndent += bodyIndent + distanceBetweenStarts; - //} - this.marker = 0; } @@ -141,13 +141,16 @@ public class TableRow extends FObj { area.addDisplaySpace(spaceBefore); } - this.blockArea = - new BlockArea(fs, area.getAllocationWidth(), - area.spaceLeft(), startIndent, endIndent, 0, - 0, 0, 0); - blockArea.setPage(area.getPage()); - blockArea.setBackgroundColor(backgroundColor); - blockArea.start(); + this.areaContainer = + new AreaContainer(fs, -area.borderWidthLeft, -area.borderWidthTop, + area.getAllocationWidth(), + area.spaceLeft(), Position.RELATIVE); + areaContainer.setPage(area.getPage()); + areaContainer.setBackgroundColor(backgroundColor); + areaContainer.setBorderStyle(borderStyle, borderStyle, borderStyle, borderStyle); + areaContainer.setBorderWidth(borderWidth, borderWidth, borderWidth, borderWidth); + areaContainer.setBorderColor(borderColor, borderColor, borderColor, borderColor); + areaContainer.start(); int numChildren = this.children.size(); if (numChildren != columns.size()) { @@ -175,27 +178,30 @@ public class TableRow extends FObj { widthOfCellsSoFar += width; Status status; - if ((status = cell.layout(blockArea)).isIncomplete()) { + if ((status = cell.layout(areaContainer)).isIncomplete()) { this.marker = i; if ((i != 0) && (status.getCode() == Status.AREA_FULL_NONE)) { status = new Status(Status.AREA_FULL_SOME); } - //blockArea.end(); - area.addChild(blockArea); - area.increaseHeight(blockArea.getHeight()); + area.addChild(areaContainer); + //areaContainer.end(); + area.increaseHeight(areaContainer.getHeight()); return status; } int h = cell.getHeight(); - blockArea.addDisplaySpace(-h); if (h > largestCellHeight) { largestCellHeight = h; } - + } + for (int i = 0; i < numChildren; i++) { + TableCell cell = (TableCell)children.elementAt(i); + cell.setHeight(largestCellHeight); } - blockArea.end(); - area.addChild(blockArea); + area.addChild(areaContainer); + areaContainer.end(); + area.setHeight(largestCellHeight); area.addDisplaySpace(largestCellHeight); // bug fix from Eric Schaeffer //area.increaseHeight(largestCellHeight); @@ -212,6 +218,6 @@ public class TableRow extends FObj { } public int getAreaHeight() { - return blockArea.getHeight(); + return areaContainer.getHeight(); } } |