diff options
author | Finn Bock <bckfnn@apache.org> | 2005-08-31 20:29:33 +0000 |
---|---|---|
committer | Finn Bock <bckfnn@apache.org> | 2005-08-31 20:29:33 +0000 |
commit | e194fdd5cfe3f1bc823d93c57420db87eb7efed0 (patch) | |
tree | e4e195d6e88bd85e02c48bffac90176543aba0cc /src/java/org/apache/fop/layoutmgr/table | |
parent | 0c4637012c7a394bb3ae1b621ca89c7742b0612d (diff) | |
download | xmlgraphics-fop-e194fdd5cfe3f1bc823d93c57420db87eb7efed0.tar.gz xmlgraphics-fop-e194fdd5cfe3f1bc823d93c57420db87eb7efed0.zip |
Bugzilla #36379:
Revised percentage resolution system.
Submitted by: Manuel Mall <mm.at.arcus.com.au>
Slightly modified to avoid early evaluation of getValue().
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@265577 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/layoutmgr/table')
7 files changed, 178 insertions, 74 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java b/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java index c732763e7..188b9f6ab 100644 --- a/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java +++ b/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java @@ -24,6 +24,7 @@ import java.util.ListIterator; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.fo.flow.Table; import org.apache.fop.fo.flow.TableColumn; @@ -127,12 +128,13 @@ public class ColumnSetup { /** * @param col column index (1 is first column) + * @param context the context for percentage based calculations * @return the X offset of the requested column */ - public int getXOffset(int col) { + public int getXOffset(int col, PercentBaseContext context) { int xoffset = 0; for (int i = 1; i < col; i++) { - xoffset += getColumn(i).getColumnWidth().getValue(); + xoffset += getColumn(i).getColumnWidth().getValue(context); } return xoffset; } diff --git a/src/java/org/apache/fop/layoutmgr/table/GridUnit.java b/src/java/org/apache/fop/layoutmgr/table/GridUnit.java index db381bf87..48aeeae17 100644 --- a/src/java/org/apache/fop/layoutmgr/table/GridUnit.java +++ b/src/java/org/apache/fop/layoutmgr/table/GridUnit.java @@ -245,6 +245,9 @@ public class GridUnit { this.effBorders.setBorderInfo( borderModel.determineWinner(this, other, side, resFlags), side); + if (cell != null) { + this.effBorders.setPadding(this.cell.getCommonBorderPaddingBackground()); + } } /** diff --git a/src/java/org/apache/fop/layoutmgr/table/PrimaryGridUnit.java b/src/java/org/apache/fop/layoutmgr/table/PrimaryGridUnit.java index 21d042b8e..9caba174d 100644 --- a/src/java/org/apache/fop/layoutmgr/table/PrimaryGridUnit.java +++ b/src/java/org/apache/fop/layoutmgr/table/PrimaryGridUnit.java @@ -23,6 +23,7 @@ import java.util.List; import org.apache.fop.fo.flow.TableCell; import org.apache.fop.fo.flow.TableColumn; +import org.apache.fop.layoutmgr.LayoutManager; /** * This class represents a primary grid unit of a spanned cell. @@ -131,11 +132,11 @@ public class PrimaryGridUnit extends GridUnit { /** @return true if cell/row has an explicit BPD/height */ public boolean hasBPD() { - if (!getCell().getBlockProgressionDimension().getOptimum().isAuto()) { + if (!getCell().getBlockProgressionDimension().getOptimum(null).isAuto()) { return true; } if (getRow() != null - && !getRow().getBlockProgressionDimension().getOptimum().isAuto()) { + && !getRow().getBlockProgressionDimension().getOptimum(null).isAuto()) { return true; } return false; diff --git a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java index a304a0dd4..4fda7ab98 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java @@ -37,6 +37,7 @@ import org.apache.fop.layoutmgr.TraitSetter; import org.apache.fop.area.Area; import org.apache.fop.area.Block; import org.apache.fop.area.Trait; +import org.apache.fop.layoutmgr.LayoutManager; import org.apache.fop.traits.MinOptMax; /** @@ -71,11 +72,10 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement super(node); fobj = node; this.gridUnit = pgu; - initialize(); } /** @return the table-cell FO */ - public TableCell getFObj() { + public TableCell getTableCell() { return this.fobj; } @@ -83,15 +83,15 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement return fobj.isSeparateBorderModel(); } - private void initialize() { + public void initialize() { borderAndPaddingBPD = 0; borderAndPaddingBPD += fobj.getCommonBorderPaddingBackground().getBorderBeforeWidth(false); borderAndPaddingBPD += fobj.getCommonBorderPaddingBackground().getBorderAfterWidth(false); if (!isSeparateBorderModel()) { borderAndPaddingBPD /= 2; } - borderAndPaddingBPD += fobj.getCommonBorderPaddingBackground().getPaddingBefore(false); - borderAndPaddingBPD += fobj.getCommonBorderPaddingBackground().getPaddingAfter(false); + borderAndPaddingBPD += fobj.getCommonBorderPaddingBackground().getPaddingBefore(false, this); + borderAndPaddingBPD += fobj.getCommonBorderPaddingBackground().getPaddingAfter(false, this); } /** @@ -116,8 +116,8 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement if (!isSeparateBorderModel()) { iIndents /= 2; } - iIndents += fobj.getCommonBorderPaddingBackground().getPaddingStart(false); - iIndents += fobj.getCommonBorderPaddingBackground().getPaddingEnd(false); + iIndents += fobj.getCommonBorderPaddingBackground().getPaddingStart(false, this); + iIndents += fobj.getCommonBorderPaddingBackground().getPaddingEnd(false, this); return iIndents; } @@ -132,7 +132,7 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement cellIPD -= getIPIndents(); if (isSeparateBorderModel()) { int borderSep = fobj.getBorderSeparation().getLengthPair() - .getIPD().getLength().getValue(); + .getIPD().getLength().getValue(this); cellIPD -= borderSep; } @@ -298,8 +298,8 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement } CommonBorderPaddingBackground cbpb = gu.getCell().getCommonBorderPaddingBackground(); - bpd -= cbpb.getPaddingBefore(false); - bpd -= cbpb.getPaddingAfter(false); + bpd -= cbpb.getPaddingBefore(false, this); + bpd -= cbpb.getPaddingAfter(false, this); return bpd; } @@ -317,7 +317,11 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement getPSLM().addIDToPage(fobj.getId()); - if (!isSeparateBorderModel()) { + if (isSeparateBorderModel()) { + if (!emptyCell || fobj.showEmptyCells()) { + TraitSetter.addBorders(curBlockArea, fobj.getCommonBorderPaddingBackground(), this); + } + } else { boolean[] outer = new boolean[] { gridUnit.getFlag(GridUnit.FIRST_IN_TABLE), gridUnit.getFlag(GridUnit.LAST_IN_TABLE), @@ -326,7 +330,7 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement if (!gridUnit.hasSpanning()) { //Can set the borders directly if there's no span TraitSetter.addCollapsingBorders(curBlockArea, - gridUnit.getBorders(), outer); + gridUnit.getBorders(), outer, this); } else { int dy = yoffset; for (int y = 0; y < gridUnit.getRows().size(); y++) { @@ -356,7 +360,7 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement } block.setBPD(bpd); lastRowHeight = rowHeight; - int ipd = gu.getColumn().getColumnWidth().getValue(); + int ipd = gu.getColumn().getColumnWidth().getValue(this); int borderStartWidth = gu.getBorders().getBorderStartWidth(false) / 2; ipd -= borderStartWidth; ipd -= gu.getBorders().getBorderEndWidth(false) / 2; @@ -368,9 +372,9 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement += gu.getBorders().getBorderBeforeWidth(false) / 2; } block.setYOffset(dy - halfCollapsingBorderHeight); - TraitSetter.addCollapsingBorders(block, gu.getBorders(), outer); + TraitSetter.addCollapsingBorders(block, gu.getBorders(), outer, this); parentLM.addChildArea(block); - dx += gu.getColumn().getColumnWidth().getValue(); + dx += gu.getColumn().getColumnWidth().getValue(this); } dy += lastRowHeight; } @@ -396,13 +400,17 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement curBlockArea.setBPD(contentBPD); + // Add background after we know the BPD if (isSeparateBorderModel()) { if (!emptyCell || fobj.showEmptyCells()) { - TraitSetter.addBorders(curBlockArea, fobj.getCommonBorderPaddingBackground()); - TraitSetter.addBackground(curBlockArea, fobj.getCommonBorderPaddingBackground()); + TraitSetter.addBackground(curBlockArea, + fobj.getCommonBorderPaddingBackground(), + this); } } else { - TraitSetter.addBackground(curBlockArea, fobj.getCommonBorderPaddingBackground()); + TraitSetter.addBackground(curBlockArea, + fobj.getCommonBorderPaddingBackground(), + this); } flush(); @@ -434,12 +442,12 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement if (!isSeparateBorderModel()) { indent /= 2; } - indent += fobj.getCommonBorderPaddingBackground().getPaddingStart(false); + indent += fobj.getCommonBorderPaddingBackground().getPaddingStart(false, this); // set position int halfBorderSep = 0; if (isSeparateBorderModel()) { halfBorderSep = fobj.getBorderSeparation().getLengthPair() - .getIPD().getLength().getValue() / 2; + .getIPD().getLength().getValue(this) / 2; } int borderAdjust = 0; if (!isSeparateBorderModel()) { @@ -534,6 +542,43 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement || !fobj.getKeepWithNext().getWithinColumn().isAuto(); */ } + + // --------- Property Resolution related functions --------- // + + /** + * Returns the IPD of the content area + * @return the IPD of the content area + */ + public int getContentAreaIPD() { + return cellIPD; + } + + /** + * Returns the BPD of the content area + * @return the BPD of the content area + */ + public int getContentAreaBPD() { + if (curBlockArea != null) { + return curBlockArea.getBPD(); + } else { + log.error("getContentAreaBPD called on unknown BPD"); + return -1; + } + } + + /** + * @see org.apache.fop.layoutmgr.LayoutManager#getGeneratesReferenceArea + */ + public boolean getGeneratesReferenceArea() { + return true; + } + + /** + * @see org.apache.fop.layoutmgr.LayoutManager#getGeneratesBlockArea + */ + public boolean getGeneratesBlockArea() { + return true; + } } diff --git a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java index df32b143b..529ec8e41 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java @@ -28,7 +28,9 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.fop.area.Block; import org.apache.fop.area.Trait; +import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.fo.Constants; +import org.apache.fop.fo.FObj; import org.apache.fop.fo.flow.Table; import org.apache.fop.fo.flow.TableBody; import org.apache.fop.fo.flow.TableRow; @@ -51,7 +53,7 @@ import org.apache.fop.traits.MinOptMax; /** * Layout manager for table contents, particularly managing the creation of combined element lists. */ -public class TableContentLayoutManager { +public class TableContentLayoutManager implements PercentBaseContext { /** Logger **/ private static Log log = LogFactory.getLog(TableContentLayoutManager.class); @@ -415,7 +417,7 @@ public class TableContentLayoutManager { PrimaryGridUnit primary = gu.getPrimary(); if (gu.isPrimary()) { - primary.getCellLM().setParent(tableLM); + primary.getCellLM().setParent(getTableLM()); //Determine the table-row if any if (tableRow == null && primary.getRow() != null) { @@ -423,11 +425,11 @@ public class TableContentLayoutManager { //Check for bpd on row, see CSS21, 17.5.3 Table height algorithms LengthRangeProperty bpd = tableRow.getBlockProgressionDimension(); - if (!bpd.getMinimum().isAuto()) { + if (!bpd.getMinimum(getTableLM()).isAuto()) { minContentHeight = Math.max(minContentHeight, - bpd.getMinimum().getLength().getValue()); + bpd.getMinimum(getTableLM()).getLength().getValue(getTableLM())); } - MinOptMaxUtil.restrict(explicitRowHeights[rgi], bpd); + MinOptMaxUtil.restrict(explicitRowHeights[rgi], bpd, getTableLM()); } @@ -438,7 +440,7 @@ public class TableContentLayoutManager { + primary.getCell().getNumberColumnsSpanned(); i++) { spanWidth += getTableLM().getColumns().getColumn(i + 1) - .getColumnWidth().getValue(); + .getColumnWidth().getValue(getTableLM()); } LayoutContext childLC = new LayoutContext(0); childLC.setStackLimit(context.getStackLimit()); //necessary? @@ -487,17 +489,17 @@ public class TableContentLayoutManager { if (gu.isLastGridUnitRowSpan()) { int effCellContentHeight = minContentHeight; LengthRangeProperty bpd = primary.getCell().getBlockProgressionDimension(); - if (!bpd.getMinimum().isAuto()) { + if (!bpd.getMinimum(getTableLM()).isAuto()) { effCellContentHeight = Math.max(effCellContentHeight, - bpd.getMinimum().getLength().getValue()); + bpd.getMinimum(getTableLM()).getLength().getValue(getTableLM())); } - if (!bpd.getOptimum().isAuto()) { + if (!bpd.getOptimum(getTableLM()).isAuto()) { effCellContentHeight = Math.max(effCellContentHeight, - bpd.getOptimum().getLength().getValue()); + bpd.getOptimum(getTableLM()).getLength().getValue(getTableLM())); } if (gu.getRowSpanIndex() == 0) { //TODO ATM only non-row-spanned cells are taken for this - MinOptMaxUtil.restrict(explicitRowHeights[rgi], bpd); + MinOptMaxUtil.restrict(explicitRowHeights[rgi], bpd, tableLM); } effCellContentHeight = Math.max(effCellContentHeight, primary.getContentLength()); @@ -514,8 +516,8 @@ public class TableContentLayoutManager { effCellContentHeight); CommonBorderPaddingBackground cbpb = primary.getCell().getCommonBorderPaddingBackground(); - padding += cbpb.getPaddingBefore(false); - padding += cbpb.getPaddingAfter(false); + padding += cbpb.getPaddingBefore(false, primary.getCellLM()); + padding += cbpb.getPaddingAfter(false, primary.getCellLM()); int effRowHeight = effCellContentHeight + padding + borderWidths; for (int previous = 0; previous < gu.getRowSpanIndex(); previous++) { effRowHeight -= rowHeights[rgi - previous - 1].opt; @@ -566,7 +568,7 @@ public class TableContentLayoutManager { */ protected int getXOffsetOfGridUnit(GridUnit gu) { int col = gu.getStartCol(); - return startXOffset + getTableLM().getColumns().getXOffset(col + 1); + return startXOffset + getTableLM().getColumns().getXOffset(col + 1, getTableLM()); } /** @@ -792,36 +794,41 @@ public class TableContentLayoutManager { gridUnits[i].getElements(), start[i], end[i]); partLength[i] = len; log.debug("len of part: " + len); + if (start[i] == 0) { LengthRangeProperty bpd = gridUnits[i].getCell() .getBlockProgressionDimension(); - if (!bpd.getMinimum().isAuto()) { - if (bpd.getMinimum().getLength().getValue() > 0) { - len = Math.max(len, bpd.getMinimum().getLength().getValue()); + if (!bpd.getMinimum(getTableLM()).isAuto()) { + if (bpd.getMinimum(getTableLM()).getLength().getValue(getTableLM()) > 0) { + len = Math.max(len, bpd.getMinimum(getTableLM()).getLength().getValue(getTableLM())); } } - if (!bpd.getOptimum().isAuto()) { - if (bpd.getOptimum().getLength().getValue() > 0) { - len = Math.max(len, bpd.getOptimum().getLength().getValue()); + if (!bpd.getOptimum(getTableLM()).isAuto()) { + if (bpd.getOptimum(getTableLM()).getLength().getValue(getTableLM()) > 0) { + len = Math.max(len, bpd.getOptimum(getTableLM()).getLength().getValue(getTableLM())); } } if (gridUnits[i].getRow() != null) { bpd = gridUnits[i].getRow().getBlockProgressionDimension(); - if (!bpd.getMinimum().isAuto()) { - if (bpd.getMinimum().getLength().getValue() > 0) { - len = Math.max(len, bpd.getMinimum().getLength().getValue()); + if (!bpd.getMinimum(getTableLM()).isAuto()) { + if (bpd.getMinimum(getTableLM()).getLength().getValue(getTableLM()) > 0) { + len = Math.max(len, bpd.getMinimum(getTableLM()).getLength().getValue(getTableLM())); } } } } + // Add the padding if any + len += gridUnits[i].getBorders() + .getPaddingBefore(false, gridUnits[i].getCellLM()); + len += gridUnits[i].getBorders() + .getPaddingAfter(false, gridUnits[i].getCellLM()); + //Now add the borders to the contentLength if (isSeparateBorderModel()) { len += gridUnits[i].getBorders().getBorderBeforeWidth(false); len += gridUnits[i].getBorders().getBorderAfterWidth(false); } - len += gridUnits[i].getBorders().getPaddingBefore(false); - len += gridUnits[i].getBorders().getPaddingAfter(false); int startRow = Math.max(gridUnits[i].getStartRow(), firstRow[bt]); Integer storedOffset = (Integer)rowOffsets[bt].get(new Integer(startRow)); int effYOffset; @@ -906,7 +913,6 @@ public class TableContentLayoutManager { Block block = new Block(); block.addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE); block.setPositioning(Block.ABSOLUTE); - TraitSetter.addBackground(block, row.getCommonBorderPaddingBackground()); return block; } } @@ -927,6 +933,7 @@ public class TableContentLayoutManager { rowBackground.setXOffset(this.startXOffset); rowBackground.setYOffset(yoffset); getTableLM().addChildArea(rowBackground); + TraitSetter.addBackground(rowBackground, row.getCommonBorderPaddingBackground(), getTableLM()); } } @@ -1125,4 +1132,13 @@ public class TableContentLayoutManager { } } + // --------- Property Resolution related functions --------- // + + /** + * @see org.apache.fop.datatypes.PercentBaseContext#getBaseLength(int, fobj) + */ + public int getBaseLength(int lengthBase, FObj fobj) { + return tableLM.getBaseLength(lengthBase, fobj); + } + } diff --git a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java index ee3a5bdba..713d0179a 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java @@ -39,6 +39,8 @@ import org.apache.fop.traits.SpaceVal; import java.util.Iterator; import java.util.LinkedList; +import org.apache.fop.datatypes.LengthBase; +import org.apache.fop.fo.FObj; /** * LayoutManager for a table FO. @@ -58,13 +60,13 @@ public class TableLayoutManager extends BlockStackingLayoutManager private Block curBlockArea; private int referenceIPD; + private int referenceBPD; private boolean autoLayout = true; //TODO space-before|after: handle space-resolution rules private MinOptMax spaceBefore; private MinOptMax spaceAfter; - /** * Create a new table layout manager. * @param node the table FO @@ -73,7 +75,6 @@ public class TableLayoutManager extends BlockStackingLayoutManager super(node); fobj = node; this.columns = new ColumnSetup(node); - initialize(); } /** @return the table FO */ @@ -88,20 +89,20 @@ public class TableLayoutManager extends BlockStackingLayoutManager return this.columns; } - private void initialize() { - spaceBefore = new SpaceVal(fobj.getCommonMarginBlock().spaceBefore).getSpace(); - spaceAfter = new SpaceVal(fobj.getCommonMarginBlock().spaceAfter).getSpace(); + public void initialize() { + spaceBefore = new SpaceVal(fobj.getCommonMarginBlock().spaceBefore, this).getSpace(); + spaceAfter = new SpaceVal(fobj.getCommonMarginBlock().spaceAfter, this).getSpace(); if (!fobj.isAutoLayout() - && fobj.getInlineProgressionDimension().getOptimum().getEnum() != EN_AUTO) { + && fobj.getInlineProgressionDimension().getOptimum(this).getEnum() != EN_AUTO) { autoLayout = false; } } private int getIPIndents() { int iIndents = 0; - iIndents += fobj.getCommonMarginBlock().startIndent.getValue(); - iIndents += fobj.getCommonMarginBlock().endIndent.getValue(); + iIndents += fobj.getCommonMarginBlock().startIndent.getValue(this); + iIndents += fobj.getCommonMarginBlock().endIndent.getValue(this); return iIndents; } @@ -120,9 +121,11 @@ public class TableLayoutManager extends BlockStackingLayoutManager } } + referenceBPD = context.getStackLimit().opt; referenceIPD = context.getRefIPD(); - if (fobj.getInlineProgressionDimension().getOptimum().getEnum() != EN_AUTO) { - referenceIPD = fobj.getInlineProgressionDimension().getOptimum().getLength().getValue(); + + if (fobj.getInlineProgressionDimension().getOptimum(this).getEnum() != EN_AUTO) { + referenceIPD = fobj.getInlineProgressionDimension().getOptimum(this).getLength().getValue(this); } else if( !fobj.isAutoLayout() ) { log.info("table-layout=\"fixed\" and width=\"auto\", but auto-layout not supported " + "=> assuming width=\"100%\""); @@ -141,11 +144,6 @@ public class TableLayoutManager extends BlockStackingLayoutManager stackSize.add(spaceBefore); } - fobj.setLayoutDimension(PercentBase.BLOCK_IPD, referenceIPD); - fobj.setLayoutDimension(PercentBase.BLOCK_BPD, context.getStackLimit().opt); - fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_IPD, referenceIPD); - fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_BPD, context.getStackLimit().opt); - // either works out table of column widths or if proportional-column-width function // is used works out total factor, so that value of single unit can be computed. int sumCols = 0; @@ -153,7 +151,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager for (Iterator i = columns.iterator(); i.hasNext(); ) { TableColumn column = (TableColumn) i.next(); Length width = column.getColumnWidth(); - sumCols += width.getValue(); + sumCols += width.getValue(this); if (width instanceof TableColLength) { factors += ((TableColLength) width).getTableUnits(); } @@ -284,7 +282,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager addBlockSpacing(adjust, spaceBefore); spaceBefore = null; - int startXOffset = fobj.getCommonMarginBlock().startIndent.getValue(); + int startXOffset = fobj.getCommonMarginBlock().startIndent.getValue(this); // add column, body then row areas @@ -301,12 +299,15 @@ public class TableLayoutManager extends BlockStackingLayoutManager curBlockArea.setBPD(tableHeight); if (fobj.isSeparateBorderModel()) { - TraitSetter.addBorders(curBlockArea, fobj.getCommonBorderPaddingBackground()); + TraitSetter.addBorders(curBlockArea, fobj.getCommonBorderPaddingBackground(), this); } - TraitSetter.addBackground(curBlockArea, fobj.getCommonBorderPaddingBackground()); + TraitSetter.addBackground(curBlockArea, + fobj.getCommonBorderPaddingBackground(), + this); TraitSetter.addMargins(curBlockArea, fobj.getCommonBorderPaddingBackground(), - fobj.getCommonMarginBlock()); + fobj.getCommonMarginBlock(), + this); TraitSetter.addBreaks(curBlockArea, fobj.getBreakBefore(), fobj.getBreakAfter()); @@ -413,5 +414,41 @@ public class TableLayoutManager extends BlockStackingLayoutManager || !fobj.getKeepWithNext().getWithinColumn().isAuto(); } + // --------- Property Resolution related functions --------- // + + /** + * @see org.apache.fop.datatypes.PercentBaseContext#getBaseLength(int, FObj) + */ + public int getBaseLength(int lengthBase, FObj fobj) { + // Special handler for TableColumn width specifications + if (fobj instanceof TableColumn && fobj.getParent() == getFObj()) { + switch (lengthBase) { + case LengthBase.CONTAINING_BLOCK_WIDTH: + return getContentAreaIPD(); + default: + log.error("Unknown base type for LengthBase."); + return 0; + } + } else { + return super.getBaseLength(lengthBase, fobj); + } + } + + /** + * Returns the IPD of the content area + * @return the IPD of the content area + */ + public int getContentAreaIPD() { + return referenceIPD; + } + + /** + * Returns the BPD of the content area + * @return the BPD of the content area + */ + public int getContentAreaBPD() { + return referenceBPD; + } + } diff --git a/src/java/org/apache/fop/layoutmgr/table/TableStepper.java b/src/java/org/apache/fop/layoutmgr/table/TableStepper.java index 272afdf18..f7a381a3e 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableStepper.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableStepper.java @@ -202,8 +202,8 @@ public class TableStepper { } else { borderBefore[column] = pgu.getBorders().getBorderBeforeWidth(false) / 2; } - paddingBefore[column] = pgu.getBorders().getPaddingBefore(false); - paddingAfter[column] = pgu.getBorders().getPaddingAfter(false); + paddingBefore[column] = pgu.getBorders().getPaddingBefore(false, pgu.getCellLM()); + paddingAfter[column] = pgu.getBorders().getPaddingAfter(false, pgu.getCellLM()); start[column] = 0; end[column] = -1; widths[column] = 0; @@ -301,8 +301,8 @@ public class TableStepper { = getTableLM().getTable().getCommonBorderPaddingBackground(); effPenaltyLen += borders.getBorderBeforeWidth(false); effPenaltyLen += borders.getBorderAfterWidth(false); - effPenaltyLen += borders.getPaddingBefore(false); - effPenaltyLen += borders.getPaddingAfter(false); + effPenaltyLen += borders.getPaddingBefore(false, getTableLM()); + effPenaltyLen += borders.getPaddingAfter(false, getTableLM()); } TableContentPosition tcpos = new TableContentPosition(getTableLM(), gridUnitParts, getActiveRow()); |