From e986da96554abe0275ecaf80abbaddad7506df42 Mon Sep 17 00:00:00 2001
From: Vincent Hennebert
Date: Thu, 13 Dec 2007 11:35:17 +0000
Subject: Fixed @throws statements in javadoc
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@603890 13f79535-47bb-0310-9956-ffa450edef68
---
.../apache/fop/render/afp/modca/AbstractStructuredAFPObject.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
(limited to 'src')
diff --git a/src/java/org/apache/fop/render/afp/modca/AbstractStructuredAFPObject.java b/src/java/org/apache/fop/render/afp/modca/AbstractStructuredAFPObject.java
index bc2bf9f99..f9348b81c 100644
--- a/src/java/org/apache/fop/render/afp/modca/AbstractStructuredAFPObject.java
+++ b/src/java/org/apache/fop/render/afp/modca/AbstractStructuredAFPObject.java
@@ -45,7 +45,7 @@ public abstract class AbstractStructuredAFPObject extends AbstractNamedAFPObject
/**
* Helper method to write the start of the Object.
* @param os The stream to write to
- * @throws an I/O exception if one occurred
+ * @throws IOException an I/O exception if one occurred
*/
protected void writeStart(OutputStream os) throws IOException {
}
@@ -53,7 +53,7 @@ public abstract class AbstractStructuredAFPObject extends AbstractNamedAFPObject
/**
* Helper method to write the contents of the Object.
* @param os The stream to write to
- * @throws an I/O exception if one occurred
+ * @throws IOException an I/O exception if one occurred
*/
protected void writeContent(OutputStream os) throws IOException {
}
@@ -61,7 +61,7 @@ public abstract class AbstractStructuredAFPObject extends AbstractNamedAFPObject
/**
* Helper method to write the end of the Object.
* @param os The stream to write to
- * @throws an I/O exception if one occurred
+ * @throws IOException an I/O exception if one occurred
*/
protected void writeEnd(OutputStream os) throws IOException {
}
@@ -69,7 +69,7 @@ public abstract class AbstractStructuredAFPObject extends AbstractNamedAFPObject
/**
* Accessor method to write the AFP datastream for the Image Object
* @param os The stream to write to
- * @throws java.io.IOException in the event that an I/O exception occurred
+ * @throws IOException in the event that an I/O exception occurred
*/
public void writeDataStream(OutputStream os)
throws IOException {
--
cgit v1.2.3
From 26b5548ee2bec051c2cc18bccbda31b86edfa560 Mon Sep 17 00:00:00 2001
From: "Andreas L. Delmelle"
Date: Thu, 13 Dec 2007 14:43:08 +0000
Subject: Minor tweaks: * only add text to a fo:wrapper if it is not a direct
flow-descendant * error if an fo:wrapper that is a direct flow-descendant
contains inline-level children
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@603926 13f79535-47bb-0310-9956-ffa450edef68
---
src/java/org/apache/fop/fo/flow/Wrapper.java | 37 ++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
(limited to 'src')
diff --git a/src/java/org/apache/fop/fo/flow/Wrapper.java b/src/java/org/apache/fop/fo/flow/Wrapper.java
index c7ca33a10..8b833f6b7 100644
--- a/src/java/org/apache/fop/fo/flow/Wrapper.java
+++ b/src/java/org/apache/fop/fo/flow/Wrapper.java
@@ -19,9 +19,12 @@
package org.apache.fop.fo.flow;
+import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObjMixed;
+import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.ValidationException;
+import org.apache.fop.fo.pagination.Flow;
import org.xml.sax.Locator;
/**
@@ -35,12 +38,24 @@ public class Wrapper extends FObjMixed {
// used for FO validation
private boolean blockOrInlineItemFound = false;
+ private boolean isFlowChild = false;
/**
* @param parent FONode that is the parent of this object
*/
public Wrapper(FONode parent) {
super(parent);
+ /* Check if the fo:wrapper is a child of an fo:flow or fo:static-content
+ * (or a descendant in nested fo:wrapper sequence, the first of which
+ * is a child of an fo:flow or fo:static-content */
+ FONode ancestor = this.parent;
+ while (!(ancestor instanceof Flow)
+ && ancestor instanceof Wrapper) {
+ ancestor = ancestor.getParent();
+ }
+ if (ancestor instanceof Flow) {
+ this.isFlowChild = true;
+ }
}
/**
@@ -49,6 +64,7 @@ public class Wrapper extends FObjMixed {
* Additionally (unimplemented): "An fo:wrapper that is a child of an
* fo:multi-properties is only permitted to have children that would
* be permitted in place of the fo:multi-properties."
+ *
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
throws ValidationException {
@@ -58,12 +74,33 @@ public class Wrapper extends FObjMixed {
"(#PCDATA|%inline;|%block;)");
}
} else if (isBlockOrInlineItem(nsURI, localName)) {
+ if (isFlowChild
+ && isInlineItem(nsURI, localName)
+ && !isNeutralItem(nsURI, localName)) {
+ invalidChildError(loc, nsURI, localName,
+ "fo:" + localName + " not allowed as child of an fo:wrapper "
+ + "that is a child of an fo:flow or fo:static-content");
+ }
blockOrInlineItemFound = true;
} else {
invalidChildError(loc, nsURI, localName);
}
}
+ /** {@inheritDoc} */
+ protected void addCharacters(
+ char[] data,
+ int start,
+ int end,
+ PropertyList pList,
+ Locator locator) throws FOPException {
+ /* Only add text if the fo:wrapper is not a child of an fo:flow
+ * or fo:static-content */
+ if (!this.isFlowChild) {
+ super.addCharacters(data, start, end, pList, locator);
+ }
+ }
+
/** {@inheritDoc} */
public String getLocalName() {
return "wrapper";
--
cgit v1.2.3
From 5ea761b17a5cbdcc2ac36f6c841d7a22d8bdd974 Mon Sep 17 00:00:00 2001
From: Vincent Hennebert
Date: Thu, 13 Dec 2007 15:55:29 +0000
Subject: Removed calls to removeLegalBreaks since they aren't necessary (the
whole content is put in a single box anyway) and the method is buggy.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@603943 13f79535-47bb-0310-9956-ffa450edef68
---
.../org/apache/fop/layoutmgr/ElementListUtils.java | 45 +++++-----------------
.../layoutmgr/table/TableContentLayoutManager.java | 2 -
2 files changed, 10 insertions(+), 37 deletions(-)
(limited to 'src')
diff --git a/src/java/org/apache/fop/layoutmgr/ElementListUtils.java b/src/java/org/apache/fop/layoutmgr/ElementListUtils.java
index 08450db98..a2baba2fc 100644
--- a/src/java/org/apache/fop/layoutmgr/ElementListUtils.java
+++ b/src/java/org/apache/fop/layoutmgr/ElementListUtils.java
@@ -30,31 +30,6 @@ import org.apache.fop.traits.MinOptMax;
*/
public class ElementListUtils {
- /**
- * Removes all legal breaks in an element list.
- * @param elements the element list
- */
- public static void removeLegalBreaks(LinkedList elements) {
- ListIterator i = elements.listIterator();
- while (i.hasNext()) {
- ListElement el = (ListElement)i.next();
- if (el.isPenalty()) {
- BreakElement breakPoss = (BreakElement)el;
- //Convert all penalties no break inhibitors
- if (breakPoss.getPenaltyValue() < KnuthPenalty.INFINITE) {
- breakPoss.setPenaltyValue(KnuthPenalty.INFINITE);
- }
- } else if (el.isGlue()) {
- i.previous();
- if (el.isBox()) {
- i.next();
- i.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false,
- null, false));
- }
- }
- }
- }
-
/**
* Removes legal breaks in an element list. A constraint can be specified to limit the
* range in which the breaks are removed. Legal breaks occuring before at least
@@ -66,7 +41,7 @@ public class ElementListUtils {
public static boolean removeLegalBreaks(LinkedList elements, MinOptMax constraint) {
return removeLegalBreaks(elements, constraint.opt);
}
-
+
/**
* Removes legal breaks in an element list. A constraint can be specified to limit the
* range in which the breaks are removed. Legal breaks occuring before at least
@@ -84,7 +59,7 @@ public class ElementListUtils {
KnuthPenalty penalty = (KnuthPenalty)el;
//Convert all penalties to break inhibitors
if (penalty.getP() < KnuthPenalty.INFINITE) {
- iter.set(new KnuthPenalty(penalty.getW(), KnuthPenalty.INFINITE,
+ iter.set(new KnuthPenalty(penalty.getW(), KnuthPenalty.INFINITE,
penalty.isFlagged(), penalty.getPosition(), penalty.isAuxiliary()));
}
} else if (el.isGlue()) {
@@ -94,7 +69,7 @@ public class ElementListUtils {
el = (ListElement)iter.previous();
iter.next();
if (el.isBox()) {
- iter.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false,
+ iter.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false,
null, false));
}
iter.next();
@@ -131,7 +106,7 @@ public class ElementListUtils {
KnuthPenalty penalty = (KnuthPenalty)el;
//Convert all penalties to break inhibitors
if (penalty.getP() < KnuthPenalty.INFINITE) {
- i.set(new KnuthPenalty(penalty.getW(), KnuthPenalty.INFINITE,
+ i.set(new KnuthPenalty(penalty.getW(), KnuthPenalty.INFINITE,
penalty.isFlagged(), penalty.getPosition(), penalty.isAuxiliary()));
}
} else if (el.isGlue()) {
@@ -140,7 +115,7 @@ public class ElementListUtils {
el = (ListElement)i.previous();
i.next();
if (el.isBox()) {
- i.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false,
+ i.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false,
null, false));
}
} else if (el.isUnresolvedElement()) {
@@ -163,7 +138,7 @@ public class ElementListUtils {
}
return true;
}
-
+
/**
* Calculates the content length of the given element list. Warning: It doesn't take any
* stretch and shrink possibilities into account.
@@ -193,7 +168,7 @@ public class ElementListUtils {
}
return len;
}
-
+
/**
* Calculates the content length of the given element list. Warning: It doesn't take any
* stretch and shrink possibilities into account.
@@ -203,7 +178,7 @@ public class ElementListUtils {
public static int calcContentLength(List elems) {
return calcContentLength(elems, 0, elems.size() - 1);
}
-
+
/**
* Indicates whether the given element list ends with a forced break.
* @param elems the element list
@@ -213,7 +188,7 @@ public class ElementListUtils {
ListElement last = (ListElement)elems.getLast();
return last.isForcedBreak();
}
-
+
/**
* Determines the position of the previous break before the start index on an
* element list.
@@ -232,5 +207,5 @@ public class ElementListUtils {
}
return prevBreak;
}
-
+
}
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
index c08216480..bcd7f0244 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
@@ -136,7 +136,6 @@ public class TableContentLayoutManager implements PercentBaseContext {
if (headerIter != null && headerList == null) {
this.headerList = getKnuthElementsForRowIterator(
headerIter, context, alignment, TableRowIterator.HEADER);
- ElementListUtils.removeLegalBreaks(this.headerList);
this.headerNetHeight
= ElementListUtils.calcContentLength(this.headerList);
if (log.isDebugEnabled()) {
@@ -157,7 +156,6 @@ public class TableContentLayoutManager implements PercentBaseContext {
if (footerIter != null && footerList == null) {
this.footerList = getKnuthElementsForRowIterator(
footerIter, context, alignment, TableRowIterator.FOOTER);
- ElementListUtils.removeLegalBreaks(this.footerList);
this.footerNetHeight
= ElementListUtils.calcContentLength(this.footerList);
if (log.isDebugEnabled()) {
--
cgit v1.2.3
From 709bda3d6c3bc23050e6bf69d16b32ed6b35b541 Mon Sep 17 00:00:00 2001
From: Vincent Hennebert
Date: Thu, 13 Dec 2007 16:10:32 +0000
Subject: Implemented the resolution of collapsing borders in the FO tree, for
every situation (normal, cell at the top of a page, cell broken), taking
conditionality, headers and footers into account.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@603945 13f79535-47bb-0310-9956-ffa450edef68
---
src/java/org/apache/fop/fo/FOPropertyMapping.java | 2 +-
.../fop/fo/flow/table/BorderSpecification.java | 24 +-
.../fo/flow/table/CollapsingBorderResolver.java | 413 ++++++++++++++++-----
.../fop/fo/flow/table/ConditionalBorder.java | 204 ++++++++++
.../apache/fop/fo/flow/table/EmptyGridUnit.java | 11 +-
.../org/apache/fop/fo/flow/table/GridUnit.java | 160 ++++++--
.../org/apache/fop/fo/flow/table/TableBody.java | 4 +
.../org/apache/fop/fo/flow/table/TableFObj.java | 44 ++-
.../org/apache/fop/fo/flow/table/TableHeader.java | 5 +
.../properties/CommonBorderPaddingBackground.java | 58 ++-
.../fop/layoutmgr/table/CollapsingBorderModel.java | 15 +
.../table/CollapsingBorderModelEyeCatching.java | 22 ++
12 files changed, 822 insertions(+), 140 deletions(-)
create mode 100644 src/java/org/apache/fop/fo/flow/table/ConditionalBorder.java
(limited to 'src')
diff --git a/src/java/org/apache/fop/fo/FOPropertyMapping.java b/src/java/org/apache/fop/fo/FOPropertyMapping.java
index e0acfca7e..5d1a6f31a 100644
--- a/src/java/org/apache/fop/fo/FOPropertyMapping.java
+++ b/src/java/org/apache/fop/fo/FOPropertyMapping.java
@@ -1141,7 +1141,7 @@ public final class FOPropertyMapping implements Constants {
m.useGeneric(genericSpace);
corr = new SpacePropertyMaker(m);
corr.setCorresponding(PR_MARGIN_TOP, PR_MARGIN_TOP, PR_MARGIN_RIGHT);
- corr.setUseParent(true);
+ corr.setUseParent(false);
corr.setRelative(true);
addPropertyMaker("space-before", m);
diff --git a/src/java/org/apache/fop/fo/flow/table/BorderSpecification.java b/src/java/org/apache/fop/fo/flow/table/BorderSpecification.java
index 214f9be07..ce6e1b802 100644
--- a/src/java/org/apache/fop/fo/flow/table/BorderSpecification.java
+++ b/src/java/org/apache/fop/fo/flow/table/BorderSpecification.java
@@ -20,6 +20,7 @@
package org.apache.fop.fo.flow.table;
import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo;
/**
@@ -28,6 +29,8 @@ import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo;
*/
public/*TODO*/ class BorderSpecification {
+ private static BorderSpecification defaultBorder;
+
private BorderInfo borderInfo;
private int holder;
@@ -43,6 +46,14 @@ public/*TODO*/ class BorderSpecification {
this.holder = holder;
}
+ static synchronized BorderSpecification getDefaultBorder() {
+ if (defaultBorder == null) {
+ defaultBorder = new BorderSpecification(CommonBorderPaddingBackground
+ .getDefaultBorderInfo(), Constants.FO_TABLE_CELL);
+ }
+ return defaultBorder;
+ }
+
/**
* Returns this border's informations.
*
@@ -66,6 +77,17 @@ public/*TODO*/ class BorderSpecification {
/** {@inheritDoc} */
public String toString() {
- return "{" + borderInfo + ", " + holder + "}";
+ String holderName = "";
+ switch (holder) {
+ case Constants.FO_TABLE: holderName = "table"; break;
+ case Constants.FO_TABLE_COLUMN: holderName = "table-column"; break;
+ case Constants.FO_TABLE_HEADER: holderName = "table-header"; break;
+ case Constants.FO_TABLE_FOOTER: holderName = "table-footer"; break;
+ case Constants.FO_TABLE_BODY: holderName = "table-body"; break;
+ case Constants.FO_TABLE_ROW: holderName = "table-row"; break;
+ case Constants.FO_TABLE_CELL: holderName = "table-cell"; break;
+ default: assert false;
+ }
+ return "{" + borderInfo + ", " + holderName + "}";
}
}
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 c4f7f9a78..f92f7bb30 100644
--- a/src/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.java
+++ b/src/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.java
@@ -19,6 +19,7 @@
package org.apache.fop.fo.flow.table;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -31,138 +32,366 @@ class CollapsingBorderResolver implements BorderResolver {
private Table table;
- private List previousRow;
-
/**
- * The flow of rows is interrupted by the table-footer. Save the header's last row (if
- * any) for resolution between it and the body's first row.
+ * The previously registered row, either in the header or the body(-ies), but not in
+ * the footer (handled separately).
*/
- private List previousRowSave;
-
- private TableBody currentTablePart;
+ private List/**/ previousRow;
private boolean firstInTable;
- private boolean firstInPart;
+ private List/**/ footerFirstRow;
- private List footerFirstRow;
+ /** The last currently registered footer row. */
+ private List/**/ footerLastRow;
- private List footerLastRow;
+ private Resolver delegate;
- private boolean inFooter;
+ private Resolver resolverInFooter;
- CollapsingBorderResolver(Table table) {
- this.table = table;
- firstInTable = true;
- }
+ private List/**/ leadingBorders;
- /** {@inheritDoc} */
- public void endRow(List row, TableCellContainer container) {
- // Resolve before- and after-borders for the table-row
- if (container instanceof TableRow) {
- TableRow tableRow = (TableRow) container;
- for (Iterator iter = row.iterator(); iter.hasNext();) {
- GridUnit gu = (GridUnit) iter.next();
+ private List/**/ trailingBorders;
+
+ /**
+ * Base class for delegate resolvers. Implementation of the State design pattern: the
+ * treatment differs slightly whether we are in the table's header, footer or body. To
+ * avoid complicated if statements, specialised delegate resolvers will be used
+ * instead.
+ */
+ private abstract class Resolver {
+
+ protected TableBody tablePart;
+
+ protected boolean firstInPart;
+
+ /**
+ * Integrates border-before specified on the table and its column.
+ *
+ * @param row the first row of the table (in the header, or in the body if the
+ * table has no header)
+ * @param withLeadingTrailing
+ * @param withNonLeadingTrailing
+ * @param withRest
+ */
+ void resolveBordersFirstRowInTable(List/**/ row, boolean withLeadingTrailing,
+ boolean withNonLeadingTrailing, 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);
+ }
+ firstInTable = false;
+ }
+
+ /**
+ * Resolves border-after for the first row, border-before for the second one.
+ *
+ * @param rowBefore
+ * @param rowAfter
+ */
+ void resolveBordersBetweenRows(List/**/ rowBefore, List/**/ rowAfter) {
+ assert rowBefore != null && rowAfter != null;
+ for (int i = 0; i < rowAfter.size(); i++) {
+ GridUnit gu = (GridUnit) rowAfter.get(i);
if (gu.getRowSpanIndex() == 0) {
- gu.resolveBorder(CommonBorderPaddingBackground.BEFORE, tableRow);
- }
- if (gu.isLastGridUnitRowSpan()) {
- gu.resolveBorder(CommonBorderPaddingBackground.AFTER, tableRow);
+ GridUnit beforeGU = (GridUnit) rowBefore.get(i);
+ gu.resolveBorder(beforeGU, CommonBorderPaddingBackground.BEFORE);
}
}
}
- if (inFooter) {
- if (footerFirstRow == null) {
- footerFirstRow = row;
+
+ /** Integrates the border-after of the part. */
+ void resolveBordersLastRowInPart(List/**/ row, boolean withLeadingTrailing,
+ boolean withNonLeadingTrailing, boolean withRest) {
+ for (int i = 0; i < row.size(); i++) {
+ ((GridUnit) row.get(i)).integrateBorderSegment(CommonBorderPaddingBackground.AFTER,
+ tablePart, withLeadingTrailing, withNonLeadingTrailing, withRest);
}
- footerLastRow = row;
- } else if (firstInTable) {
- // Resolve border-before for the first row in the table
+ }
+
+ /**
+ * Integrates border-after specified on the table and its columns.
+ *
+ * @param row the last row of the footer, or of the last body if the table has no
+ * footer
+ * @param withLeadingTrailing
+ * @param withNonLeadingTrailing
+ * @param withRest
+ */
+ void resolveBordersLastRowInTable(List/**/ row, boolean withLeadingTrailing,
+ boolean withNonLeadingTrailing, boolean withRest) {
for (int i = 0; i < row.size(); i++) {
TableColumn column = table.getColumn(i);
- ((GridUnit) row.get(i)).resolveBorder(CommonBorderPaddingBackground.BEFORE, column);
+ ((GridUnit) row.get(i)).integrateBorderSegment(CommonBorderPaddingBackground.AFTER,
+ column, withLeadingTrailing, withNonLeadingTrailing, withRest);
}
- firstInTable = false;
}
- if (firstInPart) {
- // Resolve border-before for the first row in the part
- for (int i = 0; i < row.size(); i++) {
- ((GridUnit) row.get(i)).resolveBorder(CommonBorderPaddingBackground.BEFORE,
- currentTablePart);
+
+ /**
+ * Integrates either border-before specified on the table and its columns if the
+ * table has no header, or border-after specified on the cells of the header's
+ * last row. For the case the grid unit are at the top of a page.
+ *
+ * @param row
+ */
+ void integrateLeadingBorders(List/**/ row) {
+ for (int i = 0; i < table.getNumberOfColumns(); i++) {
+ GridUnit gu = (GridUnit) row.get(i);
+ ConditionalBorder border = (ConditionalBorder) leadingBorders.get(i);
+ gu.integrateCompetingBorder(CommonBorderPaddingBackground.BEFORE, border,
+ true, false, true);
}
- firstInPart = false;
}
- if (previousRow != null) {
- // Resolve after/before borders between rows
- for (int i = 0; i < row.size(); i++) {
+
+ /**
+ * Integrates either border-after specified on the table and its columns if the
+ * table has no footer, or border-before specified on the cells of the footer's
+ * first row. For the case the grid unit are at the bottom of a page.
+ *
+ * @param row
+ */
+ void integrateTrailingBorders(List/**/ row) {
+ for (int i = 0; i < table.getNumberOfColumns(); i++) {
GridUnit gu = (GridUnit) row.get(i);
- if (gu.getRowSpanIndex() == 0) {
- GridUnit beforeGU = (GridUnit) previousRow.get(i);
- gu.resolveBorder(beforeGU, CommonBorderPaddingBackground.BEFORE);
- }
+ ConditionalBorder border = (ConditionalBorder) trailingBorders.get(i);
+ gu.integrateCompetingBorder(CommonBorderPaddingBackground.AFTER, border,
+ true, false, true);
}
}
- // Resolve start/end borders in the row
- Iterator guIter = row.iterator();
- GridUnit gu = (GridUnit) guIter.next();
- gu.resolveBorder(CommonBorderPaddingBackground.START, container);
- while (guIter.hasNext()) {
- GridUnit guEnd = (GridUnit) guIter.next();
- if (gu.isLastGridUnitColSpan()) {
- gu.resolveBorder(guEnd, CommonBorderPaddingBackground.END);
+
+ void startPart(TableBody part) {
+ tablePart = part;
+ firstInPart = true;
+ }
+
+ /**
+ * Resolves the applicable borders for the given row.
+ *
+ * - Integrates the border-before/after of the containing table-row if any;
+ * - Integrates the border-before of the containing part, if first row;
+ * - Resolves border-start/end between grid units.
+ *
+ *
+ * @param row the row being finished
+ * @param container the containing element
+ */
+ void endRow(List/**/ row, TableCellContainer container) {
+ // Resolve before- and after-borders for the table-row
+ if (container instanceof TableRow) {
+ TableRow tableRow = (TableRow) container;
+ for (Iterator iter = row.iterator(); iter.hasNext();) {
+ GridUnit gu = (GridUnit) iter.next();
+ if (gu.getRowSpanIndex() == 0) {
+ gu.integrateBorderSegment(CommonBorderPaddingBackground.BEFORE, tableRow,
+ true, true, true);
+ }
+ if (gu.isLastGridUnitRowSpan()) {
+ gu.integrateBorderSegment(CommonBorderPaddingBackground.AFTER, tableRow,
+ true, true, true);
+ }
+ }
+ }
+ if (firstInPart) {
+ // Integrate the border-before of the part
+ for (int i = 0; i < row.size(); i++) {
+ ((GridUnit) row.get(i)).integrateBorderSegment(
+ CommonBorderPaddingBackground.BEFORE, tablePart, true, true, true);
+ }
+ firstInPart = false;
+ }
+ // Resolve start/end borders in the row
+ Iterator guIter = row.iterator();
+ GridUnit gu = (GridUnit) guIter.next();
+ gu.integrateBorderSegment(CommonBorderPaddingBackground.START, container);
+ while (guIter.hasNext()) {
+ GridUnit guEnd = (GridUnit) guIter.next();
+ if (gu.isLastGridUnitColSpan()) {
+ gu.resolveBorder(guEnd, CommonBorderPaddingBackground.END);
+ }
+ gu = guEnd;
}
- gu = guEnd;
+ gu.integrateBorderSegment(CommonBorderPaddingBackground.END, container);
}
- gu.resolveBorder(CommonBorderPaddingBackground.END, container);
- previousRow = row;
+ void endPart() {
+ resolveBordersLastRowInPart(previousRow, true, true, true);
+ }
+
+ abstract void endTable();
}
- /** {@inheritDoc} */
- public void startPart(TableBody part) {
- firstInPart = true;
- currentTablePart = part;
- if (part.isTableFooter()) {
- inFooter = true;
- previousRowSave = previousRow;
- previousRow = null;
+ private class ResolverInHeader extends Resolver {
+
+ void endRow(List/**/ row, TableCellContainer container) {
+ super.endRow(row, container);
+ if (previousRow != null) {
+ resolveBordersBetweenRows(previousRow, row);
+ } else {
+ /*
+ * This is a bit hacky...
+ * 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.
+ */
+ for (Iterator guIter = row.iterator(); guIter.hasNext();) {
+ ConditionalBorder borderBefore = ((GridUnit) guIter.next()).borderBefore;
+ borderBefore.leadingTrailing = null;
+ borderBefore.rest = borderBefore.nonLeadingTrailing;
+ }
+ resolveBordersFirstRowInTable(row, false, true, true);
+ }
+ previousRow = row;
}
- }
- /** {@inheritDoc} */
- public void endPart(TableBody part) {
- // Resolve border-after for the last row in the part
- for (int i = 0; i < previousRow.size(); i++) {
- ((GridUnit) previousRow.get(i))
- .resolveBorder(CommonBorderPaddingBackground.AFTER, part);
+ void endPart() {
+ super.endPart();
+ leadingBorders = new ArrayList(table.getNumberOfColumns());
+ /*
+ * Another hack...
+ * 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.
+ */
+ for (Iterator guIter = previousRow.iterator(); guIter.hasNext();) {
+ ConditionalBorder borderAfter = ((GridUnit) guIter.next()).borderAfter;
+ borderAfter.leadingTrailing = borderAfter.nonLeadingTrailing;
+ borderAfter.rest = borderAfter.nonLeadingTrailing;
+ leadingBorders.add(borderAfter);
+ }
}
- if (inFooter) {
- inFooter = false;
- previousRow = previousRowSave;
+
+ void endTable() {
+ throw new IllegalStateException();
}
}
- /** {@inheritDoc} */
- public void endTable() {
- if (footerFirstRow != null) {
+ private class ResolverInFooter extends Resolver {
+
+ void endRow(List/**/ row, TableCellContainer container) {
+ super.endRow(row, container);
+ if (footerFirstRow == null) {
+ footerFirstRow = row;
+ } else {
+ // There is a previous row
+ resolveBordersBetweenRows(footerLastRow, row);
+ }
+ footerLastRow = row;
+ }
+
+ void endPart() {
+ resolveBordersLastRowInPart(footerLastRow, true, true, true);
+ trailingBorders = new ArrayList(table.getNumberOfColumns());
+ // 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;
+ trailingBorders.add(borderBefore);
+ }
+ }
+
+ void endTable() {
// Resolve after/before border between the last row of table-body and the
// first row of table-footer
- for (int i = 0; i < footerFirstRow.size(); i++) {
- GridUnit gu = (GridUnit) footerFirstRow.get(i);
- GridUnit beforeGU = (GridUnit) previousRow.get(i);
- gu.resolveBorder(beforeGU, CommonBorderPaddingBackground.BEFORE);
+ resolveBordersBetweenRows(previousRow, footerFirstRow);
+ // 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 = null;
+ borderAfter.rest = borderAfter.nonLeadingTrailing;
}
+ resolveBordersLastRowInTable(footerLastRow, false, true, true);
}
- List lastRow;
- if (footerLastRow != null) {
- lastRow = footerLastRow;
- } else {
- lastRow = previousRow;
+ }
+
+ private class ResolverInBody extends Resolver {
+
+ void endRow(List/**/ row, TableCellContainer container) {
+ super.endRow(row, container);
+ if (firstInTable) {
+ resolveBordersFirstRowInTable(row, true, true, true);
+ } else {
+ // Either there is a header, and then previousRow is set to the header's last row,
+ // or this is not the first row in the body, and previousRow is not null
+ resolveBordersBetweenRows(previousRow, row);
+ integrateLeadingBorders(row);
+ }
+ integrateTrailingBorders(row);
+ previousRow = row;
}
- // Resolve border-after for the last row of the table
- for (int i = 0; i < lastRow.size(); i++) {
- TableColumn column = table.getColumn(i);
- ((GridUnit) lastRow.get(i)).resolveBorder(CommonBorderPaddingBackground.AFTER, column);
+
+ void endTable() {
+ if (resolverInFooter != null) {
+ resolverInFooter.endTable();
+ } else {
+ // Trailing and rest borders already resolved with integrateTrailingBorders
+ resolveBordersLastRowInTable(previousRow, false, true, false);
+ }
}
}
+
+ CollapsingBorderResolver(Table table) {
+ this.table = table;
+ firstInTable = true;
+ }
+
+ /** {@inheritDoc} */
+ public void endRow(List/**/ row, TableCellContainer container) {
+ delegate.endRow(row, container);
+ }
+
+ /** {@inheritDoc} */
+ public void startPart(TableBody part) {
+ if (part.isTableHeader()) {
+ delegate = new ResolverInHeader();
+ } else {
+ if (leadingBorders == null) {
+ // 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);
+ }
+ }
+ if (part.isTableFooter()) {
+ resolverInFooter = new ResolverInFooter();
+ delegate = resolverInFooter;
+ } else {
+ if (trailingBorders == null) {
+ // 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);
+ }
+ }
+ delegate = new ResolverInBody();
+ }
+ }
+ delegate.startPart(part);
+ }
+
+ /** {@inheritDoc} */
+ public void endPart(TableBody part) {
+ delegate.endPart();
+ }
+
+ /** {@inheritDoc} */
+ public void endTable() {
+ delegate.endTable();
+ delegate = null;
+ }
}
diff --git a/src/java/org/apache/fop/fo/flow/table/ConditionalBorder.java b/src/java/org/apache/fop/fo/flow/table/ConditionalBorder.java
new file mode 100644
index 000000000..e03e11a15
--- /dev/null
+++ b/src/java/org/apache/fop/fo/flow/table/ConditionalBorder.java
@@ -0,0 +1,204 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.fo.flow.table;
+
+import org.apache.fop.layoutmgr.table.CollapsingBorderModel;
+
+/**
+ * A class that holds the three possible values for a border-before/after on a table-cell,
+ * in the collapsing model. These three values are (for border-before, similar for
+ * border-after):
+ *
+ * - non-leading: common case, when a cell follows the cell before on a same page;
+ * - 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;
+ * - rest: when a cell is broken over several pages; same as leading but with
+ * conditionality taken into account.
+ *
+ */
+public class ConditionalBorder {
+
+ /** 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,
+ CollapsingBorderModel collapsingBorderModel) {
+ this.leadingTrailing = leadingTrailing;
+ this.nonLeadingTrailing = nonLeadingTrailing;
+ this.rest = rest;
+ this.collapsingBorderModel = collapsingBorderModel;
+ }
+
+ /**
+ * Creates a new conditional border.
+ *
+ * @param borderSpecification the border specification to take as a basis
+ * @param collapsingBorderModel the model that will be used to resolved borders
+ */
+ ConditionalBorder(BorderSpecification borderSpecification,
+ CollapsingBorderModel collapsingBorderModel) {
+ leadingTrailing = borderSpecification;
+ nonLeadingTrailing = leadingTrailing;
+ if (borderSpecification.getBorderInfo().getWidth().isDiscard()) {
+ rest = BorderSpecification.getDefaultBorder();
+ } else {
+ rest = leadingTrailing;
+ }
+ this.collapsingBorderModel = collapsingBorderModel;
+ }
+
+ /**
+ * Resolves and updates the relevant parts of this border as well as the given one.
+ *
+ * @param competitor
+ * @param withLeadingTrailing
+ * @param withNonLeadingTrailing
+ * @param withRest
+ */
+ void resolve(ConditionalBorder competitor, boolean withLeadingTrailing,
+ boolean withNonLeadingTrailing, boolean withRest) {
+ if (withLeadingTrailing) {
+ BorderSpecification resolvedBorder = collapsingBorderModel.determineWinner(
+ leadingTrailing, competitor.leadingTrailing);
+ if (resolvedBorder != null) {
+ leadingTrailing = resolvedBorder;
+ competitor.leadingTrailing = resolvedBorder;
+ }
+ }
+ if (withNonLeadingTrailing) {
+ BorderSpecification resolvedBorder = collapsingBorderModel.determineWinner(
+ nonLeadingTrailing, competitor.nonLeadingTrailing);
+ if (resolvedBorder != null) {
+ nonLeadingTrailing = resolvedBorder;
+ competitor.nonLeadingTrailing = resolvedBorder;
+ }
+ }
+ if (withRest) {
+ BorderSpecification resolvedBorder = collapsingBorderModel.determineWinner(rest,
+ competitor.rest);
+ if (resolvedBorder != null) {
+ rest = resolvedBorder;
+ competitor.rest = resolvedBorder;
+ }
+ }
+ }
+
+ /**
+ * Integrates the given segment in this border. Unlike for
+ * {@link #integrateSegment(ConditionalBorder, boolean, boolean, boolean)}, this
+ * method nicely handles the case where the CollapsingBorderModel returns null, by
+ * keeping the components to their old values.
+ *
+ * @param competitor
+ * @param withLeadingTrailing
+ * @param withNonLeadingTrailing
+ * @param withRest
+ */
+ void integrateCompetingSegment(ConditionalBorder competitor, boolean withLeadingTrailing,
+ boolean withNonLeadingTrailing, boolean withRest) {
+ if (withLeadingTrailing) {
+ BorderSpecification resolvedBorder = collapsingBorderModel.determineWinner(
+ leadingTrailing, competitor.leadingTrailing);
+ if (resolvedBorder != null) {
+ leadingTrailing = resolvedBorder;
+ }
+ }
+ if (withNonLeadingTrailing) {
+ BorderSpecification resolvedBorder = collapsingBorderModel.determineWinner(
+ nonLeadingTrailing, competitor.nonLeadingTrailing);
+ if (resolvedBorder != null) {
+ nonLeadingTrailing = resolvedBorder;
+ }
+ }
+ if (withRest) {
+ BorderSpecification resolvedBorder = collapsingBorderModel.determineWinner(rest,
+ competitor.rest);
+ if (resolvedBorder != null) {
+ rest = resolvedBorder;
+ }
+ }
+ }
+
+ /**
+ * Updates this border after taking into account the given segment. The
+ * CollapsingBorderModel is not expected to return null.
+ *
+ * @param segment
+ * @param withLeadingTrailing
+ * @param withNonLeadingTrailing
+ * @param withRest
+ */
+ void integrateSegment(ConditionalBorder segment, boolean withLeadingTrailing,
+ boolean withNonLeadingTrailing, boolean withRest) {
+ 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;
+ }
+ }
+
+ /**
+ * Returns a shallow copy of this border.
+ *
+ * @return a copy of this border
+ */
+ ConditionalBorder copy() {
+ return new ConditionalBorder(leadingTrailing, nonLeadingTrailing, rest,
+ collapsingBorderModel);
+ }
+
+ /** {@inheritDoc} */
+ public String toString() {
+ return "{non-leading: " + nonLeadingTrailing + ", leading: " + leadingTrailing + ", rest: "
+ + rest + "}";
+ }
+
+ /**
+ * Returns a default border specification.
+ *
+ * @param collapsingBorderModel the model that will be used to resolve borders
+ * @return a border with style 'none' for all of the three components
+ */
+ static ConditionalBorder getDefaultBorder(CollapsingBorderModel collapsingBorderModel) {
+ BorderSpecification defaultBorderSpec = BorderSpecification.getDefaultBorder();
+ return new ConditionalBorder(defaultBorderSpec, defaultBorderSpec, defaultBorderSpec,
+ collapsingBorderModel);
+ }
+}
diff --git a/src/java/org/apache/fop/fo/flow/table/EmptyGridUnit.java b/src/java/org/apache/fop/fo/flow/table/EmptyGridUnit.java
index be487931b..7a8b0be62 100644
--- a/src/java/org/apache/fop/fo/flow/table/EmptyGridUnit.java
+++ b/src/java/org/apache/fop/fo/flow/table/EmptyGridUnit.java
@@ -19,8 +19,6 @@
package org.apache.fop.fo.flow.table;
-import org.apache.fop.fo.Constants;
-import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
/**
* GridUnit subclass for empty grid units.
@@ -40,10 +38,11 @@ public class EmptyGridUnit extends GridUnit {
}
/** {@inheritDoc} */
- protected void setBorder(int side) {
- resolvedBorders[side] = new BorderSpecification(
- CommonBorderPaddingBackground.getDefaultBorderInfo(),
- Constants.FO_TABLE_CELL);
+ protected void setBordersFromCell() {
+ borderBefore = ConditionalBorder.getDefaultBorder(collapsingBorderModel);
+ borderAfter = ConditionalBorder.getDefaultBorder(collapsingBorderModel);
+ borderStart = BorderSpecification.getDefaultBorder();
+ borderEnd = BorderSpecification.getDefaultBorder();
}
/** {@inheritDoc} */
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 f7c7672e3..d6d622d57 100644
--- a/src/java/org/apache/fop/fo/flow/table/GridUnit.java
+++ b/src/java/org/apache/fop/fo/flow/table/GridUnit.java
@@ -90,9 +90,12 @@ public class GridUnit {
/** flags for the grid unit */
private byte flags = 0;
- protected BorderSpecification[] resolvedBorders;
+ ConditionalBorder borderBefore;
+ ConditionalBorder borderAfter;
+ BorderSpecification borderStart;
+ BorderSpecification borderEnd;
- private CollapsingBorderModel collapsingBorderModel;
+ protected CollapsingBorderModel collapsingBorderModel;
/**
* Creates a new grid unit.
@@ -156,26 +159,27 @@ public class GridUnit {
if (table.isSeparateBorderModel()) {
assignBorderForSeparateBorderModel();
} else {
- resolvedBorders = new BorderSpecification[4];
collapsingBorderModel = CollapsingBorderModel.getBorderModelFor(table
.getBorderCollapse());
- if (rowSpanIndex == 0) {
- setBorder(CommonBorderPaddingBackground.BEFORE);
- }
- if (isLastGridUnitRowSpan()) {
- setBorder(CommonBorderPaddingBackground.AFTER);
- }
- if (colSpanIndex == 0) {
- setBorder(CommonBorderPaddingBackground.START);
- }
- if (isLastGridUnitColSpan()) {
- setBorder(CommonBorderPaddingBackground.END);
- }
+ setBordersFromCell();
}
}
- protected void setBorder(int side) {
- resolvedBorders[side] = cell.resolvedBorders[side];
+ protected void setBordersFromCell() {
+ borderBefore = cell.borderBefore.copy();
+ if (rowSpanIndex > 0) {
+ borderBefore.nonLeadingTrailing = null;
+ }
+ borderAfter = cell.borderAfter.copy();
+ if (!isLastGridUnitRowSpan()) {
+ borderAfter.nonLeadingTrailing = null;
+ }
+ if (colSpanIndex == 0) {
+ borderStart = cell.borderStart;
+ }
+ if (isLastGridUnitColSpan()) {
+ borderEnd = cell.borderEnd;
+ }
}
public TableCell getCell() {
@@ -301,8 +305,30 @@ public class GridUnit {
}
private void setBorderInfo(int side) {
- if (resolvedBorders[side] != null) {
- effectiveBorders.setBorderInfo(resolvedBorders[side].getBorderInfo(), side);
+ switch (side) {
+ case CommonBorderPaddingBackground.BEFORE:
+ if (borderBefore.nonLeadingTrailing/*TODO*/ != null) {
+ effectiveBorders.setBorderInfo(borderBefore.nonLeadingTrailing.getBorderInfo(),
+ side);
+ }
+ break;
+ case CommonBorderPaddingBackground.AFTER:
+ if (borderAfter.nonLeadingTrailing/*TODO*/ != null) {
+ effectiveBorders.setBorderInfo(borderAfter.nonLeadingTrailing.getBorderInfo(),
+ side);
+ }
+ break;
+ case CommonBorderPaddingBackground.START:
+ if (borderStart != null) {
+ effectiveBorders.setBorderInfo(borderStart.getBorderInfo(), side);
+ }
+ break;
+ case CommonBorderPaddingBackground.END:
+ if (borderEnd != null) {
+ effectiveBorders.setBorderInfo(borderEnd.getBorderInfo(), side);
+ }
+ break;
+ default: assert false;
}
}
@@ -332,26 +358,96 @@ public class GridUnit {
* CommonBorderPaddingBackground.BEFORE|AFTER|START|END)
*/
void resolveBorder(GridUnit other, int side) {
- BorderSpecification resolvedBorder = collapsingBorderModel.determineWinner(
- resolvedBorders[side], other.resolvedBorders[CollapsingBorderModel
- .getOtherSide(side)]);
- if (resolvedBorder != null) {
- this.resolvedBorders[side] = resolvedBorder;
- other.resolvedBorders[CollapsingBorderModel.getOtherSide(side)] = resolvedBorder;
+ switch (side) {
+ case CommonBorderPaddingBackground.BEFORE:
+ borderBefore.resolve(other.borderAfter, false, true, false);
+ break;
+ case CommonBorderPaddingBackground.AFTER:
+ borderAfter.resolve(other.borderBefore, false, true, false);
+ break;
+ case CommonBorderPaddingBackground.START:
+ BorderSpecification resolvedBorder = collapsingBorderModel.determineWinner(
+ borderStart, other.borderEnd);
+ if (resolvedBorder != null) {
+ this.borderStart = resolvedBorder;
+ other.borderEnd = resolvedBorder;
+ }
+ break;
+ case CommonBorderPaddingBackground.END:
+ resolvedBorder = collapsingBorderModel.determineWinner(
+ borderEnd, other.borderStart);
+ if (resolvedBorder != null) {
+ this.borderEnd = resolvedBorder;
+ other.borderStart = resolvedBorder;
+ }
+ break;
+ default: assert false;
}
}
/**
- * Resolves the border on the given side of this grid unit, comparing it against the
- * same border of the given parent element.
+ * For the given side, integrates in the conflict resolution the border segment of the
+ * given parent element.
*
- * @param side the side to resolve (one of
+ * @param side the side to consider (either CommonBorderPaddingBackground.BEFORE or
+ * AFTER)
+ * @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) {
+ switch (side) {
+ case CommonBorderPaddingBackground.BEFORE:
+ borderBefore.integrateSegment(parent.borderBefore, withLeadingTrailing,
+ withNonLeadingTrailing, withRest);
+ break;
+ case CommonBorderPaddingBackground.AFTER:
+ borderAfter.integrateSegment(parent.borderAfter, withLeadingTrailing,
+ withNonLeadingTrailing, withRest);
+ break;
+ default: assert false;
+ }
+ }
+
+ /**
+ * For the given side, integrates in the conflict resolution the border segment of the
+ * given parent element.
+ *
+ * @param side the side to consider (one of
* CommonBorderPaddingBackground.BEFORE|AFTER|START|END)
- * @param parent the parent element holding a competing border
+ * @param parent a table element whose corresponding border coincides on the given side
*/
- void resolveBorder(int side, TableFObj parent) {
- resolvedBorders[side] = collapsingBorderModel.determineWinner(resolvedBorders[side],
- parent.resolvedBorders[side]);
+ void integrateBorderSegment(int side, TableFObj parent) {
+ switch (side) {
+ case CommonBorderPaddingBackground.BEFORE:
+ case CommonBorderPaddingBackground.AFTER:
+ integrateBorderSegment(side, parent, true, true, true);
+ break;
+ case CommonBorderPaddingBackground.START:
+ borderStart = collapsingBorderModel.determineWinner(borderStart,
+ parent.borderStart);
+ break;
+ case CommonBorderPaddingBackground.END:
+ borderEnd = collapsingBorderModel.determineWinner(borderEnd,
+ parent.borderEnd);
+ break;
+ default: assert false;
+ }
+ }
+
+ void integrateCompetingBorder(int side, ConditionalBorder competitor,
+ boolean withLeadingTrailing, boolean withNonLeadingTrailing, boolean withRest) {
+ switch (side) {
+ case CommonBorderPaddingBackground.BEFORE:
+ borderBefore.integrateCompetingSegment(competitor, withLeadingTrailing,
+ withNonLeadingTrailing, withRest);
+ break;
+ case CommonBorderPaddingBackground.AFTER:
+ borderAfter.integrateCompetingSegment(competitor, withLeadingTrailing,
+ withNonLeadingTrailing, withRest);
+ break;
+ default: assert false;
+ }
}
/**
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 6b12271fc..c1453bdfa 100644
--- a/src/java/org/apache/fop/fo/flow/table/TableBody.java
+++ b/src/java/org/apache/fop/fo/flow/table/TableBody.java
@@ -261,6 +261,10 @@ public class TableBody extends TableCellContainer {
return FO_TABLE_BODY;
}
+ protected boolean isTableHeader() {
+ return false;
+ }
+
protected boolean isTableFooter() {
return false;
}
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 236556a05..4b90ccac3 100644
--- a/src/java/org/apache/fop/fo/flow/table/TableFObj.java
+++ b/src/java/org/apache/fop/fo/flow/table/TableFObj.java
@@ -42,7 +42,10 @@ public abstract class TableFObj extends FObj {
private Numeric borderEndPrecedence;
private Numeric borderStartPrecedence;
- BorderSpecification[] resolvedBorders = new BorderSpecification[4]; // TODO
+ ConditionalBorder borderBefore;
+ ConditionalBorder borderAfter;
+ BorderSpecification borderStart;
+ BorderSpecification borderEnd;
CollapsingBorderModel collapsingBorderModel;
@@ -200,7 +203,6 @@ public abstract class TableFObj extends FObj {
if (!inMarker() && !table.isSeparateBorderModel()) {
collapsingBorderModel = CollapsingBorderModel.getBorderModelFor(table
.getBorderCollapse());
- resolvedBorders = new BorderSpecification[4];
setCollapsedBorders();
}
}
@@ -226,8 +228,23 @@ public abstract class TableFObj extends FObj {
* @param side one of CommonBorderPaddingBackground.BEFORE|AFTER|START|END
*/
protected void createBorder(int side) {
- resolvedBorders[side] = new BorderSpecification(getCommonBorderPaddingBackground()
- .getBorderInfo(side), getNameId());
+ BorderSpecification borderSpec = new BorderSpecification(
+ getCommonBorderPaddingBackground().getBorderInfo(side), getNameId());
+ switch (side) {
+ case CommonBorderPaddingBackground.BEFORE:
+ borderBefore = new ConditionalBorder(borderSpec, collapsingBorderModel);
+ break;
+ case CommonBorderPaddingBackground.AFTER:
+ borderAfter = new ConditionalBorder(borderSpec, collapsingBorderModel);
+ break;
+ case CommonBorderPaddingBackground.START:
+ borderStart = borderSpec;
+ break;
+ case CommonBorderPaddingBackground.END:
+ borderEnd = borderSpec;
+ break;
+ default: assert false;
+ }
}
/**
@@ -240,7 +257,22 @@ public abstract class TableFObj extends FObj {
*/
protected void createBorder(int side, TableFObj competitor) {
createBorder(side);
- resolvedBorders[side] = collapsingBorderModel.determineWinner(resolvedBorders[side],
- competitor.resolvedBorders[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/TableHeader.java b/src/java/org/apache/fop/fo/flow/table/TableHeader.java
index 01ada2aa7..e248a0f7e 100644
--- a/src/java/org/apache/fop/fo/flow/table/TableHeader.java
+++ b/src/java/org/apache/fop/fo/flow/table/TableHeader.java
@@ -66,4 +66,9 @@ public class TableHeader extends TableBody {
public int getNameId() {
return FO_TABLE_HEADER;
}
+
+ /** {@inheritDoc} */
+ protected boolean isTableHeader() {
+ return true;
+ }
}
diff --git a/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java b/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java
index 6ea08f19c..c5a4950f4 100755
--- a/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java
+++ b/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java
@@ -130,6 +130,59 @@ public class CommonBorderPaddingBackground {
*/
private static BorderInfo defaultBorderInfo;
+ /**
+ * A conditional length of value 0. Returned by the
+ * {@link CommonBorderPaddingBackground#getBorderInfo(int)} method when the
+ * corresponding border isn't specified, to avoid to callers painful checks for null.
+ */
+ private static class ConditionalNullLength extends CondLengthProperty {
+
+ /** {@inheritDoc} */
+ public Property getComponent(int cmpId) {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ public Property getConditionality() {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ public Length getLength() {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ public Property getLengthComponent() {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ public int getLengthValue() {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ public int getLengthValue(PercentBaseContext context) {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ public boolean isDiscard() {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ public void setComponent(int cmpId, Property cmpnValue, boolean isDefault) {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ public String toString() {
+ return "CondLength[0mpt, discard]";
+ }
+ }
+
/**
* Returns a default BorderInfo of style none.
*
@@ -137,8 +190,9 @@ public class CommonBorderPaddingBackground {
*/
public static synchronized BorderInfo getDefaultBorderInfo() {
if (defaultBorderInfo == null) {
- /* It is enough to set color and width to null, as they should never be consulted */
- defaultBorderInfo = new BorderInfo(Constants.EN_NONE, null, null);
+ /* It is enough to set color to null, as it should never be consulted */
+ defaultBorderInfo = new BorderInfo(Constants.EN_NONE,
+ new ConditionalNullLength(), null);
}
return defaultBorderInfo;
}
diff --git a/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java b/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java
index a0bff3b5e..c3df74800 100644
--- a/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java
+++ b/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java
@@ -181,8 +181,23 @@ public abstract class CollapsingBorderModel {
*
* @param border1 a border specification
* @param border2 another border specification
+ * @param discard true if the .conditionality component of the border width must be
+ * taken into account
* @return the winning border, null if the two borders are equivalent
*/
+ public abstract BorderSpecification determineWinner(BorderSpecification border1,
+ BorderSpecification border2, boolean discard);
+
+ /**
+ * Returns the border which wins the border conflict resolution. Same as
+ * {@link #determineWinner(BorderSpecification, BorderSpecification, boolean)
+ * determineWinner(border1, border2, false)}.
+ *
+ * @param border1 a border specification
+ * @param border2 another border specification
+ * @return the winning border, null if the two borders are equivalent
+ * @see determineWinner
+ */
public abstract BorderSpecification determineWinner(BorderSpecification border1,
BorderSpecification border2);
diff --git a/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModelEyeCatching.java b/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModelEyeCatching.java
index 5f979c986..c1a9380a3 100644
--- a/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModelEyeCatching.java
+++ b/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModelEyeCatching.java
@@ -21,6 +21,7 @@ package org.apache.fop.layoutmgr.table;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.flow.table.BorderSpecification;
+import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo;
/**
@@ -30,6 +31,27 @@ import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo;
*/
public class CollapsingBorderModelEyeCatching extends CollapsingBorderModel {
+ /** {@inheritDoc} */
+ public BorderSpecification determineWinner(BorderSpecification border1,
+ BorderSpecification border2, boolean discard) {
+ BorderInfo bi1 = border1.getBorderInfo();
+ BorderInfo bi2 = border2.getBorderInfo();
+ if (discard) {
+ if (bi1.getWidth().isDiscard()) {
+ if (bi2.getWidth().isDiscard()) {
+ return new BorderSpecification(
+ CommonBorderPaddingBackground.getDefaultBorderInfo(), 0/*TODO*/);
+ } else {
+ return border2;
+ }
+ } else if (bi2.getWidth().isDiscard()) {
+ return border1;
+ }
+ }
+ // Otherwise, fall back to the default resolution algorithm
+ return determineWinner(border1, border2);
+ }
+
/** {@inheritDoc} */
public BorderSpecification determineWinner(BorderSpecification border1,
BorderSpecification border2) {
--
cgit v1.2.3
From 9957e3b9ae746fabc891d2d9223f708ec9709bd3 Mon Sep 17 00:00:00 2001
From: Vincent Hennebert
Date: Thu, 13 Dec 2007 17:21:24 +0000
Subject: Reverted change accidentally introduced in the previous commit. A
proper fix needs to be found for this one.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@603959 13f79535-47bb-0310-9956-ffa450edef68
---
src/java/org/apache/fop/fo/FOPropertyMapping.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'src')
diff --git a/src/java/org/apache/fop/fo/FOPropertyMapping.java b/src/java/org/apache/fop/fo/FOPropertyMapping.java
index 5d1a6f31a..d393c1d7c 100644
--- a/src/java/org/apache/fop/fo/FOPropertyMapping.java
+++ b/src/java/org/apache/fop/fo/FOPropertyMapping.java
@@ -1150,7 +1150,7 @@ public final class FOPropertyMapping implements Constants {
m.useGeneric(genericSpace);
corr = new SpacePropertyMaker(m);
corr.setCorresponding(PR_MARGIN_BOTTOM, PR_MARGIN_BOTTOM, PR_MARGIN_LEFT);
- corr.setUseParent(true);
+ corr.setUseParent(false);
corr.setRelative(true);
addPropertyMaker("space-after", m);
--
cgit v1.2.3
From f585893200a94a360b0e8f8015758aaf8f3ad2d7 Mon Sep 17 00:00:00 2001
From: Vincent Hennebert
Date: Thu, 13 Dec 2007 17:31:26 +0000
Subject: Ok, now /really/ revert the previous commit :-\
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@603961 13f79535-47bb-0310-9956-ffa450edef68
---
src/java/org/apache/fop/fo/FOPropertyMapping.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'src')
diff --git a/src/java/org/apache/fop/fo/FOPropertyMapping.java b/src/java/org/apache/fop/fo/FOPropertyMapping.java
index d393c1d7c..5d1a6f31a 100644
--- a/src/java/org/apache/fop/fo/FOPropertyMapping.java
+++ b/src/java/org/apache/fop/fo/FOPropertyMapping.java
@@ -1150,7 +1150,7 @@ public final class FOPropertyMapping implements Constants {
m.useGeneric(genericSpace);
corr = new SpacePropertyMaker(m);
corr.setCorresponding(PR_MARGIN_BOTTOM, PR_MARGIN_BOTTOM, PR_MARGIN_LEFT);
- corr.setUseParent(false);
+ corr.setUseParent(true);
corr.setRelative(true);
addPropertyMaker("space-after", m);
--
cgit v1.2.3
From ecf8547e04c4994fcb5017351ec63203f344cf7e Mon Sep 17 00:00:00 2001
From: Vincent Hennebert
Date: Thu, 13 Dec 2007 17:32:43 +0000
Subject: Style only: removed trailing white spaces
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@603962 13f79535-47bb-0310-9956-ffa450edef68
---
.../fop/fo/flow/table/ConditionalBorder.java | 2 +-
.../org/apache/fop/fo/flow/table/TableBody.java | 4 +-
.../org/apache/fop/fo/flow/table/TableFObj.java | 4 +-
.../properties/CommonBorderPaddingBackground.java | 107 ++++++++++-----------
4 files changed, 58 insertions(+), 59 deletions(-)
(limited to 'src')
diff --git a/src/java/org/apache/fop/fo/flow/table/ConditionalBorder.java b/src/java/org/apache/fop/fo/flow/table/ConditionalBorder.java
index e03e11a15..4f3cca046 100644
--- a/src/java/org/apache/fop/fo/flow/table/ConditionalBorder.java
+++ b/src/java/org/apache/fop/fo/flow/table/ConditionalBorder.java
@@ -199,6 +199,6 @@ public class ConditionalBorder {
static ConditionalBorder getDefaultBorder(CollapsingBorderModel collapsingBorderModel) {
BorderSpecification defaultBorderSpec = BorderSpecification.getDefaultBorder();
return new ConditionalBorder(defaultBorderSpec, defaultBorderSpec, defaultBorderSpec,
- collapsingBorderModel);
+ collapsingBorderModel);
}
}
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 c1453bdfa..dced3c062 100644
--- a/src/java/org/apache/fop/fo/flow/table/TableBody.java
+++ b/src/java/org/apache/fop/fo/flow/table/TableBody.java
@@ -138,7 +138,7 @@ public class TableBody extends TableCellContainer {
protected void finishLastRowGroup() throws ValidationException {
if (!inMarker()) {
- RowGroupBuilder rowGroupBuilder = getTable().getRowGroupBuilder();
+ RowGroupBuilder rowGroupBuilder = getTable().getRowGroupBuilder();
if (tableRowsFound) {
rowGroupBuilder.endRow(lastRow);
} else if (!lastCellEndsRow) {
@@ -211,7 +211,7 @@ public class TableBody extends TableCellContainer {
rowsStarted = true;
TableCell cell = (TableCell) child;
addTableCellChild(cell, firstRow);
- lastCellEndsRow = cell.endsRow();
+ lastCellEndsRow = cell.endsRow();
if (lastCellEndsRow) {
firstRow = false;
columnNumberManager.prepareForNextRow(pendingSpans);
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 4b90ccac3..9618d7ff4 100644
--- a/src/java/org/apache/fop/fo/flow/table/TableFObj.java
+++ b/src/java/org/apache/fop/fo/flow/table/TableFObj.java
@@ -48,7 +48,7 @@ public abstract class TableFObj extends FObj {
BorderSpecification borderEnd;
CollapsingBorderModel collapsingBorderModel;
-
+
/**
* Main constructor
*
@@ -208,7 +208,7 @@ public abstract class TableFObj extends FObj {
}
/*
- * TODO made public so that RetrieveMarker can access it.
+ * TODO made public so that RetrieveMarker can access it.
*/
/** {@inheritDoc} */
public void endOfNode() throws FOPException {
diff --git a/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java b/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java
index c5a4950f4..866a020e2 100755
--- a/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java
+++ b/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java
@@ -64,20 +64,20 @@ public class CommonBorderPaddingBackground {
* The "background-position-vertical" property.
*/
public Length backgroundPositionVertical;
-
-
+
+
private FopImage fopimage;
-
-
- /** the "before" edge */
+
+
+ /** the "before" edge */
public static final int BEFORE = 0;
- /** the "after" edge */
+ /** the "after" edge */
public static final int AFTER = 1;
- /** the "start" edge */
+ /** the "start" edge */
public static final int START = 2;
- /** the "end" edge */
+ /** the "end" edge */
public static final int END = 3;
-
+
public static class BorderInfo {
private int mStyle; // Enum for border style
private Color mColor; // Border color
@@ -88,15 +88,15 @@ public class CommonBorderPaddingBackground {
mWidth = width;
mColor = color;
}
-
+
public int getStyle() {
return this.mStyle;
}
-
+
public Color getColor() {
return this.mColor;
}
-
+
public CondLengthProperty getWidth() {
return this.mWidth;
}
@@ -109,7 +109,7 @@ public class CommonBorderPaddingBackground {
return mWidth.getLengthValue();
}
}
-
+
/** {@inheritDoc} */
public String toString() {
StringBuffer sb = new StringBuffer("BorderInfo");
@@ -204,9 +204,8 @@ public class CommonBorderPaddingBackground {
* Construct a CommonBorderPaddingBackground object.
*/
public CommonBorderPaddingBackground() {
-
}
-
+
/**
* Construct a CommonBorderPaddingBackground object.
*
@@ -214,7 +213,7 @@ public class CommonBorderPaddingBackground {
* @throws PropertyException if there's an error while binding the properties
*/
public CommonBorderPaddingBackground(PropertyList pList) throws PropertyException {
-
+
backgroundAttachment = pList.get(Constants.PR_BACKGROUND_ATTACHMENT).getEnum();
backgroundColor = pList.get(Constants.PR_BACKGROUND_COLOR).getColor(
pList.getFObj().getUserAgent());
@@ -231,7 +230,7 @@ public class CommonBorderPaddingBackground {
Constants.PR_BACKGROUND_POSITION_HORIZONTAL).getLength();
backgroundPositionVertical = pList.get(
Constants.PR_BACKGROUND_POSITION_VERTICAL).getLength();
-
+
//Additional processing: preload image
String url = ImageFactory.getURL(backgroundImage);
FOUserAgent userAgent = pList.getFObj().getUserAgent();
@@ -242,37 +241,37 @@ public class CommonBorderPaddingBackground {
} else {
// load dimensions
if (!fopimage.load(FopImage.DIMENSIONS)) {
- Property.log.error("Cannot read background image dimensions: "
+ Property.log.error("Cannot read background image dimensions: "
+ backgroundImage);
}
}
//TODO Report to caller so he can decide to throw an exception
}
- initBorderInfo(pList, BEFORE,
- Constants.PR_BORDER_BEFORE_COLOR,
- Constants.PR_BORDER_BEFORE_STYLE,
- Constants.PR_BORDER_BEFORE_WIDTH,
+ initBorderInfo(pList, BEFORE,
+ Constants.PR_BORDER_BEFORE_COLOR,
+ Constants.PR_BORDER_BEFORE_STYLE,
+ Constants.PR_BORDER_BEFORE_WIDTH,
Constants.PR_PADDING_BEFORE);
- initBorderInfo(pList, AFTER,
- Constants.PR_BORDER_AFTER_COLOR,
- Constants.PR_BORDER_AFTER_STYLE,
- Constants.PR_BORDER_AFTER_WIDTH,
+ initBorderInfo(pList, AFTER,
+ Constants.PR_BORDER_AFTER_COLOR,
+ Constants.PR_BORDER_AFTER_STYLE,
+ Constants.PR_BORDER_AFTER_WIDTH,
Constants.PR_PADDING_AFTER);
- initBorderInfo(pList, START,
- Constants.PR_BORDER_START_COLOR,
- Constants.PR_BORDER_START_STYLE,
- Constants.PR_BORDER_START_WIDTH,
+ initBorderInfo(pList, START,
+ Constants.PR_BORDER_START_COLOR,
+ Constants.PR_BORDER_START_STYLE,
+ Constants.PR_BORDER_START_WIDTH,
Constants.PR_PADDING_START);
- initBorderInfo(pList, END,
- Constants.PR_BORDER_END_COLOR,
- Constants.PR_BORDER_END_STYLE,
- Constants.PR_BORDER_END_WIDTH,
+ initBorderInfo(pList, END,
+ Constants.PR_BORDER_END_COLOR,
+ Constants.PR_BORDER_END_STYLE,
+ Constants.PR_BORDER_END_WIDTH,
Constants.PR_PADDING_END);
}
- private void initBorderInfo(PropertyList pList, int side,
+ private void initBorderInfo(PropertyList pList, int side,
int colorProp, int styleProp, int widthProp, int paddingProp)
throws PropertyException {
padding[side] = pList.get(paddingProp).getCondLength();
@@ -285,7 +284,7 @@ public class CommonBorderPaddingBackground {
pList.get(colorProp).getColor(ua)), side);
}
}
-
+
/**
* Sets a border.
* @param info the border information
@@ -294,7 +293,7 @@ public class CommonBorderPaddingBackground {
public void setBorderInfo(BorderInfo info, int side) {
this.borderInfo[side] = info;
}
-
+
/**
* @param side the side to retrieve
* @return the border info for a side
@@ -306,7 +305,7 @@ public class CommonBorderPaddingBackground {
return this.borderInfo[side];
}
}
-
+
/**
* Set padding.
* @param source the padding info to copy from
@@ -314,7 +313,7 @@ public class CommonBorderPaddingBackground {
public void setPadding(CommonBorderPaddingBackground source) {
this.padding = source.padding;
}
-
+
/**
* @return the background image as a preloaded FopImage, null if there is
* no background image.
@@ -322,7 +321,7 @@ public class CommonBorderPaddingBackground {
public FopImage getFopImage() {
return this.fopimage;
}
-
+
/**
* @param bDiscard indicates whether the .conditionality component should be
* considered (start of a reference-area)
@@ -405,7 +404,7 @@ public class CommonBorderPaddingBackground {
return padding[side].getLengthValue(context);
}
}
-
+
/**
* Returns the CondLengthProperty for the padding on one side.
* @param side the side
@@ -416,21 +415,21 @@ public class CommonBorderPaddingBackground {
}
/**
- * Return all the border and padding width in the inline progression
+ * Return all the border and padding width in the inline progression
* dimension.
* @param bDiscard the discard flag.
* @param context for percentage evaluation.
* @return all the padding and border width.
*/
public int getIPPaddingAndBorder(boolean bDiscard, PercentBaseContext context) {
- return getPaddingStart(bDiscard, context)
- + getPaddingEnd(bDiscard, context)
- + getBorderStartWidth(bDiscard)
- + getBorderEndWidth(bDiscard);
+ return getPaddingStart(bDiscard, context)
+ + getPaddingEnd(bDiscard, context)
+ + getBorderStartWidth(bDiscard)
+ + getBorderEndWidth(bDiscard);
}
-
+
/**
- * Return all the border and padding height in the block progression
+ * Return all the border and padding height in the block progression
* dimension.
* @param bDiscard the discard flag.
* @param context for percentage evaluation
@@ -438,7 +437,7 @@ public class CommonBorderPaddingBackground {
*/
public int getBPPaddingAndBorder(boolean bDiscard, PercentBaseContext context) {
return getPaddingBefore(bDiscard, context) + getPaddingAfter(bDiscard, context)
- + getBorderBeforeWidth(bDiscard) + getBorderAfterWidth(bDiscard);
+ + getBorderBeforeWidth(bDiscard) + getBorderAfterWidth(bDiscard);
}
/** {@inheritDoc} */
@@ -448,7 +447,7 @@ public class CommonBorderPaddingBackground {
+ getBorderStartWidth(false) + ", " + getBorderEndWidth(false) + ")\n"
+ "Border Colors: (" + getBorderColor(BEFORE) + ", " + getBorderColor(AFTER) + ", "
+ getBorderColor(START) + ", " + getBorderColor(END) + ")\n"
- + "Padding: (" + getPaddingBefore(false, null) + ", " + getPaddingAfter(false, null)
+ + "Padding: (" + getPaddingBefore(false, null) + ", " + getPaddingAfter(false, null)
+ ", " + getPaddingStart(false, null) + ", " + getPaddingEnd(false, null) + ")\n";
}
@@ -461,19 +460,19 @@ public class CommonBorderPaddingBackground {
/** @return true if border is non-zero. */
public boolean hasBorder() {
- return ((getBorderBeforeWidth(false) + getBorderAfterWidth(false)
+ return ((getBorderBeforeWidth(false) + getBorderAfterWidth(false)
+ getBorderStartWidth(false) + getBorderEndWidth(false)) > 0);
}
/**
* @param context for percentage based evaluation.
- * @return true if padding is non-zero.
+ * @return true if padding is non-zero.
*/
public boolean hasPadding(PercentBaseContext context) {
- return ((getPaddingBefore(false, context) + getPaddingAfter(false, context)
+ return ((getPaddingBefore(false, context) + getPaddingAfter(false, context)
+ getPaddingStart(false, context) + getPaddingEnd(false, context)) > 0);
}
-
+
/** @return true if there are any borders defined. */
public boolean hasBorderInfo() {
return (borderInfo[BEFORE] != null || borderInfo[AFTER] != null
--
cgit v1.2.3
From 7ed67aba5bec4a02c3a9ef237e42d6a3d6136808 Mon Sep 17 00:00:00 2001
From: Vincent Hennebert
Date: Thu, 13 Dec 2007 18:28:56 +0000
Subject: Fixed the handling of columns in the border resolution, especially in
case of column-spanning cells
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@603968 13f79535-47bb-0310-9956-ffa450edef68
---
.../fo/flow/table/CollapsingBorderResolver.java | 14 +++++--
.../org/apache/fop/fo/flow/table/TableCell.java | 11 +-----
.../table_border-collapse_collapse_resolution.xml | 45 ++++++++++++++++++++++
..._border-collapse_collapse_resolution_no-col.xml | 3 +-
4 files changed, 60 insertions(+), 13 deletions(-)
(limited to 'src')
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 f92f7bb30..f59019b92 100644
--- a/src/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.java
+++ b/src/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.java
@@ -205,14 +205,22 @@ class CollapsingBorderResolver implements BorderResolver {
// Resolve start/end borders in the row
Iterator guIter = row.iterator();
GridUnit gu = (GridUnit) guIter.next();
+ Iterator colIter = table.getColumns().iterator();
+ TableColumn col = (TableColumn) colIter.next();
+ gu.integrateBorderSegment(CommonBorderPaddingBackground.START, col);
gu.integrateBorderSegment(CommonBorderPaddingBackground.START, container);
while (guIter.hasNext()) {
- GridUnit guEnd = (GridUnit) guIter.next();
+ GridUnit nextGU = (GridUnit) guIter.next();
+ TableColumn nextCol = (TableColumn) colIter.next();
if (gu.isLastGridUnitColSpan()) {
- gu.resolveBorder(guEnd, CommonBorderPaddingBackground.END);
+ gu.integrateBorderSegment(CommonBorderPaddingBackground.END, col);
+ nextGU.integrateBorderSegment(CommonBorderPaddingBackground.START, nextCol);
+ gu.resolveBorder(nextGU, CommonBorderPaddingBackground.END);
}
- gu = guEnd;
+ gu = nextGU;
+ col = nextCol;
}
+ gu.integrateBorderSegment(CommonBorderPaddingBackground.END, col);
gu.integrateBorderSegment(CommonBorderPaddingBackground.END, container);
}
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 f85d0e97e..80dbe5e2a 100644
--- a/src/java/org/apache/fop/fo/flow/table/TableCell.java
+++ b/src/java/org/apache/fop/fo/flow/table/TableCell.java
@@ -138,15 +138,8 @@ public class TableCell extends TableFObj {
protected void setCollapsedBorders() {
createBorder(CommonBorderPaddingBackground.BEFORE);
createBorder(CommonBorderPaddingBackground.AFTER);
- Table table = getTable();
- if (table.hasExplicitColumns()) {
- TableColumn col = table.getColumn(getColumnNumber() - 1);
- createBorder(CommonBorderPaddingBackground.START, col);
- createBorder(CommonBorderPaddingBackground.END, col);
- } else {
- createBorder(CommonBorderPaddingBackground.START);
- createBorder(CommonBorderPaddingBackground.END);
- }
+ createBorder(CommonBorderPaddingBackground.START);
+ createBorder(CommonBorderPaddingBackground.END);
}
/** {@inheritDoc} */
diff --git a/test/layoutengine/standard-testcases/table_border-collapse_collapse_resolution.xml b/test/layoutengine/standard-testcases/table_border-collapse_collapse_resolution.xml
index 6aa054d7d..20cabace2 100644
--- a/test/layoutengine/standard-testcases/table_border-collapse_collapse_resolution.xml
+++ b/test/layoutengine/standard-testcases/table_border-collapse_collapse_resolution.xml
@@ -166,6 +166,30 @@
+
+ Between tables
+
+
+
+
+
+
+ Cell 1.1
+
+
+
+
+ Cell 2.1
+
+
+ Cell 2.2
+
+
+
+
+
After the tables
@@ -333,5 +357,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/layoutengine/standard-testcases/table_border-collapse_collapse_resolution_no-col.xml b/test/layoutengine/standard-testcases/table_border-collapse_collapse_resolution_no-col.xml
index b9b5c49b9..c0538b2e0 100644
--- a/test/layoutengine/standard-testcases/table_border-collapse_collapse_resolution_no-col.xml
+++ b/test/layoutengine/standard-testcases/table_border-collapse_collapse_resolution_no-col.xml
@@ -20,7 +20,8 @@
--
cgit v1.2.3
From 757fdc23d3f01bd940dc13cb1920ac2daf40a56c Mon Sep 17 00:00:00 2001
From: Vincent Hennebert
Date: Thu, 13 Dec 2007 18:52:48 +0000
Subject: Removed parameter from the endPart method, since the part is already
passed as a parameter of the previously called startPart method
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@603975 13f79535-47bb-0310-9956-ffa450edef68
---
src/java/org/apache/fop/fo/flow/table/BorderResolver.java | 4 +---
src/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.java | 2 +-
src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java | 2 +-
src/java/org/apache/fop/fo/flow/table/SeparateBorderResolver.java | 2 +-
4 files changed, 4 insertions(+), 6 deletions(-)
(limited to 'src')
diff --git a/src/java/org/apache/fop/fo/flow/table/BorderResolver.java b/src/java/org/apache/fop/fo/flow/table/BorderResolver.java
index 0a8f3d39e..5322b08d3 100644
--- a/src/java/org/apache/fop/fo/flow/table/BorderResolver.java
+++ b/src/java/org/apache/fop/fo/flow/table/BorderResolver.java
@@ -44,10 +44,8 @@ interface BorderResolver {
/**
* Receives notification of the end of a table-header/footer/body.
- *
- * @param part the part that has ended
*/
- void endPart(TableBody part);
+ void endPart();
/**
* Receives notification of the end of the table.
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 f59019b92..16fc55cfc 100644
--- a/src/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.java
+++ b/src/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.java
@@ -393,7 +393,7 @@ class CollapsingBorderResolver implements BorderResolver {
}
/** {@inheritDoc} */
- public void endPart(TableBody part) {
+ public void endPart() {
delegate.endPart();
}
diff --git a/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java b/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java
index a5c0b1b8b..f87ed47f3 100644
--- a/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java
+++ b/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java
@@ -170,7 +170,7 @@ class FixedColRowGroupBuilder extends RowGroupBuilder {
"A table-cell is spanning more rows than available in its parent element.");
}
setFlagForCols(GridUnit.LAST_IN_PART, lastRow);
- borderResolver.endPart(tableBody);
+ borderResolver.endPart();
inFooter = false;
}
diff --git a/src/java/org/apache/fop/fo/flow/table/SeparateBorderResolver.java b/src/java/org/apache/fop/fo/flow/table/SeparateBorderResolver.java
index 37e3cb6e8..c6d46ecf5 100644
--- a/src/java/org/apache/fop/fo/flow/table/SeparateBorderResolver.java
+++ b/src/java/org/apache/fop/fo/flow/table/SeparateBorderResolver.java
@@ -35,7 +35,7 @@ class SeparateBorderResolver implements BorderResolver {
}
/** {@inheritDoc} */
- public void endPart(TableBody part) {
+ public void endPart() {
}
/** {@inheritDoc} */
--
cgit v1.2.3
From 4090cb592401b107f4a560fede22b27ffc41667d Mon Sep 17 00:00:00 2001
From: Vincent Hennebert
Date: Thu, 13 Dec 2007 18:57:25 +0000
Subject: Removed parameter from the endTablePart method, as the part is
already passed as as a parameter of the previously called startTablePart
method
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@603979 13f79535-47bb-0310-9956-ffa450edef68
---
src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java | 2 +-
src/java/org/apache/fop/fo/flow/table/RowGroupBuilder.java | 3 +--
src/java/org/apache/fop/fo/flow/table/TableBody.java | 2 +-
src/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java | 4 ++--
4 files changed, 5 insertions(+), 6 deletions(-)
(limited to 'src')
diff --git a/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java b/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java
index f87ed47f3..7df071191 100644
--- a/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java
+++ b/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java
@@ -164,7 +164,7 @@ class FixedColRowGroupBuilder extends RowGroupBuilder {
}
/** {@inheritDoc} */
- void endTablePart(TableBody tableBody) throws ValidationException {
+ void endTablePart() throws ValidationException {
if (rows.size() > 0) {
throw new ValidationException(
"A table-cell is spanning more rows than available in its parent element.");
diff --git a/src/java/org/apache/fop/fo/flow/table/RowGroupBuilder.java b/src/java/org/apache/fop/fo/flow/table/RowGroupBuilder.java
index 220eff85b..f25886581 100644
--- a/src/java/org/apache/fop/fo/flow/table/RowGroupBuilder.java
+++ b/src/java/org/apache/fop/fo/flow/table/RowGroupBuilder.java
@@ -77,10 +77,9 @@ abstract class RowGroupBuilder {
* row-group is checked for emptiness. This row group builder is reset for handling
* further possible table parts.
*
- * @param tableBody the table part being ended
* @throws ValidationException if a row-spanning cell overflows the given table part
*/
- abstract void endTablePart(TableBody tableBody) throws ValidationException;
+ abstract void endTablePart() throws ValidationException;
/**
* Receives notification of the end of the table.
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 dced3c062..7df1ed0a7 100644
--- a/src/java/org/apache/fop/fo/flow/table/TableBody.java
+++ b/src/java/org/apache/fop/fo/flow/table/TableBody.java
@@ -145,7 +145,7 @@ public class TableBody extends TableCellContainer {
rowGroupBuilder.endRow(this);
}
try {
- rowGroupBuilder.endTablePart(this);
+ rowGroupBuilder.endTablePart();
} catch (ValidationException e) {
e.setLocator(locator);
throw e;
diff --git a/src/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java b/src/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java
index 66322b1b7..47c96dcca 100644
--- a/src/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java
+++ b/src/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java
@@ -91,11 +91,11 @@ class VariableColRowGroupBuilder extends RowGroupBuilder {
}
/** {@inheritDoc} */
- void endTablePart(final TableBody tableBody) throws ValidationException {
+ void endTablePart() throws ValidationException {
// TODO catch the ValidationException sooner?
events.add(new Event() {
public void play(RowGroupBuilder rowGroupBuilder) throws ValidationException {
- rowGroupBuilder.endTablePart(tableBody);
+ rowGroupBuilder.endTablePart();
}
});
}
--
cgit v1.2.3
From 61a2bba18f742acc0d1404e77af3db921ce410c3 Mon Sep 17 00:00:00 2001
From: Vincent Hennebert
Date: Thu, 13 Dec 2007 19:17:12 +0000
Subject: Throw a ValidationException if table-footer is put after table-body
and the table uses the collapsing border model. The footer must be known to
properly resolve borders.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@603990 13f79535-47bb-0310-9956-ffa450edef68
---
src/java/org/apache/fop/fo/flow/table/Table.java | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
(limited to 'src')
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 4933ab4dc..a915edf87 100644
--- a/src/java/org/apache/fop/fo/flow/table/Table.java
+++ b/src/java/org/apache/fop/fo/flow/table/Table.java
@@ -192,9 +192,17 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder {
tooManyNodesError(loc, "table-footer");
} else {
tableFooterFound = true;
- if (tableBodyFound && getUserAgent().validateStrictly()) {
- nodesOutOfOrderError(loc, "fo:table-footer",
- "(table-body+)");
+ if (tableBodyFound) {
+ if (getUserAgent().validateStrictly()) {
+ nodesOutOfOrderError(loc, "fo:table-footer", "(table-body+)");
+ } else if (!isSeparateBorderModel()) {
+ nodesOutOfOrderError(loc, "fo:table-footer", "(table-body+)."
+ + " This table uses the collapsing border"
+ + " model. In order to resolve borders in an efficient way"
+ + " the table-footer must be known before any table-body"
+ + " is parsed. Either put the footer at the correct place"
+ + " or switch to the separate border model");
+ }
}
}
} else if ("table-body".equals(localName)) {
--
cgit v1.2.3
From c6363fe8a30d2d5c6fa6f588966a35f4352f7ac0 Mon Sep 17 00:00:00 2001
From: Vincent Hennebert
Date: Fri, 14 Dec 2007 11:32:51 +0000
Subject: Clean up: removed all reset and resetPosition methods, which pre-date
the Knuth era and are no longer needed
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@604171 13f79535-47bb-0310-9956-ffa450edef68
---
.../fop/layoutmgr/AbstractLayoutManager.java | 39 ----------------------
.../fop/layoutmgr/BlockContainerLayoutManager.java | 9 -----
.../apache/fop/layoutmgr/BlockLayoutManager.java | 13 --------
.../apache/fop/layoutmgr/FlowLayoutManager.java | 8 -----
.../org/apache/fop/layoutmgr/LayoutManager.java | 7 ----
.../fop/layoutmgr/inline/ContentLayoutManager.java | 7 ----
.../inline/InlineStackingLayoutManager.java | 35 -------------------
.../fop/layoutmgr/inline/LineLayoutManager.java | 27 ---------------
.../fop/layoutmgr/inline/TextLayoutManager.java | 30 -----------------
.../fop/layoutmgr/list/ListBlockLayoutManager.java | 13 --------
.../list/ListItemContentLayoutManager.java | 14 --------
.../fop/layoutmgr/list/ListItemLayoutManager.java | 11 ------
.../table/TableAndCaptionLayoutManager.java | 11 ------
.../layoutmgr/table/TableCaptionLayoutManager.java | 11 ------
.../layoutmgr/table/TableCellLayoutManager.java | 11 ------
.../fop/layoutmgr/table/TableLayoutManager.java | 11 ------
16 files changed, 257 deletions(-)
(limited to 'src')
diff --git a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
index 21af512fc..f0365d0e4 100644
--- a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
@@ -129,45 +129,6 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager
return childLMiter.hasNext();
}
- /**
- * Reset the layoutmanager "iterator" so that it will start
- * with the passed Position's generating LM
- * on the next call to getChildLM.
- * @param pos a Position returned by a child layout manager
- * representing a potential break decision.
- * If pos is null, then back up to the first child LM.
- */
- protected void reset(org.apache.fop.layoutmgr.Position pos) {
- //if (lm == null) return;
- LayoutManager lm = (pos != null) ? pos.getLM() : null;
- if (curChildLM != lm) {
- // ASSERT curChildLM == (LayoutManager)childLMiter.previous()
- if (childLMiter.hasPrevious() && curChildLM
- != (LayoutManager) childLMiter.previous()) {
- //log.error("LMiter problem!");
- }
- while (curChildLM != lm && childLMiter.hasPrevious()) {
- curChildLM.resetPosition(null);
- curChildLM = (LayoutManager) childLMiter.previous();
- }
- // Otherwise next returns same object
- childLMiter.next();
- }
- if (curChildLM != null) {
- curChildLM.resetPosition(pos);
- }
- if (isFinished()) {
- setFinished(false);
- }
- }
-
- /** {@inheritDoc} */
- public void resetPosition(Position resetPos) {
- // if (resetPos == null) {
- // reset(null);
- // }
- }
-
/**
* Tell whether this LayoutManager has handled all of its content.
* @return True if there are no more break possibilities,
diff --git a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
index 9c3c8ce59..03aa380d2 100644
--- a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
@@ -938,15 +938,6 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
}
}
- /**
- * {@inheritDoc}
- */
- public void resetPosition(Position resetPos) {
- if (resetPos == null) {
- reset(null);
- }
- }
-
/**
* Force current area to be added to parent area.
* {@inheritDoc}
diff --git a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
index 62e41ac16..bb39def8d 100644
--- a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
@@ -476,19 +476,6 @@ public class BlockLayoutManager extends BlockStackingLayoutManager
}
}
- /**
- * {@inheritDoc}
- */
- public void resetPosition(Position resetPos) {
- if (resetPos == null) {
- reset(null);
- childBreaks.clear();
- } else {
- //reset(resetPos);
- LayoutManager lm = resetPos.getLM();
- }
- }
-
/**
* convenience method that returns the Block node
* @return the block node
diff --git a/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java b/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
index f5d912111..a70dd0883 100644
--- a/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
@@ -342,14 +342,6 @@ public class FlowLayoutManager extends BlockStackingLayoutManager
return parentArea;
}
- /**
- * {@inheritDoc}
- */
- public void resetPosition(Position resetPos) {
- if (resetPos == null) {
- reset(null);
- }
- }
/**
* Returns the IPD of the content area
* @return the IPD of the content area
diff --git a/src/java/org/apache/fop/layoutmgr/LayoutManager.java b/src/java/org/apache/fop/layoutmgr/LayoutManager.java
index 39b970682..0b17c9a27 100644
--- a/src/java/org/apache/fop/layoutmgr/LayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/LayoutManager.java
@@ -58,13 +58,6 @@ public interface LayoutManager extends PercentBaseContext {
*/
PageSequenceLayoutManager getPSLM();
- /**
- * Reset to the position.
- *
- * @param position the Position to reset to
- */
- void resetPosition(Position position);
-
/**
* Return a value indicating whether this LayoutManager has laid out
* all its content (or generated BreakPossibilities for all content.)
diff --git a/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java
index 22a01f9fb..03e9b382a 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java
@@ -212,13 +212,6 @@ public class ContentLayoutManager extends AbstractBaseLayoutManager
//to be done
}
- /**
- * {@inheritDoc}
- */
- public void resetPosition(Position position) {
- //to be done
- }
-
/**
* {@inheritDoc}
*/
diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java
index 7da7cc49f..4d0872a6d 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java
@@ -154,41 +154,6 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager
return null;
}
- /**
- * Reset position for returning next BreakPossibility.
- * @param prevPos a Position returned by this layout manager
- * representing a potential break decision.
- */
- public void resetPosition(Position prevPos) {
- if (prevPos != null) {
- // ASSERT (prevPos.getLM() == this)
- if (prevPos.getLM() != this) {
- //getLogger().error(
- // "InlineStackingLayoutManager.resetPosition: " +
- // "LM mismatch!!!");
- }
- // Back up the child LM Position
- Position childPos = prevPos.getPosition();
- reset(childPos);
- /*
- if (prevBP != null
- && prevBP.getLayoutManager() != childPos.getLM()) {
- childLC = null;
- }
- prevBP = new BreakPoss(childPos);
- */
- } else {
- // Backup to start of first child layout manager
- //prevBP = null;
- // super.resetPosition(prevPos);
- reset(prevPos);
- // If any areas created, we are restarting!
- bAreaCreated = false;
- }
- // Do we need to reset some context like pending or prevContent?
- // What about prevBP?
- }
-
/**
* TODO: Explain this method
* @param lm ???
diff --git a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
index e722162d8..6df7ac00c 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
@@ -1555,33 +1555,6 @@ public class LineLayoutManager extends InlineStackingLayoutManager
}
}
- /**
- * Reset the positions to the given position.
- *
- * @param resetPos the position to reset to
- */
- public void resetPosition(Position resetPos) {
- if (resetPos == null) {
- setFinished(false);
- iReturnedLBP = 0;
- } else {
- if (isFinished()) {
- // if isFinished is true, iReturned LBP == breakpoints.size()
- // and breakpoints.get(iReturnedLBP) would generate
- // an IndexOutOfBoundException
- setFinished(false);
- iReturnedLBP--;
- }
- // It is not clear that the member lineLayouts has the correct value;
- // because the method is not called, this cannot be checked.
- while ((LineBreakPosition) lineLayouts.getChosenPosition(iReturnedLBP)
- != (LineBreakPosition) resetPos) {
- iReturnedLBP--;
- }
- iReturnedLBP++;
- }
- }
-
/**
* Add the areas with the break points.
*
diff --git a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
index 63f11147c..40e1c087a 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
@@ -224,36 +224,6 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
}
- /**
- * Reset position for returning next BreakPossibility.
- *
- * @param prevPos the position to reset to
- */
- public void resetPosition(Position prevPos) {
- if (prevPos != null) {
- // ASSERT (prevPos.getLM() == this)
- if (prevPos.getLM() != this) {
- log.error("TextLayoutManager.resetPosition: "
- + "LM mismatch!!!");
- }
- LeafPosition tbp = (LeafPosition) prevPos;
- AreaInfo ai = (AreaInfo) vecAreaInfo.get(tbp.getLeafPos());
- if (ai.iBreakIndex != iNextStart) {
- iNextStart = ai.iBreakIndex;
- vecAreaInfo.ensureCapacity(tbp.getLeafPos() + 1);
- // TODO: reset or recalculate total IPD = sum of all word IPD
- // up to the break position
- ipdTotal = ai.ipdArea;
- setFinished(false);
- }
- } else {
- // Reset to beginning!
- vecAreaInfo.clear();
- iNextStart = 0;
- setFinished(false);
- }
- }
-
// TODO: see if we can use normal getNextBreakPoss for this with
// extra hyphenation information in LayoutContext
private boolean getHyphenIPD(HyphContext hc, MinOptMax hyphIPD) {
diff --git a/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
index acd9bf718..470cbbe9c 100644
--- a/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
@@ -277,19 +277,6 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager
}
}
- /**
- * Reset the position of this layout manager.
- *
- * @param resetPos the position to reset to
- */
- public void resetPosition(Position resetPos) {
- if (resetPos == null) {
- reset(null);
- } else {
- //TODO Something to put here?
- }
- }
-
/** {@inheritDoc} */
public boolean mustKeepTogether() {
//TODO Keeps will have to be more sophisticated sooner or later
diff --git a/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java
index e1171d6fd..853b1a128 100644
--- a/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java
@@ -220,20 +220,6 @@ public class ListItemContentLayoutManager extends BlockStackingLayoutManager {
}
}
- /**
- * Reset the position of the layout.
- *
- * @param resetPos the position to reset to
- */
- public void resetPosition(Position resetPos) {
- if (resetPos == null) {
- reset(null);
- } else {
- setFinished(false);
- //reset(resetPos);
- }
- }
-
/** {@inheritDoc} */
public boolean mustKeepTogether() {
//TODO Keeps will have to be more sophisticated sooner or later
diff --git a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
index 7b7cb52b0..dc28e98e2 100644
--- a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
@@ -623,17 +623,6 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager
}
}
- /**
- * Reset the position of this layout manager.
- *
- * @param resetPos the position to reset to
- */
- public void resetPosition(Position resetPos) {
- if (resetPos == null) {
- reset(null);
- }
- }
-
/** {@inheritDoc} */
public boolean mustKeepTogether() {
//TODO Keeps will have to be more sophisticated sooner or later
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java
index 55b67053f..6d2e49e96 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java
@@ -194,16 +194,5 @@ public class TableAndCaptionLayoutManager extends BlockStackingLayoutManager {
curBlockArea.addBlock((Block) childArea);
}
}
-
- /**
- * Reset the position of this layout manager.
- *
- * @param resetPos the position to reset to
- */
- public void resetPosition(Position resetPos) {
- if (resetPos == null) {
- reset(null);
- }
- }
}
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java
index 58c85e8cd..4c21df937 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java
@@ -193,16 +193,5 @@ public class TableCaptionLayoutManager extends BlockStackingLayoutManager {
curBlockArea.addBlock((Block) childArea);
}
}
-
- /**
- * Reset the layout position.
- *
- * @param resetPos the position to reset to
- */
- public void resetPosition(Position resetPos) {
- if (resetPos == null) {
- reset(null);
- }
- }
}
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
index 46bdecf63..63810e057 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
@@ -504,17 +504,6 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager
}
}
- /**
- * Reset the position of the layout.
- *
- * @param resetPos the position to reset to
- */
- public void resetPosition(Position resetPos) {
- if (resetPos == null) {
- reset(null);
- }
- }
-
/**
* {@inheritDoc}
*/
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
index e33773695..2e366f36d 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
@@ -404,17 +404,6 @@ public class TableLayoutManager extends BlockStackingLayoutManager
}
}
- /**
- * Reset the position of this layout manager.
- *
- * @param resetPos the position to reset to
- */
- public void resetPosition(Position resetPos) {
- if (resetPos == null) {
- reset(null);
- }
- }
-
/** {@inheritDoc} */
public int negotiateBPDAdjustment(int adj, KnuthElement lastElement) {
// TODO Auto-generated method stub
--
cgit v1.2.3
From 79d9dab416b7676bbb914dcecd80416a422b5c48 Mon Sep 17 00:00:00 2001
From: Vincent Hennebert
Date: Fri, 14 Dec 2007 12:23:10 +0000
Subject: Reduced visibility of methods from public to package-private
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@604180 13f79535-47bb-0310-9956-ffa450edef68
---
src/java/org/apache/fop/layoutmgr/table/RowPainter.java | 8 ++++----
.../fop/layoutmgr/table/TableContentLayoutManager.java | 16 ++++++++--------
2 files changed, 12 insertions(+), 12 deletions(-)
(limited to 'src')
diff --git a/src/java/org/apache/fop/layoutmgr/table/RowPainter.java b/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
index 1ea0d308e..73cce29e4 100644
--- a/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
+++ b/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
@@ -79,7 +79,7 @@ class RowPainter {
private int[] partBPD;
private TableContentLayoutManager tclm;
- public RowPainter(TableContentLayoutManager tclm, LayoutContext layoutContext) {
+ RowPainter(TableContentLayoutManager tclm, LayoutContext layoutContext) {
this.tclm = tclm;
this.layoutContext = layoutContext;
this.colCount = tclm.getColumns().getColumnCount();
@@ -91,7 +91,7 @@ class RowPainter {
Arrays.fill(end, -1);
}
- public int getAccumulatedBPD() {
+ int getAccumulatedBPD() {
return this.accumulatedBPD;
}
@@ -101,7 +101,7 @@ class RowPainter {
*
* @param tcpos a position representing the row fragment
*/
- public void handleTableContentPosition(TableContentPosition tcpos) {
+ void handleTableContentPosition(TableContentPosition tcpos) {
if (lastRow != tcpos.row && lastRow != null) {
addAreasAndFlushRow(false);
}
@@ -146,7 +146,7 @@ class RowPainter {
* part
* @return the height of the (grid) row
*/
- public int addAreasAndFlushRow(boolean forcedFlush) {
+ int addAreasAndFlushRow(boolean forcedFlush) {
int actualRowHeight = 0;
int bt = lastRow.getBodyType();
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
index bcd7f0244..fca0557b7 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
@@ -74,7 +74,7 @@ public class TableContentLayoutManager implements PercentBaseContext {
* Main constructor
* @param parent Parent layout manager
*/
- public TableContentLayoutManager(TableLayoutManager parent) {
+ TableContentLayoutManager(TableLayoutManager parent) {
this.tableLM = parent;
Table table = getTableLM().getTable();
this.bodyIter = new TableRowIterator(table, TableRowIterator.BODY);
@@ -89,7 +89,7 @@ public class TableContentLayoutManager implements PercentBaseContext {
/**
* @return the table layout manager
*/
- public TableLayoutManager getTableLM() {
+ TableLayoutManager getTableLM() {
return this.tableLM;
}
@@ -101,7 +101,7 @@ public class TableContentLayoutManager implements PercentBaseContext {
/**
* @return the column setup of this table
*/
- public ColumnSetup getColumns() {
+ ColumnSetup getColumns() {
return getTableLM().getColumns();
}
@@ -281,7 +281,7 @@ public class TableContentLayoutManager implements PercentBaseContext {
* @param parentIter the position iterator
* @param layoutContext the layout context for adding areas
*/
- public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) {
+ void addAreas(PositionIterator parentIter, LayoutContext layoutContext) {
this.usedBPD = 0;
RowPainter painter = new RowPainter(this, layoutContext);
@@ -437,7 +437,7 @@ public class TableContentLayoutManager implements PercentBaseContext {
* @param row the table-row object or null
* @return the row area or null if there's no background to paint
*/
- public Block getRowArea(TableRow row) {
+ Block getRowArea(TableRow row) {
if (row == null || !row.getCommonBorderPaddingBackground().hasBackground()) {
return null;
} else {
@@ -455,7 +455,7 @@ public class TableContentLayoutManager implements PercentBaseContext {
* @param ipd inline-progression-dimension of the row
* @param yoffset Y offset at which to paint
*/
- public void addRowBackgroundArea(TableRow row, int bpd, int ipd, int yoffset) {
+ void addRowBackgroundArea(TableRow row, int bpd, int ipd, int yoffset) {
//Add row background if any
Block rowBackground = getRowArea(row);
if (rowBackground != null) {
@@ -474,14 +474,14 @@ public class TableContentLayoutManager implements PercentBaseContext {
* Sets the overall starting x-offset. Used for proper placement of cells.
* @param startXOffset starting x-offset (table's start-indent)
*/
- public void setStartXOffset(int startXOffset) {
+ void setStartXOffset(int startXOffset) {
this.startXOffset = startXOffset;
}
/**
* @return the amount of block-progression-dimension used by the content
*/
- public int getUsedBPD() {
+ int getUsedBPD() {
return this.usedBPD;
}
--
cgit v1.2.3
From 00ba9d896e3138faa1ceeff440dbcfad7808b194 Mon Sep 17 00:00:00 2001
From: Adrian Cumiskey
Date: Fri, 14 Dec 2007 13:16:06 +0000
Subject: Fixed copy constructor
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@604185 13f79535-47bb-0310-9956-ffa450edef68
---
src/java/org/apache/fop/render/afp/AFPGraphics2D.java | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
(limited to 'src')
diff --git a/src/java/org/apache/fop/render/afp/AFPGraphics2D.java b/src/java/org/apache/fop/render/afp/AFPGraphics2D.java
index bdd33f3de..a64b77d35 100644
--- a/src/java/org/apache/fop/render/afp/AFPGraphics2D.java
+++ b/src/java/org/apache/fop/render/afp/AFPGraphics2D.java
@@ -89,13 +89,18 @@ public class AFPGraphics2D extends AbstractGraphics2D {
}
/**
- * Creates a new AbstractGraphics2D from an existing instance.
+ * Creates a new AFPGraphics2D from an existing instance.
*
* @param g
- * the AbstractGraphics2D whose properties should be copied
+ * the AFPGraphics2D whose properties should be copied
*/
public AFPGraphics2D(AFPGraphics2D g) {
super(g);
+ this.graphicsObj = g.graphicsObj;
+ this.fallbackTextHandler = g.fallbackTextHandler;
+ this.customTextHandler = g.customTextHandler;
+ this.afpInfo = g.afpInfo;
+ this.afpState = g.afpState;
}
/**
--
cgit v1.2.3
From aaa21e830458ecfb4043237325e86b486a5a3bad Mon Sep 17 00:00:00 2001
From: Jeremias Maerki
Date: Fri, 14 Dec 2007 20:58:53 +0000
Subject: Bugfix: DecodeParms -> DecodeParams (introduced when I changed to
generic PDF structures) (fixes CCITT encoded images)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@604293 13f79535-47bb-0310-9956-ffa450edef68
---
src/java/org/apache/fop/pdf/PDFFilterList.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'src')
diff --git a/src/java/org/apache/fop/pdf/PDFFilterList.java b/src/java/org/apache/fop/pdf/PDFFilterList.java
index 8004e1e60..ab7439bd5 100644
--- a/src/java/org/apache/fop/pdf/PDFFilterList.java
+++ b/src/java/org/apache/fop/pdf/PDFFilterList.java
@@ -296,7 +296,7 @@ public class PDFFilterList {
private String buildDecodeParms(List parms) {
StringBuffer sb = new StringBuffer();
boolean needParmsEntry = false;
- sb.append("\n/DecodeParms ");
+ sb.append("\n/DecodeParams ");
if (parms.size() > 1) {
sb.append("[ ");
--
cgit v1.2.3
From 96f18dd5f91bd4189f1a7c62b9a49f80c67984fe Mon Sep 17 00:00:00 2001
From: Jeremias Maerki
Date: Fri, 14 Dec 2007 21:24:14 +0000
Subject: Don't hack when you're tired! Reverting r604293 and instead fixing
the right value. It's DecodeParams -> DecodeParms!
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@604299 13f79535-47bb-0310-9956-ffa450edef68
---
src/java/org/apache/fop/pdf/PDFFilterList.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
(limited to 'src')
diff --git a/src/java/org/apache/fop/pdf/PDFFilterList.java b/src/java/org/apache/fop/pdf/PDFFilterList.java
index ab7439bd5..e866fc88e 100644
--- a/src/java/org/apache/fop/pdf/PDFFilterList.java
+++ b/src/java/org/apache/fop/pdf/PDFFilterList.java
@@ -296,7 +296,7 @@ public class PDFFilterList {
private String buildDecodeParms(List parms) {
StringBuffer sb = new StringBuffer();
boolean needParmsEntry = false;
- sb.append("\n/DecodeParams ");
+ sb.append("\n/DecodeParms ");
if (parms.size() > 1) {
sb.append("[ ");
@@ -335,9 +335,9 @@ public class PDFFilterList {
}
if (array.length() > 0 & needParmsEntry) {
if (array.length() > 1) {
- dict.put("DecodeParams", array);
+ dict.put("DecodeParms", array);
} else {
- dict.put("DecodeParams", array.get(0));
+ dict.put("DecodeParms", array.get(0));
}
}
}
--
cgit v1.2.3
From 4f9fc957bdb3b4a1ecf9af8f6ed9aabf238a5022 Mon Sep 17 00:00:00 2001
From: "Andreas L. Delmelle"
Date: Sun, 16 Dec 2007 19:54:00 +0000
Subject: Streamlining/Correction of the changes made in r603926 - delegate
validation of the fo:wrapper's children to the parent: added static
FONode.validateChildNode() - narrow the condition for processing
text-childnodes: this is not only constrained to fo:flow and
fo:static-content, but the same goes for a fo:wrapper that is a direct
descendant of a fo:block-container or fo:inline-container, which only allow
block-level content (interpretation) - minor javadoc fixups/improvements
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@604678 13f79535-47bb-0310-9956-ffa450edef68
---
src/java/org/apache/fop/fo/FONode.java | 44 ++++++++++++++++++++++++----
src/java/org/apache/fop/fo/flow/Wrapper.java | 35 +++++++++-------------
2 files changed, 52 insertions(+), 27 deletions(-)
(limited to 'src')
diff --git a/src/java/org/apache/fop/fo/FONode.java b/src/java/org/apache/fop/fo/FONode.java
index cb884781a..7c517e418 100644
--- a/src/java/org/apache/fop/fo/FONode.java
+++ b/src/java/org/apache/fop/fo/FONode.java
@@ -45,6 +45,7 @@ public abstract class FONode implements Cloneable {
/** the XSL-FO namespace URI */
protected static final String FO_URI = FOElementMapping.URI;
+ /** FOP's proprietary extension namespace URI */
protected static final String FOX_URI = ExtensionElementMapping.URI;
/** Parent FO node */
@@ -197,11 +198,13 @@ public abstract class FONode implements Cloneable {
/**
* Checks to make sure, during SAX processing of input document, that the
* incoming node is valid for the this (parent) node (e.g., checking to
- * see that fo:table is not an immediate child of fo:root)
- * called within FObj constructor
+ * see that fo:table
is not an immediate child of fo:root
)
+ * called from {@link FOTreeBuilder#startElement(String, String, String, Attributes)}
+ * before constructing the child {@link FObj}.
+ *
* @param loc location in the FO source file
* @param namespaceURI namespace of incoming node
- * @param localName (e.g. "table" for "fo:table")
+ * @param localName name of the incoming node (without namespace prefix)
* @throws ValidationException if incoming node not valid for parent
*/
protected void validateChildNode(Locator loc, String namespaceURI, String localName)
@@ -209,6 +212,27 @@ public abstract class FONode implements Cloneable {
//nop
}
+ /**
+ * Static version of {@link FONode#validateChildNode(Locator, String, String)} that
+ * can be used by subclasses that need to validate children against a different node
+ * (for example: fo:wrapper
needs to check if the incoming node is a
+ * valid child to its parent)
+ *
+ * @param fo the FONode to validate against
+ * @param loc location in the source file
+ * @param namespaceURI namespace of the incoming node
+ * @param localName name of the incoming node (without namespace prefix)
+ * @throws ValidationException if the incoming node is not a valid child for the given FO
+ */
+ protected static void validateChildNode(
+ FONode fo,
+ Locator loc,
+ String namespaceURI,
+ String localName)
+ throws ValidationException {
+ fo.validateChildNode(loc, namespaceURI, localName);
+ }
+
/**
* Adds characters (does nothing here)
* @param data array of characters containing text to be added
@@ -572,8 +596,8 @@ public abstract class FONode implements Cloneable {
}
/**
- * Returns the Constants class integer value of this node
- * @return the integer enumeration of this FO (e.g., FO_ROOT)
+ * Returns the {@link Constants} class integer value of this node
+ * @return the integer enumeration of this FO (e.g. FO_ROOT)
* if a formatting object, FO_UNKNOWN_NODE otherwise
*/
public int getNameId() {
@@ -632,6 +656,14 @@ public abstract class FONode implements Cloneable {
}
}
+ /**
+ * This method is used when adding child nodes to a FO that already
+ * contains at least one child. In this case, the new child becomes a
+ * sibling to the previous one
+ *
+ * @param precedingSibling the previous child
+ * @param followingSibling the new child
+ */
protected static void attachSiblings(FONode precedingSibling,
FONode followingSibling) {
if (precedingSibling.siblings == null) {
@@ -688,7 +720,7 @@ public abstract class FONode implements Cloneable {
* @return the last node in the list
* @throws NoSuchElementException if the list is empty
*/
- public FONode lastNode();
+ public FONode lastNode();
}
}
diff --git a/src/java/org/apache/fop/fo/flow/Wrapper.java b/src/java/org/apache/fop/fo/flow/Wrapper.java
index 8b833f6b7..b116eddeb 100644
--- a/src/java/org/apache/fop/fo/flow/Wrapper.java
+++ b/src/java/org/apache/fop/fo/flow/Wrapper.java
@@ -38,49 +38,43 @@ public class Wrapper extends FObjMixed {
// used for FO validation
private boolean blockOrInlineItemFound = false;
- private boolean isFlowChild = false;
+ private boolean inlineChildrenAllowed = false;
/**
* @param parent FONode that is the parent of this object
*/
public Wrapper(FONode parent) {
super(parent);
- /* Check if the fo:wrapper is a child of an fo:flow or fo:static-content
+ /* Check if the fo:wrapper is a child of a FO that allows mixed content
* (or a descendant in nested fo:wrapper sequence, the first of which
- * is a child of an fo:flow or fo:static-content */
+ * is a child of a FO that allows mixed content) */
FONode ancestor = this.parent;
- while (!(ancestor instanceof Flow)
- && ancestor instanceof Wrapper) {
+ while (ancestor instanceof Wrapper) {
ancestor = ancestor.getParent();
}
- if (ancestor instanceof Flow) {
- this.isFlowChild = true;
+ if (ancestor instanceof FObjMixed ) {
+ inlineChildrenAllowed = true;
}
}
/**
* {@inheritDoc}
- * XSL Content Model: marker* (#PCDATA|%inline;|%block;)*
- * Additionally (unimplemented): "An fo:wrapper that is a child of an
+ *
XSL Content Model: marker* (#PCDATA|%inline;|%block;)*
+ *
Additionally (unimplemented): "An fo:wrapper that is a child of an
* fo:multi-properties is only permitted to have children that would
- * be permitted in place of the fo:multi-properties."
+ * be permitted in place of the fo:multi-properties."
*
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
throws ValidationException {
- if (FO_URI.equals(nsURI) && localName.equals("marker")) {
+ if (FO_URI.equals(nsURI) && "marker".equals(localName)) {
if (blockOrInlineItemFound) {
nodesOutOfOrderError(loc, "fo:marker",
"(#PCDATA|%inline;|%block;)");
}
} else if (isBlockOrInlineItem(nsURI, localName)) {
- if (isFlowChild
- && isInlineItem(nsURI, localName)
- && !isNeutralItem(nsURI, localName)) {
- invalidChildError(loc, nsURI, localName,
- "fo:" + localName + " not allowed as child of an fo:wrapper "
- + "that is a child of an fo:flow or fo:static-content");
- }
+ //delegate validation to parent
+ FONode.validateChildNode(this.parent, loc, nsURI, localName);
blockOrInlineItemFound = true;
} else {
invalidChildError(loc, nsURI, localName);
@@ -94,9 +88,8 @@ public class Wrapper extends FObjMixed {
int end,
PropertyList pList,
Locator locator) throws FOPException {
- /* Only add text if the fo:wrapper is not a child of an fo:flow
- * or fo:static-content */
- if (!this.isFlowChild) {
+ /* Only add text if the fo:wrapper's parent allows inline children */
+ if (this.inlineChildrenAllowed) {
super.addCharacters(data, start, end, pList, locator);
}
}
--
cgit v1.2.3
From 916e1325a2033ddd8ed9a707049076b391b49e8b Mon Sep 17 00:00:00 2001
From: Vincent Hennebert
Date: Mon, 17 Dec 2007 10:21:04 +0000
Subject: Organized imports
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@604814 13f79535-47bb-0310-9956-ffa450edef68
---
src/java/org/apache/fop/fo/flow/Wrapper.java | 1 -
1 file changed, 1 deletion(-)
(limited to 'src')
diff --git a/src/java/org/apache/fop/fo/flow/Wrapper.java b/src/java/org/apache/fop/fo/flow/Wrapper.java
index b116eddeb..adf9b2101 100644
--- a/src/java/org/apache/fop/fo/flow/Wrapper.java
+++ b/src/java/org/apache/fop/fo/flow/Wrapper.java
@@ -24,7 +24,6 @@ import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObjMixed;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.ValidationException;
-import org.apache.fop.fo.pagination.Flow;
import org.xml.sax.Locator;
/**
--
cgit v1.2.3
From 040987c53225a7d4e634e89167e848be40514a2d Mon Sep 17 00:00:00 2001
From: Vincent Hennebert
Date: Mon, 17 Dec 2007 18:56:46 +0000
Subject: Renaming GridUnitPart into the more accurate CellPart. Moreover I was
always making the confusion between gup and pgu
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@604965 13f79535-47bb-0310-9956-ffa450edef68
---
.../org/apache/fop/layoutmgr/table/ActiveCell.java | 10 +--
.../org/apache/fop/layoutmgr/table/CellPart.java | 73 ++++++++++++++++++++++
.../apache/fop/layoutmgr/table/GridUnitPart.java | 73 ----------------------
.../org/apache/fop/layoutmgr/table/RowPainter.java | 22 +++----
.../layoutmgr/table/TableContentLayoutManager.java | 2 +-
.../fop/layoutmgr/table/TableContentPosition.java | 12 ++--
.../apache/fop/layoutmgr/table/TableStepper.java | 13 ++--
7 files changed, 103 insertions(+), 102 deletions(-)
create mode 100644 src/java/org/apache/fop/layoutmgr/table/CellPart.java
delete mode 100644 src/java/org/apache/fop/layoutmgr/table/GridUnitPart.java
(limited to 'src')
diff --git a/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java b/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java
index 139eacf43..a1957eb27 100644
--- a/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java
+++ b/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java
@@ -266,12 +266,12 @@ class ActiveCell {
}
/**
- * Creates and returns a GridUnitPart instance for the content of this cell which
+ * Creates and returns a CellPart instance for the content of this cell which
* is included in the next step.
*
- * @return a GridUnitPart instance
+ * @return a CellPart instance
*/
- GridUnitPart createGridUnitPart() {
+ CellPart createCellPart() {
if (end + 1 == elementList.size()) {
if (pgu.getFlag(GridUnit.KEEP_WITH_NEXT_PENDING)) {
keepWithNextSignal = true;
@@ -284,9 +284,9 @@ class ActiveCell {
&& elementList.size() == 1
&& elementList.get(0) instanceof KnuthBoxCellWithBPD) {
//Special case: Cell with fixed BPD
- return new GridUnitPart(pgu, 0, pgu.getElements().size() - 1);
+ return new CellPart(pgu, 0, pgu.getElements().size() - 1);
} else {
- return new GridUnitPart(pgu, start, end);
+ return new CellPart(pgu, start, end);
}
}
diff --git a/src/java/org/apache/fop/layoutmgr/table/CellPart.java b/src/java/org/apache/fop/layoutmgr/table/CellPart.java
new file mode 100644
index 000000000..bf5ad64cf
--- /dev/null
+++ b/src/java/org/apache/fop/layoutmgr/table/CellPart.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.layoutmgr.table;
+
+import org.apache.fop.fo.flow.table.GridUnit;
+import org.apache.fop.fo.flow.table.PrimaryGridUnit;
+
+/**
+ * Represents a non-dividable part of a grid unit. Used by the table stepper.
+ */
+class CellPart {
+
+ /** Primary grid unit */
+ protected PrimaryGridUnit pgu;
+ /** Index of the starting element of this part */
+ protected int start;
+ /** Index of the ending element of this part */
+ protected int end;
+
+ /**
+ * Creates a new CellPart.
+ * @param pgu Primary grid unit
+ * @param start starting element
+ * @param end ending element
+ */
+ protected CellPart(PrimaryGridUnit pgu, int start, int end) {
+ this.pgu = pgu;
+ this.start = start;
+ this.end = end;
+ }
+
+ /** @return true if this part is the first part of a cell */
+ public boolean isFirstPart() {
+ return (start == 0);
+ }
+
+ /** @return true if this part is the last part of a cell */
+ public boolean isLastPart() {
+ return (end >= 0 && end == pgu.getElements().size() - 1);
+ }
+
+ /** {@inheritDoc} */
+ public String toString() {
+ StringBuffer sb = new StringBuffer("Part: ");
+ sb.append(start).append("-").append(end);
+ sb.append(" [").append(isFirstPart() ? "F" : "-").append(isLastPart() ? "L" : "-");
+ sb.append("] ").append(pgu);
+ return sb.toString();
+ }
+
+ boolean mustKeepWithPrevious() {
+ return pgu.getFlag(GridUnit.KEEP_WITH_PREVIOUS_PENDING)
+ || (pgu.getRow() != null && pgu.getRow().mustKeepWithPrevious());
+ }
+
+}
diff --git a/src/java/org/apache/fop/layoutmgr/table/GridUnitPart.java b/src/java/org/apache/fop/layoutmgr/table/GridUnitPart.java
deleted file mode 100644
index e0cdfccf1..000000000
--- a/src/java/org/apache/fop/layoutmgr/table/GridUnitPart.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.layoutmgr.table;
-
-import org.apache.fop.fo.flow.table.GridUnit;
-import org.apache.fop.fo.flow.table.PrimaryGridUnit;
-
-/**
- * Represents a non-dividable part of a grid unit. Used by the table stepper.
- */
-class GridUnitPart {
-
- /** Primary grid unit */
- protected PrimaryGridUnit pgu;
- /** Index of the starting element of this part */
- protected int start;
- /** Index of the ending element of this part */
- protected int end;
-
- /**
- * Creates a new GridUnitPart.
- * @param pgu Primary grid unit
- * @param start starting element
- * @param end ending element
- */
- protected GridUnitPart(PrimaryGridUnit pgu, int start, int end) {
- this.pgu = pgu;
- this.start = start;
- this.end = end;
- }
-
- /** @return true if this part is the first part of a cell */
- public boolean isFirstPart() {
- return (start == 0);
- }
-
- /** @return true if this part is the last part of a cell */
- public boolean isLastPart() {
- return (end >= 0 && end == pgu.getElements().size() - 1);
- }
-
- /** {@inheritDoc} */
- public String toString() {
- StringBuffer sb = new StringBuffer("Part: ");
- sb.append(start).append("-").append(end);
- sb.append(" [").append(isFirstPart() ? "F" : "-").append(isLastPart() ? "L" : "-");
- sb.append("] ").append(pgu);
- return sb.toString();
- }
-
- boolean mustKeepWithPrevious() {
- return pgu.getFlag(GridUnit.KEEP_WITH_PREVIOUS_PENDING)
- || (pgu.getRow() != null && pgu.getRow().mustKeepWithPrevious());
- }
-
-}
diff --git a/src/java/org/apache/fop/layoutmgr/table/RowPainter.java b/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
index 73cce29e4..f78d47b52 100644
--- a/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
+++ b/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
@@ -110,27 +110,27 @@ class RowPainter {
}
rowFO = tcpos.row.getTableRow();
lastRow = tcpos.row;
- Iterator partIter = tcpos.gridUnitParts.iterator();
+ Iterator partIter = tcpos.cellParts.iterator();
//Iterate over all grid units in the current step
while (partIter.hasNext()) {
- GridUnitPart gup = (GridUnitPart)partIter.next();
+ CellPart cellPart = (CellPart)partIter.next();
if (log.isDebugEnabled()) {
- log.debug(">" + gup);
+ log.debug(">" + cellPart);
}
- int colIndex = gup.pgu.getStartCol();
- if (primaryGridUnits[colIndex] != gup.pgu) {
+ int colIndex = cellPart.pgu.getStartCol();
+ if (primaryGridUnits[colIndex] != cellPart.pgu) {
if (primaryGridUnits[colIndex] != null) {
log.warn("Replacing GU in slot " + colIndex
+ ". Some content may not be painted.");
}
- primaryGridUnits[colIndex] = gup.pgu;
- start[colIndex] = gup.start;
- end[colIndex] = gup.end;
+ primaryGridUnits[colIndex] = cellPart.pgu;
+ start[colIndex] = cellPart.start;
+ end[colIndex] = cellPart.end;
} else {
- if (gup.end < end[colIndex]) {
+ if (cellPart.end < end[colIndex]) {
throw new IllegalStateException("Internal Error: stepper problem");
}
- end[colIndex] = gup.end;
+ end[colIndex] = cellPart.end;
}
}
}
@@ -175,7 +175,7 @@ class RowPainter {
if (forcedFlush || ((end[i] == primaryGridUnits[i].getElements().size() - 1)
&& (currentGU == null || currentGU.isLastGridUnitRowSpan()))) {
//the last line in the "if" above is to avoid a premature end of a
- //row-spanned cell because no GridUnitParts are generated after a cell is
+ //row-spanned cell because no CellParts are generated after a cell is
//finished with its content.
//See table-cell_number-rows-spanned_bug38397.xml
addAreasForCell(primaryGridUnits[i], start[i], end[i], lastRow, partBPD[i],
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
index fca0557b7..57972078e 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
@@ -387,7 +387,7 @@ public class TableContentLayoutManager implements PercentBaseContext {
if (pos instanceof TableContentPosition) {
TableContentPosition tcpos = (TableContentPosition)pos;
lst.add(tcpos);
- GridUnitPart part = (GridUnitPart)tcpos.gridUnitParts.get(0);
+ CellPart part = (CellPart)tcpos.cellParts.get(0);
if (body == null) {
body = part.pgu.getBody();
}
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java b/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java
index 8986ea85f..68f55d88f 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java
@@ -36,8 +36,8 @@ class TableContentPosition extends Position {
/** The position is the last of the row group. */
public static final int LAST_IN_ROWGROUP = 2;
- /** the list of GridUnitParts making up this position */
- protected List gridUnitParts;
+ /** the list of CellParts making up this position */
+ protected List cellParts;
/** effective row this position belongs to */
protected EffRow row;
/** flags for the position */
@@ -46,13 +46,13 @@ class TableContentPosition extends Position {
/**
* Creates a new TableContentPosition.
* @param lm applicable layout manager
- * @param gridUnitParts the list of GridUnitPart instances
+ * @param cellParts the list of CellPart instances
* @param row effective row this position belongs to
*/
- protected TableContentPosition(LayoutManager lm, List gridUnitParts,
+ protected TableContentPosition(LayoutManager lm, List cellParts,
EffRow row) {
super(lm);
- this.gridUnitParts = gridUnitParts;
+ this.cellParts = cellParts;
this.row = row;
}
@@ -90,7 +90,7 @@ class TableContentPosition extends Position {
sb.append(getFlag(FIRST_IN_ROWGROUP) ? "F" : "-");
sb.append(getFlag(LAST_IN_ROWGROUP) ? "L" : "-").append("]");
sb.append("(");
- sb.append(gridUnitParts);
+ sb.append(cellParts);
sb.append(")");
return sb.toString();
}
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableStepper.java b/src/java/org/apache/fop/layoutmgr/table/TableStepper.java
index 98b07778f..d4ed460b4 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableStepper.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableStepper.java
@@ -169,26 +169,27 @@ public class TableStepper {
boolean forcedBreak = false;
int breakClass = -1;
//Put all involved grid units into a list
- List gridUnitParts = new java.util.ArrayList(maxColumnCount);
+ List cellParts = new java.util.ArrayList(maxColumnCount);
for (Iterator iter = activeCells.iterator(); iter.hasNext();) {
ActiveCell activeCell = (ActiveCell) iter.next();
if (activeCell.contributesContent()) {
- GridUnitPart gup = activeCell.createGridUnitPart();
- gridUnitParts.add(gup);
+ CellPart part = activeCell.createCellPart();
+ cellParts.add(part);
forcedBreak = activeCell.isLastForcedBreak();
if (forcedBreak) {
breakClass = activeCell.getLastBreakClass();
}
- if (returnList.size() == 0 && gup.isFirstPart() && gup.mustKeepWithPrevious()) {
+ if (returnList.size() == 0 && part.isFirstPart()
+ && part.mustKeepWithPrevious()) {
context.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING);
}
}
}
- //log.debug(">>> guPARTS: " + gridUnitParts);
+ //log.debug(">>> guPARTS: " + cellParts);
//Create elements for step
TableContentPosition tcpos = new TableContentPosition(getTableLM(),
- gridUnitParts, rowGroup[normalRow]);
+ cellParts, rowGroup[normalRow]);
if (returnList.size() == 0) {
tcpos.setFlag(TableContentPosition.FIRST_IN_ROWGROUP, true);
}
--
cgit v1.2.3
From feca36df8615178172e20001c99a071b5fa3aa02 Mon Sep 17 00:00:00 2001
From: Vincent Hennebert
Date: Mon, 17 Dec 2007 19:05:27 +0000
Subject: Simplified addAreasAndFlushRow: there can no longer be null
GridUnits, every hole in the grid is now filled with an EmptyGridUnit
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@604970 13f79535-47bb-0310-9956-ffa450edef68
---
src/java/org/apache/fop/layoutmgr/table/RowPainter.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'src')
diff --git a/src/java/org/apache/fop/layoutmgr/table/RowPainter.java b/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
index f78d47b52..880e44282 100644
--- a/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
+++ b/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
@@ -173,7 +173,7 @@ class RowPainter {
if (primaryGridUnits[i] != null) {
if (forcedFlush || ((end[i] == primaryGridUnits[i].getElements().size() - 1)
- && (currentGU == null || currentGU.isLastGridUnitRowSpan()))) {
+ && currentGU.isLastGridUnitRowSpan())) {
//the last line in the "if" above is to avoid a premature end of a
//row-spanned cell because no CellParts are generated after a cell is
//finished with its content.
@@ -185,7 +185,7 @@ class RowPainter {
end[i] = -1;
partBPD[i] = 0;
}
- } else if (currentGU != null && !currentGU.isEmpty()
+ } else if (!currentGU.isEmpty()
&& currentGU.getColSpanIndex() == 0
&& (forcedFlush || currentGU.isLastGridUnitRowSpan())) {
//A row-spanned cell has finished contributing content on the previous page
--
cgit v1.2.3
From 5323aed1fcf9375edd328b9c91a88e4a9b741e98 Mon Sep 17 00:00:00 2001
From: Vincent Hennebert
Date: Tue, 18 Dec 2007 11:56:38 +0000
Subject: Reset previousRowsLength before a new row-group is handled
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@605195 13f79535-47bb-0310-9956-ffa450edef68
---
src/java/org/apache/fop/layoutmgr/table/TableStepper.java | 1 +
1 file changed, 1 insertion(+)
(limited to 'src')
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableStepper.java b/src/java/org/apache/fop/layoutmgr/table/TableStepper.java
index d4ed460b4..35bf4c844 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableStepper.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableStepper.java
@@ -75,6 +75,7 @@ public class TableStepper {
private void setup(int columnCount) {
this.columnCount = columnCount;
this.activeRowIndex = 0;
+ this.previousRowsLength = 0;
}
/**
--
cgit v1.2.3
From fd26360942bad4bc40c56d48dd672f75162ac7ce Mon Sep 17 00:00:00 2001
From: Vincent Hennebert
Date: Tue, 18 Dec 2007 16:48:03 +0000
Subject: Simplification in RowPainter: avoid the use of an array to store
rowOffsets and firstRow index for each part of the table (header, footer,
body). One at a time is enough.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@605246 13f79535-47bb-0310-9956-ffa450edef68
---
.../org/apache/fop/layoutmgr/table/RowPainter.java | 45 +++++++++++-----------
.../layoutmgr/table/TableContentLayoutManager.java | 1 +
2 files changed, 24 insertions(+), 22 deletions(-)
(limited to 'src')
diff --git a/src/java/org/apache/fop/layoutmgr/table/RowPainter.java b/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
index 880e44282..d053c6ebd 100644
--- a/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
+++ b/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
@@ -20,6 +20,7 @@
package org.apache.fop.layoutmgr.table;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -47,17 +48,15 @@ class RowPainter {
private EffRow lastRow = null;
private LayoutContext layoutContext;
/**
- * For each part of the table (header, footer, body), index of the first row of that
- * part present on the current page.
+ * Index of the first row of the current part present on the current page.
*/
- private int[] firstRow = new int[3];
+ private int firstRow;
/**
- * Keeps track of the y-offsets of each row on a page (for body, header and footer separately).
+ * Keeps track of the y-offsets of each row on a page.
* This is particularly needed for spanned cells where you need to know the y-offset
* of the starting row when the area is generated at the time the cell is closed.
*/
- private Map[] rowOffsets = new Map[] {new java.util.HashMap(),
- new java.util.HashMap(), new java.util.HashMap()};
+ private Map rowOffsets = new HashMap();
//These three variables are our buffer to recombine the individual steps into cells
/** Primary grid units corresponding to the currently handled grid units, per row. */
@@ -87,7 +86,7 @@ class RowPainter {
this.start = new int[colCount];
this.end = new int[colCount];
this.partBPD = new int[colCount];
- Arrays.fill(firstRow, -1);
+ this.firstRow = -1;
Arrays.fill(end, -1);
}
@@ -149,17 +148,16 @@ class RowPainter {
int addAreasAndFlushRow(boolean forcedFlush) {
int actualRowHeight = 0;
- int bt = lastRow.getBodyType();
if (log.isDebugEnabled()) {
log.debug("Remembering yoffset for row " + lastRow.getIndex() + ": " + yoffset);
}
- rowOffsets[bt].put(new Integer(lastRow.getIndex()), new Integer(yoffset));
+ rowOffsets.put(new Integer(lastRow.getIndex()), new Integer(yoffset));
for (int i = 0; i < primaryGridUnits.length; i++) {
if ((primaryGridUnits[i] != null)
&& (forcedFlush || (end[i] == primaryGridUnits[i].getElements().size() - 1))) {
actualRowHeight = Math.max(actualRowHeight, computeSpanHeight(
- primaryGridUnits[i], start[i], end[i], i, bt));
+ primaryGridUnits[i], start[i], end[i], i));
}
}
actualRowHeight += 2 * tclm.getTableLM().getHalfBorderSeparationBPD();
@@ -226,8 +224,7 @@ class RowPainter {
* {@link TableRowIterator#BODY}
* @return the cell's height
*/
- private int computeSpanHeight(PrimaryGridUnit pgu, int start, int end, int columnIndex,
- int bodyType) {
+ private int computeSpanHeight(PrimaryGridUnit pgu, int start, int end, int columnIndex) {
if (log.isTraceEnabled()) {
log.trace("getting len for " + columnIndex + " "
+ start + "-" + end);
@@ -292,8 +289,8 @@ class RowPainter {
len += pgu.getHalfMaxBeforeBorderWidth();
len += pgu.getHalfMaxAfterBorderWidth();
}
- int startRow = Math.max(pgu.getStartRow(), firstRow[bodyType]);
- Integer storedOffset = (Integer)rowOffsets[bodyType].get(new Integer(startRow));
+ int startRow = Math.max(pgu.getStartRow(), firstRow);
+ Integer storedOffset = (Integer)rowOffsets.get(new Integer(startRow));
int effYOffset;
if (storedOffset != null) {
effYOffset = storedOffset.intValue();
@@ -306,12 +303,11 @@ class RowPainter {
private void addAreasForCell(PrimaryGridUnit pgu, int startPos, int endPos,
EffRow row, int contentHeight, int rowHeight) {
- int bt = row.getBodyType();
- if (firstRow[bt] < 0) {
- firstRow[bt] = row.getIndex();
+ if (firstRow < 0) {
+ firstRow = row.getIndex();
}
//Determine the first row in this sequence
- int startRowIndex = Math.max(pgu.getStartRow(), firstRow[bt]);
+ int startRowIndex = Math.max(pgu.getStartRow(), firstRow);
int lastRowIndex = lastRow.getIndex();
// In collapsing-border model, if the cell spans over several columns/rows then
@@ -321,9 +317,9 @@ class RowPainter {
int[] spannedGridRowHeights = null;
if (!tclm.getTableLM().getTable().isSeparateBorderModel() && pgu.hasSpanning()) {
spannedGridRowHeights = new int[lastRowIndex - startRowIndex + 1];
- int prevOffset = ((Integer)rowOffsets[bt].get(new Integer(startRowIndex))).intValue();
+ int prevOffset = ((Integer)rowOffsets.get(new Integer(startRowIndex))).intValue();
for (int i = 0; i < lastRowIndex - startRowIndex; i++) {
- int newOffset = ((Integer) rowOffsets[bt].get(new Integer(startRowIndex + i + 1)))
+ int newOffset = ((Integer) rowOffsets.get(new Integer(startRowIndex + i + 1)))
.intValue();
spannedGridRowHeights[i] = newOffset - prevOffset;
prevOffset = newOffset;
@@ -332,12 +328,12 @@ class RowPainter {
}
//Determine y offset for the cell
- Integer offset = (Integer)rowOffsets[bt].get(new Integer(startRowIndex));
+ Integer offset = (Integer)rowOffsets.get(new Integer(startRowIndex));
while (offset == null) {
//TODO Figure out what this does and when it's triggered
//This block is probably never used, at least it's not triggered by any of our tests
startRowIndex--;
- offset = (Integer)rowOffsets[bt].get(new Integer(startRowIndex));
+ offset = (Integer)rowOffsets.get(new Integer(startRowIndex));
}
int effYOffset = offset.intValue();
int effCellHeight = rowHeight;
@@ -364,4 +360,9 @@ class RowPainter {
layoutContext, spannedGridRowHeights, startRowIndex - pgu.getStartRow(),
lastRowIndex - pgu.getStartRow() + 1);
}
+
+ void endPart() {
+ firstRow = -1;
+ rowOffsets.clear();
+ }
}
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
index 57972078e..308b2cca7 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
@@ -418,6 +418,7 @@ public class TableContentLayoutManager implements PercentBaseContext {
handleMarkersAndPositions(lst, body, firstPos, false, painter);
}
painter.addAreasAndFlushRow(true);
+ painter.endPart();
}
private void handleMarkersAndPositions(List positions, TableBody body, boolean firstPos,
--
cgit v1.2.3
From ef06a58b6802b5cf4b1b67f81f941be18bbb4d04 Mon Sep 17 00:00:00 2001
From: Vincent Hennebert
Date: Tue, 18 Dec 2007 17:01:45 +0000
Subject: Renamed firstRow into firstRowIndex and moved its initialization into
handeTableContentPosition
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@605253 13f79535-47bb-0310-9956-ffa450edef68
---
src/java/org/apache/fop/layoutmgr/table/RowPainter.java | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
(limited to 'src')
diff --git a/src/java/org/apache/fop/layoutmgr/table/RowPainter.java b/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
index d053c6ebd..490f999cd 100644
--- a/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
+++ b/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
@@ -50,7 +50,7 @@ class RowPainter {
/**
* Index of the first row of the current part present on the current page.
*/
- private int firstRow;
+ private int firstRowIndex;
/**
* Keeps track of the y-offsets of each row on a page.
* This is particularly needed for spanned cells where you need to know the y-offset
@@ -86,7 +86,7 @@ class RowPainter {
this.start = new int[colCount];
this.end = new int[colCount];
this.partBPD = new int[colCount];
- this.firstRow = -1;
+ this.firstRowIndex = -1;
Arrays.fill(end, -1);
}
@@ -109,6 +109,9 @@ class RowPainter {
}
rowFO = tcpos.row.getTableRow();
lastRow = tcpos.row;
+ if (firstRowIndex < 0) {
+ firstRowIndex = lastRow.getIndex();
+ }
Iterator partIter = tcpos.cellParts.iterator();
//Iterate over all grid units in the current step
while (partIter.hasNext()) {
@@ -289,7 +292,7 @@ class RowPainter {
len += pgu.getHalfMaxBeforeBorderWidth();
len += pgu.getHalfMaxAfterBorderWidth();
}
- int startRow = Math.max(pgu.getStartRow(), firstRow);
+ int startRow = Math.max(pgu.getStartRow(), firstRowIndex);
Integer storedOffset = (Integer)rowOffsets.get(new Integer(startRow));
int effYOffset;
if (storedOffset != null) {
@@ -303,11 +306,8 @@ class RowPainter {
private void addAreasForCell(PrimaryGridUnit pgu, int startPos, int endPos,
EffRow row, int contentHeight, int rowHeight) {
- if (firstRow < 0) {
- firstRow = row.getIndex();
- }
//Determine the first row in this sequence
- int startRowIndex = Math.max(pgu.getStartRow(), firstRow);
+ int startRowIndex = Math.max(pgu.getStartRow(), firstRowIndex);
int lastRowIndex = lastRow.getIndex();
// In collapsing-border model, if the cell spans over several columns/rows then
@@ -362,7 +362,7 @@ class RowPainter {
}
void endPart() {
- firstRow = -1;
+ firstRowIndex = -1;
rowOffsets.clear();
}
}
--
cgit v1.2.3
From f15db7d7e260738d22feddaef6cd73abdf5860b3 Mon Sep 17 00:00:00 2001
From: Vincent Hennebert
Date: Tue, 18 Dec 2007 18:58:29 +0000
Subject: Streamlined the recording of row offsets, by replacing Map with a
List. Fixed bug #43633 in the same time.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@605295 13f79535-47bb-0310-9956-ffa450edef68
---
.../org/apache/fop/layoutmgr/table/RowPainter.java | 74 ++++++++++-------
status.xml | 3 +
.../table_row-span_missing-cell_bug43633.xml | 96 ++++++++++++++++++++++
3 files changed, 145 insertions(+), 28 deletions(-)
create mode 100644 test/layoutengine/standard-testcases/table_row-span_missing-cell_bug43633.xml
(limited to 'src')
diff --git a/src/java/org/apache/fop/layoutmgr/table/RowPainter.java b/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
index 490f999cd..0b90bf9d8 100644
--- a/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
+++ b/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
@@ -19,10 +19,10 @@
package org.apache.fop.layoutmgr.table;
+import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.Iterator;
-import java.util.Map;
+import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -56,7 +56,7 @@ class RowPainter {
* This is particularly needed for spanned cells where you need to know the y-offset
* of the starting row when the area is generated at the time the cell is closed.
*/
- private Map rowOffsets = new HashMap();
+ private List rowOffsets = new ArrayList();
//These three variables are our buffer to recombine the individual steps into cells
/** Primary grid units corresponding to the currently handled grid units, per row. */
@@ -154,7 +154,7 @@ class RowPainter {
if (log.isDebugEnabled()) {
log.debug("Remembering yoffset for row " + lastRow.getIndex() + ": " + yoffset);
}
- rowOffsets.put(new Integer(lastRow.getIndex()), new Integer(yoffset));
+ recordRowOffset(lastRow.getIndex(), yoffset);
for (int i = 0; i < primaryGridUnits.length; i++) {
if ((primaryGridUnits[i] != null)
@@ -292,15 +292,8 @@ class RowPainter {
len += pgu.getHalfMaxBeforeBorderWidth();
len += pgu.getHalfMaxAfterBorderWidth();
}
- int startRow = Math.max(pgu.getStartRow(), firstRowIndex);
- Integer storedOffset = (Integer)rowOffsets.get(new Integer(startRow));
- int effYOffset;
- if (storedOffset != null) {
- effYOffset = storedOffset.intValue();
- } else {
- effYOffset = yoffset;
- }
- len -= yoffset - effYOffset;
+ int cellOffset = getRowOffset(Math.max(pgu.getStartRow(), firstRowIndex));
+ len -= yoffset - cellOffset;
return len;
}
@@ -317,37 +310,28 @@ class RowPainter {
int[] spannedGridRowHeights = null;
if (!tclm.getTableLM().getTable().isSeparateBorderModel() && pgu.hasSpanning()) {
spannedGridRowHeights = new int[lastRowIndex - startRowIndex + 1];
- int prevOffset = ((Integer)rowOffsets.get(new Integer(startRowIndex))).intValue();
+ int prevOffset = getRowOffset(startRowIndex);
for (int i = 0; i < lastRowIndex - startRowIndex; i++) {
- int newOffset = ((Integer) rowOffsets.get(new Integer(startRowIndex + i + 1)))
- .intValue();
+ int newOffset = getRowOffset(startRowIndex + i + 1);
spannedGridRowHeights[i] = newOffset - prevOffset;
prevOffset = newOffset;
}
spannedGridRowHeights[lastRowIndex - startRowIndex] = rowHeight;
}
- //Determine y offset for the cell
- Integer offset = (Integer)rowOffsets.get(new Integer(startRowIndex));
- while (offset == null) {
- //TODO Figure out what this does and when it's triggered
- //This block is probably never used, at least it's not triggered by any of our tests
- startRowIndex--;
- offset = (Integer)rowOffsets.get(new Integer(startRowIndex));
- }
- int effYOffset = offset.intValue();
+ int cellOffset = getRowOffset(startRowIndex);
int effCellHeight = rowHeight;
- effCellHeight += yoffset - effYOffset;
+ effCellHeight += yoffset - cellOffset;
if (log.isDebugEnabled()) {
log.debug("Creating area for cell:");
log.debug(" current row: " + row.getIndex());
- log.debug(" start row: " + pgu.getStartRow() + " " + yoffset + " " + effYOffset);
+ log.debug(" start row: " + pgu.getStartRow() + " " + yoffset + " " + cellOffset);
log.debug(" contentHeight: " + contentHeight + " rowHeight=" + rowHeight
+ " effCellHeight=" + effCellHeight);
}
TableCellLayoutManager cellLM = pgu.getCellLM();
cellLM.setXOffset(tclm.getXOffsetOfGridUnit(pgu));
- cellLM.setYOffset(effYOffset);
+ cellLM.setYOffset(cellOffset);
cellLM.setContentHeight(contentHeight);
cellLM.setRowHeight(effCellHeight);
//cellLM.setRowHeight(row.getHeight().opt);
@@ -361,6 +345,40 @@ class RowPainter {
lastRowIndex - pgu.getStartRow() + 1);
}
+ /**
+ * Records the y-offset of the row with the given index.
+ *
+ * @param rowIndex index of the row
+ * @param offset y-offset of the row on the page
+ */
+ private void recordRowOffset(int rowIndex, int offset) {
+ /*
+ * In some very rare cases a row may be skipped. See for example Bugzilla #43633:
+ * in a two-column table, a row contains a row-spanning cell and a missing cell.
+ * In TableStepper#goToNextRowIfCurrentFinished this row will immediately be
+ * considered as finished, since it contains no cell ending on this row. Thus no
+ * TableContentPosition will be created for this row. Thus its index will never be
+ * recorded by the #handleTableContentPosition method.
+ *
+ * The yoffset for such a row is the same as the next non-empty row. It's needed
+ * to correctly offset blocks for cells starting on this row. Hence the loop
+ * below.
+ */
+ for (int i = rowOffsets.size(); i <= rowIndex - firstRowIndex; i++) {
+ rowOffsets.add(new Integer(offset));
+ }
+ }
+
+ /**
+ * Returns the offset of the row with the given index.
+ *
+ * @param rowIndex index of the row
+ * @return its y-offset on the page
+ */
+ private int getRowOffset(int rowIndex) {
+ return ((Integer) rowOffsets.get(rowIndex - firstRowIndex)).intValue();
+ }
+
void endPart() {
firstRowIndex = -1;
rowOffsets.clear();
diff --git a/status.xml b/status.xml
index 46942d796..77f4dcb86 100644
--- a/status.xml
+++ b/status.xml
@@ -28,6 +28,9 @@
+
+ Bugfix: content of a row with zero height overriding the previous row
+
Added SVG support for AFP (GOCA).
diff --git a/test/layoutengine/standard-testcases/table_row-span_missing-cell_bug43633.xml b/test/layoutengine/standard-testcases/table_row-span_missing-cell_bug43633.xml
new file mode 100644
index 000000000..5cf793bcf
--- /dev/null
+++ b/test/layoutengine/standard-testcases/table_row-span_missing-cell_bug43633.xml
@@ -0,0 +1,96 @@
+
+
+
+
+
+
+ Check for bug #43633: the second row of the table has only a spanning cell, and the second
+ cell is missing. This was leading to the spanning cell overlapping cell 1.1, because no
+ offset was recorded for the second row.
+
+
+
+
+
+
+
+
+
+
+
+ Before the table
+
+
+
+
+
+
+ Cell 1.1
+ Cell 1.1
+
+
+ Cell 1.2
+
+
+
+
+ Cell 2.1
+ Cell 2.1
+
+
+
+
+ Cell 3.2
+
+
+
+
+ After the table
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
--
cgit v1.2.3
From 23e00caa1c1932af9699618af8bf746315409979 Mon Sep 17 00:00:00 2001
From: Vincent Hennebert
Date: Wed, 19 Dec 2007 11:47:38 +0000
Subject: I said currentGU can no longer be null
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@605517 13f79535-47bb-0310-9956-ffa450edef68
---
src/java/org/apache/fop/layoutmgr/table/RowPainter.java | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
(limited to 'src')
diff --git a/src/java/org/apache/fop/layoutmgr/table/RowPainter.java b/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
index 0b90bf9d8..6d2568afb 100644
--- a/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
+++ b/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
@@ -168,10 +168,7 @@ class RowPainter {
//Add areas for row
tclm.addRowBackgroundArea(rowFO, actualRowHeight, layoutContext.getRefIPD(), yoffset);
for (int i = 0; i < primaryGridUnits.length; i++) {
- GridUnit currentGU = lastRow.safelyGetGridUnit(i);
- //currentGU can be null if there's no grid unit
- //at this place in the current row (empty cell and no borders to process)
-
+ GridUnit currentGU = lastRow.getGridUnit(i);
if (primaryGridUnits[i] != null) {
if (forcedFlush || ((end[i] == primaryGridUnits[i].getElements().size() - 1)
&& currentGU.isLastGridUnitRowSpan())) {
--
cgit v1.2.3
From 3311cbaf601724c5601e7ff7e6602016dbf862ac Mon Sep 17 00:00:00 2001
From: Jeremias Maerki
Date: Thu, 20 Dec 2007 17:00:46 +0000
Subject: Remove commented code.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@605978 13f79535-47bb-0310-9956-ffa450edef68
---
.../inline/ExternalGraphicLayoutManager.java | 162 +--------------------
.../layoutmgr/inline/InstreamForeignObjectLM.java | 6 +-
2 files changed, 2 insertions(+), 166 deletions(-)
(limited to 'src')
diff --git a/src/java/org/apache/fop/layoutmgr/inline/ExternalGraphicLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/ExternalGraphicLayoutManager.java
index ecdbd68e4..ab05d60c3 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/ExternalGraphicLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/ExternalGraphicLayoutManager.java
@@ -19,7 +19,6 @@
package org.apache.fop.layoutmgr.inline;
-import java.awt.geom.Rectangle2D;
import org.apache.fop.area.Area;
import org.apache.fop.area.inline.Image;
import org.apache.fop.fo.flow.ExternalGraphic;
@@ -34,7 +33,6 @@ public class ExternalGraphicLayoutManager extends AbstractGraphicsLayoutManager
/**
* Constructor
- *
* @param node the fo:external-graphic formatting object that creates the area
*/
public ExternalGraphicLayoutManager(ExternalGraphic node) {
@@ -42,165 +40,7 @@ public class ExternalGraphicLayoutManager extends AbstractGraphicsLayoutManager
fobj = node;
}
- /**
- * Setup this image.
- * This gets the sizes for the image and the dimensions and clipping.
- * @todo see if can simplify property handling logic
- */
- /*
- private void setup() {
- // assume lr-tb for now and just use the .optimum value of the range
- Length ipd = fobj.getInlineProgressionDimension().getOptimum(this).getLength();
- if (ipd.getEnum() != EN_AUTO) {
- viewWidth = ipd.getValue(this);
- } else {
- ipd = fobj.getWidth();
- if (ipd.getEnum() != EN_AUTO) {
- viewWidth = ipd.getValue(this);
- }
- }
- Length bpd = fobj.getBlockProgressionDimension().getOptimum(this).getLength();
- if (bpd.getEnum() != EN_AUTO) {
- viewHeight = bpd.getValue(this);
- } else {
- bpd = fobj.getHeight();
- if (bpd.getEnum() != EN_AUTO) {
- viewHeight = bpd.getValue(this);
- }
- }
-
- int cwidth = -1;
- int cheight = -1;
- Length ch = fobj.getContentHeight();
- if (ch.getEnum() != EN_AUTO) {
- if (ch.getEnum() == EN_SCALE_TO_FIT) {
- if (viewHeight != -1) {
- cheight = viewHeight;
- }
- } else {
- cheight = ch.getValue(this);
- }
- }
- Length cw = fobj.getContentWidth();
- if (cw.getEnum() != EN_AUTO) {
- if (cw.getEnum() == EN_SCALE_TO_FIT) {
- if (viewWidth != -1) {
- cwidth = viewWidth;
- }
- } else {
- cwidth = cw.getValue(this);
- }
- }
-
- int scaling = fobj.getScaling();
- if ((scaling == EN_UNIFORM) || (cwidth == -1) || cheight == -1) {
- if (cwidth == -1 && cheight == -1) {
- cwidth = fobj.getIntrinsicWidth();
- cheight = fobj.getIntrinsicHeight();
- } else if (cwidth == -1) {
- cwidth = (int)(fobj.getIntrinsicWidth() * (double)cheight
- / fobj.getIntrinsicHeight());
- } else if (cheight == -1) {
- cheight = (int)(fobj.getIntrinsicHeight() * (double)cwidth
- / fobj.getIntrinsicWidth());
- } else {
- // adjust the larger
- double rat1 = (double)cwidth / fobj.getIntrinsicWidth();
- double rat2 = (double)cheight / fobj.getIntrinsicHeight();
- if (rat1 < rat2) {
- // reduce cheight
- cheight = (int)(rat1 * fobj.getIntrinsicHeight());
- } else if (rat1 > rat2) {
- cwidth = (int)(rat2 * fobj.getIntrinsicWidth());
- }
- }
- }
-
- if (viewWidth == -1) {
- viewWidth = cwidth;
- }
- if (viewHeight == -1) {
- viewHeight = cheight;
- }
-
- if (cwidth > viewWidth || cheight > viewHeight) {
- int overflow = fobj.getOverflow();
- if (overflow == EN_HIDDEN) {
- clip = true;
- } else if (overflow == EN_ERROR_IF_OVERFLOW) {
- fobj.getLogger().error("Image: " + fobj.getURL()
- + " overflows the viewport, clipping to viewport");
- clip = true;
- }
- }
-
- int xoffset = 0;
- int yoffset = 0;
- switch(fobj.getDisplayAlign()) {
- case EN_BEFORE:
- break;
- case EN_AFTER:
- yoffset = viewHeight - cheight;
- break;
- case EN_CENTER:
- yoffset = (viewHeight - cheight) / 2;
- break;
- case EN_AUTO:
- default:
- break;
- }
-
- switch(fobj.getTextAlign()) {
- case EN_CENTER:
- xoffset = (viewWidth - cwidth) / 2;
- break;
- case EN_END:
- xoffset = viewWidth - cwidth;
- break;
- case EN_START:
- break;
- case EN_JUSTIFY:
- default:
- break;
- }
-
-
- CommonBorderPaddingBackground borderProps = fobj.getCommonBorderPaddingBackground();
-
- //Determine extra BPD from borders etc.
- int beforeBPD = borderProps.getPadding(CommonBorderPaddingBackground.BEFORE, false, this);
- beforeBPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.BEFORE,
- false);
- int afterBPD = borderProps.getPadding(CommonBorderPaddingBackground.AFTER, false, this);
- afterBPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.AFTER, false);
-
- yoffset += beforeBPD;
- viewBPD = viewHeight;
- viewHeight += beforeBPD;
- viewHeight += afterBPD;
-
- //Determine extra IPD from borders etc.
- int startIPD = borderProps.getPadding(CommonBorderPaddingBackground.START,
- false, this);
- startIPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.START,
- false);
- int endIPD = borderProps.getPadding(CommonBorderPaddingBackground.END, false, this);
- endIPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.END, false);
-
- xoffset += startIPD;
- viewIPD = viewWidth;
- viewWidth += startIPD;
- viewWidth += endIPD;
-
- placement = new Rectangle2D.Float(xoffset, yoffset, cwidth, cheight);
- }
- */
-
- /**
- * Get the inline area created by this element.
- *
- * @return the inline area
- */
+ /** {@inheritDoc} */
protected Area getChildArea() {
return new Image(fobj.getSrc());
}
diff --git a/src/java/org/apache/fop/layoutmgr/inline/InstreamForeignObjectLM.java b/src/java/org/apache/fop/layoutmgr/inline/InstreamForeignObjectLM.java
index 8ff6b346e..e7da50a9a 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/InstreamForeignObjectLM.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/InstreamForeignObjectLM.java
@@ -40,11 +40,7 @@ public class InstreamForeignObjectLM extends AbstractGraphicsLayoutManager {
fobj = node;
}
- /**
- * Get the inline area created by this element.
- *
- * @return the inline area
- */
+ /** {@inheritDoc} */
protected Area getChildArea() {
XMLObj child = (XMLObj) fobj.getChildXMLObj();
--
cgit v1.2.3
From ed61f771c493e86046f3d13e3d6a553d825dd8f3 Mon Sep 17 00:00:00 2001
From: Jeremias Maerki
Date: Thu, 20 Dec 2007 19:19:19 +0000
Subject: Added support for scale-down-to-fit and scale-up-to-fit.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@606004 13f79535-47bb-0310-9956-ffa450edef68
---
src/java/org/apache/fop/fo/Constants.java | 8 +-
src/java/org/apache/fop/fo/FOPropertyMapping.java | 7 +-
.../inline/AbstractGraphicsLayoutManager.java | 32 +++++++-
status.xml | 3 +
...rnal-graphic_content-height_content-width_2.xml | 92 ++++++++++++++++++++++
5 files changed, 136 insertions(+), 6 deletions(-)
create mode 100644 test/layoutengine/standard-testcases/external-graphic_content-height_content-width_2.xml
(limited to 'src')
diff --git a/src/java/org/apache/fop/fo/Constants.java b/src/java/org/apache/fop/fo/Constants.java
index e0477c0a5..edfa68c1a 100644
--- a/src/java/org/apache/fop/fo/Constants.java
+++ b/src/java/org/apache/fop/fo/Constants.java
@@ -1087,6 +1087,12 @@ public interface Constants {
int EN_SMALL_CAPTION = 184;
/** Enumeration constant -- font shorthand */
int EN_STATUS_BAR = 185;
+ /** Enumeration constant -- for page-position, XSL 1.1 */
+ int EN_ONLY = 186;
+ /** Enumeration constant -- for instream-foreign-object and external-graphic, XSL 1.1 */
+ int EN_SCALE_DOWN_TO_FIT = 187;
+ /** Enumeration constant -- for instream-foreign-object and external-graphic, XSL 1.1 */
+ int EN_SCALE_UP_TO_FIT = 188;
/** Number of enumeration constants defined */
- int ENUM_COUNT = 185;
+ int ENUM_COUNT = 188;
}
diff --git a/src/java/org/apache/fop/fo/FOPropertyMapping.java b/src/java/org/apache/fop/fo/FOPropertyMapping.java
index 5d1a6f31a..1fe9a32c4 100644
--- a/src/java/org/apache/fop/fo/FOPropertyMapping.java
+++ b/src/java/org/apache/fop/fo/FOPropertyMapping.java
@@ -25,13 +25,13 @@ import java.util.Map;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.datatypes.LengthBase;
import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.flow.table.TableFObj.ColumnNumberPropertyMaker;
import org.apache.fop.fo.properties.BackgroundPositionShorthandParser;
import org.apache.fop.fo.properties.BorderSpacingShorthandParser;
import org.apache.fop.fo.properties.BorderWidthPropertyMaker;
import org.apache.fop.fo.properties.BoxPropShorthandParser;
import org.apache.fop.fo.properties.CharacterProperty;
import org.apache.fop.fo.properties.ColorProperty;
-import org.apache.fop.fo.flow.table.TableFObj.ColumnNumberPropertyMaker;
import org.apache.fop.fo.properties.CondLengthProperty;
import org.apache.fop.fo.properties.CorrespondingPropertyMaker;
import org.apache.fop.fo.properties.DimensionPropertyMaker;
@@ -1353,6 +1353,8 @@ public final class FOPropertyMapping implements Constants {
l.setInherited(false);
l.addEnum("auto", getEnumProperty(EN_AUTO, "AUTO"));
l.addEnum("scale-to-fit", getEnumProperty(EN_SCALE_TO_FIT, "SCALE_TO_FIT"));
+ l.addEnum("scale-down-to-fit", getEnumProperty(EN_SCALE_DOWN_TO_FIT, "SCALE_DOWN_TO_FIT"));
+ l.addEnum("scale-up-to-fit", getEnumProperty(EN_SCALE_UP_TO_FIT, "SCALE_UP_TO_FIT"));
l.setDefault("auto");
l.setPercentBase(LengthBase.IMAGE_INTRINSIC_HEIGHT);
addPropertyMaker("content-height", l);
@@ -1362,6 +1364,8 @@ public final class FOPropertyMapping implements Constants {
l.setInherited(false);
l.addEnum("auto", getEnumProperty(EN_AUTO, "AUTO"));
l.addEnum("scale-to-fit", getEnumProperty(EN_SCALE_TO_FIT, "SCALE_TO_FIT"));
+ l.addEnum("scale-down-to-fit", getEnumProperty(EN_SCALE_DOWN_TO_FIT, "SCALE_DOWN_TO_FIT"));
+ l.addEnum("scale-up-to-fit", getEnumProperty(EN_SCALE_UP_TO_FIT, "SCALE_UP_TO_FIT"));
l.setDefault("auto");
l.setPercentBase(LengthBase.IMAGE_INTRINSIC_WIDTH);
addPropertyMaker("content-width", l);
@@ -2223,6 +2227,7 @@ public final class FOPropertyMapping implements Constants {
m.addEnum("last", getEnumProperty(EN_LAST, "LAST"));
m.addEnum("rest", getEnumProperty(EN_REST, "REST"));
m.addEnum("any", getEnumProperty(EN_ANY, "ANY"));
+ m.addEnum("only", getEnumProperty(EN_ONLY, "ONLY")); //XSL 1.1
m.setDefault("any");
addPropertyMaker("page-position", m);
diff --git a/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java
index ca82d3da7..75f852e06 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java
@@ -104,21 +104,45 @@ public abstract class AbstractGraphicsLayoutManager extends LeafNodeLayoutManage
int cheight = -1;
len = fobj.getContentWidth();
if (len.getEnum() != EN_AUTO) {
- if (len.getEnum() == EN_SCALE_TO_FIT) {
+ switch (len.getEnum()) {
+ case EN_SCALE_TO_FIT:
if (ipd != -1) {
cwidth = ipd;
}
- } else {
+ break;
+ case EN_SCALE_DOWN_TO_FIT:
+ if (ipd != -1 && fobj.getIntrinsicWidth() > ipd) {
+ cwidth = ipd;
+ }
+ break;
+ case EN_SCALE_UP_TO_FIT:
+ if (ipd != -1 && fobj.getIntrinsicWidth() < ipd) {
+ cwidth = ipd;
+ }
+ break;
+ default:
cwidth = len.getValue(this);
}
}
len = fobj.getContentHeight();
if (len.getEnum() != EN_AUTO) {
- if (len.getEnum() == EN_SCALE_TO_FIT) {
+ switch (len.getEnum()) {
+ case EN_SCALE_TO_FIT:
if (bpd != -1) {
cheight = bpd;
}
- } else {
+ break;
+ case EN_SCALE_DOWN_TO_FIT:
+ if (bpd != -1 && fobj.getIntrinsicHeight() > bpd) {
+ cheight = bpd;
+ }
+ break;
+ case EN_SCALE_UP_TO_FIT:
+ if (bpd != -1 && fobj.getIntrinsicHeight() < bpd) {
+ cheight = bpd;
+ }
+ break;
+ default:
cheight = len.getValue(this);
}
}
diff --git a/status.xml b/status.xml
index 7487d67a0..0537ad75d 100644
--- a/status.xml
+++ b/status.xml
@@ -28,6 +28,9 @@
+
+ Added support for scale-down-to-fit and scale-up-to-fit (introduced in XSL 1.1).
+
Bugfix: content of a row with zero height overriding the previous row
diff --git a/test/layoutengine/standard-testcases/external-graphic_content-height_content-width_2.xml b/test/layoutengine/standard-testcases/external-graphic_content-height_content-width_2.xml
new file mode 100644
index 000000000..281da9873
--- /dev/null
+++ b/test/layoutengine/standard-testcases/external-graphic_content-height_content-width_2.xml
@@ -0,0 +1,92 @@
+
+
+
+
+
+
+ This test checks external-graphics with content-width
+ (values: scale-to-fit, scale-down-to-fit and scale-up-to-fit)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
--
cgit v1.2.3
From 0c87214d3a98d0836083d191b36aa7abf944d0dc Mon Sep 17 00:00:00 2001
From: Jeremias Maerki
Date: Thu, 27 Dec 2007 10:34:15 +0000
Subject: Added new extension element: fox:external-document. It allows to add
whole documents such as multi-page TIFF images to be inserted as peers to a
page-sequence. Each image will make up an entire page. See the documentation
for details. ATM, only single pages are possible. Multi-page images will be
supported with the new image package.
Some preparations for page-position="only" but the implementation is incomplete and "only" has no effect, yet. (Just uploaded some stuff I once started)
Some javadoc cleanups.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@607032 13f79535-47bb-0310-9956-ffa450edef68
---
.../content/xdocs/trunk/extensions.xml | 73 ++++
.../org/apache/fop/apps/FormattingResults.java | 6 +-
src/java/org/apache/fop/area/AreaTreeHandler.java | 34 +-
src/java/org/apache/fop/area/RenderPagesModel.java | 2 +-
src/java/org/apache/fop/fo/FOEventHandler.java | 15 +
src/java/org/apache/fop/fo/GraphicsProperties.java | 81 +++++
src/java/org/apache/fop/fo/PropertyList.java | 8 +-
.../fop/fo/extensions/ExtensionElementMapping.java | 7 +
.../apache/fop/fo/extensions/ExternalDocument.java | 181 ++++++++++
.../org/apache/fop/fo/flow/AbstractGraphics.java | 87 +----
.../fop/fo/pagination/AbstractPageSequence.java | 154 +++++++++
.../pagination/ConditionalPageMasterReference.java | 8 +-
.../org/apache/fop/fo/pagination/PageSequence.java | 113 ++----
.../fop/fo/pagination/PageSequenceMaster.java | 15 +-
.../RepeatablePageMasterAlternatives.java | 13 +-
.../pagination/RepeatablePageMasterReference.java | 7 +
src/java/org/apache/fop/fo/pagination/Root.java | 19 +-
.../fo/pagination/SinglePageMasterReference.java | 7 +
.../fop/fo/pagination/SubSequenceSpecifier.java | 5 +
.../fop/layoutmgr/AbstractLayoutManager.java | 4 +-
.../AbstractPageSequenceLayoutManager.java | 385 +++++++++++++++++++++
.../layoutmgr/ExternalDocumentLayoutManager.java | 202 +++++++++++
.../apache/fop/layoutmgr/LayoutManagerMaker.java | 10 +
.../apache/fop/layoutmgr/LayoutManagerMapping.java | 6 +
src/java/org/apache/fop/layoutmgr/Page.java | 14 +
.../org/apache/fop/layoutmgr/PageProvider.java | 2 +-
.../fop/layoutmgr/PageSequenceLayoutManager.java | 383 ++------------------
.../fop/layoutmgr/TopLevelLayoutManager.java | 50 +++
.../inline/AbstractGraphicsLayoutManager.java | 197 ++---------
.../apache/fop/layoutmgr/inline/ImageLayout.java | 262 ++++++++++++++
src/java/org/apache/fop/render/rtf/RTFHandler.java | 3 +-
.../org/apache/fop/render/xml/XMLRenderer.java | 4 +-
status.xml | 5 +
.../standard-testcases/fox_external-document_1.xml | 53 +++
.../standard-testcases/fox_external-document_2.xml | 81 +++++
35 files changed, 1779 insertions(+), 717 deletions(-)
create mode 100644 src/java/org/apache/fop/fo/GraphicsProperties.java
create mode 100644 src/java/org/apache/fop/fo/extensions/ExternalDocument.java
create mode 100644 src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java
create mode 100644 src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java
create mode 100644 src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java
create mode 100644 src/java/org/apache/fop/layoutmgr/TopLevelLayoutManager.java
create mode 100644 src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java
create mode 100644 test/layoutengine/standard-testcases/fox_external-document_1.xml
create mode 100644 test/layoutengine/standard-testcases/fox_external-document_2.xml
(limited to 'src')
diff --git a/src/documentation/content/xdocs/trunk/extensions.xml b/src/documentation/content/xdocs/trunk/extensions.xml
index dd4a79535..288695286 100644
--- a/src/documentation/content/xdocs/trunk/extensions.xml
+++ b/src/documentation/content/xdocs/trunk/extensions.xml
@@ -115,6 +115,79 @@ to following pages. Here is an example of FO code creating such a table-header:<
or list-block.
+
+ fox:external-document
+
+ This feature is incomplete. Support for multi-page documents will be added shortly.
+ At the moment, only single-page images will work. And this will not work with RTF output.
+
+
+ This is a proprietary extension element which allows to add whole images as pages to
+ an FO document. For example, if you have a scanned document or a fax as multi-page TIFF
+ file, you can append or insert this document using the fox:external-document
+ element. Each page of the external document will create one full page in the target
+ format.
+
+
+ The fox:external-document
element is structurally a peer to
+ fo:page-sequence
, so wherever you can put an fo:page-sequence
+ you could also place a fox:external-document
.
+ Therefore, the specified contents for fo:root
change to:
+
+
+
+ (layout-master-set, declarations?, bookmark-tree?, (page-sequence|page-sequence-wrapper|fox:external-document)+)
+
+
+
+ Specification
+
+ The fox:external-document
extension formatting object is used to specify
+ how to create a (sub-)sequence of pages within a document. The content of these pages
+ comes from the individual subimages/pages of an image or paged document (for example:
+ multi-page TIFF in the form of faxes or scanned documents, or PDF files). The
+ formatting object creates the necessary areas to display one image per page.
+
+
+ In terms of page numbers, the behaviour is the same as for
+ fo:page-sequence
. The placement of the image inside the page is similar
+ to that of fo:external-graphic
or fo:instream-foreign-object
,
+ i.e. the viewport (and therefore the page size) is defined by either the intrinsic
+ size of the image or by the size properties that apply to this formatting object.
+
+ Content: EMPTY
+ The following properties apply to this formatting object:
+
+ - (Common Accessibility Properties) (not implemented, yet)
+ - (Common Aural Properties) (not implemented, yet)
+ - block-progression-dimension
+ - content-height
+ - content-type
+ - content-width
+ - display-align
+ - height
+ - id
+ - inline-progression-dimension
+ - overflow
+ - pages: <page-set> (see below) (not implemented, yet)
+ - reference-orientation
+ - scaling
+ - scaling-method
+ - src
+ - text-align
+ - width
+
+
+ Datatype "page-set": Value: auto | <integer-range>,
+ Default: "auto" which means all pages/subimages of the document.
+ <integer-range> allows values such as "7" or "1-3"
+
+
+ fox:external-document
is not suitable for concatenating FO documents.
+ For this, XInclude is recommended.
+
+
+