result.setElement(source);
result.setAnonymous(true);
result.setChildrenContentType(BlockBox.CONTENT_BLOCK);
CalculatedStyle tableSectionStyle = pageStyle.createAnonymousStyle(IdentValue.TABLE_ROW_GROUP);
TableSectionBox section = (TableSectionBox)createBlockBox(tableSectionStyle, info, false);
section.setStyle(tableSectionStyle);
section.setElement(source);
section.setAnonymous(true);
section.setChildrenContentType(BlockBox.CONTENT_BLOCK);
result.addChild(section);
TableRowBox row = null;
if (direction == MARGIN_BOX_HORIZONTAL) {
CalculatedStyle tableRowStyle = pageStyle.createAnonymousStyle(IdentValue.TABLE_ROW);
row = (TableRowBox)createBlockBox(tableRowStyle, info, false);
row.setStyle(tableRowStyle);
row.setElement(source);
row.setAnonymous(true);
row.setChildrenContentType(BlockBox.CONTENT_BLOCK);
row.setHeightOverride(height);
section.addChild(row);
}
int cellCount = 0;
boolean alwaysCreate = names.length > 1 && direction == MARGIN_BOX_HORIZONTAL;
for (int i = 0; i < names.length; i++) {
CascadedStyle cellStyle = pageInfo.createMarginBoxStyle(names[i], alwaysCreate);
if (cellStyle != null) {
TableCellBox cell = createMarginBox(c, cellStyle, alwaysCreate);
if (cell != null) {
if (direction == MARGIN_BOX_VERTICAL) {
CalculatedStyle tableRowStyle = pageStyle.createAnonymousStyle(IdentValue.TABLE_ROW);
row = (TableRowBox)createBlockBox(tableRowStyle, info, false);
row.setStyle(tableRowStyle);
row.setElement(source);
row.setAnonymous(true);
row.setChildrenContentType(BlockBox.CONTENT_BLOCK);
row.setHeightOverride(height);
section.addChild(row);
}
row.addChild(cell);
cellCount++;
}
}
}
if (direction == MARGIN_BOX_VERTICAL && cellCount > 0) {
int rHeight = 0;
for (Iterator i = section.getChildIterator(); i.hasNext(); ) {
TableRowBox r = (TableRowBox)i.next();
r.setHeightOverride(height / cellCount);
rHeight += r.getHeightOverride();
}
for (Iterator i = section.getChildIterator(); i.hasNext() && rHeight < height; ) {
TableRowBox r = (TableRowBox)i.next();
r.setHeightOverride(r.getHeightOverride()+1);
rHeight++;
}
}