import org.apache.fop.fo.flow.TableRow;
import org.apache.fop.fo.properties.LengthRangeProperty;
import org.apache.fop.layoutmgr.ElementListUtils;
+import org.apache.fop.layoutmgr.KnuthElement;
import org.apache.fop.layoutmgr.KnuthPossPosIter;
import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.SpaceResolver;
return this.accumulatedBPD;
}
- public void notifyNestedPenaltyArea(int length) {
- yoffset += length;
- accumulatedBPD += length;
- }
-
/**
* Records the fragment of row represented by the given position. If it belongs to
* another (grid) row than the current one, that latter is painted and flushed first.
log.trace("getting len for " + columnIndex + " "
+ start + "-" + end);
}
+ int actualStart = start;
+ // Skip from the content length calculation glues and penalties occuring at the
+ // beginning of the page
+ while (actualStart <= end && !((KnuthElement)pgu.getElements().get(actualStart)).isBox()) {
+ actualStart++;
+ }
int len = ElementListUtils.calcContentLength(
- pgu.getElements(), start, end);
+ pgu.getElements(), actualStart, end);
+ KnuthElement el = (KnuthElement)pgu.getElements().get(end);
+ if (el.isPenalty()) {
+ len += el.getW();
+ }
partBPD[columnIndex] = len;
if (log.isTraceEnabled()) {
log.trace("len of part: " + len);
import org.apache.fop.layoutmgr.ElementListUtils;
import org.apache.fop.layoutmgr.KnuthBox;
import org.apache.fop.layoutmgr.KnuthElement;
+import org.apache.fop.layoutmgr.KnuthGlue;
import org.apache.fop.layoutmgr.KnuthPenalty;
import org.apache.fop.layoutmgr.LayoutContext;
+import org.apache.fop.layoutmgr.Position;
/**
* This class processes row groups to create combined element lists for tables.
* current one.
*/
private int width;
+ private int remainingLength;
private int baseWidth;
private int totalLength;
private int includedLength;
}
elementList.add(new KnuthBoxCellWithBPD(height));
} else {
- //Copy elements (LinkedList) to array lists to improve
- //element access performance
elementList = pgu.getElements();
// if (log.isTraceEnabled()) {
// log.trace("column " + (column+1) + ": recording " + elementLists.size() + " element(s)");
startRow = rowIndex;
keepWithNextSignal = false;
computeBaseWidth(rowGroup);
+ remainingLength = totalLength;
goToNextLegalBreak();
}
} else if (includedLength == totalLength) {
return 0;
} else {
- return totalLength - Math.max(0, includedLength)
- + borderBefore + borderAfter + paddingBefore + paddingAfter;
+ return remainingLength + borderBefore + borderAfter + paddingBefore + paddingAfter;
}
}
int getNextStep() {
if (!includedInLastStep()) {
- return width + borderBefore + borderAfter + paddingBefore + paddingAfter;
+ return width + lastPenaltyLength + borderBefore + borderAfter + paddingBefore + paddingAfter;
} else {
start = end + 1;
if (end < elementList.size() - 1) {
goToNextLegalBreak();
- return width + borderBefore + borderAfter + paddingBefore + paddingAfter;
+ return width + lastPenaltyLength + borderBefore + borderAfter + paddingBefore + paddingAfter;
} else {
return 0;
}
}
boolean signalMinStep(int minStep) {
- if (width + borderBefore + borderAfter + paddingBefore + paddingAfter <= minStep) {
+ if (width + lastPenaltyLength + borderBefore + borderAfter + paddingBefore + paddingAfter <= minStep) {
includedLength = width;
+ computeRemainingLength();
return false;
} else {
return baseWidth + borderBefore + borderAfter + paddingBefore + paddingAfter > minStep;
}
}
+ private void computeRemainingLength() {
+ remainingLength = totalLength - width;
+ int index = end + 1;
+ while (index < elementList.size()) {
+ KnuthElement el = (KnuthElement)elementList.get(index);
+ if (el.isBox()) {
+ break;
+ } else if (el.isGlue()) {
+ remainingLength -= el.getW();
+ }
+ index++;
+ }
+ }
+
boolean contributesContent() {
return includedInLastStep() && end >= start;
}
return includedLength > 0;
}
- int getLastPenaltyLength() {
- return lastPenaltyLength;
- }
-
boolean isFinished() {
return includedInLastStep() && (end == elementList.size() - 1);
}
private int activeRowIndex;
private boolean rowBacktrackForLastStep;
private boolean skippedStep;
- private int lastMaxPenaltyLength;
private List activeCells = new LinkedList();
while ((step = getNextStep()) >= 0) {
int normalRow = activeRowIndex;
int increase = step - laststep;
- int penaltyLen = step + getMaxRemainingHeight() - totalHeight;
- int boxLen = step - addedBoxLen - penaltyLen;
+ int penaltyOrGlueLen = step + getMaxRemainingHeight() - totalHeight;
+ int boxLen = step - addedBoxLen - Math.max(0, penaltyOrGlueLen);
addedBoxLen += boxLen;
boolean forcedBreak = false;
//log.debug(">>> guPARTS: " + gridUnitParts);
//Create elements for step
- int effPenaltyLen = penaltyLen;
TableContentPosition tcpos = new TableContentPosition(getTableLM(),
gridUnitParts, rowGroup[normalRow]);
if (returnList.size() == 0) {
+ " - row=" + activeRowIndex + " - " + tcpos);
}
returnList.add(new KnuthBox(boxLen, tcpos, false));
+
+ int effPenaltyLen = Math.max(0, penaltyOrGlueLen);
TableHFPenaltyPosition penaltyPos = new TableHFPenaltyPosition(getTableLM());
if (bodyType == TableRowIterator.BODY) {
if (!getTableLM().getTable().omitHeaderAtBreak()) {
}
}
- //Handle a penalty length coming from nested content
- //Example: nested table with header/footer
- if (this.lastMaxPenaltyLength != 0) {
- penaltyPos.nestedPenaltyLength = this.lastMaxPenaltyLength;
- if (log.isDebugEnabled()) {
- log.debug("Additional penalty length from table-cell break: "
- + this.lastMaxPenaltyLength);
- }
- }
- effPenaltyLen += this.lastMaxPenaltyLength;
-
int p = 0;
boolean allCellsHaveContributed = true;
signalKeepWithNext = false;
p = -KnuthPenalty.INFINITE; //Overrides any keeps (see 4.8 in XSL 1.0)
}
returnList.add(new BreakElement(penaltyPos, effPenaltyLen, p, breakClass, context));
+ if (penaltyOrGlueLen < 0) {
+ returnList.add(new KnuthGlue(-penaltyOrGlueLen, 0, 0, new Position(null), true));
+ }
if (log.isDebugEnabled()) {
log.debug("step=" + step + " (+" + increase + ")"
+ " box=" + boxLen
- + " penalty=" + penaltyLen
+ + " penalty=" + penaltyOrGlueLen
+ " effPenalty=" + effPenaltyLen);
}
*/
private int getNextStep() {
log.trace("Entering getNextStep");
- this.lastMaxPenaltyLength = 0;
//Check for forced break conditions
/*
if (isBreakCondition()) {
if (nextStep > 0) {
stepFound = true;
minStep = Math.min(minStep, nextStep);
- lastMaxPenaltyLength = Math.max(lastMaxPenaltyLength, activeCell
- .getLastPenaltyLength());
}
}
if (!stepFound) {
super(w, null, true);
}
}
-
}