//Can set the borders directly if there's no span
CommonBorderPaddingBackground effBorders =
((GridUnit)((List)rows.get(0)).get(0)).effBorders;
+ //TODO Next line is a temporary hack!
+ TraitSetter.addCollapsingBorders(curBlockArea,
+ fobj.getCommonBorderPaddingBackground(), outer);
TraitSetter.addCollapsingBorders(curBlockArea,
effBorders, outer);
} else {
+ int dy = yoffset;
+ for (int y = 0; y < rows.size(); y++) {
+ List gridUnits = (List)rows.get(y);
+ int dx = xoffset;
+ int lastRowHeight = 0;
+ for (int x = 0; x < gridUnits.size(); x++) {
+ GridUnit gu = (GridUnit)gridUnits.get(x);
+ //Blocks for painting grid unit borders
+ Block block = new Block();
+ block.addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE);
+ block.setPositioning(Block.ABSOLUTE);
+ block.setBPD(gu.row.getRowHeight());
+ lastRowHeight = gu.row.getRowHeight();
+ int ipd = gu.column.getWidth().getValue();
+ int borderStartWidth = gu.effBorders.getBorderStartWidth(false) / 2;
+ ipd -= borderStartWidth;
+ ipd -= gu.effBorders.getBorderEndWidth(false) / 2;
+ block.setIPD(ipd);
+ block.setXOffset(dx + borderStartWidth);
+ block.setYOffset(dy);
+ TraitSetter.addCollapsingBorders(block, gu.effBorders, outer);
+ parentLM.addChild(block);
+ dx += gu.column.getWidth().getValue();
+ }
+ dy += lastRowHeight;
+ }
log.warn("TODO Add collapsed border painting for spanned cells");
}
}
//Border resolution now that the empty grid units are filled
for (int pos = 1; pos <= gridUnits.size(); pos++) {
- GridUnit gu = (GridUnit)gridUnits.get(pos - 1);
+ GridUnit starting = (GridUnit)gridUnits.get(pos - 1);
//Border resolution
if (getTable().isSeparateBorderModel()) {
- gu.assignBorder(gu.layoutManager);
+ starting.assignBorder(starting.layoutManager);
} else {
+ //Neighbouring grid unit at start edge
GridUnit start = null;
int find = pos - 1;
while (find >= 1) {
}
find--;
}
+
+ //Ending grid unit for current cell
+ GridUnit ending = null;
+ pos += starting.layoutManager.getFObj().getNumberColumnsSpanned() - 1;
+ ending = (GridUnit)gridUnits.get(pos - 1);
+
+ //Neighbouring grid unit at end edge
GridUnit end = null;
find = pos + 1;
while (find <= gridUnits.size()) {
end = candidate;
break;
}
+ find++;
}
CommonBorderPaddingBackground borders = new CommonBorderPaddingBackground();
- GridUnit.resolveBorder(getTable(), borders, gu,
+ GridUnit.resolveBorder(getTable(), borders, starting,
(start != null ? start : null),
CommonBorderPaddingBackground.START);
- GridUnit.resolveBorder(getTable(), borders, gu,
+ starting.effBorders = borders;
+ if (starting != ending) {
+ borders = new CommonBorderPaddingBackground();
+ }
+ GridUnit.resolveBorder(getTable(), borders, ending,
(end != null ? end : null),
CommonBorderPaddingBackground.END);
- gu.effBorders = borders;
+ ending.effBorders = borders;
//Only start and end borders here, before and after during layout
//TODO resolve before and after borders during layout
}
}
/**
- * Determines the columns that are spanned by the given cell.
+ * Determines the grid units that are spanned by the given cell.
* @param cellLM table-cell LM
* @param startCell starting cell index (must be >= 1)
- * @param spannedColumns List to receive the applicable columns
+ * @param spannedGridUnits List to receive the applicable grid units
*/
- private void getGridUnitsForCell(Cell cellLM, int startCell, List spannedColumns) {
+ private void getGridUnitsForCell(Cell cellLM, int startCell, List spannedGridUnits) {
int count;
if (cellLM != null) {
count = cellLM.getFObj().getNumberColumnsSpanned();
} else {
count = 1;
}
- spannedColumns.clear();
+ spannedGridUnits.clear();
for (int i = 0; i < count; i++) {
- spannedColumns.add(this.gridUnits.get(startCell + i - 1));
+ spannedGridUnits.add(this.gridUnits.get(startCell + i - 1));
}
}