<property name="build.compiler" value="classic"/>
<property name="debug" value="on"/>
<property name="optimize" value="off"/>
- <property name="deprecation" value="off"/>
+ <property name="deprecation" value="on"/>
<property name="textfontencoding" value="WinAnsiEncoding"/>
<mkdir dir="${build.src}/${properties.dir}"/>
<mkdir dir="${build.src}/${fonts.dir}"/>
<mkdir dir="${build.src}/${svg.dir}"/>
- <mkdir dir="${build.dest}/conf"/>
<mkdir dir="${build.dest}/hyph"/>
- <copy todir="${build.dest}/conf" filtering="yes">
- <fileset dir="./conf"/>
- </copy>
</target>
<!-- =================================================================== -->
</pathconvert>
<jar jarfile="${build.dir}/${name}.jar"
basedir="${build.dest}"
- includes="org/**,conf/**,hyph/**">
+ includes="org/**,hyph/**">
<manifest>
<attribute name="Main-Class" value="${main.class}"/>
<attribute name="Class-Path" value="${manifest-classpath}"/>
+++ /dev/null
-<!ELEMENT configuration (entry+)>
-<!ELEMENT entry (key,(value | list))>
-<!ELEMENT key (#PCDATA)>
-<!ELEMENT value (#PCDATA)>
-<!ELEMENT list (value+ | subentry+)>
-<!ELEMENT subentry (key,value+)>
\ No newline at end of file
+++ /dev/null
-<!--<!DOCTYPE configuration SYSTEM "config.dtd">-->
-<!-- to developers: have a look at the config.dtd to
- see how to structure your config entries -->
-
-<configuration>
- <entry>
- <key>version</key>
- <value>FOP @version@</value>
- </entry>
-
- <!-- default values for commandline options -->
- <!-- suppress all progress information, error message are still displayed -->
- <entry>
- <key>quiet</key>
- <value>false</value>
- </entry>
-<!-- sets debug mode on/off; debug mode hasm more progress
- information and a stacktrace in case of a fatal exception -->
- <entry>
- <key>debugMode</key>
- <value>false</value>
- </entry>
- <!-- displays all configuration settings and then exits -->
- <entry>
- <key>dumpConfiguration</key>
- <value>false</value>
- </entry>
- <!-- -->
- <entry>
- <key>debugMode</key>
- <value>false</value>
- </entry>
-
-
- <!-- stream-filter-list provides the default filters that are applied to all
- stream objects within the PDF file. These are normally used for
- compression -->
- <entry role="pdf">
- <key>stream-filter-list</key>
- <list>
- <!-- provides compression using zlib flate (default is on)-->
- <value>flate</value>
-
- <!-- encodes binary data into printable ascii characters (default off)
- This provides about a 4:5 expansion of data size -->
- <value>ascii-85</value>
-
- <!-- encodes binary data with hex representation (default off)
- This filter is not recommended as it doubles the data size -->
- <!-- <value>ascii-hex</value> -->
- </list>
- </entry>
- <fonts>
- </fonts>
-</configuration>
+++ /dev/null
-<!--<!DOCTYPE configuration SYSTEM "config.dtd">-->
-<!--
- this file contains templates which allow an user easy
- configuration of Fop. Actually normally you don't need this configuration
- file, but if you need to change configuration, you should
- always use this file and *not* config.xml.
- Usage: java org.apache.fop.apps.Fop -c userconfig.xml -fo fo-file -pdf pdf-file
--->
-
-
-<configuration>
-
-<!-- NOT IMPLEMENTED
-basedir: normally the base directory is the directory where the fo file is
- located. if you want to specify your own, uncomment this entry
--->
-<!--
- <entry>
- <key>baseDir</key>
- <value></value>
- </entry>
--->
-
-<!--
-************************************************************************
- HYPHENATION
-************************************************************************
--->
-
-<!--
- hyphenation directory
- if you want to specify your own directory with hyphenation pattern
- then uncomment the next entry and add the directory name
--->
-
-<!--
- <entry>
- <key>hyphenation-dir</key>
- <value>/java/xml-fop/hyph</value>
- </entry>
--->
-
-<!--
-************************************************************************
- Add fonts here
-************************************************************************
--->
-
-<fonts>
- <!-- example -->
- <!--
- <font metrics-file="arial.xml" kerning="yes" embed-file="arial.ttf">
- <font-triplet name="Arial" style="normal" weight="normal"/>
- <font-triplet name="ArialMT" style="normal" weight="normal"/>
- </font>
- <font metrics-file="arialb.xml" kerning="yes" embed-file="arialb.ttf">
- <font-triplet name="Arial" style="normal" weight="bold"/>
- <font-triplet name="ArialMT" style="normal" weight="bold"/>
- </font>
- <font metrics-file="ariali.xml" kerning="yes" embed-file="ariali.ttf">
- <font-triplet name="Arial" style="italic" weight="normal"/>
- <font-triplet name="ArialMT" style="italic" weight="normal"/>
- </font>
- <font metrics-file="arialbi.xml" kerning="yes" embed-file="arialbi.ttf">
- <font-triplet name="Arial" style="italic" weight="bold"/>
- <font-triplet name="ArialMT" style="italic" weight="bold"/>
- </font>
- -->
-</fonts>
-
-
-</configuration>
-
-
-
public void run() throws FOPException {
Driver driver = new Driver();
setupLogger(driver);
- if (errorDump) {
- driver.setErrorDump(true);
- }
// init parser
frame.progress(resource.getString("Init parser") + " ...");
import java.io.FileNotFoundException;
// FOP
-import org.apache.fop.configuration.Configuration;
import org.apache.fop.apps.FOPException;
// Avalon
/* output: XML area tree */
private static final int AREA_OUTPUT = 9;
- /* use debug mode */
- Boolean errorDump = Boolean.FALSE;
/* show configuration information */
Boolean dumpConfiguration = Boolean.FALSE;
/* suppress any progress information */
optionsParsed = parseOptions(args);
if (optionsParsed) {
checkSettings();
- if (errorDump != null && errorDump.booleanValue()) {
- debug();
- }
}
} catch (FOPException e) {
printUsage();
}
+ public Logger getLogger() {
+ return log;
+ }
+
/**
* parses the commandline arguments
* @return true if parse was successful and procesing can continue, false if processing should stop
private boolean parseOptions(String args[]) throws FOPException {
for (int i = 0; i < args.length; i++) {
if (args[i].equals("-d") || args[i].equals("--full-error-dump")) {
- errorDump = Boolean.TRUE;
log = new ConsoleLogger(ConsoleLogger.LEVEL_DEBUG);
} else if (args[i].equals("-x")
|| args[i].equals("--dump-config")) {
return dumpConfiguration;
}
- public Boolean isDebugMode() {
- return errorDump;
- }
-
public Boolean isCoarseAreaXml() {
return suppressLowLevelAreas;
}
} else {
log.debug("no user configuration file is used [default]");
}
- if (errorDump != null) {
- log.debug("debug mode on");
- } else {
- log.debug("debug mode off [default]");
- }
if (dumpConfiguration != null) {
log.debug("dump configuration");
} else {
import java.net.URL;
-// FOP
-import org.apache.fop.configuration.Configuration;
-
/**
* super class for all classes which start Fop from the commandline
*
public class CommandLineStarter extends Starter {
CommandLineOptions commandLineOptions;
- boolean errorDump;
public CommandLineStarter(CommandLineOptions commandLineOptions)
throws FOPException {
this.commandLineOptions = commandLineOptions;
- options.setCommandLineOptions(commandLineOptions);
- errorDump =
- Configuration.getBooleanValue("debugMode").booleanValue();
super.setInputHandler(commandLineOptions.getInputHandler());
}
setupLogger(driver);
driver.initialize();
- if (errorDump) {
- driver.setErrorDump(true);
- }
-
try {
driver.setRenderer(commandLineOptions.getRenderer());
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(
import org.apache.fop.fo.FOTreeBuilder;
import org.apache.fop.fo.ElementMapping;
import org.apache.fop.render.Renderer;
-import org.apache.fop.configuration.ConfigurationReader;
-import org.apache.fop.configuration.Configuration;
import org.apache.fop.tools.DocumentInputSource;
import org.apache.fop.tools.DocumentReader;
*/
private XMLReader _reader;
- /**
- * If true, full error stacks are reported
- */
- private boolean _errorDump = false;
-
/**
* the system resources that FOP will use
*/
if(userAgent == null) {
userAgent = new FOUserAgent();
userAgent.enableLogging(getLogger());
- String base = org.apache.fop.configuration.Configuration.getStringValue("baseDir");
- userAgent.setBaseURL(base);
+ userAgent.setBaseURL("file:/.");
}
return userAgent;
}
return (_treeBuilder.hasData());
}
- /**
- * Set the error dump option
- * @param dump if true, full stacks will be reported to the error log
- */
- public void setErrorDump(boolean dump) {
- _errorDump = dump;
- }
-
/**
* Set the OutputStream to use to output the result of the Renderer
* (if applicable)
}
- /**
- * Dumps an error
- */
- public void dumpError(Exception e) {
- if (_errorDump) {
- if (e instanceof SAXException) {
- getLogger().error("", e);
- if (((SAXException)e).getException() != null) {
- getLogger().error("", ((SAXException)e).getException());
- }
- } else if (e instanceof FOPException) {
- e.printStackTrace();
- if (((FOPException)e).getException() != null) {
- getLogger().error("", ((FOPException)e).getException());
- }
- } else {
- getLogger().error("", e);
- }
- }
- }
-
/**
* Runs the formatting and renderering process using the previously set
* inputsource and outputstream
if (_reader == null) {
if (!(_source instanceof DocumentInputSource)) {
- _reader = ConfigurationReader.createParser();
+ try {
+ _reader = javax.xml.parsers.SAXParserFactory.newInstance().newSAXParser().getXMLReader();
+ } catch(Exception e) {
+ throw new FOPException(e);
+ }
}
}
} else {
System.err.println("" + e.getMessage());
}
- if (options != null && options.isDebugMode().booleanValue()) {
+ if (options != null && options.getLogger().isDebugEnabled()) {
e.printStackTrace();
} else {
System.err.println("Turn on debugging for more information");
}
} catch (java.io.FileNotFoundException e) {
System.err.println("" + e.getMessage());
- if (options != null && options.isDebugMode().booleanValue()) {
+ if (options != null && options.getLogger().isDebugEnabled()) {
e.printStackTrace();
} else {
System.err.println("Turn on debugging for more information");
+++ /dev/null
-/*
- * $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.apps;
-
-// sax
-import org.xml.sax.InputSource;
-
-// java
-import java.io.File;
-import java.io.InputStream;
-
-// fop
-import org.apache.fop.configuration.Configuration;
-import org.apache.fop.configuration.ConfigurationReader;
-
-/**
- * Options handles loading of configuration files and
- * additional setting of commandline options
- */
-public class Options {
- boolean errorDump = false;
-
- public Options() throws FOPException {
- this.loadStandardConfiguration();
- initOptions();
- }
-
- public Options(File userConfigFile) throws FOPException {
- this();
- this.loadUserconfiguration(userConfigFile);
- }
-
- public Options(CommandLineOptions clOptions) throws FOPException {
- this();
- this.setCommandLineOptions(clOptions);
- }
-
- // initializing option settings
- void initOptions() {
- if (Configuration.getBooleanValue("quiet").booleanValue()) {
- //MessageHandler.setQuiet(true);
- }
- if (Configuration.getBooleanValue("debugMode").booleanValue()) {
- errorDump = true;
- }
- if (Configuration.getBooleanValue("dumpConfiguration").booleanValue()) {
- Configuration.put("dumpConfiguration", "true");
- Configuration.dumpConfiguration();
- }
- }
-
- // setting clOptions
- void setCommandLineOptions(CommandLineOptions clOptions) {
- // load user configuration file,if there is one
- File userConfigFile = clOptions.getUserConfigFile();
- if (userConfigFile != null) {
- this.loadUserconfiguration(userConfigFile);
- }
-
- // debug mode
- if (clOptions.isDebugMode() != null) {
- errorDump = clOptions.isDebugMode().booleanValue();
- Configuration.put("debugMode", new Boolean(errorDump));
- }
-
- // show configuration settings
- boolean dumpConfiguration;
- if (clOptions.dumpConfiguration() != null) {
- dumpConfiguration = clOptions.dumpConfiguration().booleanValue();
- } else {
- dumpConfiguration =
- Configuration.getBooleanValue("dumpConfiguration").booleanValue();
- }
- if (dumpConfiguration) {
- Configuration.put("dumpConfiguration", "true");
- Configuration.dumpConfiguration();
- }
-
- // quiet mode
- if (clOptions.isQuiet() != null) {
- //MessageHandler.setQuiet(clOptions.isQuiet().booleanValue());
- }
-
- // set base directory
- String baseDir = Configuration.getStringValue("baseDir");
- if (baseDir == null) {
- try {
- baseDir =
- new File(clOptions.getInputFile().getAbsolutePath()).getParentFile().toURL().toExternalForm();
- Configuration.put("baseDir", baseDir);
- } catch (Exception e) {}
- }
- if (errorDump) {
- //log.debug("base directory: " + baseDir);
- }
- }
-
- /**
- * loads standard configuration file and a user file, if it has been specified
- */
- public void loadStandardConfiguration() throws FOPException {
- String file = "config.xml";
- InputStream configfile = null;
-
- // Try to use Context Class Loader to load the properties file.
- try {
- java.lang.reflect.Method getCCL =
- Thread.class.getMethod("getContextClassLoader", new Class[0]);
- if (getCCL != null) {
- ClassLoader contextClassLoader =
- (ClassLoader)getCCL.invoke(Thread.currentThread(),
- new Object[0]);
- configfile = contextClassLoader.getResourceAsStream("conf/"
- + file);
- }
- } catch (Exception e) {}
-
- // the entry /conf/config.xml refers to a directory conf which is a sibling of org
- if (configfile == null)
- configfile =
- ConfigurationReader.class.getResourceAsStream("/conf/"
- + file);
- if (configfile == null) {
- throw new FOPException("can't find default configuration file");
- }
- if (errorDump) {
- //log.error("reading default configuration file");
- }
- ConfigurationReader reader =
- new ConfigurationReader(new InputSource(configfile));
- if (errorDump) {
- reader.setDumpError(true);
- }
- reader.start();
-
- }
-
- public void loadUserconfiguration(String userConfigFile) {
- loadUserconfiguration(new File(userConfigFile));
- }
-
- public void loadUserconfiguration(File userConfigFile) {
- // read user configuration file
- if (userConfigFile != null) {
- //log.debug("reading user configuration file");
- ConfigurationReader reader =
- new ConfigurationReader(InputHandler.fileInputSource(userConfigFile));
- if (errorDump) {
- reader.setDumpError(true);
- }
- try {
- reader.start();
- } catch (org.apache.fop.apps.FOPException error) {
- //log.error("Could not load user configuration file "
- // + userConfigFile + " - error: "
- // + error.getMessage());
- //log.error("using default values");
- if (errorDump) {
- reader.dumpError(error);
- }
- }
- }
- }
-
-}
-
-
public void run() throws FOPException {
Driver driver = new Driver();
- if (errorDump) {
- driver.setErrorDump(true);
- }
String version = Version.getVersion();
//log.debug(version);
*/
public abstract class Starter extends AbstractLogEnabled {
- Options options;
InputHandler inputHandler;
public Starter() throws FOPException {
- options = new Options();
}
public void setInputHandler(InputHandler inputHandler) {
package org.apache.fop.apps;
-import org.apache.fop.configuration.Configuration;
-
/**
* class representing the version of FOP.
*/
* @return the version string
*/
public static String getVersion() {
- return Configuration.getStringValue("version");
+ return "1.0dev";
}
}
+++ /dev/null
-/*
- * $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.configuration;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-
-/**
- * a configuration class for all general configuration aspects except those
- * related to specific renderers. All configuration is stored
- * in key / value pairs. The value can be a String, a list of Strings
- * or a map, containing a list of key / value pairs.
- *
- */
-public class Configuration {
-
- /**
- * defines role types
- */
- public final static int STANDARD = 0;
- public final static int PDF = 1;
- public final static int AWT = 2;
-
- /**
- * stores the configuration information
- */
- private static HashMap standardConfiguration = new HashMap(30);
- private static HashMap pdfConfiguration = new HashMap(20);
- private static HashMap awtConfiguration = new HashMap(20);
-
- /**
- * contains a HashMap of existing HashMaps
- */
- private static HashMap configuration = new HashMap(3);
-
- /**
- * loads the configuration types into the configuration HashMap
- */
- static {
- configuration.put("standard", standardConfiguration);
- configuration.put("pdf", pdfConfiguration);
- configuration.put("awt", awtConfiguration);
- }
-
- public static HashMap getConfiguration() {
- return configuration;
- }
-
- /**
- * general access method
- *
- * @param key a string containing the key value for the configuration value
- * role detemines the configuration target
- * @return Object containing the value; normally you would use one of the
- * convenience methods, which return the correct form.
- * null if the key is not defined.
- */
- public static Object getValue(String key, int role) {
- switch (role) {
- case Configuration.STANDARD:
- return standardConfiguration.get(key);
- case Configuration.PDF:
- return pdfConfiguration.get(key);
- case Configuration.AWT:
- return awtConfiguration.get(key);
- default:
- return standardConfiguration.get(key);
- }
- }
-
- /**
- * convenience methods to access strings values in the configuration
- * @param key a string containing the key value for the configuration value
- * role detemines the configuration target
- * @return String a string containing the value
- * null if the key is not defined.
- */
- public static String getStringValue(String key, int role) {
- Object obj = Configuration.getValue(key, role);
- if (obj instanceof String) {
- return (String)obj;
- } else {
- return null;
- }
- }
-
- /**
- * convenience methods to access int values in the configuration
- * @param key a string containing the key value for the configuration value
- * role detemines the configuration target
- * @return int a int containing the value
- * -1 if the key is not defined.
- */
- public static int getIntValue(String key, int role) {
- Object obj = Configuration.getValue(key, role);
- if (obj instanceof String) {
- return Integer.parseInt((String)obj);
- } else {
- return -1;
- }
- }
-
- /**
- * convenience methods to access boolean values in the configuration
- * @param key a string containing the key value for the configuration value
- * role detemines the configuration target
- * @return Boolean true or false as value
- * null if the key is not defined.
- */
- public static Boolean getBooleanValue(String key, int role) {
- Object obj = Configuration.getValue(key, role);
- if (obj instanceof String) {
- return new Boolean((String)obj);
- } else if (obj instanceof Boolean) {
- return (Boolean)obj;
- } else {
- return null;
- }
- }
-
- /**
- * convenience methods to access list values in the configuration
- * @param key a string containing the key value for the configuration value
- * role detemines the configuration target
- * @return ArrayList a ArrayList containing the values
- * null if the key is not defined.
- */
- public static ArrayList getListValue(String key, int role) {
- Object obj = Configuration.getValue(key, role);
- if (obj instanceof ArrayList) {
- return (ArrayList)obj;
- } else {
- return null;
- }
- }
-
- /**
- * convenience methods to access hashmap values in the configuration
- * @param key a string containing the key value for the configuration value
- * role detemines the configuration target
- * @return HashMap a HashMap containing the values
- * null if the key is not defined.
- */
- public static HashMap getHashMapValue(String key, int role) {
- Object obj = Configuration.getValue(key, role);
- if (obj instanceof HashMap) {
- return (HashMap)obj;
- } else {
- return null;
- }
- }
-
- /**
- * convenience method which retrieves some configuration information
- * from the standard configuration
- *
- * @param key a string containing the key value for the configuration value
- * @return Object containing the value; normally you would use one of the
- * convenience methods, which return the correct form.
- * null if the key is not defined.
- */
- public static Object getValue(String key) {
- return Configuration.getValue(key, Configuration.STANDARD);
- }
-
- /**
- * convenience methods to access strings values in the standard configuration
- *
- * @param key a string containing the key value for the configuration value
- * @return String a string containing the value
- * null if the key is not defined.
- */
- public static String getStringValue(String key) {
- return Configuration.getStringValue(key, Configuration.STANDARD);
- }
-
- /**
- * convenience methods to access int values in the standard configuration
- *
- * @param key a string containing the key value for the configuration value
- * @return int a int containing the value
- * -1 if the key is not defined.
- */
- public static int getIntValue(String key) {
- return Configuration.getIntValue(key, Configuration.STANDARD);
- }
-
- /**
- * convenience methods to access boolean values in the configuration
- *
- * @param key a string containing the key value for the configuration value
- * @return boolean true or false as value
- * null if the key is not defined.
- */
- public static Boolean getBooleanValue(String key) {
- return Configuration.getBooleanValue(key, Configuration.STANDARD);
- }
-
- /**
- * convenience methods to access list values in the standard configuration
- *
- * @param key a string containing the key value for the configuration value
- * @return ArrayList a ArrayList containing the values
- * null if the key is not defined.
- */
- public static ArrayList getListValue(String key) {
- return Configuration.getListValue(key, Configuration.STANDARD);
- }
-
- /**
- * convenience methods to access hashmap values in the standard configuration
- *
- * @param key a string containing the key value for the configuration value
- * @return HashMap a HashMap containing the values
- * null if the key is not defined.
- */
- public static HashMap getHashMapValue(String key) {
- return Configuration.getHashMapValue(key, Configuration.STANDARD);
- }
-
-
- /**
- * method to access fonts values in the standard configuration
- *
- * @param key a string containing the key value for the configuration value
- * @return HashMap a HashMap containing the values
- * null if the key is not defined.
- */
- public static ArrayList getFonts() {
- return (ArrayList)Configuration.getValue("fonts",
- Configuration.STANDARD);
- }
-
- /**
- * initializes this configuration
- * @param config contains the configuration information
- */
- public static void setup(int role, HashMap config) {
- switch (role) {
- case Configuration.STANDARD:
- standardConfiguration = config;
- break;
- case Configuration.PDF:
- pdfConfiguration = config;
- break;
- case Configuration.AWT:
- awtConfiguration = config;
- break;
- default:
- //log.error("Can't setup configuration. Unknown configuration role/target");
- }
- }
-
- /**
- * adds information to the configuration hashmap in key,value form
- * @param key a string containing the key value for the configuration value
- * value the configuration information
- * role detemines the configuration target
- * @param value an Object containing the value; can be a String, a ArrayList or a HashMap
- */
- public static void put(String key, Object value, int role) {
- switch (role) {
- case Configuration.STANDARD:
- standardConfiguration.put(key, value);
- break;
- case Configuration.PDF:
- pdfConfiguration.put(key, value);
- break;
- case Configuration.AWT:
- awtConfiguration.put(key, value);
- break;
- default:
- standardConfiguration.put(key, value);
- //log.error("Unknown role for new configuration entry. "
- // + "Putting key:" + key + " - value:"
- // + value + " into standard configuration.");
- }
- }
-
- ;
-
- /**
- * adds information to the standard configuration hashmap in key,value form
- * @param key a string containing the key value for the configuration value
- * value the configuration information
- * role detemines the configuration target
- * @param value an Object containing the value; can be a String, a ArrayList or a HashMap
- */
-
- public static void put(String key, Object value) {
- Configuration.put(key, value, Configuration.STANDARD);
- }
-
- /**
- * debug methods, which writes out all information in this configuration
- */
- public static void dumpConfiguration() {
- String key;
- Object value;
- ArrayList list;
- HashMap map, configuration;
- String tmp;
- System.out.println("Dumping configuration: ");
- HashMap[] configs = {
- standardConfiguration, pdfConfiguration, awtConfiguration
- };
- for (int i = 0; i < configs.length; i++) {
- //log.debug("----------------------");
- configuration = configs[i];
- Iterator iterator = configuration.keySet().iterator();
- while (iterator.hasNext()) {
- key = (String)iterator.next();
- //log.debug("key: " + key);
- value = configuration.get(key);
- if (value instanceof String) {
- //log.debug(" value: " + value);
- } else if (value instanceof ArrayList) {
- list = (ArrayList)value;
- //log.debug(" values: ");
- for (int count = 0; count < list.size(); count++) {
- //log.debug(list.get(count) + " - ");
- }
- } else if (value instanceof HashMap) {
- map = (HashMap)value;
- Iterator iter = map.keySet().iterator();
- //log.debug(" values: ");
- while (iter.hasNext()) {
- tmp = (String)iter.next();
- //log.debug(" " + tmp + ":" + map.get(tmp));
- }
- }
- }
- }
- }
-
-
-
-}
-
+++ /dev/null
-/*
- * $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.configuration;
-
-import org.apache.fop.render.pdf.EmbedFontInfo;
-import org.apache.fop.render.pdf.FontTriplet;
-
-// sax
-import org.xml.sax.helpers.DefaultHandler;
-import org.xml.sax.Attributes;
-import org.xml.sax.Locator;
-
-// java
-import java.util.HashMap;
-import java.util.ArrayList;
-
-/**
- * SAX2 Handler which retrieves the configuration information and stores them in Configuration.
- * Normally this class doesn't need to be accessed directly.
- */
-public class ConfigurationParser extends DefaultHandler {
- private final int OUT = 0;
- private final int IN_ENTRY = 1;
- private final int IN_KEY = 2;
- private final int IN_VALUE = 4;
- private final int IN_LIST = 8;
- private final int IN_SUBENTRY = 16;
- private final int IN_SUBKEY = 32;
- private final int IN_FONTS = 64;
- private final int IN_FONT = 128;
-
- private final int STRING = 0;
- private final int LIST = 1;
- private final int MAP = 2;
-
- // state of parser
- private int status = OUT;
- private int datatype = -1;
-
- // store the result configuration
- private static HashMap configuration;
- private static HashMap activeConfiguration;
-
- // stores key for new config entry
- private String key = "";
- private ArrayList keyStack = new ArrayList();
-
- // stores string value
- private String value = "";
-
- // stores key for new config entry
- private String subkey = "";
-
- // stores list value
- private ArrayList list = new ArrayList(15);
-
- // stores hashtable value
- private HashMap map = new HashMap(15);
-
- /**
- * locator for line number information
- */
- private Locator locator;
-
- /**
- * determines role / target of configuration information, default is standard
- */
- private String role = "standard";
-
- // stores fonts
- private ArrayList fontList = null;
-
- // stores information on one font
- private EmbedFontInfo fontInfo = null;
-
- // stores information on a font triplet
- private FontTriplet fontTriplet = null;
-
- // information on a font
- private String fontName, metricsFile, embedFile, kerningAsString;
- private boolean kerning;
- private ArrayList fontTriplets;
-
- // information on a font triplet
- private String fontTripletName, weight, style;
-
- public void startDocument() {
- configuration = Configuration.getConfiguration();
- }
-
- /**
- * get locator for position information
- */
- public void setDocumentLocator(Locator locator) {
- this.locator = locator;
- }
-
- /**
- * extracts the element and attribute name and sets the fitting status and datatype values
- */
- public void startElement(String uri, String localName, String qName,
- Attributes attributes) {
- if (localName.equals("key")) {
- status += IN_KEY;
- } else if (localName.equals("value")) {
- status += IN_VALUE;
- } else if (localName.equals("list")) {
- status += IN_LIST;
- } else if (localName.equals("subentry")) {
- status += IN_SUBENTRY;
- } else if (localName.equals("entry")) {
- // role=standard as default
- if (attributes.getLength() == 0) {
- role = "standard";
- // retrieve attribute value for "role" which determines configuration target
- } else {
- role = attributes.getValue("role");
- }
- } else if (localName.equals("configuration")) {}
- else if (localName.equals("fonts")) { // list of fonts starts
- fontList = new ArrayList(10);
- } else if (localName.equals("font")) {
- kerningAsString = attributes.getValue("kerning");
- if (kerningAsString.equalsIgnoreCase("yes")) {
- kerning = true;
- } else {
- kerning = false;
- }
- metricsFile = attributes.getValue("metrics-file");
- embedFile = attributes.getValue("embed-file");
- fontName = attributes.getValue("name");
- fontTriplets = new ArrayList(5);
- } else if (localName.equals("font-triplet")) {
- fontTripletName = attributes.getValue("name");
- weight = attributes.getValue("weight");
- style = attributes.getValue("style");
- fontTriplet = new FontTriplet(fontTripletName, weight, style);
- fontTriplets.add(fontTriplet);
- } else {
- // to make sure that user knows about false tag
- //log.error("Unknown tag in configuration file: "
- // + localName);
- }
- } // end startElement
-
- /**
- * stores subentries or entries into their hashes (map for subentries, configuration for entry)
- */
- public void endElement(String uri, String localName, String qName) {
- if (localName.equals("entry")) {
- switch (datatype) {
- case STRING:
- this.store(role, key, value);
- break;
- case LIST:
- this.store(role, key, list);
- break;
- case MAP:
- this.store(role, key, map);
- }
- status = OUT;
- role = "standard";
- if (keyStack.size() > 0) {
- keyStack.remove(keyStack.size() - 1);
- }
- if (keyStack.size() > 0) {
- key = (String)keyStack.get(keyStack.size() - 1);
- } else {
- key = "";
- }
- value = "";
- } else if (localName.equals("subentry")) {
- map.put(subkey, value);
- status -= IN_SUBENTRY;
- if (keyStack.size() > 0) {
- keyStack.remove(keyStack.size() - 1);
- }
- if (keyStack.size() > 0) {
- key = (String)keyStack.get(keyStack.size() - 1);
- } else {
- key = "";
- }
- value = "";
- } else if (localName.equals("key")) {
- status -= IN_KEY;
- keyStack.add(key);
- } else if (localName.equals("list")) {
- status -= IN_LIST;
- value = "";
- } else if (localName.equals("value")) {
- status -= IN_VALUE;
- } else if (localName.equals("fonts")) {
- this.store("standard", "fonts", fontList);
- } else if (localName.equals("font")) {
- fontInfo = new EmbedFontInfo(fontName, metricsFile, kerning,
- fontTriplets, embedFile);
- fontList.add(fontInfo);
- fontTriplets = null;
- metricsFile = null;
- embedFile = null;
- fontName = null;
- kerningAsString = "";
- } else if (localName.equals("font-triplet")) {}
- }
-
- /**
- * extracts characters from text nodes and puts them into their respective
- * variables
- */
- public void characters(char[] ch, int start, int length) {
- char characters[] = new char[length];
- System.arraycopy(ch, start, characters, 0, length);
- String text = new String(characters);
- switch (status) {
- case IN_KEY:
- key = text;
- break;
- case IN_LIST + IN_SUBENTRY + IN_KEY:
- subkey = text;
- break;
- case IN_VALUE:
- value = text;
- datatype = STRING;
- break;
- case IN_LIST + IN_VALUE:
- list.add(text);
- datatype = LIST;
- break;
- case IN_LIST + IN_SUBENTRY + IN_VALUE:
- value = text;
- datatype = MAP;
- break;
- }
- } // end characters
-
- /**
- * stores configuration entry into configuration hashtable according to the role
- *
- * @param role a string containing the role / target for this configuration information
- * @param key a string containing the key value for the configuration
- * @param value a string containing the value for the configuration
- */
- private void store(String role, String key, Object value) {
- activeConfiguration = (HashMap)configuration.get(role);
- if (activeConfiguration != null) {
- activeConfiguration.put(key, value);
- } else {
- //log.error("Unknown role >" + role
- // + "< for new configuration entry. \n"
- // + "Putting configuration with key:" + key
- // + " into standard configuration.");
- }
- }
-
-}
+++ /dev/null
-/*
- * $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.configuration;
-
-// sax
-import org.xml.sax.helpers.DefaultHandler;
-import org.xml.sax.XMLReader;
-import org.xml.sax.SAXException;
-import java.io.IOException;
-import org.xml.sax.InputSource;
-
-// fop
-import org.apache.fop.apps.Driver;
-import org.apache.fop.apps.FOPException;
-import org.apache.fop.configuration.Configuration;
-
-/**
- * entry class for reading configuration from file and creating a configuration
- * class. typical use looks like that: <br>
- *
- * <code>ConfigurationReader reader = new ConfigurationReader ("config.xml","standard");
- * try {
- * reader.start();
- * } catch (org.apache.fop.apps.FOPException error) {
- * reader.dumpError(error);
- * }
- * </code>
- * Once the configuration has been setup, the information can be accessed with
- * the methods of StandardConfiguration.
- */
-public class ConfigurationReader {
-
- /**
- * show a full dump on error
- */
- private static boolean errorDump = false;
-
- /**
- * inputsource for configuration file
- */
- private InputSource filename;
-
-
- /**
- * creates a configuration reader
- * @param filename the file which contains the configuration information
- */
- public ConfigurationReader(InputSource filename) {
- this.filename = filename;
- }
-
- /**
- * intantiates parser and starts parsing of config file
- */
- public void start() throws FOPException {
- XMLReader parser = createParser();
-
- // setting the parser features
- try {
- parser.setFeature("http://xml.org/sax/features/namespace-prefixes",
- false);
- } catch (SAXException e) {
- throw new FOPException("You need a parser which supports SAX version 2",
- e);
- }
- ConfigurationParser configurationParser = new ConfigurationParser();
- parser.setContentHandler(configurationParser);
-
- try {
- parser.parse(filename);
- } catch (SAXException e) {
- if (e.getException() instanceof FOPException) {
- throw (FOPException)e.getException();
- } else {
- throw new FOPException(e);
- }
- } catch (IOException e) {
- throw new FOPException(e);
- }
- }
-
- /**
- * creates a SAX parser, using the value of org.xml.sax.parser
- * defaulting to org.apache.xerces.parsers.SAXParser
- *
- * @return the created SAX parser
- */
- public static XMLReader createParser() throws FOPException {
- String parserClassName = Driver.getParserClassName();
- if (errorDump) {
- //log.debug("configuration reader using SAX parser "
- // + parserClassName);
- }
-
- try {
- return (XMLReader)Class.forName(parserClassName).newInstance();
- } catch (ClassNotFoundException e) {
- throw new FOPException("Could not find " + parserClassName, e);
- } catch (InstantiationException e) {
- throw new FOPException("Could not instantiate "
- + parserClassName, e);
- } catch (IllegalAccessException e) {
- throw new FOPException("Could not access " + parserClassName, e);
- } catch (ClassCastException e) {
- throw new FOPException(parserClassName + " is not a SAX driver",
- e);
- }
- }
-
- /**
- * Dumps an error
- */
- public void dumpError(Exception e) {
- if (errorDump) {
- if (e instanceof SAXException) {
- e.printStackTrace();
- if (((SAXException)e).getException() != null) {
- ((SAXException)e).getException().printStackTrace();
- }
- } else {
- e.printStackTrace();
- }
- }
- }
-
- /**
- * long or short error messages
- *
- */
- public void setDumpError(boolean dumpError) {
- errorDump = dumpError;
- }
-
-}
import java.io.*;
import java.util.Hashtable;
-import org.apache.fop.configuration.*;
/**
* This class is the main entry point to the hyphenation package.
HyphenationTree hTree = getFopHyphenationTree(key);
if (hTree == null) {
- String hyphenDir =
- Configuration.getStringValue("hyphenation-dir");
+ String hyphenDir = "/hyph";
if (hyphenDir != null) {
hTree = getUserHyphenationTree(key, hyphenDir);
}
public MIFHandler(OutputStream os) {
outStream = os;
// use pdf fonts for now, this is only for resolving names
- org.apache.fop.render.pdf.FontSetup.setup(fontInfo, org.apache.fop.configuration.Configuration.getFonts());
+ org.apache.fop.render.pdf.FontSetup.setup(fontInfo, null);
}
public FontInfo getFontInfo() {
*/
public void setupFontInfo(FontInfo fontInfo) {
this.fontInfo = fontInfo;
- FontSetup.setup(fontInfo, org.apache.fop.configuration.Configuration.getFonts());
+ FontSetup.setup(fontInfo, null);
}
/**
import java.io.IOException;
import java.util.Enumeration;
import java.util.ArrayList;
-import java.util.Hashtable;
+import java.util.HashMap;
import org.apache.fop.pdf.PDFWArray;
import org.apache.fop.pdf.PDFCIDFont;
-import org.apache.fop.configuration.ConfigurationReader;
import org.apache.fop.apps.FOPException;
/**
private MultiByteFont multiFont = null;
private SingleByteFont singleFont = null;
private Font returnFont = null;
- // private SingleByteFont singleFont = null;
private String text = null;
private ArrayList cidWidths = null;
private int cidWidthIndex = 0;
- private Hashtable currentKerning = null;
+ private HashMap currentKerning = null;
private ArrayList bfranges = null;
private void createFont(String path) throws FOPException {
- XMLReader parser = ConfigurationReader.createParser();
+ XMLReader parser = null;
+
+ try {
+ parser = javax.xml.parsers.SAXParserFactory.newInstance().newSAXParser().getXMLReader();
+ } catch (Exception e) {
+ throw new FOPException(e);
+ }
if (parser == null)
throw new FOPException("Unable to create SAX parser");
cidWidthIndex = getInt(attributes.getValue("start-index"));
cidWidths = new ArrayList();
} else if ("kerning".equals(localName)) {
- currentKerning = new Hashtable();
+ currentKerning = new HashMap();
if (isCID)
multiFont.kerning.put(new Integer(attributes.getValue("kpx1")),
currentKerning);
*/
public void setupFontInfo(FontInfo fontInfo) {
/* use PDF's font setup to get PDF metrics */
- org.apache.fop.render.pdf.FontSetup.setup(fontInfo, org.apache.fop.configuration.Configuration.getFonts());
+ org.apache.fop.render.pdf.FontSetup.setup(fontInfo, null);
this.fontInfo = fontInfo;
}
public void setupFontInfo(FontInfo fontInfo) {
/* use PDF's font setup to get PDF metrics */
- org.apache.fop.render.pdf.FontSetup.setup(fontInfo, org.apache.fop.configuration.Configuration.getFonts());
+ org.apache.fop.render.pdf.FontSetup.setup(fontInfo, null);
}
private boolean isCoarseXml() {
package org.apache.fop.tools;
import org.apache.fop.apps.*;
-import org.apache.fop.configuration.*;
import org.apache.fop.area.*;
import org.apache.fop.area.inline.*;
import org.apache.fop.area.inline.Character;
package org.apache.fop.tools;
import org.apache.fop.apps.*;
-import org.apache.fop.configuration.*;
+import org.apache.fop.fo.FOUserAgent;
import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
try {
File xmlFile = new File(baseDir + "/" + xml);
-
+ String baseURL = null;
try {
- Configuration.put("baseDir",
- xmlFile.getParentFile().toURL().toExternalForm());
+ baseURL = xmlFile.getParentFile().toURL().toExternalForm();
} catch (Exception e) {
getLogger().error("Error setting base directory");
}
Driver driver = new Driver();
setupLogger(driver, "fop");
driver.initialize();
+ FOUserAgent userAgent = new FOUserAgent();
+ userAgent.setBaseURL(baseURL);
+ driver.setUserAgent(userAgent);
if (outputPDF) {
driver.setRenderer(Driver.RENDER_PDF);
} else {
import java.util.*;
// FOP
-import org.apache.fop.apps.Options;
import org.apache.fop.apps.Starter;
import org.apache.fop.apps.InputHandler;
import org.apache.fop.apps.FOInputHandler;
import org.apache.fop.apps.Driver;
import org.apache.fop.apps.FOPException;
-import org.apache.fop.configuration.Configuration;
+import org.apache.fop.fo.FOUserAgent;
// Avalon
import org.apache.avalon.framework.logger.ConsoleLogger;
class FOPTaskStarter extends Starter {
Fop task;
+ String baseURL = null;
FOPTaskStarter(Fop task) throws FOPException {
this.task = task;
public void run() throws FOPException {
if (task.userConfig != null) {
- new Options (task.userConfig);
}
try {
if (task.getFofile() != null) {
- Configuration.put("baseDir",
- task.getFofile().getParentFile().toURL().
- toExternalForm());
+ baseURL = task.getFofile().getParentFile().toURL().
+ toExternalForm();
}
} catch (Exception e) {
getLogger().error("Error setting base directory", e);
}
- task.log("Using base directory: " +
- Configuration.getValue("baseDir"), Project.MSG_DEBUG);
+ task.log("Using base URL: " + baseURL, Project.MSG_DEBUG);
int rint = determineRenderer(task.getFormat());
String newExtension = determineExtension(rint);
outf = new File(task.getOutdir(), outf.getName());
}
try {
- Configuration.put("baseDir",
- fs.getDir(task.getProject()).toURL().
- toExternalForm());
+ baseURL = fs.getDir(task.getProject()).toURL().
+ toExternalForm();
} catch (Exception e) {
- task.log("Error setting base directory",
+ task.log("Error setting base URL",
Project.MSG_DEBUG);
}
try {
Driver driver = new Driver(inputHandler.getInputSource(), out);
setupLogger(driver);
+ FOUserAgent userAgent = new FOUserAgent();
+ userAgent.setBaseURL(baseURL);
+ driver.setUserAgent(userAgent);
driver.setRenderer(renderer);
- if (renderer == Driver.RENDER_XML) {
- HashMap rendererOptions = new HashMap();
- rendererOptions.put("fineDetail", new Boolean(true));
- driver.getRenderer().setOptions(rendererOptions);
- }
driver.setXMLReader(parser);
driver.run();
out.close();