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();
== -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!
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;
+ }
}
AreaContainer areaContainer;
boolean areaAdded = false;
-
+
+ boolean bIgnoreKeepTogether = false;
+
private RowSpanMgr rowSpanMgr = null;
private CellArray cellArray = null;
Position.RELATIVE);
areaContainer.foCreator = this; // G Seshadri
areaContainer.setPage(area.getPage());
- areaContainer.setParent(area);
+ areaContainer.setParent(area);
areaContainer.setBackground(propMgr.getBackgroundProps());
areaContainer.start();
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
}
public void removeLayout(Area area) {
- if (areaAdded)
+ if (areaAdded) {
area.removeChild(areaContainer);
- areaAdded = false;
+ areaAdded = false;
+ }
this.resetMarker();
this.removeID(area.getIDReferences());
}
}
return width;
}
+
+ void setIgnoreKeepTogether(boolean bIgnoreKeepTogether) {
+ this.bIgnoreKeepTogether = bIgnoreKeepTogether;
+ }
}