git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194574 13f79535-47bb-0310-9956-ffa450edef68pull/30/head
import java.util.*; | import java.util.*; | ||||
/** | /** | ||||
* initialize AWT previewer | * initialize AWT previewer | ||||
*/ | */ | ||||
} | } | ||||
package org.apache.fop.apps; | package org.apache.fop.apps; | ||||
import org.apache.fop.messaging.MessageHandler; | |||||
public class Fop { | public class Fop { | ||||
public static void main(String[] args) { | public static void main(String[] args) { | ||||
CommandLineOptions options = null; | CommandLineOptions options = null; | ||||
Starter starter = options.getStarter(); | Starter starter = options.getStarter(); | ||||
starter.run(); | starter.run(); | ||||
} catch (FOPException e) { | } catch (FOPException e) { | ||||
MessageHandler.errorln("" + e.getMessage()); | |||||
System.err.println("" + e.getMessage()); | |||||
if (options != null && options.isDebugMode().booleanValue()) { | if (options != null && options.isDebugMode().booleanValue()) { | ||||
e.printStackTrace(); | e.printStackTrace(); | ||||
} | } | ||||
} catch (java.io.FileNotFoundException e) { | } catch (java.io.FileNotFoundException e) { | ||||
MessageHandler.errorln("" + e.getMessage()); | |||||
System.err.println("" + e.getMessage()); | |||||
if (options != null && options.isDebugMode().booleanValue()) { | if (options != null && options.isDebugMode().booleanValue()) { | ||||
e.printStackTrace(); | e.printStackTrace(); | ||||
} | } |
import java.io.File; | import java.io.File; | ||||
// FOP | // FOP | ||||
import org.apache.fop.messaging.MessageHandler; | |||||
import org.apache.fop.configuration.Configuration; | import org.apache.fop.configuration.Configuration; | ||||
*/ | */ | ||||
protected static XMLReader createParser() throws FOPException { | protected static XMLReader createParser() throws FOPException { | ||||
String parserClassName = Driver.getParserClassName(); | String parserClassName = Driver.getParserClassName(); | ||||
MessageHandler.logln("using SAX parser " + parserClassName); | |||||
//log.debug("using SAX parser " + parserClassName); | |||||
try { | try { | ||||
return (XMLReader)Class.forName(parserClassName).newInstance(); | return (XMLReader)Class.forName(parserClassName).newInstance(); |
import java.io.InputStream; | import java.io.InputStream; | ||||
// fop | // fop | ||||
import org.apache.fop.messaging.MessageHandler; | |||||
import org.apache.fop.configuration.Configuration; | import org.apache.fop.configuration.Configuration; | ||||
import org.apache.fop.configuration.ConfigurationReader; | import org.apache.fop.configuration.ConfigurationReader; | ||||
// initializing option settings | // initializing option settings | ||||
void initOptions() { | void initOptions() { | ||||
if (Configuration.getBooleanValue("quiet").booleanValue()) { | if (Configuration.getBooleanValue("quiet").booleanValue()) { | ||||
MessageHandler.setQuiet(true); | |||||
//MessageHandler.setQuiet(true); | |||||
} | } | ||||
if (Configuration.getBooleanValue("debugMode").booleanValue()) { | if (Configuration.getBooleanValue("debugMode").booleanValue()) { | ||||
errorDump = true; | errorDump = true; | ||||
// quiet mode | // quiet mode | ||||
if (clOptions.isQuiet() != null) { | if (clOptions.isQuiet() != null) { | ||||
MessageHandler.setQuiet(clOptions.isQuiet().booleanValue()); | |||||
//MessageHandler.setQuiet(clOptions.isQuiet().booleanValue()); | |||||
} | } | ||||
// set base directory | // set base directory | ||||
} catch (Exception e) {} | } catch (Exception e) {} | ||||
} | } | ||||
if (errorDump) { | if (errorDump) { | ||||
MessageHandler.logln("base directory: " + baseDir); | |||||
//log.debug("base directory: " + baseDir); | |||||
} | } | ||||
} | } | ||||
throw new FOPException("can't find default configuration file"); | throw new FOPException("can't find default configuration file"); | ||||
} | } | ||||
if (errorDump) { | if (errorDump) { | ||||
MessageHandler.logln("reading default configuration file"); | |||||
//log.error("reading default configuration file"); | |||||
} | } | ||||
ConfigurationReader reader = | ConfigurationReader reader = | ||||
new ConfigurationReader(new InputSource(configfile)); | new ConfigurationReader(new InputSource(configfile)); | ||||
public void loadUserconfiguration(File userConfigFile) { | public void loadUserconfiguration(File userConfigFile) { | ||||
// read user configuration file | // read user configuration file | ||||
if (userConfigFile != null) { | if (userConfigFile != null) { | ||||
MessageHandler.logln("reading user configuration file"); | |||||
//log.debug("reading user configuration file"); | |||||
ConfigurationReader reader = | ConfigurationReader reader = | ||||
new ConfigurationReader(InputHandler.fileInputSource(userConfigFile)); | new ConfigurationReader(InputHandler.fileInputSource(userConfigFile)); | ||||
if (errorDump) { | if (errorDump) { | ||||
try { | try { | ||||
reader.start(); | reader.start(); | ||||
} catch (org.apache.fop.apps.FOPException error) { | } catch (org.apache.fop.apps.FOPException error) { | ||||
MessageHandler.errorln("Could not load user configuration file " | |||||
+ userConfigFile + " - error: " | |||||
+ error.getMessage()); | |||||
MessageHandler.errorln("using default values"); | |||||
//log.error("Could not load user configuration file " | |||||
// + userConfigFile + " - error: " | |||||
// + error.getMessage()); | |||||
//log.error("using default values"); | |||||
if (errorDump) { | if (errorDump) { | ||||
reader.dumpError(error); | reader.dumpError(error); | ||||
} | } |
import org.apache.fop.render.awt.AWTRenderer; | import org.apache.fop.render.awt.AWTRenderer; | ||||
import org.apache.fop.layout.AreaTree; | import org.apache.fop.layout.AreaTree; | ||||
import org.apache.fop.layout.Page; | import org.apache.fop.layout.Page; | ||||
import org.apache.fop.messaging.MessageHandler; | |||||
/** | /** | ||||
* This class prints a xsl-fo dokument without interaction. | * This class prints a xsl-fo dokument without interaction. | ||||
} | } | ||||
String version = Version.getVersion(); | String version = Version.getVersion(); | ||||
MessageHandler.errorln(version); | |||||
//log.debug(version); | |||||
XMLReader parser = inputHandler.getParser(); | XMLReader parser = inputHandler.getParser(); | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.HashMap; | import java.util.HashMap; | ||||
import java.util.Iterator; | import java.util.Iterator; | ||||
import org.apache.fop.messaging.MessageHandler; | |||||
/** | /** | ||||
* a configuration class for all general configuration aspects except those | * a configuration class for all general configuration aspects except those | ||||
awtConfiguration = config; | awtConfiguration = config; | ||||
break; | break; | ||||
default: | default: | ||||
MessageHandler.errorln("Can't setup configuration. Unknown configuration role/target"); | |||||
//log.error("Can't setup configuration. Unknown configuration role/target"); | |||||
} | } | ||||
} | } | ||||
break; | break; | ||||
default: | default: | ||||
standardConfiguration.put(key, value); | standardConfiguration.put(key, value); | ||||
MessageHandler.errorln("Unknown role for new configuration entry. " | |||||
+ "Putting key:" + key + " - value:" | |||||
+ value + " into standard configuration."); | |||||
//log.error("Unknown role for new configuration entry. " | |||||
// + "Putting key:" + key + " - value:" | |||||
// + value + " into standard configuration."); | |||||
} | } | ||||
} | } | ||||
standardConfiguration, pdfConfiguration, awtConfiguration | standardConfiguration, pdfConfiguration, awtConfiguration | ||||
}; | }; | ||||
for (int i = 0; i < configs.length; i++) { | for (int i = 0; i < configs.length; i++) { | ||||
MessageHandler.logln("----------------------"); | |||||
//log.debug("----------------------"); | |||||
configuration = configs[i]; | configuration = configs[i]; | ||||
Iterator iterator = configuration.keySet().iterator(); | Iterator iterator = configuration.keySet().iterator(); | ||||
while (iterator.hasNext()) { | while (iterator.hasNext()) { | ||||
key = (String)iterator.next(); | key = (String)iterator.next(); | ||||
MessageHandler.logln("key: " + key); | |||||
//log.debug("key: " + key); | |||||
value = configuration.get(key); | value = configuration.get(key); | ||||
if (value instanceof String) { | if (value instanceof String) { | ||||
MessageHandler.logln(" value: " + value); | |||||
//log.debug(" value: " + value); | |||||
} else if (value instanceof ArrayList) { | } else if (value instanceof ArrayList) { | ||||
list = (ArrayList)value; | list = (ArrayList)value; | ||||
MessageHandler.log(" values: "); | |||||
//log.debug(" values: "); | |||||
for (int count = 0; count < list.size(); count++) { | for (int count = 0; count < list.size(); count++) { | ||||
MessageHandler.log(list.get(count) + " - "); | |||||
//log.debug(list.get(count) + " - "); | |||||
} | } | ||||
MessageHandler.logln(""); | |||||
} else if (value instanceof HashMap) { | } else if (value instanceof HashMap) { | ||||
map = (HashMap)value; | map = (HashMap)value; | ||||
Iterator iter = map.keySet().iterator(); | Iterator iter = map.keySet().iterator(); | ||||
MessageHandler.log(" values: "); | |||||
//log.debug(" values: "); | |||||
while (iter.hasNext()) { | while (iter.hasNext()) { | ||||
tmp = (String)iter.next(); | tmp = (String)iter.next(); | ||||
MessageHandler.log(" " + tmp + ":" + map.get(tmp)); | |||||
//log.debug(" " + tmp + ":" + map.get(tmp)); | |||||
} | } | ||||
MessageHandler.logln(""); | |||||
} | } | ||||
} | } | ||||
} | } |
import java.util.HashMap; | import java.util.HashMap; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
// fop | |||||
import org.apache.fop.messaging.MessageHandler; | |||||
/** | /** | ||||
* SAX2 Handler which retrieves the configuration information and stores them in Configuration. | * SAX2 Handler which retrieves the configuration information and stores them in Configuration. | ||||
* Normally this class doesn't need to be accessed directly. | * Normally this class doesn't need to be accessed directly. | ||||
fontTriplets.add(fontTriplet); | fontTriplets.add(fontTriplet); | ||||
} else { | } else { | ||||
// to make sure that user knows about false tag | // to make sure that user knows about false tag | ||||
MessageHandler.errorln("Unknown tag in configuration file: " | |||||
+ localName); | |||||
//log.error("Unknown tag in configuration file: " | |||||
// + localName); | |||||
} | } | ||||
} // end startElement | } // end startElement | ||||
if (activeConfiguration != null) { | if (activeConfiguration != null) { | ||||
activeConfiguration.put(key, value); | activeConfiguration.put(key, value); | ||||
} else { | } else { | ||||
MessageHandler.errorln("Unknown role >" + role | |||||
+ "< for new configuration entry. \n" | |||||
+ "Putting configuration with key:" + key | |||||
+ " into standard configuration."); | |||||
//log.error("Unknown role >" + role | |||||
// + "< for new configuration entry. \n" | |||||
// + "Putting configuration with key:" + key | |||||
// + " into standard configuration."); | |||||
} | } | ||||
} | } | ||||
// fop | // fop | ||||
import org.apache.fop.apps.Driver; | import org.apache.fop.apps.Driver; | ||||
import org.apache.fop.messaging.MessageHandler; | |||||
import org.apache.fop.apps.FOPException; | import org.apache.fop.apps.FOPException; | ||||
import org.apache.fop.configuration.Configuration; | import org.apache.fop.configuration.Configuration; | ||||
public static XMLReader createParser() throws FOPException { | public static XMLReader createParser() throws FOPException { | ||||
String parserClassName = Driver.getParserClassName(); | String parserClassName = Driver.getParserClassName(); | ||||
if (errorDump) { | if (errorDump) { | ||||
MessageHandler.logln("configuration reader using SAX parser " | |||||
+ parserClassName); | |||||
//log.debug("configuration reader using SAX parser " | |||||
// + parserClassName); | |||||
} | } | ||||
try { | try { |
package org.apache.fop.datatypes; | package org.apache.fop.datatypes; | ||||
import org.apache.fop.fo.Property; | import org.apache.fop.fo.Property; | ||||
import org.apache.fop.messaging.MessageHandler; | |||||
/** | /** | ||||
* a length quantity in XSL which is specified as "auto" | * a length quantity in XSL which is specified as "auto" |
package org.apache.fop.datatypes; | package org.apache.fop.datatypes; | ||||
import java.util.*; | import java.util.*; | ||||
import org.apache.fop.messaging.MessageHandler; | |||||
/** | /** | ||||
* a colour quantity in XSL | * a colour quantity in XSL | ||||
this.red = 0; | this.red = 0; | ||||
this.green = 0; | this.green = 0; | ||||
this.blue = 0; | this.blue = 0; | ||||
MessageHandler.errorln("unknown colour format. Must be #RGB or #RRGGBB"); | |||||
//log.error("unknown colour format. Must be #RGB or #RRGGBB"); | |||||
} | } | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
this.red = 0; | this.red = 0; | ||||
this.green = 0; | this.green = 0; | ||||
this.blue = 0; | this.blue = 0; | ||||
MessageHandler.errorln("unknown colour format. Must be #RGB or #RRGGBB"); | |||||
//log.error("unknown colour format. Must be #RGB or #RRGGBB"); | |||||
} | } | ||||
} else if (value.startsWith("rgb(")) { | } else if (value.startsWith("rgb(")) { | ||||
int poss = value.indexOf("("); | int poss = value.indexOf("("); | ||||
this.red = 0; | this.red = 0; | ||||
this.green = 0; | this.green = 0; | ||||
this.blue = 0; | this.blue = 0; | ||||
MessageHandler.errorln("unknown colour format. Must be #RGB or #RRGGBB"); | |||||
//log.error("unknown colour format. Must be #RGB or #RRGGBB"); | |||||
} | } | ||||
} | } | ||||
} else if (value.startsWith("url(")) { | } else if (value.startsWith("url(")) { | ||||
this.red = 0; | this.red = 0; | ||||
this.green = 0; | this.green = 0; | ||||
this.blue = 0; | this.blue = 0; | ||||
MessageHandler.errorln("unknown colour name: " | |||||
+ value); | |||||
//log.error("unknown colour name: " | |||||
// + value); | |||||
} | } | ||||
} | } | ||||
} | } |
import org.apache.fop.fo.Property; | import org.apache.fop.fo.Property; | ||||
import org.apache.fop.fo.expr.Numeric; | import org.apache.fop.fo.expr.Numeric; | ||||
import org.apache.fop.messaging.MessageHandler; | |||||
/** | /** | ||||
* a length quantity in XSL | * a length quantity in XSL | ||||
dvalue = dvalue * assumed_resolution; | dvalue = dvalue * assumed_resolution; | ||||
else { | else { | ||||
dvalue = 0; | dvalue = 0; | ||||
MessageHandler.errorln("unknown length unit '" + unit | |||||
+ "'"); | |||||
//log.error("unknown length unit '" + unit | |||||
// + "'"); | |||||
} | } | ||||
setComputedValue((int)(dvalue * 1000)); | setComputedValue((int)(dvalue * 1000)); | ||||
} | } |
import org.apache.fop.fo.expr.Numeric; | import org.apache.fop.fo.expr.Numeric; | ||||
import org.apache.fop.fo.Property; | import org.apache.fop.fo.Property; | ||||
import org.apache.fop.messaging.MessageHandler; | |||||
/** | /** | ||||
* a length quantity in XSL | * a length quantity in XSL |
import org.apache.fop.fo.FObj; | import org.apache.fop.fo.FObj; | ||||
import org.apache.fop.fo.FONode; | import org.apache.fop.fo.FONode; | ||||
import org.apache.fop.fo.PropertyList; | import org.apache.fop.fo.PropertyList; | ||||
import org.apache.fop.messaging.MessageHandler; | |||||
public class LengthBase implements PercentBase { | public class LengthBase implements PercentBase { | ||||
// Standard kinds of percent-based length | // Standard kinds of percent-based length | ||||
return 0; | return 0; | ||||
} | } | ||||
case CUSTOM_BASE: | case CUSTOM_BASE: | ||||
MessageHandler.errorln("!!! LengthBase.getBaseLength() called on CUSTOM_BASE type !!!"); | |||||
//log.debug("!!! LengthBase.getBaseLength() called on CUSTOM_BASE type !!!"); | |||||
return 0; | return 0; | ||||
default: | default: | ||||
MessageHandler.errorln("Unknown base type for LengthBase."); | |||||
//log.error("Unknown base type for LengthBase."); | |||||
return 0; | return 0; | ||||
} | } | ||||
} | } |
* // if minimum is explicit, force max to min | * // if minimum is explicit, force max to min | ||||
* if ((bfSet&MAXSET)!=0) { | * if ((bfSet&MAXSET)!=0) { | ||||
* // Warning: min>max, resetting max to min | * // Warning: min>max, resetting max to min | ||||
* MessageHandler.errorln("forcing max to min in LengthRange"); | |||||
* log.error("forcing max to min in LengthRange"); | |||||
* } | * } | ||||
* maximum = minimum ; | * maximum = minimum ; | ||||
* } | * } | ||||
* if ((bfSet&OPTSET)!=0) { | * if ((bfSet&OPTSET)!=0) { | ||||
* if ((bfSet&MAXSET)!=0) { | * if ((bfSet&MAXSET)!=0) { | ||||
* // Warning: opt > max, resetting opt to max | * // Warning: opt > max, resetting opt to max | ||||
* MessageHandler.errorln("forcing opt to max in LengthRange"); | |||||
* log.error("forcing opt to max in LengthRange"); | |||||
* optimum = maximum ; | * optimum = maximum ; | ||||
* } | * } | ||||
* else { | * else { | ||||
* if ((bfSet&MINSET)!=0) { | * if ((bfSet&MINSET)!=0) { | ||||
* // if minimum is explicit, force opt to min | * // if minimum is explicit, force opt to min | ||||
* if ((bfSet&OPTSET)!=0) { | * if ((bfSet&OPTSET)!=0) { | ||||
* MessageHandler.errorln("forcing opt to min in LengthRange"); | |||||
* log.error("forcing opt to min in LengthRange"); | |||||
* } | * } | ||||
* optimum = minimum ; | * optimum = minimum ; | ||||
* } | * } |
// FOP | // FOP | ||||
import org.apache.fop.datatypes.ColorType; | import org.apache.fop.datatypes.ColorType; | ||||
import java.awt.color.ICC_Profile; | |||||
import java.awt.color.ICC_ColorSpace; | |||||
import java.net.URL; | |||||
import java.io.IOException; | |||||
import java.io.InputStream; | |||||
/** | /** | ||||
* The fo:color-profile formatting object. | * The fo:color-profile formatting object. | ||||
* This loads the color profile when needed and resolves a requested color. | * This loads the color profile when needed and resolves a requested color. | ||||
int intent; | int intent; | ||||
String src; | String src; | ||||
String profileName; | String profileName; | ||||
ICC_ColorSpace colorSpace = null; | |||||
protected ColorProfile(FONode parent) { | protected ColorProfile(FONode parent) { | ||||
super(parent); | super(parent); | ||||
* or the value is not found. | * or the value is not found. | ||||
*/ | */ | ||||
public ColorType getColor(int[] colorVals, int defR, int defG, int defB) { | public ColorType getColor(int[] colorVals, int defR, int defG, int defB) { | ||||
// float[] rgbvals = colorSpace.toRGB(colorVals); | |||||
// return new ColorType(rgbvals); | |||||
return null; | return null; | ||||
} | } | ||||
* Load the color profile. | * Load the color profile. | ||||
*/ | */ | ||||
private void load() { | private void load() { | ||||
try { | |||||
URL url = new URL(src); | |||||
InputStream is = url.openStream(); | |||||
ICC_Profile iccProfile = ICC_Profile.getInstance(is); | |||||
colorSpace = new ICC_ColorSpace(iccProfile); | |||||
} catch(IOException ioe) { | |||||
log.error("Could not read Color Profile src", ioe); | |||||
} catch(IllegalArgumentException iae) { | |||||
log.error("Color Profile src not an ICC Profile", iae); | |||||
} | |||||
} | } | ||||
} | } |
package org.apache.fop.fo; | package org.apache.fop.fo; | ||||
import org.apache.fop.apps.FOPException; | import org.apache.fop.apps.FOPException; | ||||
import org.apache.fop.messaging.MessageHandler; | |||||
public class EnumProperty extends Property { | public class EnumProperty extends Property { | ||||
* Called by subclass if no match found. | * Called by subclass if no match found. | ||||
*/ | */ | ||||
public Property checkEnumValues(String value) { | public Property checkEnumValues(String value) { | ||||
MessageHandler.errorln("Unknown enumerated value for property '" | |||||
+ getPropName() + "': " + value); | |||||
//log.error("Unknown enumerated value for property '" | |||||
// + getPropName() + "': " + value); | |||||
return null; | return null; | ||||
} | } | ||||
return setSubprop(baseProp, partName, p); | return setSubprop(baseProp, partName, p); | ||||
} | } | ||||
} else { | } else { | ||||
//MessageHandler.errorln("compound property component " | |||||
//log.error("compound property component " | |||||
// + partName + " unknown."); | // + partName + " unknown."); | ||||
} | } | ||||
return baseProp; | return baseProp; | ||||
} | } | ||||
} catch (FOPException e) { | } catch (FOPException e) { | ||||
//MessageHandler.errorln("convertShorthandProperty caught FOPException " | |||||
//log.error("convertShorthandProperty caught FOPException " | |||||
// + e); | // + e); | ||||
} catch (org.apache.fop.fo.expr.PropertyException propEx) { | } catch (org.apache.fop.fo.expr.PropertyException propEx) { | ||||
//MessageHandler.errorln("convertShorthandProperty caught PropertyException " | |||||
//log.error("convertShorthandProperty caught PropertyException " | |||||
// + propEx); | // + propEx); | ||||
} | } | ||||
if (pret != null) { | if (pret != null) { | ||||
return make(propertyList, specVal, | return make(propertyList, specVal, | ||||
propertyList.getParentFObj()); | propertyList.getParentFObj()); | ||||
} catch (FOPException e) { | } catch (FOPException e) { | ||||
//MessageHandler.errorln("Error computing property value for " | |||||
//log.error("Error computing property value for " | |||||
// + propName + " from " | // + propName + " from " | ||||
// + specVal); | // + specVal); | ||||
return null; | return null; |
package org.apache.fop.fo; | package org.apache.fop.fo; | ||||
import java.util.HashMap; | import java.util.HashMap; | ||||
import org.apache.fop.messaging.MessageHandler; | |||||
import org.apache.fop.fo.properties.WritingMode; | import org.apache.fop.fo.properties.WritingMode; | ||||
import org.apache.fop.apps.FOPException; | import org.apache.fop.apps.FOPException; | ||||
return builder.makeProperty(this, namespace, element, | return builder.makeProperty(this, namespace, element, | ||||
propertyName); | propertyName); | ||||
} catch (org.apache.fop.apps.FOPException e) { | } catch (org.apache.fop.apps.FOPException e) { | ||||
MessageHandler.errorln("Exception in getInherited(): property=" | |||||
+ propertyName + " : " + e); | |||||
//log.error("Exception in getInherited(): property=" | |||||
// + propertyName + " : " + e); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
private Property get(String propertyName, boolean bTryInherit, | private Property get(String propertyName, boolean bTryInherit, | ||||
boolean bTryDefault) { | boolean bTryDefault) { | ||||
if (builder == null) | |||||
MessageHandler.errorln("OH OH, builder has not been set"); | |||||
if (builder == null) { | |||||
//log.error("OH OH, builder has not been set"); | |||||
} | |||||
/* Handle request for one part of a compound property */ | /* Handle request for one part of a compound property */ | ||||
int sepchar = propertyName.indexOf('.'); | int sepchar = propertyName.indexOf('.'); | ||||
String subpropName = null; | String subpropName = null; | ||||
p = this.builder.makeProperty(this, namespace, element, | p = this.builder.makeProperty(this, namespace, element, | ||||
propertyName); | propertyName); | ||||
} catch (FOPException e) { | } catch (FOPException e) { | ||||
MessageHandler.errorln("Exception in getNearestSpecified(): property=" | |||||
+ propertyName + " : " + e); | |||||
//log.error("Exception in getNearestSpecified(): property=" | |||||
// + propertyName + " : " + e); | |||||
} | } | ||||
} | } | ||||
return p; | return p; | ||||
return builder.makeProperty(this, namespace, element, | return builder.makeProperty(this, namespace, element, | ||||
propertyName); | propertyName); | ||||
} catch (org.apache.fop.apps.FOPException e) { | } catch (org.apache.fop.apps.FOPException e) { | ||||
MessageHandler.errorln("Exception in getFromParent(): property=" | |||||
+ propertyName + " : " + e); | |||||
//log.error("Exception in getFromParent(): property=" | |||||
// + propertyName + " : " + e); | |||||
} | } | ||||
} | } | ||||
return null; // No builder or exception in makeProperty! | return null; // No builder or exception in makeProperty! |
package org.apache.fop.fo; | package org.apache.fop.fo; | ||||
import org.apache.fop.fo.properties.*; | import org.apache.fop.fo.properties.*; | ||||
import org.apache.fop.messaging.MessageHandler; | |||||
import org.apache.fop.svg.*; | import org.apache.fop.svg.*; | ||||
import org.apache.fop.datatypes.*; | import org.apache.fop.datatypes.*; | ||||
try { | try { | ||||
p = propertyMaker.compute(propertyList); | p = propertyMaker.compute(propertyList); | ||||
} catch (FOPException e) { | } catch (FOPException e) { | ||||
MessageHandler.errorln("exception occurred while computing" | |||||
+ " value of property '" | |||||
+ propertyName + "': " | |||||
+ e.getMessage()); | |||||
//log.error("exception occurred while computing" | |||||
// + " value of property '" | |||||
// + propertyName + "': " | |||||
// + e.getMessage()); | |||||
} | } | ||||
} else { | } else { | ||||
MessageHandler.errorln("property " + propertyName | |||||
+ " ignored"); | |||||
//log.error("property " + propertyName | |||||
// + " ignored"); | |||||
} | } | ||||
return p; | return p; | ||||
} | } | ||||
if (propertyMaker != null) { | if (propertyMaker != null) { | ||||
b = propertyMaker.isInherited(); | b = propertyMaker.isInherited(); | ||||
} else { | } else { | ||||
// MessageHandler.errorln("Unknown property " + propertyName); | |||||
// log.error("Unknown property " + propertyName); | |||||
b = true; | b = true; | ||||
} | } | ||||
return b; | return b; | ||||
p.put(propName, propVal); | p.put(propName, propVal); | ||||
} | } | ||||
} catch (FOPException e) { /* Do other props. */ | } catch (FOPException e) { /* Do other props. */ | ||||
MessageHandler.errorln(e.getMessage()); | |||||
//log.error(e.getMessage()); | |||||
} | } | ||||
} else { | } else { | ||||
if (!attributeName.startsWith("xmlns")) | |||||
MessageHandler.errorln("property '" | |||||
+ attributeName + "' ignored"); | |||||
if (!attributeName.startsWith("xmlns")) { | |||||
//log.error("property '" | |||||
// + attributeName + "' ignored"); | |||||
} | |||||
} | } | ||||
} | } | ||||
if (propertyMaker != null) { | if (propertyMaker != null) { | ||||
return propertyMaker.isCorrespondingForced(propertyList); | return propertyMaker.isCorrespondingForced(propertyList); | ||||
} else { | } else { | ||||
MessageHandler.errorln("no Maker for " + propertyName); | |||||
//log.error("no Maker for " + propertyName); | |||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
if (propertyMaker != null) { | if (propertyMaker != null) { | ||||
return propertyMaker.getShorthand(propertyList); | return propertyMaker.getShorthand(propertyList); | ||||
} else { | } else { | ||||
MessageHandler.errorln("no Maker for " + propertyName); | |||||
//log.error("no Maker for " + propertyName); | |||||
return null; | return null; | ||||
} | } | ||||
} | } | ||||
if (propertyMaker != null) { | if (propertyMaker != null) { | ||||
p = propertyMaker.make(propertyList); | p = propertyMaker.make(propertyList); | ||||
} else { | } else { | ||||
MessageHandler.errorln("property " + propertyName | |||||
+ " ignored"); | |||||
//log.error("property " + propertyName | |||||
// + " ignored"); | |||||
} | } | ||||
return p; | return p; | ||||
} | } |
public void handleAttrs(Attributes attlist) throws FOPException { | public void handleAttrs(Attributes attlist) throws FOPException { | ||||
attr = attlist; | attr = attlist; | ||||
} | } | ||||
public Document getDocument() { | |||||
return doc; | |||||
} | |||||
public abstract String getNameSpace(); | public abstract String getNameSpace(); | ||||
protected static HashMap ns = new HashMap(); | protected static HashMap ns = new HashMap(); |
public Character(FONode parent) { | public Character(FONode parent) { | ||||
super(parent); | super(parent); | ||||
this.name = "fo:character"; | |||||
} | } | ||||
public Status layout(Area area) throws FOPException { | public Status layout(Area area) throws FOPException { |
public Flow(FONode parent) { | public Flow(FONode parent) { | ||||
super(parent); | super(parent); | ||||
this.name = getElementName(); | |||||
} | } | ||||
public void handleAttrs(Attributes attlist) throws FOPException { | public void handleAttrs(Attributes attlist) throws FOPException { | ||||
protected void setFlowName(String name) throws FOPException { | protected void setFlowName(String name) throws FOPException { | ||||
if (name == null || name.equals("")) { | if (name == null || name.equals("")) { | ||||
log.warn("A 'flow-name' is required for " | log.warn("A 'flow-name' is required for " | ||||
+ getElementName() | |||||
+ getName() | |||||
+ ". This constraint will be enforced in future versions of FOP"); | + ". This constraint will be enforced in future versions of FOP"); | ||||
_flowName = "xsl-region-body"; | _flowName = "xsl-region-body"; | ||||
} else { | } else { | ||||
return this.contentWidth; | return this.contentWidth; | ||||
} | } | ||||
protected String getElementName() { | |||||
return "fo:flow"; | |||||
} | |||||
public Status getStatus() { | public Status getStatus() { | ||||
return _status; | return _status; | ||||
} | } | ||||
public boolean generatesReferenceAreas() { | public boolean generatesReferenceAreas() { | ||||
return true; | return true; | ||||
} | } |
public Footnote(FONode parent) { | public Footnote(FONode parent) { | ||||
super(parent); | super(parent); | ||||
this.name = "fo:footnote"; | |||||
} | } | ||||
public Status layout(Area area) throws FOPException { | public Status layout(Area area) throws FOPException { |
public FootnoteBody(FONode parent) { | public FootnoteBody(FONode parent) { | ||||
super(parent); | super(parent); | ||||
this.name = "fo:footnote-body"; | |||||
} | } | ||||
public Status layout(Area area) throws FOPException { | public Status layout(Area area) throws FOPException { |
// FOP | // FOP | ||||
import org.apache.fop.fo.*; | import org.apache.fop.fo.*; | ||||
import org.apache.fop.fo.properties.*; | import org.apache.fop.fo.properties.*; | ||||
import org.apache.fop.layout.*; | |||||
import org.apache.fop.layout.inline.*; | |||||
import org.apache.fop.layout.BlockArea; | |||||
import org.apache.fop.area.inline.InlineArea; | |||||
import org.apache.fop.area.inline.Viewport; | |||||
import org.apache.fop.area.inline.ForeignObject; | |||||
import org.apache.fop.layout.FontState; | import org.apache.fop.layout.FontState; | ||||
import org.apache.fop.layout.AccessibilityProps; | |||||
import org.apache.fop.layout.AuralProps; | |||||
import org.apache.fop.layout.BorderAndPadding; | |||||
import org.apache.fop.layout.BackgroundProps; | |||||
import org.apache.fop.layout.MarginInlineProps; | |||||
import org.apache.fop.layout.RelativePositionProps; | |||||
import org.apache.fop.apps.FOPException; | import org.apache.fop.apps.FOPException; | ||||
// Java | |||||
import java.util.Enumeration; | |||||
import org.w3c.dom.Document; | |||||
public class InstreamForeignObject extends FObj { | public class InstreamForeignObject extends FObj { | ||||
int startIndent; | int startIndent; | ||||
int endIndent; | int endIndent; | ||||
ForeignObjectArea areaCurrent; | |||||
Viewport areaCurrent; | |||||
/** | /** | ||||
* constructs an instream-foreign-object object (called by Maker). | * constructs an instream-foreign-object object (called by Maker). | ||||
super(parent); | super(parent); | ||||
} | } | ||||
/** | |||||
* Get the inline area created by this element. | |||||
*/ | |||||
protected InlineArea getInlineArea() { | |||||
if (children == null) { | |||||
return areaCurrent; | |||||
} | |||||
if (this.children.size() != 1) { | |||||
// error | |||||
} | |||||
FONode fo = (FONode)children.get(0); | |||||
if(!(fo instanceof XMLObj)) { | |||||
// error | |||||
} | |||||
XMLObj child = (XMLObj)fo; | |||||
// Common Accessibility Properties | |||||
AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); | |||||
// Common Aural Properties | |||||
AuralProps mAurProps = propMgr.getAuralProps(); | |||||
// Common Border, Padding, and Background Properties | |||||
BorderAndPadding bap = propMgr.getBorderAndPadding(); | |||||
BackgroundProps bProps = propMgr.getBackgroundProps(); | |||||
// Common Margin Properties-Inline | |||||
MarginInlineProps mProps = propMgr.getMarginInlineProps(); | |||||
// Common Relative Position Properties | |||||
RelativePositionProps mRelProps = propMgr.getRelativePositionProps(); | |||||
// viewport size is determined by block-progression-dimension | |||||
// and inline-progression-dimension | |||||
// if replaced then use height then ignore block-progression-dimension | |||||
//int h = this.properties.get("height").getLength().mvalue(); | |||||
// use line-height then ignore dimension in height direction | |||||
int lh = this.properties.get("line-height").getLength().mvalue(); | |||||
int bpd = this.properties.get("block-progression-dimension").getLength().mvalue(); | |||||
int ipd = this.properties.get("inline-progression-dimension").getLength().mvalue(); | |||||
// if auto then use the intrinsic size of the content scaled | |||||
// to the content-height and content-width | |||||
Document doc = child.getDocument(); | |||||
String ns = child.getNameSpace(); | |||||
children = null; | |||||
ForeignObject foreign = new ForeignObject(doc, ns); | |||||
areaCurrent = new Viewport(foreign); | |||||
return areaCurrent; | |||||
} | |||||
/** | /** | ||||
* layout this formatting object. | * layout this formatting object. | ||||
* | * | ||||
* @param area the area to layout the object into | * @param area the area to layout the object into | ||||
* | * | ||||
* @return the status of the layout | * @return the status of the layout | ||||
*/ | |||||
* | |||||
public Status layout(Area area) throws FOPException { | public Status layout(Area area) throws FOPException { | ||||
if (this.marker == BREAK_AFTER) { | if (this.marker == BREAK_AFTER) { | ||||
// this.properties.get("text-align"); | // this.properties.get("text-align"); | ||||
// this.properties.get("width"); | // this.properties.get("width"); | ||||
/* retrieve properties */ | |||||
/* retrieve properties * | |||||
String id = this.properties.get("id").getString(); | String id = this.properties.get("id").getString(); | ||||
int align = this.properties.get("text-align").getEnum(); | int align = this.properties.get("text-align").getEnum(); | ||||
int valign = this.properties.get("vertical-align").getEnum(); | int valign = this.properties.get("vertical-align").getEnum(); | ||||
if (numChildren > 1) { | if (numChildren > 1) { | ||||
throw new FOPException("Only one child element is allowed in an instream-foreign-object"); | throw new FOPException("Only one child element is allowed in an instream-foreign-object"); | ||||
} | } | ||||
/* layout foreign object */ | |||||
/* layout foreign object * | |||||
if (this.children.size() > 0) { | if (this.children.size() > 0) { | ||||
FONode fo = (FONode)children.get(0); | FONode fo = (FONode)children.get(0); | ||||
Status status; | Status status; | ||||
return status; | return status; | ||||
} | } | ||||
/* finish off the foreign object area */ | |||||
/* finish off the foreign object area * | |||||
this.areaCurrent.end(); | this.areaCurrent.end(); | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* endIndent = areaCurrent.getEffectiveWidth() - forcedWidth - | * endIndent = areaCurrent.getEffectiveWidth() - forcedWidth - | ||||
* forcedStartOffset; | * forcedStartOffset; | ||||
*/ | |||||
* | |||||
} | } | ||||
areaCurrent.setStartIndent(startIndent); | areaCurrent.setStartIndent(startIndent); | ||||
// areaCurrent.setEndIndent(endIndent); | // areaCurrent.setEndIndent(endIndent); | ||||
/* if there is a space-before */ | |||||
/* if there is a space-before * | |||||
if (spaceBefore != 0) { | if (spaceBefore != 0) { | ||||
/* add a display space */ | |||||
/* add a display space * | |||||
// area.addDisplaySpace(spaceBefore); | // area.addDisplaySpace(spaceBefore); | ||||
} | } | ||||
/* add the SVG area to the containing area */ | |||||
/* add the SVG area to the containing area * | |||||
// area.addChild(areaCurrent); | // area.addChild(areaCurrent); | ||||
areaCurrent.setPage(area.getPage()); | areaCurrent.setPage(area.getPage()); | ||||
/* increase the height of the containing area accordingly */ | |||||
/* increase the height of the containing area accordingly * | |||||
// area.increaseHeight(areaCurrent.getEffectiveHeight()); | // area.increaseHeight(areaCurrent.getEffectiveHeight()); | ||||
/* if there is a space-after */ | |||||
/* if there is a space-after * | |||||
if (spaceAfter != 0) { | if (spaceAfter != 0) { | ||||
/* add a display space */ | |||||
/* add a display space * | |||||
// area.addDisplaySpace(spaceAfter); | // area.addDisplaySpace(spaceAfter); | ||||
} | } | ||||
} | } | ||||
areaCurrent = null; | areaCurrent = null; | ||||
/* return status */ | |||||
/* return status * | |||||
return new Status(Status.OK); | return new Status(Status.OK); | ||||
} | } | ||||
*/ | |||||
} | } |
public ListItem(FONode parent) { | public ListItem(FONode parent) { | ||||
super(parent); | super(parent); | ||||
this.name = "fo:list-item"; | |||||
} | } | ||||
public Status layout(Area area) throws FOPException { | public Status layout(Area area) throws FOPException { |
public ListItemBody(FONode parent) { | public ListItemBody(FONode parent) { | ||||
super(parent); | super(parent); | ||||
this.name = "fo:list-item-body"; | |||||
} | } | ||||
public Status layout(Area area) throws FOPException { | public Status layout(Area area) throws FOPException { |
public ListItemLabel(FONode parent) { | public ListItemLabel(FONode parent) { | ||||
super(parent); | super(parent); | ||||
this.name = "fo:list-item-label"; | |||||
} | } | ||||
public Status layout(Area area) throws FOPException { | public Status layout(Area area) throws FOPException { |
public MultiProperties(FONode parent) { | public MultiProperties(FONode parent) { | ||||
super(parent); | super(parent); | ||||
this.name = "fo:multi-properties"; | |||||
} | } | ||||
public Status layout(Area area) throws FOPException { | public Status layout(Area area) throws FOPException { |
public MultiPropertySet(FONode parent) { | public MultiPropertySet(FONode parent) { | ||||
super(parent); | super(parent); | ||||
this.name = "fo:multi-property-set"; | |||||
} | } | ||||
public Status layout(Area area) throws FOPException { | public Status layout(Area area) throws FOPException { |
public MultiSwitch(FONode parent) { | public MultiSwitch(FONode parent) { | ||||
super(parent); | super(parent); | ||||
this.name = "fo:multi-switch"; | |||||
} | } | ||||
public Status layout(Area area) throws FOPException { | public Status layout(Area area) throws FOPException { |
public MultiToggle(FONode parent) { | public MultiToggle(FONode parent) { | ||||
super(parent); | super(parent); | ||||
this.name = "fo:multi-toggle"; | |||||
} | } | ||||
public Status layout(Area area) throws FOPException { | public Status layout(Area area) throws FOPException { |
public RetrieveMarker(FONode parent) { | public RetrieveMarker(FONode parent) { | ||||
super(parent); | super(parent); | ||||
this.name = "fo:retrieve-marker"; | |||||
} | } | ||||
public void handleAttrs(Attributes attlist) throws FOPException { | public void handleAttrs(Attributes attlist) throws FOPException { |
import org.apache.fop.layout.Area; | import org.apache.fop.layout.Area; | ||||
import org.apache.fop.apps.FOPException; | import org.apache.fop.apps.FOPException; | ||||
// Java | |||||
import java.util.Enumeration; | |||||
public class StaticContent extends Flow { | public class StaticContent extends Flow { | ||||
public StaticContent(FONode parent) { | public StaticContent(FONode parent) { | ||||
return new Status(Status.OK); | return new Status(Status.OK); | ||||
} | } | ||||
protected String getElementName() { | |||||
return "fo:static-content"; | |||||
} | |||||
// flowname checking is more stringient for static content currently | // flowname checking is more stringient for static content currently | ||||
protected void setFlowName(String name) throws FOPException { | protected void setFlowName(String name) throws FOPException { | ||||
if (name == null || name.equals("")) { | if (name == null || name.equals("")) { | ||||
throw new FOPException("A 'flow-name' is required for " | throw new FOPException("A 'flow-name' is required for " | ||||
+ getElementName() + "."); | |||||
+ getName() + "."); | |||||
} else { | } else { | ||||
super.setFlowName(name); | super.setFlowName(name); | ||||
} | } |
public Table(FONode parent) { | public Table(FONode parent) { | ||||
super(parent); | super(parent); | ||||
this.name = "fo:table"; | |||||
} | } | ||||
public Status layout(Area area) throws FOPException { | public Status layout(Area area) throws FOPException { |
public TableBody(FONode parent) { | public TableBody(FONode parent) { | ||||
super(parent); | super(parent); | ||||
this.name = "fo:table-body"; | |||||
} | } | ||||
public void setColumns(ArrayList columns) { | public void setColumns(ArrayList columns) { |
public TableCell(FONode parent) { | public TableCell(FONode parent) { | ||||
super(parent); | super(parent); | ||||
this.name = "fo:table-cell"; | |||||
} | } | ||||
public void handleAttrs(Attributes attlist) throws FOPException { | public void handleAttrs(Attributes attlist) throws FOPException { |
public TableColumn(FONode parent) { | public TableColumn(FONode parent) { | ||||
super(parent); | super(parent); | ||||
this.name = "fo:table-column"; | |||||
} | } | ||||
public Length getColumnWidthAsLength() { | public Length getColumnWidthAsLength() { |
public TableFooter(FONode parent) { | public TableFooter(FONode parent) { | ||||
super(parent); | super(parent); | ||||
this.name = "fo:table-footer"; | |||||
} | } | ||||
} | } |
public TableHeader(FONode parent) { | public TableHeader(FONode parent) { | ||||
super(parent); | super(parent); | ||||
this.name = "fo:table-header"; | |||||
} | } | ||||
} | } |
import java.util.Iterator; | import java.util.Iterator; | ||||
import java.util.HashMap; | import java.util.HashMap; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import org.apache.fop.messaging.MessageHandler; | |||||
/** | /** | ||||
* Reads a TrueType file and generates a subset | * Reads a TrueType file and generates a subset | ||||
if (newIdx == null) { | if (newIdx == null) { | ||||
// This errormessage would look much better | // This errormessage would look much better | ||||
// if the fontname was printed to | // if the fontname was printed to | ||||
MessageHandler.error("An embedded font " | |||||
+ "contains bad glyph data. " | |||||
+ "Characters might not display " | |||||
+ "correctly."); | |||||
//log.error("An embedded font " | |||||
// + "contains bad glyph data. " | |||||
// + "Characters might not display " | |||||
// + "correctly."); | |||||
moreComposites = false; | moreComposites = false; | ||||
continue; | continue; | ||||
} | } | ||||
createCvt(in); // copy the cvt table | createCvt(in); // copy the cvt table | ||||
} catch (IOException ex) { | } catch (IOException ex) { | ||||
// Cvt is optional (only required for OpenType (MS) fonts) | // Cvt is optional (only required for OpenType (MS) fonts) | ||||
MessageHandler.errorln("TrueType warning: " + ex.getMessage()); | |||||
//log.error("TrueType warning: " + ex.getMessage()); | |||||
} | } | ||||
try { | try { | ||||
createFpgm(in); // copy fpgm table | createFpgm(in); // copy fpgm table | ||||
} catch (IOException ex) { | } catch (IOException ex) { | ||||
// Fpgm is optional (only required for OpenType (MS) fonts) | // Fpgm is optional (only required for OpenType (MS) fonts) | ||||
MessageHandler.errorln("TrueType warning: " + ex.getMessage()); | |||||
//log.error("TrueType warning: " + ex.getMessage()); | |||||
} | } | ||||
try { | try { | ||||
createPrep(in); // copy prep table | createPrep(in); // copy prep table | ||||
} catch (IOException ex) { | } catch (IOException ex) { | ||||
// Prep is optional (only required for OpenType (MS) fonts) | // Prep is optional (only required for OpenType (MS) fonts) | ||||
MessageHandler.errorln("TrueType warning: " + ex.getMessage()); | |||||
//log.error("TrueType warning: " + ex.getMessage()); | |||||
} | } | ||||
try { | try { | ||||
createLoca(glyphs.size()); // create empty loca table | createLoca(glyphs.size()); // create empty loca table | ||||
} catch (IOException ex) { | } catch (IOException ex) { | ||||
// Loca is optional (only required for OpenType (MS) fonts) | // Loca is optional (only required for OpenType (MS) fonts) | ||||
MessageHandler.errorln("TrueType warning: " + ex.getMessage()); | |||||
//log.error("TrueType warning: " + ex.getMessage()); | |||||
} | } | ||||
try { | try { | ||||
createGlyf(in, glyphs); | createGlyf(in, glyphs); | ||||
} catch (IOException ex) { | } catch (IOException ex) { | ||||
// Glyf is optional (only required for OpenType (MS) fonts) | // Glyf is optional (only required for OpenType (MS) fonts) | ||||
MessageHandler.errorln("TrueType warning: " + ex.getMessage()); | |||||
//log.error("TrueType warning: " + ex.getMessage()); | |||||
} | } | ||||
pad4(); | pad4(); |
} | } | ||||
public byte[] getEPSImage() throws FopImageException { | public byte[] getEPSImage() throws FopImageException { | ||||
if (epsImage == null) | |||||
MessageHandler.errorln("ERROR LOADING EXTERNAL EPS"); | |||||
if (epsImage == null) { | |||||
//log.error("ERROR LOADING EXTERNAL EPS"); | |||||
} | |||||
return epsImage; | return epsImage; | ||||
} | } | ||||
// Java | // Java | ||||
import java.util.Hashtable; | import java.util.Hashtable; | ||||
import org.apache.fop.messaging.MessageHandler; | |||||
import java.awt.image.*; | import java.awt.image.*; | ||||
import java.awt.*; | import java.awt.*; | ||||
public void imageComplete(int status) { | public void imageComplete(int status) { | ||||
/* | /* | ||||
* MessageHandler.error("Status "); | |||||
* log.error("Status "); | |||||
* if (status == ImageConsumer.COMPLETESCANLINES) { | * if (status == ImageConsumer.COMPLETESCANLINES) { | ||||
* MessageHandler.errorln("CompleteScanLines"); | |||||
* log.error("CompleteScanLines"); | |||||
* } else if (status == ImageConsumer.IMAGEABORTED) { | * } else if (status == ImageConsumer.IMAGEABORTED) { | ||||
* MessageHandler.errorln("ImageAborted"); | |||||
* log.error("ImageAborted"); | |||||
* } else if (status == ImageConsumer.IMAGEERROR) { | * } else if (status == ImageConsumer.IMAGEERROR) { | ||||
* MessageHandler.errorln("ImageError"); | |||||
* log.error("ImageError"); | |||||
* } else if (status == ImageConsumer.RANDOMPIXELORDER) { | * } else if (status == ImageConsumer.RANDOMPIXELORDER) { | ||||
* MessageHandler.errorln("RandomPixelOrder"); | |||||
* log.error("RandomPixelOrder"); | |||||
* } else if (status == ImageConsumer.SINGLEFRAME) { | * } else if (status == ImageConsumer.SINGLEFRAME) { | ||||
* MessageHandler.errorln("SingleFrame"); | |||||
* log.error("SingleFrame"); | |||||
* } else if (status == ImageConsumer.SINGLEFRAMEDONE) { | * } else if (status == ImageConsumer.SINGLEFRAMEDONE) { | ||||
* MessageHandler.errorln("SingleFrameDone"); | |||||
* log.error("SingleFrameDone"); | |||||
* } else if (status == ImageConsumer.SINGLEPASS) { | * } else if (status == ImageConsumer.SINGLEPASS) { | ||||
* MessageHandler.errorln("SinglePass"); | |||||
* log.error("SinglePass"); | |||||
* } else if (status == ImageConsumer.STATICIMAGEDONE) { | * } else if (status == ImageConsumer.STATICIMAGEDONE) { | ||||
* MessageHandler.errorln("StaticImageDone"); | |||||
* log.error("StaticImageDone"); | |||||
* } else if (status == ImageConsumer.TOPDOWNLEFTRIGHT) { | * } else if (status == ImageConsumer.TOPDOWNLEFTRIGHT) { | ||||
* MessageHandler.errorln("TopDownLeftRight"); | |||||
* log.error("TopDownLeftRight"); | |||||
* } | * } | ||||
*/ | */ | ||||
synchronized (this.imageStatus) { | synchronized (this.imageStatus) { | ||||
} | } | ||||
public void setColorModel(ColorModel model) { | public void setColorModel(ColorModel model) { | ||||
// MessageHandler.errorln("setColorModel: " + model); | |||||
// log.error("setColorModel: " + model); | |||||
this.cm = model; | this.cm = model; | ||||
} | } | ||||
public void setDimensions(int width, int height) { | public void setDimensions(int width, int height) { | ||||
// MessageHandler.errorln("setDimension: w=" + width + " h=" + height); | |||||
// log.error("setDimension: w=" + width + " h=" + height); | |||||
this.width = width; | this.width = width; | ||||
this.height = height; | this.height = height; | ||||
} | } | ||||
public void setHints(int hintflags) { | public void setHints(int hintflags) { | ||||
// MessageHandler.errorln("setHints: " + hintflags); | |||||
// log.error("setHints: " + hintflags); | |||||
this.hints = hintflags; | this.hints = hintflags; | ||||
} | } | ||||
public void setProperties(Hashtable props) { | public void setProperties(Hashtable props) { | ||||
// MessageHandler.errorln("setProperties: " + props); | |||||
// log.error("setProperties: " + props); | |||||
this.properties = props; | this.properties = props; | ||||
} | } | ||||
// FOP | // FOP | ||||
import org.apache.fop.apps.Driver; | import org.apache.fop.apps.Driver; | ||||
import org.apache.fop.messaging.*; | |||||
import org.apache.fop.datatypes.ColorSpace; | import org.apache.fop.datatypes.ColorSpace; | ||||
import org.apache.fop.pdf.PDFColor; | import org.apache.fop.pdf.PDFColor; | ||||
import org.apache.fop.image.analyser.ImageReader; | import org.apache.fop.image.analyser.ImageReader; | ||||
new SAXSVGDocumentFactory(SVGImage.getParserName()); | new SAXSVGDocumentFactory(SVGImage.getParserName()); | ||||
doc = factory.createDocument(this.m_href.toExternalForm()); | doc = factory.createDocument(this.m_href.toExternalForm()); | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
MessageHandler.errorln("Could not load external SVG: " | |||||
+ e.getMessage()); | |||||
//log.error("Could not load external SVG: " | |||||
// + e.getMessage()); | |||||
} | } | ||||
} | } | ||||
return true; | return true; | ||||
} catch (NoClassDefFoundError ncdfe) { | } catch (NoClassDefFoundError ncdfe) { | ||||
MessageHandler.errorln("Batik not in class path"); | |||||
//log.error("Batik not in class path"); | |||||
return false; | return false; | ||||
} | } | ||||
catch (Exception e) { | catch (Exception e) { | ||||
MessageHandler.errorln("Could not load external SVG: " + | |||||
e.getMessage()); | |||||
//log.error("Could not load external SVG: " + | |||||
// e.getMessage()); | |||||
// assuming any exception means this document is not svg | // assuming any exception means this document is not svg | ||||
// or could not be loaded for some reason | // or could not be loaded for some reason | ||||
return false; | return false; |
// Java | // Java | ||||
import java.util.Vector; | import java.util.Vector; | ||||
import java.util.Enumeration; | import java.util.Enumeration; | ||||
import org.apache.fop.messaging.MessageHandler; | |||||
/** | /** | ||||
* This class represents a Block Area. | * This class represents a Block Area. |
if (f == null) { | if (f == null) { | ||||
throw new FOPException("no default font defined by OutputConverter"); | throw new FOPException("no default font defined by OutputConverter"); | ||||
} | } | ||||
//MessageHandler.errorln("defaulted font to any,normal,normal"); | |||||
//log.error("defaulted font to any,normal,normal"); | |||||
} | } | ||||
//MessageHandler.errorln("unknown font " + key | |||||
//log.error("unknown font " + key | |||||
// + " so defaulted font to any"); | // + " so defaulted font to any"); | ||||
} | } | ||||
// fop | // fop | ||||
import org.apache.fop.render.Renderer; | import org.apache.fop.render.Renderer; | ||||
import org.apache.fop.messaging.MessageHandler; | |||||
import org.apache.fop.layout.inline.*; | import org.apache.fop.layout.inline.*; | ||||
import org.apache.fop.datatypes.IDNode; | import org.apache.fop.datatypes.IDNode; | ||||
import org.apache.fop.fo.properties.WrapOption; | import org.apache.fop.fo.properties.WrapOption; | ||||
wordWidth = charWidth; | wordWidth = charWidth; | ||||
if ((finalWidth + spaceWidth + wordWidth) | if ((finalWidth + spaceWidth + wordWidth) | ||||
> this.getContentWidth()) { | > this.getContentWidth()) { | ||||
if (overrun) | |||||
MessageHandler.log("area contents overflows area"); | |||||
if (overrun) { | |||||
//log.debug("area contents overflows area"); | |||||
} | |||||
if (this.wrapOption == WrapOption.WRAP) { | if (this.wrapOption == WrapOption.WRAP) { | ||||
return i; | return i; | ||||
} | } | ||||
(wordStart == start) && | (wordStart == start) && | ||||
(finalWidth == 0)) { | (finalWidth == 0)) { | ||||
MessageHandler.log("area contents overflows area"); | |||||
//log.debug("area contents overflows area"); | |||||
addSpacedWord(new String(data, wordStart, wordLength - 1), | addSpacedWord(new String(data, wordStart, wordLength - 1), | ||||
ls, | ls, | ||||
finalWidth + spaceWidth | finalWidth + spaceWidth | ||||
wordWidth = 0; | wordWidth = 0; | ||||
} | } | ||||
if (overrun) | |||||
MessageHandler.log("area contents overflows area"); | |||||
if (overrun) { | |||||
//log.debug("area contents overflows area"); | |||||
} | |||||
return -1; | return -1; | ||||
} | } | ||||
break; | break; | ||||
// leader pattern use-content not implemented. | // leader pattern use-content not implemented. | ||||
case LeaderPattern.USECONTENT: | case LeaderPattern.USECONTENT: | ||||
MessageHandler.errorln("leader-pattern=\"use-content\" not " | |||||
+ "supported by this version of Fop"); | |||||
//log.error("leader-pattern=\"use-content\" not " | |||||
// + "supported by this version of Fop"); | |||||
return; | return; | ||||
} | } | ||||
// adds leader length to length of pending inline areas | // adds leader length to length of pending inline areas | ||||
private InlineArea buildSimpleLeader(char c, int leaderLength) { | private InlineArea buildSimpleLeader(char c, int leaderLength) { | ||||
int width = this.currentFontState.width(currentFontState.mapChar(c)); | int width = this.currentFontState.width(currentFontState.mapChar(c)); | ||||
if (width == 0) { | if (width == 0) { | ||||
MessageHandler.errorln("char " + c | |||||
+ " has width 0. Using width 100 instead."); | |||||
//log.error("char " + c | |||||
// + " has width 0. Using width 100 instead."); | |||||
width = 100; | width = 100; | ||||
} | } | ||||
int factor = (int)Math.floor(leaderLength / width); | int factor = (int)Math.floor(leaderLength / width); | ||||
int remainingWidth) { | int remainingWidth) { | ||||
// check whether the language property has been set | // check whether the language property has been set | ||||
if (this.hyphProps.language.equalsIgnoreCase("none")) { | if (this.hyphProps.language.equalsIgnoreCase("none")) { | ||||
MessageHandler.errorln("if property 'hyphenate' is used, a language must be specified"); | |||||
//log.error("if property 'hyphenate' is used, a language must be specified"); | |||||
return wordStart; | return wordStart; | ||||
} | } | ||||
import java.io.*; | import java.io.*; | ||||
import java.util.Hashtable; | import java.util.Hashtable; | ||||
import org.apache.fop.configuration.*; | import org.apache.fop.configuration.*; | ||||
import org.apache.fop.messaging.MessageHandler; | |||||
/** | /** | ||||
* This class is the main entry point to the hyphenation package. | * This class is the main entry point to the hyphenation package. | ||||
if (hTree != null) { | if (hTree != null) { | ||||
hyphenTrees.put(key, hTree); | hyphenTrees.put(key, hTree); | ||||
} else { | } else { | ||||
MessageHandler.errorln("Couldn't find hyphenation pattern " | |||||
+ key); | |||||
//log.error("Couldn't find hyphenation pattern " | |||||
// + key); | |||||
} | } | ||||
return hTree; | return hTree; | ||||
} | } | ||||
if (key.length() == 5) { | if (key.length() == 5) { | ||||
is = getResourceStream(key.substring(0, 2)); | is = getResourceStream(key.substring(0, 2)); | ||||
if (is != null) { | if (is != null) { | ||||
MessageHandler.errorln("Couldn't find hyphenation pattern " | |||||
+ key | |||||
+ "\nusing general language pattern " | |||||
+ key.substring(0, 2) | |||||
+ " instead."); | |||||
//log.error("Couldn't find hyphenation pattern " | |||||
// + key | |||||
// + "\nusing general language pattern " | |||||
// + key.substring(0, 2) | |||||
// + " instead."); | |||||
} else { | } else { | ||||
if (errorDump) { | if (errorDump) { | ||||
MessageHandler.errorln("Couldn't find precompiled " | |||||
+ "fop hyphenation pattern " | |||||
+ key + ".hyp"); | |||||
//log.error("Couldn't find precompiled " | |||||
// + "fop hyphenation pattern " | |||||
// + key + ".hyp"); | |||||
} | } | ||||
return null; | return null; | ||||
} | } | ||||
} else { | } else { | ||||
if (errorDump) { | if (errorDump) { | ||||
MessageHandler.errorln("Couldn't find precompiled " | |||||
+ "fop hyphenation pattern " | |||||
+ key + ".hyp"); | |||||
//log.error("Couldn't find precompiled " | |||||
// + "fop hyphenation pattern " | |||||
// + key + ".hyp"); | |||||
} | } | ||||
return null; | return null; | ||||
} | } | ||||
try { | try { | ||||
ois.close(); | ois.close(); | ||||
} catch (IOException e) { | } catch (IOException e) { | ||||
MessageHandler.errorln("can't close hyphenation object stream"); | |||||
//log.error("can't close hyphenation object stream"); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
if (hyphenFile.exists()) { | if (hyphenFile.exists()) { | ||||
hTree = new HyphenationTree(); | hTree = new HyphenationTree(); | ||||
if (errorDump) { | if (errorDump) { | ||||
MessageHandler.errorln("reading " + hyphenDir + key | |||||
+ ".xml"); | |||||
//log.error("reading " + hyphenDir + key | |||||
// + ".xml"); | |||||
} | } | ||||
try { | try { | ||||
hTree.loadPatterns(hyphenFile.getPath()); | hTree.loadPatterns(hyphenFile.getPath()); | ||||
return hTree; | return hTree; | ||||
} catch (HyphenationException ex) { | } catch (HyphenationException ex) { | ||||
if (errorDump) { | if (errorDump) { | ||||
MessageHandler.errorln("Can't load user patterns " | |||||
+ "from xml file " + hyphenDir | |||||
+ key + ".xml"); | |||||
//log.error("Can't load user patterns " | |||||
// + "from xml file " + hyphenDir | |||||
// + key + ".xml"); | |||||
} | } | ||||
return null; | return null; | ||||
} | } | ||||
} else { | } else { | ||||
if (errorDump) { | if (errorDump) { | ||||
MessageHandler.errorln("Tried to load " | |||||
+ hyphenFile.toString() | |||||
+ "\nCannot find compiled nor xml file for " | |||||
+ "hyphenation pattern" + key); | |||||
//log.error("Tried to load " | |||||
// + hyphenFile.toString() | |||||
// + "\nCannot find compiled nor xml file for " | |||||
// + "hyphenation pattern" + key); | |||||
} | } | ||||
return null; | return null; | ||||
} | } | ||||
int rightMin) { | int rightMin) { | ||||
HyphenationTree hTree = getHyphenationTree(lang, country); | HyphenationTree hTree = getHyphenationTree(lang, country); | ||||
if (hTree == null) { | if (hTree == null) { | ||||
MessageHandler.errorln("Error building hyphenation tree for language " | |||||
+ lang); | |||||
//log.error("Error building hyphenation tree for language " | |||||
// + lang); | |||||
return null; | return null; | ||||
} | } | ||||
return hTree.hyphenate(word, leftMin, rightMin); | return hTree.hyphenate(word, leftMin, rightMin); | ||||
int leftMin, int rightMin) { | int leftMin, int rightMin) { | ||||
HyphenationTree hTree = getHyphenationTree(lang, country); | HyphenationTree hTree = getHyphenationTree(lang, country); | ||||
if (hTree == null) { | if (hTree == null) { | ||||
MessageHandler.errorln("Error building hyphenation tree for language " | |||||
+ lang); | |||||
//log.error("Error building hyphenation tree for language " | |||||
// + lang); | |||||
return null; | return null; | ||||
} | } | ||||
return hTree.hyphenate(word, offset, len, leftMin, rightMin); | return hTree.hyphenate(word, offset, len, leftMin, rightMin); |
/* | |||||
* $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.messaging; | |||||
/** | |||||
* A trivial implementation of a MessageListener | |||||
* For further explanation | |||||
*/ | |||||
public class DefaultMessageListener implements MessageListener { | |||||
/** | |||||
* The method processMessage has to be overwritten to handle the MessageEvents. | |||||
* The message type (information or error) is accessible via event.getMessageType(). | |||||
*/ | |||||
public void processMessage(MessageEvent event) { | |||||
switch (event.getMessageType()) { | |||||
case MessageEvent.ERROR: | |||||
System.err.print("ERROR: " + event.getMessage()); | |||||
break; | |||||
case MessageEvent.LOG: | |||||
System.out.print("LOG: " + event.getMessage()); | |||||
break; | |||||
default: | |||||
System.out.print("Unknown message type: " + event.getMessage()); | |||||
} | |||||
} | |||||
} |
/* | |||||
* $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.messaging; | |||||
import java.util.EventObject; | |||||
/** | |||||
* a container for the text and the type of a message | |||||
* MessageEvents are created by MessageHandler and can be received by any | |||||
* MessageListener, which is added to MessageHandler; | |||||
*/ | |||||
public class MessageEvent extends EventObject { | |||||
public static final int LOG = 0; | |||||
public static final int ERROR = 1; | |||||
String message; | |||||
int messageType = MessageEvent.LOG; | |||||
public MessageEvent(Object source) { | |||||
super(source); | |||||
message = (String)source; // MessageHandler.getMessage() | |||||
} | |||||
/** | |||||
* retrieves the message | |||||
* @return String containing the message | |||||
* | |||||
*/ | |||||
public String getMessage() { | |||||
return message; | |||||
} | |||||
/** | |||||
* sets the message type | |||||
* @param messageType the type of the message as int in the form of MessageEvent.LOG or MessageEvent.ERROR | |||||
* | |||||
*/ | |||||
void setMessageType(int messageType) { | |||||
this.messageType = messageType; | |||||
} | |||||
/** | |||||
* returns the type of message as int | |||||
* | |||||
* @return messageType the type of the message as int in the form of MessageEvent.LOG or MessageEvent.ERROR | |||||
*/ | |||||
public int getMessageType() { | |||||
return messageType; | |||||
} | |||||
} | |||||
/* | |||||
* 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.messaging; | |||||
import java.io.*; | |||||
import java.util.*; | |||||
import org.apache.log.*; | |||||
/** | |||||
* The class MessageHandler contains the static methods log and error which | |||||
* should be used for any end user information instead of System.out.print() or | |||||
* System.err.print(). The class defines several output methods: | |||||
* writing to the screen (default), logging to a file, creating message events and repressing all | |||||
* output. If you don't want to change the default behaviour, you should be | |||||
* happy with MessageHandler.log(message) and MessageHandler.error(message)<br> | |||||
* The class MessageHandler also supports the setting of an id. If set every message | |||||
* has as a prefix an identifying string. That way Fop probably can also be used in | |||||
* environments, where more than one Fop instance are running in same JVM.<br> | |||||
* If Fop is embedded in a gui application or for any reasons the existing | |||||
* messaging system doesn't meet the programmer's requirements, one can add | |||||
* a MessageEvent listener to MessageHandler and handle the incoming messages | |||||
* in an appropriate way. See the class DefaultMessageListener, which is a trivial | |||||
* implementation of the MessageListener. | |||||
* Here is an example how to configure MessageHandler for the DefaultMessageListener (anybody | |||||
* can provide his own listener by extending MessageListener<br> | |||||
* <code> | |||||
* MessageHandler.setOutputMethod(MessageHandler.EVENT); | |||||
* MessageHandler.addListener(new DefaultMessageListener()); | |||||
* </code><br> | |||||
* This examples shows, how to redirect the messages to a log file called fop.log. | |||||
* All messages are appended to this file. | |||||
* <code> | |||||
* MessageHandler.setOutputMethod(MessageHandler.FILE); | |||||
* MessageHandler.setLogfileName("\\fop.log",true); | |||||
* </code> | |||||
*/ | |||||
public class MessageHandler { | |||||
public static final int SCREEN = 0; | |||||
public static final int FILE = 1; | |||||
public static final int EVENT = 2; | |||||
public static final int NONE = 3; // this should always be the last method | |||||
private static String logfileName = "fop.log"; | |||||
private static PrintWriter writer; | |||||
private static int outputMethod = SCREEN; | |||||
private static boolean fileOpened = false; | |||||
private static boolean appendToFile = true; | |||||
private static String message = ""; | |||||
private static String prefix = ""; | |||||
private static Vector listeners = new Vector(); | |||||
private static boolean IDisSet = false; | |||||
private static boolean quiet = false; | |||||
/** | |||||
* helper class to access the message | |||||
* @return a string containing the message | |||||
*/ | |||||
private static String getMessage() { | |||||
return message; | |||||
} | |||||
/** | |||||
* helper class which sets the message | |||||
* and adds a prefix which can contain | |||||
* the id of the thread which uses this messagehandler | |||||
*/ | |||||
private static void setMessage(String m) { | |||||
if (IDisSet) { | |||||
message = getID() + ":" + m; | |||||
} else { | |||||
message = m; | |||||
} | |||||
} | |||||
// temp workaround | |||||
private static Logger logger = null; | |||||
/** | |||||
* informs the user of the message | |||||
* @param message the message for the user | |||||
*/ | |||||
public static void log(String message) { | |||||
if (!quiet) { | |||||
if(logger == null) { | |||||
logger = Hierarchy.getDefaultHierarchy().getLoggerFor("fop"); | |||||
} | |||||
setMessage(message); | |||||
switch (outputMethod) { | |||||
case SCREEN: | |||||
logger.debug(getMessage()); | |||||
break; | |||||
case FILE: | |||||
if (fileOpened) { | |||||
writer.print(getMessage()); | |||||
writer.flush(); | |||||
} else { | |||||
openFile(); | |||||
writer.print(getMessage()); | |||||
writer.flush(); | |||||
} | |||||
break; | |||||
case EVENT: | |||||
setMessage(message); | |||||
Enumeration enum = listeners.elements(); | |||||
while (enum.hasMoreElements()) { | |||||
((MessageListener)enum.nextElement()).processMessage(new MessageEvent(getMessage())); | |||||
} | |||||
break; | |||||
case NONE: | |||||
// do nothing | |||||
break; | |||||
default: | |||||
logger.debug(message); | |||||
} | |||||
} | |||||
} | |||||
/** | |||||
* convenience method which adds a return to the message | |||||
* @param message the message for the user | |||||
*/ | |||||
public static void logln(String message) { | |||||
log(message); | |||||
} | |||||
/** | |||||
* error warning for the user | |||||
* @param errorMessage contains the warning string | |||||
*/ | |||||
public static void error(String errorMessage) { | |||||
if(logger == null) { | |||||
logger = Hierarchy.getDefaultHierarchy().getLoggerFor("fop"); | |||||
} | |||||
setMessage(errorMessage); | |||||
switch (outputMethod) { | |||||
case SCREEN: | |||||
logger.error(getMessage()); | |||||
break; | |||||
case FILE: | |||||
if (fileOpened) { | |||||
writer.print(getMessage()); | |||||
writer.flush(); | |||||
} else { | |||||
openFile(); | |||||
writer.print(getMessage()); | |||||
writer.flush(); | |||||
} | |||||
break; | |||||
case EVENT: | |||||
setMessage(message); | |||||
Enumeration enum = listeners.elements(); | |||||
while (enum.hasMoreElements()) { | |||||
MessageEvent messEv = new MessageEvent(getMessage()); | |||||
messEv.setMessageType(MessageEvent.ERROR); | |||||
((MessageListener)enum.nextElement()).processMessage(messEv); | |||||
} | |||||
break; | |||||
case NONE: | |||||
// do nothing | |||||
break; | |||||
default: | |||||
logger.error(errorMessage); | |||||
} | |||||
} | |||||
/** | |||||
* convenience method which adds a return to the error message | |||||
* @param errorMessage the message for the user | |||||
*/ | |||||
public static void errorln(String errorMessage) { | |||||
error(errorMessage); | |||||
} | |||||
/** | |||||
* adds a MessageListener which listens for MessageEvents | |||||
* @param MessageListener the listener to add | |||||
*/ | |||||
public static void addListener(MessageListener listener) { | |||||
listeners.addElement(listener); | |||||
} | |||||
/** | |||||
* removes a MessageListener | |||||
* @param MessageListener the listener to remove | |||||
*/ | |||||
public static void removeListener(MessageListener listener) { | |||||
listeners.removeElement(listener); | |||||
} | |||||
/** | |||||
* sets the output method | |||||
* @param method the output method to use, allowed values are<br> | |||||
* MessageHandler.SCREEN, MessageHandler.FILE, MessageHandler.EVENT | |||||
* MessageHandler.NONE | |||||
*/ | |||||
public static void setOutputMethod(int method) { | |||||
if (method > NONE) { | |||||
MessageHandler.error("Error: Unknown output method"); | |||||
} else { | |||||
outputMethod = method; | |||||
} | |||||
} | |||||
/** | |||||
* informs what output method is set | |||||
* @return the output method | |||||
*/ | |||||
public static int getOutputMethod() { | |||||
return outputMethod; | |||||
} | |||||
/** | |||||
* sets the logfile name | |||||
* @param filename name of the logfile | |||||
* @param append if true, the logfile is appended | |||||
*/ | |||||
public static void setLogfileName(String filename, boolean append) { | |||||
logfileName = filename; | |||||
appendToFile = append; | |||||
} | |||||
/** | |||||
* returns the logfile name | |||||
* @return String containing the logfile name | |||||
*/ | |||||
public static String getLogfileName() { | |||||
return logfileName; | |||||
} | |||||
/** | |||||
* helper file which opens the file for output method FILE | |||||
*/ | |||||
private static void openFile() { | |||||
try { | |||||
writer = | |||||
new PrintWriter(new FileWriter(logfileName, appendToFile), | |||||
true); | |||||
writer.println("\n=============================================="); | |||||
fileOpened = true; | |||||
} catch (IOException ioe) { | |||||
System.err.println("Error: " + ioe); | |||||
} | |||||
} | |||||
/** | |||||
* if set to true an id string is prefixed to every message | |||||
* uses the thread info as an id for the message producer. Should be used if | |||||
* more than one instance of Fop is running in the same JVM | |||||
* this id becomes a prefix to every message | |||||
*/ | |||||
private static String getID() { | |||||
return Thread.currentThread().toString(); | |||||
} | |||||
/** | |||||
* if set to true an id string is prefixed to every message | |||||
* uses the thread info as an id for the message producer. Should be used if | |||||
* more than one instance of Fop is running in the same JVM | |||||
* this id becomes a prefix to every message | |||||
* | |||||
* @param id boolean (default is false) | |||||
*/ | |||||
public static void setID(boolean id) { | |||||
IDisSet = id; | |||||
} | |||||
/** | |||||
* if set to true all normal messages are suppressed. | |||||
* error messages are displayed allthesame | |||||
* | |||||
* @param quietMode boolean (default is false) | |||||
*/ | |||||
public static void setQuiet(boolean quietMode) { | |||||
quiet = quietMode; | |||||
} | |||||
} |
/* | |||||
* $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.messaging; | |||||
/** | |||||
* For situations, where the messages Fop directs to the user have to be handled in some | |||||
* special way, the interface MessageListener and the class MessageEvent are provided. | |||||
* Embedding Fop into a graphical user interface could be such a scenario.<br> | |||||
* Any MessageListener listens for MessageEvents, which contain the user message and | |||||
* also the message type information (progress information or error warning). | |||||
* The class DefaultMessageListener shows an trivial implementation of MessageListener. | |||||
*/ | |||||
public interface MessageListener { | |||||
void processMessage(MessageEvent event); | |||||
} | |||||
// referenced and I'd rather not do it | // referenced and I'd rather not do it | ||||
import org.apache.fop.image.FopImage; | import org.apache.fop.image.FopImage; | ||||
import org.apache.fop.messaging.MessageHandler; | |||||
import org.apache.fop.layout.LinkSet; | import org.apache.fop.layout.LinkSet; | ||||
import org.apache.fop.datatypes.ColorSpace; | import org.apache.fop.datatypes.ColorSpace; | ||||
} else if (bookComponent.document.height != height | } else if (bookComponent.document.height != height | ||||
|| bookComponent.document.width != width) { | || bookComponent.document.width != width) { | ||||
MessageHandler.logln("Warning : FrameMaker doesnt support different page-sizes in a document"); | |||||
//log.warn("FrameMaker doesnt support different page-sizes in a document"); | |||||
} | } | ||||
} | } |
compressedStream.flush(); | compressedStream.flush(); | ||||
compressedStream.close(); | compressedStream.close(); | ||||
} catch (IOException e) { | } catch (IOException e) { | ||||
org.apache.fop.messaging.MessageHandler.error("Fatal error: " | |||||
+ e.getMessage()); | |||||
e.printStackTrace(); | |||||
//log.error("Fatal error: " | |||||
// + e.getMessage(), e); | |||||
} | } | ||||
return outArrayStream.toByteArray(); | return outArrayStream.toByteArray(); |
// Java | // Java | ||||
import java.io.PrintWriter; | import java.io.PrintWriter; | ||||
import org.apache.fop.messaging.MessageHandler; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
/** | /** | ||||
*/ | */ | ||||
public void incrementCount() { | public void incrementCount() { | ||||
this.count++; | this.count++; | ||||
// MessageHandler.logln("Incrementing count to " + this.getCount()); | |||||
// log.debug("Incrementing count to " + this.getCount()); | |||||
} | } | ||||
/** | /** |
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Enumeration; | import java.util.Enumeration; | ||||
import org.apache.fop.configuration.Configuration; | import org.apache.fop.configuration.Configuration; | ||||
import org.apache.fop.messaging.MessageHandler; | |||||
/** | /** | ||||
* class representing a PDF stream. | * class representing a PDF stream. | ||||
} else if (filterType.equals("")) { | } else if (filterType.equals("")) { | ||||
return; | return; | ||||
} else { | } else { | ||||
MessageHandler.errorln("Unsupported filter type in stream-filter-list: " | |||||
+ filterType); | |||||
//log.error("Unsupported filter type in stream-filter-list: " | |||||
// + filterType); | |||||
} | } | ||||
} | } | ||||
// Java | // Java | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import org.apache.fop.messaging.MessageHandler; | |||||
import java.io.OutputStream; | import java.io.OutputStream; | ||||
// FOP | // FOP | ||||
isPS = false; | isPS = false; | ||||
this.Xnum = Xnumber; | this.Xnum = Xnumber; | ||||
if (img == null) | if (img == null) | ||||
MessageHandler.errorln("FISH"); | |||||
//log.error("FISH"); | |||||
fopimage = img; | fopimage = img; | ||||
this.pdfDoc = pdfdoc; | this.pdfDoc = pdfdoc; | ||||
pdfICCStream = null; | pdfICCStream = null; | ||||
} | } | ||||
} | } | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
MessageHandler.errorln("Error while reading image " + | |||||
fopimage.getURL() + | |||||
": " + e.getMessage()); | |||||
//log.error("Error while reading image " + | |||||
// fopimage.getURL() + | |||||
// ": " + e.getMessage()); | |||||
} | } | ||||
} | } | ||||
length += pdfBytes.length; | length += pdfBytes.length; | ||||
} | } | ||||
} catch (FopImageException imgex) { | } catch (FopImageException imgex) { | ||||
MessageHandler.errorln("Error in XObject : " | |||||
+ imgex.getMessage()); | |||||
//log.error("Error in XObject : " | |||||
// + imgex.getMessage()); | |||||
} | } | ||||
return length; | return length; |
package org.apache.fop.render.awt; | package org.apache.fop.render.awt; | ||||
// FOP | // FOP | ||||
import org.apache.fop.messaging.MessageHandler; | |||||
import org.apache.fop.layout.FontInfo; | import org.apache.fop.layout.FontInfo; | ||||
import org.apache.fop.layout.FontDescriptor; | import org.apache.fop.layout.FontDescriptor; | ||||
import org.apache.fop.layout.FontState; | import org.apache.fop.layout.FontState; |
package org.apache.fop.render.awt; | package org.apache.fop.render.awt; | ||||
// FOP | // FOP | ||||
import org.apache.fop.messaging.MessageHandler; | |||||
import org.apache.fop.layout.FontInfo; | import org.apache.fop.layout.FontInfo; | ||||
import org.apache.fop.layout.FontDescriptor; | import org.apache.fop.layout.FontDescriptor; | ||||
FontMetricsMapper metric; | FontMetricsMapper metric; | ||||
int normal, bold, bolditalic, italic; | int normal, bold, bolditalic, italic; | ||||
MessageHandler.logln("setting up fonts"); | |||||
/* | /* | ||||
* available java fonts are: | * available java fonts are: | ||||
* Serif - bold, normal, italic, bold-italic | * Serif - bold, normal, italic, bold-italic |
// FOP | // FOP | ||||
import org.apache.fop.render.mif.fonts.*; | import org.apache.fop.render.mif.fonts.*; | ||||
import org.apache.fop.messaging.MessageHandler; | |||||
import org.apache.fop.layout.FontInfo; | import org.apache.fop.layout.FontInfo; | ||||
import org.apache.fop.layout.FontDescriptor; | import org.apache.fop.layout.FontDescriptor; | ||||
import org.apache.fop.mif.MIFDocument; | import org.apache.fop.mif.MIFDocument; | ||||
* @param fontInfo the font info object to set up | * @param fontInfo the font info object to set up | ||||
*/ | */ | ||||
public static void setup(FontInfo fontInfo) { | public static void setup(FontInfo fontInfo) { | ||||
MessageHandler.logln("setting up fonts"); | |||||
fontInfo.addMetrics("F1", new Helvetica()); | fontInfo.addMetrics("F1", new Helvetica()); | ||||
fontInfo.addMetrics("F2", new HelveticaOblique()); | fontInfo.addMetrics("F2", new HelveticaOblique()); |
} | } | ||||
} | } | ||||
} catch (Exception ex) { | } catch (Exception ex) { | ||||
//MessageHandler.error("Failed to read font metrics file " | |||||
//log.error("Failed to read font metrics file " | |||||
// + configFontInfo.getMetricsFile() | // + configFontInfo.getMetricsFile() | ||||
// + " : " + ex.getMessage()); | // + " : " + ex.getMessage()); | ||||
} | } |
import org.apache.fop.render.pdf.Font; | import org.apache.fop.render.pdf.Font; | ||||
import org.apache.fop.layout.FontDescriptor; | import org.apache.fop.layout.FontDescriptor; | ||||
import org.apache.fop.pdf.PDFStream; | import org.apache.fop.pdf.PDFStream; | ||||
import org.apache.fop.messaging.MessageHandler; | |||||
import java.util.HashMap; | import java.util.HashMap; | ||||
import org.apache.fop.render.pdf.FontReader; | import org.apache.fop.render.pdf.FontReader; | ||||
} | } | ||||
// System.out.println("Metrics " + metricsFileName + " loaded."); | // System.out.println("Metrics " + metricsFileName + " loaded."); | ||||
} catch (Exception ex) { | } catch (Exception ex) { | ||||
MessageHandler.error("Failed to read font metrics file " | |||||
+ metricsFileName | |||||
+ " : " + ex.getMessage()); | |||||
//log.error("Failed to read font metrics file " | |||||
// + metricsFileName | |||||
// + " : " + ex.getMessage()); | |||||
} | } | ||||
} | } | ||||
} | } |
import org.apache.fop.render.pdf.CIDFont; | import org.apache.fop.render.pdf.CIDFont; | ||||
import org.apache.fop.render.pdf.CMap; | import org.apache.fop.render.pdf.CMap; | ||||
import org.apache.fop.pdf.PDFTTFStream; | import org.apache.fop.pdf.PDFTTFStream; | ||||
import org.apache.fop.messaging.MessageHandler; | |||||
import java.io.InputStream; | import java.io.InputStream; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.io.FileInputStream; | import java.io.FileInputStream; | ||||
embeddedFont.addFilter("ascii-85"); | embeddedFont.addFilter("ascii-85"); | ||||
embeddedFont.setData(subsetFont, subsetFont.length); | embeddedFont.setData(subsetFont, subsetFont.length); | ||||
} catch (IOException ioe) { | } catch (IOException ioe) { | ||||
MessageHandler.errorln("Failed to embed font [" + i + "] " | |||||
+ fontName + ": " + ioe.getMessage()); | |||||
//log.error("Failed to embed font [" + i + "] " | |||||
// + fontName + ": " + ioe.getMessage()); | |||||
return (PDFStream)null; | return (PDFStream)null; | ||||
} | } | ||||
*/ | */ | ||||
import java.awt.event.ActionEvent; | import java.awt.event.ActionEvent; | ||||
import org.apache.fop.messaging.MessageHandler; | |||||
import javax.swing.AbstractAction; | import javax.swing.AbstractAction; | ||||
import javax.swing.ImageIcon; | import javax.swing.ImageIcon; | ||||
import java.net.*; | import java.net.*; | ||||
String path = IMAGE_DIR + iconName + ".gif"; | String path = IMAGE_DIR + iconName + ".gif"; | ||||
URL url = getClass().getResource(path); | URL url = getClass().getResource(path); | ||||
if (url == null) { | if (url == null) { | ||||
MessageHandler.errorln("Icon not found: " + path); | |||||
//log.error("Icon not found: " + path); | |||||
} else | } else | ||||
putValue(SMALL_ICON, new ImageIcon(url)); | putValue(SMALL_ICON, new ImageIcon(url)); | ||||
} | } | ||||
} | } | ||||
public void doit() { | public void doit() { | ||||
MessageHandler.errorln("Not implemented."); | |||||
//log.error("Not implemented."); | |||||
} | } | ||||
public void undoit() { | public void undoit() { | ||||
MessageHandler.errorln("Not implemented."); | |||||
//log.error("Not implemented."); | |||||
} | } | ||||
} | } |
import javax.swing.*; | import javax.swing.*; | ||||
import java.awt.event.*; | import java.awt.event.*; | ||||
import org.apache.fop.messaging.MessageHandler; | |||||
public class GoToPageDialog extends JDialog { | public class GoToPageDialog extends JDialog { | ||||
JPanel panel1 = new JPanel(); | JPanel panel1 = new JPanel(); | ||||
GridBagLayout gridBagLayout1 = new GridBagLayout(); | GridBagLayout gridBagLayout1 = new GridBagLayout(); | ||||
jbInit(); | jbInit(); | ||||
pack(); | pack(); | ||||
} catch (Exception ex) { | } catch (Exception ex) { | ||||
MessageHandler.errorln("GoToPageDialog: Konstruktor: " | |||||
+ ex.getMessage()); | |||||
//log.error("GoToPageDialog: Konstruktor: " | |||||
// + ex.getMessage(), ex); | |||||
} | } | ||||
} | } | ||||
package org.apache.fop.viewer; | package org.apache.fop.viewer; | ||||
import java.io.*; | import java.io.*; | ||||
import org.apache.fop.messaging.MessageHandler; | |||||
import java.util.*; | import java.util.*; | ||||
/** | /** | ||||
if (index > 0 && str.length() > index) { | if (index > 0 && str.length() > index) { | ||||
return true; | return true; | ||||
} else { | } else { | ||||
MessageHandler.logln(getClass().getName() | |||||
+ ": load(): invalid line " + str + "." | |||||
+ " Character '=' missed."); | |||||
//log.debug(getClass().getName() | |||||
// + ": load(): invalid line " + str + "." | |||||
// + " Character '=' missed."); | |||||
return false; | return false; | ||||
} | } | ||||
} | } |
import org.apache.fop.layout.*; | import org.apache.fop.layout.*; | ||||
import org.apache.fop.render.awt.*; | import org.apache.fop.render.awt.*; | ||||
import org.apache.fop.messaging.*; | |||||
/** | /** | ||||
* Frame and User Interface for Preview | * Frame and User Interface for Preview | ||||
*/ | */ | ||||
public class PreviewDialog extends JFrame implements ProgressListener, | |||||
MessageListener { | |||||
public class PreviewDialog extends JFrame implements ProgressListener { | |||||
protected Translator res; | protected Translator res; | ||||
/** | /** | ||||
* Called by MessageHandler if an error message or a | |||||
* Called by logger if an error message or a | |||||
* log message is received. | * log message is received. | ||||
*/ | */ | ||||
public void processMessage(MessageEvent event) { | |||||
String error = event.getMessage(); | |||||
public void processMessage() { | |||||
/* String error = event.getMessage(); | |||||
String text = processStatus.getText(); | String text = processStatus.getText(); | ||||
FontMetrics fmt = | FontMetrics fmt = | ||||
processStatus.getFontMetrics(processStatus.getFont()); | processStatus.getFontMetrics(processStatus.getFont()); | ||||
progress(event.getMessage()); | progress(event.getMessage()); | ||||
} | } | ||||
} | } | ||||
} | |||||
}*/ | |||||
} | } | ||||
public void dispose() { | public void dispose() { | ||||
System.exit(0); | System.exit(0); | ||||
} | } | ||||
} // class PreviewDialog | } // class PreviewDialog | ||||
package org.apache.fop.viewer; | package org.apache.fop.viewer; | ||||
import java.util.*; | import java.util.*; | ||||
import org.apache.fop.messaging.MessageHandler; | |||||
import java.io.*; | import java.io.*; | ||||
try { | try { | ||||
lookup.load(in); | lookup.load(in); | ||||
} catch (Exception ex) { | } catch (Exception ex) { | ||||
MessageHandler.logln("Abgefangene Exception: " + ex.getMessage()); | |||||
//log.error("Abgefangene Exception: " + ex.getMessage()); | |||||
isSourceFound = false; | isSourceFound = false; | ||||
} | } | ||||
} | } | ||||
return obj; | return obj; | ||||
else { | else { | ||||
if (isMissingEmphasized) { | if (isMissingEmphasized) { | ||||
MessageHandler.logln(getClass().getName() + ": missing key: " | |||||
+ key); | |||||
//log.debug(getClass().getName() + ": missing key: " | |||||
// + key); | |||||
return getMissedRepresentation(key.toString()); | return getMissedRepresentation(key.toString()); | ||||
} else | } else | ||||
return key.toString(); | return key.toString(); |
package org.apache.fop.viewer; | package org.apache.fop.viewer; | ||||
import java.awt.*; | import java.awt.*; | ||||
import org.apache.fop.messaging.MessageHandler; | |||||
import java.io.*; | import java.io.*; | ||||
import java.awt.event.*; | import java.awt.event.*; | ||||
import java.util.*; | import java.util.*; | ||||
public static void setTranslator(Translator aRes) { | public static void setTranslator(Translator aRes) { | ||||
res = aRes; | res = aRes; | ||||
if (res == null) { | if (res == null) { | ||||
MessageHandler.logln("UserMessage: setTranslator(null) !"); | |||||
//log.debug("UserMessage: setTranslator(null) !"); | |||||
res = new SecureResourceBundle(null); | res = new SecureResourceBundle(null); | ||||
} | } | ||||
* Ersetzt die eventuellen Platzhalter durch die übergebenen Parameter | * Ersetzt die eventuellen Platzhalter durch die übergebenen Parameter | ||||
*/ | */ | ||||
static String prepareMessage(String rawText, String[] par) { | static String prepareMessage(String rawText, String[] par) { | ||||
MessageHandler.logln("prepareMessage(): " + rawText + ", parameter: " | |||||
+ par); | |||||
//log.debug("prepareMessage(): " + rawText + ", parameter: " | |||||
// + par); | |||||
int index = rawText.indexOf(PARAMETER_TAG); | int index = rawText.indexOf(PARAMETER_TAG); | ||||
String composedMess = ""; | String composedMess = ""; | ||||
if ((index == -1) && (par == null)) | if ((index == -1) && (par == null)) | ||||
return rawText; | return rawText; | ||||
if ((index != -1) && (par == null)) { | if ((index != -1) && (par == null)) { | ||||
MessageHandler.logln("Message " + actMessId | |||||
+ " erwartet Parameter. Aufgerufen ohne Parameter"); | |||||
//log.debug("Message " + actMessId | |||||
// + " erwartet Parameter. Aufgerufen ohne Parameter"); | |||||
return rawText; | return rawText; | ||||
} | } | ||||
if ((index == -1) && (par != null)) { | if ((index == -1) && (par != null)) { | ||||
MessageHandler.logln("Message " + actMessId | |||||
+ " erwartet keine Parameter. Aufgerufen mit folgenden Parametern:"); | |||||
for (int i = 0; i < par.length; ++i) | |||||
MessageHandler.logln(par[i].toString()); | |||||
//log.debug("Message " + actMessId | |||||
// + " erwartet keine Parameter. Aufgerufen mit folgenden Parametern:"); | |||||
for (int i = 0; i < par.length; ++i) { | |||||
//log.debug(par[i].toString()); | |||||
} | |||||
return rawText; | return rawText; | ||||
} | } | ||||
int tagCount = 0; | int tagCount = 0; | ||||
try { | try { | ||||
composedMess += rawText.substring(0, index) + par[tagCount]; | composedMess += rawText.substring(0, index) + par[tagCount]; | ||||
} catch (ArrayIndexOutOfBoundsException ex) { | } catch (ArrayIndexOutOfBoundsException ex) { | ||||
MessageHandler.logln("Anzahl der übergebenen Parameter zu der Meldung " | |||||
+ actMessId | |||||
+ " ist weniger als erwartet."); | |||||
ex.printStackTrace(); | |||||
//log.error("Anzahl der übergebenen Parameter zu der Meldung " | |||||
// + actMessId | |||||
// + " ist weniger als erwartet.", ex); | |||||
return composedMess + rawText; | return composedMess + rawText; | ||||
} | } | ||||
rawText = rawText.substring(index + PARAMETER_TAG.length()); | rawText = rawText.substring(index + PARAMETER_TAG.length()); | ||||
tagCount++; | tagCount++; | ||||
} | } | ||||
composedMess += rawText; | composedMess += rawText; | ||||
if (tagCount != par.length) | |||||
MessageHandler.logln("Die zu der Meldung " + actMessId | |||||
+ " übergebenen Parameter sind mehr als die Meldung vorsieht."); | |||||
if (tagCount != par.length) { | |||||
//log.debug("Die zu der Meldung " + actMessId | |||||
// + " übergebenen Parameter sind mehr als die Meldung vorsieht."); | |||||
} | |||||
return composedMess; | return composedMess; | ||||
} | } | ||||
translatedMes.substring(translatedMes.indexOf(':') + 1); | translatedMes.substring(translatedMes.indexOf(':') + 1); | ||||
} catch (Exception ex) { | } catch (Exception ex) { | ||||
MessageHandler.logln("FALSCHES FORMAT: MESSAGE: " + textID); | |||||
//log.debug("FALSCHES FORMAT: MESSAGE: " + textID); | |||||
} | } | ||||
} else { // Message not found | } else { // Message not found | ||||
MessageHandler.logln("UserMessage: textID '" + textID | |||||
+ "' not found. Return " | |||||
+ "value 'CANCEL' = " + CANCEL); | |||||
//log.debug("UserMessage: textID '" + textID | |||||
// + "' not found. Return " | |||||
// + "value 'CANCEL' = " + CANCEL); | |||||
// return CANCEL; | // return CANCEL; | ||||
} else { | } else { | ||||
if (optionTypeIndex == STYLE_NOBUTTON) { | if (optionTypeIndex == STYLE_NOBUTTON) { | ||||
// Wird nicht mehr unterstützt | // Wird nicht mehr unterstützt | ||||
MessageHandler.logln("UserMessage: STYLE_NOBUTTON wird nicht unterstützt"); | |||||
//log.debug("UserMessage: STYLE_NOBUTTON wird nicht unterstützt"); | |||||
return result; | return result; | ||||
} else { | } else { | ||||
result = MessagesDialog.showConfirmDialog(null, preparedMes, | result = MessagesDialog.showConfirmDialog(null, preparedMes, |