vmote       2003/08/20 09:35:27

  Modified:    src/java/org/apache/fop/apps Driver.java
               src/java/org/apache/fop/control Document.java
               src/java/org/apache/fop/extensions Bookmarks.java
  Log:
  move some fields and methods from Driver to Document
  
  Revision  Changes    Path
  1.30      +7 -56     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.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- Driver.java       19 Aug 2003 22:17:57 -0000      1.29
  +++ Driver.java       20 Aug 2003 16:35:27 -0000      1.30
  @@ -59,8 +59,6 @@
   import org.apache.fop.fo.FOUserAgent;
   import org.apache.fop.fo.FOInputHandler;
   import org.apache.fop.fo.FOTreeHandler;
  -import org.apache.fop.fo.FOTreeListener;
  -import org.apache.fop.fo.FOTreeEvent;
   import org.apache.fop.area.Title;
   import org.apache.fop.fo.pagination.PageSequence;
   import org.apache.fop.mif.MIFHandler;
  @@ -138,7 +136,7 @@
    * driver.render(parser, fileInputSource(args[0]));
    * </PRE>
    */
  -public class Driver implements LogEnabled, FOTreeListener {
  +public class Driver implements LogEnabled {
   
       /**
        * private constant to indicate renderer was not defined.
  @@ -236,12 +234,6 @@
       private Logger log = null;
       private FOUserAgent userAgent = null;
   
  -    /**
  -     * The current AreaTree for the PageSequence being rendered.
  -     */
  -    private AreaTree areaTree;
  -    private AreaTreeModel atModel;
  -
       private Document currentDocument = null;
   
       /**
  @@ -597,11 +589,11 @@
           try {
               if (foInputHandler instanceof FOTreeHandler) {
                   FOTreeHandler foTreeHandler = (FOTreeHandler)foInputHandler;
  -                foTreeHandler.addFOTreeListener(this);
  -                this.areaTree = new AreaTree();
  -                this.atModel = AreaTree.createRenderPagesModel(renderer);
  +                foTreeHandler.addFOTreeListener(currentDocument);
  +                currentDocument.areaTree = new AreaTree();
  +                currentDocument.atModel = AreaTree.createRenderPagesModel(renderer);
                   //this.atModel = new CachedRenderPagesModel(renderer);
  -                areaTree.setTreeModel(atModel);
  +                currentDocument.areaTree.setTreeModel(currentDocument.atModel);
               }
               /**
                The following statement triggers virtually all of the processing
  @@ -619,7 +611,7 @@
               parser.parse(source);
               if (foInputHandler instanceof FOTreeHandler) {
                   FOTreeHandler foTreeHandler = (FOTreeHandler)foInputHandler;
  -                foTreeHandler.removeFOTreeListener(this);
  +                foTreeHandler.removeFOTreeListener(currentDocument);
               }
           } catch (SAXException e) {
               if (e.getException() instanceof FOPException) {
  @@ -661,7 +653,7 @@
               initialize();
           }
   
  -        if (renderer == null && rendererType != RENDER_RTF 
  +        if (renderer == null && rendererType != RENDER_RTF
               && rendererType != RENDER_MIF) {
                   setRenderer(RENDER_PDF);
           }
  @@ -681,47 +673,6 @@
           } else {
               render(reader, source);
           }
  -    }
  -
  -    /**
  -     * Required by the FOTreeListener interface. It handles an
  -     * FOTreeEvent that is fired when a PageSequence object has been completed.
  -     * @param event the FOTreeEvent that was fired
  -     * @throws FOPException for errors in building the PageSequence
  -     */
  -    public void foPageSequenceComplete (FOTreeEvent event) throws FOPException {
  -        PageSequence pageSeq = event.getPageSequence();
  -        Title title = null;
  -        if (pageSeq.getTitleFO() != null) {
  -            title = pageSeq.getTitleFO().getTitleArea();
  -        }
  -        areaTree.startPageSequence(title);
  -        pageSeq.format(areaTree);
  -    }
  -
  -    /**
  -     * Required by the FOTreeListener interface. It handles an FOTreeEvent that
  -     * is fired when the Document has been completely parsed.
  -     * @param event the FOTreeEvent that was fired
  -     * @throws SAXException for parsing errors
  -     */
  -    public void foDocumentComplete (FOTreeEvent event) throws SAXException {
  -        //processAreaTree(atModel);
  -        try {
  -            areaTree.endDocument();
  -            renderer.stopRenderer();
  -        } catch (IOException ex) {
  -            throw new SAXException(ex);
  -        }
  -    }
  -
  -    /**
  -     * Get the area tree for this layout handler.
  -     *
  -     * @return the area tree for this document
  -     */
  -    public AreaTree getAreaTree() {
  -        return areaTree;
       }
   
   }
  
  
  
  1.5       +61 -2     xml-fop/src/java/org/apache/fop/control/Document.java
  
  Index: Document.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/control/Document.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Document.java     19 Aug 2003 05:19:21 -0000      1.4
  +++ Document.java     20 Aug 2003 16:35:27 -0000      1.5
  @@ -52,19 +52,30 @@
   
   // Java
   import java.util.Map;
  +import java.io.IOException;
   
   // FOP
  +import org.apache.fop.area.AreaTree;
  +import org.apache.fop.area.AreaTreeModel;
   import org.apache.fop.apps.Driver;
  +import org.apache.fop.apps.FOPException;
   import org.apache.fop.fo.FOTreeControl;
  +import org.apache.fop.fo.FOTreeEvent;
  +import org.apache.fop.fo.FOTreeListener;
  +import org.apache.fop.fo.pagination.PageSequence;
  +import org.apache.fop.area.Title;
   import org.apache.fop.fonts.Font;
   import org.apache.fop.fonts.FontMetrics;
   import org.apache.fop.layout.LayoutStrategy;
   
  +// SAX
  +import org.xml.sax.SAXException;
  +
   /**
    * Class storing information for the FOP Document being processed, and managing
    * the processing of it.
    */
  -public class Document implements FOTreeControl {
  +public class Document implements FOTreeControl, FOTreeListener {
   
       /** The parent Driver object */
       private Driver driver;
  @@ -86,6 +97,12 @@
       private LayoutStrategy ls = null;
   
       /**
  +     * The current AreaTree for the PageSequence being rendered.
  +     */
  +    public AreaTree areaTree;
  +    public AreaTreeModel atModel;
  +
  +    /**
        * Main constructor
        */
       public Document(Driver driver) {
  @@ -290,5 +307,47 @@
       public Driver getDriver() {
           return driver;
       }
  +
  +    /**
  +     * Required by the FOTreeListener interface. It handles an
  +     * FOTreeEvent that is fired when a PageSequence object has been completed.
  +     * @param event the FOTreeEvent that was fired
  +     * @throws FOPException for errors in building the PageSequence
  +     */
  +    public void foPageSequenceComplete (FOTreeEvent event) throws FOPException {
  +        PageSequence pageSeq = event.getPageSequence();
  +        Title title = null;
  +        if (pageSeq.getTitleFO() != null) {
  +            title = pageSeq.getTitleFO().getTitleArea();
  +        }
  +        areaTree.startPageSequence(title);
  +        pageSeq.format(areaTree);
  +    }
  +
  +    /**
  +     * Required by the FOTreeListener interface. It handles an FOTreeEvent that
  +     * is fired when the Document has been completely parsed.
  +     * @param event the FOTreeEvent that was fired
  +     * @throws SAXException for parsing errors
  +     */
  +    public void foDocumentComplete (FOTreeEvent event) throws SAXException {
  +        //processAreaTree(atModel);
  +        try {
  +            areaTree.endDocument();
  +            driver.getRenderer().stopRenderer();
  +        } catch (IOException ex) {
  +            throw new SAXException(ex);
  +        }
  +    }
  +
  +    /**
  +     * Get the area tree for this layout handler.
  +     *
  +     * @return the area tree for this document
  +     */
  +    public AreaTree getAreaTree() {
  +        return areaTree;
  +    }
  +
   }
   
  
  
  
  1.9       +1 -1      xml-fop/src/java/org/apache/fop/extensions/Bookmarks.java
  
  Index: Bookmarks.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/extensions/Bookmarks.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Bookmarks.java    19 Aug 2003 06:54:31 -0000      1.8
  +++ Bookmarks.java    20 Aug 2003 16:35:27 -0000      1.9
  @@ -113,7 +113,7 @@
           if (foInputHandler instanceof FOTreeHandler) {
               FOTreeHandler foth = (FOTreeHandler)foInputHandler;
               Document doc = (Document)foth.foTreeControl;
  -            AreaTree at = doc.getDriver().getAreaTree();
  +            AreaTree at = doc.getAreaTree();
               at.addTreeExtension(data);
               data.setAreaTree(at);
           }
  
  
  

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

Reply via email to