}
public void mergeColumnStylesIntoCellStyles(
Styles cellStyles, boolean firstRow, boolean firstColumn) {
MutablePropertyValues cellValues = cellStyles.getPropertyValues();
// If the cell is transparent then it will show through the row
// background, or if that is also transparent the cell background. If
// the row has a background image set then setting the cell's colour
// to the column's color would obscure the row image. So in that case
// don't set the cell background.
//
// todo Support columns in output markup so that these styles can be
// todo added to the element. This code would then become protocol
// todo dependent and would have to be moved into the protocols.
if (layerIsTransparent(CELL)) {
if (layerIsTransparent(ROW) && layerIsTransparent(ROW_GROUP)) {
if (layerIsTransparent(COLUMN)) {
setBackgroundFromLayer(cellValues, COLUMN_GROUP);
} else {
setBackgroundFromLayer(cellValues, COLUMN);
}
}
}
// Only set the width of the cell on the first row.
if (firstRow) {
// The column width sets the absolute minimum width for all cells
// in that column. The actual minimum width for the column is
// approximately the largest of the minimum widths of all the cells
// in that column. So we only need to set the column width on the
// cell if the cell is auto, or the column's width is larger than
// the cell.
StyleValue cellWidth = cellValues.getStyleValue(
StylePropertyDetails.WIDTH);
if (cellWidth == WidthKeywords.AUTO) {
StyleValues columnValues = getLayer(COLUMN);
StyleValue columnWidth = columnValues.getStyleValue(
StylePropertyDetails.WIDTH);
// The minimum width of the cell will be the largest of the
// specified width and the MCW (the minimum content width
// determined by the content). So setting the width of the cell to
// the width of the column will have the same effect as it would
// have on the column itself.
cellValues.setComputedValue(StylePropertyDetails.WIDTH,
columnWidth);
} else {
// todo compare sizes, not sure what to do if one is length
// todo and other is percentage.
}