//Determine the table-row if any
if (tableRow == null && primary.getRow() != null) {
tableRow = primary.getRow();
//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()));
}
MinOptMaxUtil.restrict(explicitRowHeights[rgi], bpd, getTableLM());
}
//Calculate width of cell
int spanWidth = 0;
for (int i = primary.getStartCol();
i < primary.getStartCol()
+ primary.getCell().getNumberColumnsSpanned();
i++) {
if (getTableLM().getColumns().getColumn(i + 1) != null) {
spanWidth += getTableLM().getColumns().getColumn(i + 1)
.getColumnWidth().getValue(getTableLM());
}
}
LayoutContext childLC = new LayoutContext(0);
childLC.setStackLimit(context.getStackLimit()); //necessary?
childLC.setRefIPD(spanWidth);
//Get the element list for the cell contents
LinkedList elems = primary.getCellLM().getNextKnuthElements(
childLC, alignment);
//Temporary? Multiple calls in case of break conditions.
//TODO Revisit when table layout is restartable
while (!primary.getCellLM().isFinished()) {
LinkedList additionalElems = primary.getCellLM().getNextKnuthElements(
childLC, alignment);
elems.addAll(additionalElems);
}
ElementListObserver.observe(elems, "table-cell", primary.getCell().getId());
if ((elems.size() > 0)
&& ((KnuthElement)elems.getLast()).isForcedBreak()) {
// a descendant of this block has break-after
log.debug("Descendant of table-cell signals break: "
+ primary.getCellLM().isFinished());
}
primary.setElements(elems);
if (childLC.isKeepWithNextPending()) {
log.debug("child LM signals pending keep-with-next");
primary.setFlag(GridUnit.KEEP_WITH_NEXT_PENDING, true);
}
if (childLC.isKeepWithPreviousPending()) {
log.debug("child LM signals pending keep-with-previous");
primary.setFlag(GridUnit.KEEP_WITH_PREVIOUS_PENDING, true);
}
}
//Calculate height of cell contents
primary.setContentLength(ElementListUtils.calcContentLength(
primary.getElements()));
maxCellHeight = Math.max(maxCellHeight, primary.getContentLength());
//Calculate height of row, see CSS21, 17.5.3 Table height algorithms
if (gu.isLastGridUnitRowSpan()) {
int effCellContentHeight = minContentHeight;
LengthRangeProperty bpd = primary.getCell().getBlockProgressionDimension();
if (!bpd.getMinimum(getTableLM()).isAuto()) {
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()));
}
if (gu.getRowSpanIndex() == 0) {
//TODO ATM only non-row-spanned cells are taken for this
MinOptMaxUtil.restrict(explicitRowHeights[rgi], bpd, tableLM);
}