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 2001/07/04 14:41:11 UTC

cvs commit: xml-fop/src/org/apache/fop/viewer Command.java

keiron      01/07/04 05:41:11

  Modified:    src/org/apache/fop/apps AWTStarter.java FOInputHandler.java
                        Fop.java InputHandler.java Options.java
                        PrintStarter.java Starter.java
                        TraxInputHandler.java XSLTInputHandler.java
               src/org/apache/fop/datatypes ColorSpace.java Keep.java
                        LengthBase.java LengthPair.java LengthRange.java
                        Space.java
               src/org/apache/fop/fo/pagination Region.java
               src/org/apache/fop/image FopImageException.java
               src/org/apache/fop/mif MIFDocument.java
               src/org/apache/fop/pdf PDFFilterException.java
               src/org/apache/fop/render/mif Font.java FontSetup.java
                        MIFRenderer.java
               src/org/apache/fop/render/pcl PCLRenderer.java
                        PCLStream.java
               src/org/apache/fop/viewer Command.java
  Log:
  fixed line endings
  some cleanup also
  no code changes
  
  Revision  Changes    Path
  1.4       +171 -174  xml-fop/src/org/apache/fop/apps/AWTStarter.java
  
  Index: AWTStarter.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/apps/AWTStarter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AWTStarter.java	2001/04/12 00:12:42	1.3
  +++ AWTStarter.java	2001/07/04 12:40:40	1.4
  @@ -1,174 +1,171 @@
  -/* 
  - * 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.apps;
  -/*
  -  originally contributed by
  -  Juergen Verwohlt: Juergen.Verwohlt@jCatalog.com,
  -  Rainer Steinkuhle: Rainer.Steinkuhle@jCatalog.com,
  -  Stanislav Gorkhover: Stanislav.Gorkhover@jCatalog.com
  -
  - */
  -import org.apache.fop.messaging.MessageHandler;
  -import org.apache.fop.viewer.*;
  -import org.apache.fop.render.awt.*;
  -
  -
  -import javax.swing.UIManager;
  -import java.awt.*;
  -
  -// SAX
  -import org.xml.sax.XMLReader;
  -import org.xml.sax.InputSource;
  -import org.xml.sax.SAXException;
  -import org.xml.sax.SAXParseException;
  -
  -
  -
  -// Java
  -import java.io.FileReader;
  -import java.io.File;
  -import java.io.FileWriter;
  -import java.io.PrintWriter;
  -import java.io.IOException;
  -import java.io.FileNotFoundException;
  -import java.io.FileInputStream;
  -import java.io.InputStream;
  -import java.net.URL;
  -import java.util.*;
  -
  -
  -
  -/**
  - * initialize AWT previewer
  - */
  -
  -public class AWTStarter extends CommandLineStarter {
  -
  -    PreviewDialog frame;
  -    AWTRenderer renderer;
  -    public static String TRANSLATION_PATH = "/org/apache/fop/viewer/resources/";
  -
  -    private Translator resource;
  -
  -    public AWTStarter (CommandLineOptions commandLineOptions) 
  -	throws FOPException
  -    {
  -        super(commandLineOptions);
  -        init();
  -    }
  -
  -    private void init () {
  -        try {
  -            UIManager.setLookAndFeel(
  -              new javax.swing.plaf.metal.MetalLookAndFeel());
  -        } catch (Exception e) {
  -            e.printStackTrace();
  -        }
  -
  -        String language = commandLineOptions.getLanguage();
  -
  -        if (language == null)
  -            language = System.getProperty("user.language");
  -
  -        resource = getResourceBundle(TRANSLATION_PATH + "resources." +
  -                                     language);
  -
  -        UserMessage.setTranslator(
  -          getResourceBundle(TRANSLATION_PATH + "messages." +
  -                            language));
  -
  -        resource.setMissingEmphasized(false);
  -        renderer = new AWTRenderer(resource);
  -        frame = createPreviewDialog(renderer, resource);
  -        renderer.setProgressListener(frame);
  -        renderer.setComponent(frame);
  -        MessageHandler.setOutputMethod(MessageHandler.EVENT);
  -        MessageHandler.addListener(frame);
  -    }
  -
  -
  -    public void run () 
  -	throws FOPException
  -    {
  -	Driver driver = new Driver();
  -        if (errorDump) {
  -            driver.setErrorDump(true);
  -        }
  -
  -        //init parser
  -        frame.progress(resource.getString("Init parser") + " ...");
  -        XMLReader parser = inputHandler.getParser();
  -
  -        if (parser == null) {
  -	    throw new FOPException("Unable to create SAX parser");
  -        }
  -
  -        setParserFeatures(parser);
  -
  -        try {
  -            driver.setRenderer(renderer);
  -
  -            // build FO tree: time
  -            frame.progress(resource.getString("Build FO tree") + " ...");
  -            driver.buildFOTree(parser, inputHandler.getInputSource());
  -
  -            // layout FO tree: time
  -            frame.progress(resource.getString("Layout FO tree") + " ...");
  -            driver.format();
  -
  -            // render: time
  -            frame.progress(resource.getString("Render") + " ...");
  -            driver.render();
  -
  -            frame.progress(resource.getString("Show"));
  -            frame.showPage();
  -
  -        } catch (Exception e) {
  -	    if (e instanceof FOPException) {
  -		throw (FOPException)e;
  -	    }
  -	    throw new FOPException(e);
  -        }
  -
  -    }
  -
  -    protected PreviewDialog createPreviewDialog(AWTRenderer renderer,
  -            Translator res) {
  -        PreviewDialog frame = new PreviewDialog(renderer, res);
  -        frame.validate();
  -
  -        // center window
  -        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
  -        Dimension frameSize = frame.getSize();
  -        if (frameSize.height > screenSize.height)
  -            frameSize.height = screenSize.height;
  -        if (frameSize.width > screenSize.width)
  -            frameSize.width = screenSize.width;
  -        frame.setLocation((screenSize.width - frameSize.width) / 2,
  -                          (screenSize.height - frameSize.height) / 2);
  -        frame.setVisible(true);
  -        return frame;
  -    }
  -
  -
  -
  -    private SecureResourceBundle getResourceBundle(String path) {
  -        InputStream in = null;
  -
  -        try {
  -            URL url = getClass().getResource(path);
  -            in = url.openStream();
  -        } catch (Exception ex) {
  -            MessageHandler.logln("Can't find URL to: <" + path + "> " +
  -                                 ex.getMessage());
  -        }
  -        return new SecureResourceBundle(in);
  -    }
  -}
  -
  -
  -
  +/* $Id: AWTStarter.java,v 1.4 2001/07/04 12:40:40 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.apps;
  +/*
  +  originally contributed by
  +  Juergen Verwohlt: Juergen.Verwohlt@jCatalog.com,
  +  Rainer Steinkuhle: Rainer.Steinkuhle@jCatalog.com,
  +  Stanislav Gorkhover: Stanislav.Gorkhover@jCatalog.com
  +
  + */
  +import org.apache.fop.messaging.MessageHandler;
  +import org.apache.fop.viewer.*;
  +import org.apache.fop.render.awt.*;
  +
  +
  +import javax.swing.UIManager;
  +import java.awt.*;
  +
  +// SAX
  +import org.xml.sax.XMLReader;
  +import org.xml.sax.InputSource;
  +import org.xml.sax.SAXException;
  +import org.xml.sax.SAXParseException;
  +
  +
  +
  +// Java
  +import java.io.FileReader;
  +import java.io.File;
  +import java.io.FileWriter;
  +import java.io.PrintWriter;
  +import java.io.IOException;
  +import java.io.FileNotFoundException;
  +import java.io.FileInputStream;
  +import java.io.InputStream;
  +import java.net.URL;
  +import java.util.*;
  +
  +
  +
  +/**
  + * initialize AWT previewer
  + */
  +
  +public class AWTStarter extends CommandLineStarter {
  +
  +    PreviewDialog frame;
  +    AWTRenderer renderer;
  +    public static String TRANSLATION_PATH = "/org/apache/fop/viewer/resources/";
  +
  +    private Translator resource;
  +
  +    public AWTStarter (CommandLineOptions commandLineOptions)
  +    throws FOPException {
  +        super(commandLineOptions);
  +        init();
  +    }
  +
  +    private void init () {
  +        try {
  +            UIManager.setLookAndFeel(
  +              new javax.swing.plaf.metal.MetalLookAndFeel());
  +        } catch (Exception e) {
  +            e.printStackTrace();
  +        }
  +
  +        String language = commandLineOptions.getLanguage();
  +
  +        if (language == null)
  +            language = System.getProperty("user.language");
  +
  +        resource = getResourceBundle(TRANSLATION_PATH + "resources." +
  +                                     language);
  +
  +        UserMessage.setTranslator(
  +          getResourceBundle(TRANSLATION_PATH + "messages." +
  +                            language));
  +
  +        resource.setMissingEmphasized(false);
  +        renderer = new AWTRenderer(resource);
  +        frame = createPreviewDialog(renderer, resource);
  +        renderer.setProgressListener(frame);
  +        renderer.setComponent(frame);
  +        MessageHandler.setOutputMethod(MessageHandler.EVENT);
  +        MessageHandler.addListener(frame);
  +    }
  +
  +
  +    public void run () throws FOPException {
  +        Driver driver = new Driver();
  +        if (errorDump) {
  +            driver.setErrorDump(true);
  +        }
  +
  +        //init parser
  +        frame.progress(resource.getString("Init parser") + " ...");
  +        XMLReader parser = inputHandler.getParser();
  +
  +        if (parser == null) {
  +            throw new FOPException("Unable to create SAX parser");
  +        }
  +
  +        setParserFeatures(parser);
  +
  +        try {
  +            driver.setRenderer(renderer);
  +
  +            // build FO tree: time
  +            frame.progress(resource.getString("Build FO tree") + " ...");
  +            driver.buildFOTree(parser, inputHandler.getInputSource());
  +
  +            // layout FO tree: time
  +            frame.progress(resource.getString("Layout FO tree") + " ...");
  +            driver.format();
  +
  +            // render: time
  +            frame.progress(resource.getString("Render") + " ...");
  +            driver.render();
  +
  +            frame.progress(resource.getString("Show"));
  +            frame.showPage();
  +
  +        } catch (Exception e) {
  +            if (e instanceof FOPException) {
  +                throw (FOPException) e;
  +            }
  +            throw new FOPException(e);
  +        }
  +
  +    }
  +
  +    protected PreviewDialog createPreviewDialog(AWTRenderer renderer,
  +            Translator res) {
  +        PreviewDialog frame = new PreviewDialog(renderer, res);
  +        frame.validate();
  +
  +        // center window
  +        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
  +        Dimension frameSize = frame.getSize();
  +        if (frameSize.height > screenSize.height)
  +            frameSize.height = screenSize.height;
  +        if (frameSize.width > screenSize.width)
  +            frameSize.width = screenSize.width;
  +        frame.setLocation((screenSize.width - frameSize.width) / 2,
  +                          (screenSize.height - frameSize.height) / 2);
  +        frame.setVisible(true);
  +        return frame;
  +    }
  +
  +
  +
  +    private SecureResourceBundle getResourceBundle(String path) {
  +        InputStream in = null;
  +
  +        try {
  +            URL url = getClass().getResource(path);
  +            in = url.openStream();
  +        } catch (Exception ex) {
  +            MessageHandler.logln("Can't find URL to: <" + path + "> " +
  +                                 ex.getMessage());
  +        }
  +        return new SecureResourceBundle(in);
  +    }
  +}
  +
  +
  +
  
  
  
  1.3       +37 -41    xml-fop/src/org/apache/fop/apps/FOInputHandler.java
  
  Index: FOInputHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/apps/FOInputHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FOInputHandler.java	2001/04/12 00:12:42	1.2
  +++ FOInputHandler.java	2001/07/04 12:40:41	1.3
  @@ -1,41 +1,37 @@
  -/* 
  - * 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.apps;
  -
  -// Imported SAX classes
  -import org.xml.sax.InputSource;
  -import org.xml.sax.XMLReader;
  -
  -//fop
  -import org.apache.fop.messaging.MessageHandler;
  -
  -//java
  -import java.io.File;
  -
  -/**
  - * Manages input if it is an xsl:fo file
  - */
  -
  -public class FOInputHandler extends InputHandler {
  -
  -	File fofile;
  -    public FOInputHandler (File fofile) {
  -		this.fofile = fofile;
  -    }
  -
  -    public InputSource getInputSource () {
  -        return super.fileInputSource(fofile);
  -    }
  -
  -    public XMLReader getParser() 
  -	throws FOPException
  -    {
  -        return super.createParser();
  -    }
  -}
  -
  +/* $Id: FOInputHandler.java,v 1.3 2001/07/04 12:40:41 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.apps;
  +
  +// Imported SAX classes
  +import org.xml.sax.InputSource;
  +import org.xml.sax.XMLReader;
  +
  +//fop
  +import org.apache.fop.messaging.MessageHandler;
  +
  +//java
  +import java.io.File;
  +
  +/**
  + * Manages input if it is an xsl:fo file
  + */
  +public class FOInputHandler extends InputHandler {
  +
  +    File fofile;
  +    public FOInputHandler (File fofile) {
  +        this.fofile = fofile;
  +    }
  +
  +    public InputSource getInputSource () {
  +        return super.fileInputSource(fofile);
  +    }
  +
  +    public XMLReader getParser() throws FOPException {
  +        return super.createParser();
  +    }
  +}
  +
  
  
  
  1.5       +34 -36    xml-fop/src/org/apache/fop/apps/Fop.java
  
  Index: Fop.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/apps/Fop.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Fop.java	2001/04/12 00:12:43	1.4
  +++ Fop.java	2001/07/04 12:40:42	1.5
  @@ -1,36 +1,34 @@
  -/* 
  - * 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.apps;
  -
  -import org.apache.fop.messaging.MessageHandler;
  -
  -public class Fop {
  -    public static void main (String [] args) {
  -	CommandLineOptions options = null;
  -	
  -	try {
  -	    options = new CommandLineOptions (args);
  -	    Starter starter = options.getStarter();
  -	    starter.run();
  -	}
  -	catch (FOPException e) {
  -	    MessageHandler.errorln("ERROR: "+e.getMessage());
  -	    if (options != null && options.isDebugMode().booleanValue()) {
  -		e.printStackTrace();
  -	    }
  -	}
  -	catch (java.io.FileNotFoundException e) {
  -	    MessageHandler.errorln("ERROR: "+e.getMessage());
  -	    if (options != null && options.isDebugMode().booleanValue()) {
  -		e.printStackTrace();
  -	    }
  -	}
  -    }
  -    
  -}
  -
  +/* $Id: Fop.java,v 1.5 2001/07/04 12:40:42 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.apps;
  +
  +import org.apache.fop.messaging.MessageHandler;
  +
  +public class Fop {
  +    public static void main (String [] args) {
  +        CommandLineOptions options = null;
  +
  +        try {
  +            options = new CommandLineOptions (args);
  +            Starter starter = options.getStarter();
  +            starter.run();
  +        } catch (FOPException e) {
  +            MessageHandler.errorln("ERROR: "+e.getMessage());
  +            if (options != null && options.isDebugMode().booleanValue()) {
  +                e.printStackTrace();
  +            }
  +        }
  +        catch (java.io.FileNotFoundException e) {
  +            MessageHandler.errorln("ERROR: "+e.getMessage());
  +            if (options != null && options.isDebugMode().booleanValue()) {
  +                e.printStackTrace();
  +            }
  +        }
  +    }
  +
  +}
  +
  
  
  
  1.3       +82 -84    xml-fop/src/org/apache/fop/apps/InputHandler.java
  
  Index: InputHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/apps/InputHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- InputHandler.java	2001/04/12 00:12:43	1.2
  +++ InputHandler.java	2001/07/04 12:40:42	1.3
  @@ -1,84 +1,82 @@
  -/* 
  - * 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.apps;
  -
  -// SAX
  -import org.xml.sax.InputSource;
  -import org.xml.sax.XMLReader;
  -
  -// Java
  -import java.net.URL;
  -import java.io.File;
  -
  -// FOP
  -import org.apache.fop.messaging.MessageHandler;
  -import org.apache.fop.configuration.Configuration;
  -
  -
  -abstract public class InputHandler {
  -
  -
  -    abstract public InputSource getInputSource();
  -    abstract public XMLReader getParser() throws FOPException;
  -
  -
  -    /**
  -       * create an InputSource from a File
  -       *
  -       * @param file the File
  -       * @return the InputSource created
  -       */
  -    static public InputSource fileInputSource(File file) {
  -        /* this code adapted from James Clark's in XT */
  -        String path = file.getAbsolutePath();
  -        String fSep = System.getProperty("file.separator");
  -        if (fSep != null && fSep.length() == 1)
  -            path = path.replace(fSep.charAt(0), '/');
  -        if (path.length() > 0 && path.charAt(0) != '/')
  -            path = '/' + path;
  -        try {
  -            return new InputSource(new URL("file", null, path).toString());
  -        } catch (java.net.MalformedURLException e) {
  -            throw new Error("unexpected MalformedURLException");
  -        }
  -    }
  -
  -    /**
  -        * creates a SAX parser, using the value of org.xml.sax.parser
  -        * defaulting to org.apache.xerces.parsers.SAXParser
  -        *
  -        * @return the created SAX parser
  -        */
  -    protected static XMLReader createParser() 
  -	throws FOPException
  -    {
  -        String parserClassName = System.getProperty("org.xml.sax.parser");
  -        if (parserClassName == null) {
  -            parserClassName = "org.apache.xerces.parsers.SAXParser";
  -        }
  -        MessageHandler.logln("using SAX parser " + parserClassName);
  -
  -        try {
  -            return (XMLReader) Class.forName(
  -                     parserClassName).newInstance();
  -        } catch (ClassNotFoundException e) {
  -	    throw new FOPException(e);
  -        }
  -        catch (InstantiationException e) {
  -	    throw new FOPException("Could not instantiate " +
  -                                   parserClassName,e);
  -        }
  -        catch (IllegalAccessException e) {
  -	    throw new FOPException("Could not access " + parserClassName,e);
  -        }
  -        catch (ClassCastException e) {
  -	    throw new FOPException(parserClassName + " is not a SAX driver",e);
  -        }
  -    }
  -}
  -
  +/* $Id: InputHandler.java,v 1.3 2001/07/04 12:40:42 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.apps;
  +
  +// SAX
  +import org.xml.sax.InputSource;
  +import org.xml.sax.XMLReader;
  +
  +// Java
  +import java.net.URL;
  +import java.io.File;
  +
  +// FOP
  +import org.apache.fop.messaging.MessageHandler;
  +import org.apache.fop.configuration.Configuration;
  +
  +
  +abstract public class InputHandler {
  +
  +
  +    abstract public InputSource getInputSource();
  +    abstract public XMLReader getParser() throws FOPException;
  +
  +
  +    /**
  +     * create an InputSource from a File
  +     *
  +     * @param file the File
  +     * @return the InputSource created
  +     */
  +    static public InputSource fileInputSource(File file) {
  +        /* this code adapted from James Clark's in XT */
  +        String path = file.getAbsolutePath();
  +        String fSep = System.getProperty("file.separator");
  +        if (fSep != null && fSep.length() == 1)
  +            path = path.replace(fSep.charAt(0), '/');
  +        if (path.length() > 0 && path.charAt(0) != '/')
  +            path = '/' + path;
  +        try {
  +            return new InputSource(new URL("file", null, path).toString());
  +        } catch (java.net.MalformedURLException e) {
  +            throw new Error("unexpected MalformedURLException");
  +        }
  +    }
  +
  +    /**
  +     * creates a SAX parser, using the value of org.xml.sax.parser
  +     * defaulting to org.apache.xerces.parsers.SAXParser
  +     *
  +     * @return the created SAX parser
  +     */
  +    protected static XMLReader createParser() throws FOPException {
  +        String parserClassName = System.getProperty("org.xml.sax.parser");
  +        if (parserClassName == null) {
  +            parserClassName = "org.apache.xerces.parsers.SAXParser";
  +        }
  +        MessageHandler.logln("using SAX parser " + parserClassName);
  +
  +        try {
  +            return (XMLReader) Class.forName(
  +                     parserClassName).newInstance();
  +        } catch (ClassNotFoundException e) {
  +            throw new FOPException(e);
  +        }
  +        catch (InstantiationException e) {
  +            throw new FOPException("Could not instantiate " +
  +                                   parserClassName, e);
  +        }
  +        catch (IllegalAccessException e) {
  +            throw new FOPException("Could not access " +
  +                                   parserClassName, e);
  +        }
  +        catch (ClassCastException e) {
  +            throw new FOPException(parserClassName + " is not a SAX driver",e);
  +        }
  +    }
  +}
  +
  
  
  
  1.6       +0 -1      xml-fop/src/org/apache/fop/apps/Options.java
  
  Index: Options.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/apps/Options.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Options.java	2001/06/21 18:05:07	1.5
  +++ Options.java	2001/07/04 12:40:42	1.6
  @@ -23,7 +23,6 @@
    *  Options handles loading of configuration files and 
    *  additional setting of commandline options
    */
  -
   public class Options {
   	boolean errorDump = false;
   	
  
  
  
  1.4       +191 -195  xml-fop/src/org/apache/fop/apps/PrintStarter.java
  
  Index: PrintStarter.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/apps/PrintStarter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PrintStarter.java	2001/04/12 00:12:43	1.3
  +++ PrintStarter.java	2001/07/04 12:40:43	1.4
  @@ -1,195 +1,191 @@
  -/* 
  - * 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.apps;
  -
  -/*
  -  originally contributed by
  -  Stanislav Gorkhover: stanislav.gorkhover@jcatalog.com
  -  jCatalog Software AG
  - */
  -
  -
  -import org.xml.sax.XMLReader;
  -import org.xml.sax.InputSource;
  -import org.xml.sax.SAXException;
  -import org.xml.sax.SAXParseException;
  -
  -import java.awt.Graphics;
  -import java.awt.print.*;
  -import java.io.OutputStream;
  -import java.io.IOException;
  -import java.util.Vector;
  -
  -import org.apache.fop.render.awt.AWTRenderer;
  -import org.apache.fop.layout.AreaTree;
  -import org.apache.fop.layout.Page;
  -import org.apache.fop.messaging.MessageHandler;
  -
  -
  -/**
  - * This class prints a xsl-fo dokument without interaction.
  - * At the moment java has not the possibility to configure the printer and it's
  - * options without interaction (30.03.2000).
  - * This class allows to print a set of pages (from-to), even/odd pages and many copies.
  - * - Print from page xxx: property name - start, value int
  - * - Print to page xxx: property name - end, value int
  - * - Print even/odd pages: property name - even, value boolean
  - * - Print xxx copies: property name - copies, value int
  - *
  - */
  -public class PrintStarter extends CommandLineStarter {
  -
  -    public PrintStarter (CommandLineOptions options) 
  -	throws FOPException
  -    {
  -        super(options);
  -    }
  -
  -    public void run () 
  -	throws FOPException
  -    {
  -        Driver driver = new Driver();
  -        if (errorDump) {
  -            driver.setErrorDump(true);
  -        }
  -
  -        String version = Version.getVersion();
  -        MessageHandler.errorln(version);
  -
  -        XMLReader parser = inputHandler.getParser();
  -        
  -        setParserFeatures(parser);
  -
  -        PrintRenderer renderer = new PrintRenderer();
  -
  -        try {
  -            driver.setRenderer(renderer);
  -            driver.buildFOTree(parser, inputHandler.getInputSource());
  -            driver.format();
  -            driver.render();
  -        } catch (Exception e) {
  -	    if (e instanceof FOPException) {
  -		throw (FOPException)e;
  -	    }
  -	    throw new FOPException(e);
  -	}
  -
  -        int copies = PrintRenderer.getIntProperty("copies", 1);
  -        renderer.setCopies(copies);
  -
  -        PrinterJob pj = PrinterJob.getPrinterJob();
  -        pj.setPageable(renderer);
  -
  -        pj.setCopies(copies);
  -        try {
  -            pj.print();
  -        } catch (PrinterException pe) {
  -            pe.printStackTrace();
  -        }
  -    }
  -
  -
  -    static class PrintRenderer extends AWTRenderer {
  -
  -        static int EVEN_AND_ALL = 0;
  -        static int EVEN = 1;
  -        static int ODD = 2;
  -
  -        int startNumber;
  -        int endNumber;
  -        int mode = EVEN_AND_ALL;
  -        int copies = 1;
  -
  -        PrintRenderer() {
  -            super(null);
  -
  -            startNumber = getIntProperty("start", 1) - 1;
  -            endNumber = getIntProperty("end", -1);
  -
  -            mode = EVEN_AND_ALL;
  -            String str = System.getProperty("even");
  -            if (str != null) {
  -                try {
  -                    mode = Boolean.valueOf(str).booleanValue() ? EVEN : ODD;
  -                } catch (Exception e) {
  -                }
  -            }
  -
  -        }
  -
  -
  -        static int getIntProperty(String name, int def) {
  -            String propValue = System.getProperty(name);
  -            if (propValue != null) {
  -                try {
  -                    return Integer.parseInt(propValue);
  -                } catch (Exception e) {
  -                    return def;
  -                }
  -            } else {
  -                return def;
  -            }
  -        }
  -
  -        public void render(AreaTree areaTree,
  -                           OutputStream stream) throws IOException {
  -            tree = areaTree;
  -            if (endNumber == -1) {
  -                endNumber = tree.getPages().size();
  -            }
  -
  -            Vector numbers = getInvalidPageNumbers();
  -            for (int i = numbers.size() - 1; i > -1; i--)
  -                tree.getPages().removeElementAt(
  -                  Integer.parseInt((String) numbers.elementAt(i)));
  -
  -        }
  -
  -        public void renderPage(Page page) {
  -            pageWidth = (int)((float) page.getWidth() / 1000f);
  -            pageHeight = (int)((float) page.getHeight() / 1000f);
  -            super.renderPage(page);
  -        }
  -
  -
  -        private Vector getInvalidPageNumbers() {
  -
  -            Vector vec = new Vector();
  -            int max = tree.getPages().size();
  -            boolean isValid;
  -            for (int i = 0; i < max; i++) {
  -                isValid = true;
  -                if (i < startNumber || i > endNumber) {
  -                    isValid = false;
  -                } else if (mode != EVEN_AND_ALL) {
  -                    if (mode == EVEN && ((i + 1) % 2 != 0))
  -                        isValid = false;
  -                    else if (mode == ODD && ((i + 1) % 2 != 1))
  -                        isValid = false;
  -                }
  -
  -                if (!isValid)
  -                    vec.add(i + "");
  -            }
  -
  -            return vec;
  -        }
  -
  -        void setCopies(int val) {
  -            copies = val;
  -            Vector copie = tree.getPages();
  -            for (int i = 1; i < copies; i++) {
  -                tree.getPages().addAll(copie);
  -            }
  -
  -        }
  -
  -    } // class PrintRenderer
  -} // class PrintCommandLine
  -
  -
  +/* $Id: PrintStarter.java,v 1.4 2001/07/04 12:40:43 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.apps;
  +
  +/*
  +  originally contributed by
  +  Stanislav Gorkhover: stanislav.gorkhover@jcatalog.com
  +  jCatalog Software AG
  + */
  +
  +
  +import org.xml.sax.XMLReader;
  +import org.xml.sax.InputSource;
  +import org.xml.sax.SAXException;
  +import org.xml.sax.SAXParseException;
  +
  +import java.awt.Graphics;
  +import java.awt.print.*;
  +import java.io.OutputStream;
  +import java.io.IOException;
  +import java.util.Vector;
  +
  +import org.apache.fop.render.awt.AWTRenderer;
  +import org.apache.fop.layout.AreaTree;
  +import org.apache.fop.layout.Page;
  +import org.apache.fop.messaging.MessageHandler;
  +
  +
  +/**
  + * This class prints a xsl-fo dokument without interaction.
  + * At the moment java has not the possibility to configure the printer and it's
  + * options without interaction (30.03.2000).
  + * This class allows to print a set of pages (from-to), even/odd pages and many copies.
  + * - Print from page xxx: property name - start, value int
  + * - Print to page xxx: property name - end, value int
  + * - Print even/odd pages: property name - even, value boolean
  + * - Print xxx copies: property name - copies, value int
  + *
  + */
  +public class PrintStarter extends CommandLineStarter {
  +
  +    public PrintStarter (CommandLineOptions options) throws FOPException {
  +        super(options);
  +    }
  +
  +    public void run () throws FOPException {
  +        Driver driver = new Driver();
  +        if (errorDump) {
  +            driver.setErrorDump(true);
  +        }
  +
  +        String version = Version.getVersion();
  +        MessageHandler.errorln(version);
  +
  +        XMLReader parser = inputHandler.getParser();
  +
  +        setParserFeatures(parser);
  +
  +        PrintRenderer renderer = new PrintRenderer();
  +
  +        try {
  +            driver.setRenderer(renderer);
  +            driver.buildFOTree(parser, inputHandler.getInputSource());
  +            driver.format();
  +            driver.render();
  +        } catch (Exception e) {
  +            if (e instanceof FOPException) {
  +                throw (FOPException) e;
  +            }
  +            throw new FOPException(e);
  +        }
  +
  +        int copies = PrintRenderer.getIntProperty("copies", 1);
  +        renderer.setCopies(copies);
  +
  +        PrinterJob pj = PrinterJob.getPrinterJob();
  +        pj.setPageable(renderer);
  +
  +        pj.setCopies(copies);
  +        try {
  +            pj.print();
  +        } catch (PrinterException pe) {
  +            pe.printStackTrace();
  +        }
  +    }
  +
  +
  +    static class PrintRenderer extends AWTRenderer {
  +
  +        static int EVEN_AND_ALL = 0;
  +        static int EVEN = 1;
  +        static int ODD = 2;
  +
  +        int startNumber;
  +        int endNumber;
  +        int mode = EVEN_AND_ALL;
  +        int copies = 1;
  +
  +        PrintRenderer() {
  +            super(null);
  +
  +            startNumber = getIntProperty("start", 1) - 1;
  +            endNumber = getIntProperty("end", -1);
  +
  +            mode = EVEN_AND_ALL;
  +            String str = System.getProperty("even");
  +            if (str != null) {
  +                try {
  +                    mode = Boolean.valueOf(str).booleanValue() ? EVEN : ODD;
  +                } catch (Exception e) {
  +                }
  +            }
  +
  +        }
  +
  +
  +        static int getIntProperty(String name, int def) {
  +            String propValue = System.getProperty(name);
  +            if (propValue != null) {
  +                try {
  +                    return Integer.parseInt(propValue);
  +                } catch (Exception e) {
  +                    return def;
  +                }
  +            } else {
  +                return def;
  +            }
  +        }
  +
  +        public void render(AreaTree areaTree,
  +                           OutputStream stream) throws IOException {
  +            tree = areaTree;
  +            if (endNumber == -1) {
  +                endNumber = tree.getPages().size();
  +            }
  +
  +            Vector numbers = getInvalidPageNumbers();
  +            for (int i = numbers.size() - 1; i > -1; i--)
  +                tree.getPages().removeElementAt(
  +                  Integer.parseInt((String) numbers.elementAt(i)));
  +
  +        }
  +
  +        public void renderPage(Page page) {
  +            pageWidth = (int)((float) page.getWidth() / 1000f);
  +            pageHeight = (int)((float) page.getHeight() / 1000f);
  +            super.renderPage(page);
  +        }
  +
  +
  +        private Vector getInvalidPageNumbers() {
  +
  +            Vector vec = new Vector();
  +            int max = tree.getPages().size();
  +            boolean isValid;
  +            for (int i = 0; i < max; i++) {
  +                isValid = true;
  +                if (i < startNumber || i > endNumber) {
  +                    isValid = false;
  +                } else if (mode != EVEN_AND_ALL) {
  +                    if (mode == EVEN && ((i + 1) % 2 != 0))
  +                        isValid = false;
  +                    else if (mode == ODD && ((i + 1) % 2 != 1))
  +                        isValid = false;
  +                }
  +
  +                if (!isValid)
  +                    vec.add(i + "");
  +            }
  +
  +            return vec;
  +        }
  +
  +        void setCopies(int val) {
  +            copies = val;
  +            Vector copie = tree.getPages();
  +            for (int i = 1; i < copies; i++) {
  +                tree.getPages().addAll(copie);
  +            }
  +
  +        }
  +
  +    } // class PrintRenderer
  +} // class PrintCommandLine
  +
  +
  +
  
  
  
  1.3       +51 -57    xml-fop/src/org/apache/fop/apps/Starter.java
  
  Index: Starter.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/apps/Starter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Starter.java	2001/04/12 00:12:44	1.2
  +++ Starter.java	2001/07/04 12:40:43	1.3
  @@ -1,57 +1,51 @@
  -/* 
  - * 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.apps;
  -
  -// SAX
  -import org.xml.sax.XMLReader;
  -import org.xml.sax.SAXException;
  -
  -// Java
  -import java.io.*;
  -import java.net.URL;
  -
  -// FOP
  -import org.apache.fop.messaging.MessageHandler;
  -
  -
  -/**
  - * 
  - * abstract super class 
  - * Creates a SAX Parser (defaulting to Xerces).
  - *
  - */
  -public abstract class Starter {
  -
  -    Options options;
  -    InputHandler inputHandler;
  -	
  -    public Starter() 
  -	throws FOPException
  -    {
  -	options = new Options ();		
  -    }
  -    
  -    public void setInputHandler(InputHandler inputHandler) {
  -	this.inputHandler = inputHandler;
  -    }
  -    
  -    abstract public void run()
  -	throws FOPException;
  -    
  -    // setting the parser features	
  -    public void setParserFeatures (XMLReader parser) 
  -	throws FOPException
  -    {
  -        try {
  -            parser.setFeature("http://xml.org/sax/features/namespace-prefixes",true);
  -        } catch (SAXException e) {
  -	    throw new FOPException("Error in setting up parser feature namespace-prefixes\n" +
  -				   "You need a parser which supports SAX version 2",e);
  -        }
  -    }
  -}
  +/* $Id: Starter.java,v 1.3 2001/07/04 12:40:43 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.apps;
  +
  +// SAX
  +import org.xml.sax.XMLReader;
  +import org.xml.sax.SAXException;
  +
  +// Java
  +import java.io.*;
  +import java.net.URL;
  +
  +// FOP
  +import org.apache.fop.messaging.MessageHandler;
  +
  +/**
  + * abstract super class
  + * Creates a SAX Parser (defaulting to Xerces).
  + *
  + */
  +public abstract class Starter {
  +
  +    Options options;
  +    InputHandler inputHandler;
  +
  +    public Starter() throws FOPException {
  +        options = new Options ();
  +    }
  +
  +    public void setInputHandler(InputHandler inputHandler) {
  +        this.inputHandler = inputHandler;
  +    }
  +
  +    abstract public void run() throws FOPException;
  +
  +            // setting the parser features
  +    public void setParserFeatures (XMLReader parser) throws FOPException {
  +        try {
  +            parser.setFeature("http://xml.org/sax/features/namespace-prefixes",
  +                              true);
  +        } catch (SAXException e) {
  +            throw new FOPException(
  +              "Error in setting up parser feature namespace-prefixes\n" +
  +              "You need a parser which supports SAX version 2",e);
  +        }
  +    }
  +}
  
  
  
  1.3       +111 -114  xml-fop/src/org/apache/fop/apps/TraxInputHandler.java
  
  Index: TraxInputHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/apps/TraxInputHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TraxInputHandler.java	2001/04/12 00:12:44	1.2
  +++ TraxInputHandler.java	2001/07/04 12:40:44	1.3
  @@ -1,114 +1,111 @@
  -/* 
  - * 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.apps;
  -
  -
  -// Imported TraX classes
  -import javax.xml.transform.TransformerFactory;
  -import javax.xml.transform.stream.StreamSource;
  -import javax.xml.transform.sax.SAXResult;
  -import javax.xml.transform.sax.SAXSource;
  -import javax.xml.transform.sax.SAXTransformerFactory;
  -
  -
  -// Imported SAX classes
  -import org.xml.sax.InputSource;
  -import org.xml.sax.SAXException;
  -import org.xml.sax.XMLReader;
  -import org.xml.sax.XMLFilter;
  -
  -
  -
  -// Imported java.io classes
  -import java.io.InputStream;
  -import java.io.IOException;
  -import java.io.File;
  -
  -// FOP
  -import org.apache.fop.messaging.MessageHandler;
  -
  -/**
  - * XSLTInputHandler basically takes an xmlfile and transforms it with an xsltfile
  - * and the resulting xsl:fo document is input for Fop.
  - */
  -
  -public class TraxInputHandler extends InputHandler {
  -
  -	File xmlfile, xsltfile;
  -
  -    public TraxInputHandler (File xmlfile, File xsltfile ) {
  -        this.xmlfile = xmlfile;
  -		this.xsltfile = xsltfile;
  -    }
  -
  -    /**
  -      *  overwrites the method of the super class to return the xmlfile
  -      */
  -    public InputSource getInputSource () {
  -        return fileInputSource(xmlfile);
  -    }
  -
  -    /**
  -      *  overwrites this method of the super class and returns an XMLFilter instead of a
  -      *  simple XMLReader which allows chaining of transformations
  -      *
  -      */
  -    public XMLReader getParser() throws FOPException {
  -        return this.getXMLFilter(xmlfile,xsltfile);
  -    }
  -
  -    /**
  -      * Creates from the transformer an instance of an XMLFilter which
  -      * then can be used in a chain with the XMLReader passed to Driver. This way
  -      * during the conversion of the xml file + xslt stylesheet the resulting
  -      * data is fed into Fop. This should help to avoid memory problems
  -      * @param xmlfile The xmlfile containing the text data
  -      * @param xsltfile An xslt stylesheet
  -      * @return XMLFilter an XMLFilter which can be chained together with other XMLReaders or XMLFilters
  -      */
  -    public static XMLFilter getXMLFilter (File xmlfile, File xsltfile) 
  -	throws FOPException
  -    {
  -        try {
  -            // Instantiate  a TransformerFactory.
  -            TransformerFactory tFactory = TransformerFactory.newInstance();
  -            // Determine whether the TransformerFactory supports The use uf SAXSource
  -            // and SAXResult
  -            if (tFactory.getFeature(SAXSource.FEATURE) &&
  -                    tFactory.getFeature(SAXResult.FEATURE)) {
  -                // Cast the TransformerFactory to SAXTransformerFactory.
  -                SAXTransformerFactory saxTFactory =
  -                  ((SAXTransformerFactory) tFactory);
  -                // Create an XMLFilter for each stylesheet.
  -                XMLFilter xmlfilter = saxTFactory.newXMLFilter(
  -                                        new StreamSource(xsltfile));
  -
  -                // Create an XMLReader.
  -                XMLReader parser = createParser();
  -                if (parser == null) {
  -                    throw new FOPException("Unable to create SAX parser");
  -                }
  -
  -                // xmlFilter1 uses the XMLReader as its reader.
  -                xmlfilter.setParent(parser);
  -                return xmlfilter;
  -            } else {
  -                throw new FOPException(
  -                  "Your parser doesn't support the features SAXSource and SAXResult." +
  -                  "\nMake sure you are using a xsl parser which supports TrAX");
  -            }
  -        }
  -        catch (Exception ex) {
  -	    if (ex instanceof FOPException) {
  -		throw (FOPException)ex;
  -	    }
  -	    throw new FOPException(ex);
  -	}
  -    }
  -}
  -
  +/* $Id: TraxInputHandler.java,v 1.3 2001/07/04 12:40:44 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.apps;
  +
  +
  +// Imported TraX classes
  +import javax.xml.transform.TransformerFactory;
  +import javax.xml.transform.stream.StreamSource;
  +import javax.xml.transform.sax.SAXResult;
  +import javax.xml.transform.sax.SAXSource;
  +import javax.xml.transform.sax.SAXTransformerFactory;
  +
  +
  +// Imported SAX classes
  +import org.xml.sax.InputSource;
  +import org.xml.sax.SAXException;
  +import org.xml.sax.XMLReader;
  +import org.xml.sax.XMLFilter;
  +
  +
  +
  +// Imported java.io classes
  +import java.io.InputStream;
  +import java.io.IOException;
  +import java.io.File;
  +
  +// FOP
  +import org.apache.fop.messaging.MessageHandler;
  +
  +/**
  + * XSLTInputHandler basically takes an xmlfile and transforms it with an xsltfile
  + * and the resulting xsl:fo document is input for Fop.
  + */
  +public class TraxInputHandler extends InputHandler {
  +
  +    File xmlfile, xsltfile;
  +
  +    public TraxInputHandler (File xmlfile, File xsltfile) {
  +        this.xmlfile = xmlfile;
  +        this.xsltfile = xsltfile;
  +    }
  +
  +    /**
  +     *  overwrites the method of the super class to return the xmlfile
  +     */
  +    public InputSource getInputSource () {
  +        return fileInputSource(xmlfile);
  +    }
  +
  +    /**
  +     *  overwrites this method of the super class and returns an XMLFilter instead of a
  +     *  simple XMLReader which allows chaining of transformations
  +     *
  +     */
  +    public XMLReader getParser() throws FOPException {
  +        return this.getXMLFilter(xmlfile, xsltfile);
  +    }
  +
  +    /**
  +     * Creates from the transformer an instance of an XMLFilter which
  +     * then can be used in a chain with the XMLReader passed to Driver. This way
  +     * during the conversion of the xml file + xslt stylesheet the resulting
  +     * data is fed into Fop. This should help to avoid memory problems
  +     * @param xmlfile The xmlfile containing the text data
  +     * @param xsltfile An xslt stylesheet
  +     * @return XMLFilter an XMLFilter which can be chained together with other XMLReaders or XMLFilters
  +     */
  +    public static XMLFilter getXMLFilter (File xmlfile,
  +                                          File xsltfile) throws FOPException {
  +        try {
  +            // Instantiate  a TransformerFactory.
  +            TransformerFactory tFactory = TransformerFactory.newInstance();
  +            // Determine whether the TransformerFactory supports The use uf SAXSource
  +            // and SAXResult
  +            if (tFactory.getFeature(SAXSource.FEATURE) &&
  +                    tFactory.getFeature(SAXResult.FEATURE)) {
  +                // Cast the TransformerFactory to SAXTransformerFactory.
  +                SAXTransformerFactory saxTFactory =
  +                  ((SAXTransformerFactory) tFactory);
  +                // Create an XMLFilter for each stylesheet.
  +                XMLFilter xmlfilter = saxTFactory.newXMLFilter(
  +                                        new StreamSource(xsltfile));
  +
  +                // Create an XMLReader.
  +                XMLReader parser = createParser();
  +                if (parser == null) {
  +                    throw new FOPException("Unable to create SAX parser");
  +                }
  +
  +                // xmlFilter1 uses the XMLReader as its reader.
  +                xmlfilter.setParent(parser);
  +                return xmlfilter;
  +            } else {
  +                throw new FOPException(
  +                  "Your parser doesn't support the features SAXSource and SAXResult." +
  +                  "\nMake sure you are using a xsl parser which supports TrAX");
  +            }
  +        }
  +        catch (Exception ex) {
  +            if (ex instanceof FOPException) {
  +                throw (FOPException) ex;
  +            }
  +            throw new FOPException(ex);
  +        }
  +    }
  +}
  +
  
  
  
  1.5       +121 -129  xml-fop/src/org/apache/fop/apps/XSLTInputHandler.java
  
  Index: XSLTInputHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/apps/XSLTInputHandler.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XSLTInputHandler.java	2001/04/12 00:12:44	1.4
  +++ XSLTInputHandler.java	2001/07/04 12:40:45	1.5
  @@ -1,129 +1,121 @@
  -/* 
  - * 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.apps;
  -
  -import java.lang.reflect.*;
  -
  -
  -// Imported SAX classes
  -import org.xml.sax.InputSource;
  -import org.xml.sax.SAXException;
  -import org.xml.sax.XMLReader;
  -
  -// Imported java.io classes
  -import java.io.*;
  -
  -// FOP
  -import org.apache.fop.messaging.MessageHandler;
  -import org.apache.fop.tools.xslt.XSLTransform;
  -
  -/**
  - * XSLTInputHandler basically takes an xmlfile and transforms it with an xsltfile
  - * and the resulting xsl:fo document is input for Fop.
  - */
  -
  -public class XSLTInputHandler extends InputHandler {
  -
  -    File xmlfile, xsltfile;
  -    boolean useOldTransform = false;
  -    
  -    public XSLTInputHandler (File xmlfile, File xsltfile ) {
  -        this.xmlfile = xmlfile;
  -	this.xsltfile = xsltfile;
  -    }
  -
  -    /**
  -      *  overwrites the method of the super class to return the xmlfile
  -      */
  -    public InputSource getInputSource () {
  -	if (useOldTransform) {
  -	    try {
  -		java.io.Writer writer;
  -		java.io.Reader reader;
  -		File tmpFile = null;
  -	 
  -		// create a Writer
  -		// the following is an ugly hack to allow processing of larger files
  -		// if xml file size is larger than 500 kb write the fo:file to disk
  -		if ((xmlfile.length()) > 500000) {
  -		    tmpFile = new File(xmlfile.getName()+".fo.tmp");
  -		    writer = new FileWriter(tmpFile);
  -		} else {
  -		    writer = new StringWriter();
  -		}
  -
  -		XSLTransform.transform(xmlfile.getCanonicalPath(), xsltfile.getCanonicalPath(), writer);
  -
  -		writer.flush();
  -		writer.close();
  -
  -		if (tmpFile != null) {
  -		    reader = new FileReader(tmpFile);
  -		} else {
  -		    // create a input source containing the xsl:fo file which can be fed to Fop		    
  -		    reader = new StringReader(writer.toString());
  -		}
  -		return new InputSource(reader);
  -	    }
  -	    catch (Exception ex) {
  -		ex.printStackTrace();
  -		return null;
  -	    }
  -	}
  -	else {
  -	    return fileInputSource(xmlfile);
  -	}
  -	
  -    }
  -
  -    /**
  -      * This looks to see if the Trax api is supported and uses that to 
  -      * get an XMLFilter. Otherwise, it falls back to using DOM documents 
  -      *
  -      */
  -    public XMLReader getParser() 
  -	throws FOPException
  -    {
  -	XMLReader result = null;
  -	try {
  -	    // try trax first
  -	    Class transformer = Class.forName("javax.xml.transform.Transformer");
  -	    transformer = Class.forName("org.apache.fop.apps.TraxInputHandler");
  -	    Class[] argTypes = 	{ File.class, File.class };
  -	    Method getFilterMethod = transformer.getMethod("getXMLFilter",argTypes);
  -	    File[] args = {xmlfile, xsltfile};
  -	    Object obj = getFilterMethod.invoke(null,args);
  -	    if (obj instanceof XMLReader) {
  -		result = (XMLReader)obj;
  -	    }
  -	}
  -	catch (ClassNotFoundException ex){
  -	    throw new FOPException(ex);
  -	}
  -	catch (InvocationTargetException ex) {
  -	    throw new FOPException(ex);
  -	}
  -	catch (IllegalAccessException ex) {
  -	    throw new FOPException(ex);
  -	}
  -	catch (NoSuchMethodException ex) {
  -	    throw new FOPException(ex);
  -	}
  -	// otherwise, use DOM documents via our XSLTransform tool class old style
  -	if (result == null) {
  -	    useOldTransform = true;
  -	    result = createParser();
  -	}
  -	return result;
  -	        
  -    }
  -
  - 
  -    
  -}
  -
  +/* $Id: XSLTInputHandler.java,v 1.5 2001/07/04 12:40:45 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.apps;
  +
  +import java.lang.reflect.*;
  +
  +
  +// Imported SAX classes
  +import org.xml.sax.InputSource;
  +import org.xml.sax.SAXException;
  +import org.xml.sax.XMLReader;
  +
  +// Imported java.io classes
  +import java.io.*;
  +
  +// FOP
  +import org.apache.fop.messaging.MessageHandler;
  +import org.apache.fop.tools.xslt.XSLTransform;
  +
  +/**
  + * XSLTInputHandler basically takes an xmlfile and transforms it with an xsltfile
  + * and the resulting xsl:fo document is input for Fop.
  + */
  +public class XSLTInputHandler extends InputHandler {
  +
  +    File xmlfile, xsltfile;
  +    boolean useOldTransform = false;
  +
  +    public XSLTInputHandler (File xmlfile, File xsltfile) {
  +        this.xmlfile = xmlfile;
  +        this.xsltfile = xsltfile;
  +    }
  +
  +    /**
  +     *  overwrites the method of the super class to return the xmlfile
  +     */
  +    public InputSource getInputSource () {
  +        if (useOldTransform) {
  +            try {
  +                java.io.Writer writer;
  +                java.io.Reader reader;
  +                File tmpFile = null;
  +
  +                // create a Writer
  +                // the following is an ugly hack to allow processing of larger files
  +                // if xml file size is larger than 500 kb write the fo:file to disk
  +                if ((xmlfile.length()) > 500000) {
  +                    tmpFile = new File(xmlfile.getName() + ".fo.tmp");
  +                    writer = new FileWriter(tmpFile);
  +                } else {
  +                    writer = new StringWriter();
  +                }
  +
  +                XSLTransform.transform(xmlfile.getCanonicalPath(),
  +                                       xsltfile.getCanonicalPath(), writer);
  +
  +                writer.flush();
  +                writer.close();
  +
  +                if (tmpFile != null) {
  +                    reader = new FileReader(tmpFile);
  +                } else {
  +                    // create a input source containing the xsl:fo file which can be fed to Fop
  +                    reader = new StringReader(writer.toString());
  +                }
  +                return new InputSource(reader);
  +            } catch (Exception ex) {
  +                ex.printStackTrace();
  +                return null;
  +            }
  +        } else {
  +            return fileInputSource(xmlfile);
  +        }
  +
  +    }
  +
  +    /**
  +     * This looks to see if the Trax api is supported and uses that to
  +     * get an XMLFilter. Otherwise, it falls back to using DOM documents
  +     *
  +     */
  +    public XMLReader getParser() throws FOPException {
  +        XMLReader result = null;
  +        try {
  +            // try trax first
  +            Class transformer = Class.forName("javax.xml.transform.Transformer");
  +            transformer = Class.forName("org.apache.fop.apps.TraxInputHandler");
  +            Class[] argTypes = { File.class, File.class };
  +            Method getFilterMethod =
  +              transformer.getMethod("getXMLFilter",argTypes);
  +            File[] args = {xmlfile, xsltfile};
  +            Object obj = getFilterMethod.invoke(null, args);
  +            if (obj instanceof XMLReader) {
  +                result = (XMLReader) obj;
  +            }
  +        } catch (ClassNotFoundException ex) {
  +            throw new FOPException(ex);
  +        }
  +        catch (InvocationTargetException ex) {
  +            throw new FOPException(ex);
  +        }
  +        catch (IllegalAccessException ex) {
  +            throw new FOPException(ex);
  +        }
  +        catch (NoSuchMethodException ex) {
  +            throw new FOPException(ex);
  +        }
  +        // otherwise, use DOM documents via our XSLTransform tool class old style
  +        if (result == null) {
  +            useOldTransform = true;
  +            result = createParser();
  +        }
  +        return result;
  +
  +    }
  +}
  +
  
  
  
  1.2       +50 -106   xml-fop/src/org/apache/fop/datatypes/ColorSpace.java
  
  Index: ColorSpace.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/datatypes/ColorSpace.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ColorSpace.java	2000/04/27 19:33:50	1.1
  +++ ColorSpace.java	2001/07/04 12:40:49	1.2
  @@ -1,106 +1,50 @@
  -/*-- $Id: ColorSpace.java,v 1.1 2000/04/27 19:33:50 gears Exp $ -- 
  -
  - ============================================================================
  -				   The Apache Software License, Version 1.1
  - ============================================================================
  - 
  -	Copyright (C) 1999 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
  -	apache@apache.org.
  - 
  - 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
  - APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  - INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  - DING, BUT NOT LIMITED TO, PROCUREMENT	OF SUBSTITUTE GOODS OR SERVICES; LOSS
  - OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)	HOWEVER CAUSED AND ON
  - ANY  THEORY OF LIABILITY,	WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  - (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 <jt...@jtauber.com>. For more  information on the Apache 
  - Software Foundation, please see <http://www.apache.org/>.
  - 
  - */
  -
  -package org.apache.fop.datatypes;
  -
  -public class ColorSpace {
  -	//Ok... so I had some grand purpose for this, but I can't recall.
  -	//I'm just writing it 
  -
  -	public static int DEVICE_UNKNOWN = -1;
  -	public static int DEVICE_GRAY = 1;
  -	//what's the *official* spelling?
  -	//public static int DEVICE_GREY = 1;
  -	public static int DEVICE_RGB = 2;
  -	public static int DEVICE_CMYK = 3;
  -	
  -	//Are there any others?
  -	
  -	protected int currentColorSpace = -1;
  -
  -	public ColorSpace (int theColorSpace)
  -	{
  -		this.currentColorSpace = theColorSpace;
  -	
  -	}
  -	public int getColorSpace()
  -	{
  -		return (this.currentColorSpace);
  -	}
  -	public void setColorSpace(int theColorSpace)
  -	{
  -		this.currentColorSpace = theColorSpace;
  -	}
  -	
  -	public String getColorSpacePDFString()
  -	{//this is for PDF Output. Does anyone else need a string representation?
  -		
  -		
  -		//shouldn't this be a select-case? I can never remember
  -	//the syntax for that.
  -		if(this.currentColorSpace == this.DEVICE_RGB)
  -		{
  -			return("DeviceRGB");
  -		}
  -		else if(this.currentColorSpace == this.DEVICE_CMYK)
  -		{
  -			return("DeviceCMYK");
  -		}
  -		else if(this.currentColorSpace== this.DEVICE_GRAY)
  -		{
  -			return("DeviceGray");
  -		}
  -		else
  -		{//unknown... Error. Tell them it's RGB and hope they don't notice.
  -			return("DeviceRGB");
  -		}
  -	}
  -} 
  \ No newline at end of file
  +/* $Id: ColorSpace.java,v 1.2 2001/07/04 12:40:49 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.datatypes;
  +
  +public class ColorSpace {
  +    //Ok... so I had some grand purpose for this, but I can't recall.
  +    //I'm just writing it
  +
  +    public static int DEVICE_UNKNOWN = -1;
  +    public static int DEVICE_GRAY = 1;
  +    //what's the *official* spelling?
  +    //public static int DEVICE_GREY = 1;
  +    public static int DEVICE_RGB = 2;
  +    public static int DEVICE_CMYK = 3;
  +
  +    //Are there any others?
  +
  +    protected int currentColorSpace = -1;
  +
  +    public ColorSpace (int theColorSpace) {
  +        this.currentColorSpace = theColorSpace;
  +
  +    }
  +    public int getColorSpace() {
  +        return (this.currentColorSpace);
  +    }
  +    public void setColorSpace(int theColorSpace) {
  +        this.currentColorSpace = theColorSpace;
  +    }
  +
  +    public String getColorSpacePDFString() {//this is for PDF Output. Does anyone else need a string representation?
  +
  +
  +        //shouldn't this be a select-case? I can never remember
  +        //the syntax for that.
  +        if (this.currentColorSpace == this.DEVICE_RGB) {
  +            return("DeviceRGB");
  +        } else if (this.currentColorSpace == this.DEVICE_CMYK) {
  +            return("DeviceCMYK");
  +        } else if (this.currentColorSpace == this.DEVICE_GRAY) {
  +            return("DeviceGray");
  +        } else {//unknown... Error. Tell them it's RGB and hope they don't notice.
  +            return("DeviceRGB");
  +        }
  +    }
  +}
  
  
  
  1.2       +74 -116   xml-fop/src/org/apache/fop/datatypes/Keep.java
  
  Index: Keep.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/datatypes/Keep.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Keep.java	2001/01/02 21:32:18	1.1
  +++ Keep.java	2001/07/04 12:40:50	1.2
  @@ -1,116 +1,74 @@
  -/*-- $Id: Keep.java,v 1.1 2001/01/02 21:32:18 klease Exp $ -- 
  -
  - ============================================================================
  -                   The Apache Software License, Version 1.1
  - ============================================================================
  - 
  -    Copyright (C) 1999 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
  -    apache@apache.org.
  - 
  - 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
  - APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  - INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  - DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  - OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  - ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  - (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 <jt...@jtauber.com>. For more  information on the Apache 
  - Software Foundation, please see <http://www.apache.org/>.
  - 
  - */
  -package org.apache.fop.datatypes;
  -
  -import org.apache.fop.fo.Property;
  -
  -/**
  - * XSL FO Keep Property datatype (keep-together, etc)
  - */
  -public class Keep implements CompoundDatatype {
  -    private Property withinLine;
  -    private Property withinColumn;
  -    private Property withinPage;
  -
  -  public Keep () {
  -  }
  -
  -  // From CompoundDatatype
  -    public void setComponent(String sCmpnName, Property cmpnValue,
  -			     boolean bIsDefault) {
  -      if (sCmpnName.equals("within-line"))
  -	setWithinLine(cmpnValue, bIsDefault);
  -      else if (sCmpnName.equals("within-column"))
  -	setWithinColumn(cmpnValue, bIsDefault);
  -      else if (sCmpnName.equals("within-page"))
  -	setWithinPage(cmpnValue, bIsDefault);
  -    }
  -
  -  // From CompoundDatatype
  -  public Property getComponent(String sCmpnName) {
  -      if (sCmpnName.equals("within-line"))
  -	return getWithinLine();
  -      else if (sCmpnName.equals("within-column"))
  -	return getWithinColumn();
  -      else if (sCmpnName.equals("within-page"))
  -	return getWithinPage();
  -      else return null;
  -    }
  -
  -    public void setWithinLine(Property withinLine, boolean bIsDefault) {
  -	this.withinLine = withinLine;
  -    }
  -
  -    protected void setWithinColumn(Property withinColumn, boolean bIsDefault) {
  -	this.withinColumn = withinColumn;
  -    }
  -
  -    public void setWithinPage(Property withinPage, boolean bIsDefault) {
  -	this.withinPage = withinPage;
  -    }
  -
  -    public Property getWithinLine() {
  -      return this.withinLine;
  -    }
  -
  -    public Property getWithinColumn() {
  -      return this.withinColumn;
  -    }
  -
  -    public Property getWithinPage() {
  -      return this.withinPage;
  -    }
  -
  -    /** What to do here?? There isn't really a meaningful single value. */
  -    public String toString() {
  -      return "Keep";
  -    }
  -}
  +/* $Id: Keep.java,v 1.2 2001/07/04 12:40:50 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.datatypes;
  +
  +import org.apache.fop.fo.Property;
  +
  +/**
  + * XSL FO Keep Property datatype (keep-together, etc)
  + */
  +public class Keep implements CompoundDatatype {
  +    private Property withinLine;
  +    private Property withinColumn;
  +    private Property withinPage;
  +
  +    public Keep () {
  +    }
  +
  +    // From CompoundDatatype
  +    public void setComponent(String sCmpnName, Property cmpnValue,
  +                             boolean bIsDefault) {
  +        if (sCmpnName.equals("within-line"))
  +            setWithinLine(cmpnValue, bIsDefault);
  +        else if (sCmpnName.equals("within-column"))
  +            setWithinColumn(cmpnValue, bIsDefault);
  +        else if (sCmpnName.equals("within-page"))
  +            setWithinPage(cmpnValue, bIsDefault);
  +    }
  +
  +    // From CompoundDatatype
  +    public Property getComponent(String sCmpnName) {
  +        if (sCmpnName.equals("within-line"))
  +            return getWithinLine();
  +        else if (sCmpnName.equals("within-column"))
  +            return getWithinColumn();
  +        else if (sCmpnName.equals("within-page"))
  +            return getWithinPage();
  +        else
  +            return null;
  +    }
  +
  +    public void setWithinLine(Property withinLine, boolean bIsDefault) {
  +        this.withinLine = withinLine;
  +    }
  +
  +    protected void setWithinColumn(Property withinColumn,
  +                                   boolean bIsDefault) {
  +        this.withinColumn = withinColumn;
  +    }
  +
  +    public void setWithinPage(Property withinPage, boolean bIsDefault) {
  +        this.withinPage = withinPage;
  +    }
  +
  +    public Property getWithinLine() {
  +        return this.withinLine;
  +    }
  +
  +    public Property getWithinColumn() {
  +        return this.withinColumn;
  +    }
  +
  +    public Property getWithinPage() {
  +        return this.withinPage;
  +    }
  +
  +    /** What to do here?? There isn't really a meaningful single value. */
  +    public String toString() {
  +        return "Keep";
  +    }
  +}
  
  
  
  1.4       +87 -126   xml-fop/src/org/apache/fop/datatypes/LengthBase.java
  
  Index: LengthBase.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/datatypes/LengthBase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LengthBase.java	2000/12/26 23:37:59	1.3
  +++ LengthBase.java	2001/07/04 12:40:50	1.4
  @@ -1,126 +1,87 @@
  -/*-- $Id: LengthBase.java,v 1.3 2000/12/26 23:37:59 arved Exp $ -- 
  -
  - ============================================================================
  -                   The Apache Software License, Version 1.1
  - ============================================================================
  - 
  -    Copyright (C) 1999 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
  -    apache@apache.org.
  - 
  - 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
  - APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  - INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  - DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  - OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  - ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  - (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 <jt...@jtauber.com>. For more  information on the Apache 
  - Software Foundation, please see <http://www.apache.org/>.
  - 
  - */
  -package org.apache.fop.datatypes;
  -
  -import org.apache.fop.fo.FObj;
  -import org.apache.fop.fo.PropertyList;
  -import org.apache.fop.messaging.MessageHandler;
  -
  -public class LengthBase implements PercentBase {
  -  // Standard kinds of percent-based length
  -  public static final int CUSTOM_BASE=0;
  -  public static final int FONTSIZE=1;
  -  public static final int INH_FONTSIZE=2;
  -  public static final int CONTAINING_BOX=3;  
  -  public static final int CONTAINING_REFAREA=4;
  -
  -  /**
  -   * FO parent of the FO for which this property is to be calculated.
  -   */
  -  protected /* final */ FObj parentFO;
  -  /**
  -   * PropertyList for the FO where this property is calculated.
  -   */
  -  private /* final */ PropertyList propertyList;
  -  /** One of the defined types of LengthBase */
  -  private /* final */ int iBaseType;
  -
  -  public LengthBase(FObj parentFO, PropertyList plist, int iBaseType) {
  -    this.parentFO = parentFO;
  -    this.propertyList = plist;
  -    this.iBaseType = iBaseType;
  -  }
  -
  -  /** Accessor for parentFO object from subclasses which define
  -   * custom kinds of LengthBase calculations.
  -   */
  -  protected FObj getParentFO() {
  -    return parentFO;
  -  }
  -
  -  /** Accessor for propertyList object from subclasses which define
  -   * custom kinds of LengthBase calculations.
  -   */
  -  protected PropertyList getPropertyList() {
  -    return propertyList;
  -  }
  -
  -  public int getDimension() { return 1; }
  -  public double getBaseValue() { return 1.0; }
  -
  -  public int getBaseLength() {
  -    switch(iBaseType) {
  -    case FONTSIZE:
  -      return propertyList.get("font-size").getLength().mvalue();
  -    case INH_FONTSIZE:
  -      return propertyList.getInherited("font-size").getLength().mvalue();
  -    case CONTAINING_BOX:
  -      // depends on property?? inline-progression vs block-progression
  -      return parentFO.getContentWidth();
  -    case CONTAINING_REFAREA: // example: start-indent, end-indent
  -      {
  -          FObj fo;
  -          for (fo = parentFO;
  -               fo != null && !fo.generatesReferenceAreas();
  -               fo = fo.getParent())
  -          ;
  -          return (fo != null? fo.getContentWidth():0);
  -      }
  -    case CUSTOM_BASE:
  -      MessageHandler.errorln("!!! LengthBase.getBaseLength() called on CUSTOM_BASE type !!!");
  -      return 0;
  -    default:
  -      MessageHandler.errorln("Unknown base type for LengthBase.");
  -      return 0;
  -    }
  -  }
  -}
  -
  +/* $Id: LengthBase.java,v 1.4 2001/07/04 12:40:50 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.datatypes;
  +
  +import org.apache.fop.fo.FObj;
  +import org.apache.fop.fo.PropertyList;
  +import org.apache.fop.messaging.MessageHandler;
  +
  +public class LengthBase implements PercentBase {
  +    // Standard kinds of percent-based length
  +    public static final int CUSTOM_BASE = 0;
  +    public static final int FONTSIZE = 1;
  +    public static final int INH_FONTSIZE = 2;
  +    public static final int CONTAINING_BOX = 3;
  +    public static final int CONTAINING_REFAREA = 4;
  +
  +    /**
  +     * FO parent of the FO for which this property is to be calculated.
  +     */
  +    protected /* final */ FObj parentFO;
  +    /**
  +     * PropertyList for the FO where this property is calculated.
  +     */
  +    private /* final */ PropertyList propertyList;
  +    /** One of the defined types of LengthBase */
  +    private /* final */ int iBaseType;
  +
  +    public LengthBase(FObj parentFO, PropertyList plist, int iBaseType) {
  +        this.parentFO = parentFO;
  +        this.propertyList = plist;
  +        this.iBaseType = iBaseType;
  +    }
  +
  +    /** Accessor for parentFO object from subclasses which define
  +     * custom kinds of LengthBase calculations.
  +     */
  +    protected FObj getParentFO() {
  +        return parentFO;
  +    }
  +
  +    /** Accessor for propertyList object from subclasses which define
  +     * custom kinds of LengthBase calculations.
  +     */
  +    protected PropertyList getPropertyList() {
  +        return propertyList;
  +    }
  +
  +    public int getDimension() {
  +        return 1;
  +    }
  +    public double getBaseValue() {
  +        return 1.0;
  +    }
  +
  +    public int getBaseLength() {
  +        switch (iBaseType) {
  +            case FONTSIZE:
  +                return propertyList.get("font-size").getLength().mvalue();
  +            case INH_FONTSIZE:
  +                return propertyList.getInherited(
  +                         "font-size").getLength().mvalue();
  +            case CONTAINING_BOX:
  +                // depends on property?? inline-progression vs block-progression
  +                return parentFO.getContentWidth();
  +            case CONTAINING_REFAREA: // example: start-indent, end-indent
  +                {
  +                    FObj fo;
  +                    for (fo = parentFO; fo != null &&
  +                            !fo.generatesReferenceAreas();
  +                            fo = fo.getParent())
  +                        ;
  +                    return (fo != null ? fo.getContentWidth() : 0);
  +                }
  +            case CUSTOM_BASE:
  +                MessageHandler.errorln("!!! LengthBase.getBaseLength() called on CUSTOM_BASE type !!!");
  +                return 0;
  +            default:
  +                MessageHandler.errorln("Unknown base type for LengthBase.");
  +                return 0;
  +        }
  +    }
  +}
  +
  
  
  
  1.2       +48 -47    xml-fop/src/org/apache/fop/datatypes/LengthPair.java
  
  Index: LengthPair.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/datatypes/LengthPair.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LengthPair.java	2001/04/11 21:39:55	1.1
  +++ LengthPair.java	2001/07/04 12:40:51	1.2
  @@ -1,47 +1,48 @@
  -/*-- $Id: LengthPair.java,v 1.1 2001/04/11 21:39:55 klease 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.datatypes;
  -
  -import org.apache.fop.messaging.MessageHandler;
  -import org.apache.fop.fo.Property;
  -
  -/**
  - * This datatype hold a pair of lengths, specifiying the dimensions in
  - * both inline and block-progression-directions.
  - * It is currently only used to specify border-separation in tables.
  - */
  -public class LengthPair implements CompoundDatatype {
  -
  -    private Property ipd;
  -    private Property bpd;
  -
  -  // From CompoundDatatype
  -    public void setComponent(String sCmpnName, Property cmpnValue,
  -			     boolean bIsDefault) {
  -      if (sCmpnName.equals("block-progression-direction"))
  -	  bpd = cmpnValue;
  -      else if (sCmpnName.equals("inline-progression-direction"))
  -	  ipd = cmpnValue;
  -    }
  -
  -  // From CompoundDatatype
  -  public Property getComponent(String sCmpnName) {
  -      if (sCmpnName.equals("block-progression-direction"))
  -	return getBPD();
  -      else if (sCmpnName.equals("inline-progression-direction"))
  -	return getIPD();
  -      else return null; // SHOULDN'T HAPPEN
  -    }
  -
  -    public Property getIPD() {
  -	return this.ipd;
  -    }
  -
  -    public Property getBPD() {
  -	return this.bpd;
  -    }
  -}
  +/* $Id: LengthPair.java,v 1.2 2001/07/04 12:40:51 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.datatypes;
  +
  +import org.apache.fop.messaging.MessageHandler;
  +import org.apache.fop.fo.Property;
  +
  +/**
  + * This datatype hold a pair of lengths, specifiying the dimensions in
  + * both inline and block-progression-directions.
  + * It is currently only used to specify border-separation in tables.
  + */
  +public class LengthPair implements CompoundDatatype {
  +
  +    private Property ipd;
  +    private Property bpd;
  +
  +    // From CompoundDatatype
  +    public void setComponent(String sCmpnName, Property cmpnValue,
  +                             boolean bIsDefault) {
  +        if (sCmpnName.equals("block-progression-direction"))
  +            bpd = cmpnValue;
  +        else if (sCmpnName.equals("inline-progression-direction"))
  +            ipd = cmpnValue;
  +    }
  +
  +    // From CompoundDatatype
  +    public Property getComponent(String sCmpnName) {
  +        if (sCmpnName.equals("block-progression-direction"))
  +            return getBPD();
  +        else if (sCmpnName.equals("inline-progression-direction"))
  +            return getIPD();
  +        else
  +            return null; // SHOULDN'T HAPPEN
  +    }
  +
  +    public Property getIPD() {
  +        return this.ipd;
  +    }
  +
  +    public Property getBPD() {
  +        return this.bpd;
  +    }
  +}
  
  
  
  1.4       +157 -196  xml-fop/src/org/apache/fop/datatypes/LengthRange.java
  
  Index: LengthRange.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/datatypes/LengthRange.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LengthRange.java	2001/01/02 21:32:20	1.3
  +++ LengthRange.java	2001/07/04 12:40:51	1.4
  @@ -1,196 +1,157 @@
  -/*-- $Id: LengthRange.java,v 1.3 2001/01/02 21:32:20 klease Exp $ -- 
  -
  - ============================================================================
  -                   The Apache Software License, Version 1.1
  - ============================================================================
  - 
  -    Copyright (C) 1999 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
  -    apache@apache.org.
  - 
  - 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
  - APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  - INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  - DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  - OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  - ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  - (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 <jt...@jtauber.com>. For more  information on the Apache 
  - Software Foundation, please see <http://www.apache.org/>.
  - 
  - */
  -package org.apache.fop.datatypes;
  -
  -import org.apache.fop.messaging.MessageHandler;
  -import org.apache.fop.fo.Property;
  -
  -/**
  - * a "progression-dimension" quantity
  - * ex. block-progression-dimension, inline-progression-dimension
  - * corresponds to the triplet min-height, height, max-height (or width)
  - */
  -public class LengthRange implements CompoundDatatype {
  -
  -    private Property minimum;
  -    private Property optimum;
  -    private Property maximum;
  -  private static final int MINSET=1;
  -  private static final int OPTSET=2;
  -  private static final int MAXSET=4;
  -  private int bfSet = 0; // bit field
  -  private boolean bChecked = false;
  -
  -  // From CompoundDatatype
  -    public void setComponent(String sCmpnName, Property cmpnValue,
  -			     boolean bIsDefault) {
  -      if (sCmpnName.equals("minimum"))
  -	setMinimum(cmpnValue, bIsDefault);
  -      else if (sCmpnName.equals("optimum"))
  -	setOptimum(cmpnValue, bIsDefault);
  -      else if (sCmpnName.equals("maximum"))
  -	setMaximum(cmpnValue, bIsDefault);
  -    }
  -
  -  // From CompoundDatatype
  -  public Property getComponent(String sCmpnName) {
  -      if (sCmpnName.equals("minimum"))
  -	return getMinimum();
  -      else if (sCmpnName.equals("optimum"))
  -	return getOptimum();
  -      else if (sCmpnName.equals("maximum"))
  -	return getMaximum();
  -      else return null; // SHOULDN'T HAPPEN
  -    }
  -
  -    /**
  -     * Set minimum value to min.
  -     * @param min A Length value specifying the minimum value for this
  -     * LengthRange.
  -     * @param bIsDefault If true, this is set as a "default" value
  -     * and not a user-specified explicit value.
  -     */
  -    protected void setMinimum(Property minimum, boolean bIsDefault) {
  -      this.minimum = minimum;
  -	if (!bIsDefault) bfSet |= MINSET;
  -    }
  -
  -
  -    /**
  -     * Set maximum value to max if it is >= optimum or optimum isn't set.
  -     * @param max A Length value specifying the maximum value for this
  -     * @param bIsDefault If true, this is set as a "default" value
  -     * and not a user-specified explicit value.
  -     */
  -    protected void setMaximum(Property max, boolean bIsDefault) {
  -	maximum = max;
  -	if (!bIsDefault) bfSet |= MAXSET;
  -    }
  -
  -
  -    /**
  -     * Set the optimum value.
  -     * @param opt A Length value specifying the optimum value for this
  -     * @param bIsDefault If true, this is set as a "default" value
  -     * and not a user-specified explicit value.
  -     */
  -    protected void setOptimum(Property opt, boolean bIsDefault) {
  -      optimum = opt;
  -      if (!bIsDefault) bfSet |= OPTSET;
  -    }
  -
  -  // Minimum is prioritaire, if explicit
  -  private void checkConsistency() {
  -    if (bChecked) return;
  -    // Make sure max >= min
  -    // Must also control if have any allowed enum values!
  -    /*********************
  -    if (minimum.mvalue() > maximum.mvalue()) {
  -      if ((bfSet&MINSET)!=0) {
  -	// if minimum is explicit, force max to min
  -	if ((bfSet&MAXSET)!=0) {
  -	  // Warning: min>max, resetting max to min
  -	  MessageHandler.errorln("WARNING: forcing max to min in LengthRange");
  -	}
  -	maximum = minimum ;
  -      }
  -      else {
  -	minimum = maximum; // minimum was default value
  -      }
  -    }
  -    // Now make sure opt <= max and opt >= min
  -    if (optimum.mvalue() > maximum.mvalue()) {
  -      if ((bfSet&OPTSET)!=0) {
  -	if ((bfSet&MAXSET)!=0) {
  -	  // Warning: opt > max, resetting opt to max
  -	  MessageHandler.errorln("WARNING: forcing opt to max in LengthRange");
  -	  optimum = maximum ;
  -	}
  -	else {
  -	  maximum = optimum; // maximum was default value
  -	}
  -      }
  -      else {
  -	// opt is default and max is explicit or default
  -	optimum = maximum ;
  -      }
  -    }
  -    else if (optimum.mvalue() < minimum.mvalue()) {
  -      if ((bfSet&MINSET)!=0) {
  -	// if minimum is explicit, force opt to min
  -	if ((bfSet&OPTSET)!=0) {
  -	  MessageHandler.errorln("WARNING: forcing opt to min in LengthRange");
  -	}
  -	optimum = minimum ;
  -      }
  -      else {
  -	minimum = optimum; // minimum was default value
  -      }
  -    }
  -    ********$*********/
  -    bChecked = true;
  -  }
  -
  -    public Property getMinimum() {
  -      checkConsistency();
  -      return this.minimum;
  -    }
  -
  -    public Property getMaximum() {
  -      checkConsistency();
  -      return this.maximum;
  -    }
  -
  -    public Property getOptimum() {
  -      checkConsistency();
  -      return this.optimum;
  -    }
  -}
  +/* $Id: LengthRange.java,v 1.4 2001/07/04 12:40:51 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.datatypes;
  +
  +import org.apache.fop.messaging.MessageHandler;
  +import org.apache.fop.fo.Property;
  +
  +/**
  + * a "progression-dimension" quantity
  + * ex. block-progression-dimension, inline-progression-dimension
  + * corresponds to the triplet min-height, height, max-height (or width)
  + */
  +public class LengthRange implements CompoundDatatype {
  +
  +    private Property minimum;
  +    private Property optimum;
  +    private Property maximum;
  +    private static final int MINSET = 1;
  +    private static final int OPTSET = 2;
  +    private static final int MAXSET = 4;
  +    private int bfSet = 0; // bit field
  +    private boolean bChecked = false;
  +
  +    // From CompoundDatatype
  +    public void setComponent(String sCmpnName, Property cmpnValue,
  +                             boolean bIsDefault) {
  +        if (sCmpnName.equals("minimum"))
  +            setMinimum(cmpnValue, bIsDefault);
  +        else if (sCmpnName.equals("optimum"))
  +            setOptimum(cmpnValue, bIsDefault);
  +        else if (sCmpnName.equals("maximum"))
  +            setMaximum(cmpnValue, bIsDefault);
  +    }
  +
  +    // From CompoundDatatype
  +    public Property getComponent(String sCmpnName) {
  +        if (sCmpnName.equals("minimum"))
  +            return getMinimum();
  +        else if (sCmpnName.equals("optimum"))
  +            return getOptimum();
  +        else if (sCmpnName.equals("maximum"))
  +            return getMaximum();
  +        else
  +            return null; // SHOULDN'T HAPPEN
  +    }
  +
  +    /**
  +     * Set minimum value to min.
  +     * @param min A Length value specifying the minimum value for this
  +     * LengthRange.
  +     * @param bIsDefault If true, this is set as a "default" value
  +     * and not a user-specified explicit value.
  +     */
  +    protected void setMinimum(Property minimum, boolean bIsDefault) {
  +        this.minimum = minimum;
  +        if (!bIsDefault)
  +            bfSet |= MINSET;
  +    }
  +
  +
  +    /**
  +     * Set maximum value to max if it is >= optimum or optimum isn't set.
  +     * @param max A Length value specifying the maximum value for this
  +     * @param bIsDefault If true, this is set as a "default" value
  +     * and not a user-specified explicit value.
  +     */
  +    protected void setMaximum(Property max, boolean bIsDefault) {
  +        maximum = max;
  +        if (!bIsDefault)
  +            bfSet |= MAXSET;
  +    }
  +
  +
  +    /**
  +     * Set the optimum value.
  +     * @param opt A Length value specifying the optimum value for this
  +     * @param bIsDefault If true, this is set as a "default" value
  +     * and not a user-specified explicit value.
  +     */
  +    protected void setOptimum(Property opt, boolean bIsDefault) {
  +        optimum = opt;
  +        if (!bIsDefault)
  +            bfSet |= OPTSET;
  +    }
  +
  +    // Minimum is prioritaire, if explicit
  +    private void checkConsistency() {
  +        if (bChecked)
  +            return;
  +        // Make sure max >= min
  +        // Must also control if have any allowed enum values!
  +        /*********************
  +        if (minimum.mvalue() > maximum.mvalue()) {
  +          if ((bfSet&MINSET)!=0) {
  +        // if minimum is explicit, force max to min
  +        if ((bfSet&MAXSET)!=0) {
  +        // Warning: min>max, resetting max to min
  +        MessageHandler.errorln("WARNING: forcing max to min in LengthRange");
  +    }
  +        maximum = minimum ;
  +          }
  +          else {
  +        minimum = maximum; // minimum was default value
  +          }
  +    }
  +        // Now make sure opt <= max and opt >= min
  +        if (optimum.mvalue() > maximum.mvalue()) {
  +          if ((bfSet&OPTSET)!=0) {
  +        if ((bfSet&MAXSET)!=0) {
  +        // Warning: opt > max, resetting opt to max
  +        MessageHandler.errorln("WARNING: forcing opt to max in LengthRange");
  +        optimum = maximum ;
  +    }
  +        else {
  +        maximum = optimum; // maximum was default value
  +    }
  +          }
  +          else {
  +        // opt is default and max is explicit or default
  +        optimum = maximum ;
  +          }
  +    }
  +        else if (optimum.mvalue() < minimum.mvalue()) {
  +          if ((bfSet&MINSET)!=0) {
  +        // if minimum is explicit, force opt to min
  +        if ((bfSet&OPTSET)!=0) {
  +        MessageHandler.errorln("WARNING: forcing opt to min in LengthRange");
  +    }
  +        optimum = minimum ;
  +          }
  +          else {
  +        minimum = optimum; // minimum was default value
  +          }
  +    }
  +         ********$*********/
  +        bChecked = true;
  +    }
  +
  +    public Property getMinimum() {
  +        checkConsistency();
  +        return this.minimum;
  +    }
  +
  +    public Property getMaximum() {
  +        checkConsistency();
  +        return this.maximum;
  +    }
  +
  +    public Property getOptimum() {
  +        checkConsistency();
  +        return this.optimum;
  +    }
  +}
  
  
  
  1.4       +62 -103   xml-fop/src/org/apache/fop/datatypes/Space.java
  
  Index: Space.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/datatypes/Space.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Space.java	2001/01/02 21:32:18	1.3
  +++ Space.java	2001/07/04 12:40:52	1.4
  @@ -1,103 +1,62 @@
  -/*-- $Id: Space.java,v 1.3 2001/01/02 21:32:18 klease Exp $ -- 
  -
  - ============================================================================
  -                   The Apache Software License, Version 1.1
  - ============================================================================
  - 
  -    Copyright (C) 1999 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
  -    apache@apache.org.
  - 
  - 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
  - APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  - INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  - DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  - OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  - ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  - (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 <jt...@jtauber.com>. For more  information on the Apache 
  - Software Foundation, please see <http://www.apache.org/>.
  - 
  - */
  -package org.apache.fop.datatypes;
  -
  -import org.apache.fop.fo.Property;
  -
  -/**
  - * a space quantity in XSL (space-before, space-after)
  - */
  -public class Space extends LengthRange {
  -
  -    private Property precedence;
  -    private Property conditionality ;
  - 
  -  // From CompoundDatatype
  -    public void setComponent(String sCmpnName, Property cmpnValue,
  -			     boolean bIsDefault) {
  -      if (sCmpnName.equals("precedence"))
  -	setPrecedence(cmpnValue, bIsDefault);
  -      else if (sCmpnName.equals("conditionality"))
  -	setConditionality(cmpnValue, bIsDefault);
  -      else super.setComponent(sCmpnName, cmpnValue, bIsDefault);
  -    }
  -
  -  // From CompoundDatatype
  -  public Property getComponent(String sCmpnName) {
  -      if (sCmpnName.equals("precedence"))
  -	return getPrecedence();
  -      else if (sCmpnName.equals("conditionality"))
  -	return getConditionality();
  -      else return super.getComponent(sCmpnName);
  -    }
  -
  -    protected void setPrecedence(Property precedence, boolean bIsDefault) {
  -      this.precedence = precedence;
  -    }
  -
  -    protected void setConditionality(Property conditionality, boolean bIsDefault) {
  -      this.conditionality = conditionality;
  -    }
  -
  -    public Property getPrecedence() {
  -	return this.precedence ;
  -    }
  -
  -  /*
  -  public boolean isDiscard() {
  -    return (this.conditionality == DISCARD);
  -  }
  -  */
  -
  -    public Property getConditionality() {
  -      return this.conditionality ;
  -    }
  -}
  +/* $Id: Space.java,v 1.4 2001/07/04 12:40:52 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.datatypes;
  +
  +import org.apache.fop.fo.Property;
  +
  +/**
  + * a space quantity in XSL (space-before, space-after)
  + */
  +public class Space extends LengthRange {
  +
  +    private Property precedence;
  +    private Property conditionality ;
  +
  +    // From CompoundDatatype
  +    public void setComponent(String sCmpnName, Property cmpnValue,
  +                             boolean bIsDefault) {
  +        if (sCmpnName.equals("precedence"))
  +            setPrecedence(cmpnValue, bIsDefault);
  +        else if (sCmpnName.equals("conditionality"))
  +            setConditionality(cmpnValue, bIsDefault);
  +        else
  +            super.setComponent(sCmpnName, cmpnValue, bIsDefault);
  +    }
  +
  +    // From CompoundDatatype
  +    public Property getComponent(String sCmpnName) {
  +        if (sCmpnName.equals("precedence"))
  +            return getPrecedence();
  +        else if (sCmpnName.equals("conditionality"))
  +            return getConditionality();
  +        else
  +            return super.getComponent(sCmpnName);
  +    }
  +
  +    protected void setPrecedence(Property precedence, boolean bIsDefault) {
  +        this.precedence = precedence;
  +    }
  +
  +    protected void setConditionality(Property conditionality,
  +                                     boolean bIsDefault) {
  +        this.conditionality = conditionality;
  +    }
  +
  +    public Property getPrecedence() {
  +        return this.precedence ;
  +    }
  +
  +    /*
  +     public boolean isDiscard() {
  +       return (this.conditionality == DISCARD);
  +     }
  +     */
  +
  +    public Property getConditionality() {
  +        return this.conditionality ;
  +    }
  +}
  
  
  
  1.4       +111 -122  xml-fop/src/org/apache/fop/fo/pagination/Region.java
  
  Index: Region.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/pagination/Region.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Region.java	2001/03/04 23:09:22	1.3
  +++ Region.java	2001/07/04 12:40:56	1.4
  @@ -1,122 +1,111 @@
  -/*-- $Id: Region.java,v 1.3 2001/03/04 23:09:22 arved 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.fo.pagination;
  -
  -// FOP
  -import org.apache.fop.fo.FObj;
  -import org.apache.fop.fo.PropertyList;
  -import org.apache.fop.apps.FOPException;
  -import org.apache.fop.layout.RegionArea;
  -
  -/**
  - * This is an abstract base class for pagination regions
  - */
  -public abstract class Region extends FObj 
  -{
  -    public static final String PROP_REGION_NAME = "region-name";
  -    
  -    private SimplePageMaster _layoutMaster;
  -    private String _regionName;
  -    
  -    protected Region(FObj parent, PropertyList propertyList)
  -	throws FOPException 
  -    {
  -	super(parent, propertyList);
  -	this.name = getElementName();
  -	
  -	// regions may have name, or default
  -	if (null == this.properties.get(PROP_REGION_NAME)) {
  -	    setRegionName(getDefaultRegionName());
  -	}
  -	else if (this.properties.get(PROP_REGION_NAME).getString().equals("")) {
  -	    setRegionName(getDefaultRegionName());
  -	}
  -	else {
  -	    setRegionName(this.properties.get(PROP_REGION_NAME).getString());
  -	    // check that name is OK. Not very pretty.
  -	    if (isReserved(getRegionName()) && 
  -		!getRegionName().equals(getDefaultRegionName())) {
  -		throw new FOPException(PROP_REGION_NAME+" '" + _regionName
  -				       + "' for "+this.name+" not permitted."); 
  -	    }
  -	}
  -
  -	if (parent.getName().equals("fo:simple-page-master")) {
  -	    _layoutMaster = (SimplePageMaster) parent;
  -	    getPageMaster().addRegion(this);
  -	} else {
  -	    throw new FOPException(getElementName()+" must be child "
  -				   + "of simple-page-master, not "
  -				   + parent.getName()); 
  -	}
  -    }
  -
  -    /**
  -     * Creates a Region layout object for this pagination Region.
  -     */
  -    abstract RegionArea makeRegionArea(int allocationRectangleXPosition,
  -				   int allocationRectangleYPosition,
  -				   int allocationRectangleWidth,
  -				   int allocationRectangleHeight);
  -    
  -				   /**
  -     * Returns the default region name (xsl-region-before, xsl-region-start,
  -     * etc.) 
  -     */
  -    protected abstract String getDefaultRegionName();
  -
  -    /**
  -     * Returns the element name ("fo:region-body", "fo:region-start",
  -     * etc.) 
  -     */
  -    protected abstract String getElementName();
  -    
  -    public abstract String getRegionClass();
  -    
  -
  -    /**
  -     * Returns the name of this region
  -     */
  -    public String getRegionName() 
  -    {
  -	return _regionName;
  -    }
  -
  -    private void setRegionName(String name) 
  -    {
  -	_regionName = name;
  -    }
  -    
  -    protected SimplePageMaster getPageMaster() 
  -    {
  -	return _layoutMaster;
  -    }
  -    
  -
  -    /**
  -     * Checks to see if a given region name is one of the reserved names
  -     *
  -     * @param name a region name to check
  -     * @return true if the name parameter is a reserved region name
  -     */
  -    protected boolean isReserved(String name) 
  -	throws FOPException
  -    {
  -	return (name.equals( "xsl-region-before" ) || 
  -		name.equals( "xsl-region-start" )  ||
  -		name.equals( "xsl-region-end" )    || 
  -		name.equals( "xsl-region-after" )  ||
  -		name.equals( "xsl-before-float-separator" ) ||
  -		name.equals( "xsl-footnote-separator" ));
  -    }
  -    
  -    public boolean generatesReferenceAreas() {
  -	return true;
  -    }
  -    
  -}
  +/* $Id: Region.java,v 1.4 2001/07/04 12:40:56 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.fo.pagination;
  +
  +// FOP
  +import org.apache.fop.fo.FObj;
  +import org.apache.fop.fo.PropertyList;
  +import org.apache.fop.apps.FOPException;
  +import org.apache.fop.layout.RegionArea;
  +
  +/**
  + * This is an abstract base class for pagination regions
  + */
  +public abstract class Region extends FObj {
  +    public static final String PROP_REGION_NAME = "region-name";
  +
  +    private SimplePageMaster _layoutMaster;
  +    private String _regionName;
  +
  +    protected Region(FObj parent,
  +                     PropertyList propertyList) throws FOPException {
  +        super(parent, propertyList);
  +        this.name = getElementName();
  +
  +        // regions may have name, or default
  +        if (null == this.properties.get(PROP_REGION_NAME)) {
  +            setRegionName(getDefaultRegionName());
  +        } else if ( this.properties.get(
  +              PROP_REGION_NAME).getString().equals("")) {
  +            setRegionName(getDefaultRegionName());
  +        } else {
  +            setRegionName(
  +              this.properties.get(PROP_REGION_NAME).getString());
  +            // check that name is OK. Not very pretty.
  +            if (isReserved(getRegionName()) &&
  +                    !getRegionName().equals(getDefaultRegionName())) {
  +                throw new FOPException(PROP_REGION_NAME + " '" +
  +                                       _regionName + "' for "+this.name + " not permitted.");
  +            }
  +        }
  +
  +        if (parent.getName().equals("fo:simple-page-master")) {
  +            _layoutMaster = (SimplePageMaster) parent;
  +            getPageMaster().addRegion(this);
  +        } else {
  +            throw new FOPException(getElementName() + " must be child " +
  +                                   "of simple-page-master, not " + parent.getName());
  +        }
  +    }
  +
  +    /**
  +     * Creates a Region layout object for this pagination Region.
  +     */
  +    abstract RegionArea makeRegionArea( int allocationRectangleXPosition,
  +                                        int allocationRectangleYPosition,
  +                                        int allocationRectangleWidth, int allocationRectangleHeight);
  +
  +    /**
  +     * Returns the default region name (xsl-region-before, xsl-region-start,
  +     * etc.)
  +     */
  +    protected abstract String getDefaultRegionName();
  +
  +    /**
  +     * Returns the element name ("fo:region-body", "fo:region-start",
  +     * etc.)
  +     */
  +    protected abstract String getElementName();
  +
  +    public abstract String getRegionClass();
  +
  +
  +    /**
  +     * Returns the name of this region
  +     */
  +    public String getRegionName() {
  +        return _regionName;
  +    }
  +
  +    private void setRegionName(String name) {
  +        _regionName = name;
  +    }
  +
  +    protected SimplePageMaster getPageMaster() {
  +        return _layoutMaster;
  +    }
  +
  +    /**
  +     * Checks to see if a given region name is one of the reserved names
  +     *
  +     * @param name a region name to check
  +     * @return true if the name parameter is a reserved region name
  +     */
  +    protected boolean isReserved(String name) throws FOPException {
  +        return (name.equals("xsl-region-before") ||
  +                name.equals("xsl-region-start") ||
  +                name.equals("xsl-region-end") ||
  +                name.equals("xsl-region-after") ||
  +                name.equals("xsl-before-float-separator") ||
  +                name.equals("xsl-footnote-separator"));
  +    }
  +
  +    public boolean generatesReferenceAreas() {
  +        return true;
  +    }
  +
  +}
  
  
  
  1.2       +21 -66    xml-fop/src/org/apache/fop/image/FopImageException.java
  
  Index: FopImageException.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/image/FopImageException.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FopImageException.java	2000/05/23 09:04:22	1.1
  +++ FopImageException.java	2001/07/04 12:40:58	1.2
  @@ -1,66 +1,21 @@
  -/*
  -
  - ============================================================================
  -                   The Apache Software License, Version 1.1
  - ============================================================================
  - 
  -    Copyright (C) 1999 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
  -    apache@apache.org.
  - 
  - 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
  - APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  - INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  - DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  - OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  - ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  - (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 <jt...@jtauber.com>. For more  information on the Apache 
  - Software Foundation, please see <http://www.apache.org/>.
  - 
  - */
  -
  -//Author:       Eric SCHAEFFER
  -//Description:  Image Exception
  -
  -package org.apache.fop.image;
  -
  -public class FopImageException extends Exception {
  -
  -	public FopImageException() {
  -		super();
  -	}
  -
  -	public FopImageException(String message) {
  -		super(message);
  -	}
  -}
  +/* $Id: FopImageException.java,v 1.2 2001/07/04 12:40:58 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.
  + */
  +
  +//Author:       Eric SCHAEFFER
  +//Description:  Image Exception
  +
  +package org.apache.fop.image;
  +
  +public class FopImageException extends Exception {
  +
  +    public FopImageException() {
  +        super();
  +    }
  +
  +    public FopImageException(String message) {
  +        super(message);
  +    }
  +}
  
  
  
  1.2       +1105 -1185xml-fop/src/org/apache/fop/mif/MIFDocument.java
  
  Index: MIFDocument.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/mif/MIFDocument.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MIFDocument.java	2001/02/10 03:20:32	1.1
  +++ MIFDocument.java	2001/07/04 12:41:01	1.2
  @@ -1,1185 +1,1105 @@
  -/*-- $Id: MIFDocument.java,v 1.1 2001/02/10 03:20:32 arved Exp $ --
  -
  - ============================================================================
  -                   The Apache Software License, Version 1.1
  - ============================================================================
  - 
  -    Copyright (C) 1999 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
  -    apache@apache.org.
  - 
  - 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
  - APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  - INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  - DING, BUT NOT LIMITED TO, PROCUREMENT	OF SUBSTITUTE GOODS OR SERVICES; LOSS
  - OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)	HOWEVER CAUSED AND ON
  - ANY  THEORY OF LIABILITY,	WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  - (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 <jt...@jtauber.com>. For more  information on the Apache
  - Software Foundation, please see <http://www.apache.org/>.
  -
  - */
  -
  -
  -//Author : Seshadri G
  -
  -
  -
  -package org.apache.fop.mif;
  -
  -// images are the one place that FOP classes outside this package get
  -// referenced and I'd rather not do it
  -
  -import org.apache.fop.image.FopImage;
  -import org.apache.fop.messaging.MessageHandler;
  -import org.apache.fop.layout.LinkSet;
  -import org.apache.fop.datatypes.ColorSpace;
  -
  -import org.apache.fop.datatypes.IDReferences;
  -import org.apache.fop.layout.Page;
  -import org.apache.fop.layout.FontMetric;
  -import org.apache.fop.layout.FontDescriptor;
  -// Java
  -import java.io.*;
  -import java.io.PrintWriter;
  -import java.util.*;
  -import java.awt.Rectangle;
  -
  -/**
  - * class representing a MIF document.
  - *
  - * The document is built up by calling various methods and then finally
  - * output to given filehandle using output method.
  - *
  - */ 
  -public class MIFDocument {
  -
  -    /** the version of MIF supported */
  -
  -
  -    protected static final String mifVersion = "5.5";
  -    protected BookComponent bookComponent;
  -    private Flow curFlow;    // this is a ref to the current flow which could be a textflow or 
  -			     // a table	
  -    private ID curIDCounter=new ID();	
  -
  -    class ID {
  -
  -	private int idCounter=1;
  -	public int getnewID() {
  -
  -		return idCounter++;
  -	}
  -	
  -    }	
  -
  -    class FontFormat {    
  -
  -	public FontFormat() { }
  -
  -    }
  -
  -    class ParagraphFormat extends FontFormat {
  -
  -	public ParagraphFormat() {}
  -	int startIndent;
  -	int endIndent;
  -
  -
  -
  -    }
  -
  -    class Document {
  -	protected int height;
  -	protected int width;
  -	public Document() {}
  -
  -	public void output(OutputStream stream) throws IOException {	
  -
  -		String mif="\n<Document " + "\n<DPageSize " + width/1000f + " " + height/1000f + " >\n>";
  -		byte buf[]=mif.getBytes();	
  -
  -		stream.write(buf);
  -		
  -	}
  -
  -    }
  -
  -    
  -    class PolyLine {
  -
  -	public PolyLine() {}
  -    }
  -
  -    class ImportObject {
  -
  -	private String url;
  -	private int x,y,w,h;
  -
  -	public ImportObject(String url,int x,int y,int w,int h) {
  -
  -		this.url=url;	
  -		this.x=x;
  -		this.y=y;
  -		this.w=w;
  -		this.h=h;
  -
  -	}
  -
  -
  -	public void output(OutputStream stream) throws IOException {	
  -
  -
  -		String path=this.url;
  -
  -		//Strip 'file:'
  -		path= path.substring(5);
  -		String result="";
  -		int i;
  -		do { // replace all matching '/'
  -
  -			i=path.indexOf("/");
  -			if (i != -1) {
  -				result=path.substring(0,i);
  -				result += "<c\\>";
  -				result += path.substring(i + 1);
  -				path=result;
  -			}
  -
  -		} while (i!= -1);
  -		
  -		String mif="\n<ImportObject" + "\n<ImportObFixedSize Yes>";
  -		mif += "\n\t<ImportObFileDI " + "`<c\\>" + path + "'" + " >";
  -		mif +="\n\t<ShapeRect " + this.x/1000f + " " + this.y/1000f + " " + this.w/1000f + " " + this.h/1000f + " >";
  -
  -		mif += "\n> #End ImportObj";			
  -		stream.write(mif.getBytes());		
  -
  -	}
  -
  -    }
  -
  -	
  -    class Frame {
  -
  -	private int ID;
  -	private int x,y,w,h;
  -	Vector content=new Vector();
  -	public Frame(int x, int y, int w, int h) {
  -
  -		this.ID=curIDCounter.getnewID();
  -		this.x=x;
  -		this.y=y;
  -		this.w=w;
  -		this.h=h;
  -
  -	}
  -	
  -	public void addContent(ImportObject obj) {
  -
  -		content.addElement(obj);		
  -
  -	}
  -
  -	public void output(OutputStream stream) throws IOException {
  -
  -		String mif="\n<Frame" + "\n\t<ID " + this.ID + " >";
  -		mif += "\n\t<Pen 15>\n\t<Fill 7>\n\t<PenWidth  1.0 >\n\t<Separation 0>\n\t<ObColor `Black'>\n\t<DashedPattern \n\t <DashedStyle Solid> \n >";
  -
  -		mif +="\n\t<RunaroundGap  6.0 pt>\n\t<RunaroundType None>\n\t<Angle  360.0>\n\t<Float No>\n\t<NSOffset  0.0>\n\t<BLOffset  0>\n\t<Cropped No>\n\t<FrameType Below>\n\t<AnchorAlign Center>";
  -
  -		mif += "\n\t<ShapeRect " + this.x/1000f + " " + this.y/1000f + " " + this.w/1000f + " "  + this.h/1000f + " >";
  -	
  -
  -		stream.write(mif.getBytes());
  -
  -		Enumeration e=content.elements();
  -		while (e.hasMoreElements()) {
  -
  -			((ImportObject) e.nextElement()).output(stream);
  -		}
  -		mif ="\n> #End Frame";
  -		stream.write(mif.getBytes());
  -
  -
  -
  -	}	
  -	public int getID() {
  -	
  -		return this.ID;
  -	}	
  -
  -    }
  -  
  -    class TextRect {
  -	private int rx,ry,w,h;
  -	private int numCols;
  -	private int curCol=0; //Current column being processed
  -	private int colGap=0;
  -	private int textRectID;
  -	public TextRect(int numCols) {
  -
  -		this.numCols=numCols;
  -		this.curCol=0;
  -		this.textRectID=curIDCounter.getnewID();
  -		
  -	}
  -
  -
  -	public int getTextRectID() {
  -	
  -		return textRectID;
  -	
  -	}
  -
  -
  -	public void setTextRectProp(int left,int top,int width,int height) {
  -		
  -		if (curCol==0) {
  -
  -			//Use the left and top margins
  -
  -			rx=left;
  -			ry=top;
  -			w=width; // current column width , not the entire span
  -			h=height;
  -			curCol++;
  -			
  -		}
  -		else if (curCol==1) {
  -			// Figure out the column gap and the span of the textrect
  -			colGap=left-rx-width;
  -			// Next the entire width
  -			w=numCols*width + (numCols-1)*colGap;
  -			curCol++;
  -			
  -
  -		}
  -				
  -	}
  -
  -
  -	public void output(OutputStream stream) throws IOException {	
  -
  -		String mif="\n<TextRect" + "\n\t<ID " + textRectID + ">" + "\n\t<ShapeRect " + rx/1000f + " " +  ry/1000f + " " + w/1000f + " " + h/1000f + ">" ;
  -
  -		if (numCols>1) {
  -			mif += "\n<TRNumColumns " + numCols + ">";
  -			mif += "\n<TRColumnGap " + colGap/1000f + ">";
  -		}
  -
  -		mif += "\n> #End TextRect" ;
  -		byte buf[]=mif.getBytes();
  -		stream.write(buf);
  -	}
  -
  -    }
  -
  -    class Page {
  -	private String pageType;
  -	private String pageTag;
  -	private String pageBackground;
  -	private Vector textRects;
  -	public Page(String pageType, String pageTag, String pageBackground) {
  -	
  -	       	this.pageType=pageType;
  -		this.pageTag=pageTag;
  -		this.pageBackground=pageBackground;
  -		this.textRects=new Vector();
  -	}
  -
  -	public Page() {
  -
  -		this.pageType="BodyPage";
  -		this.pageBackground="Default";
  -		this.textRects=new Vector();
  -
  -	}
  -
  -
  -	public void addTextRect(int numCols) {
  -				
  -		TextRect textRect=new TextRect(numCols);
  -		this.textRects.addElement(textRect);
  -	}
  -
  -	public TextRect curTextRect() {
  -
  -		return (TextRect) textRects.lastElement();
  -
  -	}
  -
  -
  -	
  -	public void output(OutputStream stream) throws IOException {
  -
  -
  -		String mif="\n<Page" + "\n\t<PageType " + pageType + ">" + "\n\t<PageBackground " + "`" + pageBackground + "'" + ">";
  -
  -		byte  buf[]=mif.getBytes();
  -
  -		stream.write(buf);
  -		
  -		Enumeration e=textRects.elements();
  -
  -		while (e.hasMoreElements()) {
  -
  -			((TextRect) e.nextElement()).output(stream);
  -
  -		}
  -		mif="\n>  #End Page\n";
  -		stream.write(mif.getBytes()); 
  -
  -	}
  -
  -	
  -     }
  -
  -    abstract class Flow {    
  -
  -	public Flow() {}
  -	public abstract Para curPara();
  -	public abstract void startPara();
  -    }
  -
  -
  -    class TextFlow extends Flow {
  -	
  -	Vector paras;		
  -	private int ID; 	// This ID is used within ParaLine, however it is 
  -	        		// logical to keep it unique	to a textflow
  -
  -	public TextFlow() {
  -		
  -		
  -		//The current textrect into which the textflow goes
  -		//is the last created.
  -
  -		this.ID=((bookComponent.curPage()).curTextRect()).getTextRectID();
  -		this.paras=new Vector();
  -		
  -	}
  -	
  -
  -	public int getTextRectID() {
  -
  -		return ID;
  -
  -	}
  -
  -	public Para curPara() {
  -
  -		return (Para) paras.lastElement();
  -	}
  -
  -	public void startPara() {
  -
  -		this.paras.addElement(new Para(ID));
  -	}
  -
  -	public void output(OutputStream stream) throws IOException {	
  -		String mif="\n<TextFlow";
  -		stream.write(mif.getBytes());
  -		Enumeration e=paras.elements();
  -		while (e.hasMoreElements()) {
  -
  -			((Para) e.nextElement()).output(stream);
  -		}
  -		mif="\n> #End TextFlow";
  -		stream.write(mif.getBytes());
  -	}
  -
  -     }
  -	
  -
  -     class Para  {	     
  -	
  -	Vector paraLines;
  -	int ID; // Same as TextRectID
  -	ParagraphFormat pgf=null; // This corresponds to to the block properties
  -	public Para() {
  -
  -		this.ID=0;
  -		this.paraLines=new Vector();
  -	}
  -
  -
  -	public Para(int ID) {
  -	
  -		this.ID=ID;
  -		this.paraLines=new Vector();
  -		
  -	}
  -
  -	public ParaLine curParaLine() {
  -		if (paraLines.isEmpty()) {
  -			return null;
  -		}
  -		else {
  -			return (ParaLine) paraLines.lastElement();
  -		}
  -	}
  -
  -	void startParaLine() {
  -		
  -		this.paraLines.addElement(new ParaLine(ID));
  -
  -	}
  -
  -
  -	public void setBlockProp(int startIndent,int endIndent) {
  -
  -		pgf=new ParagraphFormat();
  -		pgf.startIndent=startIndent;
  -		pgf.endIndent=endIndent;
  -				
  -
  -	}
  -
  -
  -	public void output(OutputStream stream) throws IOException {	
  -
  -		String mif="\n<Para";
  -		//Is there a block property?
  -
  -		if (pgf != null) {
  -			mif += "\n<Pgf" ;
  -			mif += "\n<PgfTag `Body'>";
  -			mif += "\n<PgfLIndent " + pgf.startIndent/1000f + ">";
  -			mif += "\n<PgfRIndent " + pgf.endIndent/1000f + ">";
  -			mif += "\n>";
  -		}
  -		stream.write(mif.getBytes());
  -		Enumeration e=paraLines.elements();
  -		while (e.hasMoreElements()) {
  -
  -			((ParaLine) e.nextElement()).output(stream);
  -		}
  -		mif="\n> #End ParaLine";
  -		stream.write(mif.getBytes());
  -
  -	}
  -	
  -     }
  -
  -     class ParaLine {
  -	Vector content; 
  -	int textRectID;
  -	String tableID;
  -	String aFrameID;
  -	public ParaLine(int textRectID) {
  -
  -		this.textRectID=textRectID;
  -		this.content=new Vector();
  -
  -	}
  -	public ParaLine () {
  -
  -		this.textRectID=0; // There is no ID used, in tables
  -		this.content=new Vector();
  -	}
  -
  -	public void addContent(Object obj) {
  -
  -		this.content.addElement(obj);
  -
  -	}
  -	public void output(OutputStream stream) throws IOException {
  -	
  -		String mif="\n<ParaLine"; 
  -
  -		// tables dont need the textrectid
  -		if (textRectID != 0) 
  -		 	mif += "\n\t<TextRectID " + textRectID + ">";	
  -
  -		stream.write(mif.getBytes());
  -		Enumeration e = this.content.elements();
  -	        while (e.hasMoreElements()) {
  -
  -			Object elem=(Object) e.nextElement();
  -			if (elem instanceof String) {
  -							
  -				// Output newlines as char hard return
  -				
  -				if (elem == "\n") {
  -
  -					mif ="\n<Char HardReturn>";
  -				}
  -				else {
  -					mif="\n\t<String `" + elem + "'>";
  -				}
  -				stream.write(mif.getBytes()); 
  -				
  -			}
  -			else 
  -			if (elem instanceof Frame) {
  -				
  -				mif="\n\t<AFrame " + ((Frame) elem).getID() + " >";
  -				stream.write(mif.getBytes()); 
  -			}		
  -			else
  -			if (elem instanceof Tbl) {
  -				mif="\n\t<ATbl " + ((Tbl) elem).getID() + " >";
  -				stream.write(mif.getBytes()); 
  -			}	
  -	        }
  -		mif="\n> #End ParaLine";
  -		stream.write(mif.getBytes());
  -	
  -	}
  -     }
  - 
  -     
  -     class PgfCatalog {
  -
  -	Vector pgfs; // Paragraph formats
  -	public PgfCatalog() {}
  -
  -	public void output(OutputStream stream) throws IOException {
  -		String mif="\n<PgfCatalog" + "\n<Pgf" + "\n<PgfTag `Body'>" + "\n>" + "\n>";
  -		stream.write(mif.getBytes());
  -	}
  -
  -     }
  -
  -     class Color {
  -
  -	public Color() {}
  -     }
  -
  -     class ColorCatalog {
  -
  -	public ColorCatalog() {}
  -     }
  -
  -
  -     class Ruling {
  -
  -	int penWidth;
  -	int pen;
  -	int lines;
  -	public Ruling() {
  -	// Default ruling
  -		penWidth=1;
  -		pen=0;
  -		lines=1;
  -	
  -
  -	}
  -
  -	public void output(OutputStream stream) throws IOException {
  -
  -		String mif = "\n<Ruling \n<RulingTag `Default'>";
  -		mif +="\n<RulingPenWidth " + penWidth + ">";
  -		mif +="\n<RulingPen " + pen + ">";
  -		mif +="\n<RulingLines " + lines + ">";
  -		mif +="\n>";
  -		stream.write(mif.getBytes());
  -	}
  -
  -     }
  -
  -     class RulingCatalog {
  -	// Contains multiple rulings
  -
  -	Vector ruling = new Vector();
  -	public RulingCatalog() {
  -	
  -	// Add the defualt ruling to the catalog
  -
  -		ruling.addElement(new Ruling());	
  -
  -	}
  -
  -	public void output(OutputStream stream) throws IOException {
  -
  -		String mif="\n<RulingCatalog";
  -		stream.write(mif.getBytes());
  -		Enumeration e=ruling.elements();	
  -		while (e.hasMoreElements()) {		
  -			((Ruling) e.nextElement()).output(stream);
  -		}
  -		mif="\n> #End RulingCatalog";
  -		stream.write(mif.getBytes());
  -					
  -	}
  -
  -
  -     }
  -
  -          
  -     class TblFormat {
  -
  -	public TblFormat() {}
  -     }
  -
  -     class TblCatalog {
  -
  -	public TblCatalog() {}
  -
  -     }
  -	
  -     class Tbl extends Flow {
  -
  -	class TblColumn {
  -		private int width;
  -		public TblColumn(int width) {
  -
  -			this.width=width;
  -
  -		}
  -		public void output(OutputStream stream) throws IOException {
  -
  -
  -			String mif="\n\t<TblColumnWidth " + width + " >";
  -			stream.write(mif.getBytes());				
  -
  -		}
  -
  -		
  -   	}
  -
  -	class Row {
  -		
  -		class Cell {
  -
  -			private int rowSpan,colSpan;
  -			private Vector paras; // Paras
  -			public Cell(int rowSpan,int colSpan) {
  -
  -				this.rowSpan=rowSpan;
  -				this.colSpan=colSpan;
  -				paras=new Vector();
  -
  -			}
  -			public void startPara() {
  -
  -				this.paras.addElement(new Para());
  -			}
  -			public void output(OutputStream stream) throws IOException {
  -
  -				String mif="\n\t\t<Cell" + "\n\t\t<CellContent";
  -				stream.write(mif.getBytes());	
  -				Enumeration e=paras.elements();	
  -				while (e.hasMoreElements()) {		
  -					((Para) e.nextElement()).output(stream);
  -				}			
  -				mif="\n\t\t> #End CellContent";
  -				mif +="\n\t> #End Cell";
  -				stream.write(mif.getBytes());			
  -			}
  -
  -		}	
  -		private Vector cells; 
  -
  -		public void addCell(int rowSpan, int colSpan) {
  -
  -			cells.addElement(new Cell(rowSpan,colSpan));
  -		}
  -
  -		public Row() {
  -
  -			cells=new Vector();
  -	
  -		}
  -		public Cell curCell() {
  -
  -			return (Cell) this.cells.lastElement();
  -		}
  -
  -		public void output(OutputStream stream) throws IOException {
  -
  -			String mif="\n\t<Row";
  -			stream.write(mif.getBytes());
  -			Enumeration e=cells.elements();	
  -			while (e.hasMoreElements()) {		
  -				((Cell) e.nextElement()).output(stream);
  -			}			
  -			mif="\n\t> #End Row";
  -			stream.write(mif.getBytes());			
  -
  -		}
  -
  -
  -     	}
  -
  -	private int ID;
  -	private Vector tblColumns=new Vector();
  -	private Vector tblBody,tblHead,tblFoot;
  -	private Vector current; // is a reference to one of tblHead,tblBody or tblFoot
  -	public void addColumn(int colWidth) {
  -
  -		tblColumns.addElement(new TblColumn(colWidth));
  -
  -	}
  -	public void setCurrent(String current) {
  -
  -		if (current == "fo:table-body") {
  -			this.current=this.tblBody;
  -		}
  -		else
  -		if (current == "tablehead") {
  -			this.current=this.tblHead;
  -		}
  -		else
  -		if (current == "tablefoot") {
  -			this.current=this.tblFoot;
  -		}
  -	}
  -	public void startRow() {
  -
  -		this.current.addElement(new Row());
  -	}
  -
  -	public void startCell(int rowSpan,int colSpan) {
  -
  -		//Add a cell into the current row
  -
  -		((Row) this.current.lastElement()).addCell(rowSpan,colSpan);
  -
  -	}
  -
  -	public Tbl() {
  -
  -		this.ID=curIDCounter.getnewID();
  -		tblBody=new Vector();
  -		tblHead=new Vector();
  -		tblFoot=new Vector();
  -
  -	}
  -
  -	public int getID() {
  -
  -		return this.ID;
  -	}	
  -	public Para curPara() {
  -
  -		// Return the last para of the current cell
  -
  -		Row curRow;
  -		curRow= (Row) this.current.lastElement();
  -		return (Para) curRow.curCell().paras.lastElement();
  -
  -
  -	}
  -	public void startPara() {
  -
  -		// start a new para in the current cell
  -		Row curRow;
  -		curRow= (Row) this.current.lastElement();
  -		curRow.curCell().startPara();
  -
  -	}
  -
  -
  -	public void output(OutputStream stream) throws IOException {
  -
  -		String mif="\n<Tbl" + "\n\t<TblID " + ID + " >";
  -
  -		// note tbl format to be added in a later release
  -		mif += "\n<TblTag Body>" + "\n<TblFormat";
  -		mif +="\n<TblColumnRuling `Default'>";
  -		mif +="\n<TblBodyRowRuling `Default'>";
  -		mif +="\n<TblLRuling `Default'>";
  -		mif +="\n<TblBRuling `Default'>";
  -		mif +="\n<TblRRuling `Default'>";
  -		mif +="\n<TblTRuling `Default'>";
  -
  -		mif += "\n> #End TblFormat";
  - ;
  -		mif +="\n\t<TblNumColumns " + tblColumns.size() + " >";				
  -		stream.write(mif.getBytes());
  -		
  -		if (! tblHead.isEmpty()) {
  -			Enumeration e=tblHead.elements();	
  -			while (e.hasMoreElements()) {		
  -				((Row) e.nextElement()).output(stream);
  -			}
  -		}
  -		if (! tblFoot.isEmpty()) {
  -			Enumeration e=tblFoot.elements();	
  -			while (e.hasMoreElements()) {		
  -				((Row) e.nextElement()).output(stream);
  -			}
  -		}
  -		if (! tblBody.isEmpty()) {
  -			mif="\n\t<TblBody";
  -			stream.write(mif.getBytes());
  -			Enumeration e=tblBody.elements();	
  -			while (e.hasMoreElements()) {		
  -				((Row) e.nextElement()).output(stream);
  -			}
  -			mif="\n\t> #End tblBody";
  -		}
  -		mif +="\n> #End Table";
  -		stream.write(mif.getBytes());	
  -	}
  -
  -     }
  -
  -     class XRefFormat {
  -
  -	public XRefFormat() {}
  -     }
  -
  -     class CrossRefInfo {
  -
  -	public CrossRefInfo() {}
  -     }
  -
  -     class XRef {
  -
  -	public XRef() {}
  -     }
  -
  -     class Marker {
  -
  -	public Marker() {}
  -
  -     }
  -
  -     class BookComponent {
  -
  -	Document document;
  -	ColorCatalog colorCatalog;
  -	RulingCatalog rulingCatalog;
  -	PgfCatalog pgfCatalog;
  -	TblCatalog tblCatalog;
  -	Vector aFrames =  new Vector();
  -        Vector tables =  new Vector();
  -	Vector pages =  new Vector();
  -	Vector textFlows =  new Vector();	
  -	
  -	
  -	public BookComponent() {
  -	
  -		document=null; // Initially no values are available    
  -		pgfCatalog = new PgfCatalog();
  -		rulingCatalog=new RulingCatalog();
  -	}
  -
  -
  -	public Frame createFrame(int x, int y,int w,int h) {
  -
  -		Frame frame=new Frame(x,y,w,h);
  -		aFrames.addElement(frame);	
  -		return frame;
  -		
  -	}
  -
  -	public Frame curFrame() {
  -
  -		return (Frame) aFrames.lastElement();
  -
  -	}
  -
  -	public TextFlow curTextFlow() {
  -
  -		return (TextFlow) textFlows.lastElement();
  -
  -	}
  -
  -	public Tbl createTable() {
  -
  -		Tbl table=new Tbl();
  -		tables.addElement(table);
  -		return table;
  -	}
  -	public Tbl curTable() {
  -		
  -		return (Tbl) tables.lastElement();
  -	}
  -
  -	public void output(OutputStream stream) throws IOException {
  -	    String mif="<MIFFile 5.00>" + "\n<Units Upt>"	;		
  -	    stream.write(mif.getBytes());
  -	    pgfCatalog.output(stream);	
  -	    rulingCatalog.output(stream);	
  -	    document.output(stream);	
  -
  -	    if (! aFrames.isEmpty()) {
  -
  -		mif="\n<AFrames";
  -		stream.write(mif.getBytes());
  -		Enumeration e=aFrames.elements();	
  -		while (e.hasMoreElements()) {		
  -
  -			((Frame) e.nextElement()).output(stream);
  -		}
  -		
  -	        mif="\n>";
  -	        stream.write(mif.getBytes());
  -	    }
  -
  -	    if (! tables.isEmpty()) {
  -
  -		mif="\n<Tbls";
  -		stream.write(mif.getBytes());
  -		Enumeration e=tables.elements();	
  -		while (e.hasMoreElements()) {		
  -
  -			((Tbl) e.nextElement()).output(stream);
  -		}
  -		
  -	        mif="\n>";
  -	        stream.write(mif.getBytes());
  -	    }
  -	
  -    
  -	    Enumeration e = pages.elements();
  -	    while (e.hasMoreElements()) {
  -
  -		((Page) e.nextElement()).output(stream);
  -	    }
  -
  -	    e=textFlows.elements();
  -    	    while (e.hasMoreElements()) {
  -
  -		((TextFlow) e.nextElement()).output(stream);
  -
  -	    }
  -	
  -		    		
  -	}
  -
  -
  -	private Page curPage() {
  -
  -	    return (Page) pages.lastElement();			
  -
  -	}
  -
  -
  -
  -     }
  -
  -     class ElementSet {
  -
  -	public ElementSet() {}
  -
  -     }
  -
  -     	    
  -    /**
  -     * creates an empty MIF document
  -     */
  -    public MIFDocument() {
  -		
  -	bookComponent = new BookComponent();
  -      
  -    }
  -	
  -    public void createPage () {
  -
  -	bookComponent.pages.addElement(new Page());
  -	
  -    }
  -
  -    
  -    public void addToStream(String s) {
  -
  -	//Add this string to the curent flow
  -	
  -	Para para= curFlow.curPara();
  -	ParaLine paraLine= para.curParaLine();
  -	paraLine.addContent(s);
  -
  -    }
  -
  -
  -	
  -
  -    public void output(OutputStream stream) throws IOException {
  -
  -
  -	//Output the contents of bookComponent
  -
  -	this.bookComponent.output(stream);
  -
  -   }
  -
  -
  -    public void setDocumentHeightWidth (int height, int width) {
  -
  -	if (bookComponent.document == null) {
  -
  -		bookComponent.document=new Document();
  -		bookComponent.document.height=height;
  -		bookComponent.document.width=width;
  -  	}
  -
  -	else if(bookComponent.document.height != height || bookComponent.document.width != width) 	{
  -
  -		MessageHandler.logln("Warning : FrameMaker doesnt support different page-sizes 		in a document");		
  -	}
  -
  -   }
  -
  -
  -
  -   public void createTextRect(int numCols) {
  -	
  -	
  -	//Create a textrect on the bodypage with these dimensions
  -	//This default behaviour will later be changed to reflect on 
  -	//the master-page
  -
  -	
  -	(bookComponent.curPage()).addTextRect(numCols);	
  -
  -
  -	// Then create a textflow corresponding to this textrect
  -
  -	curFlow=new TextFlow();
  -	bookComponent.textFlows.addElement(curFlow);
  -
  -   }
  -
  -
  -   public void setTextRectProp(int left,int top, int width,int height) {
  -	
  -	
  -	(bookComponent.curPage()).curTextRect().setTextRectProp(left,top,width,height);
  -
  -   
  -   } 
  -
  -
  -    public void startLine() {
  -
  -				
  -	if (curFlow.curPara().curParaLine() != null) {
  -		this.addToStream("\n");
  -		curFlow.curPara().startParaLine();
  -	}
  -	else 
  -		curFlow.curPara().startParaLine();
  -				
  -	
  -  }
  -		
  -
  -  public void setBlockProp(int startIndent,int endIndent) {
  -
  -	
  -	curFlow.startPara(); //Start a para
  -	curFlow.curPara().setBlockProp(startIndent,endIndent);
  -	
  -  }
  -
  -  public void createFrame(int x, int y, int w, int h) {
  -
  -	//Create a new anchored frame 
  -
  -	bookComponent.createFrame(x,y,w,h);	
  -
  -  }
  -
  -
  -
  -  public void addImage(String url,int x,int y,int w,int h) {
  -
  -	Frame frame=bookComponent.createFrame(x,y,w,h);
  -	ImportObject imageObject=new ImportObject(url,0,0,w,h);
  -	frame.addContent(imageObject);
  -	if (curFlow.curPara().curParaLine() == null) {
  -		curFlow.curPara().startParaLine();
  -		
  -	}
  -	curFlow.curPara().curParaLine().addContent(frame);
  -			
  -		
  -  }
  -
  -  public void createTable() {
  -
  -	// First create a table with an ID, then add it to the textflow
  -
  -	Tbl table=bookComponent.createTable();
  -	if (curFlow.curPara().curParaLine() == null) {
  -		curFlow.curPara().startParaLine();
  -		
  -	}
  -	curFlow.curPara().curParaLine().addContent(table);
  -
  -	/* The above would have added the table to the textflow
  -	   But now the flow goes into the table, so ... */
  -
  -	curFlow=table;
  -
  -  }
  -
  -  public void setColumnProp(int colWidth) {
  -
  -
  -	//Get the current table
  -
  -	Tbl table=bookComponent.curTable();
  -	table.addColumn(colWidth);
  -
  -
  -  } 
  -
  -  public void setCurrent(String current) {
  -
  -	//Start the table body or header or footer
  -	Tbl table=bookComponent.curTable();
  -	table.setCurrent(current);
  -
  -  }
  -
  -  public void startRow() {
  -
  -	Tbl table=bookComponent.curTable();
  -	table.startRow();	
  -
  -
  -  }
  -
  -  public void startCell(int rowSpan,int colSpan) {
  -	
  -	Tbl table=bookComponent.curTable();
  -	table.startCell(rowSpan,colSpan);
  -
  -  }
  -
  -  public void endTable() {
  -
  -	// Switch the ref back to the current textflow
  -
  -	curFlow=bookComponent.curTextFlow();
  -
  -  }
  -
  -
  -     
  - }    
  +/* $Id: MIFDocument.java,v 1.2 2001/07/04 12:41:01 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.
  + */
  +
  +//Author : Seshadri G
  +
  +package org.apache.fop.mif;
  +
  +// images are the one place that FOP classes outside this package get
  +// referenced and I'd rather not do it
  +
  +import org.apache.fop.image.FopImage;
  +import org.apache.fop.messaging.MessageHandler;
  +import org.apache.fop.layout.LinkSet;
  +import org.apache.fop.datatypes.ColorSpace;
  +
  +import org.apache.fop.datatypes.IDReferences;
  +import org.apache.fop.layout.Page;
  +import org.apache.fop.layout.FontMetric;
  +import org.apache.fop.layout.FontDescriptor;
  +// Java
  +import java.io.*;
  +import java.io.PrintWriter;
  +import java.util.*;
  +import java.awt.Rectangle;
  +
  +/**
  + * class representing a MIF document.
  + *
  + * The document is built up by calling various methods and then finally
  + * output to given filehandle using output method.
  + *
  + */
  +public class MIFDocument {
  +
  +    /** the version of MIF supported */
  +
  +
  +    protected static final String mifVersion = "5.5";
  +    protected BookComponent bookComponent;
  +    private Flow curFlow; // this is a ref to the current flow which could be a textflow or
  +    // a table
  +    private ID curIDCounter = new ID();
  +
  +    class ID {
  +
  +        private int idCounter = 1;
  +        public int getnewID() {
  +
  +            return idCounter++;
  +        }
  +
  +    }
  +
  +    class FontFormat {
  +
  +        public FontFormat() { }
  +
  +    }
  +
  +    class ParagraphFormat extends FontFormat {
  +
  +        public ParagraphFormat() {}
  +        int startIndent;
  +        int endIndent;
  +
  +
  +
  +    }
  +
  +    class Document {
  +        protected int height;
  +        protected int width;
  +        public Document() {}
  +
  +        public void output(OutputStream stream) throws IOException {
  +
  +            String mif = "\n<Document " + "\n<DPageSize " + width / 1000f +
  +                         " " + height / 1000f + " >\n>";
  +            byte buf[] = mif.getBytes();
  +
  +            stream.write(buf);
  +
  +        }
  +
  +    }
  +
  +
  +    class PolyLine {
  +
  +        public PolyLine() {}
  +    }
  +
  +    class ImportObject {
  +
  +        private String url;
  +        private int x, y, w, h;
  +
  +        public ImportObject(String url, int x, int y, int w, int h) {
  +
  +            this.url = url;
  +            this.x = x;
  +            this.y = y;
  +            this.w = w;
  +            this.h = h;
  +
  +        }
  +
  +
  +        public void output(OutputStream stream) throws IOException {
  +
  +
  +            String path = this.url;
  +
  +            //Strip 'file:'
  +            path = path.substring(5);
  +            String result = "";
  +            int i;
  +            do { // replace all matching '/'
  +
  +                i = path.indexOf("/");
  +                if (i != -1) {
  +                    result = path.substring(0, i);
  +                    result += "<c\\>";
  +                    result += path.substring(i + 1);
  +                    path = result;
  +                }
  +
  +            } while (i != -1)
  +                ;
  +
  +            String mif = "\n<ImportObject" + "\n<ImportObFixedSize Yes>";
  +            mif += "\n\t<ImportObFileDI " + "`<c\\>" + path + "'" + " >";
  +            mif += "\n\t<ShapeRect " + this.x / 1000f + " " +
  +                   this.y / 1000f + " " + this.w / 1000f + " " +
  +                   this.h / 1000f + " >";
  +
  +            mif += "\n> #End ImportObj";
  +            stream.write(mif.getBytes());
  +
  +        }
  +
  +    }
  +
  +
  +    class Frame {
  +
  +        private int ID;
  +        private int x, y, w, h;
  +        Vector content = new Vector();
  +        public Frame(int x, int y, int w, int h) {
  +
  +            this.ID = curIDCounter.getnewID();
  +            this.x = x;
  +            this.y = y;
  +            this.w = w;
  +            this.h = h;
  +
  +        }
  +
  +        public void addContent(ImportObject obj) {
  +
  +            content.addElement(obj);
  +
  +        }
  +
  +        public void output(OutputStream stream) throws IOException {
  +
  +            String mif = "\n<Frame" + "\n\t<ID " + this.ID + " >";
  +            mif += "\n\t<Pen 15>\n\t<Fill 7>\n\t<PenWidth  1.0 >\n\t<Separation 0>\n\t<ObColor `Black'>\n\t<DashedPattern \n\t <DashedStyle Solid> \n >";
  +
  +            mif += "\n\t<RunaroundGap  6.0 pt>\n\t<RunaroundType None>\n\t<Angle  360.0>\n\t<Float No>\n\t<NSOffset  0.0>\n\t<BLOffset  0>\n\t<Cropped No>\n\t<FrameType Below>\n\t<AnchorAlign Center>";
  +
  +            mif += "\n\t<ShapeRect " + this.x / 1000f + " " +
  +                   this.y / 1000f + " " + this.w / 1000f + " " +
  +                   this.h / 1000f + " >";
  +
  +
  +            stream.write(mif.getBytes());
  +
  +            Enumeration e = content.elements();
  +            while (e.hasMoreElements()) {
  +
  +                ((ImportObject) e.nextElement()).output(stream);
  +            }
  +            mif = "\n> #End Frame";
  +            stream.write(mif.getBytes());
  +
  +
  +
  +        }
  +        public int getID() {
  +
  +            return this.ID;
  +        }
  +
  +    }
  +
  +    class TextRect {
  +        private int rx, ry, w, h;
  +        private int numCols;
  +        private int curCol = 0; //Current column being processed
  +        private int colGap = 0;
  +        private int textRectID;
  +        public TextRect(int numCols) {
  +
  +            this.numCols = numCols;
  +            this.curCol = 0;
  +            this.textRectID = curIDCounter.getnewID();
  +
  +        }
  +
  +
  +        public int getTextRectID() {
  +
  +            return textRectID;
  +
  +        }
  +
  +
  +        public void setTextRectProp(int left, int top, int width,
  +                                    int height) {
  +
  +            if (curCol == 0) {
  +
  +                //Use the left and top margins
  +
  +                rx = left;
  +                ry = top;
  +                w = width; // current column width , not the entire span
  +                h = height;
  +                curCol++;
  +
  +            } else if (curCol == 1) {
  +                // Figure out the column gap and the span of the textrect
  +                colGap = left - rx - width;
  +                // Next the entire width
  +                w = numCols * width + (numCols - 1) * colGap;
  +                curCol++;
  +
  +
  +            }
  +
  +        }
  +
  +
  +        public void output(OutputStream stream) throws IOException {
  +
  +            String mif = "\n<TextRect" + "\n\t<ID " + textRectID + ">" +
  +                         "\n\t<ShapeRect " + rx / 1000f + " " +
  +                         ry / 1000f + " " + w / 1000f + " " + h / 1000f + ">" ;
  +
  +            if (numCols > 1) {
  +                mif += "\n<TRNumColumns " + numCols + ">";
  +                mif += "\n<TRColumnGap " + colGap / 1000f + ">";
  +            }
  +
  +            mif += "\n> #End TextRect" ;
  +            byte buf[] = mif.getBytes();
  +            stream.write(buf);
  +        }
  +
  +    }
  +
  +    class Page {
  +        private String pageType;
  +        private String pageTag;
  +        private String pageBackground;
  +        private Vector textRects;
  +        public Page(String pageType, String pageTag,
  +                    String pageBackground) {
  +
  +            this.pageType = pageType;
  +            this.pageTag = pageTag;
  +            this.pageBackground = pageBackground;
  +            this.textRects = new Vector();
  +        }
  +
  +        public Page() {
  +
  +            this.pageType = "BodyPage";
  +            this.pageBackground = "Default";
  +            this.textRects = new Vector();
  +
  +        }
  +
  +
  +        public void addTextRect(int numCols) {
  +
  +            TextRect textRect = new TextRect(numCols);
  +            this.textRects.addElement(textRect);
  +        }
  +
  +        public TextRect curTextRect() {
  +
  +            return (TextRect) textRects.lastElement();
  +
  +        }
  +
  +
  +
  +        public void output(OutputStream stream) throws IOException {
  +
  +
  +            String mif = "\n<Page" + "\n\t<PageType " + pageType + ">" +
  +                         "\n\t<PageBackground " + "`" + pageBackground +
  +                         "'" + ">";
  +
  +            byte buf[] = mif.getBytes();
  +
  +            stream.write(buf);
  +
  +            Enumeration e = textRects.elements();
  +
  +            while (e.hasMoreElements()) {
  +
  +                ((TextRect) e.nextElement()).output(stream);
  +
  +            }
  +            mif = "\n>  #End Page\n";
  +            stream.write(mif.getBytes());
  +
  +        }
  +
  +
  +    }
  +
  +    abstract class Flow {
  +
  +        public Flow() {}
  +        public abstract Para curPara();
  +        public abstract void startPara();
  +    }
  +
  +
  +    class TextFlow extends Flow {
  +
  +        Vector paras;
  +        private int ID; // This ID is used within ParaLine, however it is
  +        // logical to keep it unique	to a textflow
  +
  +        public TextFlow() {
  +
  +
  +            //The current textrect into which the textflow goes
  +            //is the last created.
  +
  +            this.ID = ((bookComponent.curPage()).curTextRect()).
  +                      getTextRectID();
  +            this.paras = new Vector();
  +
  +        }
  +
  +
  +        public int getTextRectID() {
  +
  +            return ID;
  +
  +        }
  +
  +        public Para curPara() {
  +
  +            return (Para) paras.lastElement();
  +        }
  +
  +        public void startPara() {
  +
  +            this.paras.addElement(new Para(ID));
  +        }
  +
  +        public void output(OutputStream stream) throws IOException {
  +            String mif = "\n<TextFlow";
  +            stream.write(mif.getBytes());
  +            Enumeration e = paras.elements();
  +            while (e.hasMoreElements()) {
  +
  +                ((Para) e.nextElement()).output(stream);
  +            }
  +            mif = "\n> #End TextFlow";
  +            stream.write(mif.getBytes());
  +        }
  +
  +    }
  +
  +
  +    class Para {
  +
  +        Vector paraLines;
  +        int ID; // Same as TextRectID
  +        ParagraphFormat pgf = null; // This corresponds to to the block properties
  +        public Para() {
  +
  +            this.ID = 0;
  +            this.paraLines = new Vector();
  +        }
  +
  +
  +        public Para(int ID) {
  +
  +            this.ID = ID;
  +            this.paraLines = new Vector();
  +
  +        }
  +
  +        public ParaLine curParaLine() {
  +            if (paraLines.isEmpty()) {
  +                return null;
  +            } else {
  +                return (ParaLine) paraLines.lastElement();
  +            }
  +        }
  +
  +        void startParaLine() {
  +
  +            this.paraLines.addElement(new ParaLine(ID));
  +
  +        }
  +
  +
  +        public void setBlockProp(int startIndent, int endIndent) {
  +
  +            pgf = new ParagraphFormat();
  +            pgf.startIndent = startIndent;
  +            pgf.endIndent = endIndent;
  +
  +
  +        }
  +
  +
  +        public void output(OutputStream stream) throws IOException {
  +
  +            String mif = "\n<Para";
  +            //Is there a block property?
  +
  +            if (pgf != null) {
  +                mif += "\n<Pgf" ;
  +                mif += "\n<PgfTag `Body'>";
  +                mif += "\n<PgfLIndent " + pgf.startIndent / 1000f + ">";
  +                mif += "\n<PgfRIndent " + pgf.endIndent / 1000f + ">";
  +                mif += "\n>";
  +            }
  +            stream.write(mif.getBytes());
  +            Enumeration e = paraLines.elements();
  +            while (e.hasMoreElements()) {
  +
  +                ((ParaLine) e.nextElement()).output(stream);
  +            }
  +            mif = "\n> #End ParaLine";
  +            stream.write(mif.getBytes());
  +
  +        }
  +
  +    }
  +
  +    class ParaLine {
  +        Vector content;
  +        int textRectID;
  +        String tableID;
  +        String aFrameID;
  +        public ParaLine(int textRectID) {
  +
  +            this.textRectID = textRectID;
  +            this.content = new Vector();
  +
  +        }
  +        public ParaLine () {
  +
  +            this.textRectID = 0; // There is no ID used, in tables
  +            this.content = new Vector();
  +        }
  +
  +        public void addContent(Object obj) {
  +
  +            this.content.addElement(obj);
  +
  +        }
  +        public void output(OutputStream stream) throws IOException {
  +
  +            String mif = "\n<ParaLine";
  +
  +            // tables dont need the textrectid
  +            if (textRectID != 0)
  +                mif += "\n\t<TextRectID " + textRectID + ">";
  +
  +            stream.write(mif.getBytes());
  +            Enumeration e = this.content.elements();
  +            while (e.hasMoreElements()) {
  +
  +                Object elem = (Object) e.nextElement();
  +                if (elem instanceof String) {
  +
  +                    // Output newlines as char hard return
  +
  +                    if (elem == "\n") {
  +
  +                        mif = "\n<Char HardReturn>";
  +                    } else {
  +                        mif = "\n\t<String `" + elem + "'>";
  +                    }
  +                    stream.write(mif.getBytes());
  +
  +                } else if (elem instanceof Frame) {
  +
  +                    mif = "\n\t<AFrame " + ((Frame) elem).getID() + " >";
  +                    stream.write(mif.getBytes());
  +                } else if (elem instanceof Tbl) {
  +                    mif = "\n\t<ATbl " + ((Tbl) elem).getID() + " >";
  +                    stream.write(mif.getBytes());
  +                }
  +            }
  +            mif = "\n> #End ParaLine";
  +            stream.write(mif.getBytes());
  +
  +        }
  +    }
  +
  +    class PgfCatalog {
  +
  +        Vector pgfs; // Paragraph formats
  +        public PgfCatalog() {}
  +
  +        public void output(OutputStream stream) throws IOException {
  +            String mif = "\n<PgfCatalog" + "\n<Pgf" + "\n<PgfTag `Body'>" +
  +                         "\n>" + "\n>";
  +            stream.write(mif.getBytes());
  +        }
  +
  +    }
  +
  +    class Color {
  +
  +        public Color() {}
  +    }
  +
  +    class ColorCatalog {
  +
  +        public ColorCatalog() {}
  +    }
  +
  +    class Ruling {
  +
  +        int penWidth;
  +        int pen;
  +        int lines;
  +        public Ruling() {
  +            // Default ruling
  +            penWidth = 1;
  +            pen = 0;
  +            lines = 1;
  +
  +
  +        }
  +
  +        public void output(OutputStream stream) throws IOException {
  +
  +            String mif = "\n<Ruling \n<RulingTag `Default'>";
  +            mif += "\n<RulingPenWidth " + penWidth + ">";
  +            mif += "\n<RulingPen " + pen + ">";
  +            mif += "\n<RulingLines " + lines + ">";
  +            mif += "\n>";
  +            stream.write(mif.getBytes());
  +        }
  +
  +    }
  +
  +    class RulingCatalog {
  +        // Contains multiple rulings
  +
  +        Vector ruling = new Vector();
  +        public RulingCatalog() {
  +
  +            // Add the defualt ruling to the catalog
  +
  +            ruling.addElement(new Ruling());
  +
  +        }
  +
  +        public void output(OutputStream stream) throws IOException {
  +
  +            String mif = "\n<RulingCatalog";
  +            stream.write(mif.getBytes());
  +            Enumeration e = ruling.elements();
  +            while (e.hasMoreElements()) {
  +                ((Ruling) e.nextElement()).output(stream);
  +            }
  +            mif = "\n> #End RulingCatalog";
  +            stream.write(mif.getBytes());
  +
  +        }
  +
  +    }
  +
  +    class TblFormat {
  +        public TblFormat() {}
  +    }
  +
  +    class TblCatalog {
  +        public TblCatalog() {}
  +
  +    }
  +
  +    class Tbl extends Flow {
  +
  +        class TblColumn {
  +            private int width;
  +            public TblColumn(int width) {
  +
  +                this.width = width;
  +
  +            }
  +            public void output(OutputStream stream) throws IOException {
  +
  +                String mif = "\n\t<TblColumnWidth " + width + " >";
  +                stream.write(mif.getBytes());
  +
  +            }
  +
  +
  +        }
  +
  +        class Row {
  +
  +            class Cell {
  +
  +                private int rowSpan, colSpan;
  +                private Vector paras; // Paras
  +                public Cell(int rowSpan, int colSpan) {
  +
  +                    this.rowSpan = rowSpan;
  +                    this.colSpan = colSpan;
  +                    paras = new Vector();
  +
  +                }
  +                public void startPara() {
  +
  +                    this.paras.addElement(new Para());
  +                }
  +                public void output(OutputStream stream) throws IOException {
  +
  +                    String mif = "\n\t\t<Cell" + "\n\t\t<CellContent";
  +                    stream.write(mif.getBytes());
  +                    Enumeration e = paras.elements();
  +                    while (e.hasMoreElements()) {
  +                        ((Para) e.nextElement()).output(stream);
  +                    }
  +                    mif = "\n\t\t> #End CellContent";
  +                    mif += "\n\t> #End Cell";
  +                    stream.write(mif.getBytes());
  +                }
  +
  +            }
  +            private Vector cells;
  +
  +            public void addCell(int rowSpan, int colSpan) {
  +
  +                cells.addElement(new Cell(rowSpan, colSpan));
  +            }
  +
  +            public Row() {
  +
  +                cells = new Vector();
  +
  +            }
  +            public Cell curCell() {
  +
  +                return (Cell) this.cells.lastElement();
  +            }
  +
  +            public void output(OutputStream stream) throws IOException {
  +
  +                String mif = "\n\t<Row";
  +                stream.write(mif.getBytes());
  +                Enumeration e = cells.elements();
  +                while (e.hasMoreElements()) {
  +                    ((Cell) e.nextElement()).output(stream);
  +                }
  +                mif = "\n\t> #End Row";
  +                stream.write(mif.getBytes());
  +
  +            }
  +
  +
  +        }
  +
  +        private int ID;
  +        private Vector tblColumns = new Vector();
  +        private Vector tblBody, tblHead, tblFoot;
  +        private Vector current; // is a reference to one of tblHead,tblBody or tblFoot
  +        public void addColumn(int colWidth) {
  +
  +            tblColumns.addElement(new TblColumn(colWidth));
  +
  +        }
  +
  +        public void setCurrent(String current) {
  +
  +            if (current == "fo:table-body") {
  +                this.current = this.tblBody;
  +            } else if (current == "tablehead") {
  +                this.current = this.tblHead;
  +            } else if (current == "tablefoot") {
  +                this.current = this.tblFoot;
  +            }
  +        }
  +
  +        public void startRow() {
  +
  +            this.current.addElement(new Row());
  +        }
  +
  +        public void startCell(int rowSpan, int colSpan) {
  +
  +            //Add a cell into the current row
  +
  +            ((Row) this.current.lastElement()).addCell(rowSpan, colSpan);
  +
  +        }
  +
  +        public Tbl() {
  +
  +            this.ID = curIDCounter.getnewID();
  +            tblBody = new Vector();
  +            tblHead = new Vector();
  +            tblFoot = new Vector();
  +
  +        }
  +
  +        public int getID() {
  +
  +            return this.ID;
  +        }
  +
  +        public Para curPara() {
  +
  +            // Return the last para of the current cell
  +
  +            Row curRow;
  +            curRow = (Row) this.current.lastElement();
  +            return (Para) curRow.curCell().paras.lastElement();
  +
  +
  +        }
  +        public void startPara() {
  +
  +            // start a new para in the current cell
  +            Row curRow;
  +            curRow = (Row) this.current.lastElement();
  +            curRow.curCell().startPara();
  +
  +        }
  +
  +        public void output(OutputStream stream) throws IOException {
  +
  +            String mif = "\n<Tbl" + "\n\t<TblID " + ID + " >";
  +
  +            // note tbl format to be added in a later release
  +            mif += "\n<TblTag Body>" + "\n<TblFormat";
  +            mif += "\n<TblColumnRuling `Default'>";
  +            mif += "\n<TblBodyRowRuling `Default'>";
  +            mif += "\n<TblLRuling `Default'>";
  +            mif += "\n<TblBRuling `Default'>";
  +            mif += "\n<TblRRuling `Default'>";
  +            mif += "\n<TblTRuling `Default'>";
  +
  +            mif += "\n> #End TblFormat";
  +            ;
  +            mif += "\n\t<TblNumColumns " + tblColumns.size() + " >";
  +            stream.write(mif.getBytes());
  +
  +            if (! tblHead.isEmpty()) {
  +                Enumeration e = tblHead.elements();
  +                while (e.hasMoreElements()) {
  +                    ((Row) e.nextElement()).output(stream);
  +                }
  +            }
  +            if (! tblFoot.isEmpty()) {
  +                Enumeration e = tblFoot.elements();
  +                while (e.hasMoreElements()) {
  +                    ((Row) e.nextElement()).output(stream);
  +                }
  +            }
  +            if (! tblBody.isEmpty()) {
  +                mif = "\n\t<TblBody";
  +                stream.write(mif.getBytes());
  +                Enumeration e = tblBody.elements();
  +                while (e.hasMoreElements()) {
  +                    ((Row) e.nextElement()).output(stream);
  +                }
  +                mif = "\n\t> #End tblBody";
  +            }
  +            mif += "\n> #End Table";
  +            stream.write(mif.getBytes());
  +        }
  +
  +    }
  +
  +    class XRefFormat {
  +
  +        public XRefFormat() {}
  +    }
  +
  +    class CrossRefInfo {
  +
  +        public CrossRefInfo() {}
  +    }
  +
  +    class XRef {
  +
  +        public XRef() {}
  +    }
  +
  +    class Marker {
  +
  +        public Marker() {}
  +
  +    }
  +
  +    class BookComponent {
  +
  +        Document document;
  +        ColorCatalog colorCatalog;
  +        RulingCatalog rulingCatalog;
  +        PgfCatalog pgfCatalog;
  +        TblCatalog tblCatalog;
  +        Vector aFrames = new Vector();
  +        Vector tables = new Vector();
  +        Vector pages = new Vector();
  +        Vector textFlows = new Vector();
  +
  +
  +        public BookComponent() {
  +
  +            document = null; // Initially no values are available
  +            pgfCatalog = new PgfCatalog();
  +            rulingCatalog = new RulingCatalog();
  +        }
  +
  +
  +        public Frame createFrame(int x, int y, int w, int h) {
  +
  +            Frame frame = new Frame(x, y, w, h);
  +            aFrames.addElement(frame);
  +            return frame;
  +
  +        }
  +
  +        public Frame curFrame() {
  +
  +            return (Frame) aFrames.lastElement();
  +
  +        }
  +
  +        public TextFlow curTextFlow() {
  +
  +            return (TextFlow) textFlows.lastElement();
  +
  +        }
  +
  +        public Tbl createTable() {
  +
  +            Tbl table = new Tbl();
  +            tables.addElement(table);
  +            return table;
  +        }
  +        public Tbl curTable() {
  +
  +            return (Tbl) tables.lastElement();
  +        }
  +
  +        public void output(OutputStream stream) throws IOException {
  +            String mif = "<MIFFile 5.00>" + "\n<Units Upt>" ;
  +            stream.write(mif.getBytes());
  +            pgfCatalog.output(stream);
  +            rulingCatalog.output(stream);
  +            document.output(stream);
  +
  +            if (! aFrames.isEmpty()) {
  +
  +                mif = "\n<AFrames";
  +                stream.write(mif.getBytes());
  +                Enumeration e = aFrames.elements();
  +                while (e.hasMoreElements()) {
  +
  +                    ((Frame) e.nextElement()).output(stream);
  +                }
  +
  +                mif = "\n>";
  +                stream.write(mif.getBytes());
  +            }
  +
  +            if (! tables.isEmpty()) {
  +
  +                mif = "\n<Tbls";
  +                stream.write(mif.getBytes());
  +                Enumeration e = tables.elements();
  +                while (e.hasMoreElements()) {
  +
  +                    ((Tbl) e.nextElement()).output(stream);
  +                }
  +
  +                mif = "\n>";
  +                stream.write(mif.getBytes());
  +            }
  +
  +
  +            Enumeration e = pages.elements();
  +            while (e.hasMoreElements()) {
  +
  +                ((Page) e.nextElement()).output(stream);
  +            }
  +
  +            e = textFlows.elements();
  +            while (e.hasMoreElements()) {
  +
  +                ((TextFlow) e.nextElement()).output(stream);
  +
  +            }
  +        }
  +
  +        private Page curPage() {
  +            return (Page) pages.lastElement();
  +        }
  +    }
  +
  +    class ElementSet {
  +        public ElementSet() {}
  +
  +    }
  +
  +    /**
  +     * creates an empty MIF document
  +     */
  +    public MIFDocument() {
  +
  +        bookComponent = new BookComponent();
  +
  +    }
  +
  +    public void createPage () {
  +
  +        bookComponent.pages.addElement(new Page());
  +
  +    }
  +
  +    public void addToStream(String s) {
  +
  +        //Add this string to the curent flow
  +
  +        Para para = curFlow.curPara();
  +        ParaLine paraLine = para.curParaLine();
  +        paraLine.addContent(s);
  +
  +    }
  +
  +    public void output(OutputStream stream) throws IOException {
  +        //Output the contents of bookComponent
  +
  +        this.bookComponent.output(stream);
  +
  +    }
  +
  +    public void setDocumentHeightWidth (int height, int width) {
  +
  +        if (bookComponent.document == null) {
  +
  +            bookComponent.document = new Document();
  +            bookComponent.document.height = height;
  +            bookComponent.document.width = width;
  +        }
  +        else if (bookComponent.document.height != height ||
  +            bookComponent.document.width != width) {
  +
  +            MessageHandler.logln("Warning : FrameMaker doesnt support different page-sizes   in a document");
  +        }
  +
  +    }
  +
  +    public void createTextRect(int numCols) {
  +
  +        //Create a textrect on the bodypage with these dimensions
  +        //This default behaviour will later be changed to reflect on
  +        //the master-page
  +
  +
  +        (bookComponent.curPage()).addTextRect(numCols);
  +
  +
  +        // Then create a textflow corresponding to this textrect
  +
  +        curFlow = new TextFlow();
  +        bookComponent.textFlows.addElement(curFlow);
  +    }
  +
  +    public void setTextRectProp(int left, int top, int width, int height) {
  +
  +        (bookComponent.curPage()).curTextRect().setTextRectProp(left,
  +                top, width, height);
  +
  +
  +    }
  +
  +    public void startLine() {
  +
  +        if (curFlow.curPara().curParaLine() != null) {
  +            this.addToStream("\n");
  +            curFlow.curPara().startParaLine();
  +        } else
  +            curFlow.curPara().startParaLine();
  +
  +
  +    }
  +
  +    public void setBlockProp(int startIndent, int endIndent) {
  +
  +
  +        curFlow.startPara(); //Start a para
  +        curFlow.curPara().setBlockProp(startIndent, endIndent);
  +
  +    }
  +
  +    public void createFrame(int x, int y, int w, int h) {
  +
  +        //Create a new anchored frame
  +
  +        bookComponent.createFrame(x, y, w, h);
  +
  +    }
  +
  +    public void addImage(String url, int x, int y, int w, int h) {
  +
  +        Frame frame = bookComponent.createFrame(x, y, w, h);
  +        ImportObject imageObject = new ImportObject(url, 0, 0, w, h);
  +        frame.addContent(imageObject);
  +        if (curFlow.curPara().curParaLine() == null) {
  +            curFlow.curPara().startParaLine();
  +
  +        }
  +        curFlow.curPara().curParaLine().addContent(frame);
  +
  +
  +    }
  +
  +    public void createTable() {
  +
  +        // First create a table with an ID, then add it to the textflow
  +
  +        Tbl table = bookComponent.createTable();
  +        if (curFlow.curPara().curParaLine() == null) {
  +            curFlow.curPara().startParaLine();
  +
  +        }
  +        curFlow.curPara().curParaLine().addContent(table);
  +
  +        /* The above would have added the table to the textflow
  +           But now the flow goes into the table, so ... */
  +
  +        curFlow = table;
  +
  +    }
  +
  +    public void setColumnProp(int colWidth) {
  +
  +
  +        //Get the current table
  +
  +        Tbl table = bookComponent.curTable();
  +        table.addColumn(colWidth);
  +
  +
  +    }
  +
  +    public void setCurrent(String current) {
  +
  +        //Start the table body or header or footer
  +        Tbl table = bookComponent.curTable();
  +        table.setCurrent(current);
  +
  +    }
  +
  +    public void startRow() {
  +
  +        Tbl table = bookComponent.curTable();
  +        table.startRow();
  +
  +
  +    }
  +
  +    public void startCell(int rowSpan, int colSpan) {
  +
  +        Tbl table = bookComponent.curTable();
  +        table.startCell(rowSpan, colSpan);
  +
  +    }
  +
  +    public void endTable() {
  +
  +        // Switch the ref back to the current textflow
  +
  +        curFlow = bookComponent.curTextFlow();
  +
  +    }
  +
  +}
  
  
  
  1.2       +21 -66    xml-fop/src/org/apache/fop/pdf/PDFFilterException.java
  
  Index: PDFFilterException.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFFilterException.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PDFFilterException.java	2000/05/23 09:17:57	1.1
  +++ PDFFilterException.java	2001/07/04 12:41:02	1.2
  @@ -1,66 +1,21 @@
  -/*
  -
  - ============================================================================
  -                   The Apache Software License, Version 1.1
  - ============================================================================
  - 
  -    Copyright (C) 1999 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
  -    apache@apache.org.
  - 
  - 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
  - APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  - INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  - DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  - OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  - ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  - (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 <jt...@jtauber.com>. For more  information on the Apache 
  - Software Foundation, please see <http://www.apache.org/>.
  - 
  - */
  -
  -//Author:       Eric SCHAEFFER
  -//Description:  Filter Exception
  -
  -package org.apache.fop.pdf;
  -
  -public class PDFFilterException extends Exception {
  -
  -	public PDFFilterException() {
  -		super();
  -	}
  -
  -	public PDFFilterException(String message) {
  -		super(message);
  -	}
  -}
  +/* $Id: PDFFilterException.java,v 1.2 2001/07/04 12:41:02 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.
  + */
  +
  +//Author:       Eric SCHAEFFER
  +//Description:  Filter Exception
  +
  +package org.apache.fop.pdf;
  +
  +public class PDFFilterException extends Exception {
  +
  +    public PDFFilterException() {
  +        super();
  +    }
  +
  +    public PDFFilterException(String message) {
  +        super(message);
  +    }
  +}
  
  
  
  1.2       +29 -73    xml-fop/src/org/apache/fop/render/mif/Font.java
  
  Index: Font.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/render/mif/Font.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Font.java	2001/02/10 03:24:16	1.1
  +++ Font.java	2001/07/04 12:41:03	1.2
  @@ -1,73 +1,29 @@
  -/*-- $Id: Font.java,v 1.1 2001/02/10 03:24:16 arved Exp $ -- 
  -
  - ============================================================================
  -                   The Apache Software License, Version 1.1
  - ============================================================================
  - 
  -    Copyright (C) 1999 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
  -    apache@apache.org.
  - 
  - 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
  - APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  - INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  - DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  - OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  - ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  - (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 <jt...@jtauber.com>. For more  information on the Apache 
  - Software Foundation, please see <http://www.apache.org/>.
  - 
  - */
  -package org.apache.fop.render.mif;
  -
  -// FOP
  -import org.apache.fop.layout.FontMetric;
  -
  -/**
  - * base class for PDF font classes
  - */
  -public abstract class Font implements FontMetric {
  -
  -    /**
  -     * get the encoding of the font
  -     */
  -    public abstract String encoding();
  -
  -    /**
  -     * get the base font name
  -     */
  -    public abstract String fontName();
  -}
  -
  -
  -
  +/* $Id: Font.java,v 1.2 2001/07/04 12:41:03 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.render.mif;
  +
  +// FOP
  +import org.apache.fop.layout.FontMetric;
  +
  +/**
  + * base class for PDF font classes
  + */
  +public abstract class Font implements FontMetric {
  +
  +    /**
  +     * get the encoding of the font
  +     */
  +    public abstract String encoding();
  +
  +    /**
  +     * get the base font name
  +     */
  +    public abstract String fontName();
  +}
  +
  +
  +
  
  
  
  1.2       +156 -239  xml-fop/src/org/apache/fop/render/mif/FontSetup.java
  
  Index: FontSetup.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/render/mif/FontSetup.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FontSetup.java	2001/02/10 03:24:43	1.1
  +++ FontSetup.java	2001/07/04 12:41:04	1.2
  @@ -1,239 +1,156 @@
  -/*-- $Id: FontSetup.java,v 1.1 2001/02/10 03:24:43 arved Exp $ -- 
  -
  - ============================================================================
  -                   The Apache Software License, Version 1.1
  - ============================================================================
  - 
  -    Copyright (C) 1999 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
  -    apache@apache.org.
  - 
  - 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
  - APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  - INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  - DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  - OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  - ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  - (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 <jt...@jtauber.com>. For more  information on the Apache 
  - Software Foundation, please see <http://www.apache.org/>.
  - 
  - */
  -package org.apache.fop.render.mif;
  -
  -// FOP
  -import org.apache.fop.render.mif.fonts.*;
  -import org.apache.fop.messaging.MessageHandler;
  -import org.apache.fop.layout.FontInfo;
  -import org.apache.fop.layout.FontDescriptor;
  -import org.apache.fop.mif.MIFDocument;
  -//import org.apache.fop.pdf.PDFResources;
  -
  -// Java
  -import java.util.Enumeration;
  -import java.util.Hashtable;
  -
  -/**
  - * sets up the PDF fonts.
  - *
  - * Assigns the font (with metrics) to internal names like "F1" and
  - *  assigns family-style-weight triplets to the fonts
  - */
  -public class FontSetup {
  -
  -    /**
  -     * sets up the font info object.
  -     *
  -     * adds metrics for basic fonts and useful family-style-weight
  -     * triplets for lookup
  -     *
  -     * @param fontInfo the font info object to set up
  -     */
  -    public static void setup(FontInfo fontInfo) {
  -    MessageHandler.logln("setting up fonts");
  -        
  -    fontInfo.addMetrics("F1", new Helvetica());
  -    fontInfo.addMetrics("F2", new HelveticaOblique());
  -    fontInfo.addMetrics("F3", new HelveticaBold());
  -    fontInfo.addMetrics("F4", new HelveticaBoldOblique());
  -    fontInfo.addMetrics("F5", new TimesRoman());
  -    fontInfo.addMetrics("F6", new TimesItalic());
  -    fontInfo.addMetrics("F7", new TimesBold());
  -    fontInfo.addMetrics("F8", new TimesBoldItalic());
  -    fontInfo.addMetrics("F9", new Courier());
  -    fontInfo.addMetrics("F10", new CourierOblique());
  -    fontInfo.addMetrics("F11", new CourierBold());
  -    fontInfo.addMetrics("F12", new CourierBoldOblique());
  -    fontInfo.addMetrics("F13", new Symbol());
  -    fontInfo.addMetrics("F14", new ZapfDingbats());
  -
  -    //Custom type 1 fonts step 1/2
  -//    fontInfo.addMetrics("F15", new OMEP());
  -//    fontInfo.addMetrics("F16", new GaramondLightCondensed());
  -//    fontInfo.addMetrics("F17", new BauerBodoniBoldItalic());
  -
  -    /* any is treated as serif */
  -    fontInfo.addFontProperties("F5", "any", "normal", "normal");
  -    fontInfo.addFontProperties("F6", "any", "italic", "normal");
  -    fontInfo.addFontProperties("F6", "any", "oblique", "normal");
  -    fontInfo.addFontProperties("F7", "any", "normal", "bold");
  -    fontInfo.addFontProperties("F8", "any", "italic", "bold");
  -    fontInfo.addFontProperties("F8", "any", "oblique", "bold");
  -
  -    fontInfo.addFontProperties("F1", "sans-serif", "normal",
  -                   "normal");
  -    fontInfo.addFontProperties("F2", "sans-serif", "oblique",
  -                   "normal");
  -    fontInfo.addFontProperties("F2", "sans-serif", "italic",
  -                   "normal");
  -    fontInfo.addFontProperties("F3", "sans-serif", "normal",
  -                   "bold");
  -    fontInfo.addFontProperties("F4", "sans-serif", "oblique",
  -                   "bold");
  -    fontInfo.addFontProperties("F4", "sans-serif", "italic",
  -                   "bold");
  -    fontInfo.addFontProperties("F5", "serif", "normal", "normal");
  -    fontInfo.addFontProperties("F6", "serif", "oblique",
  -                   "normal");
  -    fontInfo.addFontProperties("F6", "serif", "italic", "normal");
  -    fontInfo.addFontProperties("F7", "serif", "normal", "bold");
  -    fontInfo.addFontProperties("F8", "serif", "oblique", "bold");
  -    fontInfo.addFontProperties("F8", "serif", "italic", "bold");
  -    fontInfo.addFontProperties("F9", "monospace", "normal",
  -                   "normal");
  -    fontInfo.addFontProperties("F10", "monospace", "oblique",
  -                   "normal");
  -    fontInfo.addFontProperties("F10", "monospace", "italic",
  -                   "normal");
  -    fontInfo.addFontProperties("F11", "monospace", "normal",
  -                   "bold");
  -    fontInfo.addFontProperties("F12", "monospace", "oblique",
  -                   "bold");
  -    fontInfo.addFontProperties("F12", "monospace", "italic",
  -                   "bold");
  -
  -    fontInfo.addFontProperties("F1", "Helvetica", "normal",
  -                   "normal");
  -    fontInfo.addFontProperties("F2", "Helvetica", "oblique",
  -                   "normal");
  -    fontInfo.addFontProperties("F2", "Helvetica", "italic",
  -                   "normal");
  -    fontInfo.addFontProperties("F3", "Helvetica", "normal",
  -                   "bold");
  -    fontInfo.addFontProperties("F4", "Helvetica", "oblique",
  -                   "bold");
  -    fontInfo.addFontProperties("F4", "Helvetica", "italic",
  -                   "bold");
  -    fontInfo.addFontProperties("F5", "Times", "normal", "normal");
  -    fontInfo.addFontProperties("F6", "Times", "oblique",
  -                   "normal");
  -    fontInfo.addFontProperties("F6", "Times", "italic", "normal");
  -    fontInfo.addFontProperties("F7", "Times", "normal", "bold");
  -    fontInfo.addFontProperties("F8", "Times", "oblique", "bold");
  -    fontInfo.addFontProperties("F8", "Times", "italic", "bold");
  -    fontInfo.addFontProperties("F9", "Courier", "normal",
  -                   "normal");
  -    fontInfo.addFontProperties("F10", "Courier", "oblique",
  -                   "normal");
  -    fontInfo.addFontProperties("F10", "Courier", "italic",
  -                   "normal");
  -    fontInfo.addFontProperties("F11", "Courier", "normal",
  -                   "bold");
  -    fontInfo.addFontProperties("F12", "Courier", "oblique",
  -                   "bold");
  -    fontInfo.addFontProperties("F12", "Courier", "italic",
  -                   "bold");
  -    fontInfo.addFontProperties("F13", "Symbol", "normal",
  -                   "normal");
  -    fontInfo.addFontProperties("F14", "ZapfDingbats", "normal",
  -                   "normal");
  -
  -    //Custom type 1 fonts step 2/2
  -//    fontInfo.addFontProperties("F15", "OMEP", "normal", "normal");
  -//    fontInfo.addFontProperties("F16", "Garamond-LightCondensed", "normal", "normal");
  -//    fontInfo.addFontProperties("F17", "BauerBodoni", "italic", "bold");
  -
  -    /* for compatibility with PassiveTex */
  -    fontInfo.addFontProperties("F5", "Times-Roman", "normal",
  -                   "normal");
  -    fontInfo.addFontProperties("F6", "Times-Roman", "oblique",
  -                   "normal");
  -    fontInfo.addFontProperties("F6", "Times-Roman", "italic",
  -                   "normal");
  -    fontInfo.addFontProperties("F7", "Times-Roman", "normal",
  -                   "bold");
  -    fontInfo.addFontProperties("F8", "Times-Roman", "oblique",
  -                   "bold"); 
  -    fontInfo.addFontProperties("F8", "Times-Roman", "italic",
  -                   "bold"); 
  -    fontInfo.addFontProperties("F5", "Times Roman", "normal",
  -                   "normal"); 
  -    fontInfo.addFontProperties("F6", "Times Roman", "oblique",
  -                   "normal"); 
  -    fontInfo.addFontProperties("F6", "Times Roman", "italic",
  -                   "normal"); 
  -    fontInfo.addFontProperties("F7", "Times Roman", "normal",
  -                   "bold"); 
  -    fontInfo.addFontProperties("F8", "Times Roman", "oblique",
  -                   "bold"); 
  -    fontInfo.addFontProperties("F8", "Times Roman", "italic",
  -                   "bold"); 
  -    fontInfo.addFontProperties("F9", "Computer-Modern-Typewriter",
  -                   "normal", "normal");
  -    }
  -
  -    /**
  -     * add the fonts in the font info to the PDF document
  -     *
  -     * @param doc PDF document to add fonts to
  -     * @param fontInfo font info object to get font information from
  -     */
  -    public static void addToFontFormat(MIFDocument mifDoc, FontInfo fontInfo) {
  -    
  -        Hashtable fonts = fontInfo.getFonts();
  -        Enumeration e = fonts.keys();
  -        while (e.hasMoreElements()) {
  -           String f = (String) e.nextElement();
  -           Font font = (Font)fonts.get(f);
  -           FontDescriptor desc = null;
  -           if (font instanceof FontDescriptor) {
  -            desc = (FontDescriptor)font;
  -           }
  -          /* mifDoc.makeFont(f,font.fontName(),
  -                       font.encoding(),
  -                       font,
  -                       desc
  -                       );  */
  -                  
  -        } 
  -    }  
  -}
  +/* $Id: FontSetup.java,v 1.2 2001/07/04 12:41:04 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.render.mif;
  +
  +// FOP
  +import org.apache.fop.render.mif.fonts.*;
  +import org.apache.fop.messaging.MessageHandler;
  +import org.apache.fop.layout.FontInfo;
  +import org.apache.fop.layout.FontDescriptor;
  +import org.apache.fop.mif.MIFDocument;
  +//import org.apache.fop.pdf.PDFResources;
  +
  +// Java
  +import java.util.Enumeration;
  +import java.util.Hashtable;
  +
  +/**
  + * sets up the PDF fonts.
  + *
  + * Assigns the font (with metrics) to internal names like "F1" and
  + *  assigns family-style-weight triplets to the fonts
  + */
  +public class FontSetup {
  +
  +    /**
  +     * sets up the font info object.
  +     *
  +     * adds metrics for basic fonts and useful family-style-weight
  +     * triplets for lookup
  +     *
  +     * @param fontInfo the font info object to set up
  +     */
  +    public static void setup(FontInfo fontInfo) {
  +        MessageHandler.logln("setting up fonts");
  +
  +        fontInfo.addMetrics("F1", new Helvetica());
  +        fontInfo.addMetrics("F2", new HelveticaOblique());
  +        fontInfo.addMetrics("F3", new HelveticaBold());
  +        fontInfo.addMetrics("F4", new HelveticaBoldOblique());
  +        fontInfo.addMetrics("F5", new TimesRoman());
  +        fontInfo.addMetrics("F6", new TimesItalic());
  +        fontInfo.addMetrics("F7", new TimesBold());
  +        fontInfo.addMetrics("F8", new TimesBoldItalic());
  +        fontInfo.addMetrics("F9", new Courier());
  +        fontInfo.addMetrics("F10", new CourierOblique());
  +        fontInfo.addMetrics("F11", new CourierBold());
  +        fontInfo.addMetrics("F12", new CourierBoldOblique());
  +        fontInfo.addMetrics("F13", new Symbol());
  +        fontInfo.addMetrics("F14", new ZapfDingbats());
  +
  +        //Custom type 1 fonts step 1/2
  +        //    fontInfo.addMetrics("F15", new OMEP());
  +        //    fontInfo.addMetrics("F16", new GaramondLightCondensed());
  +        //    fontInfo.addMetrics("F17", new BauerBodoniBoldItalic());
  +
  +        /* any is treated as serif */
  +        fontInfo.addFontProperties("F5", "any", "normal", "normal");
  +        fontInfo.addFontProperties("F6", "any", "italic", "normal");
  +        fontInfo.addFontProperties("F6", "any", "oblique", "normal");
  +        fontInfo.addFontProperties("F7", "any", "normal", "bold");
  +        fontInfo.addFontProperties("F8", "any", "italic", "bold");
  +        fontInfo.addFontProperties("F8", "any", "oblique", "bold");
  +
  +        fontInfo.addFontProperties("F1", "sans-serif", "normal", "normal");
  +        fontInfo.addFontProperties("F2", "sans-serif", "oblique", "normal");
  +        fontInfo.addFontProperties("F2", "sans-serif", "italic", "normal");
  +        fontInfo.addFontProperties("F3", "sans-serif", "normal", "bold");
  +        fontInfo.addFontProperties("F4", "sans-serif", "oblique", "bold");
  +        fontInfo.addFontProperties("F4", "sans-serif", "italic", "bold");
  +        fontInfo.addFontProperties("F5", "serif", "normal", "normal");
  +        fontInfo.addFontProperties("F6", "serif", "oblique", "normal");
  +        fontInfo.addFontProperties("F6", "serif", "italic", "normal");
  +        fontInfo.addFontProperties("F7", "serif", "normal", "bold");
  +        fontInfo.addFontProperties("F8", "serif", "oblique", "bold");
  +        fontInfo.addFontProperties("F8", "serif", "italic", "bold");
  +        fontInfo.addFontProperties("F9", "monospace", "normal", "normal");
  +        fontInfo.addFontProperties("F10", "monospace", "oblique", "normal");
  +        fontInfo.addFontProperties("F10", "monospace", "italic", "normal");
  +        fontInfo.addFontProperties("F11", "monospace", "normal", "bold");
  +        fontInfo.addFontProperties("F12", "monospace", "oblique", "bold");
  +        fontInfo.addFontProperties("F12", "monospace", "italic", "bold");
  +
  +        fontInfo.addFontProperties("F1", "Helvetica", "normal", "normal");
  +        fontInfo.addFontProperties("F2", "Helvetica", "oblique", "normal");
  +        fontInfo.addFontProperties("F2", "Helvetica", "italic", "normal");
  +        fontInfo.addFontProperties("F3", "Helvetica", "normal", "bold");
  +        fontInfo.addFontProperties("F4", "Helvetica", "oblique", "bold");
  +        fontInfo.addFontProperties("F4", "Helvetica", "italic", "bold");
  +        fontInfo.addFontProperties("F5", "Times", "normal", "normal");
  +        fontInfo.addFontProperties("F6", "Times", "oblique", "normal");
  +        fontInfo.addFontProperties("F6", "Times", "italic", "normal");
  +        fontInfo.addFontProperties("F7", "Times", "normal", "bold");
  +        fontInfo.addFontProperties("F8", "Times", "oblique", "bold");
  +        fontInfo.addFontProperties("F8", "Times", "italic", "bold");
  +        fontInfo.addFontProperties("F9", "Courier", "normal", "normal");
  +        fontInfo.addFontProperties("F10", "Courier", "oblique", "normal");
  +        fontInfo.addFontProperties("F10", "Courier", "italic", "normal");
  +        fontInfo.addFontProperties("F11", "Courier", "normal", "bold");
  +        fontInfo.addFontProperties("F12", "Courier", "oblique", "bold");
  +        fontInfo.addFontProperties("F12", "Courier", "italic", "bold");
  +        fontInfo.addFontProperties("F13", "Symbol", "normal", "normal");
  +        fontInfo.addFontProperties("F14", "ZapfDingbats", "normal", "normal");
  +
  +        //Custom type 1 fonts step 2/2
  +        //    fontInfo.addFontProperties("F15", "OMEP", "normal", "normal");
  +        //    fontInfo.addFontProperties("F16", "Garamond-LightCondensed", "normal", "normal");
  +        //    fontInfo.addFontProperties("F17", "BauerBodoni", "italic", "bold");
  +
  +        /* for compatibility with PassiveTex */
  +        fontInfo.addFontProperties("F5", "Times-Roman", "normal", "normal");
  +        fontInfo.addFontProperties("F6", "Times-Roman", "oblique", "normal");
  +        fontInfo.addFontProperties("F6", "Times-Roman", "italic", "normal");
  +        fontInfo.addFontProperties("F7", "Times-Roman", "normal", "bold");
  +        fontInfo.addFontProperties("F8", "Times-Roman", "oblique", "bold");
  +        fontInfo.addFontProperties("F8", "Times-Roman", "italic", "bold");
  +        fontInfo.addFontProperties("F5", "Times Roman", "normal", "normal");
  +        fontInfo.addFontProperties("F6", "Times Roman", "oblique", "normal");
  +        fontInfo.addFontProperties("F6", "Times Roman", "italic", "normal");
  +        fontInfo.addFontProperties("F7", "Times Roman", "normal", "bold");
  +        fontInfo.addFontProperties("F8", "Times Roman", "oblique", "bold");
  +        fontInfo.addFontProperties("F8", "Times Roman", "italic", "bold");
  +        fontInfo.addFontProperties("F9", "Computer-Modern-Typewriter",
  +                                   "normal", "normal");
  +    }
  +
  +    /**
  +     * add the fonts in the font info to the PDF document
  +     *
  +     * @param doc PDF document to add fonts to
  +     * @param fontInfo font info object to get font information from
  +     */
  +    public static void addToFontFormat(MIFDocument mifDoc,
  +                                       FontInfo fontInfo) {
  +
  +        Hashtable fonts = fontInfo.getFonts();
  +        Enumeration e = fonts.keys();
  +        while (e.hasMoreElements()) {
  +            String f = (String) e.nextElement();
  +            Font font = (Font) fonts.get(f);
  +            FontDescriptor desc = null;
  +            if (font instanceof FontDescriptor) {
  +                desc = (FontDescriptor) font;
  +            }
  +            /* mifDoc.makeFont(f,font.fontName(),
  +                          font.encoding(),
  +                          font,
  +                          desc
  +                          );  */
  +
  +        }
  +    }
  +}
  
  
  
  1.5       +468 -534  xml-fop/src/org/apache/fop/render/mif/MIFRenderer.java
  
  Index: MIFRenderer.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/render/mif/MIFRenderer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MIFRenderer.java	2001/05/20 23:55:34	1.4
  +++ MIFRenderer.java	2001/07/04 12:41:04	1.5
  @@ -1,534 +1,468 @@
  -/*-- $Id: MIFRenderer.java,v 1.4 2001/05/20 23:55:34 arved Exp $ -- 
  -
  - ============================================================================
  -				   The Apache Software License, Version 1.1
  - ============================================================================
  - 
  -	Copyright (C) 1999 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
  -	apache@apache.org.
  - 
  - 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
  - APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  - INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  - DING, BUT NOT LIMITED TO, PROCUREMENT	OF SUBSTITUTE GOODS OR SERVICES; LOSS
  - OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)	HOWEVER CAUSED AND ON
  - ANY  THEORY OF LIABILITY,	WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  - (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 <jt...@jtauber.com>. For more  information on the Apache 
  - Software Foundation, please see <http://www.apache.org/>.
  - 
  - */
  -
  -// Author : Seshadri G
  -
  -
  -
  -
  -package org.apache.fop.render.mif;
  -
  -// FOP
  -import org.apache.fop.render.Renderer;
  -import org.apache.fop.messaging.MessageHandler;
  -import org.apache.fop.image.ImageArea;
  -import org.apache.fop.image.FopImage;
  -import org.apache.fop.apps.FOPException;
  -import org.apache.fop.fo.properties.*;
  -import org.apache.fop.fo.*; 
  -import org.apache.fop.layout.*;
  -import org.apache.fop.layout.inline.*;
  -import org.apache.fop.datatypes.*;
  -import org.apache.fop.svg.*;
  -import org.apache.fop.mif.*;
  -import org.apache.fop.layout.*;
  -import org.apache.fop.image.*;
  -
  -import org.w3c.dom.*;
  -import org.w3c.dom.svg.*;
  -import org.w3c.dom.css.*;
  -import org.w3c.dom.svg.SVGLength;
  -
  -// Java
  -import java.io.IOException;
  -import java.io.OutputStream;
  -import java.util.Enumeration;
  -import java.awt.Rectangle;
  -import java.util.Vector;
  -import java.util.Hashtable;
  -/**
  - * Renderer that renders areas to MIF
  - */
  -public class MIFRenderer implements Renderer {
  -
  -	private String currentFontName;
  -	private String currentFontSize;
  -	private int pageHeight;
  -	private int pageWidth;
  -
  -	/** the current vertical position in millipoints from bottom */
  -	protected int currentYPosition = 0;
  -
  -	/** the current horizontal position in millipoints from left */
  -	protected int currentXPosition = 0;
  -
  -	/** the horizontal position of the current area container */
  -	private int currentAreaContainerXPosition = 0;
  -
  -	
  -	/** the MIF Document being created */
  -	protected MIFDocument mifDoc;
  -
  -
  -	/* is a table currently open? */
  -	private boolean inTable=false;
  -
  -	/** options */
  -	protected Hashtable options;
  -	
  -	/**
  -	 * create the MIF renderer
  -	 */
  -	public MIFRenderer() {
  -		this.mifDoc = new MIFDocument();
  -	}
  -	
  -	/** set up renderer options */
  -	public void setOptions(Hashtable options) {
  -		this.options = options;
  -	}
  -		
  -	/**
  -	 * render the areas into MIF
  -	 *
  -	 * @param areaTree the laid-out area tree
  -	 * @param writer the PrintWriter to write the MIF with
  -	 */
  -
  -	public void render(AreaTree areaTree,
  -                       OutputStream stream) throws IOException, FOPException {
  -    
  -            MessageHandler.logln("rendering areas to MIF");
  -           // idReferences=areaTree.getIDReferences();           
  -            //this.pdfResources = this.pdfDoc.getResources();            
  -            //this.pdfDoc.setIDReferences(idReferences);
  -	      Enumeration e = areaTree.getPages().elements();
  -              while (e.hasMoreElements()) {
  -		this.renderPage((Page) e.nextElement());
  -	      }
  -    
  -    
  -          //  MessageHandler.logln("writing out MIF");
  -
  -		this.mifDoc.output(stream);
  -		stream.close();
  -    }
  -
  -
  -    
  - 
  -    /** set up the given FontInfo */
  -    public void setupFontInfo(FontInfo fontInfo) {
  -
  -	FontSetup.setup(fontInfo);
  -	//FontSetup.addToFontFormat(this.mifDoc, fontInfo);
  -
  -
  -    } 
  -
  -    /** set the producer of the rendering */
  -    public void setProducer(String producer) {} 
  -
  -   	
  -    public void renderAreaContainer(AreaContainer area) {
  -
  -	if (area.foCreator != null && area.foCreator.getName() == "fo:table") {
  -	
  -		this.mifDoc.createTable();
  -		this.inTable=true;
  -	}
  -	else 
  -	if (area.foCreator != null && area.foCreator.getName() == "fo:table-body") {
  -	
  -		this.mifDoc.setCurrent("fo:table-body");
  -	}
  -	else 
  -	if (area.foCreator != null && area.foCreator.getName() == "fo:table-column") {
  -		
  -		int colWidth=((org.apache.fop.fo.flow.TableColumn) area.foCreator).getColumnWidth();	
  -		this.mifDoc.setColumnProp(colWidth);
  -	}
  -	else 
  -	if (area.foCreator != null && area.foCreator.getName() == "fo:table-row") {
  -	
  -		this.mifDoc.startRow();
  -	}
  -	else 
  -	if (area.foCreator != null && area.foCreator.getName() == "fo:table-cell") {
  -		
  -		int rowSpan=((org.apache.fop.fo.flow.TableCell) area.foCreator).getNumRowsSpanned();
  -		int colSpan=((org.apache.fop.fo.flow.TableCell) area.foCreator).getNumColumnsSpanned();
  -		this.mifDoc.startCell(rowSpan,colSpan);
  -	}
  -	else
  -	if (inTable) {
  -	
  -		inTable=false;
  -		this.mifDoc.endTable();
  -
  -	} 
  -        int saveY = this.currentYPosition;
  -        int saveX = this.currentAreaContainerXPosition;
  -
  -        if (area.getPosition() == Position.ABSOLUTE) {
  -   	     // Y position is computed assuming positive Y axis, adjust for negative postscript one
  -   		this.currentYPosition =area.getYPosition() - 2 * area.getPaddingTop() - 2 * 						area.getBorderTopWidth();
  -        
  -		this.currentAreaContainerXPosition = area.getXPosition();
  -        } else if (area.getPosition() == Position.RELATIVE) {
  -	
  -	        this.currentYPosition -= area.getYPosition();
  -        	this.currentAreaContainerXPosition += area.getXPosition();
  -        
  -	} else if (area.getPosition() == Position.STATIC) {
  -        	
  -		this.currentYPosition -=
  -        	area.getPaddingTop() + area.getBorderTopWidth();
  -        	this.currentAreaContainerXPosition +=area.getPaddingLeft() + 		area.getBorderLeftWidth();
  -        }
  -
  -        this.currentXPosition = this.currentAreaContainerXPosition;
  -        doFrame(area);
  -
  -        Enumeration e = area.getChildren().elements();
  -        while (e.hasMoreElements()) {
  -            Box b = (Box) e.nextElement();
  -            b.render(this);
  -        }
  -        if (area.getPosition() != Position.STATIC) {
  -            this.currentYPosition = saveY;
  -            this.currentAreaContainerXPosition = saveX;
  -        } else
  -            this.currentYPosition -= area.getHeight();
  -    }
  -
  -    public void renderBodyAreaContainer(BodyAreaContainer area) {
  -
  -	
  -        int saveY = this.currentYPosition;
  -        int saveX = this.currentAreaContainerXPosition;
  -
  -        if (area.getPosition() == Position.ABSOLUTE) {
  -            // Y position is computed assuming positive Y axis, adjust for negative postscript one
  -            this.currentYPosition = area.getYPosition();
  -            this.currentAreaContainerXPosition = area.getXPosition();
  -        } else if (area.getPosition() == Position.RELATIVE) {
  -            this.currentYPosition -= area.getYPosition();
  -            this.currentAreaContainerXPosition += area.getXPosition();
  -        }
  -		
  -        this.currentXPosition = this.currentAreaContainerXPosition;
  -        int w, h;
  -        int rx = this.currentAreaContainerXPosition;
  -        w = area.getContentWidth();
  -        h = area.getContentHeight();
  -        int ry = this.currentYPosition;
  -        ColorType bg = area.getBackgroundColor();
  -
  -	/*
  -
  -        // I'm not sure I should have to check for bg being null
  -        // but I do
  -        if ((bg != null) && (bg.alpha() == 0)) {
  -            this.addRect(rx, ry, w, -h, new PDFColor(bg), new PDFColor(bg));
  -        }
  -
  -	*/
  -	/*
  -	
  -	// floats & footnotes stuff
  -	renderAreaContainer(area.getBeforeFloatReferenceArea());
  -  	renderAreaContainer(area.getFootnoteReferenceArea());
  -	
  -	*/
  -	// main reference area
  -	Enumeration e = area.getMainReferenceArea().getChildren().elements();
  -	while (e.hasMoreElements()) {
  -		Box b = (Box) e.nextElement();
  -		b.render(this);	// span areas
  -	}		
  -
  -        if (area.getPosition() != Position.STATIC) {
  -            this.currentYPosition = saveY;
  -            this.currentAreaContainerXPosition = saveX;
  -        } else
  -            this.currentYPosition -= area.getHeight();
  -
  -	}
  -	
  -
  -    private void doFrame(Area area) {
  -	int w, h;
  -	int rx = this.currentAreaContainerXPosition;
  -	w = area.getContentWidth();
  -	
  -	if (area instanceof BlockArea)
  -	  rx += ((BlockArea)area).getStartIndent();
  -	
  -   	h = area.getContentHeight();
  -	int ry = this.currentYPosition;
  -	ColorType bg = area.getBackgroundColor();
  -		
  -	rx = rx - area.getPaddingLeft();
  -	ry = ry + area.getPaddingTop();
  -	w = w + area.getPaddingLeft() + area.getPaddingRight();
  -	h = h + area.getPaddingTop() + area.getPaddingBottom();
  -	
  -	/*	
  -	// I'm not sure I should have to check for bg being null
  -	// but I do
  -	if ((bg != null) && (bg.alpha() == 0)) {
  -		this.addRect(rx, ry, w, -h,
  -			 new PDFColor(bg),
  -			 new PDFColor(bg));
  -	}
  -
  -	*/
  -	
  -	rx = rx - area.getBorderLeftWidth();
  -	ry = ry + area.getBorderTopWidth();
  -	w = w + area.getBorderLeftWidth() + area.getBorderRightWidth();
  -	h = h + area.getBorderTopWidth() + area.getBorderBottomWidth();
  -
  -	//Create a textrect with these dimensions.
  -	//The y co-ordinate is measured +ve downwards so subtract page-height
  -		
  -	this.mifDoc.setTextRectProp(rx,pageHeight-ry,w,h);
  -
  -	/*
  -	 BorderAndPadding bp = area.getBorderAndPadding();
  -	 if (area.getBorderTopWidth() != 0)
  -	   addLine(rx, ry, rx + w, ry, area.getBorderTopWidth(),
  -			   new PDFColor(bp.getBorderColor(BorderAndPadding.TOP)));
  -	 if (area.getBorderLeftWidth() != 0)
  -	   addLine(rx, ry, rx, ry - h, area.getBorderLeftWidth(),
  -			   new PDFColor(bp.getBorderColor(BorderAndPadding.LEFT)));
  -	 if (area.getBorderRightWidth() != 0)
  -	   addLine(rx + w, ry, rx + w, ry - h, area.getBorderRightWidth(),
  -			   new PDFColor(bp.getBorderColor(BorderAndPadding.RIGHT)));
  -	 if (area.getBorderBottomWidth() != 0)
  -	   addLine(rx, ry - h, rx + w, ry - h, area.getBorderBottomWidth(),
  -			   new PDFColor(bp.getBorderColor(BorderAndPadding.BOTTOM)));
  -	*/
  -    } 
  -
  -    public void renderSpanArea(SpanArea area) {
  -
  -	 	//A span maps to a textframe
  -
  -		
  -		this.mifDoc.createTextRect(area.getColumnCount());
  -				
  -		Enumeration e = area.getChildren().elements();
  -		while (e.hasMoreElements()) {
  -			Box b = (Box) e.nextElement();
  -			b.render(this);	// column areas
  -		}				
  -	}	
  -
  -
  -
  -
  -   
  -
  -    /** render the given block area */
  -    public void renderBlockArea(BlockArea area) {
  -
  -	this.mifDoc.setBlockProp(area.getStartIndent(),area.getEndIndent());
  -	Enumeration e = area.getChildren().elements();
  -	while (e.hasMoreElements()) {
  -		Box b = (Box) e.nextElement();
  -		b.render(this);
  -	}
  -
  -    } 
  -
  -    /** render the given display space */
  -    public void renderDisplaySpace(DisplaySpace space) {
  -
  -	int d = space.getSize();
  -	this.currentYPosition -= d;
  -
  -    } 
  -
  -    /** render the given SVG area */
  -    public void renderSVGArea(SVGArea area) {} 
  -
  -    /** render a foreign object area */
  -    public void renderForeignObjectArea(ForeignObjectArea area) {
  -    } 
  -
  -	public void renderWordArea(WordArea area) {
  -	String s;
  -	s = area.getText(); 
  -	this.mifDoc.addToStream(s);
  -	
  -	this.currentXPosition += area.getContentWidth();
  -	}
  -	
  -    /** render the given image area */
  -    public void renderImageArea(ImageArea area) {
  -
  -	int x = this.currentAreaContainerXPosition + area.getXOffset();
  -        int y = this.currentYPosition;
  -        int w = area.getContentWidth();
  -        int h = area.getHeight();
  -
  -        this.currentYPosition -= h;
  -
  -        FopImage img = area.getImage();
  -        if (img instanceof SVGImage) {
  -           /* try {
  -                SVGSVGElement svg =
  -                  ((SVGImage) img).getSVGDocument().getRootElement();
  -                currentStream.add("ET\nq\n" + (((float) w) / 1000f) +
  -                                  " 0 0 " + (((float) h) / 1000f) + " " +
  -                                  (((float) x) / 1000f) + " " +
  -                                  (((float)(y - h)) / 1000f) + " cm\n");
  -                //        renderSVG(svg, (int) x, (int) y);
  -                currentStream.add("Q\nBT\n");
  -            } catch (FopImageException e) {
  -            } */
  -
  -	MessageHandler.logln("Warning: SVG images not supported in this version");
  -        } else {
  -		String url = img.getURL(); 	
  -		this.mifDoc.addImage(url,x,pageHeight-y,w,h);
  -
  -          }
  -    }
  -
  -
  -
  -    /** render the given inline area */
  -    public void renderInlineArea(InlineArea area) {} 
  -
  -    /** render the given inline space */
  -    public void renderInlineSpace(InlineSpace space) {
  -
  -	// I dont need the size of space! I just need to 
  -	// leave a blank space each time
  -	String s=" ";
  -	this.mifDoc.addToStream(s); // cool!
  -	this.currentXPosition += space.getSize();
  -    } 
  -
  -    /** render the given line area */
  -    public void renderLineArea(LineArea area) {
  -
  -
  -	
  -	int rx = this.currentAreaContainerXPosition
  -		+ area.getStartIndent();
  -	int ry = this.currentYPosition;
  -	int w = area.getContentWidth();
  -	int h = area.getHeight();
  -
  -	this.currentYPosition -= area.getPlacementOffset();
  -	this.currentXPosition = rx;
  -
  -	int bl = this.currentYPosition;
  -          
  -	//The start of a new linearea corresponds to a new para in FM
  -
  -	this.mifDoc.startLine();
  -
  -	Enumeration e = area.getChildren().elements();
  -	while (e.hasMoreElements()) {
  -	
  -		Box b = (Box) e.nextElement();
  -		this.currentYPosition = ry - area.getPlacementOffset();
  -		b.render(this); 
  -
  -	}
  -	this.currentYPosition = ry-h;
  -	this.currentXPosition = rx;
  -	
  -
  -    } 
  -
  -
  -
  -    /** render the given page */
  -    public void renderPage(Page page) {
  -
  -	AreaContainer before, after;
  -	BodyAreaContainer body;
  -	body = page.getBody();
  -	before = page.getBefore();
  -	after = page.getAfter();
  -
  -	this.currentFontName = "";
  -	this.currentFontSize = "0";
  -
  -	pageHeight=page.getHeight();
  -	pageWidth=page.getWidth();
  -	this.mifDoc.setDocumentHeightWidth(pageHeight,pageWidth);
  -	
  -	
  -	this.mifDoc.createPage();
  -	
  -	renderBodyAreaContainer(body);
  -
  -	
  -	// If the area is an instance of anything other than body, it goes into the 
  -	// corresponding master page.
  -	
  -
  -	if (before != null) {
  -		
  -		this.mifDoc.createTextRect(1); // Create a rect with one col
  -		renderAreaContainer(before);
  -	}
  -
  -	if (after != null) {
  -		
  -		this.mifDoc.createTextRect(1); // Create a rect with one col
  -		renderAreaContainer(after);
  -	}
  -
  -    } 
  -
  -    /** render the given leader area */
  -    public void renderLeaderArea(LeaderArea area) {}
  -
  -
  -}
  +/* $Id: MIFRenderer.java,v 1.5 2001/07/04 12:41:04 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.
  + */
  +
  +// Author : Seshadri G
  +
  +package org.apache.fop.render.mif;
  +
  +// FOP
  +import org.apache.fop.render.Renderer;
  +import org.apache.fop.messaging.MessageHandler;
  +import org.apache.fop.image.ImageArea;
  +import org.apache.fop.image.FopImage;
  +import org.apache.fop.apps.FOPException;
  +import org.apache.fop.fo.properties.*;
  +import org.apache.fop.fo.*;
  +import org.apache.fop.layout.*;
  +import org.apache.fop.layout.inline.*;
  +import org.apache.fop.datatypes.*;
  +import org.apache.fop.svg.*;
  +import org.apache.fop.mif.*;
  +import org.apache.fop.layout.*;
  +import org.apache.fop.image.*;
  +
  +import org.w3c.dom.*;
  +import org.w3c.dom.svg.*;
  +import org.w3c.dom.css.*;
  +import org.w3c.dom.svg.SVGLength;
  +
  +// Java
  +import java.io.IOException;
  +import java.io.OutputStream;
  +import java.util.Enumeration;
  +import java.awt.Rectangle;
  +import java.util.Vector;
  +import java.util.Hashtable;
  +/**
  + * Renderer that renders areas to MIF
  + */
  +public class MIFRenderer implements Renderer {
  +
  +    private String currentFontName;
  +    private String currentFontSize;
  +    private int pageHeight;
  +    private int pageWidth;
  +
  +    /** the current vertical position in millipoints from bottom */
  +    protected int currentYPosition = 0;
  +
  +    /** the current horizontal position in millipoints from left */
  +    protected int currentXPosition = 0;
  +
  +    /** the horizontal position of the current area container */
  +    private int currentAreaContainerXPosition = 0;
  +
  +
  +    /** the MIF Document being created */
  +    protected MIFDocument mifDoc;
  +
  +
  +    /* is a table currently open? */
  +    private boolean inTable = false;
  +
  +    /** options */
  +    protected Hashtable options;
  +
  +    /**
  +     * create the MIF renderer
  +     */
  +    public MIFRenderer() {
  +        this.mifDoc = new MIFDocument();
  +    }
  +
  +    /** set up renderer options */
  +    public void setOptions(Hashtable options) {
  +        this.options = options;
  +    }
  +
  +    /**
  +     * render the areas into MIF
  +     *
  +     * @param areaTree the laid-out area tree
  +     * @param writer the PrintWriter to write the MIF with
  +     */
  +
  +    public void render(AreaTree areaTree,
  +                       OutputStream stream) throws IOException, FOPException {
  +
  +        MessageHandler.logln("rendering areas to MIF");
  +        // idReferences=areaTree.getIDReferences();
  +        //this.pdfResources = this.pdfDoc.getResources();
  +        //this.pdfDoc.setIDReferences(idReferences);
  +        Enumeration e = areaTree.getPages().elements();
  +        while (e.hasMoreElements()) {
  +            this.renderPage((Page) e.nextElement());
  +        }
  +
  +        //  MessageHandler.logln("writing out MIF");
  +
  +        this.mifDoc.output(stream);
  +        stream.close();
  +    }
  +
  +    /** set up the given FontInfo */
  +    public void setupFontInfo(FontInfo fontInfo) {
  +
  +        FontSetup.setup(fontInfo);
  +        //FontSetup.addToFontFormat(this.mifDoc, fontInfo);
  +
  +    }
  +
  +    /** set the producer of the rendering */
  +    public void setProducer(String producer) {}
  +
  +    public void renderAreaContainer(AreaContainer area) {
  +
  +        if (area.foCreator != null && area.foCreator.getName() == "fo:table") {
  +
  +            this.mifDoc.createTable();
  +            this.inTable = true;
  +        } else if (area.foCreator != null &&
  +            area.foCreator.getName() == "fo:table-body") {
  +
  +            this.mifDoc.setCurrent("fo:table-body");
  +        } else if (area.foCreator != null &&
  +            area.foCreator.getName() == "fo:table-column") {
  +
  +            int colWidth = ((org.apache.fop.fo.flow.TableColumn)
  +                            area.foCreator).getColumnWidth();
  +            this.mifDoc.setColumnProp(colWidth);
  +        } else if (area.foCreator != null &&
  +            area.foCreator.getName() == "fo:table-row") {
  +
  +            this.mifDoc.startRow();
  +        } else if (area.foCreator != null &&
  +            area.foCreator.getName() == "fo:table-cell") {
  +
  +            int rowSpan =
  +              ((org.apache.fop.fo.flow.TableCell) area.foCreator).
  +              getNumRowsSpanned();
  +            int colSpan =
  +              ((org.apache.fop.fo.flow.TableCell) area.foCreator).
  +              getNumColumnsSpanned();
  +            this.mifDoc.startCell(rowSpan, colSpan);
  +        } else if (inTable) {
  +
  +            inTable = false;
  +            this.mifDoc.endTable();
  +
  +        }
  +        int saveY = this.currentYPosition;
  +        int saveX = this.currentAreaContainerXPosition;
  +
  +        if (area.getPosition() == Position.ABSOLUTE) {
  +            // Y position is computed assuming positive Y axis, adjust for negative postscript one
  +            this.currentYPosition =
  +              area.getYPosition() - 2 * area.getPaddingTop() -
  +              2 * area.getBorderTopWidth();
  +
  +            this.currentAreaContainerXPosition = area.getXPosition();
  +        } else if (area.getPosition() == Position.RELATIVE) {
  +
  +            this.currentYPosition -= area.getYPosition();
  +            this.currentAreaContainerXPosition += area.getXPosition();
  +
  +        } else if (area.getPosition() == Position.STATIC) {
  +
  +            this.currentYPosition -=
  +              area.getPaddingTop() + area.getBorderTopWidth();
  +            this.currentAreaContainerXPosition +=
  +              area.getPaddingLeft() + area.getBorderLeftWidth();
  +        }
  +
  +        this.currentXPosition = this.currentAreaContainerXPosition;
  +        doFrame(area);
  +
  +        Enumeration e = area.getChildren().elements();
  +        while (e.hasMoreElements()) {
  +            Box b = (Box) e.nextElement();
  +            b.render(this);
  +        }
  +        if (area.getPosition() != Position.STATIC) {
  +            this.currentYPosition = saveY;
  +            this.currentAreaContainerXPosition = saveX;
  +        } else
  +            this.currentYPosition -= area.getHeight();
  +    }
  +
  +    public void renderBodyAreaContainer(BodyAreaContainer area) {
  +
  +
  +        int saveY = this.currentYPosition;
  +        int saveX = this.currentAreaContainerXPosition;
  +
  +        if (area.getPosition() == Position.ABSOLUTE) {
  +            // Y position is computed assuming positive Y axis, adjust for negative postscript one
  +            this.currentYPosition = area.getYPosition();
  +            this.currentAreaContainerXPosition = area.getXPosition();
  +        } else if (area.getPosition() == Position.RELATIVE) {
  +            this.currentYPosition -= area.getYPosition();
  +            this.currentAreaContainerXPosition += area.getXPosition();
  +        }
  +
  +        this.currentXPosition = this.currentAreaContainerXPosition;
  +        int w, h;
  +        int rx = this.currentAreaContainerXPosition;
  +        w = area.getContentWidth();
  +        h = area.getContentHeight();
  +        int ry = this.currentYPosition;
  +        ColorType bg = area.getBackgroundColor();
  +
  +        /*
  +
  +               // I'm not sure I should have to check for bg being null
  +               // but I do
  +               if ((bg != null) && (bg.alpha() == 0)) {
  +                   this.addRect(rx, ry, w, -h, new PDFColor(bg), new PDFColor(bg));
  +               }
  +
  +         */
  +        /*
  +
  +        // floats & footnotes stuff
  +        renderAreaContainer(area.getBeforeFloatReferenceArea());
  +         	renderAreaContainer(area.getFootnoteReferenceArea());
  +
  +         */
  +        // main reference area
  +        Enumeration e =
  +          area.getMainReferenceArea().getChildren().elements();
  +        while (e.hasMoreElements()) {
  +            Box b = (Box) e.nextElement();
  +            b.render(this); // span areas
  +        }
  +
  +        if (area.getPosition() != Position.STATIC) {
  +            this.currentYPosition = saveY;
  +            this.currentAreaContainerXPosition = saveX;
  +        } else
  +            this.currentYPosition -= area.getHeight();
  +
  +    }
  +
  +    private void doFrame(Area area) {
  +        int w, h;
  +        int rx = this.currentAreaContainerXPosition;
  +        w = area.getContentWidth();
  +
  +        if (area instanceof BlockArea)
  +            rx += ((BlockArea) area).getStartIndent();
  +
  +        h = area.getContentHeight();
  +        int ry = this.currentYPosition;
  +        ColorType bg = area.getBackgroundColor();
  +
  +        rx = rx - area.getPaddingLeft();
  +        ry = ry + area.getPaddingTop();
  +        w = w + area.getPaddingLeft() + area.getPaddingRight();
  +        h = h + area.getPaddingTop() + area.getPaddingBottom();
  +
  +        /*
  +        // I'm not sure I should have to check for bg being null
  +        // but I do
  +        if ((bg != null) && (bg.alpha() == 0)) {
  +        	this.addRect(rx, ry, w, -h,
  +        		 new PDFColor(bg),
  +        		 new PDFColor(bg));
  +    }
  +
  +         */
  +
  +        rx = rx - area.getBorderLeftWidth();
  +        ry = ry + area.getBorderTopWidth();
  +        w = w + area.getBorderLeftWidth() + area.getBorderRightWidth();
  +        h = h + area.getBorderTopWidth() + area.getBorderBottomWidth();
  +
  +        //Create a textrect with these dimensions.
  +        //The y co-ordinate is measured +ve downwards so subtract page-height
  +
  +        this.mifDoc.setTextRectProp(rx, pageHeight - ry, w, h);
  +
  +        /*
  +         BorderAndPadding bp = area.getBorderAndPadding();
  +         if (area.getBorderTopWidth() != 0)
  +           addLine(rx, ry, rx + w, ry, area.getBorderTopWidth(),
  +        		   new PDFColor(bp.getBorderColor(BorderAndPadding.TOP)));
  +         if (area.getBorderLeftWidth() != 0)
  +           addLine(rx, ry, rx, ry - h, area.getBorderLeftWidth(),
  +        		   new PDFColor(bp.getBorderColor(BorderAndPadding.LEFT)));
  +         if (area.getBorderRightWidth() != 0)
  +           addLine(rx + w, ry, rx + w, ry - h, area.getBorderRightWidth(),
  +        		   new PDFColor(bp.getBorderColor(BorderAndPadding.RIGHT)));
  +         if (area.getBorderBottomWidth() != 0)
  +           addLine(rx, ry - h, rx + w, ry - h, area.getBorderBottomWidth(),
  +        		   new PDFColor(bp.getBorderColor(BorderAndPadding.BOTTOM)));
  +         */
  +    }
  +
  +    public void renderSpanArea(SpanArea area) {
  +
  +        //A span maps to a textframe
  +
  +
  +        this.mifDoc.createTextRect(area.getColumnCount());
  +
  +        Enumeration e = area.getChildren().elements();
  +        while (e.hasMoreElements()) {
  +            Box b = (Box) e.nextElement();
  +            b.render(this); // column areas
  +        }
  +    }
  +
  +    /** render the given block area */
  +    public void renderBlockArea(BlockArea area) {
  +
  +        this.mifDoc.setBlockProp(area.getStartIndent(),
  +                                 area.getEndIndent());
  +        Enumeration e = area.getChildren().elements();
  +        while (e.hasMoreElements()) {
  +            Box b = (Box) e.nextElement();
  +            b.render(this);
  +        }
  +
  +    }
  +
  +    /** render the given display space */
  +    public void renderDisplaySpace(DisplaySpace space) {
  +
  +        int d = space.getSize();
  +        this.currentYPosition -= d;
  +
  +    }
  +
  +    /** render the given SVG area */
  +    public void renderSVGArea(SVGArea area) {}
  +
  +    /** render a foreign object area */
  +    public void renderForeignObjectArea(ForeignObjectArea area) {
  +    }
  +
  +    public void renderWordArea(WordArea area) {
  +        String s;
  +        s = area.getText();
  +        this.mifDoc.addToStream(s);
  +
  +        this.currentXPosition += area.getContentWidth();
  +    }
  +
  +    /** render the given image area */
  +    public void renderImageArea(ImageArea area) {
  +
  +        int x = this.currentAreaContainerXPosition + area.getXOffset();
  +        int y = this.currentYPosition;
  +        int w = area.getContentWidth();
  +        int h = area.getHeight();
  +
  +        this.currentYPosition -= h;
  +
  +        FopImage img = area.getImage();
  +        if (img instanceof SVGImage) {
  +            /* try {
  +                  SVGSVGElement svg =
  +                    ((SVGImage) img).getSVGDocument().getRootElement();
  +                  currentStream.add("ET\nq\n" + (((float) w) / 1000f) +
  +                                    " 0 0 " + (((float) h) / 1000f) + " " +
  +                                    (((float) x) / 1000f) + " " +
  +                                    (((float)(y - h)) / 1000f) + " cm\n");
  +                  //        renderSVG(svg, (int) x, (int) y);
  +                  currentStream.add("Q\nBT\n");
  +              } catch (FopImageException e) {
  +              } */
  +
  +            MessageHandler.logln("Warning: SVG images not supported in this version");
  +        } else {
  +            String url = img.getURL();
  +            this.mifDoc.addImage(url, x, pageHeight - y, w, h);
  +
  +        }
  +    }
  +
  +    /** render the given inline area */
  +    public void renderInlineArea(InlineArea area) {}
  +
  +    /** render the given inline space */
  +    public void renderInlineSpace(InlineSpace space) {
  +
  +        // I dont need the size of space! I just need to
  +        // leave a blank space each time
  +        String s = " ";
  +        this.mifDoc.addToStream(s); // cool!
  +        this.currentXPosition += space.getSize();
  +    }
  +
  +    /** render the given line area */
  +    public void renderLineArea(LineArea area) {
  +
  +        int rx = this.currentAreaContainerXPosition + area.getStartIndent();
  +        int ry = this.currentYPosition;
  +        int w = area.getContentWidth();
  +        int h = area.getHeight();
  +
  +        this.currentYPosition -= area.getPlacementOffset();
  +        this.currentXPosition = rx;
  +
  +        int bl = this.currentYPosition;
  +
  +        //The start of a new linearea corresponds to a new para in FM
  +
  +        this.mifDoc.startLine();
  +
  +        Enumeration e = area.getChildren().elements();
  +        while (e.hasMoreElements()) {
  +
  +            Box b = (Box) e.nextElement();
  +            this.currentYPosition = ry - area.getPlacementOffset();
  +            b.render(this);
  +
  +        }
  +        this.currentYPosition = ry - h;
  +        this.currentXPosition = rx;
  +
  +    }
  +
  +    /** render the given page */
  +    public void renderPage(Page page) {
  +
  +        AreaContainer before, after;
  +        BodyAreaContainer body;
  +        body = page.getBody();
  +        before = page.getBefore();
  +        after = page.getAfter();
  +
  +        this.currentFontName = "";
  +        this.currentFontSize = "0";
  +
  +        pageHeight = page.getHeight();
  +        pageWidth = page.getWidth();
  +        this.mifDoc.setDocumentHeightWidth(pageHeight, pageWidth);
  +
  +        this.mifDoc.createPage();
  +
  +        renderBodyAreaContainer(body);
  +
  +
  +        // If the area is an instance of anything other than body, it goes into the
  +        // corresponding master page.
  +
  +
  +        if (before != null) {
  +
  +            this.mifDoc.createTextRect(1); // Create a rect with one col
  +            renderAreaContainer(before);
  +        }
  +
  +        if (after != null) {
  +
  +            this.mifDoc.createTextRect(1); // Create a rect with one col
  +            renderAreaContainer(after);
  +        }
  +
  +    }
  +
  +    /** render the given leader area */
  +    public void renderLeaderArea(LeaderArea area) {}
  +
  +}
  
  
  
  1.7       +739 -778  xml-fop/src/org/apache/fop/render/pcl/PCLRenderer.java
  
  Index: PCLRenderer.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/render/pcl/PCLRenderer.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- PCLRenderer.java	2001/05/20 23:55:57	1.6
  +++ PCLRenderer.java	2001/07/04 12:41:07	1.7
  @@ -1,778 +1,739 @@
  -/* $Id: PCLRenderer.java,v 1.6 2001/05/20 23:55:57 arved 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 com.eastpoint.chrysalis;
  -package org.apache.fop.render.pcl;
  -
  -// FOP
  -import org.apache.fop.render.PrintRenderer;
  -import org.apache.fop.messaging.MessageHandler;
  -import org.apache.fop.image.ImageArea;
  -import org.apache.fop.image.FopImage;
  -import org.apache.fop.apps.FOPException;
  -import org.apache.fop.fo.properties.*;
  -import org.apache.fop.datatypes.*;
  -import org.apache.fop.pdf.PDFPathPaint;
  -import org.apache.fop.pdf.PDFColor;
  -import org.apache.fop.layout.*;
  -import org.apache.fop.layout.inline.*;
  -import org.apache.fop.image.*;
  -
  -import org.apache.fop.svg.SVGArea;
  -import org.w3c.dom.svg.SVGSVGElement;
  -import org.w3c.dom.svg.SVGDocument;
  -
  -
  -// Java
  -import java.io.IOException;
  -import java.io.OutputStream;
  -import java.util.Enumeration;
  -
  -/**
  - * Renderer that renders areas to PCL
  -
  -	Created by Arthur E Welch III while at M&I EastPoint Technology
  -	Donated by EastPoint to the Apache FOP project March 2, 2001.
  - */
  -public class PCLRenderer extends PrintRenderer
  -{
  -    /** the current stream to add PCL commands to */
  -    public PCLStream currentStream;
  -
  -	private int pageHeight = 7920;
  -
  -	// These variables control the virtual paggination functionality.
  -	public int	curdiv = 0;
  -	private int	divisions = -1;
  -	public int	paperheight = -1;	// Paper height in decipoints?
  -	public int	orientation = -1;	// -1=default/unknown, 0=portrait, 1=landscape.
  -	public int	topmargin = -1;	// Top margin in decipoints?
  -	public int	leftmargin = -1;	// Left margin in decipoints?
  -	private int fullmargin = 0;
  -	private final boolean debug = false;
  -
  -	private int xoffset = -180;	// X Offset to allow for PCL implicit 1/4" left margin.
  -
  -	private java.util.Hashtable options;
  -	
  -	/**
  -	 * Create the PCL renderer
  -	 */
  -	public PCLRenderer()
  -	{
  -	}
  -
  -	/** set up renderer options */
  -	public void setOptions(java.util.Hashtable options) {
  -		this.options = options;
  -	}
  -	
  -    /**
  -       * set the PCL document's producer
  -       *
  -       * @param producer string indicating application producing PCL
  -       */
  -    public void setProducer(String producer)
  -    {
  -    }
  -
  -    /**
  -     * render the areas into PCL
  -     *
  -     * @param areaTree the laid-out area tree
  -     * @param stream the Outputstream to write the PCL to
  -     */
  -    public void render(AreaTree areaTree, OutputStream stream) throws IOException, FOPException
  -    {
  -		MessageHandler.logln("rendering areas to PCL");
  -		idReferences=areaTree.getIDReferences();
  -		//this.pdfResources = this.pdfDoc.getResources();
  -		//this.pdfDoc.setIDReferences(idReferences);
  -		Enumeration e = areaTree.getPages().elements();
  -
  -		currentStream = new PCLStream(stream);
  -
  -		// Set orientation.
  -		if ( orientation > -1 )
  -			currentStream.add("\033&l" + orientation + "O");
  -		else
  -			currentStream.add("\033&l0O");
  -		if ( orientation == 1 || orientation == 3 )
  -			xoffset = -144;
  -		else
  -			xoffset = -180;
  -
  -		// Reset the margins.
  -		currentStream.add("\033" + "9\033&l0E");
  -
  -
  -		while (e.hasMoreElements())
  -		{
  -		    this.renderPage((Page) e.nextElement());
  -		}
  -        if ( !idReferences.isEveryIdValid() )
  -        {
  -            //throw new FOPException("The following id's were referenced but not found: "+idReferences.getInvalidIds()+"\n");
  -            MessageHandler.errorln("Warning: The following id's were referenced but not found: "+idReferences.getInvalidIds() + "\n");
  -        }
  -
  -        MessageHandler.logln("writing out PCL");
  -		stream.flush();
  -    }
  -
  -    /**
  -       * add a line to the current stream
  -       *
  -       * @param x1 the start x location in millipoints
  -       * @param y1 the start y location in millipoints
  -       * @param x2 the end x location in millipoints
  -       * @param y2 the end y location in millipoints
  -       * @param th the thickness in millipoints
  -       * @param stroke the line color
  -       */
  -    protected void addLine(int x1, int y1, int x2, int y2, int th,
  -                           PDFPathPaint stroke)
  -    {
  -		if ( x1 == x2 )
  -			addRect(x1 - (th/2), y1, th, y2 - y1 + 1, stroke, stroke);
  -		else if ( y1 == y2 )
  -			addRect(x1, y1 + (th/2), x2 - x1 + 1, th, stroke, stroke);
  -    }
  -
  -    /**
  -      * add a line to the current stream
  -      *
  -      * @param x1 the start x location in millipoints
  -      * @param y1 the start y location in millipoints
  -      * @param x2 the end x location in millipoints
  -      * @param y2 the end y location in millipoints
  -      * @param th the thickness in millipoints
  -      * @param rs the rule style
  -      * @param stroke the line color
  -      */
  -    protected void addLine(int x1, int y1, int x2, int y2, int th,
  -                           int rs, PDFPathPaint stroke)
  -    {
  -		int	dashon = 0;
  -		int	dashoff = 0;
  -		//if ( rs != null && rs.length() > 5 && rs.charAt(0) == '[' && rs.charAt(1) != ']' && rs.charAt(4) == ']' )
  -		//{
  -		//	dashon = rs.charAt(1) - '0';
  -		//	dashoff = rs.charAt(3) - '0';
  -		//}
  -        switch (rs)
  -        {
  -            case org.apache.fop.fo.properties.RuleStyle.DASHED:
  -				dashon = 3;
  -				dashoff = 3;
  -                break;
  -            case org.apache.fop.fo.properties.RuleStyle.DOTTED:
  -				dashon = 1;
  -				dashoff = 3;
  -                break;
  -		}
  -		if ( x1 == x2 )
  -		{
  -			if ( dashon > 0 && dashoff > 0 )
  -			{
  -				int	start = y1;
  -				int	len = th * dashon;
  -				while ( start < y2 )
  -				{
  -					if ( start + len > y2 )
  -						len = y2 - start;
  -					addRect(x1 - (th/2), start, th, len, stroke, stroke);
  -					start += (len + dashoff * th);
  -				}
  -			}
  -			else
  -				addRect(x1 - (th/2), y1, th, y2 - y1 + 1, stroke, stroke);
  -		}
  -		else if ( y1 == y2 )
  -		{
  -			if ( dashon > 0 && dashoff > 0 )
  -			{
  -				int	start = x1;
  -				int	len = th * dashon;
  -				while ( start < x2 )
  -				{
  -					if ( start + len > x2 )
  -						len = x2 - start;
  -					addRect(start, y1 + (th/2), len, th, stroke, stroke);
  -					start += (len + dashoff * th);
  -				}
  -			}
  -			else
  -				addRect(x1, y1 + (th/2), x2 - x1 + 1, th, stroke, stroke);
  -		}
  -    }
  -
  -    /**
  -       * add a rectangle to the current stream
  -       *
  -       * @param x the x position of left edge in millipoints
  -       * @param y the y position of top edge in millipoints
  -       * @param w the width in millipoints
  -       * @param h the height in millipoints
  -       * @param stroke the stroke color/gradient
  -       */
  -    protected void addRect(int x, int y, int w, int h,
  -                           PDFPathPaint stroke)
  -    {
  -		if ( h < 0 )
  -			h *= -1;
  -
  -		if (h < 720 || w < 720)
  -		{
  -			if ( w < 720 )
  -				w = 720;
  -			if ( h < 720 )
  -				h = 720;
  -		    addRect(x, y, w, h, stroke, stroke);
  -		}
  -		else
  -		{
  -		    addRect(x, y, w, 720, stroke, stroke);
  -		    addRect(x, y, 720, h, stroke, stroke);
  -		    addRect(x + w - 720, y, 720, h, stroke, stroke);
  -		    addRect(x, y - h + 720, w, 720, stroke, stroke);
  -		}
  -    }
  -
  -    /**
  -       * add a filled rectangle to the current stream
  -       *
  -       * @param x the x position of left edge in millipoints
  -       * @param y the y position of top edge in millipoints
  -       * @param w the width in millipoints
  -       * @param h the height in millipoints
  -       * @param fill the fill color/gradient
  -       * @param stroke the stroke color/gradient
  -       */
  -    protected void addRect(int x, int y, int w, int h,
  -                           PDFPathPaint stroke, PDFPathPaint fill)
  -    {
  -		if ((w == 0) || (h == 0))
  -	    	return;
  -		if ( h < 0 )
  -			h *= -1;
  -
  -		PDFColor sc = (PDFColor)stroke;
  -		PDFColor fc = (PDFColor)fill;
  -
  -		sc.setColorSpace(ColorSpace.DEVICE_RGB);
  -		fc.setColorSpace(ColorSpace.DEVICE_RGB);
  -
  -		int	lineshade = (int)(100 - ((0.3f * sc.red() + 0.59f * sc.green() + 0.11f * sc.blue()) * 100f));
  -		int	fillshade = (int)(100 - ((0.3f * fc.red() + 0.59f * fc.green() + 0.11f * fc.blue()) * 100f));
  -
  -		int xpos = xoffset + (x / 100);
  -		if ( xpos < 0 )
  -		{
  -			xpos = 0;
  -			MessageHandler.errorln("PCLRenderer.addRect() WARNING: Horizontal position out of bounds.");
  -		}
  -
  -		currentStream.add("\033*v1O\033&a" + xpos + "h" + (pageHeight - (y / 100)) + "V"
  -							+ "\033*c" + (w / 100) + "h" + (h / 100) + "V"
  -							+ "\033*c" + lineshade + "G"
  -							+ "\033*c2P");
  -		if ( fillshade != lineshade && (w >= 720 || h >= 720) )
  -		{
  -			xpos = xoffset + ((x + 240) / 100);
  -			if ( xpos < 0 )
  -			{
  -				xpos = 0;
  -				MessageHandler.errorln("PCLRenderer.addRect() WARNING: Horizontal position out of bounds.");
  -			}
  -			currentStream.add("\033&a" + xpos + "h" + (pageHeight - ((y + 240)) / 100) + "V"
  -								+ "\033*c" + ((w - 480) / 100) + "h" + ((h - 480) / 100) + "V"
  -								+ "\033*c" + fillshade + "G"
  -								+ "\033*c2P");
  -		}
  -		// Reset pattern transparency mode.
  -		currentStream.add("\033*v0O");
  -    }
  -
  -	boolean printBMP(FopImage img, int x, int y, int w, int h) throws FopImageException
  -	{
  -		// Print the passed image file in PCL.
  -		byte imgmap[] = img.getBitmaps();
  -
  -		int	ix = 0;
  -		int iy = 0;
  -		int	indx = 0;
  -		int	iw = img.getWidth();
  -		int	ih = img.getHeight();
  -		int	bytewidth = (iw / 8);
  -		if ( (iw % 8) != 0 )
  -			bytewidth++;
  -		byte	ib;
  -		char	ic[] = new char[bytewidth * 2];
  -		char	icu[] = new char[bytewidth];
  -		int	lastcount = -1;
  -		byte lastbyte = 0;
  -		int	icwidth = 0;
  -		int	cr = 0;
  -		int	cg = 0;
  -		int	cb = 0;
  -		int	grey = 0;
  -		boolean iscolor = img.getColorSpace().getColorSpace() != ColorSpace.DEVICE_GRAY;
  -		int dcount = 0;
  -		int xres = (iw * 72000) / w;
  -		int yres = (ih * 72000) / h;
  -		int	resolution = xres;
  -		if ( yres > xres )
  -			resolution = yres;
  -
  -		if ( resolution > 300 )
  -			resolution = 600;
  -		else if ( resolution > 150 )
  -			resolution = 300;
  -		else if ( resolution > 100 )
  -			resolution = 150;
  -		else if ( resolution > 75 )
  -			resolution = 100;
  -		else
  -			resolution = 75;
  -if ( debug )
  -System.out.println("PCLRenderer.printBMP() iscolor = " + iscolor);
  -		// Setup for graphics
  -		currentStream.add("\033*t" + resolution + "R\033*r0F\033*r1A");
  -
  -		// Transfer graphics data
  -		for ( iy = 0 ; iy < ih ; iy++ )
  -		{
  -			ib = 0;
  -			//int	padding = iw % 8;
  -			//if ( padding != 0 )
  -			//	padding = 8 - padding;
  -			//padding = 0;
  -			//indx = (ih - iy - 1 + padding) * iw;
  -			indx = iy * iw;
  -			if ( iscolor )
  -				indx *= 3;
  -			//currentStream.add("\033*b" + bytewidth + "W");
  -			for ( ix = 0 ; ix < iw ; ix++ )
  -			{
  -				if ( iscolor )
  -				{
  -					cr = imgmap[indx++] & 0xFF;
  -					cg = imgmap[indx++] & 0xFF;
  -					cb = imgmap[indx++] & 0xFF;
  -					grey = (cr * 30 + cg * 59 + cb * 11) / 100;
  -				}
  -				else
  -					grey = imgmap[indx++] & 0xFF;
  -				if ( grey < 128 )
  -					ib |= (1 << (7 - (ix % 8)));
  -				if ( (ix % 8) == 7 || ((ix + 1) == iw))
  -				{
  -					if ( icwidth < bytewidth )
  -					{
  -						if ( lastcount >= 0 )
  -						{
  -							if ( ib == lastbyte )
  -								lastcount++;
  -							else
  -							{
  -								ic[icwidth++] = (char)(lastcount & 0xFF);
  -								ic[icwidth++] = (char)lastbyte;
  -								lastbyte = ib;
  -								lastcount = 0;
  -							}
  -						}
  -						else
  -						{
  -							lastbyte = ib;
  -							lastcount = 0;
  -						}
  -						if ( lastcount == 255 || ((ix + 1) == iw) )
  -						{
  -							ic[icwidth++] = (char)(lastcount & 0xFF);
  -							ic[icwidth++] = (char)lastbyte;
  -							lastbyte = 0;
  -							lastcount = -1;
  -						}
  -					}
  -					icu[ix / 8] = (char)ib;
  -					ib = 0;
  -				}
  -			}
  -			if ( icwidth < bytewidth )
  -			{
  -				currentStream.add("\033*b1m" + icwidth + "W");
  -				currentStream.add(new String(ic, 0, icwidth));
  -			}
  -			else
  -			{
  -				currentStream.add("\033*b0m" + bytewidth + "W");
  -				currentStream.add(new String(icu));
  -			}
  -			lastcount = -1;
  -			icwidth = 0;
  -		}
  -
  -		// End graphics
  -		currentStream.add("\033*rB");
  -
  -
  -		return(true);
  -	}
  -
  -    /**
  -     * render image area to PCL
  -     *
  -     * @param area the image area to render
  -     */
  -    public void renderImageArea(ImageArea area)
  -    {
  -		int x = this.currentAreaContainerXPosition + area.getXOffset();
  -		int y = this.currentYPosition;
  -		int w = area.getContentWidth();
  -		int h = area.getHeight();
  -
  -		this.currentYPosition -= h;
  -
  -		FopImage img = area.getImage();
  -
  -		int xpos = xoffset + (x / 100);
  -		if ( xpos < 0 )
  -		{
  -			xpos = 0;
  -			MessageHandler.errorln("PCLRenderer.renderImageArea() WARNING: Horizontal position out of bounds.");
  -		}
  -
  -		currentStream.add("\033&a" + xpos + "h" + (pageHeight - (y / 100)) + "V");
  -
  -		try
  -		{
  -			printBMP(img, x, y, w, h);
  -		}
  -		catch ( FopImageException e )
  -		{
  -			//e.printStackTrace(System.out);
  -			MessageHandler.errorln("PCLRenderer.renderImageArea() Error printing BMP (" + e.toString() + ")");
  -		}
  -    }
  -
  -    /** render a foreign object area */
  -    public void renderForeignObjectArea(ForeignObjectArea area)
  -    {
  -        // if necessary need to scale and align the content
  -        this.currentXPosition = this.currentXPosition + area.getXOffset();
  -        this.currentYPosition = this.currentYPosition;
  -        switch (area.getAlign())
  -        {
  -            case TextAlign.START:
  -                break;
  -            case TextAlign.END:
  -                break;
  -            case TextAlign.CENTER:
  -            case TextAlign.JUSTIFY:
  -                break;
  -        }
  -        switch (area.getVerticalAlign())
  -        {
  -            case VerticalAlign.BASELINE:
  -                break;
  -            case VerticalAlign.MIDDLE:
  -                break;
  -            case VerticalAlign.SUB:
  -                break;
  -            case VerticalAlign.SUPER:
  -                break;
  -            case VerticalAlign.TEXT_TOP:
  -                break;
  -            case VerticalAlign.TEXT_BOTTOM:
  -                break;
  -            case VerticalAlign.TOP:
  -                break;
  -            case VerticalAlign.BOTTOM:
  -                break;
  -        }
  -        // in general the content will not be text
  -
  -        // align and scale
  -
  -        switch (area.scalingMethod())
  -        {
  -            case Scaling.UNIFORM:
  -                break;
  -            case Scaling.NON_UNIFORM:
  -                break;
  -        }
  -        // if the overflow is auto (default), scroll or visible
  -        // then the contents should not be clipped, since this
  -        // is considered a printing medium.
  -        switch (area.getOverflow())
  -        {
  -            case Overflow.VISIBLE:
  -            case Overflow.SCROLL:
  -            case Overflow.AUTO:
  -                break;
  -            case Overflow.HIDDEN:
  -                break;
  -        }
  -        area.getObject().render(this);
  -
  -        this.currentXPosition += area.getEffectiveWidth();
  -    //    this.currentYPosition -= area.getEffectiveHeight();
  -    }
  -
  -    /**
  -     * render SVG area to PCL
  -     *
  -     * @param area the SVG area to render
  -     */
  -	public void renderSVGArea(SVGArea area)
  -	{
  -if ( debug )
  -System.out.println("PCLRenderer.renderSVGArea(" + area + ")");
  -        int x = this.currentXPosition;
  -        int y = this.currentYPosition;
  -        SVGSVGElement svg = ((SVGDocument)area.getSVGDocument()).getRootElement();
  -        int w = (int)(svg.getWidth().getBaseVal().getValue() * 1000);
  -        int h = (int)(svg.getHeight().getBaseVal().getValue() * 1000);
  -
  -        /*
  -         * Clip to the svg area.
  -         * Note: To have the svg overlay (under) a text area then use
  -         * an fo:block-container
  -         */
  -
  -        // TODO - translate and clip to viewbox
  -
  -        //currentStream.add(svgRenderer.getString());
  -
  -        //currentStream.add("Q\n");
  -	}
  -
  -	public void setFont(String name, float size)
  -	{
  -		int	fontcode = 0;
  -		if ( name.length() > 1 && name.charAt(0) == 'F' )
  -		{
  -			try
  -			{
  -				fontcode = Integer.parseInt(name.substring(1));
  -			}
  -			catch (Exception e)
  -			{
  -				e.printStackTrace();
  -			}
  -		}
  -		switch (fontcode)
  -		{
  -			case	1:	// F1 = Helvetica
  -				//currentStream.add("\033(8U\033(s1p" + (size / 1000) + "v0s0b24580T");
  -				// Arial is more common among PCL5 printers than Helvetica - so use Arial
  -				currentStream.add("\033(0N\033(s1p" + (size / 1000) + "v0s0b16602T");
  -				break;
  -			case	2:	// F2 = Helvetica Oblique
  -				currentStream.add("\033(0N\033(s1p" + (size / 1000) + "v1s0b16602T");
  -				break;
  -			case	3:	// F3 = Helvetica Bold
  -				currentStream.add("\033(0N\033(s1p" + (size / 1000) + "v0s3b16602T");
  -				break;
  -			case	4:	// F4 = Helvetica Bold Oblique
  -				currentStream.add("\033(0N\033(s1p" + (size / 1000) + "v1s3b16602T");
  -				break;
  -			case	5:	// F5 = Times Roman
  -				//currentStream.add("\033(8U\033(s1p" + (size / 1000) + "v0s0b25093T");
  -				// Times New is more common among PCL5 printers than Times - so use Times New
  -				currentStream.add("\033(0N\033(s1p" + (size / 1000) + "v0s0b16901T");
  -				break;
  -			case	6:	// F6 = Times Italic
  -				currentStream.add("\033(0N\033(s1p" + (size / 1000) + "v1s0b16901T");
  -				break;
  -			case	7:	// F7 = Times Bold
  -				currentStream.add("\033(0N\033(s1p" + (size / 1000) + "v0s3b16901T");
  -				break;
  -			case	8:	// F8 = Times Bold Italic
  -				currentStream.add("\033(0N\033(s1p" + (size / 1000) + "v1s3b16901T");
  -				break;
  -			case	9:	// F9 = Courier
  -				currentStream.add("\033(0N\033(s0p" + (120.01f / (size / 1000.00f)) + "h0s0b4099T");
  -				break;
  -			case	10:	// F10 = Courier Oblique
  -				currentStream.add("\033(0N\033(s0p" + (120.01f / (size / 1000.00f)) + "h1s0b4099T");
  -				break;
  -			case	11:	// F11 = Courier Bold
  -				currentStream.add("\033(0N\033(s0p" + (120.01f / (size / 1000.00f)) + "h0s3b4099T");
  -				break;
  -			case	12:	// F12 = Courier Bold Oblique
  -				currentStream.add("\033(0N\033(s0p" + (120.01f / (size / 1000.00f)) + "h1s3b4099T");
  -				break;
  -			case	13:	// F13 = Symbol
  -				currentStream.add("\033(19M\033(s1p" + (size / 1000) + "v0s0b16686T");
  -				//currentStream.add("\033(9U\033(s1p" + (size / 1000) + "v0s0b25093T"); // ECMA Latin 1 Symbol Set in Times Roman???
  -				break;
  -			case	14:	// F14 = Zapf Dingbats
  -				currentStream.add("\033(14L\033(s1p" + (size / 1000) + "v0s0b45101T");
  -				break;
  -			default:
  -				currentStream.add("\033(0N\033(s" + (size / 1000) + "V");
  -				break;
  -		}
  -	}
  -
  -    /**
  -     * render inline area to PCL
  -     *
  -     * @param area inline area to render
  -     */
  -    public void renderWordArea(WordArea area)
  -    {
  -		String name = area.getFontState().getFontName();
  -		int size = area.getFontState().getFontSize();
  -
  -		float red = area.getRed();
  -		float green = area.getGreen();
  -		float blue = area.getBlue();
  -        PDFColor theAreaColor = new PDFColor((double) area.getRed(),
  -                                             (double) area.getGreen(), (double) area.getBlue());
  -
  -		//currentStream.add("\033*c" + (int)(100 - ((0.3f * red + 0.59f * green + 0.11f * blue) * 100f)) + "G\033*v2T");
  -		currentStream.add("\033*v1O\033*c" + (int)(100 - ((0.3f * red + 0.59f * green + 0.11f * blue) * 100f)) + "G\033*v2T");
  -
  -		if ((!name.equals(this.currentFontName)) || (size != this.currentFontSize))
  -		{
  -		    this.currentFontName = name;
  -		    this.currentFontSize = size;
  -			setFont(name, size);
  -		}
  -
  -		this.currentFill = theAreaColor;
  -
  -		int rx = this.currentXPosition;
  -		int bl = this.currentYPosition;
  -
  -		String s;
  -		if ( area.getPageNumberID()!=null )
  -		{
  -			// this text is a page number, so resolve it
  -		    s = idReferences.getPageNumber(area.getPageNumberID());            
  -		    if(s==null)
  -		        s="";
  -		}
  -		else
  -		{
  -		    s = area.getText();
  -		}
  -
  -		addWordLines(area, rx, bl, size, theAreaColor);
  -
  -		int xpos = xoffset + (rx / 100);
  -		if ( xpos < 0 )
  -		{
  -			xpos = 0;
  -			MessageHandler.errorln("PCLRenderer.renderWordArea() WARNING: Horizontal position out of bounds.");
  -		}
  -		currentStream.add("\033&a" + xpos + "h" + (pageHeight - (bl / 100)) + "V" + s);
  -
  -		this.currentXPosition += area.getContentWidth();
  -    }
  -
  -    /**
  -     * render page into PCL
  -     *
  -     * @param page page to render
  -     */
  -    public void renderPage(Page page)
  -    {
  -if ( debug )
  -System.out.println("PCLRenderer.renderPage() page.Height() = " + page.getHeight());
  -		BodyAreaContainer body;
  -		AreaContainer before, after, start, end;
  -
  -		if ( paperheight > 0 && divisions == -1 )
  -			divisions = paperheight / (page.getHeight() / 100);
  -
  -if ( debug )
  -System.out.println("PCLRenderer.renderPage() paperheight=" + paperheight + " divisions=" + divisions);
  -
  -		// Set top margin.
  -		//float fullmargin = 0;
  -		if ( divisions > 0 )
  -			fullmargin = paperheight * curdiv / divisions;
  -		if ( topmargin > 0 )
  -			fullmargin += topmargin;
  -if ( debug )
  -System.out.println("PCLRenderer.renderPage() curdiv=" + curdiv + " fullmargin=" + fullmargin);
  -		//if ( fullmargin > 0 )
  -		//	currentStream.add("\033&l" + (fullmargin / 15f) + "c1e8C");
  -		//this.currentYPosition = fullmargin * 100;
  -
  -		if ( paperheight > 0 )
  -			pageHeight = (paperheight / divisions) + fullmargin;
  -		else
  -			pageHeight = page.getHeight() / 100;
  -if ( debug )
  -System.out.println("PCLRenderer.renderPage() Set currentYPosition=" + this.currentYPosition);
  -		if ( leftmargin > 0 && curdiv == 0 )
  -			currentStream.add("\033&k" + (leftmargin / 6f) + "H\033&a1L\033&k12H");
  -	      
  -		body = page.getBody();
  -		before = page.getBefore();
  -		after = page.getAfter();
  -		start = page.getStart();
  -		end = page.getEnd();
  -
  -		this.currentFontName = "";
  -		this.currentFontSize = 0;
  -
  -		renderBodyAreaContainer(body);
  -
  -		if (before != null)
  -		    renderAreaContainer(before);
  -
  -		if (after != null)
  -		    renderAreaContainer(after);
  -		
  -		if (start != null)
  -		    renderAreaContainer(start);
  -
  -		if (end != null)
  -		    renderAreaContainer(end);
  -
  -		// End page.
  -		if ( ++curdiv == divisions || divisions == -1 )
  -		{
  -			curdiv = 0;
  -			currentStream.add("\f");
  -		}
  -
  -		// Links, etc not implemented...
  -		/*
  -		currentPage = this.pdfDoc.makePage(this.pdfResources, currentStream,
  -					 page.getWidth()/1000, page.getHeight()/1000, page);
  -
  -		if (page.hasLinks()) {
  -			currentAnnotList = this.pdfDoc.makeAnnotList();
  -			currentPage.setAnnotList(currentAnnotList);
  -
  -			Enumeration e = page.getLinkSets().elements();
  -			while (e.hasMoreElements()) {
  -			LinkSet linkSet = (LinkSet) e.nextElement();
  -
  -			linkSet.align();
  -			String dest = linkSet.getDest();
  -	                int linkType = linkSet.getLinkType();
  -			Enumeration f = linkSet.getRects().elements();
  -			while (f.hasMoreElements()) {
  -				LinkedRectangle lrect = (LinkedRectangle) f.nextElement();
  -				currentAnnotList.addLink(
  -					this.pdfDoc.makeLink(lrect.getRectangle(), dest, linkType));
  -			}
  -			}
  -		} else {
  -			// just to be on the safe side
  -			currentAnnotList = null;
  -		}
  -		*/
  -    }
  -}
  +/* $Id: PCLRenderer.java,v 1.7 2001/07/04 12:41:07 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.render.pcl;
  +
  +// FOP
  +import org.apache.fop.render.PrintRenderer;
  +import org.apache.fop.messaging.MessageHandler;
  +import org.apache.fop.image.ImageArea;
  +import org.apache.fop.image.FopImage;
  +import org.apache.fop.apps.FOPException;
  +import org.apache.fop.fo.properties.*;
  +import org.apache.fop.datatypes.*;
  +import org.apache.fop.pdf.PDFPathPaint;
  +import org.apache.fop.pdf.PDFColor;
  +import org.apache.fop.layout.*;
  +import org.apache.fop.layout.inline.*;
  +import org.apache.fop.image.*;
  +
  +import org.apache.fop.svg.SVGArea;
  +import org.w3c.dom.svg.SVGSVGElement;
  +import org.w3c.dom.svg.SVGDocument;
  +
  +
  +// Java
  +import java.io.IOException;
  +import java.io.OutputStream;
  +import java.util.Enumeration;
  +
  +/**
  + * Renderer that renders areas to PCL
  +
  +	Created by Arthur E Welch III while at M&I EastPoint Technology
  +	Donated by EastPoint to the Apache FOP project March 2, 2001.
  + */
  +public class PCLRenderer extends PrintRenderer {
  +    /** the current stream to add PCL commands to */
  +    public PCLStream currentStream;
  +
  +    private int pageHeight = 7920;
  +
  +    // These variables control the virtual paggination functionality.
  +    public int curdiv = 0;
  +    private int divisions = -1;
  +    public int paperheight = -1; // Paper height in decipoints?
  +    public int orientation = -1; // -1=default/unknown, 0=portrait, 1=landscape.
  +    public int topmargin = -1; // Top margin in decipoints?
  +    public int leftmargin = -1; // Left margin in decipoints?
  +    private int fullmargin = 0;
  +    private final boolean debug = false;
  +
  +    private int xoffset = -180; // X Offset to allow for PCL implicit 1/4" left margin.
  +
  +    private java.util.Hashtable options;
  +
  +    /**
  +     * Create the PCL renderer
  +     */
  +    public PCLRenderer() {
  +    }
  +
  +    /** set up renderer options */
  +    public void setOptions(java.util.Hashtable options) {
  +        this.options = options;
  +    }
  +
  +    /**
  +     * set the PCL document's producer
  +     *
  +     * @param producer string indicating application producing PCL
  +     */
  +    public void setProducer(String producer) {
  +    }
  +
  +    /**
  +     * render the areas into PCL
  +     *
  +     * @param areaTree the laid-out area tree
  +     * @param stream the Outputstream to write the PCL to
  +     */
  +    public void render(AreaTree areaTree,
  +                       OutputStream stream) throws IOException, FOPException {
  +        MessageHandler.logln("rendering areas to PCL");
  +        idReferences = areaTree.getIDReferences();
  +        //this.pdfResources = this.pdfDoc.getResources();
  +        //this.pdfDoc.setIDReferences(idReferences);
  +        Enumeration e = areaTree.getPages().elements();
  +
  +        currentStream = new PCLStream(stream);
  +
  +        // Set orientation.
  +        if (orientation > -1)
  +            currentStream.add("\033&l" + orientation + "O");
  +        else
  +            currentStream.add("\033&l0O");
  +        if (orientation == 1 || orientation == 3)
  +            xoffset = -144;
  +        else
  +            xoffset = -180;
  +
  +        // Reset the margins.
  +        currentStream.add("\033" + "9\033&l0E");
  +
  +
  +        while (e.hasMoreElements()) {
  +            this.renderPage((Page) e.nextElement());
  +        }
  +        if (!idReferences.isEveryIdValid()) {
  +            //throw new FOPException("The following id's were referenced but not found: "+idReferences.getInvalidIds()+"\n");
  +            MessageHandler.errorln("Warning: The following id's were referenced but not found: "+
  +                                   idReferences.getInvalidIds() + "\n");
  +        }
  +
  +        MessageHandler.logln("writing out PCL");
  +        stream.flush();
  +    }
  +
  +    /**
  +     * add a line to the current stream
  +     *
  +     * @param x1 the start x location in millipoints
  +     * @param y1 the start y location in millipoints
  +     * @param x2 the end x location in millipoints
  +     * @param y2 the end y location in millipoints
  +     * @param th the thickness in millipoints
  +     * @param stroke the line color
  +     */
  +    protected void addLine(int x1, int y1, int x2, int y2, int th,
  +                           PDFPathPaint stroke) {
  +        if (x1 == x2)
  +            addRect(x1 - (th / 2), y1, th, y2 - y1 + 1, stroke, stroke);
  +        else if (y1 == y2)
  +            addRect(x1, y1 + (th / 2), x2 - x1 + 1, th, stroke, stroke);
  +    }
  +
  +    /**
  +     * add a line to the current stream
  +     *
  +     * @param x1 the start x location in millipoints
  +     * @param y1 the start y location in millipoints
  +     * @param x2 the end x location in millipoints
  +     * @param y2 the end y location in millipoints
  +     * @param th the thickness in millipoints
  +     * @param rs the rule style
  +     * @param stroke the line color
  +     */
  +    protected void addLine(int x1, int y1, int x2, int y2, int th,
  +                           int rs, PDFPathPaint stroke) {
  +        int dashon = 0;
  +        int dashoff = 0;
  +        //if ( rs != null && rs.length() > 5 && rs.charAt(0) == '[' && rs.charAt(1) != ']' && rs.charAt(4) == ']' )
  +        //{
  +        //	dashon = rs.charAt(1) - '0';
  +        //	dashoff = rs.charAt(3) - '0';
  +        //}
  +        switch (rs) {
  +            case org.apache.fop.fo.properties.RuleStyle.DASHED:
  +                dashon = 3;
  +                dashoff = 3;
  +                break;
  +            case org.apache.fop.fo.properties.RuleStyle.DOTTED:
  +                dashon = 1;
  +                dashoff = 3;
  +                break;
  +        }
  +        if (x1 == x2) {
  +            if (dashon > 0 && dashoff > 0) {
  +                int start = y1;
  +                int len = th * dashon;
  +                while (start < y2) {
  +                    if (start + len > y2)
  +                        len = y2 - start;
  +                    addRect(x1 - (th / 2), start, th, len, stroke, stroke);
  +                    start += (len + dashoff * th);
  +                }
  +            } else
  +                addRect(x1 - (th / 2), y1, th, y2 - y1 + 1, stroke, stroke);
  +        } else if (y1 == y2) {
  +            if (dashon > 0 && dashoff > 0) {
  +                int start = x1;
  +                int len = th * dashon;
  +                while (start < x2) {
  +                    if (start + len > x2)
  +                        len = x2 - start;
  +                    addRect(start, y1 + (th / 2), len, th, stroke, stroke);
  +                    start += (len + dashoff * th);
  +                }
  +            } else
  +                addRect(x1, y1 + (th / 2), x2 - x1 + 1, th, stroke, stroke);
  +        }
  +    }
  +
  +    /**
  +     * add a rectangle to the current stream
  +     *
  +     * @param x the x position of left edge in millipoints
  +     * @param y the y position of top edge in millipoints
  +     * @param w the width in millipoints
  +     * @param h the height in millipoints
  +     * @param stroke the stroke color/gradient
  +     */
  +    protected void addRect(int x, int y, int w, int h,
  +                           PDFPathPaint stroke) {
  +        if (h < 0)
  +            h *= -1;
  +
  +        if (h < 720 || w < 720) {
  +            if (w < 720)
  +                w = 720;
  +            if (h < 720)
  +                h = 720;
  +            addRect(x, y, w, h, stroke, stroke);
  +        } else {
  +            addRect(x, y, w, 720, stroke, stroke);
  +            addRect(x, y, 720, h, stroke, stroke);
  +            addRect(x + w - 720, y, 720, h, stroke, stroke);
  +            addRect(x, y - h + 720, w, 720, stroke, stroke);
  +        }
  +    }
  +
  +    /**
  +     * add a filled rectangle to the current stream
  +     *
  +     * @param x the x position of left edge in millipoints
  +     * @param y the y position of top edge in millipoints
  +     * @param w the width in millipoints
  +     * @param h the height in millipoints
  +     * @param fill the fill color/gradient
  +     * @param stroke the stroke color/gradient
  +     */
  +    protected void addRect(int x, int y, int w, int h,
  +                           PDFPathPaint stroke, PDFPathPaint fill) {
  +        if ((w == 0) || (h == 0))
  +            return;
  +        if (h < 0)
  +            h *= -1;
  +
  +        PDFColor sc = (PDFColor) stroke;
  +        PDFColor fc = (PDFColor) fill;
  +
  +        sc.setColorSpace(ColorSpace.DEVICE_RGB);
  +        fc.setColorSpace(ColorSpace.DEVICE_RGB);
  +
  +        int lineshade = (int)(100 - ((0.3f * sc.red() + 0.59f * sc.green() +
  +                                      0.11f * sc.blue()) * 100f));
  +        int fillshade = (int)(100 - ((0.3f * fc.red() + 0.59f * fc.green() +
  +                                      0.11f * fc.blue()) * 100f));
  +
  +        int xpos = xoffset + (x / 100);
  +        if (xpos < 0) {
  +            xpos = 0;
  +            MessageHandler.errorln("PCLRenderer.addRect() WARNING: Horizontal position out of bounds.");
  +        }
  +
  +        currentStream.add("\033*v1O\033&a" + xpos + "h" +
  +                          (pageHeight - (y / 100)) + "V" + "\033*c" +
  +                          (w / 100) + "h" + (h / 100) + "V" + "\033*c" +
  +                          lineshade + "G" + "\033*c2P");
  +        if (fillshade != lineshade && (w >= 720 || h >= 720)) {
  +            xpos = xoffset + ((x + 240) / 100);
  +            if (xpos < 0) {
  +                xpos = 0;
  +                MessageHandler.errorln("PCLRenderer.addRect() WARNING: Horizontal position out of bounds.");
  +            }
  +            currentStream.add("\033&a" + xpos + "h" +
  +                              (pageHeight - ((y + 240)) / 100) + "V" +
  +                              "\033*c" + ((w - 480) / 100) + "h" +
  +                              ((h - 480) / 100) + "V" + "\033*c" + fillshade +
  +                              "G" + "\033*c2P");
  +        }
  +        // Reset pattern transparency mode.
  +        currentStream.add("\033*v0O");
  +    }
  +
  +    boolean printBMP(FopImage img, int x, int y, int w,
  +                     int h) throws FopImageException {
  +        // Print the passed image file in PCL.
  +        byte imgmap[] = img.getBitmaps();
  +
  +        int ix = 0;
  +        int iy = 0;
  +        int indx = 0;
  +        int iw = img.getWidth();
  +        int ih = img.getHeight();
  +        int bytewidth = (iw / 8);
  +        if ((iw % 8) != 0)
  +            bytewidth++;
  +        byte ib;
  +        char ic[] = new char[bytewidth * 2];
  +        char icu[] = new char[bytewidth];
  +        int lastcount = -1;
  +        byte lastbyte = 0;
  +        int icwidth = 0;
  +        int cr = 0;
  +        int cg = 0;
  +        int cb = 0;
  +        int grey = 0;
  +        boolean iscolor = img.getColorSpace().getColorSpace() !=
  +                          ColorSpace.DEVICE_GRAY;
  +        int dcount = 0;
  +        int xres = (iw * 72000) / w;
  +        int yres = (ih * 72000) / h;
  +        int resolution = xres;
  +        if (yres > xres)
  +            resolution = yres;
  +
  +        if (resolution > 300)
  +            resolution = 600;
  +        else if (resolution > 150)
  +            resolution = 300;
  +        else if (resolution > 100)
  +            resolution = 150;
  +        else if (resolution > 75)
  +            resolution = 100;
  +        else
  +            resolution = 75;
  +        if (debug)
  +            System.out.println("PCLRenderer.printBMP() iscolor = " +
  +                               iscolor);
  +        // Setup for graphics
  +        currentStream.add("\033*t" + resolution + "R\033*r0F\033*r1A");
  +
  +        // Transfer graphics data
  +        for (iy = 0 ; iy < ih ; iy++) {
  +            ib = 0;
  +            //int	padding = iw % 8;
  +            //if ( padding != 0 )
  +            //	padding = 8 - padding;
  +            //padding = 0;
  +            //indx = (ih - iy - 1 + padding) * iw;
  +            indx = iy * iw;
  +            if (iscolor)
  +                indx *= 3;
  +            //currentStream.add("\033*b" + bytewidth + "W");
  +            for (ix = 0 ; ix < iw ; ix++) {
  +                if (iscolor) {
  +                    cr = imgmap[indx++] & 0xFF;
  +                    cg = imgmap[indx++] & 0xFF;
  +                    cb = imgmap[indx++] & 0xFF;
  +                    grey = (cr * 30 + cg * 59 + cb * 11) / 100;
  +                } else
  +                    grey = imgmap[indx++] & 0xFF;
  +                if (grey < 128)
  +                    ib |= (1 << (7 - (ix % 8)));
  +                if ((ix % 8) == 7 || ((ix + 1) == iw)) {
  +                    if (icwidth < bytewidth) {
  +                        if (lastcount >= 0) {
  +                            if (ib == lastbyte)
  +                                lastcount++;
  +                            else {
  +                                ic[icwidth++] = (char)(lastcount & 0xFF);
  +                                ic[icwidth++] = (char) lastbyte;
  +                                lastbyte = ib;
  +                                lastcount = 0;
  +                            }
  +                        } else {
  +                            lastbyte = ib;
  +                            lastcount = 0;
  +                        }
  +                        if (lastcount == 255 || ((ix + 1) == iw)) {
  +                            ic[icwidth++] = (char)(lastcount & 0xFF);
  +                            ic[icwidth++] = (char) lastbyte;
  +                            lastbyte = 0;
  +                            lastcount = -1;
  +                        }
  +                    }
  +                    icu[ix / 8] = (char) ib;
  +                    ib = 0;
  +                }
  +            }
  +            if (icwidth < bytewidth) {
  +                currentStream.add("\033*b1m" + icwidth + "W");
  +                currentStream.add(new String(ic, 0, icwidth));
  +            } else {
  +                currentStream.add("\033*b0m" + bytewidth + "W");
  +                currentStream.add(new String(icu));
  +            }
  +            lastcount = -1;
  +            icwidth = 0;
  +        }
  +
  +        // End graphics
  +        currentStream.add("\033*rB");
  +
  +
  +        return(true);
  +    }
  +
  +    /**
  +     * render image area to PCL
  +     *
  +     * @param area the image area to render
  +     */
  +    public void renderImageArea(ImageArea area) {
  +        int x = this.currentAreaContainerXPosition + area.getXOffset();
  +        int y = this.currentYPosition;
  +        int w = area.getContentWidth();
  +        int h = area.getHeight();
  +
  +        this.currentYPosition -= h;
  +
  +        FopImage img = area.getImage();
  +
  +        int xpos = xoffset + (x / 100);
  +        if (xpos < 0) {
  +            xpos = 0;
  +            MessageHandler.errorln("PCLRenderer.renderImageArea() WARNING: Horizontal position out of bounds.");
  +        }
  +
  +        currentStream.add("\033&a" + xpos + "h" +
  +                          (pageHeight - (y / 100)) + "V");
  +
  +        try {
  +            printBMP(img, x, y, w, h);
  +        } catch (FopImageException e) {
  +            //e.printStackTrace(System.out);
  +            MessageHandler.errorln(
  +              "PCLRenderer.renderImageArea() Error printing BMP (" +
  +              e.toString() + ")");
  +        }
  +    }
  +
  +    /** render a foreign object area */
  +    public void renderForeignObjectArea(ForeignObjectArea area) {
  +        // if necessary need to scale and align the content
  +        this.currentXPosition = this.currentXPosition + area.getXOffset();
  +        this.currentYPosition = this.currentYPosition;
  +        switch (area.getAlign()) {
  +            case TextAlign.START:
  +                break;
  +            case TextAlign.END:
  +                break;
  +            case TextAlign.CENTER:
  +            case TextAlign.JUSTIFY:
  +                break;
  +        }
  +        switch (area.getVerticalAlign()) {
  +            case VerticalAlign.BASELINE:
  +                break;
  +            case VerticalAlign.MIDDLE:
  +                break;
  +            case VerticalAlign.SUB:
  +                break;
  +            case VerticalAlign.SUPER:
  +                break;
  +            case VerticalAlign.TEXT_TOP:
  +                break;
  +            case VerticalAlign.TEXT_BOTTOM:
  +                break;
  +            case VerticalAlign.TOP:
  +                break;
  +            case VerticalAlign.BOTTOM:
  +                break;
  +        }
  +        // in general the content will not be text
  +
  +        // align and scale
  +
  +        switch (area.scalingMethod()) {
  +            case Scaling.UNIFORM:
  +                break;
  +            case Scaling.NON_UNIFORM:
  +                break;
  +        }
  +        // if the overflow is auto (default), scroll or visible
  +        // then the contents should not be clipped, since this
  +        // is considered a printing medium.
  +        switch (area.getOverflow()) {
  +            case Overflow.VISIBLE:
  +            case Overflow.SCROLL:
  +            case Overflow.AUTO:
  +                break;
  +            case Overflow.HIDDEN:
  +                break;
  +        }
  +        area.getObject().render(this);
  +
  +        this.currentXPosition += area.getEffectiveWidth();
  +        //    this.currentYPosition -= area.getEffectiveHeight();
  +    }
  +
  +    /**
  +     * render SVG area to PCL
  +     *
  +     * @param area the SVG area to render
  +     */
  +    public void renderSVGArea(SVGArea area) {
  +        if (debug)
  +            System.out.println("PCLRenderer.renderSVGArea(" + area + ")");
  +        int x = this.currentXPosition;
  +        int y = this.currentYPosition;
  +        SVGSVGElement svg =
  +          ((SVGDocument) area.getSVGDocument()).getRootElement();
  +        int w = (int)(svg.getWidth().getBaseVal().getValue() * 1000);
  +        int h = (int)(svg.getHeight().getBaseVal().getValue() * 1000);
  +
  +        /*
  +         * Clip to the svg area.
  +         * Note: To have the svg overlay (under) a text area then use
  +         * an fo:block-container
  +         */
  +
  +        // TODO - translate and clip to viewbox
  +
  +        //currentStream.add(svgRenderer.getString());
  +
  +        //currentStream.add("Q\n");
  +    }
  +
  +    public void setFont(String name, float size) {
  +        int fontcode = 0;
  +        if (name.length() > 1 && name.charAt(0) == 'F') {
  +            try {
  +                fontcode = Integer.parseInt(name.substring(1));
  +            } catch (Exception e) {
  +                e.printStackTrace();
  +            }
  +        }
  +        switch (fontcode) {
  +            case 1: // F1 = Helvetica
  +                //currentStream.add("\033(8U\033(s1p" + (size / 1000) + "v0s0b24580T");
  +                // Arial is more common among PCL5 printers than Helvetica - so use Arial
  +                currentStream.add("\033(0N\033(s1p" + (size / 1000) + "v0s0b16602T");
  +                break;
  +            case 2: // F2 = Helvetica Oblique
  +                currentStream.add("\033(0N\033(s1p" + (size / 1000) + "v1s0b16602T");
  +                break;
  +            case 3: // F3 = Helvetica Bold
  +                currentStream.add("\033(0N\033(s1p" + (size / 1000) + "v0s3b16602T");
  +                break;
  +            case 4: // F4 = Helvetica Bold Oblique
  +                currentStream.add("\033(0N\033(s1p" + (size / 1000) + "v1s3b16602T");
  +                break;
  +            case 5: // F5 = Times Roman
  +                //currentStream.add("\033(8U\033(s1p" + (size / 1000) + "v0s0b25093T");
  +                // Times New is more common among PCL5 printers than Times - so use Times New
  +                currentStream.add("\033(0N\033(s1p" + (size / 1000) + "v0s0b16901T");
  +                break;
  +            case 6: // F6 = Times Italic
  +                currentStream.add("\033(0N\033(s1p" + (size / 1000) + "v1s0b16901T");
  +                break;
  +            case 7: // F7 = Times Bold
  +                currentStream.add("\033(0N\033(s1p" + (size / 1000) + "v0s3b16901T");
  +                break;
  +            case 8: // F8 = Times Bold Italic
  +                currentStream.add("\033(0N\033(s1p" + (size / 1000) + "v1s3b16901T");
  +                break;
  +            case 9: // F9 = Courier
  +                currentStream.add("\033(0N\033(s0p" +
  +                                  (120.01f / (size / 1000.00f)) + "h0s0b4099T");
  +                break;
  +            case 10: // F10 = Courier Oblique
  +                currentStream.add("\033(0N\033(s0p" +
  +                                  (120.01f / (size / 1000.00f)) + "h1s0b4099T");
  +                break;
  +            case 11: // F11 = Courier Bold
  +                currentStream.add("\033(0N\033(s0p" +
  +                                  (120.01f / (size / 1000.00f)) + "h0s3b4099T");
  +                break;
  +            case 12: // F12 = Courier Bold Oblique
  +                currentStream.add("\033(0N\033(s0p" +
  +                                  (120.01f / (size / 1000.00f)) + "h1s3b4099T");
  +                break;
  +            case 13: // F13 = Symbol
  +                currentStream.add("\033(19M\033(s1p" + (size / 1000) +
  +                                  "v0s0b16686T");
  +                //currentStream.add("\033(9U\033(s1p" + (size / 1000) + "v0s0b25093T"); // ECMA Latin 1 Symbol Set in Times Roman???
  +                break;
  +            case 14: // F14 = Zapf Dingbats
  +                currentStream.add("\033(14L\033(s1p" + (size / 1000) +
  +                                  "v0s0b45101T");
  +                break;
  +            default:
  +                currentStream.add("\033(0N\033(s" + (size / 1000) + "V");
  +                break;
  +        }
  +    }
  +
  +    /**
  +     * render inline area to PCL
  +     *
  +     * @param area inline area to render
  +     */
  +    public void renderWordArea(WordArea area) {
  +        String name = area.getFontState().getFontName();
  +        int size = area.getFontState().getFontSize();
  +
  +        float red = area.getRed();
  +        float green = area.getGreen();
  +        float blue = area.getBlue();
  +        PDFColor theAreaColor = new PDFColor((double) area.getRed(),
  +                                             (double) area.getGreen(), (double) area.getBlue());
  +
  +        //currentStream.add("\033*c" + (int)(100 - ((0.3f * red + 0.59f * green + 0.11f * blue) * 100f)) + "G\033*v2T");
  +        currentStream.add("\033*v1O\033*c" + (int)(100 -
  +                          ((0.3f * red + 0.59f * green + 0.11f * blue) * 100f))
  +                          + "G\033*v2T");
  +
  +        if ((!name.equals(this.currentFontName)) ||
  +                (size != this.currentFontSize)) {
  +            this.currentFontName = name;
  +            this.currentFontSize = size;
  +            setFont(name, size);
  +        }
  +
  +        this.currentFill = theAreaColor;
  +
  +        int rx = this.currentXPosition;
  +        int bl = this.currentYPosition;
  +
  +        String s;
  +        if (area.getPageNumberID() != null) {
  +            // this text is a page number, so resolve it
  +            s = idReferences.getPageNumber(area.getPageNumberID());
  +            if (s == null)
  +                s = "";
  +        } else {
  +            s = area.getText();
  +        }
  +
  +        addWordLines(area, rx, bl, size, theAreaColor);
  +
  +        int xpos = xoffset + (rx / 100);
  +        if (xpos < 0) {
  +            xpos = 0;
  +            MessageHandler.errorln("PCLRenderer.renderWordArea() WARNING: Horizontal position out of bounds.");
  +        }
  +        currentStream.add("\033&a" + xpos + "h" +
  +                          (pageHeight - (bl / 100)) + "V" + s);
  +
  +        this.currentXPosition += area.getContentWidth();
  +    }
  +
  +    /**
  +     * render page into PCL
  +     *
  +     * @param page page to render
  +     */
  +    public void renderPage(Page page) {
  +        if (debug)
  +            System.out.println(
  +              "PCLRenderer.renderPage() page.Height() = " +
  +              page.getHeight());
  +        BodyAreaContainer body;
  +        AreaContainer before, after, start, end;
  +
  +        if (paperheight > 0 && divisions == -1)
  +            divisions = paperheight / (page.getHeight() / 100);
  +
  +        if (debug)
  +            System.out.println( "PCLRenderer.renderPage() paperheight=" +
  +                                paperheight + " divisions=" + divisions);
  +
  +        // Set top margin.
  +        //float fullmargin = 0;
  +        if (divisions > 0)
  +            fullmargin = paperheight * curdiv / divisions;
  +        if (topmargin > 0)
  +            fullmargin += topmargin;
  +        if (debug)
  +            System.out.println("PCLRenderer.renderPage() curdiv=" +
  +                               curdiv + " fullmargin=" + fullmargin);
  +        //if ( fullmargin > 0 )
  +        //	currentStream.add("\033&l" + (fullmargin / 15f) + "c1e8C");
  +        //this.currentYPosition = fullmargin * 100;
  +
  +        if (paperheight > 0)
  +            pageHeight = (paperheight / divisions) + fullmargin;
  +        else
  +            pageHeight = page.getHeight() / 100;
  +        if (debug)
  +            System.out.println(
  +              "PCLRenderer.renderPage() Set currentYPosition=" +
  +              this.currentYPosition);
  +        if (leftmargin > 0 && curdiv == 0)
  +            currentStream.add("\033&k" + (leftmargin / 6f) + "H\033&a1L\033&k12H");
  +
  +        body = page.getBody();
  +        before = page.getBefore();
  +        after = page.getAfter();
  +        start = page.getStart();
  +        end = page.getEnd();
  +
  +        this.currentFontName = "";
  +        this.currentFontSize = 0;
  +
  +        renderBodyAreaContainer(body);
  +
  +        if (before != null)
  +            renderAreaContainer(before);
  +
  +        if (after != null)
  +            renderAreaContainer(after);
  +
  +        if (start != null)
  +            renderAreaContainer(start);
  +
  +        if (end != null)
  +            renderAreaContainer(end);
  +
  +        // End page.
  +        if (++curdiv == divisions || divisions == -1) {
  +            curdiv = 0;
  +            currentStream.add("\f");
  +        }
  +
  +        // Links, etc not implemented...
  +        /*
  +        currentPage = this.pdfDoc.makePage(this.pdfResources, currentStream,
  +        			 page.getWidth()/1000, page.getHeight()/1000, page);
  +
  +        if (page.hasLinks()) {
  +        	currentAnnotList = this.pdfDoc.makeAnnotList();
  +        	currentPage.setAnnotList(currentAnnotList);
  +
  +        	Enumeration e = page.getLinkSets().elements();
  +        	while (e.hasMoreElements()) {
  +        	LinkSet linkSet = (LinkSet) e.nextElement();
  +
  +        	linkSet.align();
  +        	String dest = linkSet.getDest();
  +                       int linkType = linkSet.getLinkType();
  +        	Enumeration f = linkSet.getRects().elements();
  +        	while (f.hasMoreElements()) {
  +        		LinkedRectangle lrect = (LinkedRectangle) f.nextElement();
  +        		currentAnnotList.addLink(
  +        			this.pdfDoc.makeLink(lrect.getRectangle(), dest, linkType));
  +        	}
  +        	}
  +    } else {
  +        	// just to be on the safe side
  +        	currentAnnotList = null;
  +    }
  +         */
  +    }
  +}
  
  
  
  1.3       +40 -48    xml-fop/src/org/apache/fop/render/pcl/PCLStream.java
  
  Index: PCLStream.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/render/pcl/PCLStream.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PCLStream.java	2001/03/13 02:41:49	1.2
  +++ PCLStream.java	2001/07/04 12:41:07	1.3
  @@ -1,48 +1,40 @@
  -/* $Id: PCLStream.java,v 1.2 2001/03/13 02:41:49 arved 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 com.eastpoint.chrysalis;
  -package org.apache.fop.render.pcl;
  -
  -import java.io.*;
  -
  -public class PCLStream
  -{
  -	OutputStream	out = null;
  -	boolean	doOutput = true;
  -
  -	public PCLStream(OutputStream os)
  -	{
  -		out = os;
  -	}
  -
  -	public void add(String str)
  -	{
  -		if ( !doOutput )
  -			return;
  -
  -		byte buff[] = new byte[str.length()];
  -		int	countr;
  -		int	len = str.length();
  -		for ( countr = 0 ; countr < len ; countr++ )
  -			buff[countr] = (byte)str.charAt(countr);
  -		try
  -		{
  -			out.write(buff);
  -		}
  -		catch (IOException e)
  -		{
  -			//e.printStackTrace();
  -			//e.printStackTrace(System.out);
  -			throw new RuntimeException(e.toString());
  -		}
  -	}
  -
  -	public void setDoOutput(boolean doout)
  -	{
  -		doOutput = doout;
  -	}
  -}
  +/* $Id: PCLStream.java,v 1.3 2001/07/04 12:41:07 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.render.pcl;
  +
  +import java.io.*;
  +
  +public class PCLStream {
  +    OutputStream out = null;
  +    boolean doOutput = true;
  +
  +    public PCLStream(OutputStream os) {
  +        out = os;
  +    }
  +
  +    public void add(String str) {
  +        if (!doOutput)
  +            return;
  +
  +        byte buff[] = new byte[str.length()];
  +        int countr;
  +        int len = str.length();
  +        for (countr = 0 ; countr < len ; countr++)
  +            buff[countr] = (byte) str.charAt(countr);
  +        try {
  +            out.write(buff);
  +        } catch (IOException e) {
  +            //e.printStackTrace();
  +            //e.printStackTrace(System.out);
  +            throw new RuntimeException(e.toString());
  +        }
  +    }
  +
  +    public void setDoOutput(boolean doout) {
  +        doOutput = doout;
  +    }
  +}
  
  
  
  1.5       +63 -60    xml-fop/src/org/apache/fop/viewer/Command.java
  
  Index: Command.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/viewer/Command.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Command.java	2000/06/27 22:14:33	1.4
  +++ Command.java	2001/07/04 12:41:09	1.5
  @@ -1,61 +1,64 @@
  -package org.apache.fop.viewer;
  -/*
  -  Juergen Verwohlt: Juergen.Verwohlt@jcatalog.com,
  -  Rainer Steinkuhle: Rainer.Steinkuhle@jcatalog.com,
  -  Stanislav Gorkhover: Stanislav.Gorkhover@jcatalog.com
  - */
  -
  -import java.awt.event.ActionEvent;
  +/* $Id: Command.java,v 1.5 2001/07/04 12:41:09 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.viewer;
  +/*
  +  Juergen Verwohlt: Juergen.Verwohlt@jcatalog.com,
  +  Rainer Steinkuhle: Rainer.Steinkuhle@jcatalog.com,
  +  Stanislav Gorkhover: Stanislav.Gorkhover@jcatalog.com
  + */
  +
  +import java.awt.event.ActionEvent;
   import org.apache.fop.messaging.MessageHandler;
  -import javax.swing.AbstractAction;
  -import javax.swing.ImageIcon;
  -import java.net.*;
  -
  -
  -/**
  - * Klasse f�r UI-Kommandos. Die Kommandos k�nnen in das Men�system oder
  - * in eine Toolbar eingef�gt werden.<br>
  - * <code>Commands</code> unterst�tzen mehrsprachigkeit.<br>
  - * Durch �berschreiben der Methode <code>doit<code> kann die Klasse customisiert werden.
  - * �ber die Methode <code>undoit</code> kann Undo-Funktionalit�t unterst�tzt werden.<br>
  - *
  - * @author Juergen.Verwohlt@jcatalog.com
  - * @version 1.0 18.03.99
  - */
  -public class Command extends AbstractAction {
  -
  -  public static String IMAGE_DIR = "/org/apache/fop/viewer/Images/";
  -
  -  public Command(String name) {
  -    this(name, (ImageIcon)null);
  -  }
  -
  -  public Command(String name, ImageIcon anIcon) {
  -    super(name, anIcon);
  -  }
  -
  -
  -  public Command(String name, String iconName) {
  -    super(name);
  -    String path = IMAGE_DIR + iconName + ".gif";
  -    URL url = getClass().getResource(path);
  -    if (url == null) {
  -      MessageHandler.errorln("Icon not found: " + path);
  -    }
  -    else
  -      putValue(SMALL_ICON, new ImageIcon(url));
  -  }
  -
  -
  -  public void actionPerformed(ActionEvent e) {
  -    doit();
  -  }
  -
  -  public void doit() {
  -    MessageHandler.errorln("Not implemented.");
  -  }
  -
  -  public void undoit() {
  -    MessageHandler.errorln("Not implemented.");
  -  }
  -}
  +import javax.swing.AbstractAction;
  +import javax.swing.ImageIcon;
  +import java.net.*;
  +
  +
  +/**
  + * Klasse f�r UI-Kommandos. Die Kommandos k�nnen in das Men�system oder
  + * in eine Toolbar eingef�gt werden.<br>
  + * <code>Commands</code> unterst�tzen mehrsprachigkeit.<br>
  + * Durch �berschreiben der Methode <code>doit<code> kann die Klasse customisiert werden.
  + * �ber die Methode <code>undoit</code> kann Undo-Funktionalit�t unterst�tzt werden.<br>
  + *
  + * @author Juergen.Verwohlt@jcatalog.com
  + * @version 1.0 18.03.99
  + */
  +public class Command extends AbstractAction {
  +
  +    public static String IMAGE_DIR = "/org/apache/fop/viewer/Images/";
  +
  +    public Command(String name) {
  +        this(name, (ImageIcon) null);
  +    }
  +
  +    public Command(String name, ImageIcon anIcon) {
  +        super(name, anIcon);
  +    }
  +
  +    public Command(String name, String iconName) {
  +        super(name);
  +        String path = IMAGE_DIR + iconName + ".gif";
  +        URL url = getClass().getResource(path);
  +        if (url == null) {
  +            MessageHandler.errorln("Icon not found: " + path);
  +        } else
  +            putValue(SMALL_ICON, new ImageIcon(url));
  +    }
  +
  +    public void actionPerformed(ActionEvent e) {
  +        doit();
  +    }
  +
  +    public void doit() {
  +        MessageHandler.errorln("Not implemented.");
  +    }
  +
  +    public void undoit() {
  +        MessageHandler.errorln("Not implemented.");
  +    }
  +}
  
  
  

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