vmote       2003/08/15 08:52:10

  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
               src/java/org/apache/fop/fo FOInputHandler.java
                        FOTreeHandler.java
               src/java/org/apache/fop/mif MIFHandler.java
               src/java/org/apache/fop/render/ps PSDocumentGraphics2D.java
               src/java/org/apache/fop/rtf/renderer RTFHandler.java
               src/java/org/apache/fop/svg PDFDocumentGraphics2D.java
                        PDFGraphics2D.java
               src/java/org/apache/fop/tools AreaTreeBuilder.java
  Log:
  1. integrate Document and LayoutStrategy into workflow
  2. make Document a child of Driver and start integrating this hierarchy
  
  Revision  Changes    Path
  1.24      +21 -5     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.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- Driver.java       13 Aug 2003 05:32:54 -0000      1.23
  +++ Driver.java       15 Aug 2003 15:52:10 -0000      1.24
  @@ -53,6 +53,7 @@
   // FOP
   import org.apache.fop.area.AreaTree;
   import org.apache.fop.area.AreaTreeModel;
  +import org.apache.fop.control.Document;
   import org.apache.fop.fo.ElementMapping;
   import org.apache.fop.fo.FOTreeBuilder;
   import org.apache.fop.fo.FOUserAgent;
  @@ -68,6 +69,8 @@
   import org.apache.fop.rtf.renderer.RTFHandler;
   import org.apache.fop.tools.DocumentInputSource;
   import org.apache.fop.tools.DocumentReader;
  +import org.apache.fop.layout.LayoutStrategy;
  +import org.apache.fop.layoutmgr.LayoutManagerLS;
   
   // Avalon
   import org.apache.avalon.framework.logger.ConsoleLogger;
  @@ -75,7 +78,8 @@
   import org.apache.avalon.framework.logger.Logger;
   
   // DOM
  -import org.w3c.dom.Document;
  +/* org.w3c.dom.Document is not imported to reduce confusion with
  +   org.apache.fop.control.Document */
   
   // SAX
   import org.xml.sax.ContentHandler;
  @@ -233,6 +237,8 @@
       private AreaTree areaTree;
       private AreaTreeModel atModel;
   
  +    private Document currentDocument = null;
  +
       /**
        * Main constructor for the Driver class.
        */
  @@ -540,15 +546,15 @@
           // TODO: - do this stuff in a better way
           // PIJ: I guess the structure handler should be created by the renderer.
           if (rendererType == RENDER_MIF) {
  -            foInputHandler = new MIFHandler(this, stream);
  +            foInputHandler = new MIFHandler(currentDocument, stream);
           } else if (rendererType == RENDER_RTF) {
  -            foInputHandler = new RTFHandler(this, stream);
  +            foInputHandler = new RTFHandler(currentDocument, stream);
           } else {
               if (renderer == null) {
                   throw new IllegalStateException(
                           "Renderer not set when using standard foInputHandler");
               }
  -            foInputHandler = new FOTreeHandler(this, stream, renderer, true);
  +            foInputHandler = new FOTreeHandler(currentDocument, stream, renderer, 
true);
           }
   
           foInputHandler.enableLogging(getLogger());
  @@ -584,7 +590,17 @@
           if (!isInitialized()) {
               initialize();
           }
  +        /** Document creation is hard-wired for now, but needs to be made
  +         accessible through the API and/or configuration */
  +        if (currentDocument == null) {
  +            currentDocument = new Document(this);
  +        }
           parser.setContentHandler(getContentHandler());
  +        /** LayoutStrategy is hard-wired for now, but needs to be made
  +        accessible through the API and/or configuration */
  +        if (foInputHandler instanceof FOTreeHandler) {
  +            currentDocument.setLayoutStrategy(new LayoutManagerLS());
  +        }
           try {
               if (foInputHandler instanceof FOTreeHandler) {
                   FOTreeHandler foTreeHandler = (FOTreeHandler)foInputHandler;
  @@ -631,7 +647,7 @@
        * @param document the DOM document to read from
        * @throws FOPException if anything goes wrong.
        */
  -    public synchronized void render(Document document)
  +    public synchronized void render(org.w3c.dom.Document document)
                   throws FOPException {
           DocumentInputSource source = new DocumentInputSource(document);
           DocumentReader reader = new DocumentReader();
  
  
  
  1.3       +36 -9     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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Document.java     14 Aug 2003 19:16:41 -0000      1.2
  +++ Document.java     15 Aug 2003 15:52:10 -0000      1.3
  @@ -54,20 +54,20 @@
   import java.util.Map;
   
   // FOP
  +import org.apache.fop.apps.Driver;
   import org.apache.fop.fonts.Font;
   import org.apache.fop.fonts.FontMetrics;
  +import org.apache.fop.layout.LayoutStrategy;
   
   /**
  - * The FontInfo for the layout and rendering of a fo document.
  - * This stores the list of available fonts that are setup by
  - * the renderer. The font name can be retrieved for the
  - * family style and weight.
  - * <br>
  - * Currently font supported font-variant small-caps is not
  - * implemented.
  + * Class storing information for the FOP Document being processed, and managing
  + * the processing of it.
    */
   public class Document {
   
  +    /** The parent Driver object */
  +    private Driver driver;
  +
       /** Map containing fonts that have been used */
       private Map usedFonts;
   
  @@ -78,9 +78,17 @@
       private Map fonts;
   
       /**
  +     * the LayoutStrategy to be used to process this document
  +     * TODO: this actually belongs in the RenderContext class, when it is
  +     * created
  +     */
  +    private LayoutStrategy ls = null;
  +
  +    /**
        * Main constructor
        */
  -    public Document() {
  +    public Document(Driver driver) {
  +        this.driver = driver;
           this.triplets = new java.util.HashMap();
           this.fonts = new java.util.HashMap();
           this.usedFonts = new java.util.HashMap();
  @@ -261,6 +269,25 @@
       public FontMetrics getMetricsFor(String fontName) {
           usedFonts.put(fontName, fonts.get(fontName));
           return (FontMetrics)fonts.get(fontName);
  +    }
  +
  +    /**
  +     * Set the LayoutStrategy to be used to process this Document
  +     * @param ls the LayoutStrategy object to be used to process this Document
  +     */
  +    public void setLayoutStrategy(LayoutStrategy ls) {
  +        this.ls = ls;
  +    }
  +
  +    /**
  +     * @return this Document's LayoutStrategy object
  +     */
  +    public LayoutStrategy getLayoutStrategy () {
  +        return ls;
  +    }
  +
  +    public Driver getDriver() {
  +        return driver;
       }
   }
   
  
  
  
  1.6       +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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Bookmarks.java    12 Aug 2003 06:18:43 -0000      1.5
  +++ Bookmarks.java    15 Aug 2003 15:52:10 -0000      1.6
  @@ -109,7 +109,7 @@
           }
           // add data to area tree for resolving and handling
           if (foInputHandler instanceof FOTreeHandler) {
  -            AreaTree at = ((FOTreeHandler)foInputHandler).driver.getAreaTree();
  +            AreaTree at = 
((FOTreeHandler)foInputHandler).doc.getDriver().getAreaTree();
               at.addTreeExtension(data);
               data.setAreaTree(at);
           }
  
  
  
  1.5       +6 -4      xml-fop/src/java/org/apache/fop/fo/FOInputHandler.java
  
  Index: FOInputHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FOInputHandler.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- FOInputHandler.java       14 Aug 2003 07:42:58 -0000      1.4
  +++ FOInputHandler.java       15 Aug 2003 15:52:10 -0000      1.5
  @@ -94,13 +94,15 @@
        */
       private Set idReferences = new HashSet();
   
  -    public Driver driver = null;
  +//    public Driver driver = null;
  +
  +    public Document doc = null;
   
       /**
        * Main constructor
        */
  -    public FOInputHandler(Driver driver) {
  -        this.driver = driver;
  +    public FOInputHandler(Document document) {
  +        this.doc = document;
       }
   
       /**
  
  
  
  1.5       +6 -11     xml-fop/src/java/org/apache/fop/fo/FOTreeHandler.java
  
  Index: FOTreeHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FOTreeHandler.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- FOTreeHandler.java        14 Aug 2003 07:42:58 -0000      1.4
  +++ FOTreeHandler.java        15 Aug 2003 15:52:10 -0000      1.5
  @@ -128,11 +128,6 @@
       private Renderer renderer;
   
       /**
  -     * The FontInfo for this renderer.
  -     */
  -    private Document fontInfo = new Document();
  -
  -    /**
        * Collection of objects that have registered to be notified about
        * FOTreeEvent firings.
        */
  @@ -145,9 +140,9 @@
        * @param store if true then use the store pages model and keep the
        *              area tree in memory
        */
  -    public FOTreeHandler(Driver driver, OutputStream outputStream, Renderer 
renderer,
  +    public FOTreeHandler(Document document, OutputStream outputStream, Renderer 
renderer,
                            boolean store) {
  -        super(driver);
  +        super(document);
           if (collectStatistics) {
               runtime = Runtime.getRuntime();
           }
  @@ -174,9 +169,9 @@
               startTime = System.currentTimeMillis();
           }
           try {
  -            renderer.setupFontInfo(fontInfo);
  +            renderer.setupFontInfo(doc);
               // check that the "any,normal,400" font exists
  -            if (!fontInfo.isSetupValid()) {
  +            if (!doc.isSetupValid()) {
                   throw new SAXException(new FOPException(
                           "No default font defined by OutputConverter"));
               }
  @@ -478,7 +473,7 @@
        * @return the font information
        */
       public Document getFontInfo() {
  -        return this.fontInfo;
  +        return this.doc;
       }
   
       /**
  
  
  
  1.10      +3 -11     xml-fop/src/java/org/apache/fop/mif/MIFHandler.java
  
  Index: MIFHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/mif/MIFHandler.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- MIFHandler.java   14 Aug 2003 07:42:58 -0000      1.9
  +++ MIFHandler.java   15 Aug 2003 15:52:10 -0000      1.10
  @@ -91,7 +91,6 @@
       protected MIFFile mifFile;
       /** the OutputStream to write to */
       protected OutputStream outStream;
  -    private Document fontInfo = new Document();
   
       // current state elements
       private MIFElement textFlow;
  @@ -101,18 +100,11 @@
        * Creates a new MIF handler on a given OutputStream.
        * @param os OutputStream to write to
        */
  -    public MIFHandler(Driver driver, OutputStream os) {
  -        super(driver);
  +    public MIFHandler(Document doc, OutputStream os) {
  +        super(doc);
           outStream = os;
           // use pdf fonts for now, this is only for resolving names
  -        org.apache.fop.render.pdf.FontSetup.setup(fontInfo, null);
  -    }
  -
  -    /**
  -     * @see org.apache.fop.fo.FOInputHandler#getFontInfo()
  -     */
  -    public Document getFontInfo() {
  -        return fontInfo;
  +        org.apache.fop.render.pdf.FontSetup.setup(doc, null);
       }
   
       /**
  
  
  
  1.6       +1 -1      
xml-fop/src/java/org/apache/fop/render/ps/PSDocumentGraphics2D.java
  
  Index: PSDocumentGraphics2D.java
  ===================================================================
  RCS file: 
/home/cvs/xml-fop/src/java/org/apache/fop/render/ps/PSDocumentGraphics2D.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PSDocumentGraphics2D.java 14 Aug 2003 07:42:58 -0000      1.5
  +++ PSDocumentGraphics2D.java 15 Aug 2003 15:52:10 -0000      1.6
  @@ -94,7 +94,7 @@
           super(textAsShapes);
   
           if (!textAsShapes) {
  -            fontInfo = new Document();
  +            fontInfo = new Document(null);
               FontSetup.setup(fontInfo, null);
               //FontState fontState = new FontState("Helvetica", "normal",
               //                          FontInfo.NORMAL, 12, 0);
  
  
  
  1.14      +3 -11     xml-fop/src/java/org/apache/fop/rtf/renderer/RTFHandler.java
  
  Index: RTFHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/rtf/renderer/RTFHandler.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- RTFHandler.java   14 Aug 2003 07:42:58 -0000      1.13
  +++ RTFHandler.java   15 Aug 2003 15:52:10 -0000      1.14
  @@ -90,7 +90,6 @@
    */
   public class RTFHandler extends FOInputHandler {
   
  -    private Document fontInfo = new Document();
       private RtfFile rtfFile;
       private final OutputStream os;
       private RtfSection sect;
  @@ -111,19 +110,12 @@
        * Creates a new RTF structure handler.
        * @param os OutputStream to write to
        */
  -    public RTFHandler(Driver driver, OutputStream os) {
  -        super(driver);
  +    public RTFHandler(Document doc, OutputStream os) {
  +        super(doc);
           this.os = os;
           // use pdf fonts for now, this is only for resolving names
  -        org.apache.fop.render.pdf.FontSetup.setup(fontInfo, null);
  +        org.apache.fop.render.pdf.FontSetup.setup(doc, null);
           System.err.println(ALPHA_WARNING);
  -    }
  -
  -    /**
  -     * @see org.apache.fop.fo.FOInputHandler#getFontInfo()
  -     */
  -    public Document getFontInfo() {
  -        return this.fontInfo;
       }
   
       /**
  
  
  
  1.5       +15 -15    xml-fop/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java
  
  Index: PDFDocumentGraphics2D.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PDFDocumentGraphics2D.java        14 Aug 2003 07:42:58 -0000      1.4
  +++ PDFDocumentGraphics2D.java        15 Aug 2003 15:52:10 -0000      1.5
  @@ -3,34 +3,34 @@
    * ============================================================================
    *                    The Apache Software License, Version 1.1
    * ============================================================================
  - * 
  + *
    * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  - * 
  + *
    * Redistribution and use in source and binary forms, with or without modifica-
    * tion, are permitted provided that the following conditions are met:
  - * 
  + *
    * 1. Redistributions of source code must retain the above copyright notice,
    *    this list of conditions and the following disclaimer.
  - * 
  + *
    * 2. Redistributions in binary form must reproduce the above copyright notice,
    *    this list of conditions and the following disclaimer in the documentation
    *    and/or other materials provided with the distribution.
  - * 
  + *
    * 3. The end-user documentation included with the redistribution, if any, must
    *    include the following acknowledgment: "This product includes software
    *    developed by the Apache Software Foundation (http://www.apache.org/)."
    *    Alternately, this acknowledgment may appear in the software itself, if
    *    and wherever such third-party acknowledgments normally appear.
  - * 
  + *
    * 4. The names "FOP" and "Apache Software Foundation" must not be used to
    *    endorse or promote products derived from this software without prior
    *    written permission. For written permission, please contact
    *    [EMAIL PROTECTED]
  - * 
  + *
    * 5. Products derived from this software may not be called "Apache", nor may
    *    "Apache" appear in their name, without prior written permission of the
    *    Apache Software Foundation.
  - * 
  + *
    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
    * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
    * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  @@ -42,12 +42,12 @@
    * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
    * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    * ============================================================================
  - * 
  + *
    * This software consists of voluntary contributions made by many individuals
    * on behalf of the Apache Software Foundation and was originally created by
    * James Tauber <[EMAIL PROTECTED]>. For more information on the Apache
    * Software Foundation, please see <http://www.apache.org/>.
  - */ 
  + */
   package org.apache.fop.svg;
   
   import org.apache.fop.pdf.PDFDocument;
  @@ -93,13 +93,13 @@
    */
   public class PDFDocumentGraphics2D extends PDFGraphics2D
               implements LogEnabled, Configurable, Initializable {
  -    
  +
       private PDFPage currentPage;
       private PDFStream pdfStream;
       private int width;
       private int height;
       private List fontList;
  -    
  +
       //Avalon-dependent stuff
       private Logger logger;
       private Configuration cfg;
  @@ -119,7 +119,7 @@
           super(textAsShapes);
   
           if (!textAsShapes) {
  -            fontInfo = new Document();
  +            fontInfo = new Document(null);
               FontSetup.setup(fontInfo, null);
               //FontState fontState = new FontState("Helvetica", "normal",
               //                          FontInfo.NORMAL, 12, 0);
  @@ -195,7 +195,7 @@
        */
       public void initialize() throws Exception {
           if (this.fontInfo == null) {
  -            fontInfo = new Document();
  +            fontInfo = new Document(null);
               FontSetup.setup(fontInfo, this.fontList);
               //FontState fontState = new FontState("Helvetica", "normal",
               //                          FontInfo.NORMAL, 12, 0);
  @@ -207,7 +207,7 @@
               this.pdfDoc.setFilterMap(
                   PDFFilterList.buildFilterMapFromConfiguration(cfg));
           }
  -        
  +
           graphicsState = new PDFState();
   
           currentFontName = "";
  
  
  
  1.9       +1 -1      xml-fop/src/java/org/apache/fop/svg/PDFGraphics2D.java
  
  Index: PDFGraphics2D.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/svg/PDFGraphics2D.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- PDFGraphics2D.java        14 Aug 2003 19:16:41 -0000      1.8
  +++ PDFGraphics2D.java        15 Aug 2003 15:52:10 -0000      1.9
  @@ -983,7 +983,7 @@
       private void createPattern(PatternPaint pp, boolean fill) {
           Rectangle2D rect = pp.getPatternRect();
   
  -        Document fi = new Document();
  +        Document fi = new Document(null);
           FontSetup.setup(fi, null);
   
           PDFResources res = pdfDoc.getFactory().makeResources();
  
  
  
  1.5       +1 -1      xml-fop/src/java/org/apache/fop/tools/AreaTreeBuilder.java
  
  Index: AreaTreeBuilder.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/tools/AreaTreeBuilder.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AreaTreeBuilder.java      14 Aug 2003 19:16:41 -0000      1.4
  +++ AreaTreeBuilder.java      15 Aug 2003 15:52:10 -0000      1.5
  @@ -169,7 +169,7 @@
               rend = new SVGRenderer();
           }
           setupLogger(rend);
  -        Document fi = new Document();
  +        Document fi = new Document(null);
           rend.setupFontInfo(fi);
           FOUserAgent ua = new FOUserAgent();
           setupLogger(ua);
  
  
  

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

Reply via email to