vmote       2003/09/02 06:56:40

  Modified:    src/java/org/apache/fop/apps Document.java Driver.java
               src/java/org/apache/fop/fo FONode.java FOTreeBuilder.java
                        FOTreeControl.java FObjMixed.java
               src/java/org/apache/fop/fo/extensions/svg SVGElement.java
               src/java/org/apache/fop/fo/flow ExternalGraphic.java
               src/java/org/apache/fop/layoutmgr AddLMVisitor.java
  Log:
  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.
  
  Revision  Changes    Path
  1.8       +20 -1     xml-fop/src/java/org/apache/fop/apps/Document.java
  
  Index: Document.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/apps/Document.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Document.java     2 Sep 2003 01:31:36 -0000       1.7
  +++ Document.java     2 Sep 2003 13:56:40 -0000       1.8
  @@ -58,6 +58,8 @@
   
   
   // FOP
  +import org.apache.fop.apps.FOUserAgent;
  +
   import org.apache.fop.area.AreaTree;
   import org.apache.fop.area.AreaTreeModel;
   
  @@ -74,6 +76,9 @@
   // 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.
  @@ -395,6 +400,20 @@
        */
       public FOInputHandler getFOInputHandler() {
           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();
       }
   
   }
  
  
  
  1.38      +1 -1      xml-fop/src/java/org/apache/fop/apps/Driver.java
  
  Index: Driver.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/apps/Driver.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- Driver.java       2 Sep 2003 01:31:36 -0000       1.37
  +++ Driver.java       2 Sep 2003 13:56:40 -0000       1.38
  @@ -274,7 +274,7 @@
           userAgent = agent;
       }
   
  -    private FOUserAgent getUserAgent() {
  +    protected FOUserAgent getUserAgent() {
           if (userAgent == null) {
               userAgent = new FOUserAgent();
               userAgent.enableLogging(getLogger());
  
  
  
  1.12      +2 -13     xml-fop/src/java/org/apache/fop/fo/FONode.java
  
  Index: FONode.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FONode.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- FONode.java       2 Sep 2003 01:31:36 -0000       1.11
  +++ FONode.java       2 Sep 2003 13:56:40 -0000       1.12
  @@ -69,9 +69,6 @@
    *
    */
   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 @@
        * @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 @@
        * @return FOUserAgent
        */
       public FOUserAgent getUserAgent() {
  -        return userAgent;
  +        return getFOTreeControl().getUserAgent();
       }
   
       /**
  
  
  
  1.17      +0 -5      xml-fop/src/java/org/apache/fop/fo/FOTreeBuilder.java
  
  Index: FOTreeBuilder.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FOTreeBuilder.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- FOTreeBuilder.java        2 Sep 2003 01:31:36 -0000       1.16
  +++ FOTreeBuilder.java        2 Sep 2003 13:56:40 -0000       1.17
  @@ -278,11 +278,6 @@
           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);
  
  
  
  1.8       +16 -1     xml-fop/src/java/org/apache/fop/fo/FOTreeControl.java
  
  Index: FOTreeControl.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FOTreeControl.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- FOTreeControl.java        2 Sep 2003 01:31:36 -0000       1.7
  +++ FOTreeControl.java        2 Sep 2003 13:56:40 -0000       1.8
  @@ -56,9 +56,13 @@
   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 @@
        * @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();
  +
   }
  
  
  
  1.14      +0 -1      xml-fop/src/java/org/apache/fop/fo/FObjMixed.java
  
  Index: FObjMixed.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FObjMixed.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- FObjMixed.java    2 Sep 2003 01:31:36 -0000       1.13
  +++ FObjMixed.java    2 Sep 2003 13:56:40 -0000       1.14
  @@ -79,7 +79,6 @@
           }
   
           FOText ft = new FOText(data, start, length, textInfo, this);
  -        ft.setUserAgent(userAgent);
           getFOTreeControl().getFOInputHandler().characters(ft.ca, ft.start, 
ft.length);
           addChild(ft);
       }
  
  
  
  1.2       +4 -4      
xml-fop/src/java/org/apache/fop/fo/extensions/svg/SVGElement.java
  
  Index: SVGElement.java
  ===================================================================
  RCS file: 
/home/cvs/xml-fop/src/java/org/apache/fop/fo/extensions/svg/SVGElement.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SVGElement.java   28 Aug 2003 19:49:44 -0000      1.1
  +++ SVGElement.java   2 Sep 2003 13:56:40 -0000       1.2
  @@ -114,7 +114,7 @@
           /* 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 @@
           }
   
           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 @@
                                   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;
  
  
  
  1.9       +2 -2      xml-fop/src/java/org/apache/fop/fo/flow/ExternalGraphic.java
  
  Index: ExternalGraphic.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/ExternalGraphic.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ExternalGraphic.java      25 Aug 2003 15:37:02 -0000      1.8
  +++ ExternalGraphic.java      2 Sep 2003 13:56:40 -0000       1.9
  @@ -151,14 +151,14 @@
           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;
  
  
  
  1.15      +2 -1      xml-fop/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java
  
  Index: AddLMVisitor.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- AddLMVisitor.java 28 Aug 2003 19:08:58 -0000      1.14
  +++ AddLMVisitor.java 2 Sep 2003 13:56:40 -0000       1.15
  @@ -176,6 +176,7 @@
           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()));
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to