} else {
// If we have a floated table with a caption, we need to float the
// outer anonymous box and not the table
CalculatedStyle anonStyle;
if (table.getStyle().isFloated()) {
CascadedStyle cascadedStyle = CascadedStyle.createLayoutStyle(
new PropertyDeclaration[]{
CascadedStyle.createLayoutPropertyDeclaration(
CSSName.DISPLAY, IdentValue.BLOCK),
CascadedStyle.createLayoutPropertyDeclaration(
CSSName.FLOAT, table.getStyle().getIdent(CSSName.FLOAT))});
anonStyle = table.getStyle().deriveStyle(cascadedStyle);
} else {
anonStyle = table.getStyle().createAnonymousStyle(IdentValue.BLOCK);
}
BlockBox anonBox = new BlockBox();
anonBox.setStyle(anonStyle);
anonBox.setAnonymous(true);
anonBox.setFromCaptionedTable(true);
anonBox.setElement(table.getElement());
anonBox.setChildrenContentType(BlockBox.CONTENT_BLOCK);
anonBox.addAllChildren(topCaptions);
anonBox.addChild(table);
anonBox.addAllChildren(bottomCaptions);
if (table.getStyle().isFloated()) {
anonBox.setFloatedBoxData(new FloatedBoxData());
table.setFloatedBoxData(null);
CascadedStyle original = c.getSharedContext().getCss().getCascadedStyle(
table.getElement(), false);
CascadedStyle modified = CascadedStyle.createLayoutStyle(
original,
new PropertyDeclaration[]{
CascadedStyle.createLayoutPropertyDeclaration(
CSSName.FLOAT, IdentValue.NONE)
});