*
* @param row the first row of the table (in the header, or in the body if the
* table has no header)
+ * @param withNormal
* @param withLeadingTrailing
- * @param withNonLeadingTrailing
* @param withRest
*/
- void resolveBordersFirstRowInTable(List/*<GridUnit>*/ row, boolean withLeadingTrailing,
- boolean withNonLeadingTrailing, boolean withRest) {
+ void resolveBordersFirstRowInTable(List/*<GridUnit>*/ row, boolean withNormal,
+ boolean withLeadingTrailing, boolean withRest) {
assert firstInTable;
for (int i = 0; i < row.size(); i++) {
TableColumn column = table.getColumn(i);
((GridUnit) row.get(i)).integrateBorderSegment(
- CommonBorderPaddingBackground.BEFORE, column, withLeadingTrailing,
- withNonLeadingTrailing, withRest);
+ CommonBorderPaddingBackground.BEFORE, column, withNormal,
+ withLeadingTrailing, withRest);
}
firstInTable = false;
}
}
/** Integrates the border-after of the part. */
- void resolveBordersLastRowInPart(List/*<GridUnit>*/ row, boolean withLeadingTrailing,
- boolean withNonLeadingTrailing, boolean withRest) {
+ void resolveBordersLastRowInPart(List/*<GridUnit>*/ row, boolean withNormal,
+ boolean withLeadingTrailing, boolean withRest) {
for (int i = 0; i < row.size(); i++) {
((GridUnit) row.get(i)).integrateBorderSegment(CommonBorderPaddingBackground.AFTER,
- tablePart, withLeadingTrailing, withNonLeadingTrailing, withRest);
+ tablePart, withNormal, withLeadingTrailing, withRest);
}
}
*
* @param row the last row of the footer, or of the last body if the table has no
* footer
+ * @param withNormal
* @param withLeadingTrailing
- * @param withNonLeadingTrailing
* @param withRest
*/
- void resolveBordersLastRowInTable(List/*<GridUnit>*/ row, boolean withLeadingTrailing,
- boolean withNonLeadingTrailing, boolean withRest) {
+ void resolveBordersLastRowInTable(List/*<GridUnit>*/ row, boolean withNormal,
+ boolean withLeadingTrailing, boolean withRest) {
for (int i = 0; i < row.size(); i++) {
TableColumn column = table.getColumn(i);
((GridUnit) row.get(i)).integrateBorderSegment(CommonBorderPaddingBackground.AFTER,
- column, withLeadingTrailing, withNonLeadingTrailing, withRest);
+ column, withNormal, withLeadingTrailing, withRest);
}
}
GridUnit gu = (GridUnit) row.get(i);
ConditionalBorder border = (ConditionalBorder) leadingBorders.get(i);
gu.integrateCompetingBorder(CommonBorderPaddingBackground.BEFORE, border,
- true, false, true);
+ false, true, true);
}
}
GridUnit gu = (GridUnit) row.get(i);
ConditionalBorder border = (ConditionalBorder) trailingBorders.get(i);
gu.integrateCompetingBorder(CommonBorderPaddingBackground.AFTER, border,
- true, false, true);
+ false, true, true);
}
}
* The two only sensible values for border-before on the header's first row are:
* - at the beginning of the table (normal case)
* - if the header is repeated after each page break
- * To represent those values we (ab)use the nonLeadingTrailing and the rest
- * fields of ConditionalBorder. But strictly speaking this is not their
- * purposes.
+ * To represent those values we (ab)use the normal and the rest fields of
+ * ConditionalBorder. But strictly speaking this is not their purposes.
*/
for (Iterator guIter = row.iterator(); guIter.hasNext();) {
ConditionalBorder borderBefore = ((GridUnit) guIter.next()).borderBefore;
- borderBefore.leadingTrailing = borderBefore.nonLeadingTrailing;
- borderBefore.rest = borderBefore.nonLeadingTrailing;
+ borderBefore.leadingTrailing = borderBefore.normal;
+ borderBefore.rest = borderBefore.normal;
}
- resolveBordersFirstRowInTable(row, false, true, true);
+ resolveBordersFirstRowInTable(row, true, false, true);
}
previousRow = row;
}
* The border-after of a header is always the same. Leading and rest don't
* apply to cells in the header since they are never broken. To ease
* resolution we override the (normally unused) leadingTrailing and rest
- * fields of ConditionalBorder with the only sensible nonLeadingTrailing
- * field. That way grid units from the body will always resolve against the
- * same, normal header border.
+ * fields of ConditionalBorder with the only sensible normal field. That way
+ * grid units from the body will always resolve against the same, normal
+ * header border.
*/
for (Iterator guIter = previousRow.iterator(); guIter.hasNext();) {
ConditionalBorder borderAfter = ((GridUnit) guIter.next()).borderAfter;
- borderAfter.leadingTrailing = borderAfter.nonLeadingTrailing;
- borderAfter.rest = borderAfter.nonLeadingTrailing;
+ borderAfter.leadingTrailing = borderAfter.normal;
+ borderAfter.rest = borderAfter.normal;
leadingBorders.add(borderAfter);
}
/* TODO Temporary hack for resolved borders in header */
// See same method in ResolverInHeader for an explanation of the hack
for (Iterator guIter = footerFirstRow.iterator(); guIter.hasNext();) {
ConditionalBorder borderBefore = ((GridUnit) guIter.next()).borderBefore;
- borderBefore.leadingTrailing = borderBefore.nonLeadingTrailing;
- borderBefore.rest = borderBefore.nonLeadingTrailing;
+ borderBefore.leadingTrailing = borderBefore.normal;
+ borderBefore.rest = borderBefore.normal;
trailingBorders.add(borderBefore);
}
}
// See endRow method in ResolverInHeader for an explanation of the hack
for (Iterator guIter = footerLastRow.iterator(); guIter.hasNext();) {
ConditionalBorder borderAfter = ((GridUnit) guIter.next()).borderAfter;
- borderAfter.leadingTrailing = borderAfter.nonLeadingTrailing;
- borderAfter.rest = borderAfter.nonLeadingTrailing;
+ borderAfter.leadingTrailing = borderAfter.normal;
+ borderAfter.rest = borderAfter.normal;
}
- resolveBordersLastRowInTable(footerLastRow, false, true, true);
+ resolveBordersLastRowInTable(footerLastRow, true, false, true);
}
}
firstInBody = false;
for (Iterator iter = row.iterator(); iter.hasNext();) {
GridUnit gu = (GridUnit) iter.next();
- gu.borderBefore.leadingTrailing = gu.borderBefore.nonLeadingTrailing;
+ gu.borderBefore.leadingTrailing = gu.borderBefore.normal;
}
}
}
resolverInFooter.endTable();
} else {
// Trailing and rest borders already resolved with integrateTrailingBorders
- resolveBordersLastRowInTable(previousRow, false, true, false);
+ resolveBordersLastRowInTable(previousRow, true, false, false);
}
for (Iterator iter = previousRow.iterator(); iter.hasNext();) {
GridUnit gu = (GridUnit) iter.next();
- gu.borderAfter.leadingTrailing = gu.borderAfter.nonLeadingTrailing;
+ gu.borderAfter.leadingTrailing = gu.borderAfter.normal;
}
}
}
if (headerLastRow != null) {
for (Iterator iter = headerLastRow.iterator(); iter.hasNext();) {
GridUnit gu = (GridUnit) iter.next();
- gu.borderAfter.leadingTrailing = gu.borderAfter.nonLeadingTrailing;
+ gu.borderAfter.leadingTrailing = gu.borderAfter.normal;
}
}
if (footerLastRow != null) {
for (Iterator iter = footerLastRow.iterator(); iter.hasNext();) {
GridUnit gu = (GridUnit) iter.next();
- gu.borderAfter.leadingTrailing = gu.borderAfter.nonLeadingTrailing;
+ gu.borderAfter.leadingTrailing = gu.borderAfter.normal;
}
}
/* End of temporary hack */
* in the collapsing model. These three values are (for border-before, similar for
* border-after):
* <ul>
- * <li>non-leading: common case, when a cell follows the cell before on a same page;</li>
+ * <li>normal: common case, when a cell follows the cell before on a same page;</li>
* <li>leading: when the table is broken and the cell appears at the top of a page, in
* which case its border must be resolved with the header (or the top of the table)
* instead of with the previous cell;</li>
public static final int REST = 2;
+ /** Normal case, no break. */
+ BorderSpecification normal;
+
/** Special case: the cell is at the top or the bottom of the page. */
BorderSpecification leadingTrailing;
- /** Normal case, no break. */
- BorderSpecification nonLeadingTrailing;
-
/** Special case: break inside the cell. */
BorderSpecification rest;
/** The model used to resolve borders. */
private CollapsingBorderModel collapsingBorderModel;
- private ConditionalBorder(BorderSpecification leadingTrailing,
- BorderSpecification nonLeadingTrailing, BorderSpecification rest,
+ private ConditionalBorder(BorderSpecification normal,
+ BorderSpecification leadingTrailing, BorderSpecification rest,
CollapsingBorderModel collapsingBorderModel) {
+ this.normal = normal;
this.leadingTrailing = leadingTrailing;
- this.nonLeadingTrailing = nonLeadingTrailing;
this.rest = rest;
this.collapsingBorderModel = collapsingBorderModel;
}
*/
ConditionalBorder(BorderSpecification borderSpecification,
CollapsingBorderModel collapsingBorderModel) {
- leadingTrailing = borderSpecification;
- nonLeadingTrailing = leadingTrailing;
+ normal = borderSpecification;
+ leadingTrailing = normal;
if (borderSpecification.getBorderInfo().getWidth().isDiscard()) {
rest = BorderSpecification.getDefaultBorder();
} else {
* Resolves and updates the relevant parts of this border as well as the given one.
*
* @param competitor
+ * @param withNormal
* @param withLeadingTrailing
- * @param withNonLeadingTrailing
* @param withRest
*/
- void resolve(ConditionalBorder competitor, boolean withLeadingTrailing,
- boolean withNonLeadingTrailing, boolean withRest) {
- if (withLeadingTrailing) {
+ void resolve(ConditionalBorder competitor, boolean withNormal,
+ boolean withLeadingTrailing, boolean withRest) {
+ if (withNormal) {
BorderSpecification resolvedBorder = collapsingBorderModel.determineWinner(
- leadingTrailing, competitor.leadingTrailing);
+ normal, competitor.normal);
if (resolvedBorder != null) {
- leadingTrailing = resolvedBorder;
- competitor.leadingTrailing = resolvedBorder;
+ normal = resolvedBorder;
+ competitor.normal = resolvedBorder;
}
}
- if (withNonLeadingTrailing) {
+ if (withLeadingTrailing) {
BorderSpecification resolvedBorder = collapsingBorderModel.determineWinner(
- nonLeadingTrailing, competitor.nonLeadingTrailing);
+ leadingTrailing, competitor.leadingTrailing);
if (resolvedBorder != null) {
- nonLeadingTrailing = resolvedBorder;
- competitor.nonLeadingTrailing = resolvedBorder;
+ leadingTrailing = resolvedBorder;
+ competitor.leadingTrailing = resolvedBorder;
}
}
if (withRest) {
* keeping the components to their old values.
*
* @param competitor
+ * @param withNormal
* @param withLeadingTrailing
- * @param withNonLeadingTrailing
* @param withRest
*/
- void integrateCompetingSegment(ConditionalBorder competitor, boolean withLeadingTrailing,
- boolean withNonLeadingTrailing, boolean withRest) {
- if (withLeadingTrailing) {
+ void integrateCompetingSegment(ConditionalBorder competitor, boolean withNormal,
+ boolean withLeadingTrailing, boolean withRest) {
+ if (withNormal) {
BorderSpecification resolvedBorder = collapsingBorderModel.determineWinner(
- leadingTrailing, competitor.leadingTrailing);
+ normal, competitor.normal);
if (resolvedBorder != null) {
- leadingTrailing = resolvedBorder;
+ normal = resolvedBorder;
}
}
- if (withNonLeadingTrailing) {
+ if (withLeadingTrailing) {
BorderSpecification resolvedBorder = collapsingBorderModel.determineWinner(
- nonLeadingTrailing, competitor.nonLeadingTrailing);
+ leadingTrailing, competitor.leadingTrailing);
if (resolvedBorder != null) {
- nonLeadingTrailing = resolvedBorder;
+ leadingTrailing = resolvedBorder;
}
}
if (withRest) {
* CollapsingBorderModel is not expected to return null.
*
* @param segment
+ * @param withNormal
* @param withLeadingTrailing
- * @param withNonLeadingTrailing
* @param withRest
*/
- void integrateSegment(ConditionalBorder segment, boolean withLeadingTrailing,
- boolean withNonLeadingTrailing, boolean withRest) {
+ void integrateSegment(ConditionalBorder segment, boolean withNormal,
+ boolean withLeadingTrailing, boolean withRest) {
+ if (withNormal) {
+ normal = collapsingBorderModel.determineWinner(normal, segment.normal);
+ assert normal != null;
+ }
if (withLeadingTrailing) {
leadingTrailing = collapsingBorderModel.determineWinner(leadingTrailing,
segment.leadingTrailing);
assert leadingTrailing != null;
}
- if (withNonLeadingTrailing) {
- nonLeadingTrailing = collapsingBorderModel.determineWinner(nonLeadingTrailing,
- segment.nonLeadingTrailing);
- assert nonLeadingTrailing != null;
- }
if (withRest) {
rest = collapsingBorderModel.determineWinner(rest, segment.rest);
assert rest != null;
* @return a copy of this border
*/
ConditionalBorder copy() {
- return new ConditionalBorder(leadingTrailing, nonLeadingTrailing, rest,
- collapsingBorderModel);
+ return new ConditionalBorder(normal, leadingTrailing, rest, collapsingBorderModel);
}
/** {@inheritDoc} */
public String toString() {
- return "{non-leading: " + nonLeadingTrailing + ", leading: " + leadingTrailing + ", rest: "
- + rest + "}";
+ return "{normal: " + normal + ", leading: " + leadingTrailing + ", rest: " + rest + "}";
}
/**
protected void setBordersFromCell() {
borderBefore = cell.borderBefore.copy();
if (rowSpanIndex > 0) {
- borderBefore.nonLeadingTrailing = BorderSpecification.getDefaultBorder();
+ borderBefore.normal = BorderSpecification.getDefaultBorder();
}
borderAfter = cell.borderAfter.copy();
if (!isLastGridUnitRowSpan()) {
- borderAfter.nonLeadingTrailing = BorderSpecification.getDefaultBorder();
+ borderAfter.normal = BorderSpecification.getDefaultBorder();
}
if (colSpanIndex == 0) {
borderStart = cell.borderStart;
public BorderInfo getBorderBefore(int which) {
switch (which) {
case ConditionalBorder.NORMAL:
- return borderBefore.nonLeadingTrailing.getBorderInfo();
+ return borderBefore.normal.getBorderInfo();
case ConditionalBorder.LEADING_TRAILING:
return borderBefore.leadingTrailing.getBorderInfo();
case ConditionalBorder.REST:
public BorderInfo getBorderAfter(int which) {
switch (which) {
case ConditionalBorder.NORMAL:
- return borderAfter.nonLeadingTrailing.getBorderInfo();
+ return borderAfter.normal.getBorderInfo();
case ConditionalBorder.LEADING_TRAILING:
return borderAfter.leadingTrailing.getBorderInfo();
case ConditionalBorder.REST:
void resolveBorder(GridUnit other, int side) {
switch (side) {
case CommonBorderPaddingBackground.BEFORE:
- borderBefore.resolve(other.borderAfter, false, true, false);
+ borderBefore.resolve(other.borderAfter, true, false, false);
break;
case CommonBorderPaddingBackground.AFTER:
- borderAfter.resolve(other.borderBefore, false, true, false);
+ borderAfter.resolve(other.borderBefore, true, false, false);
break;
case CommonBorderPaddingBackground.START:
BorderSpecification resolvedBorder = collapsingBorderModel.determineWinner(
* @param parent a table element whose corresponding border coincides on the given
* side
*/
- void integrateBorderSegment(int side, TableFObj parent, boolean withLeadingTrailing,
- boolean withNonLeadingTrailing, boolean withRest) {
+ void integrateBorderSegment(int side, TableFObj parent, boolean withNormal,
+ boolean withLeadingTrailing, boolean withRest) {
switch (side) {
case CommonBorderPaddingBackground.BEFORE:
- borderBefore.integrateSegment(parent.borderBefore, withLeadingTrailing,
- withNonLeadingTrailing, withRest);
+ borderBefore.integrateSegment(parent.borderBefore, withNormal,
+ withLeadingTrailing, withRest);
break;
case CommonBorderPaddingBackground.AFTER:
- borderAfter.integrateSegment(parent.borderAfter, withLeadingTrailing,
- withNonLeadingTrailing, withRest);
+ borderAfter.integrateSegment(parent.borderAfter, withNormal,
+ withLeadingTrailing, withRest);
break;
default: assert false;
}
}
void integrateCompetingBorder(int side, ConditionalBorder competitor,
- boolean withLeadingTrailing, boolean withNonLeadingTrailing, boolean withRest) {
+ boolean withNormal, boolean withLeadingTrailing, boolean withRest) {
switch (side) {
case CommonBorderPaddingBackground.BEFORE:
- borderBefore.integrateCompetingSegment(competitor, withLeadingTrailing,
- withNonLeadingTrailing, withRest);
+ borderBefore.integrateCompetingSegment(competitor, withNormal,
+ withLeadingTrailing, withRest);
break;
case CommonBorderPaddingBackground.AFTER:
- borderAfter.integrateCompetingSegment(competitor, withLeadingTrailing,
- withNonLeadingTrailing, withRest);
+ borderAfter.integrateCompetingSegment(competitor, withNormal,
+ withLeadingTrailing, withRest);
break;
default: assert false;
}
GridUnit gu = getGridUnit(body);
String errorMsge = baseErrorMsge + "border-before";
- checkBorder(errorMsge, gu.borderBefore.nonLeadingTrailing, 8000, Color.black);
+ checkBorder(errorMsge, gu.borderBefore.normal, 8000, Color.black);
checkBorder(errorMsge, gu.borderBefore.leadingTrailing, 8000, Color.black);
checkBorder(errorMsge, gu.borderBefore.rest, resolvedBorders[tableNum][0]);
errorMsge = baseErrorMsge + "border-after";
- checkBorder(errorMsge, gu.borderAfter.nonLeadingTrailing, 8000, Color.black);
+ checkBorder(errorMsge, gu.borderAfter.normal, 8000, Color.black);
checkBorder(errorMsge, gu.borderAfter.leadingTrailing, 8000, Color.black);
checkBorder(errorMsge, gu.borderAfter.rest, resolvedBorders[tableNum][1]);
TableBody header = table.getTableHeader();
GridUnit gu = getGridUnit(header);
- checkBorder(errorMsge, gu.borderBefore.nonLeadingTrailing,
+ checkBorder(errorMsge, gu.borderBefore.normal,
resolvedBordersHF[tableNum][borderNum++]);
checkBorder(errorMsge, gu.borderBefore.rest,
resolvedBordersHF[tableNum][borderNum++]);
TableBody footer = table.getTableFooter();
gu = getGridUnit(footer);
- checkBorder(errorMsge, gu.borderAfter.nonLeadingTrailing,
+ checkBorder(errorMsge, gu.borderAfter.normal,
resolvedBordersHF[tableNum][borderNum++]);
checkBorder(errorMsge, gu.borderAfter.rest,
resolvedBordersHF[tableNum][borderNum++]);
FONodeIterator bodyIter = table.getChildNodes();
TableBody body = (TableBody) bodyIter.nextNode();
gu = getGridUnit(body);
- checkBorder(errorMsge, gu.borderBefore.nonLeadingTrailing,
+ checkBorder(errorMsge, gu.borderBefore.normal,
resolvedBordersHF[tableNum][borderNum++]);
checkBorder(errorMsge, gu.borderBefore.leadingTrailing,
resolvedBordersHF[tableNum][borderNum++]);
checkBorder(errorMsge, gu.borderBefore.rest,
resolvedBordersHF[tableNum][borderNum++]);
- checkBorder(errorMsge, gu.borderAfter.nonLeadingTrailing,
+ checkBorder(errorMsge, gu.borderAfter.normal,
resolvedBordersHF[tableNum][borderNum++]);
checkBorder(errorMsge, gu.borderAfter.leadingTrailing,
resolvedBordersHF[tableNum][borderNum++]);
body = (TableBody) bodyIter.nextNode();
gu = getGridUnit(body);
- checkBorder(errorMsge, gu.borderBefore.nonLeadingTrailing,
+ checkBorder(errorMsge, gu.borderBefore.normal,
resolvedBordersHF[tableNum][borderNum++]);
checkBorder(errorMsge, gu.borderBefore.leadingTrailing,
resolvedBordersHF[tableNum][borderNum++]);
checkBorder(errorMsge, gu.borderBefore.rest,
resolvedBordersHF[tableNum][borderNum++]);
- checkBorder(errorMsge, gu.borderAfter.nonLeadingTrailing,
+ checkBorder(errorMsge, gu.borderAfter.normal,
resolvedBordersHF[tableNum][borderNum++]);
checkBorder(errorMsge, gu.borderAfter.leadingTrailing,
resolvedBordersHF[tableNum][borderNum++]);