From: Vincent Hennebert Date: Thu, 12 Jul 2007 16:11:32 +0000 (+0000) Subject: Move the creation of GridUnitParts into ActiveCell X-Git-Tag: fop-0_94~39 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b535780e8c8028029abdbe700b0d1f125a717883;p=xmlgraphics-fop.git Move the creation of GridUnitParts into ActiveCell git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@555677 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/layoutmgr/table/GridUnitPart.java b/src/java/org/apache/fop/layoutmgr/table/GridUnitPart.java index 52227ef30..0dcb785fc 100644 --- a/src/java/org/apache/fop/layoutmgr/table/GridUnitPart.java +++ b/src/java/org/apache/fop/layoutmgr/table/GridUnitPart.java @@ -62,4 +62,9 @@ class GridUnitPart { return sb.toString(); } + boolean mustKeepWithPrevious() { + return pgu.getFlag(GridUnit.KEEP_WITH_PREVIOUS_PENDING) + || (pgu.getRow() != null && pgu.getRow().mustKeepWithPrevious()); + } + } diff --git a/src/java/org/apache/fop/layoutmgr/table/TableStepper.java b/src/java/org/apache/fop/layoutmgr/table/TableStepper.java index b36930ecb..43eb690a2 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableStepper.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableStepper.java @@ -222,7 +222,37 @@ public class TableStepper { boolean isFinished() { return includedInLastStep() && (end == elementList.size() - 1); } - } + + GridUnitPart createGridUnitPart() { + if (end + 1 == elementList.size()) { + if (pgu.getFlag(GridUnit.KEEP_WITH_NEXT_PENDING)) { + log.debug("PGU has pending keep-with-next"); + keepWithNextSignal = true; + } + if (pgu.getRow() != null && pgu.getRow().mustKeepWithNext()) { + log.debug("table-row causes keep-with-next"); + keepWithNextSignal = true; + } + } + if (start == 0 && end == 0 + && elementList.size() == 1 + && elementList.get(0) instanceof KnuthBoxCellWithBPD) { + //Special case: Cell with fixed BPD + return new GridUnitPart(pgu, 0, pgu.getElements().size() - 1); + } else { + return new GridUnitPart(pgu, start, end); + } + } + + boolean isLastForcedBreak() { + return ((KnuthElement)elementList.get(end)).isForcedBreak(); + } + + int getLastBreakClass() { + return ((KnuthPenalty)elementList.get(end)).getBreakClass(); + } +} + /** Logger **/ private static Log log = LogFactory.getLog(TableStepper.class); @@ -352,43 +382,14 @@ public class TableStepper { for (Iterator iter = activeCells.iterator(); iter.hasNext();) { ActiveCell activeCell = (ActiveCell) iter.next(); if (activeCell.contributesContent()) { - PrimaryGridUnit pgu = activeCell.pgu; - if (activeCell.start == 0 && activeCell.end == 0 - && activeCell.elementList.size() == 1 - && activeCell.elementList.get(0) instanceof KnuthBoxCellWithBPD) { - //Special case: Cell with fixed BPD - gridUnitParts.add(new GridUnitPart(pgu, - 0, pgu.getElements().size() - 1)); - } else { - gridUnitParts.add(new GridUnitPart(pgu, activeCell.start, activeCell.end)); - if (((KnuthElement)activeCell.elementList.get(activeCell.end)).isForcedBreak()) { - forcedBreak = true; - breakClass = ((KnuthPenalty)activeCell.elementList.get(activeCell.end)).getBreakClass(); - } - } - if (activeCell.end + 1 == activeCell.elementList.size()) { - if (pgu.getFlag(GridUnit.KEEP_WITH_NEXT_PENDING)) { - log.debug("PGU has pending keep-with-next"); - activeCell.keepWithNextSignal = true; - } - if (pgu.getRow() != null && pgu.getRow().mustKeepWithNext()) { - log.debug("table-row causes keep-with-next"); - activeCell.keepWithNextSignal = true; - } + GridUnitPart gup = activeCell.createGridUnitPart(); + gridUnitParts.add(gup); + forcedBreak = activeCell.isLastForcedBreak(); + if (forcedBreak) { + breakClass = activeCell.getLastBreakClass(); } - if (activeCell.start == 0 && activeCell.end >= 0) { - if (pgu.getFlag(GridUnit.KEEP_WITH_PREVIOUS_PENDING)) { - log.debug("PGU has pending keep-with-previous"); - if (returnList.size() == 0) { - context.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING); - } - } - if (pgu.getRow() != null && pgu.getRow().mustKeepWithPrevious()) { - log.debug("table-row causes keep-with-previous"); - if (returnList.size() == 0) { - context.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING); - } - } + if (returnList.size() == 0 && gup.isFirstPart() && gup.mustKeepWithPrevious()) { + context.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING); } } }