From: Vincent Hennebert Date: Wed, 18 Apr 2007 14:39:59 +0000 (+0000) Subject: Fix the handling of forced breaks which were sometimes counted twice. X-Git-Tag: fop-0_94~132 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=23b32dea958c1708f692f9c7199a952ef062b58d;p=xmlgraphics-fop.git Fix the handling of forced breaks which were sometimes counted twice. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@530040 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/layoutmgr/table/TableStepper.java b/src/java/org/apache/fop/layoutmgr/table/TableStepper.java index 20b80c1bd..2c676ae0b 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableStepper.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableStepper.java @@ -85,7 +85,6 @@ public class TableStepper { private boolean rowBacktrackForLastStep; private boolean skippedStep; private boolean[] keepWithNextSignals; - private boolean forcedBreak; private int lastMaxPenaltyLength; /** @@ -117,15 +116,7 @@ public class TableStepper { keepWithNextSignals = new boolean[columnCount]; Arrays.fill(end, -1); } - - private void clearBreakCondition() { - forcedBreak = false; - } - - private boolean isBreakCondition() { - return forcedBreak; - } - + /** * Returns the row currently being processed. * @@ -307,6 +298,7 @@ public class TableStepper { int boxLen = step - addedBoxLen - penaltyLen; addedBoxLen += boxLen; + boolean forcedBreak = false; //Put all involved grid units into a list List gridUnitParts = new java.util.ArrayList(maxColumnCount); for (int i = 0; i < columnCount; i++) { @@ -320,6 +312,9 @@ public class TableStepper { 0, pgu.getElements().size() - 1)); } else { gridUnitParts.add(new GridUnitPart(pgu, start[i], end[i])); + if (((KnuthElement)elementLists[i].get(end[i])).isForcedBreak()) { + forcedBreak = true; + } } if (end[i] + 1 == elementLists[i].size()) { if (pgu.getFlag(GridUnit.KEEP_WITH_NEXT_PENDING)) { @@ -408,13 +403,12 @@ public class TableStepper { //Need to avoid breaking because borders and/or paddding from other columns would //not fit in the available space (see getNextStep()) } - if (isBreakCondition()) { + if (forcedBreak) { if (skippedStep) { log.error("This is a conflict situation. The output may be wrong." + " Please send your FO file to fop-dev@xmlgraphics.apache.org!"); } p = -KnuthPenalty.INFINITE; //Overrides any keeps (see 4.8 in XSL 1.0) - clearBreakCondition(); } returnList.add(new BreakElement(penaltyPos, effPenaltyLen, p, -1, context)); @@ -436,9 +430,6 @@ public class TableStepper { //we have to signal the still pending last keep-with-next using the LayoutContext. context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING); } - if (isBreakCondition()) { - ((BreakElement)returnList.getLast()).setPenaltyValue(-KnuthPenalty.INFINITE); - } if (lastTCPos != null) { lastTCPos.setFlag(TableContentPosition.LAST_IN_ROWGROUP, true); } @@ -478,7 +469,6 @@ public class TableStepper { this.lastMaxPenaltyLength = Math.max(this.lastMaxPenaltyLength, el.getW()); if (el.getP() <= -KnuthElement.INFINITE) { log.debug("FORCED break encountered!"); - forcedBreak = true; break; } else if (el.getP() < KnuthElement.INFINITE) { //First legal break point diff --git a/test/layoutengine/standard-testcases/table-cell_block_break-after.xml b/test/layoutengine/standard-testcases/table-cell_block_break-after.xml new file mode 100644 index 000000000..df1ed152c --- /dev/null +++ b/test/layoutengine/standard-testcases/table-cell_block_break-after.xml @@ -0,0 +1,82 @@ + + + + + +

+ This test checks breaks on tables: breaks inside table-cell content. It ensures that breaks + are taken into account only once. +

+
+ + + + + + + + + + + + + + + Cell 1 + Cell 1 + Cell 1 + + + Cell 2 + + Cell 2 + Cell 2 + Cell 2 + + Cell 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + +