From f37491ef6c45f266a511e4811e13c48e6b980fa6 Mon Sep 17 00:00:00 2001 From: Keiron Liddle Date: Mon, 19 Feb 2001 00:17:42 +0000 Subject: [PATCH] adds break before and break after for table rows also reports error if the number of columns the cells are using is different to the number of columns in the table git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194076 13f79535-47bb-0310-9956-ffa450edef68 --- src/org/apache/fop/fo/flow/TableBody.java | 10 +++++ src/org/apache/fop/fo/flow/TableRow.java | 47 +++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/src/org/apache/fop/fo/flow/TableBody.java b/src/org/apache/fop/fo/flow/TableBody.java index 9f3ecae1b..d3d08745e 100644 --- a/src/org/apache/fop/fo/flow/TableBody.java +++ b/src/org/apache/fop/fo/flow/TableBody.java @@ -210,6 +210,16 @@ public class TableBody extends FObj { Status status; if ((status = row.layout(areaContainer)).isIncomplete()) { + if(status.isPageBreak()) { + this.marker = i; + area.addChild(areaContainer); + //areaContainer.end(); + + area.increaseHeight(areaContainer.getHeight()); + area.setAbsoluteHeight( + areaContainer.getAbsoluteHeight()); + return status; + } if (keepWith.size() > 0) { // && status.getCode() == Status.AREA_FULL_NONE row.removeLayout(areaContainer); for (Enumeration e = keepWith.elements(); diff --git a/src/org/apache/fop/fo/flow/TableRow.java b/src/org/apache/fop/fo/flow/TableRow.java index d3bc2cf34..ab6b6ba73 100644 --- a/src/org/apache/fop/fo/flow/TableRow.java +++ b/src/org/apache/fop/fo/flow/TableRow.java @@ -80,6 +80,8 @@ public class TableRow extends FObj { FontState fs; int spaceBefore; int spaceAfter; + int breakBefore; + int breakAfter; ColorType backgroundColor; String id; @@ -273,6 +275,9 @@ public class TableRow extends FObj { "space-before.optimum").getLength().mvalue(); this.spaceAfter = this.properties.get( "space-after.optimum").getLength().mvalue(); + this.breakBefore = + this.properties.get("break-before").getEnum(); + this.breakAfter = this.properties.get("break-after").getEnum(); this.backgroundColor = this.properties.get("background-color").getColorType(); this.borderTopColor = @@ -378,6 +383,21 @@ public class TableRow extends FObj { this.marker = 0; + if (breakBefore == BreakBefore.PAGE) { + return new Status(Status.FORCE_PAGE_BREAK); + } + + if (breakBefore == BreakBefore.ODD_PAGE) { + return new Status(Status.FORCE_PAGE_BREAK_ODD); + } + + if (breakBefore == BreakBefore.EVEN_PAGE) { + return new Status(Status.FORCE_PAGE_BREAK_EVEN); + } + + if (breakBefore == BreakBefore.COLUMN) { + return new Status(Status.FORCE_COLUMN_BREAK); + } } if ((spaceBefore != 0) && (this.marker == 0)) { @@ -431,6 +451,10 @@ public class TableRow extends FObj { state.setColumn(colCount); // add the state of a cell. cells.insertElementAt(state, i); + if(colCount + numCols > columns.size()) { + MessageHandler.errorln("WARNING: Number of cell columns under table-row not equal to number of table-columns"); + return new Status(Status.OK); + } for (int count = 0; count < numCols && count < columns.size(); count++) { @@ -443,6 +467,10 @@ public class TableRow extends FObj { widthOfCellsSoFar += width; } + if(colCount < columns.size()) { + MessageHandler.errorln("WARNING: Number of cell columns under table-row not equal to number of table-columns"); + return new Status(Status.OK); + } } int numChildren = this.children.size(); @@ -588,6 +616,25 @@ public class TableRow extends FObj { if (someCellDidNotLayoutCompletely) { return new Status(Status.AREA_FULL_SOME); } else { + if (breakAfter == BreakAfter.PAGE) { + this.marker = BREAK_AFTER; + return new Status(Status.FORCE_PAGE_BREAK); + } + + if (breakAfter == BreakAfter.ODD_PAGE) { + this.marker = BREAK_AFTER; + return new Status(Status.FORCE_PAGE_BREAK_ODD); + } + + if (breakAfter == BreakAfter.EVEN_PAGE) { + this.marker = BREAK_AFTER; + return new Status(Status.FORCE_PAGE_BREAK_EVEN); + } + + if (breakAfter == BreakAfter.COLUMN) { + this.marker = BREAK_AFTER; + return new Status(Status.FORCE_COLUMN_BREAK); + } if (keepWithNext.getType() != KeepValue.KEEP_WITH_AUTO) { return new Status(Status.KEEP_WITH_NEXT); } -- 2.39.5