From: Karen Lease Date: Sun, 1 Dec 2002 11:55:57 +0000 (+0000) Subject: Improve keep handling in table rows X-Git-Tag: fop-0_20_5rc~17 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b86eb17f77817b5b91dd1540941c30c5684f0853;p=xmlgraphics-fop.git Improve keep handling in table rows git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/fop-0_20_2-maintain@195688 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/org/apache/fop/fo/flow/AbstractTableBody.java b/src/org/apache/fop/fo/flow/AbstractTableBody.java index b1657098c..329172512 100644 --- a/src/org/apache/fop/fo/flow/AbstractTableBody.java +++ b/src/org/apache/fop/fo/flow/AbstractTableBody.java @@ -124,7 +124,7 @@ public abstract class AbstractTableBody extends FObj { area.spaceLeft(), Position.RELATIVE); areaContainer.foCreator = this; // G Seshadri areaContainer.setPage(area.getPage()); - areaContainer.setParent(area); + areaContainer.setParent(area); areaContainer.setBackground(propMgr.getBackgroundProps()); areaContainer.setBorderAndPadding(propMgr.getBorderAndPadding()); areaContainer.start(); @@ -152,11 +152,29 @@ public abstract class AbstractTableBody extends FObj { == -1) { keepWith.add(lastRow); } else { + /* This row has no keep-with-previous, or it is the first + * row in this area. + */ if (endKeepGroup && keepWith.size() > 0) { keepWith = new ArrayList(); } + // If we have composed at least one complete row which is not part + // of a keep set, we can take following keeps into account again + if (endKeepGroup && i > this.marker) { + rowSpanMgr.setIgnoreKeeps(false); + } } - + + /* Tell the row whether it is at the top of this area: if so, the row + * should not honor keep-together. + */ + boolean bRowStartsArea = (i == this.marker); + if (bRowStartsArea == false && keepWith.size() > 0) { + if (children.indexOf(keepWith.get(0)) == this.marker) { + bRowStartsArea = true; + } + } + row.setIgnoreKeepTogether(bRowStartsArea && startsAC(area)); int status; if (Status.isIncomplete((status = row.layout(areaContainer)))) { // BUG!!! don't distinguish between break-before and after! @@ -250,5 +268,24 @@ public abstract class AbstractTableBody extends FObj { this.resetMarker(); this.removeID(area.getIDReferences()); } - + + /** + * Return true if the passed area is on the left edge of its nearest + * absolute AreaContainer (generally a page column). + */ + private boolean startsAC(Area area) { + Area parent=null; + + while ((parent = area.getParent()) != null && + parent.hasNonSpaceChildren() == false) { + // The area will be the first non-space child in its parent + // Note: it's not added yet! + if (parent instanceof AreaContainer && + ((AreaContainer)parent).getPosition() == Position.ABSOLUTE) { + return true; + } + area = parent; + } + return false; + } } diff --git a/src/org/apache/fop/fo/flow/TableRow.java b/src/org/apache/fop/fo/flow/TableRow.java index 45d497249..e4b7ce48d 100644 --- a/src/org/apache/fop/fo/flow/TableRow.java +++ b/src/org/apache/fop/fo/flow/TableRow.java @@ -48,7 +48,9 @@ public class TableRow extends FObj { AreaContainer areaContainer; boolean areaAdded = false; - + + boolean bIgnoreKeepTogether = false; + private RowSpanMgr rowSpanMgr = null; private CellArray cellArray = null; @@ -247,7 +249,7 @@ public class TableRow extends FObj { Position.RELATIVE); areaContainer.foCreator = this; // G Seshadri areaContainer.setPage(area.getPage()); - areaContainer.setParent(area); + areaContainer.setParent(area); areaContainer.setBackground(propMgr.getBackgroundProps()); areaContainer.start(); @@ -303,7 +305,7 @@ public class TableRow extends FObj { int rowSpan = cell.getNumRowsSpanned(); int status; if (Status.isIncomplete((status = cell.layout(areaContainer)))) { - if ((keepTogether.getType() == KeepValue.KEEP_WITH_ALWAYS) + if ((keepTogether.getType() == KeepValue.KEEP_WITH_ALWAYS && bIgnoreKeepTogether==false) || (status == Status.AREA_FULL_NONE) || rowSpan > 1) { // We will put this row into the next column/page @@ -417,9 +419,10 @@ public class TableRow extends FObj { } public void removeLayout(Area area) { - if (areaAdded) + if (areaAdded) { area.removeChild(areaContainer); - areaAdded = false; + areaAdded = false; + } this.resetMarker(); this.removeID(area.getIDReferences()); } @@ -500,5 +503,9 @@ public class TableRow extends FObj { } return width; } + + void setIgnoreKeepTogether(boolean bIgnoreKeepTogether) { + this.bIgnoreKeepTogether = bIgnoreKeepTogether; + } }