aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Hennebert <vhennebert@apache.org>2007-08-02 16:26:36 +0000
committerVincent Hennebert <vhennebert@apache.org>2007-08-02 16:26:36 +0000
commit89829841e46887b2cc2ed16153a7202ad11f2775 (patch)
tree071ea72e5adf7c0df4fde447a117bb83878e48e6
parentbeb66bc635565b61796d281d09fdd7835d18e299 (diff)
downloadxmlgraphics-fop-89829841e46887b2cc2ed16153a7202ad11f2775.tar.gz
xmlgraphics-fop-89829841e46887b2cc2ed16153a7202ad11f2775.zip
Move the handling of breaks back in TableContentLM
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@562172 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java115
-rw-r--r--src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java35
2 files changed, 79 insertions, 71 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
index c7db197a3..a72243bc0 100644
--- a/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
@@ -66,79 +66,60 @@ class RowGroupLayoutManager {
this.tableStepper = tableStepper;
}
+ int getBreakBefore() {
+ TableRow rowFO = rowGroup[0].getTableRow();
+ if (rowFO == null) {
+ return Constants.EN_AUTO;
+ } else {
+ return rowFO.getBreakBefore();
+ }
+ }
+
+ int getBreakAfter() {
+ TableRow rowFO = rowGroup[rowGroup.length - 1].getTableRow();
+ if (rowFO == null) {
+ return Constants.EN_AUTO;
+ } else {
+ return rowFO.getBreakAfter();
+ }
+ }
+
public LinkedList getNextKnuthElements(LayoutContext context, int alignment, int bodyType) {
LinkedList returnList = new LinkedList();
- //Check for break-before on the table-row at the start of the row group
- TableRow rowFO = rowGroup[0].getTableRow();
- if (rowFO != null && rowFO.getBreakBefore() != Constants.EN_AUTO) {
- log.info("break-before found");
- if (returnList.size() > 0) {
- ListElement last = (ListElement)returnList.getLast();
- if (last.isPenalty()) {
- KnuthPenalty pen = (KnuthPenalty)last;
- pen.setP(-KnuthPenalty.INFINITE);
- pen.setBreakClass(rowFO.getBreakBefore());
- } else {//if (last instanceof BreakElement) { // TODO vh: seems the only possibility
- BreakElement breakPoss = (BreakElement) last;
- breakPoss.setPenaltyValue(-KnuthPenalty.INFINITE);
- breakPoss.setBreakClass(rowFO.getBreakBefore());
- }
- } else {
- returnList.add(new BreakElement(new Position(tableLM),
- 0, -KnuthPenalty.INFINITE, rowFO.getBreakBefore(), context));
- }
- }
-
- //Border resolution
- if (!tableLM.getTable().isSeparateBorderModel()) {
- resolveNormalBeforeAfterBordersForRowGroup();
- }
+ //Border resolution
+ if (!tableLM.getTable().isSeparateBorderModel()) {
+ resolveNormalBeforeAfterBordersForRowGroup();
+ }
- //Reset keep-with-next when remaining inside the table.
- //The context flag is only used to propagate keep-with-next to the outside.
- //The clearing is ok here because createElementsForRowGroup already handles
- //the keep when inside a table.
- context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING, false);
-
- //Element list creation
- createElementsForRowGroup(context, alignment, bodyType,
- returnList, rowGroup);
-
- //Handle keeps
- if (context.isKeepWithNextPending()) {
- log.debug("child LM (row group) signals pending keep-with-next");
- }
- if (context.isKeepWithPreviousPending()) {
- log.debug("child LM (row group) signals pending keep-with-previous");
- if (returnList.size() > 0) {
- //Modify last penalty
- ListElement last = (ListElement)returnList.getLast();
- if (last.isPenalty()) {
- BreakElement breakPoss = (BreakElement)last;
- //Only honor keep if there's no forced break
- if (!breakPoss.isForcedBreak()) {
- breakPoss.setPenaltyValue(KnuthPenalty.INFINITE);
- }
- }
- }
- }
-
- //Check for break-after on the table-row at the end of the row group
- rowFO = rowGroup[rowGroup.length - 1].getTableRow();
- if (rowFO != null && rowFO.getBreakAfter() != Constants.EN_AUTO) {
- if (returnList.size() > 0) {
- ListElement last = (ListElement)returnList.getLast();
- if (last instanceof KnuthPenalty) {
- KnuthPenalty pen = (KnuthPenalty)last;
- pen.setP(-KnuthPenalty.INFINITE);
- pen.setBreakClass(rowFO.getBreakAfter());
- } else if (last instanceof BreakElement) {
- BreakElement breakPoss = (BreakElement)last;
- breakPoss.setPenaltyValue(-KnuthPenalty.INFINITE);
- breakPoss.setBreakClass(rowFO.getBreakAfter());
+ //Reset keep-with-next when remaining inside the table.
+ //The context flag is only used to propagate keep-with-next to the outside.
+ //The clearing is ok here because createElementsForRowGroup already handles
+ //the keep when inside a table.
+ context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING, false);
+
+ //Element list creation
+ createElementsForRowGroup(context, alignment, bodyType,
+ returnList, rowGroup);
+
+ //Handle keeps
+ if (context.isKeepWithNextPending()) {
+ log.debug("child LM (row group) signals pending keep-with-next");
+ }
+ if (context.isKeepWithPreviousPending()) {
+ log.debug("child LM (row group) signals pending keep-with-previous");
+ if (returnList.size() > 0) {
+ //Modify last penalty
+ ListElement last = (ListElement)returnList.getLast();
+ if (last.isPenalty()) {
+ BreakElement breakPoss = (BreakElement)last;
+ //Only honor keep if there's no forced break
+ if (!breakPoss.isForcedBreak()) {
+ breakPoss.setPenaltyValue(KnuthPenalty.INFINITE);
}
}
}
+ }
+
return returnList;
}
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
index 37742437c..5b0064899 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
@@ -214,12 +214,39 @@ public class TableContentLayoutManager implements PercentBaseContext {
LayoutContext context, int alignment, int bodyType) {
LinkedList returnList = new LinkedList();
EffRow[] rowGroup = null;
+ int breakBetween = Constants.EN_AUTO;
while ((rowGroup = iter.getNextRowGroup()) != null) {
- returnList.addAll(new RowGroupLayoutManager(getTableLM(), rowGroup, bodyIter,
- headerIter, footerIter, iter, stepper).getNextKnuthElements(context, alignment,
- bodyType));
+ RowGroupLayoutManager rowGroupLM = new RowGroupLayoutManager(getTableLM(), rowGroup,
+ bodyIter, headerIter, footerIter, iter, stepper);
+ if (breakBetween == Constants.EN_AUTO) {
+ // TODO improve
+ breakBetween = rowGroupLM.getBreakBefore();
+ }
+ if (breakBetween != Constants.EN_AUTO) {
+ if (returnList.size() > 0) {
+ BreakElement breakPoss = (BreakElement) returnList.getLast();
+ breakPoss.setPenaltyValue(-KnuthPenalty.INFINITE);
+ breakPoss.setBreakClass(breakBetween);
+ } else {
+ returnList.add(new BreakElement(new Position(tableLM),
+ 0, -KnuthPenalty.INFINITE, breakBetween, context));
+ }
+ }
+ returnList.addAll(rowGroupLM.getNextKnuthElements(context, alignment, bodyType));
+ breakBetween = rowGroupLM.getBreakAfter();
+ }
+ // Break after the table's last row
+ // TODO should eventually be handled at the table level
+ if (breakBetween != Constants.EN_AUTO) {
+ if (returnList.size() > 0) {
+ BreakElement breakPoss = (BreakElement) returnList.getLast();
+ breakPoss.setPenaltyValue(-KnuthPenalty.INFINITE);
+ breakPoss.setBreakClass(breakBetween);
+ } else {
+ returnList.add(new BreakElement(new Position(tableLM),
+ 0, -KnuthPenalty.INFINITE, breakBetween, context));
+ }
}
-
if (returnList.size() > 0) {
//Remove the last penalty produced by the combining algorithm (see TableStepper), for the last step
ListElement last = (ListElement)returnList.getLast();