From: Keiron Liddle Date: Wed, 4 Jul 2001 12:41:09 +0000 (+0000) Subject: fixed line endings X-Git-Tag: PRE_CODEFORMATTING~51 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6a99271a265b037c7df93fa1decde3be41a048fb;p=xmlgraphics-fop.git fixed line endings some cleanup also no code changes git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194328 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/org/apache/fop/apps/AWTStarter.java b/src/org/apache/fop/apps/AWTStarter.java index d78f1232f..a38edf207 100644 --- a/src/org/apache/fop/apps/AWTStarter.java +++ b/src/org/apache/fop/apps/AWTStarter.java @@ -1,7 +1,7 @@ -/* +/* $Id$ * 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." + * For details on use and redistribution please refer to the + * LICENSE file included with these sources. */ package org.apache.fop.apps; @@ -54,9 +54,8 @@ public class AWTStarter extends CommandLineStarter { private Translator resource; - public AWTStarter (CommandLineOptions commandLineOptions) - throws FOPException - { + public AWTStarter (CommandLineOptions commandLineOptions) + throws FOPException { super(commandLineOptions); init(); } @@ -91,10 +90,8 @@ public class AWTStarter extends CommandLineStarter { } - public void run () - throws FOPException - { - Driver driver = new Driver(); + public void run () throws FOPException { + Driver driver = new Driver(); if (errorDump) { driver.setErrorDump(true); } @@ -104,7 +101,7 @@ public class AWTStarter extends CommandLineStarter { XMLReader parser = inputHandler.getParser(); if (parser == null) { - throw new FOPException("Unable to create SAX parser"); + throw new FOPException("Unable to create SAX parser"); } setParserFeatures(parser); @@ -128,10 +125,10 @@ public class AWTStarter extends CommandLineStarter { frame.showPage(); } catch (Exception e) { - if (e instanceof FOPException) { - throw (FOPException)e; - } - throw new FOPException(e); + if (e instanceof FOPException) { + throw (FOPException) e; + } + throw new FOPException(e); } } diff --git a/src/org/apache/fop/apps/FOInputHandler.java b/src/org/apache/fop/apps/FOInputHandler.java index 6f99e223c..5fd055a4c 100644 --- a/src/org/apache/fop/apps/FOInputHandler.java +++ b/src/org/apache/fop/apps/FOInputHandler.java @@ -1,10 +1,9 @@ -/* +/* $Id$ * 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." + * For details on use and redistribution please refer to the + * LICENSE file included with these sources. */ - package org.apache.fop.apps; // Imported SAX classes @@ -20,21 +19,18 @@ import java.io.File; /** * Manages input if it is an xsl:fo file */ - public class FOInputHandler extends InputHandler { - File fofile; + File fofile; public FOInputHandler (File fofile) { - this.fofile = fofile; + this.fofile = fofile; } public InputSource getInputSource () { return super.fileInputSource(fofile); } - public XMLReader getParser() - throws FOPException - { + public XMLReader getParser() throws FOPException { return super.createParser(); } } diff --git a/src/org/apache/fop/apps/Fop.java b/src/org/apache/fop/apps/Fop.java index 2f4032deb..801bf8a81 100644 --- a/src/org/apache/fop/apps/Fop.java +++ b/src/org/apache/fop/apps/Fop.java @@ -1,36 +1,34 @@ -/* +/* $Id$ * 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." + * 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(); - } - } + 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(); + } + } } - + } diff --git a/src/org/apache/fop/apps/InputHandler.java b/src/org/apache/fop/apps/InputHandler.java index 868a2de15..731e375e9 100644 --- a/src/org/apache/fop/apps/InputHandler.java +++ b/src/org/apache/fop/apps/InputHandler.java @@ -1,10 +1,9 @@ -/* +/* $Id$ * 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." + * For details on use and redistribution please refer to the + * LICENSE file included with these sources. */ - package org.apache.fop.apps; // SAX @@ -28,11 +27,11 @@ abstract public class InputHandler { /** - * create an InputSource from a File - * - * @param file the File - * @return the InputSource created - */ + * 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(); @@ -49,14 +48,12 @@ abstract public class InputHandler { } /** - * 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 - { + * 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"; @@ -67,17 +64,18 @@ abstract public class InputHandler { return (XMLReader) Class.forName( parserClassName).newInstance(); } catch (ClassNotFoundException e) { - throw new FOPException(e); + throw new FOPException(e); } catch (InstantiationException e) { - throw new FOPException("Could not instantiate " + - parserClassName,e); + throw new FOPException("Could not instantiate " + + parserClassName, e); } catch (IllegalAccessException e) { - throw new FOPException("Could not access " + parserClassName,e); + throw new FOPException("Could not access " + + parserClassName, e); } catch (ClassCastException e) { - throw new FOPException(parserClassName + " is not a SAX driver",e); + throw new FOPException(parserClassName + " is not a SAX driver",e); } } } diff --git a/src/org/apache/fop/apps/Options.java b/src/org/apache/fop/apps/Options.java index db54cc413..03655e645 100644 --- a/src/org/apache/fop/apps/Options.java +++ b/src/org/apache/fop/apps/Options.java @@ -23,7 +23,6 @@ import org.apache.fop.configuration.ConfigurationReader; * Options handles loading of configuration files and * additional setting of commandline options */ - public class Options { boolean errorDump = false; diff --git a/src/org/apache/fop/apps/PrintStarter.java b/src/org/apache/fop/apps/PrintStarter.java index dbd1269ee..3d2c52a0d 100644 --- a/src/org/apache/fop/apps/PrintStarter.java +++ b/src/org/apache/fop/apps/PrintStarter.java @@ -1,10 +1,9 @@ -/* +/* $Id$ * 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." + * For details on use and redistribution please refer to the + * LICENSE file included with these sources. */ - package org.apache.fop.apps; /* @@ -44,15 +43,11 @@ import org.apache.fop.messaging.MessageHandler; */ public class PrintStarter extends CommandLineStarter { - public PrintStarter (CommandLineOptions options) - throws FOPException - { + public PrintStarter (CommandLineOptions options) throws FOPException { super(options); } - public void run () - throws FOPException - { + public void run () throws FOPException { Driver driver = new Driver(); if (errorDump) { driver.setErrorDump(true); @@ -62,7 +57,7 @@ public class PrintStarter extends CommandLineStarter { MessageHandler.errorln(version); XMLReader parser = inputHandler.getParser(); - + setParserFeatures(parser); PrintRenderer renderer = new PrintRenderer(); @@ -73,11 +68,11 @@ public class PrintStarter extends CommandLineStarter { driver.format(); driver.render(); } catch (Exception e) { - if (e instanceof FOPException) { - throw (FOPException)e; - } - throw new FOPException(e); - } + if (e instanceof FOPException) { + throw (FOPException) e; + } + throw new FOPException(e); + } int copies = PrintRenderer.getIntProperty("copies", 1); renderer.setCopies(copies); @@ -193,3 +188,4 @@ public class PrintStarter extends CommandLineStarter { } // class PrintCommandLine + diff --git a/src/org/apache/fop/apps/Starter.java b/src/org/apache/fop/apps/Starter.java index c82ef9323..130e2f1ac 100644 --- a/src/org/apache/fop/apps/Starter.java +++ b/src/org/apache/fop/apps/Starter.java @@ -1,10 +1,9 @@ -/* +/* $Id$ * 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." + * For details on use and redistribution please refer to the + * LICENSE file included with these sources. */ - package org.apache.fop.apps; // SAX @@ -18,10 +17,8 @@ import java.net.URL; // FOP import org.apache.fop.messaging.MessageHandler; - /** - * - * abstract super class + * abstract super class * Creates a SAX Parser (defaulting to Xerces). * */ @@ -29,29 +26,26 @@ public abstract class Starter { Options options; InputHandler inputHandler; - - public Starter() - throws FOPException - { - options = new Options (); + + public Starter() throws FOPException { + options = new Options (); } - + public void setInputHandler(InputHandler inputHandler) { - this.inputHandler = inputHandler; + this.inputHandler = inputHandler; } - - abstract public void run() - throws FOPException; - - // setting the parser features - public void setParserFeatures (XMLReader parser) - throws FOPException - { + + 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); + 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); + throw new FOPException( + "Error in setting up parser feature namespace-prefixes\n" + + "You need a parser which supports SAX version 2",e); } } } diff --git a/src/org/apache/fop/apps/TraxInputHandler.java b/src/org/apache/fop/apps/TraxInputHandler.java index 473d7cdf6..0b1e10f43 100644 --- a/src/org/apache/fop/apps/TraxInputHandler.java +++ b/src/org/apache/fop/apps/TraxInputHandler.java @@ -1,10 +1,9 @@ -/* +/* $Id$ * 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." + * For details on use and redistribution please refer to the + * LICENSE file included with these sources. */ - package org.apache.fop.apps; @@ -36,44 +35,42 @@ 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; + File xmlfile, xsltfile; - public TraxInputHandler (File xmlfile, File xsltfile ) { + public TraxInputHandler (File xmlfile, File xsltfile) { this.xmlfile = xmlfile; - this.xsltfile = xsltfile; + this.xsltfile = xsltfile; } /** - * overwrites the method of the super class to return the xmlfile - */ + * 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 - * - */ + * 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); + 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 - { + * 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(); @@ -104,11 +101,11 @@ public class TraxInputHandler extends InputHandler { } } catch (Exception ex) { - if (ex instanceof FOPException) { - throw (FOPException)ex; - } - throw new FOPException(ex); - } + if (ex instanceof FOPException) { + throw (FOPException) ex; + } + throw new FOPException(ex); + } } } diff --git a/src/org/apache/fop/apps/XSLTInputHandler.java b/src/org/apache/fop/apps/XSLTInputHandler.java index ccce94447..1169e5870 100644 --- a/src/org/apache/fop/apps/XSLTInputHandler.java +++ b/src/org/apache/fop/apps/XSLTInputHandler.java @@ -1,10 +1,9 @@ -/* +/* $Id$ * 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." + * 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.*; @@ -26,104 +25,97 @@ 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 ) { + + public XSLTInputHandler (File xmlfile, File xsltfile) { this.xmlfile = xmlfile; - this.xsltfile = xsltfile; + this.xsltfile = xsltfile; } /** - * overwrites the method of the super class to return the xmlfile - */ + * 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); - } - + 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; - - } + * 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; - - + } } diff --git a/src/org/apache/fop/datatypes/ColorSpace.java b/src/org/apache/fop/datatypes/ColorSpace.java index 2cda6d827..546d756bc 100644 --- a/src/org/apache/fop/datatypes/ColorSpace.java +++ b/src/org/apache/fop/datatypes/ColorSpace.java @@ -1,106 +1,50 @@ -/*-- $Id$ -- - - ============================================================================ - 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 . For more information on the Apache - Software Foundation, please see . - +/* $Id$ + * 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 + //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? - 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 + //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"); + } + } +} diff --git a/src/org/apache/fop/datatypes/Keep.java b/src/org/apache/fop/datatypes/Keep.java index 99971f713..467cdcc1b 100644 --- a/src/org/apache/fop/datatypes/Keep.java +++ b/src/org/apache/fop/datatypes/Keep.java @@ -1,53 +1,9 @@ -/*-- $Id$ -- - - ============================================================================ - 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 . For more information on the Apache - Software Foundation, please see . - +/* $Id$ + * 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; @@ -60,57 +16,59 @@ public class Keep implements CompoundDatatype { private Property withinColumn; private Property withinPage; - public Keep () { - } + public Keep () { + } - // From CompoundDatatype + // 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); + 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; + // 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; + this.withinLine = withinLine; } - protected void setWithinColumn(Property withinColumn, boolean bIsDefault) { - this.withinColumn = withinColumn; + protected void setWithinColumn(Property withinColumn, + boolean bIsDefault) { + this.withinColumn = withinColumn; } public void setWithinPage(Property withinPage, boolean bIsDefault) { - this.withinPage = withinPage; + this.withinPage = withinPage; } public Property getWithinLine() { - return this.withinLine; + return this.withinLine; } public Property getWithinColumn() { - return this.withinColumn; + return this.withinColumn; } public Property getWithinPage() { - return this.withinPage; + return this.withinPage; } /** What to do here?? There isn't really a meaningful single value. */ public String toString() { - return "Keep"; + return "Keep"; } } diff --git a/src/org/apache/fop/datatypes/LengthBase.java b/src/org/apache/fop/datatypes/LengthBase.java index b054bc58c..eef01459b 100644 --- a/src/org/apache/fop/datatypes/LengthBase.java +++ b/src/org/apache/fop/datatypes/LengthBase.java @@ -1,53 +1,9 @@ -/*-- $Id$ -- - - ============================================================================ - 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 . For more information on the Apache - Software Foundation, please see . - +/* $Id$ + * 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; @@ -55,72 +11,77 @@ 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; + // 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; + /** + * 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; - } + 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 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; - } + /** 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 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; + 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; + } } - } } diff --git a/src/org/apache/fop/datatypes/LengthPair.java b/src/org/apache/fop/datatypes/LengthPair.java index 00e70fded..6f763d310 100644 --- a/src/org/apache/fop/datatypes/LengthPair.java +++ b/src/org/apache/fop/datatypes/LengthPair.java @@ -1,4 +1,4 @@ -/*-- $Id$ -- +/* $Id$ * 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. @@ -19,29 +19,30 @@ public class LengthPair implements CompoundDatatype { private Property ipd; private Property bpd; - // From CompoundDatatype + // 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; + 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 + // 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; + return this.ipd; } public Property getBPD() { - return this.bpd; + return this.bpd; } } diff --git a/src/org/apache/fop/datatypes/LengthRange.java b/src/org/apache/fop/datatypes/LengthRange.java index d6e99a889..8beeb189a 100644 --- a/src/org/apache/fop/datatypes/LengthRange.java +++ b/src/org/apache/fop/datatypes/LengthRange.java @@ -1,53 +1,9 @@ -/*-- $Id$ -- - - ============================================================================ - 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 . For more information on the Apache - Software Foundation, please see . - +/* $Id$ + * 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; @@ -63,32 +19,33 @@ 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; + 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 + // 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); + 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 + // 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 } /** @@ -99,8 +56,9 @@ public class LengthRange implements CompoundDatatype { * and not a user-specified explicit value. */ protected void setMinimum(Property minimum, boolean bIsDefault) { - this.minimum = minimum; - if (!bIsDefault) bfSet |= MINSET; + this.minimum = minimum; + if (!bIsDefault) + bfSet |= MINSET; } @@ -111,8 +69,9 @@ public class LengthRange implements CompoundDatatype { * and not a user-specified explicit value. */ protected void setMaximum(Property max, boolean bIsDefault) { - maximum = max; - if (!bIsDefault) bfSet |= MAXSET; + maximum = max; + if (!bIsDefault) + bfSet |= MAXSET; } @@ -123,74 +82,76 @@ public class LengthRange implements CompoundDatatype { * and not a user-specified explicit value. */ protected void setOptimum(Property opt, boolean bIsDefault) { - optimum = opt; - if (!bIsDefault) bfSet |= OPTSET; + 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; - } + // 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; + checkConsistency(); + return this.minimum; } public Property getMaximum() { - checkConsistency(); - return this.maximum; + checkConsistency(); + return this.maximum; } public Property getOptimum() { - checkConsistency(); - return this.optimum; + checkConsistency(); + return this.optimum; } } diff --git a/src/org/apache/fop/datatypes/Space.java b/src/org/apache/fop/datatypes/Space.java index 4b5fb9409..71ce6e15c 100644 --- a/src/org/apache/fop/datatypes/Space.java +++ b/src/org/apache/fop/datatypes/Space.java @@ -1,53 +1,9 @@ -/*-- $Id$ -- - - ============================================================================ - 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 . For more information on the Apache - Software Foundation, please see . - +/* $Id$ + * 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; @@ -59,45 +15,48 @@ public class Space extends LengthRange { private Property precedence; private Property conditionality ; - - // From CompoundDatatype + + // 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); + 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); + // 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; + this.precedence = precedence; } - protected void setConditionality(Property conditionality, boolean bIsDefault) { - this.conditionality = conditionality; + protected void setConditionality(Property conditionality, + boolean bIsDefault) { + this.conditionality = conditionality; } public Property getPrecedence() { - return this.precedence ; + return this.precedence ; } - /* - public boolean isDiscard() { - return (this.conditionality == DISCARD); - } - */ + /* + public boolean isDiscard() { + return (this.conditionality == DISCARD); + } + */ public Property getConditionality() { - return this.conditionality ; + return this.conditionality ; } } diff --git a/src/org/apache/fop/fo/pagination/Region.java b/src/org/apache/fop/fo/pagination/Region.java index af1f50e07..94d11b3e7 100644 --- a/src/org/apache/fop/fo/pagination/Region.java +++ b/src/org/apache/fop/fo/pagination/Region.java @@ -1,11 +1,10 @@ -/*-- $Id$ -- - +/* $Id$ * 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." + * For details on use and redistribution please refer to the + * LICENSE file included with these sources. */ - package org.apache.fop.fo.pagination; +package org.apache.fop.fo.pagination; // FOP import org.apache.fop.fo.FObj; @@ -16,87 +15,79 @@ import org.apache.fop.layout.RegionArea; /** * This is an abstract base class for pagination regions */ -public abstract class Region extends FObj -{ +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()); - } + + 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); - - /** + abstract RegionArea makeRegionArea( int allocationRectangleXPosition, + int allocationRectangleYPosition, + int allocationRectangleWidth, int allocationRectangleHeight); + + /** * Returns the default region name (xsl-region-before, xsl-region-start, - * etc.) + * etc.) */ protected abstract String getDefaultRegionName(); /** * Returns the element name ("fo:region-body", "fo:region-start", - * etc.) + * etc.) */ protected abstract String getElementName(); - + public abstract String getRegionClass(); - + /** * Returns the name of this region */ - public String getRegionName() - { - return _regionName; + public String getRegionName() { + return _regionName; } - private void setRegionName(String name) - { - _regionName = name; + private void setRegionName(String name) { + _regionName = name; } - - protected SimplePageMaster getPageMaster() - { - return _layoutMaster; + + protected SimplePageMaster getPageMaster() { + return _layoutMaster; } - /** * Checks to see if a given region name is one of the reserved names @@ -104,19 +95,17 @@ public abstract class Region extends FObj * @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" )); + 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; + return true; } - + } diff --git a/src/org/apache/fop/image/FopImageException.java b/src/org/apache/fop/image/FopImageException.java index 15d9fc982..b7907edb7 100644 --- a/src/org/apache/fop/image/FopImageException.java +++ b/src/org/apache/fop/image/FopImageException.java @@ -1,52 +1,7 @@ -/* - - ============================================================================ - 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 . For more information on the Apache - Software Foundation, please see . - +/* $Id$ + * 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 @@ -56,11 +11,11 @@ package org.apache.fop.image; public class FopImageException extends Exception { - public FopImageException() { - super(); - } + public FopImageException() { + super(); + } - public FopImageException(String message) { - super(message); - } + public FopImageException(String message) { + super(message); + } } diff --git a/src/org/apache/fop/mif/MIFDocument.java b/src/org/apache/fop/mif/MIFDocument.java index 0ec698dcd..b44cdc3b5 100644 --- a/src/org/apache/fop/mif/MIFDocument.java +++ b/src/org/apache/fop/mif/MIFDocument.java @@ -1,59 +1,11 @@ -/*-- $Id$ -- - - ============================================================================ - 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 . For more information on the Apache - Software Foundation, please see . - +/* $Id$ + * 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 @@ -80,7 +32,7 @@ import java.awt.Rectangle; * 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 */ @@ -88,1098 +40,1066 @@ public class MIFDocument { 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(); + 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() { + private int idCounter = 1; + public int getnewID() { - return idCounter++; - } - - } + return idCounter++; + } - class FontFormat { + } + + class FontFormat { - public FontFormat() { } + public FontFormat() { } } class ParagraphFormat extends FontFormat { - public ParagraphFormat() {} - int startIndent; - int endIndent; + public ParagraphFormat() {} + int startIndent; + int endIndent; } class Document { - protected int height; - protected int width; - public Document() {} + protected int height; + protected int width; + public Document() {} - public void output(OutputStream stream) throws IOException { + public void output(OutputStream stream) throws IOException { - String mif="\n\n>"; - byte buf[]=mif.getBytes(); + String mif = "\n\n>"; + byte buf[] = mif.getBytes(); - stream.write(buf); - - } + stream.write(buf); + + } } - + class PolyLine { - public PolyLine() {} + public PolyLine() {} } class ImportObject { - private String url; - private int x,y,w,h; + private String url; + private int x, y, w, h; - public ImportObject(String url,int x,int y,int w,int 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; + this.url = url; + this.x = x; + this.y = y; + this.w = w; + this.h = h; - } + } - public void output(OutputStream stream) throws IOException { + public void output(OutputStream stream) throws IOException { - String path=this.url; + String path = this.url; - //Strip 'file:' - path= path.substring(5); - String result=""; - int i; - do { // replace all matching '/' + //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 += ""; - result += path.substring(i + 1); - path=result; - } + i = path.indexOf("/"); + if (i != -1) { + result = path.substring(0, i); + result += ""; + result += path.substring(i + 1); + path = result; + } - } while (i!= -1); - - String mif="\n"; - mif += "\n\t" + path + "'" + " >"; - mif +="\n\t"; + } while (i != -1) + ; - mif += "\n> #End ImportObj"; - stream.write(mif.getBytes()); + String mif = "\n"; + mif += "\n\t" + path + "'" + " >"; + mif += "\n\t"; - } + 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) { + 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) { - this.ID=curIDCounter.getnewID(); - this.x=x; - this.y=y; - this.w=w; - this.h=h; + content.addElement(obj); - } - - public void addContent(ImportObject obj) { + } - content.addElement(obj); + public void output(OutputStream stream) throws IOException { - } + String mif = "\n"; + mif += "\n\t\n\t\n\t\n\t\n\t\n\t \n >"; - public void output(OutputStream stream) throws IOException { + mif += "\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t"; - String mif="\n"; - mif += "\n\t\n\t\n\t\n\t\n\t\n\t \n >"; + mif += "\n\t"; - mif +="\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t"; - mif += "\n\t"; - + stream.write(mif.getBytes()); - stream.write(mif.getBytes()); + Enumeration e = content.elements(); + while (e.hasMoreElements()) { - Enumeration e=content.elements(); - while (e.hasMoreElements()) { + ((ImportObject) e.nextElement()).output(stream); + } + mif = "\n> #End Frame"; + stream.write(mif.getBytes()); - ((ImportObject) e.nextElement()).output(stream); - } - mif ="\n> #End Frame"; - stream.write(mif.getBytes()); + } + public int getID() { - } - public int getID() { - - return this.ID; - } + 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" + "\n\t" ; - - if (numCols>1) { - mif += "\n"; - mif += "\n"; - } - - mif += "\n> #End TextRect" ; - byte buf[]=mif.getBytes(); - stream.write(buf); - } + 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" + + "\n\t" ; + + if (numCols > 1) { + mif += "\n"; + mif += "\n"; + } + + 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(); - } + private String pageType; + private String pageTag; + private String pageBackground; + private Vector textRects; + public Page(String pageType, String pageTag, + String pageBackground) { - public Page() { + this.pageType = pageType; + this.pageTag = pageTag; + this.pageBackground = pageBackground; + this.textRects = new Vector(); + } - this.pageType="BodyPage"; - this.pageBackground="Default"; - 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() { + public void addTextRect(int numCols) { - return (TextRect) textRects.lastElement(); + 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" + "\n\t"; - byte buf[]=mif.getBytes(); + public void output(OutputStream stream) throws IOException { - stream.write(buf); - - Enumeration e=textRects.elements(); - while (e.hasMoreElements()) { + String mif = "\n" + + "\n\t"; - ((TextRect) e.nextElement()).output(stream); + byte buf[] = mif.getBytes(); - } - mif="\n> #End Page\n"; - stream.write(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(); + } + + 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. + Vector paras; + private int ID; // This ID is used within ParaLine, however it is + // logical to keep it unique to a textflow + + public TextFlow() { - this.ID=((bookComponent.curPage()).curTextRect()).getTextRectID(); - this.paras=new Vector(); - - } - - public int getTextRectID() { + //The current textrect into which the textflow goes + //is the last created. - return ID; + this.ID = ((bookComponent.curPage()).curTextRect()). + getTextRectID(); + this.paras = new Vector(); - } + } - public Para curPara() { - return (Para) paras.lastElement(); - } + public int getTextRectID() { - public void startPara() { + return ID; - this.paras.addElement(new Para(ID)); - } + } - public void output(OutputStream stream) throws IOException { - String mif="\n"; - mif += "\n"; - 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"; - - 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"; - } - else { - mif="\n\t"; - } - stream.write(mif.getBytes()); - - } - else - if (elem instanceof Frame) { - - mif="\n\t"; - stream.write(mif.getBytes()); - } - else - if (elem instanceof Tbl) { - mif="\n\t"; - stream.write(mif.getBytes()); - } - } - mif="\n> #End ParaLine"; - stream.write(mif.getBytes()); - - } - } - - - class PgfCatalog { - Vector pgfs; // Paragraph formats - public PgfCatalog() {} + class Para { - public void output(OutputStream stream) throws IOException { - String mif="\n" + "\n>" + "\n>"; - stream.write(mif.getBytes()); - } - - } - - class Color { - - public Color() {} - } + Vector paraLines; + int ID; // Same as TextRectID + ParagraphFormat pgf = null; // This corresponds to to the block properties + public Para() { - class ColorCatalog { + this.ID = 0; + this.paraLines = new Vector(); + } - public ColorCatalog() {} - } + public Para(int ID) { - class Ruling { + this.ID = ID; + this.paraLines = new Vector(); - int penWidth; - int pen; - int lines; - public Ruling() { - // Default ruling - penWidth=1; - pen=0; - lines=1; - + } - } + public ParaLine curParaLine() { + if (paraLines.isEmpty()) { + return null; + } else { + return (ParaLine) paraLines.lastElement(); + } + } - public void output(OutputStream stream) throws IOException { + void startParaLine() { - String mif = "\n"; - mif +="\n"; - mif +="\n"; - mif +="\n"; - mif +="\n>"; - stream.write(mif.getBytes()); - } + this.paraLines.addElement(new ParaLine(ID)); - } + } - class RulingCatalog { - // Contains multiple rulings - Vector ruling = new Vector(); - public RulingCatalog() { - - // Add the defualt ruling to the catalog + public void setBlockProp(int startIndent, int endIndent) { - ruling.addElement(new Ruling()); + pgf = new ParagraphFormat(); + pgf.startIndent = startIndent; + pgf.endIndent = endIndent; - } - public void output(OutputStream stream) throws IOException { + } - String mif="\n"; + mif += "\n"; + mif += "\n>"; + } + stream.write(mif.getBytes()); + Enumeration e = paraLines.elements(); + while (e.hasMoreElements()) { - public TblFormat() {} - } + ((ParaLine) e.nextElement()).output(stream); + } + mif = "\n> #End ParaLine"; + stream.write(mif.getBytes()); - class TblCatalog { + } - public TblCatalog() {} + } - } - - class Tbl extends Flow { + class ParaLine { + Vector content; + int textRectID; + String tableID; + String aFrameID; + public ParaLine(int textRectID) { - class TblColumn { - private int width; - public TblColumn(int width) { + this.textRectID = textRectID; + this.content = new Vector(); - this.width=width; + } + public ParaLine () { - } - public void output(OutputStream stream) throws IOException { + this.textRectID = 0; // There is no ID used, in tables + this.content = new Vector(); + } + public void addContent(Object obj) { - String mif="\n\t"; - stream.write(mif.getBytes()); + this.content.addElement(obj); - } + } + public void output(OutputStream stream) throws IOException { - - } + String mif = "\n"; - private int rowSpan,colSpan; - private Vector paras; // Paras - public Cell(int rowSpan,int colSpan) { + stream.write(mif.getBytes()); + Enumeration e = this.content.elements(); + while (e.hasMoreElements()) { - this.rowSpan=rowSpan; - this.colSpan=colSpan; - paras=new Vector(); + Object elem = (Object) e.nextElement(); + if (elem instanceof String) { - } - public void startPara() { + // Output newlines as char hard return - this.paras.addElement(new Para()); - } - public void output(OutputStream stream) throws IOException { + if (elem == "\n") { - String mif="\n\t\t"; + } + stream.write(mif.getBytes()); - } - private Vector cells; + } else if (elem instanceof Frame) { - public void addCell(int rowSpan, int colSpan) { + mif = "\n\t"; + stream.write(mif.getBytes()); + } else if (elem instanceof Tbl) { + mif = "\n\t"; + stream.write(mif.getBytes()); + } + } + mif = "\n> #End ParaLine"; + stream.write(mif.getBytes()); - cells.addElement(new Cell(rowSpan,colSpan)); - } + } + } - public Row() { + class PgfCatalog { - cells=new Vector(); - - } - public Cell curCell() { + Vector pgfs; // Paragraph formats + public PgfCatalog() {} - return (Cell) this.cells.lastElement(); - } + public void output(OutputStream stream) throws IOException { + String mif = "\n" + + "\n>" + "\n>"; + stream.write(mif.getBytes()); + } - public void output(OutputStream stream) throws IOException { + } - String mif="\n\t"; + mif += "\n"; + mif += "\n"; + mif += "\n>"; + stream.write(mif.getBytes()); + } - //Add a cell into the current row + } - ((Row) this.current.lastElement()).addCell(rowSpan,colSpan); + class RulingCatalog { + // Contains multiple rulings - } + Vector ruling = new Vector(); + public RulingCatalog() { - public Tbl() { + // Add the defualt ruling to the catalog - this.ID=curIDCounter.getnewID(); - tblBody=new Vector(); - tblHead=new Vector(); - tblFoot=new Vector(); + ruling.addElement(new Ruling()); - } + } - public int getID() { + public void output(OutputStream stream) throws IOException { - return this.ID; - } - public Para curPara() { + String mif = "\n"; + this.width = width; - // note tbl format to be added in a later release - mif += "\n" + "\n"; - 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"; + stream.write(mif.getBytes()); - } + } - class XRefFormat { - public XRefFormat() {} - } + } - class CrossRefInfo { + class Row { - public CrossRefInfo() {} - } + class Cell { - class XRef { + private int rowSpan, colSpan; + private Vector paras; // Paras + public Cell(int rowSpan, int colSpan) { - public XRef() {} - } + this.rowSpan = rowSpan; + this.colSpan = colSpan; + paras = new Vector(); - class Marker { + } + public void startPara() { - public Marker() {} + this.paras.addElement(new Para()); + } + public void output(OutputStream stream) throws IOException { - } + String mif = "\n\t\t" ; - stream.write(mif.getBytes()); - pgfCatalog.output(stream); - rulingCatalog.output(stream); - document.output(stream); + 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) { - if (! aFrames.isEmpty()) { + tblColumns.addElement(new TblColumn(colWidth)); - mif="\n"; + + // note tbl format to be added in a later release + mif += "\n" + "\n"; + 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" ; + stream.write(mif.getBytes()); + pgfCatalog.output(stream); + rulingCatalog.output(stream); + document.output(stream); + + if (! aFrames.isEmpty()) { + + mif = "\n. For more information on the Apache - Software Foundation, please see . - +/* $Id$ + * 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 @@ -56,11 +11,11 @@ package org.apache.fop.pdf; public class PDFFilterException extends Exception { - public PDFFilterException() { - super(); - } + public PDFFilterException() { + super(); + } - public PDFFilterException(String message) { - super(message); - } + public PDFFilterException(String message) { + super(message); + } } diff --git a/src/org/apache/fop/render/mif/Font.java b/src/org/apache/fop/render/mif/Font.java index 49e8bdc98..e88fe10aa 100644 --- a/src/org/apache/fop/render/mif/Font.java +++ b/src/org/apache/fop/render/mif/Font.java @@ -1,53 +1,9 @@ -/*-- $Id$ -- - - ============================================================================ - 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 . For more information on the Apache - Software Foundation, please see . - +/* $Id$ + * 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 diff --git a/src/org/apache/fop/render/mif/FontSetup.java b/src/org/apache/fop/render/mif/FontSetup.java index aeb76311d..4869543ab 100644 --- a/src/org/apache/fop/render/mif/FontSetup.java +++ b/src/org/apache/fop/render/mif/FontSetup.java @@ -1,53 +1,9 @@ -/*-- $Id$ -- - - ============================================================================ - 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 . For more information on the Apache - Software Foundation, please see . - +/* $Id$ + * 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 @@ -79,136 +35,96 @@ public class FontSetup { * @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()); + 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()); + //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"); + /* 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", "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"); + 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"); + //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"); + /* 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"); } /** @@ -217,23 +133,24 @@ public class FontSetup { * @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) { - + 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 - ); */ - - } - } + 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 + ); */ + + } + } } diff --git a/src/org/apache/fop/render/mif/MIFRenderer.java b/src/org/apache/fop/render/mif/MIFRenderer.java index c871a9bcc..e38004baa 100644 --- a/src/org/apache/fop/render/mif/MIFRenderer.java +++ b/src/org/apache/fop/render/mif/MIFRenderer.java @@ -1,59 +1,11 @@ -/*-- $Id$ -- - - ============================================================================ - 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 . For more information on the Apache - Software Foundation, please see . - +/* $Id$ + * 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 @@ -63,7 +15,7 @@ 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.fo.*; import org.apache.fop.layout.*; import org.apache.fop.layout.inline.*; import org.apache.fop.datatypes.*; @@ -89,140 +41,136 @@ import java.util.Hashtable; */ 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(); + 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); - + FontSetup.setup(fontInfo); + //FontSetup.addToFontFormat(this.mifDoc, fontInfo); - } + } /** set the producer of the rendering */ - public void setProducer(String producer) {} + 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(); - - } + 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(); + // 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.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; @@ -242,7 +190,7 @@ public class MIFRenderer implements Renderer { public void renderBodyAreaContainer(BodyAreaContainer area) { - + int saveY = this.currentYPosition; int saveX = this.currentAreaContainerXPosition; @@ -254,7 +202,7 @@ public class MIFRenderer implements Renderer { this.currentYPosition -= area.getYPosition(); this.currentAreaContainerXPosition += area.getXPosition(); } - + this.currentXPosition = this.currentAreaContainerXPosition; int w, h; int rx = this.currentAreaContainerXPosition; @@ -263,28 +211,29 @@ public class MIFRenderer implements Renderer { 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)); - } + // 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 - } + // 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; @@ -292,122 +241,117 @@ public class MIFRenderer implements Renderer { } 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))); - */ - } + int w, h; + int rx = this.currentAreaContainerXPosition; + w = area.getContentWidth(); - public void renderSpanArea(SpanArea area) { + if (area instanceof BlockArea) + rx += ((BlockArea) area).getStartIndent(); + + h = area.getContentHeight(); + int ry = this.currentYPosition; + ColorType bg = area.getBackgroundColor(); - //A span maps to a textframe + rx = rx - area.getPaddingLeft(); + ry = ry + area.getPaddingTop(); + w = w + area.getPaddingLeft() + area.getPaddingRight(); + h = h + area.getPaddingTop() + area.getPaddingBottom(); - - this.mifDoc.createTextRect(area.getColumnCount()); - - Enumeration e = area.getChildren().elements(); - while (e.hasMoreElements()) { - Box b = (Box) e.nextElement(); - b.render(this); // column areas - } - } + /* + // 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); - } + 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; + int d = space.getSize(); + this.currentYPosition -= d; - } + } /** render the given SVG area */ - public void renderSVGArea(SVGArea 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(); - } - + } + + 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 x = this.currentAreaContainerXPosition + area.getXOffset(); int y = this.currentYPosition; int w = area.getContentWidth(); int h = area.getHeight(); @@ -416,119 +360,109 @@ public class MIFRenderer implements Renderer { 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"); + /* 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); + String url = img.getURL(); + this.mifDoc.addImage(url, x, pageHeight - y, w, h); - } + } } - - /** render the given inline area */ - public void renderInlineArea(InlineArea 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(); - } + // 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(); - - 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; + this.currentYPosition -= area.getPlacementOffset(); + this.currentXPosition = rx; - int bl = this.currentYPosition; - - //The start of a new linearea corresponds to a new para in FM + int bl = this.currentYPosition; - this.mifDoc.startLine(); + //The start of a new linearea corresponds to a new para in FM - Enumeration e = area.getChildren().elements(); - while (e.hasMoreElements()) { - - Box b = (Box) e.nextElement(); - this.currentYPosition = ry - area.getPlacementOffset(); - b.render(this); + this.mifDoc.startLine(); - } - this.currentYPosition = ry-h; - this.currentXPosition = rx; - + 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); - } - - } + 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) {} - } diff --git a/src/org/apache/fop/render/pcl/PCLRenderer.java b/src/org/apache/fop/render/pcl/PCLRenderer.java index 88d45c05f..9c0ed9aa9 100755 --- a/src/org/apache/fop/render/pcl/PCLRenderer.java +++ b/src/org/apache/fop/render/pcl/PCLRenderer.java @@ -1,10 +1,9 @@ /* $Id$ * 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." + * LICENSE file included with these sources. */ -//package com.eastpoint.chrysalis; package org.apache.fop.render.pcl; // FOP @@ -37,46 +36,43 @@ import java.util.Enumeration; 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 -{ +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; - } - + 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) - { + * set the PCL document's producer + * + * @param producer string indicating application producing PCL + */ + public void setProducer(String producer) { } /** @@ -85,388 +81,354 @@ public class PCLRenderer extends PrintRenderer * @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() ) - { + 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.errorln("Warning: The following id's were referenced but not found: "+ + idReferences.getInvalidIds() + "\n"); } MessageHandler.logln("writing out PCL"); - stream.flush(); + 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 - */ + * 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); + 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 - */ + * 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) - { + 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; + 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); - } + 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 - */ + * 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); - } + 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 - */ + * 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"); + 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); - } + 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() + ")"); - } + 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) - { + 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()) - { + switch (area.getAlign()) { case TextAlign.START: break; case TextAlign.END: @@ -475,8 +437,7 @@ System.out.println("PCLRenderer.printBMP() iscolor = " + iscolor); case TextAlign.JUSTIFY: break; } - switch (area.getVerticalAlign()) - { + switch (area.getVerticalAlign()) { case VerticalAlign.BASELINE: break; case VerticalAlign.MIDDLE: @@ -498,8 +459,7 @@ System.out.println("PCLRenderer.printBMP() iscolor = " + iscolor); // align and scale - switch (area.scalingMethod()) - { + switch (area.scalingMethod()) { case Scaling.UNIFORM: break; case Scaling.NON_UNIFORM: @@ -508,8 +468,7 @@ System.out.println("PCLRenderer.printBMP() iscolor = " + iscolor); // 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()) - { + switch (area.getOverflow()) { case Overflow.VISIBLE: case Overflow.SCROLL: case Overflow.AUTO: @@ -520,7 +479,7 @@ System.out.println("PCLRenderer.printBMP() iscolor = " + iscolor); area.getObject().render(this); this.currentXPosition += area.getEffectiveWidth(); - // this.currentYPosition -= area.getEffectiveHeight(); + // this.currentYPosition -= area.getEffectiveHeight(); } /** @@ -528,13 +487,13 @@ System.out.println("PCLRenderer.printBMP() iscolor = " + iscolor); * * @param area the SVG area to render */ - public void renderSVGArea(SVGArea area) - { -if ( debug ) -System.out.println("PCLRenderer.renderSVGArea(" + area + ")"); + 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(); + SVGSVGElement svg = + ((SVGDocument) area.getSVGDocument()).getRootElement(); int w = (int)(svg.getWidth().getBaseVal().getValue() * 1000); int h = (int)(svg.getHeight().getBaseVal().getValue() * 1000); @@ -549,132 +508,130 @@ System.out.println("PCLRenderer.renderSVGArea(" + area + ")"); //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; - } - } + } + + 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(); + 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(); + //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(); } /** @@ -682,97 +639,101 @@ System.out.println("PCLRenderer.renderSVGArea(" + area + ")"); * * @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; - } - */ + 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; + } + */ } } diff --git a/src/org/apache/fop/render/pcl/PCLStream.java b/src/org/apache/fop/render/pcl/PCLStream.java index bd382b35b..dadc3a984 100755 --- a/src/org/apache/fop/render/pcl/PCLStream.java +++ b/src/org/apache/fop/render/pcl/PCLStream.java @@ -1,48 +1,40 @@ /* $Id$ * 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." + * 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 class PCLStream { + OutputStream out = null; + boolean doOutput = true; - public PCLStream(OutputStream os) - { - out = os; - } + public PCLStream(OutputStream os) { + out = os; + } - public void add(String str) - { - if ( !doOutput ) - return; + 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()); - } - } + 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; - } + public void setDoOutput(boolean doout) { + doOutput = doout; + } } diff --git a/src/org/apache/fop/viewer/Command.java b/src/org/apache/fop/viewer/Command.java index fac40424a..4fd793692 100644 --- a/src/org/apache/fop/viewer/Command.java +++ b/src/org/apache/fop/viewer/Command.java @@ -1,3 +1,9 @@ +/* $Id$ + * 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, @@ -24,38 +30,35 @@ import java.net.*; */ 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 static String IMAGE_DIR = "/org/apache/fop/viewer/Images/"; + public Command(String name) { + this(name, (ImageIcon) null); + } - 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); + public Command(String name, ImageIcon anIcon) { + super(name, anIcon); } - else - putValue(SMALL_ICON, new ImageIcon(url)); - } + 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 actionPerformed(ActionEvent e) { + doit(); + } - public void doit() { - MessageHandler.errorln("Not implemented."); - } + public void doit() { + MessageHandler.errorln("Not implemented."); + } - public void undoit() { - MessageHandler.errorln("Not implemented."); - } + public void undoit() { + MessageHandler.errorln("Not implemented."); + } }