aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/fo
diff options
context:
space:
mode:
authorVincent Hennebert <vhennebert@apache.org>2008-05-12 19:37:39 +0000
committerVincent Hennebert <vhennebert@apache.org>2008-05-12 19:37:39 +0000
commitfd57079cbeda429803cff6cf2b8142146f5fef45 (patch)
tree3117e8768667df3555b1a2715ab45e9bf653ae54 /src/java/org/apache/fop/fo
parentb5179656de4cddd63571053d26e4161c8af14725 (diff)
downloadxmlgraphics-fop-fd57079cbeda429803cff6cf2b8142146f5fef45.tar.gz
xmlgraphics-fop-fd57079cbeda429803cff6cf2b8142146f5fef45.zip
Put the resolutions of collapsed borders together into the CollapsingBorderResolver class.
The previous scheme allowed for early resolution of borders where possible, but made it hard to understand since the resolution was spread in the various table classes. Now everything is done inside a single class git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@655614 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/fo')
-rw-r--r--src/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.java43
-rw-r--r--src/java/org/apache/fop/fo/flow/table/GridUnit.java18
-rw-r--r--src/java/org/apache/fop/fo/flow/table/Table.java10
-rw-r--r--src/java/org/apache/fop/fo/flow/table/TableBody.java9
-rw-r--r--src/java/org/apache/fop/fo/flow/table/TableCell.java8
-rw-r--r--src/java/org/apache/fop/fo/flow/table/TableColumn.java9
-rw-r--r--src/java/org/apache/fop/fo/flow/table/TableFObj.java38
-rw-r--r--src/java/org/apache/fop/fo/flow/table/TableRow.java9
8 files changed, 63 insertions, 81 deletions
diff --git a/src/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.java b/src/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.java
index 86bf40f2f..2d48380ee 100644
--- a/src/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.java
+++ b/src/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.java
@@ -24,6 +24,7 @@ import java.util.Iterator;
import java.util.List;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
+import org.apache.fop.layoutmgr.table.CollapsingBorderModel;
/**
* A class that implements the border-collapsing model.
@@ -32,6 +33,8 @@ class CollapsingBorderResolver implements BorderResolver {
private Table table;
+ private CollapsingBorderModel collapsingBorderModel;
+
/**
* The previously registered row, either in the header or the body(-ies), but not in
* the footer (handled separately).
@@ -74,6 +77,9 @@ class CollapsingBorderResolver implements BorderResolver {
protected boolean firstInPart;
+ private BorderSpecification borderStartTableAndBody;
+ private BorderSpecification borderEndTableAndBody;
+
/**
* Integrates border-before specified on the table and its column.
*
@@ -174,6 +180,10 @@ class CollapsingBorderResolver implements BorderResolver {
void startPart(TableBody part) {
tablePart = part;
firstInPart = true;
+ borderStartTableAndBody = collapsingBorderModel.determineWinner(table.borderStart,
+ tablePart.borderStart);
+ borderEndTableAndBody = collapsingBorderModel.determineWinner(table.borderEnd,
+ tablePart.borderEnd);
}
/**
@@ -188,6 +198,8 @@ class CollapsingBorderResolver implements BorderResolver {
* @param container the containing element
*/
void endRow(List/*<GridUnit>*/ row, TableCellContainer container) {
+ BorderSpecification borderStart = borderStartTableAndBody;
+ BorderSpecification borderEnd = borderEndTableAndBody;
// Resolve before- and after-borders for the table-row
if (container instanceof TableRow) {
TableRow tableRow = (TableRow) container;
@@ -200,6 +212,10 @@ class CollapsingBorderResolver implements BorderResolver {
gu.integrateBorderSegment(CommonBorderPaddingBackground.AFTER, tableRow,
last, last, true);
}
+ borderStart = collapsingBorderModel.determineWinner(borderStart,
+ tableRow.borderStart);
+ borderEnd = collapsingBorderModel.determineWinner(borderEnd,
+ tableRow.borderEnd);
}
if (firstInPart) {
// Integrate the border-before of the part
@@ -215,7 +231,7 @@ class CollapsingBorderResolver implements BorderResolver {
Iterator colIter = table.getColumns().iterator();
TableColumn col = (TableColumn) colIter.next();
gu.integrateBorderSegment(CommonBorderPaddingBackground.START, col);
- gu.integrateBorderSegment(CommonBorderPaddingBackground.START, container);
+ gu.integrateBorderSegment(CommonBorderPaddingBackground.START, borderStart);
while (guIter.hasNext()) {
GridUnit nextGU = (GridUnit) guIter.next();
TableColumn nextCol = (TableColumn) colIter.next();
@@ -228,7 +244,7 @@ class CollapsingBorderResolver implements BorderResolver {
col = nextCol;
}
gu.integrateBorderSegment(CommonBorderPaddingBackground.END, col);
- gu.integrateBorderSegment(CommonBorderPaddingBackground.END, container);
+ gu.integrateBorderSegment(CommonBorderPaddingBackground.END, borderEnd);
}
void endPart() {
@@ -371,7 +387,26 @@ class CollapsingBorderResolver implements BorderResolver {
CollapsingBorderResolver(Table table) {
this.table = table;
+ collapsingBorderModel = CollapsingBorderModel.getBorderModelFor(table.getBorderCollapse());
firstInTable = true;
+ // Resolve before and after borders between the table and each table-column
+ int index = 0;
+ do {
+ TableColumn col = table.getColumn(index);
+ // See endRow method in ResolverInHeader for an explanation of the hack
+ col.borderBefore.integrateSegment(table.borderBefore, true, false, true);
+ col.borderBefore.leadingTrailing = col.borderBefore.rest;
+ col.borderAfter.integrateSegment(table.borderAfter, true, false, true);
+ col.borderAfter.leadingTrailing = col.borderAfter.rest;
+ /*
+ * TODO The border resolution must be done only once for each table column,
+ * even if it's repeated; otherwise, re-resolving against the table's borders
+ * will lead to null border specifications.
+ *
+ * Eventually table columns should probably be cloned instead.
+ */
+ index += col.getNumberColumnsRepeated();
+ } while (index < table.getNumberOfColumns());
}
/** {@inheritDoc} */
@@ -388,9 +423,7 @@ class CollapsingBorderResolver implements BorderResolver {
// No header, leading borders determined by the table
leadingBorders = new ArrayList(table.getNumberOfColumns());
for (Iterator colIter = table.getColumns().iterator(); colIter.hasNext();) {
- // See endRow method in ResolverInHeader for an explanation of the hack
ConditionalBorder border = ((TableColumn) colIter.next()).borderBefore;
- border.leadingTrailing = border.rest;
leadingBorders.add(border);
}
}
@@ -402,9 +435,7 @@ class CollapsingBorderResolver implements BorderResolver {
// No footer, trailing borders determined by the table
trailingBorders = new ArrayList(table.getNumberOfColumns());
for (Iterator colIter = table.getColumns().iterator(); colIter.hasNext();) {
- // See endRow method in ResolverInHeader for an explanation of the hack
ConditionalBorder border = ((TableColumn) colIter.next()).borderAfter;
- border.leadingTrailing = border.rest;
trailingBorders.add(border);
}
}
diff --git a/src/java/org/apache/fop/fo/flow/table/GridUnit.java b/src/java/org/apache/fop/fo/flow/table/GridUnit.java
index ec84dd200..3d48a6836 100644
--- a/src/java/org/apache/fop/fo/flow/table/GridUnit.java
+++ b/src/java/org/apache/fop/fo/flow/table/GridUnit.java
@@ -374,6 +374,24 @@ public class GridUnit {
}
}
+ /**
+ * For the given side, integrates in the conflict resolution the given border segment.
+ *
+ * @param side the side to consider (one of CommonBorderPaddingBackground.START|END)
+ * @param segment a border specification to integrate at the given side
+ */
+ void integrateBorderSegment(int side, BorderSpecification segment) {
+ switch(side) {
+ case CommonBorderPaddingBackground.START:
+ borderStart = collapsingBorderModel.determineWinner(borderStart, segment);
+ break;
+ case CommonBorderPaddingBackground.END:
+ borderEnd = collapsingBorderModel.determineWinner(borderEnd, segment);
+ break;
+ default: assert false;
+ }
+ }
+
void integrateCompetingBorder(int side, ConditionalBorder competitor,
boolean withNormal, boolean withLeadingTrailing, boolean withRest) {
switch (side) {
diff --git a/src/java/org/apache/fop/fo/flow/table/Table.java b/src/java/org/apache/fop/fo/flow/table/Table.java
index 69d5fbb9d..5b96a668e 100644
--- a/src/java/org/apache/fop/fo/flow/table/Table.java
+++ b/src/java/org/apache/fop/fo/flow/table/Table.java
@@ -265,7 +265,7 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder {
case FO_TABLE_HEADER:
case FO_TABLE_FOOTER:
case FO_TABLE_BODY:
- if (!columnsFinalized) {
+ if (!inMarker() && !columnsFinalized) {
columnsFinalized = true;
if (hasExplicitColumns) {
finalizeColumns();
@@ -291,14 +291,6 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder {
}
}
- /** {@inheritDoc} */
- protected void setCollapsedBorders() {
- createBorder(CommonBorderPaddingBackground.START);
- createBorder(CommonBorderPaddingBackground.END);
- createBorder(CommonBorderPaddingBackground.BEFORE);
- createBorder(CommonBorderPaddingBackground.AFTER);
- }
-
private void finalizeColumns() throws FOPException {
for (int i = 0; i < columns.size(); i++) {
if (columns.get(i) == null) {
diff --git a/src/java/org/apache/fop/fo/flow/table/TableBody.java b/src/java/org/apache/fop/fo/flow/table/TableBody.java
index 0214e7336..b4e48d2e6 100644
--- a/src/java/org/apache/fop/fo/flow/table/TableBody.java
+++ b/src/java/org/apache/fop/fo/flow/table/TableBody.java
@@ -211,15 +211,6 @@ public class TableBody extends TableCellContainer {
super.addChildNode(child);
}
- /** {inheritDoc} */
- protected void setCollapsedBorders() {
- Table table = (Table) parent;
- createBorder(CommonBorderPaddingBackground.START, table);
- createBorder(CommonBorderPaddingBackground.END, table);
- createBorder(CommonBorderPaddingBackground.BEFORE);
- createBorder(CommonBorderPaddingBackground.AFTER);
- }
-
void addRowGroup(List rowGroup) {
rowGroups.add(rowGroup);
}
diff --git a/src/java/org/apache/fop/fo/flow/table/TableCell.java b/src/java/org/apache/fop/fo/flow/table/TableCell.java
index b1dfd86c3..2781bf082 100644
--- a/src/java/org/apache/fop/fo/flow/table/TableCell.java
+++ b/src/java/org/apache/fop/fo/flow/table/TableCell.java
@@ -134,14 +134,6 @@ public class TableCell extends TableFObj {
}
/** {@inheritDoc} */
- protected void setCollapsedBorders() {
- createBorder(CommonBorderPaddingBackground.BEFORE);
- createBorder(CommonBorderPaddingBackground.AFTER);
- createBorder(CommonBorderPaddingBackground.START);
- createBorder(CommonBorderPaddingBackground.END);
- }
-
- /** {@inheritDoc} */
public boolean generatesReferenceAreas() {
return true;
}
diff --git a/src/java/org/apache/fop/fo/flow/table/TableColumn.java b/src/java/org/apache/fop/fo/flow/table/TableColumn.java
index 0ace2c311..6916e090b 100644
--- a/src/java/org/apache/fop/fo/flow/table/TableColumn.java
+++ b/src/java/org/apache/fop/fo/flow/table/TableColumn.java
@@ -134,15 +134,6 @@ public class TableColumn extends TableFObj {
}
/** {@inheritDoc} */
- protected void setCollapsedBorders() {
- Table table = (Table) parent;
- createBorder(CommonBorderPaddingBackground.BEFORE, table);
- createBorder(CommonBorderPaddingBackground.AFTER, table);
- createBorder(CommonBorderPaddingBackground.START);
- createBorder(CommonBorderPaddingBackground.END);
- }
-
- /** {@inheritDoc} */
public void endOfNode() throws FOPException {
getFOEventHandler().endColumn(this);
}
diff --git a/src/java/org/apache/fop/fo/flow/table/TableFObj.java b/src/java/org/apache/fop/fo/flow/table/TableFObj.java
index adeb2eadd..6bc113fd0 100644
--- a/src/java/org/apache/fop/fo/flow/table/TableFObj.java
+++ b/src/java/org/apache/fop/fo/flow/table/TableFObj.java
@@ -226,7 +226,12 @@ public abstract class TableFObj extends FObj {
* Prepares the borders of this element if the collapsing-border model is in use.
* Conflict resolution with parent elements is done where applicable.
*/
- protected abstract void setCollapsedBorders();
+ protected void setCollapsedBorders() {
+ createBorder(CommonBorderPaddingBackground.START);
+ createBorder(CommonBorderPaddingBackground.END);
+ createBorder(CommonBorderPaddingBackground.BEFORE);
+ createBorder(CommonBorderPaddingBackground.AFTER);
+ }
/**
* Creates a BorderSpecification from the border set on the given side. If no border
@@ -234,7 +239,7 @@ public abstract class TableFObj extends FObj {
*
* @param side one of CommonBorderPaddingBackground.BEFORE|AFTER|START|END
*/
- protected void createBorder(int side) {
+ private void createBorder(int side) {
BorderSpecification borderSpec = new BorderSpecification(
getCommonBorderPaddingBackground().getBorderInfo(side), getNameId());
switch (side) {
@@ -253,33 +258,4 @@ public abstract class TableFObj extends FObj {
default: assert false;
}
}
-
- /**
- * Creates a BorderSpecification from the border set on the given side, performing
- * conflict resolution with the same border on the given object.
- *
- * @param side one of CommonBorderPaddingBackground.BEFORE|AFTER|START|END
- * @param competitor a parent table element whose side coincides with the given side
- * on this element
- */
- protected void createBorder(int side, TableFObj competitor) {
- createBorder(side);
- switch (side) {
- case CommonBorderPaddingBackground.BEFORE:
- borderBefore.integrateSegment(competitor.borderBefore, true, true, true);
- break;
- case CommonBorderPaddingBackground.AFTER:
- borderAfter.integrateSegment(competitor.borderAfter, true, true, true);
- break;
- case CommonBorderPaddingBackground.START:
- borderStart = collapsingBorderModel.determineWinner(borderStart,
- competitor.borderStart);
- break;
- case CommonBorderPaddingBackground.END:
- borderEnd = collapsingBorderModel.determineWinner(borderEnd,
- competitor.borderEnd);
- break;
- default: assert false;
- }
- }
}
diff --git a/src/java/org/apache/fop/fo/flow/table/TableRow.java b/src/java/org/apache/fop/fo/flow/table/TableRow.java
index bf7b16dca..3be794fbd 100644
--- a/src/java/org/apache/fop/fo/flow/table/TableRow.java
+++ b/src/java/org/apache/fop/fo/flow/table/TableRow.java
@@ -138,15 +138,6 @@ public class TableRow extends TableCellContainer {
return true;
}
- /** {@inheritDoc} */
- protected void setCollapsedBorders() {
- TableBody body = (TableBody) parent;
- createBorder(CommonBorderPaddingBackground.START, body);
- createBorder(CommonBorderPaddingBackground.END, body);
- createBorder(CommonBorderPaddingBackground.BEFORE);
- createBorder(CommonBorderPaddingBackground.AFTER);
- }
-
/** @return the "break-after" property. */
public int getBreakAfter() {
return breakAfter;