Browse Source

Initial keep-together support on table.


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198672 13f79535-47bb-0310-9956-ffa450edef68
tags/fop-0_90-alpha1
Jeremias Maerki 19 years ago
parent
commit
01030d8337

+ 14
- 1
src/java/org/apache/fop/fo/flow/Table.java View File

@@ -200,7 +200,8 @@ public class Table extends FObj {
*/
protected void endOfNode() throws FOPException {
if (!tableBodyFound) {
missingChildElementError("(marker*,table-column*,table-header?,table-footer?,table-body+)");
missingChildElementError(
"(marker*,table-column*,table-header?,table-footer?,table-body+)");
}

getFOEventHandler().endTable(this);
@@ -235,6 +236,7 @@ public class Table extends FObj {
return this.defaultColumn;
}
/** @return the list of table-column elements. */
public List getColumns() {
return columns;
}
@@ -247,10 +249,12 @@ public class Table extends FObj {
return (TableBody)childNodes.get(index);
}

/** @return the body for the table-header. */
public TableBody getTableHeader() {
return tableHeader;
}

/** @return the body for the table-footer. */
public TableBody getTableFooter() {
return tableFooter;
}
@@ -318,6 +322,15 @@ public class Table extends FObj {
return keepTogether;
}

/**
* Convenience method to check if a keep-together constraint is specified.
* @return true if keep-together is active.
*/
public boolean mustKeepTogether() {
return !getKeepTogether().getWithinPage().isAuto()
|| !getKeepTogether().getWithinColumn().isAuto();
}
/** @return the "border-collapse" property. */
public int getBorderCollapse() {
return borderCollapse;

+ 1
- 1
src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java View File

@@ -198,7 +198,7 @@ public class TableContentLayoutManager {
if (returnList.size() > 0) {
//Remove last penalty
KnuthElement last = (KnuthElement)returnList.getLast();
if (last.isPenalty() && last.getP() == 0) {
if (last.isPenalty()) {
returnList.removeLast();
}
}

+ 6
- 1
src/java/org/apache/fop/layoutmgr/table/TableStepper.java View File

@@ -141,6 +141,7 @@ public class TableStepper {
}
if (pgu.isLastGridUnitRowSpan() && pgu.getRow() != null) {
makeBoxForWholeRow |= pgu.getRow().mustKeepTogether();
makeBoxForWholeRow |= pgu.getTable().mustKeepTogether();
}
if (makeBoxForWholeRow) {
List list = new java.util.ArrayList(1);
@@ -243,7 +244,11 @@ public class TableStepper {
penaltyPos.footerElements = tclm.getFooterElements();
}
}
returnList.add(new KnuthPenalty(effPenaltyLen, 0, false, penaltyPos, false));
int p = 0;
if (getTableLM().mustKeepTogether()) {
p = KnuthPenalty.INFINITE;
}
returnList.add(new KnuthPenalty(effPenaltyLen, p, false, penaltyPos, false));

log.debug("step=" + step + " (+" + increase + ")"
+ " box=" + boxLen

Loading…
Cancel
Save