You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ke...@apache.org on 2002/06/05 16:52:28 UTC

cvs commit: xml-fop/src/org/apache/fop/render/mif/fonts Courier.java CourierBold.java CourierBoldOblique.java CourierOblique.java Helvetica.java HelveticaBold.java HelveticaBoldOblique.java HelveticaOblique.java Symbol.java TimesBold.java TimesBoldItalic.java TimesItalic.java TimesRoman.java ZapfDingbats.java

keiron      2002/06/05 07:52:28

  Modified:    src/org/apache/fop/apps CommandLineStarter.java Driver.java
                        StructureHandler.java
               src/org/apache/fop/fo FOText.java FObjMixed.java
               src/org/apache/fop/fo/flow Block.java Flow.java
               src/org/apache/fop/fo/pagination LayoutMasterSet.java
                        PageSequence.java
  Added:       src/org/apache/fop/mif MIFElement.java MIFFile.java
                        MIFHandler.java PGFElement.java RefElement.java
                        RulingElement.java
  Removed:     src/org/apache/fop/mif MIFDocument.java
               src/org/apache/fop/render/mif Font.java FontSetup.java
                        MIFRenderer.java
               src/org/apache/fop/render/mif/fonts Courier.java
                        CourierBold.java CourierBoldOblique.java
                        CourierOblique.java Helvetica.java
                        HelveticaBold.java HelveticaBoldOblique.java
                        HelveticaOblique.java Symbol.java TimesBold.java
                        TimesBoldItalic.java TimesItalic.java
                        TimesRoman.java ZapfDingbats.java
  Log:
  start to an improved mif handler
  cleaner structures and logic for handling the mif document and elements
  uses the structure handler concept to create the mif document
  
  Revision  Changes    Path
  1.16      +4 -2      xml-fop/src/org/apache/fop/apps/CommandLineStarter.java
  
  Index: CommandLineStarter.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/apps/CommandLineStarter.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- CommandLineStarter.java	26 Apr 2002 09:40:54 -0000	1.15
  +++ CommandLineStarter.java	5 Jun 2002 14:52:27 -0000	1.16
  @@ -1,5 +1,5 @@
   /*
  - * $Id: CommandLineStarter.java,v 1.15 2002/04/26 09:40:54 keiron Exp $
  + * $Id: CommandLineStarter.java,v 1.16 2002/06/05 14:52:27 keiron Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -66,8 +66,10 @@
               BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(
                                         commandLineOptions.getOutputFile()));
               driver.setOutputStream(bos);
  -            driver.getRenderer().setOptions(
  +            if(driver.getRenderer() != null) {
  +                driver.getRenderer().setOptions(
                 commandLineOptions.getRendererOptions());
  +            }
               driver.render(parser, inputHandler.getInputSource());
               bos.close();
               System.exit(0);
  
  
  
  1.49      +15 -5     xml-fop/src/org/apache/fop/apps/Driver.java
  
  Index: Driver.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/apps/Driver.java,v
  retrieving revision 1.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- Driver.java	27 May 2002 12:34:18 -0000	1.48
  +++ Driver.java	5 Jun 2002 14:52:27 -0000	1.49
  @@ -1,5 +1,5 @@
   /*
  - * $Id: Driver.java,v 1.48 2002/05/27 12:34:18 keiron Exp $
  + * $Id: Driver.java,v 1.49 2002/06/05 14:52:27 keiron Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -149,6 +149,11 @@
       private Renderer _renderer;
   
       /**
  +     * the structure handler
  +     */ 
  +    private StructureHandler structHandler;
  +
  +    /**
        * the source of the FO file
        */
       private InputSource _source;
  @@ -339,7 +344,7 @@
               setRenderer(new org.apache.fop.render.txt.TXTRenderer());
               break;
           case RENDER_MIF:
  -            setRenderer(new org.apache.fop.render.mif.MIFRenderer());
  +            //structHandler = new org.apache.fop.mif.MIFHandler(_stream);
               break;
           case RENDER_XML:
               setRenderer(new org.apache.fop.render.xml.XMLRenderer());
  @@ -453,11 +458,16 @@
        * events but isn't a SAX Parser itself.
        */
       public ContentHandler getContentHandler() {
  -        StructureHandler handler = new LayoutHandler(_stream, _renderer, true);
  -        handler.setLogger(getLogger());
  +        // TODO - do this stuff in a better way
  +        if(_renderer != null) {
  +            structHandler = new LayoutHandler(_stream, _renderer, true);
  +        } else {
  +            structHandler = new org.apache.fop.mif.MIFHandler(_stream);
  +        }
  +        structHandler.setLogger(getLogger());
           _treeBuilder.setLogger(getLogger());
           _treeBuilder.setUserAgent(getUserAgent());
  -        _treeBuilder.setStructHandler(handler);
  +        _treeBuilder.setStructHandler(structHandler);
   
           return _treeBuilder;
       }
  
  
  
  1.2       +32 -26    xml-fop/src/org/apache/fop/apps/StructureHandler.java
  
  Index: StructureHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/apps/StructureHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StructureHandler.java	27 May 2002 12:34:19 -0000	1.1
  +++ StructureHandler.java	5 Jun 2002 14:52:27 -0000	1.2
  @@ -1,5 +1,5 @@
   /*
  - * $Id: StructureHandler.java,v 1.1 2002/05/27 12:34:19 keiron Exp $
  + * $Id: StructureHandler.java,v 1.2 2002/06/05 14:52:27 keiron Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -11,7 +11,9 @@
   import java.util.HashSet;
   
   import org.apache.avalon.framework.logger.Logger;
  -import org.apache.fop.fo.pagination.PageSequence;
  +import org.apache.fop.fo.pagination.*;
  +import org.apache.fop.fo.flow.*;
  +import org.apache.fop.fo.*;
   import org.apache.fop.layout.FontInfo;
   
   import org.xml.sax.SAXException;
  @@ -52,7 +54,7 @@
   
       }
   
  -    public void startPageSequence() {
  +    public void startPageSequence(PageSequence pageSeq, LayoutMasterSet lms) {
   
       }
   
  @@ -60,83 +62,87 @@
   
       }
   
  -    public void setPageInfo() {
  +    public void startFlow(Flow fl) {
   
       }
   
  -    public void startBlock() {
  +    public void endFlow(Flow fl) {
   
       }
   
  -    public void endBlock() {
  +    public void startBlock(Block bl) {
  +
  +    }
  +
  +    public void endBlock(Block bl) {
   
       }
   
   
       // Tables
  -    public void startTable() {
  +    public void startTable(Table tbl) {
   
       }
   
  -    public void endTable() {
  +    public void endTable(Table tbl) {
   
       }
   
  -    public void startHeader() {
  +    public void startHeader(TableHeader th) {
   
       }
   
  -    public void endHeader() {
  +    public void endHeader(TableHeader th) {
   
       }
   
  -    public void startFooter() {
  +    public void startFooter(TableFooter tf) {
   
       }
   
  -    public void endFooter() {
  +    public void endFooter(TableFooter tf) {
   
       }
   
  -    public void startBody() {
  +    public void startBody(TableBody tb) {
   
       }
   
  -    public void endBody() {
  +    public void endBody(TableBody tb) {
   
       }
   
  -    public void startRow() {
  +    public void startRow(TableRow tr) {
   
       }
   
  -    public void endRow() {
  +    public void endRow(TableRow tr) {
   
       }
   
  -    public void startCell() {
  +    public void startCell(TableCell tc) {
   
       }
   
  -    public void endCell() {
  +    public void endCell(TableCell tc) {
   
       }
   
   
       // Lists
  -    public void startList() {
  +    public void startList(ListBlock lb) {
   
       }
   
  -    public void endList() {
  +    public void endList(ListBlock lb) {
   
       }
   
  -    public void startListItem() {
  +    public void startListItem(ListItem li) {
   
       }
   
  -    public void endListItem() {
  +    public void endListItem(ListItem li) {
   
       }
   
  @@ -185,7 +191,7 @@
       }
   
   
  -    public void image() {
  +    public void image(ExternalGraphic eg) {
   
       }
   
  @@ -193,7 +199,7 @@
   
       }
   
  -    public void foreignObject() {
  +    public void foreignObject(InstreamForeignObject ifo) {
   
       }
   
  @@ -201,12 +207,12 @@
   
       }
   
  -    public void leader() {
  +    public void leader(Leader l) {
   
       }
   
   
  -    public void characters() {
  +    public void characters(char data[], int start, int length) {
   
       }
   
  
  
  
  1.35      +7 -1      xml-fop/src/org/apache/fop/fo/FOText.java
  
  Index: FOText.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/FOText.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- FOText.java	10 May 2002 12:24:19 -0000	1.34
  +++ FOText.java	5 Jun 2002 14:52:27 -0000	1.35
  @@ -1,5 +1,5 @@
   /*
  - * $Id: FOText.java,v 1.34 2002/05/10 12:24:19 klease Exp $
  + * $Id: FOText.java,v 1.35 2002/06/05 14:52:27 keiron Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources."
  @@ -18,6 +18,7 @@
   import org.apache.fop.layoutmgr.LayoutManager;
   import org.apache.fop.layoutmgr.TextLayoutManager;
   import org.apache.fop.layoutmgr.TextBPLayoutManager;
  +import org.apache.fop.apps.StructureHandler;
   
   import java.util.NoSuchElementException;
   import java.util.List;
  @@ -46,6 +47,11 @@
           System.arraycopy(chars, s, ca, 0, e - s);
           this.length = e - s;
           textInfo = ti;
  +    }
  +
  +    public void setStructHandler(StructureHandler st) {
  +        super.setStructHandler(st);
  +        structHandler.characters(ca, start, length);
       }
   
       public boolean willCreateArea() {
  
  
  
  1.26      +2 -1      xml-fop/src/org/apache/fop/fo/FObjMixed.java
  
  Index: FObjMixed.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/FObjMixed.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- FObjMixed.java	27 May 2002 12:34:19 -0000	1.25
  +++ FObjMixed.java	5 Jun 2002 14:52:27 -0000	1.26
  @@ -1,5 +1,5 @@
   /*
  - * $Id: FObjMixed.java,v 1.25 2002/05/27 12:34:19 keiron Exp $
  + * $Id: FObjMixed.java,v 1.26 2002/06/05 14:52:27 keiron Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -59,6 +59,7 @@
   
           FOText ft = new FOText(data, start, length, textInfo);
           ft.setLogger(log);
  +        ft.setStructHandler(structHandler);
           addChild(ft);
       }
   
  
  
  
  1.56      +4 -1      xml-fop/src/org/apache/fop/fo/flow/Block.java
  
  Index: Block.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/flow/Block.java,v
  retrieving revision 1.55
  retrieving revision 1.56
  diff -u -r1.55 -r1.56
  --- Block.java	27 May 2002 12:34:19 -0000	1.55
  +++ Block.java	5 Jun 2002 14:52:27 -0000	1.56
  @@ -1,5 +1,5 @@
   /*
  - * $Id: Block.java,v 1.55 2002/05/27 12:34:19 keiron Exp $
  + * $Id: Block.java,v 1.56 2002/06/05 14:52:27 keiron Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -86,6 +86,8 @@
             this.properties.get("linefeed-treatment").getEnum();
   
           setupID();
  +
  +        structHandler.startBlock(this);
       }
   
       public Status layout(Area area) throws FOPException {
  @@ -404,6 +406,7 @@
   
       public void end() {
           handleWhiteSpace();
  +        structHandler.endBlock(this);
       }
   
       private void handleWhiteSpace() {
  
  
  
  1.33      +7 -1      xml-fop/src/org/apache/fop/fo/flow/Flow.java
  
  Index: Flow.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/flow/Flow.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- Flow.java	23 May 2002 06:27:13 -0000	1.32
  +++ Flow.java	5 Jun 2002 14:52:27 -0000	1.33
  @@ -1,5 +1,5 @@
   /*
  - * $Id: Flow.java,v 1.32 2002/05/23 06:27:13 keiron Exp $
  + * $Id: Flow.java,v 1.33 2002/06/05 14:52:27 keiron Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -83,6 +83,12 @@
           setFlowName(getProperty("flow-name").getString());
           // Now done in addChild of page-sequence
           //pageSequence.addFlow(this);
  +
  +        structHandler.startFlow(this);
  +    }
  +
  +    public void end() {
  +        structHandler.endFlow(this);
       }
   
       protected void setFlowName(String name) throws FOPException {
  
  
  
  1.15      +3 -3      xml-fop/src/org/apache/fop/fo/pagination/LayoutMasterSet.java
  
  Index: LayoutMasterSet.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/pagination/LayoutMasterSet.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- LayoutMasterSet.java	15 Nov 2001 12:40:31 -0000	1.14
  +++ LayoutMasterSet.java	5 Jun 2002 14:52:27 -0000	1.15
  @@ -1,5 +1,5 @@
   /*
  - * $Id: LayoutMasterSet.java,v 1.14 2001/11/15 12:40:31 keiron Exp $
  + * $Id: LayoutMasterSet.java,v 1.15 2002/06/05 14:52:27 keiron Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -74,7 +74,7 @@
        * This is used by the page sequence to get a page master for
        * creating pages.
        */
  -    protected SimplePageMaster getSimplePageMaster(String masterName) {
  +    public SimplePageMaster getSimplePageMaster(String masterName) {
           return (SimplePageMaster)this.simplePageMasters.get(masterName);
       }
   
  @@ -97,7 +97,7 @@
        * This is used by the page sequence to get a page master for 
        * creating pages.
        */
  -    protected PageSequenceMaster getPageSequenceMaster(String masterName) {
  +    public PageSequenceMaster getPageSequenceMaster(String masterName) {
           return (PageSequenceMaster)this.pageSequenceMasters.get(masterName);
       }
   
  
  
  
  1.50      +3 -1      xml-fop/src/org/apache/fop/fo/pagination/PageSequence.java
  
  Index: PageSequence.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/pagination/PageSequence.java,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- PageSequence.java	27 May 2002 12:34:19 -0000	1.49
  +++ PageSequence.java	5 Jun 2002 14:52:27 -0000	1.50
  @@ -1,5 +1,5 @@
   /*
  - * $Id: PageSequence.java,v 1.49 2002/05/27 12:34:19 keiron Exp $
  + * $Id: PageSequence.java,v 1.50 2002/06/05 14:52:27 keiron Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -194,6 +194,8 @@
           // this.properties.get("country");
           // this.properties.get("language");
           setupID();
  +
  +        structHandler.startPageSequence(this, layoutMasterSet);
       }
   
   
  
  
  
  1.1                  xml-fop/src/org/apache/fop/mif/MIFElement.java
  
  Index: MIFElement.java
  ===================================================================
  /*
   * $Id: MIFElement.java,v 1.1 2002/06/05 14:52:27 keiron Exp $
   * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
   * For details on use and redistribution please refer to the
   * LICENSE file included with these sources.
   */
  
  package org.apache.fop.mif;
  
  // Java
  import java.io.*;
  import java.util.*;
  
  /**
   * The is the basis for MIF document elements.
   * This enables the creation of the element and to write it
   * to an output stream including sub-elements or a single value.
   */
  public class MIFElement {
      protected String name;
      protected String valueStr;
      protected ArrayList valueElements = null;
  
      protected boolean started = false;
      protected boolean finish = false;
      protected boolean finished = false;
  
      /**
       */
      public MIFElement(String n) {
          name = n;
      }
  
      public void setValue(String str) {
          valueStr = str;
      }
  
      public void addElement(MIFElement el) {
          if(valueElements == null) {
              valueElements = new ArrayList();
          }
          valueElements.add(el);
      }
  
      /**
       * Output this element to an output stream.
       * This will output only so far as the fisrt unfinished child element.
       * This method can be called again to continue from the previous point.
       * An element that contains child elements will only be finished when
       * the finish method is called.
       */
      public boolean output(OutputStream os, int indent) throws IOException {
          if(finished) return true;
          String indentStr = "";
          for(int c = 0; c < indent; c++) indentStr += " ";
          if(!started) {
              os.write((indentStr + "<" + name).getBytes());
              if(valueElements != null)
                  os.write(("\n").getBytes());
              started = true;
          }
          if(valueElements != null) {
              boolean done = true;
              for(Iterator iter = valueElements.iterator(); iter.hasNext(); ) {
                  MIFElement el = (MIFElement)iter.next();
                  boolean d = el.output(os, indent + 1);
                  if(d) {
                      iter.remove();
                  } else {
                      done = false;
                      break;
                  }
              }
              if(!finish || !done) {
                  return false;
              }
              os.write((indentStr + "> # end of " + name + "\n").getBytes());
          } else {
              os.write((" " + valueStr + ">\n").getBytes());
          }
          finished = true;
          return true;
      }
  
      public void finish(boolean deep) {
          finish = true;
          if(deep && valueElements != null) {
              for(Iterator iter = valueElements.iterator(); iter.hasNext(); ) {
                  MIFElement el = (MIFElement)iter.next();
                  el.finish(deep);
              }
          }
      }
  }
  
  
  
  
  1.1                  xml-fop/src/org/apache/fop/mif/MIFFile.java
  
  Index: MIFFile.java
  ===================================================================
  /*
   * $Id: MIFFile.java,v 1.1 2002/06/05 14:52:27 keiron Exp $
   * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
   * For details on use and redistribution please refer to the
   * LICENSE file included with these sources.
   */
  
  package org.apache.fop.mif;
  
  // Java
  import java.io.*;
  import java.util.*;
  
  /**
   * The MIF File.
   * This organises the MIF File and the corresponding elements.
   * The catalog elements are used to setup the resources that
   * are referenced.
   */
  public class MIFFile extends MIFElement {
  
      protected MIFElement colorCatalog = null;
      protected PGFElement pgfCatalog = null;
      protected MIFElement fontCatalog = null;
      protected RulingElement rulingCatalog = null;
      protected MIFElement tblCatalog = null;
      protected MIFElement views = null;
      protected MIFElement variableFormats = null;
      protected MIFElement xRefFormats = null;
      protected MIFElement document = null;
      protected MIFElement bookComponent = null;
      protected MIFElement initialAutoNums = null;
      protected MIFElement aFrames = null;
      protected MIFElement tbls = null;
      protected ArrayList pages = new ArrayList();
      protected ArrayList textFlows = null;
  
  
      /**
       */
      public MIFFile() {
          super("");
          valueElements = new ArrayList();
          setup();
      }
  
      /**
       * Do some setup.
       * Currently adds some dummy values to the resources.
       */
      protected void setup() {
          MIFElement unit = new MIFElement("Units");
          unit.setValue("Ucm");
          addElement(unit);
  
          colorCatalog = new MIFElement("ColorCatalog");
          MIFElement color = new MIFElement("Color");
          MIFElement prop = new MIFElement("ColorTag");
          prop.setValue("`Black'");
          color.addElement(prop);
          prop = new MIFElement("ColorCyan");
          prop.setValue("0.000000");
          color.addElement(prop);
  
          prop = new MIFElement("ColorMagenta");
          prop.setValue("0.000000");
          color.addElement(prop);
          prop = new MIFElement("ColorYellow");
          prop.setValue("0.000000");
          color.addElement(prop);
          prop = new MIFElement("ColorBlack");
          prop.setValue("100.000000");
          color.addElement(prop);
          prop = new MIFElement("ColorAttribute");
          prop.setValue("ColorIsBlack");
          color.addElement(prop);
          prop = new MIFElement("ColorAttribute");
          prop.setValue("ColorIsReserved");
          color.addElement(prop);
          color.finish(true);
  
          colorCatalog.addElement(color);
          addElement(colorCatalog);
  
          pgfCatalog = new PGFElement();
          pgfCatalog.lookupElement(null);
          addElement(pgfCatalog);
  
          rulingCatalog = new RulingElement();
          rulingCatalog.lookupElement(null);
          addElement(rulingCatalog);
  
      }
  
      public void output(OutputStream os) throws IOException {
          if(finished) return;
  
          if(!started) {
              os.write(("<MIFFile  5.00> # Generated by FOP\n"/* + getVersion()*/).getBytes());
              started = true;
          }
          boolean done = true;
  
          for(Iterator iter = valueElements.iterator(); iter.hasNext(); ) {
              MIFElement el = (MIFElement)iter.next();
              boolean d = el.output(os, 0);
              if(d) {
                  iter.remove();
              } else {
                  done = false;
                  break;
              }
          }
          if(done && finish) {
              os.write(("# end of MIFFile").getBytes());
          }
      }
  
      public void addPage(MIFElement p) {
          pages.add(p);
          addElement(p);
      }
  }
  
  
  
  
  1.1                  xml-fop/src/org/apache/fop/mif/MIFHandler.java
  
  Index: MIFHandler.java
  ===================================================================
  /*
   * $Id: MIFHandler.java,v 1.1 2002/06/05 14:52:27 keiron Exp $
   * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
   * For details on use and redistribution please refer to the
   * LICENSE file included with these sources.
   */
  
  package org.apache.fop.mif;
  
  import org.apache.fop.apps.StructureHandler;
  import org.apache.fop.layout.FontInfo;
  import org.apache.fop.fo.pagination.*;
  import org.apache.fop.fo.flow.*;
  import org.apache.fop.fo.*;
  import org.apache.fop.apps.FOPException;
  
  // Java
  import java.io.*;
  import java.util.*;
  
  import org.xml.sax.SAXException;
  
  // do we really want every method throwing a SAXException
  
  /**
   * The MIF Handler.
   * This generates MIF output using the structure events from
   * the FO Tree sent to this structure handler.
   * This builds an MIF file and writes it to the output.
   */
  public class MIFHandler extends StructureHandler {
      protected MIFFile mifFile;
      protected OutputStream outStream;
      private FontInfo fontInfo = new FontInfo();
  
      // current state elements
      MIFElement textFlow;
      MIFElement para;
  
      /**
       */
      public MIFHandler(OutputStream os) {
          outStream = os;
          // use pdf fonts for now, this is only for resolving names
          org.apache.fop.render.pdf.FontSetup.setup(fontInfo);
      }
  
      public FontInfo getFontInfo() {
          return fontInfo;
      }
  
      public void startDocument() throws SAXException {
          mifFile = new MIFFile();
          try {
              mifFile.output(outStream);
          } catch(IOException ioe) {
              throw new SAXException(ioe);
          }
      }
  
      public void endDocument() throws SAXException {
          // finish all open elements
          mifFile.finish(true);
          try {
              mifFile.output(outStream);
              outStream.flush();
          } catch(IOException ioe) {
              throw new SAXException(ioe);
          }
      }
  
      /**
       * Start the page sequence.
       * This creates the pages in the MIF document that will be used
       * by the following flows and static areas.
       */
      public void startPageSequence(PageSequence pageSeq, LayoutMasterSet lms) {
          // get the layout master set
          // setup the pages for this sequence
          String name = pageSeq.getProperty("master-reference").getString();
          SimplePageMaster spm = lms.getSimplePageMaster(name);
          if(spm == null) {
              PageSequenceMaster psm = lms.getPageSequenceMaster(name);
          } else {
              // create simple master with regions
              MIFElement prop = new MIFElement("PageType");
              prop.setValue("BodyPage");
  
             MIFElement page = new MIFElement("Page");
             page.addElement(prop);
  
             prop = new MIFElement("PageBackground");
             prop.setValue("'Default'");
             page.addElement(prop);
  
             // build regions
             MIFElement textRect = new MIFElement("TextRect");
             prop = new MIFElement("ID");
             prop.setValue("1");
             textRect.addElement(prop);
             prop = new MIFElement("ShapeRect");
             prop.setValue("0.0 841.889 453.543 0.0");
             textRect.addElement(prop);
             page.addElement(textRect);
  
             textRect = new MIFElement("TextRect");
             prop = new MIFElement("ID");
             prop.setValue("2");
             textRect.addElement(prop);
             prop = new MIFElement("ShapeRect");
             prop.setValue("0.0 841.889 453.543 187.65");
             textRect.addElement(prop);
             page.addElement(textRect);
  
  
  
             mifFile.addPage(page);
          }
      }
  
      public void endPageSequence(PageSequence pageSeq) throws FOPException {
          
      }
  
      public void startFlow(Flow fl) {
          // start text flow in body region
          textFlow = new MIFElement("TextFlow");
      }
  
      public void endFlow(Flow fl) {
          textFlow.finish(true);
          mifFile.addElement(textFlow);
          textFlow = null;
      }
  
      public void startBlock(Block bl) {
          para = new MIFElement("Para");
          // get font
          textFlow.addElement(para);
      }
  
      public void endBlock(Block bl) {
          para.finish(true);
          para = null;
      }
  
      public void characters(char data[], int start, int length) {
          if(para != null) {
              String str = new String(data, start, length);
              str = str.trim();
              // break into nice length chunks
              if(str.length() == 0) {
                  return;
              }
  
              MIFElement line = new MIFElement("ParaLine");
              MIFElement prop = new MIFElement("TextRectID");
              prop.setValue("2");
              line.addElement(prop);
              prop = new MIFElement("String");
              prop.setValue("\"" + str + "\"");
              line.addElement(prop);
  
              para.addElement(line);
          }
      }
  
  }
  
  
  
  
  1.1                  xml-fop/src/org/apache/fop/mif/PGFElement.java
  
  Index: PGFElement.java
  ===================================================================
  /*
   * $Id: PGFElement.java,v 1.1 2002/06/05 14:52:27 keiron Exp $
   * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
   * For details on use and redistribution please refer to the
   * LICENSE file included with these sources.
   */
  
  package org.apache.fop.mif;
  
  // Java
  import java.io.*;
  import java.util.*;
  
  /**
   * Font Catalog element.
   * This is the reference lookup element for fonts in
   * the MIF document.
   */
  public class PGFElement extends RefElement {
  
      /**
       */
      public PGFElement() {
          super("PgfCatalog");
      }
  
      public MIFElement lookupElement(Object key) {
          if(key == null) {
              MIFElement pgf = new MIFElement("Pgf");
              MIFElement prop = new MIFElement("PgfTag");
              prop.setValue("`Body'");
              pgf.addElement(prop);
              addElement(pgf);
              pgf.finish(true);
              return pgf;
          }
          return null;
      }
  }
  
  
  
  
  1.1                  xml-fop/src/org/apache/fop/mif/RefElement.java
  
  Index: RefElement.java
  ===================================================================
  /*
   * $Id: RefElement.java,v 1.1 2002/06/05 14:52:27 keiron Exp $
   * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
   * For details on use and redistribution please refer to the
   * LICENSE file included with these sources.
   */
  
  package org.apache.fop.mif;
  
  // Java
  import java.io.*;
  import java.util.*;
  
  /**
   * Reference MIF Element.
   * This element is a lookup reference set that contains
   * a list of resources used in the MIF Document.
   * When a lookup is performed it will either create a new
   * element or return an existing element that is valid.
   * THe key depends on the type of reference, it should be able
   * to uniquely identify the element.
   */
  public class RefElement extends MIFElement {
  
      /**
       */
      public RefElement(String n) {
          super(n);
      }
  
      public MIFElement lookupElement(Object key) {
          return null;
      }
  }
  
  
  
  
  1.1                  xml-fop/src/org/apache/fop/mif/RulingElement.java
  
  Index: RulingElement.java
  ===================================================================
  /*
   * $Id: RulingElement.java,v 1.1 2002/06/05 14:52:27 keiron Exp $
   * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
   * For details on use and redistribution please refer to the
   * LICENSE file included with these sources.
   */
  
  package org.apache.fop.mif;
  
  // Java
  import java.io.*;
  import java.util.*;
  
  /**
   *
   */
  public class RulingElement extends RefElement {
  
      /**
       */
      public RulingElement() {
          super("RulingCatalog");
      }
  
      public MIFElement lookupElement(Object key) {
          if(key == null) {
              MIFElement rul = new MIFElement("Ruling");
              MIFElement prop = new MIFElement("RulingTag");
              prop.setValue("`Default'");
              rul.addElement(prop);
              prop = new MIFElement("RulingPenWidth");
              prop.setValue("1");
              rul.addElement(prop);
              prop = new MIFElement("RulingPen");
              prop.setValue("0");
              rul.addElement(prop);
              prop = new MIFElement("RulingLines");
              prop.setValue("1");
              rul.addElement(prop);
  
              addElement(rul);
              rul.finish(true);
              return rul;
          }
          return null;
      }
  }
  
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org