}
Element source = c.getRootLayer().getMaster().getElement(); // HACK
ChildBoxInfo info = new ChildBoxInfo();
CalculatedStyle pageStyle = new EmptyStyle().deriveStyle(pageInfo.getPageStyle());
CalculatedStyle tableStyle = pageStyle.deriveStyle(
CascadedStyle.createLayoutStyle(new PropertyDeclaration[] {
new PropertyDeclaration(
CSSName.DISPLAY,
new PropertyValue(IdentValue.TABLE),
true,
StylesheetInfo.USER),
new PropertyDeclaration(
CSSName.WIDTH,
new PropertyValue(CSSPrimitiveValue.CSS_PERCENTAGE, 100.0f, "100%"),
true,
StylesheetInfo.USER),
}));
TableBox result = (TableBox)createBlockBox(tableStyle, info, false);
result.setMarginAreaRoot(true);
result.setStyle(tableStyle);
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);