diff options
author | William Victor Mote <vmote@apache.org> | 2003-09-02 13:56:40 +0000 |
---|---|---|
committer | William Victor Mote <vmote@apache.org> | 2003-09-02 13:56:40 +0000 |
commit | 37f1c80b0f0f99b96fc06a560aaeb41c7b409dfe (patch) | |
tree | cc7251dc30ea6938784d3be7c93f5602a24fcf4c /src/java/org | |
parent | b35e94b1df6972593ec2b0ac2fabb560feaddb35 (diff) | |
download | xmlgraphics-fop-37f1c80b0f0f99b96fc06a560aaeb41c7b409dfe.tar.gz xmlgraphics-fop-37f1c80b0f0f99b96fc06a560aaeb41c7b409dfe.zip |
Remove storage of apps/FOUserAgent from fo/FONode in favor of storing it once in a higher level class (currently Driver), and accessing it from there. Cleaner design, uses less memory, at the expense of some additional processing time to come up the tree to find the information.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196888 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org')
-rw-r--r-- | src/java/org/apache/fop/apps/Document.java | 19 | ||||
-rw-r--r-- | src/java/org/apache/fop/apps/Driver.java | 2 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/FONode.java | 15 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/FOTreeBuilder.java | 5 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/FOTreeControl.java | 15 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/FObjMixed.java | 1 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/extensions/svg/SVGElement.java | 6 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/flow/ExternalGraphic.java | 4 | ||||
-rw-r--r-- | src/java/org/apache/fop/layoutmgr/AddLMVisitor.java | 1 |
9 files changed, 43 insertions, 25 deletions
diff --git a/src/java/org/apache/fop/apps/Document.java b/src/java/org/apache/fop/apps/Document.java index 5d985bb16..b5efd34eb 100644 --- a/src/java/org/apache/fop/apps/Document.java +++ b/src/java/org/apache/fop/apps/Document.java @@ -58,6 +58,8 @@ import java.util.HashSet; // FOP +import org.apache.fop.apps.FOUserAgent; + import org.apache.fop.area.AreaTree; import org.apache.fop.area.AreaTreeModel; @@ -74,6 +76,9 @@ import org.apache.fop.layout.LayoutStrategy; // SAX import org.xml.sax.SAXException; +// Avalon +import org.apache.avalon.framework.logger.Logger; + /** * Class storing information for the FOP Document being processed, and managing * the processing of it. @@ -397,4 +402,18 @@ public class Document implements FOTreeControl, FOTreeListener { return foInputHandler; } + /** + * @return the Logger to be used for processing this Document + */ + public Logger getLogger() { + return getDriver().getLogger(); + } + + /** + * @return the FOUserAgent used for processing this document + */ + public FOUserAgent getUserAgent() { + return getDriver().getUserAgent(); + } + } diff --git a/src/java/org/apache/fop/apps/Driver.java b/src/java/org/apache/fop/apps/Driver.java index 94f5cd93f..266120447 100644 --- a/src/java/org/apache/fop/apps/Driver.java +++ b/src/java/org/apache/fop/apps/Driver.java @@ -274,7 +274,7 @@ public class Driver implements LogEnabled { userAgent = agent; } - private FOUserAgent getUserAgent() { + protected FOUserAgent getUserAgent() { if (userAgent == null) { userAgent = new FOUserAgent(); userAgent.enableLogging(getLogger()); diff --git a/src/java/org/apache/fop/fo/FONode.java b/src/java/org/apache/fop/fo/FONode.java index 079ee5d9c..a7d63904c 100644 --- a/src/java/org/apache/fop/fo/FONode.java +++ b/src/java/org/apache/fop/fo/FONode.java @@ -69,9 +69,6 @@ import org.apache.fop.apps.FOUserAgent; * */ public abstract class FONode { - - /** FO User Agent for this node (for logger etc.)*/ - protected FOUserAgent userAgent; /** Parent FO node */ protected FONode parent; /** Name of the node */ @@ -98,15 +95,7 @@ public abstract class FONode { * @return the logger */ public Logger getLogger() { - return userAgent.getLogger(); - } - - /** - * Sets the user agent for the node. - * @param ua the user agent - */ - public void setUserAgent(FOUserAgent ua) { - userAgent = ua; + return getFOTreeControl().getLogger(); } /** @@ -114,7 +103,7 @@ public abstract class FONode { * @return FOUserAgent */ public FOUserAgent getUserAgent() { - return userAgent; + return getFOTreeControl().getUserAgent(); } /** diff --git a/src/java/org/apache/fop/fo/FOTreeBuilder.java b/src/java/org/apache/fop/fo/FOTreeBuilder.java index a8b56cb76..d438d440a 100644 --- a/src/java/org/apache/fop/fo/FOTreeBuilder.java +++ b/src/java/org/apache/fop/fo/FOTreeBuilder.java @@ -278,11 +278,6 @@ public class FOTreeBuilder extends DefaultHandler { try { fobj = fobjMaker.make(currentFObj); fobj.setName(localName); - // set the user agent for resolving user agent values - fobj.setUserAgent(userAgent); - // set the structure handler so that appropriate - // elements can signal structure events - fobj.handleAttrs(attlist); } catch (FOPException e) { throw new SAXException(e); diff --git a/src/java/org/apache/fop/fo/FOTreeControl.java b/src/java/org/apache/fop/fo/FOTreeControl.java index 79621ffa3..73ffa914b 100644 --- a/src/java/org/apache/fop/fo/FOTreeControl.java +++ b/src/java/org/apache/fop/fo/FOTreeControl.java @@ -56,9 +56,13 @@ import java.util.Map; import java.util.Set; // FOP +import org.apache.fop.apps.FOUserAgent; import org.apache.fop.fo.extensions.Bookmarks; import org.apache.fop.fonts.FontMetrics; +// Avalon +import org.apache.avalon.framework.logger.Logger; + /** * An interface for classes that are conceptually the parent class of the * fo.pagination.Root object. The purpose of the interface is to maintain @@ -118,4 +122,15 @@ public interface FOTreeControl { * @return the FOInputHandler for parsing this FO Tree */ FOInputHandler getFOInputHandler(); + + /** + * @return the Logger being used with this FO Tree + */ + Logger getLogger(); + + /** + * @return the FOUserAgent used for processing this FO Tree + */ + FOUserAgent getUserAgent(); + } diff --git a/src/java/org/apache/fop/fo/FObjMixed.java b/src/java/org/apache/fop/fo/FObjMixed.java index 8d1096173..aca9803f2 100644 --- a/src/java/org/apache/fop/fo/FObjMixed.java +++ b/src/java/org/apache/fop/fo/FObjMixed.java @@ -79,7 +79,6 @@ public class FObjMixed extends FObj { } FOText ft = new FOText(data, start, length, textInfo, this); - ft.setUserAgent(userAgent); getFOTreeControl().getFOInputHandler().characters(ft.ca, ft.start, ft.length); addChild(ft); } diff --git a/src/java/org/apache/fop/fo/extensions/svg/SVGElement.java b/src/java/org/apache/fop/fo/extensions/svg/SVGElement.java index 893a72041..44d61c800 100644 --- a/src/java/org/apache/fop/fo/extensions/svg/SVGElement.java +++ b/src/java/org/apache/fop/fo/extensions/svg/SVGElement.java @@ -114,7 +114,7 @@ public class SVGElement extends SVGObj { /* if width and height are zero, get the bounds of the content. */ try { - String baseDir = userAgent.getBaseURL(); + String baseDir = getUserAgent().getBaseURL(); if (baseDir != null) { ((SVGOMDocument)doc).setURLObject(new URL(baseDir)); } @@ -123,7 +123,7 @@ public class SVGElement extends SVGObj { } Element e = ((SVGDocument)doc).getRootElement(); - final float ptmm = userAgent.getPixelUnitToMillimeter(); + final float ptmm = getUserAgent().getPixelUnitToMillimeter(); // temporary svg context SVGContext dc = new SVGContext() { public float getPixelToMM() { @@ -179,7 +179,7 @@ public class SVGElement extends SVGObj { SVGDOMImplementation.SVG_NAMESPACE_URI); //} int fontSize = 12; - Point2D p2d = getSize(fontSize, svgRoot, userAgent.getPixelUnitToMillimeter()); + Point2D p2d = getSize(fontSize, svgRoot, getUserAgent().getPixelUnitToMillimeter()); ((SVGOMElement)e).setSVGContext(null); return p2d; diff --git a/src/java/org/apache/fop/fo/flow/ExternalGraphic.java b/src/java/org/apache/fop/fo/flow/ExternalGraphic.java index e00bbffd9..8dff84d92 100644 --- a/src/java/org/apache/fop/fo/flow/ExternalGraphic.java +++ b/src/java/org/apache/fop/fo/flow/ExternalGraphic.java @@ -151,14 +151,14 @@ public class ExternalGraphic extends FObj { int scaling = properties.get("scaling").getEnum(); if ((scaling == Scaling.UNIFORM) || (cwidth == -1) || cheight == -1) { ImageFactory fact = ImageFactory.getInstance(); - fopimage = fact.getImage(url, userAgent); + fopimage = fact.getImage(url, getUserAgent()); if (fopimage == null) { // error url = null; return; } // load dimensions - if (!fopimage.load(FopImage.DIMENSIONS, userAgent)) { + if (!fopimage.load(FopImage.DIMENSIONS, getUserAgent())) { // error url = null; return; diff --git a/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java b/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java index 911b5b4f2..b884c5046 100644 --- a/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java +++ b/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java @@ -176,6 +176,7 @@ public class AddLMVisitor extends FOTreeVisitor { if (node.getChildren() != null) { InlineStackingLayoutManager lm; lm = new InlineStackingLayoutManager(); + Document doc = (Document)node.getFOTreeControl(); lm.setUserAgent(node.getUserAgent()); lm.setFObj(node); lm.setLMiter(new LMiter(node.getChildren())); |