/** * Transform the passed blocks to make them columns, that is insert them in an enclosing "div" (or * group) with the appropriate styles. * * @param blocks the blocks to transform. Presumably all column macro blocks. * @param columnWidth the relative width to give to each column. */ private void makeColumns(List<MacroBlock> blocks, double columnWidth) { Iterator<MacroBlock> it = blocks.iterator(); while (it.hasNext()) { MacroBlock probablyColumn = it.next(); if (probablyColumn.getId().equals(ColumnMacro.MACRO_NAME)) { ColumnStyle style = new ColumnStyle(); style.setWidth(columnWidth + "%"); if (it.hasNext()) { style.setPaddingRight(COLUMN_RIGHT_PADDING_STYLE); } Map<String, String> params = Collections.singletonMap(PARAMETER_STYLE, style.getStyleAsString()); Block colParent = new GroupBlock(new HashMap<String, String>(params)); colParent.addChild(probablyColumn.clone()); probablyColumn.getParent().replaceChild(colParent, probablyColumn); } // FIXME Should we cry and throw an exception if ever we meet something else than a column // macro right under // a section macro ? } }