From: Jeremias Maerki Date: Mon, 10 Mar 2008 22:39:38 +0000 (+0000) Subject: Bugfix for row/body/col background painting when padding is used in the table-cells. X-Git-Tag: fop-0_95beta~12 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a4c2cb03927957fcad3407a3e31afa72217433b9;p=xmlgraphics-fop.git Bugfix for row/body/col background painting when padding is used in the table-cells. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@635741 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java index 7036f199b..b99df4eb3 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java @@ -354,11 +354,12 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager CommonBorderPaddingBackground padding = primaryGridUnit.getCell() .getCommonBorderPaddingBackground(); - int cellBPD = totalHeight - borderBeforeWidth - borderAfterWidth; + int paddingRectBPD = totalHeight - borderBeforeWidth - borderAfterWidth; + int cellBPD = paddingRectBPD; cellBPD -= padding.getPaddingBefore(borderBeforeWhich == ConditionalBorder.REST, this); cellBPD -= padding.getPaddingAfter(borderAfterWhich == ConditionalBorder.REST, this); - addBackgroundAreas(painter, firstRowHeight, borderBeforeWidth, cellBPD); + addBackgroundAreas(painter, firstRowHeight, borderBeforeWidth, paddingRectBPD); if (isSeparateBorderModel()) { if (!emptyCell || getTableCell().showEmptyCells()) { @@ -488,22 +489,23 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager /** Adds background areas for the column, body and row, if any. */ private void addBackgroundAreas(RowPainter painter, int firstRowHeight, int borderBeforeWidth, - int cellBPD) { + int paddingRectBPD) { TableColumn column = getTable().getColumn(primaryGridUnit.getColIndex()); if (column.getCommonBorderPaddingBackground().hasBackground()) { - Block colBackgroundArea = getBackgroundArea(cellBPD, borderBeforeWidth); + Block colBackgroundArea = getBackgroundArea(paddingRectBPD, borderBeforeWidth); ((TableLayoutManager) parentLM).registerColumnBackgroundArea(column, colBackgroundArea, -startIndent); } TableBody body = primaryGridUnit.getTableBody(); if (body.getCommonBorderPaddingBackground().hasBackground()) { - painter.registerPartBackgroundArea(getBackgroundArea(cellBPD, borderBeforeWidth)); + painter.registerPartBackgroundArea( + getBackgroundArea(paddingRectBPD, borderBeforeWidth)); } TableRow row = primaryGridUnit.getRow(); if (row != null && row.getCommonBorderPaddingBackground().hasBackground()) { - Block rowBackgroundArea = getBackgroundArea(cellBPD, borderBeforeWidth); + Block rowBackgroundArea = getBackgroundArea(paddingRectBPD, borderBeforeWidth); ((TableLayoutManager) parentLM).addBackgroundArea(rowBackgroundArea); TraitSetter.addBackground(rowBackgroundArea, row.getCommonBorderPaddingBackground(), (TableLayoutManager) parentLM, @@ -541,12 +543,16 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager } private Block getBackgroundArea(int bpd, int borderBeforeWidth) { + CommonBorderPaddingBackground padding = getTableCell().getCommonBorderPaddingBackground(); + int paddingStart = padding.getPaddingStart(false, this); + int paddingEnd = padding.getPaddingStart(false, this); + Block block = new Block(); TraitSetter.setProducerID(block, getTable().getId()); block.setPositioning(Block.ABSOLUTE); - block.setIPD(cellIPD); + block.setIPD(cellIPD + paddingStart + paddingEnd); block.setBPD(bpd); - block.setXOffset(xoffset + startIndent); + block.setXOffset(xoffset + startIndent - paddingStart); block.setYOffset(yoffset + borderBeforeWidth); return block; } diff --git a/test/layoutengine/standard-testcases/table_backgrounds_2.xml b/test/layoutengine/standard-testcases/table_backgrounds_2.xml new file mode 100644 index 000000000..11d6d67f9 --- /dev/null +++ b/test/layoutengine/standard-testcases/table_backgrounds_2.xml @@ -0,0 +1,113 @@ + + + + + +

+ This test checks background painting for fo:table-row, fo:table-body and fo:table-column + when the cells use padding. +

+
+ + + + + + + + + + + + + + + background on cell + + + background on cell + + + + + background on row + + + background on row + + + + + + + background on body + + + background on body + + + + + + + + + + background on column + + + background on column + + + + + + + + + + background on table + + + background on table + + + + + + + + + + + + + + + + + + + + + + + + +