From 8dd8bb7ab96f1063cc4c4b05fbee143084b557cb Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Tue, 22 Feb 2005 09:52:03 +0000 Subject: [PATCH] Individual grid unit block areas for painting the resolved borders. Bugfix in Row for searching the adjacent cell at end edge. Setting the borders that are already resolved on the right grid units. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198453 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/fop/layoutmgr/table/Cell.java | 29 ++++++++++++++++ .../org/apache/fop/layoutmgr/table/Row.java | 33 +++++++++++++------ 2 files changed, 52 insertions(+), 10 deletions(-) diff --git a/src/java/org/apache/fop/layoutmgr/table/Cell.java b/src/java/org/apache/fop/layoutmgr/table/Cell.java index f664f8b60..cd2c9a7ba 100644 --- a/src/java/org/apache/fop/layoutmgr/table/Cell.java +++ b/src/java/org/apache/fop/layoutmgr/table/Cell.java @@ -311,9 +311,38 @@ public class Cell extends BlockStackingLayoutManager { //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"); } } diff --git a/src/java/org/apache/fop/layoutmgr/table/Row.java b/src/java/org/apache/fop/layoutmgr/table/Row.java index 87ac870a2..29d1ce281 100644 --- a/src/java/org/apache/fop/layoutmgr/table/Row.java +++ b/src/java/org/apache/fop/layoutmgr/table/Row.java @@ -200,12 +200,13 @@ public class Row extends BlockStackingLayoutManager { //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) { @@ -216,6 +217,13 @@ public class Row extends BlockStackingLayoutManager { } 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()) { @@ -224,15 +232,20 @@ public class Row extends BlockStackingLayoutManager { 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 } @@ -412,21 +425,21 @@ public class Row extends BlockStackingLayoutManager { } /** - * 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)); } } -- 2.39.5