//Check for bpd on row, see CSS21, 17.5.3 Table height algorithms
LengthRangeProperty bpd = tableRow.getBlockProgressionDimension();
if (!bpd.getMinimum(getTableLM()).isAuto()) {
- minContentHeight = Math.max(minContentHeight,
- bpd.getMinimum(getTableLM()).getLength().getValue(getTableLM()));
+ minContentHeight = Math.max(
+ minContentHeight,
+ bpd.getMinimum(
+ getTableLM()).getLength().getValue(getTableLM()));
}
MinOptMaxUtil.restrict(explicitRowHeights[rgi], bpd, getTableLM());
int effCellContentHeight = minContentHeight;
LengthRangeProperty bpd = primary.getCell().getBlockProgressionDimension();
if (!bpd.getMinimum(getTableLM()).isAuto()) {
- effCellContentHeight = Math.max(effCellContentHeight,
- bpd.getMinimum(getTableLM()).getLength().getValue(getTableLM()));
+ effCellContentHeight = Math.max(
+ effCellContentHeight,
+ bpd.getMinimum(getTableLM()).getLength().getValue(getTableLM()));
}
if (!bpd.getOptimum(getTableLM()).isAuto()) {
- effCellContentHeight = Math.max(effCellContentHeight,
- bpd.getOptimum(getTableLM()).getLength().getValue(getTableLM()));
+ effCellContentHeight = Math.max(
+ effCellContentHeight,
+ bpd.getOptimum(getTableLM()).getLength().getValue(getTableLM()));
}
if (gu.getRowSpanIndex() == 0) {
//TODO ATM only non-row-spanned cells are taken for this
}
public void handleTableContentPosition(TableContentPosition tcpos) {
- log.debug("===handleTableContentPosition(" + tcpos);
if (lastRow != tcpos.row && lastRow != null) {
addAreasAndFlushRow(false);
yoffset += lastRowHeight;
this.accumulatedBPD += lastRowHeight;
}
- rowFO = null;
+ if (log.isDebugEnabled()) {
+ log.debug("===handleTableContentPosition(" + tcpos);
+ }
+ rowFO = tcpos.row.getTableRow();
lastRow = tcpos.row;
Iterator partIter = tcpos.gridUnitParts.iterator();
//Iterate over all grid units in the current step
while (partIter.hasNext()) {
GridUnitPart gup = (GridUnitPart)partIter.next();
- log.debug(">" + gup);
+ if (log.isDebugEnabled()) {
+ log.debug(">" + gup);
+ }
int colIndex = gup.pgu.getStartCol();
if (gridUnits[colIndex] != gup.pgu) {
+ if (gridUnits[colIndex] != null) {
+ log.warn("Replacing GU in slot " + colIndex
+ + ". Some content may not be painted.");
+ }
gridUnits[colIndex] = gup.pgu;
start[colIndex] = gup.start;
end[colIndex] = gup.end;
}
end[colIndex] = gup.end;
}
- if (rowFO == null) {
- //Find the row if any
- rowFO = gridUnits[colIndex].getRow();
- }
}
}
int readyCount = 0;
int bt = lastRow.getBodyType();
+ if (log.isDebugEnabled()) {
+ log.debug("Remembering yoffset for row " + lastRow.getIndex() + ": " + yoffset);
+ }
rowOffsets[bt].put(new Integer(lastRow.getIndex()), new Integer(yoffset));
for (int i = 0; i < gridUnits.length; i++) {
if ((gridUnits[i] != null)
&& (forcedFlush || (end[i] == gridUnits[i].getElements().size() - 1))) {
- log.debug("getting len for " + i + " "
- + start[i] + "-" + end[i]);
+ if (log.isTraceEnabled()) {
+ log.trace("getting len for " + i + " "
+ + start[i] + "-" + end[i]);
+ }
readyCount++;
int len = ElementListUtils.calcContentLength(
gridUnits[i].getElements(), start[i], end[i]);
partLength[i] = len;
- log.debug("len of part: " + len);
+ if (log.isTraceEnabled()) {
+ log.trace("len of part: " + len);
+ }
if (start[i] == 0) {
LengthRangeProperty bpd = gridUnits[i].getCell()
.getBlockProgressionDimension();
if (!bpd.getMinimum(getTableLM()).isAuto()) {
- if (bpd.getMinimum(getTableLM()).getLength().getValue(getTableLM()) > 0) {
- len = Math.max(len, bpd.getMinimum(getTableLM()).getLength().getValue(getTableLM()));
+ int min = bpd.getMinimum(getTableLM())
+ .getLength().getValue(getTableLM());
+ if (min > 0) {
+ len = Math.max(len, bpd.getMinimum(getTableLM())
+ .getLength().getValue(getTableLM()));
}
}
if (!bpd.getOptimum(getTableLM()).isAuto()) {
- if (bpd.getOptimum(getTableLM()).getLength().getValue(getTableLM()) > 0) {
- len = Math.max(len, bpd.getOptimum(getTableLM()).getLength().getValue(getTableLM()));
+ int opt = bpd.getOptimum(getTableLM())
+ .getLength().getValue(getTableLM());
+ if (opt > 0) {
+ len = Math.max(len, opt);
}
}
if (gridUnits[i].getRow() != null) {
bpd = gridUnits[i].getRow().getBlockProgressionDimension();
if (!bpd.getMinimum(getTableLM()).isAuto()) {
- if (bpd.getMinimum(getTableLM()).getLength().getValue(getTableLM()) > 0) {
- len = Math.max(len, bpd.getMinimum(getTableLM()).getLength().getValue(getTableLM()));
+ int min = bpd.getMinimum(getTableLM()).getLength()
+ .getValue(getTableLM());
+ if (min > 0) {
+ len = Math.max(len, min);
}
}
}
return actualRowHeight;
}
- private void addAreasForCell(PrimaryGridUnit pgu, int start, int end,
+ private void addAreasForCell(PrimaryGridUnit pgu, int startPos, int endPos,
EffRow row, int contentHeight, int rowHeight) {
int bt = row.getBodyType();
if (firstRow[bt] < 0) {
firstRow[bt] = row.getIndex();
}
//Determine the first row in this sequence
- //TODO Maybe optimize since addAreasAndFlushRow uses almost the same code
int startRow = Math.max(pgu.getStartRow(), firstRow[bt]);
- int effYOffset = ((Integer)rowOffsets[bt].get(new Integer(startRow))).intValue();
+ //Determine y offset for the cell
+ Integer offset = (Integer)rowOffsets[bt].get(new Integer(startRow));
+ while (offset == null) {
+ startRow--;
+ offset = (Integer)rowOffsets[bt].get(new Integer(startRow));
+ }
+ int effYOffset = offset.intValue();
int effCellHeight = rowHeight;
effCellHeight += yoffset - effYOffset;
- log.debug("current row: " + row.getIndex());
- log.debug("start row: " + pgu.getStartRow() + " " + yoffset + " " + effYOffset);
- log.debug("contentHeight: " + contentHeight + " rowHeight=" + rowHeight
- + " effCellHeight=" + effCellHeight);
+ if (log.isDebugEnabled()) {
+ log.debug("Creating area for cell:");
+ log.debug(" current row: " + row.getIndex());
+ log.debug(" start row: " + pgu.getStartRow() + " " + yoffset + " " + effYOffset);
+ log.debug(" contentHeight: " + contentHeight + " rowHeight=" + rowHeight
+ + " effCellHeight=" + effCellHeight);
+ }
TableCellLayoutManager cellLM = pgu.getCellLM();
cellLM.setXOffset(getXOffsetOfGridUnit(pgu));
cellLM.setYOffset(effYOffset);
cellLM.setRowHeight(effCellHeight);
//cellLM.setRowHeight(row.getHeight().opt);
cellLM.addAreas(new KnuthPossPosIter(pgu.getElements(),
- start, end + 1), layoutContext);
+ startPos, endPos + 1), layoutContext);
}
}
rowBackground.setXOffset(this.startXOffset);
rowBackground.setYOffset(yoffset);
getTableLM().addChildArea(rowBackground);
- TraitSetter.addBackground(rowBackground, row.getCommonBorderPaddingBackground(), getTableLM());
+ TraitSetter.addBackground(rowBackground,
+ row.getCommonBorderPaddingBackground(), getTableLM());
}
}
public String toString() {
StringBuffer sb = new StringBuffer("TableContentPosition:");
sb.append(getIndex());
- sb.append("[").append(getFlag(FIRST_IN_ROWGROUP) ? "F" : "-");
- sb.append((getFlag(LAST_IN_ROWGROUP) ? "L" : "-")).append("]");
+ sb.append("[");
+ sb.append(row.getIndex()).append("/");
+ sb.append(getFlag(FIRST_IN_ROWGROUP) ? "F" : "-");
+ sb.append(getFlag(LAST_IN_ROWGROUP) ? "L" : "-").append("]");
sb.append("(");
sb.append(gridUnitParts);
sb.append(")");
}
private GridUnit getActiveGridUnit(int column) {
- return getActiveRow().getGridUnit(column);
+ return getActiveRow().safelyGetGridUnit(column);
}
private PrimaryGridUnit getActivePrimaryGridUnit(int column) {
- return getActiveGridUnit(column).getPrimary();
+ GridUnit gu = getActiveGridUnit(column);
+ if (gu == null) {
+ return null;
+ } else {
+ return gu.getPrimary();
+ }
}
private void calcTotalHeight() {
private void setupElementList(int column) {
GridUnit gu = getActiveGridUnit(column);
EffRow row = getActiveRow();
- if (gu.isEmpty()) {
+ if (gu == null || gu.isEmpty()) {
elementLists[column] = null;
start[column] = 0;
end[column] = -1;
TableContentPosition lastTCPos = null;
LinkedList returnList = new LinkedList();
while ((step = getNextStep(laststep)) >= 0) {
+ int normalRow = activeRow;
if (rowBacktrackForLastStep) {
//Even though we've already switched to the next row, we have to
//calculate as if we were still on the previous row
List gridUnitParts = new java.util.ArrayList(maxColumnCount);
for (int i = 0; i < start.length; i++) {
if (end[i] >= start[i]) {
- PrimaryGridUnit pgu = getActivePrimaryGridUnit(i);
+ PrimaryGridUnit pgu = rowGroup[startRow[i]].getGridUnit(i).getPrimary();
if (start[i] == 0 && end[i] == 0
&& elementLists[i].size() == 1
&& elementLists[i].get(0) instanceof KnuthBoxCellWithBPD) {
//Create elements for step
int effPenaltyLen = penaltyLen;
TableContentPosition tcpos = new TableContentPosition(getTableLM(),
- gridUnitParts, getActiveRow());
+ gridUnitParts, rowGroup[normalRow]);
if (returnList.size() == 0) {
tcpos.setFlag(TableContentPosition.FIRST_IN_ROWGROUP, true);
}
lastTCPos = tcpos;
- log.debug(" - " + rowBacktrackForLastStep + " - " + activeRow + " - " + tcpos);
+ if (log.isDebugEnabled()) {
+ log.debug(" - backtrack=" + rowBacktrackForLastStep
+ + " - row=" + activeRow + " - " + tcpos);
+ }
returnList.add(new KnuthBox(boxLen, tcpos, false));
TableHFPenaltyPosition penaltyPos = new TableHFPenaltyPosition(getTableLM());
if (bodyType == TableRowIterator.BODY) {
+ "in progress (See XSL 1.0, 7.19.1)");
}
activeRow++;
- log.debug("===> new row: " + activeRow);
+ if (log.isDebugEnabled()) {
+ log.debug("===> new row: " + activeRow);
+ }
initializeElementLists();
for (int i = 0; i < backupWidths.length; i++) {
if (end[i] < 0) {
borderAfter[i] = getActivePrimaryGridUnit(i).getHalfMaxAfterBorderWidth();
}
}
- log.debug("borders before=" + borderBefore[i] + " after=" + borderAfter[i]);
- log.debug("padding before=" + paddingBefore[i] + " after=" + paddingAfter[i]);
+ if (log.isTraceEnabled()) {
+ log.trace("borders before=" + borderBefore[i] + " after=" + borderAfter[i]);
+ log.trace("padding before=" + paddingBefore[i] + " after=" + paddingAfter[i]);
+ }
}
if (seqCount == 0) {
return -1;