aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/fo/FObj.java
diff options
context:
space:
mode:
authorWilliam Victor Mote <vmote@apache.org>2003-05-02 18:54:10 +0000
committerWilliam Victor Mote <vmote@apache.org>2003-05-02 18:54:10 +0000
commitcebfaa1cff9666f54deed91bc032b2a1868dde6f (patch)
tree8e78c2f83c11a9b212f7042db698d0717ad77d3a /src/java/org/apache/fop/fo/FObj.java
parentf38f1324a9af2a9faad3b3a810ddbe2a937d5769 (diff)
downloadxmlgraphics-fop-cebfaa1cff9666f54deed91bc032b2a1868dde6f.tar.gz
xmlgraphics-fop-cebfaa1cff9666f54deed91bc032b2a1868dde6f.zip
Add params includeSelf and returnRoot to findNearestAncestorGeneratingRAs() for a more general solution.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196391 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/fo/FObj.java')
-rw-r--r--src/java/org/apache/fop/fo/FObj.java39
1 files changed, 31 insertions, 8 deletions
diff --git a/src/java/org/apache/fop/fo/FObj.java b/src/java/org/apache/fop/fo/FObj.java
index c008b5ac9..ca33fdcc8 100644
--- a/src/java/org/apache/fop/fo/FObj.java
+++ b/src/java/org/apache/fop/fo/FObj.java
@@ -173,20 +173,43 @@ public class FObj extends FONode {
}
/**
- * Find nearest ancestor, including self, which generates
- * reference areas.
- * If no such ancestor is found, use the value on the root FO.
+ * Find nearest ancestor which generates Reference Areas.
*
+ * @param includeSelf Set to true to consider the current FObj as an
+ * "ancestor". Set to false to only return a true ancestor.
+ * @param returnRoot Supposing a condition where no appropriate ancestor
+ * FObj is found, setting returnRoot to true will return the FObj with no
+ * parent (presumably the root FO). Otherwise, null will be returned.
+ * Note that this will override a false setting for includeSelf, and return
+ * the current node if it is the root FO. Setting returnRoot to true should
+ * always return a valid FObj.
* @return FObj of the nearest ancestor that generates Reference Areas
+ * and fits the parameters.
*/
- private FObj findNearestAncestorGeneratingRAs() {
+ private FObj findNearestAncestorGeneratingRAs(boolean includeSelf,
+ boolean returnRoot) {
FObj p = this;
+ if (includeSelf && p.generatesReferenceAreas()) {
+ return p;
+ }
FObj parent = p.findNearestAncestorFObj();
- while (parent != null && !p.generatesReferenceAreas()) {
- p = (FObj) parent;
+ if (parent == null && returnRoot) {
+ return p;
+ }
+ do {
+ p = parent;
parent = p.findNearestAncestorFObj();
+ } while (parent != null && !p.generatesReferenceAreas());
+ if (p.generatesReferenceAreas()) {
+ return p;
+ }
+ // if we got here, it is because parent is null
+ if (returnRoot) {
+ return p;
+ }
+ else {
+ return null;
}
- return p;
}
public PropertyList getPropertiesForNamespace(String nameSpaceURI) {
@@ -304,7 +327,7 @@ public class FObj extends FONode {
* reference areas, or from root FO if no ancestor found.
*/
protected void setWritingMode() {
- FObj p = findNearestAncestorGeneratingRAs();
+ FObj p = findNearestAncestorGeneratingRAs(true, true);
this.properties.setWritingMode(
p.getProperty("writing-mode").getEnum());
}