From 0129d4c43c3f3152a7dc65c4208b8edb420bf8f1 Mon Sep 17 00:00:00 2001 From: William Victor Mote Date: Fri, 2 May 2003 15:09:59 +0000 Subject: [PATCH] Refactor: extract method findNearestAncestorGeneratingRAs() from setWritingMode(). git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196389 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/fo/FObj.java | 30 +++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/java/org/apache/fop/fo/FObj.java b/src/java/org/apache/fop/fo/FObj.java index 9caf7af97..a35729774 100644 --- a/src/java/org/apache/fop/fo/FObj.java +++ b/src/java/org/apache/fop/fo/FObj.java @@ -172,6 +172,23 @@ public class FObj extends FONode { return (FObj)par; } + /** + * Find nearest ancestor, including self, which generates + * reference areas. + * If no such ancestor is found, use the value on the root FO. + * + * @return FObj of the nearest ancestor that generates Reference Areas + */ + private FObj findNearestAncestorGeneratingRAs() { + FObj p; + FONode parent; + for (p = this; !p.generatesReferenceAreas() + && (parent = p.getParent()) != null + && (parent instanceof FObj); p = (FObj) parent) { + } + return p; + } + public PropertyList getPropertiesForNamespace(String nameSpaceURI) { if (this.properties == null) { return null; @@ -283,17 +300,11 @@ public class FObj extends FONode { /** * Set writing mode for this FO. - * Find nearest ancestor, including self, which generates - * reference areas and use the value of its writing-mode property. - * If no such ancestor is found, use the value on the root FO. + * Use that from the nearest ancestor, including self, which generates + * reference areas, or from root FO if no ancestor found. */ protected void setWritingMode() { - FObj p; - FONode parent; - for (p = this; !p.generatesReferenceAreas() - && (parent = p.getParent()) != null - && (parent instanceof FObj); p = (FObj) parent) { - } + FObj p = findNearestAncestorGeneratingRAs(); this.properties.setWritingMode( p.getProperty("writing-mode").getEnum()); } @@ -339,6 +350,7 @@ public class FObj extends FONode { * If this object can contain markers it checks that the marker * has a unique class-name for this object and that it is * the first child. + * @param marker Marker to add. */ public void addMarker(Marker marker) { String mcname = marker.getMarkerClassName(); -- 2.39.5