aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeiron Liddle <keiron@apache.org>2001-08-20 11:19:24 +0000
committerKeiron Liddle <keiron@apache.org>2001-08-20 11:19:24 +0000
commit4daeb7896ffdcf2a1c3303d6b41103d05f1a9014 (patch)
treeeead5682967b118e1e8b19bdb59d6d7c6e8f1e08
parentc1c2792e38fe0a0567b4bcf1c3f782e757fa846e (diff)
downloadxmlgraphics-fop-4daeb7896ffdcf2a1c3303d6b41103d05f1a9014.tar.gz
xmlgraphics-fop-4daeb7896ffdcf2a1c3303d6b41103d05f1a9014.zip
changed to logkit for logging only half done
fixed getContentHandler in driver git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194430 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/org/apache/fop/apps/CommandLineOptions.java128
-rw-r--r--src/org/apache/fop/apps/CommandLineStarter.java17
-rw-r--r--src/org/apache/fop/apps/Driver.java50
-rw-r--r--src/org/apache/fop/apps/PDFOutputHandler.java4
-rw-r--r--src/org/apache/fop/apps/Starter.java7
-rw-r--r--src/org/apache/fop/apps/StreamRenderer.java27
-rw-r--r--src/org/apache/fop/apps/XTDriver.java5
-rw-r--r--src/org/apache/fop/datatypes/LengthPair.java1
-rw-r--r--src/org/apache/fop/datatypes/LengthRange.java1
-rw-r--r--src/org/apache/fop/datatypes/MixedLength.java2
-rw-r--r--src/org/apache/fop/datatypes/PercentLength.java2
-rw-r--r--src/org/apache/fop/datatypes/TableColLength.java2
-rw-r--r--src/org/apache/fop/datatypes/ToBeImplementedProperty.java6
-rw-r--r--src/org/apache/fop/fo/ColorProfile.java1
-rw-r--r--src/org/apache/fop/fo/Declarations.java1
-rw-r--r--src/org/apache/fop/fo/FONode.java8
-rw-r--r--src/org/apache/fop/fo/FOText.java7
-rw-r--r--src/org/apache/fop/fo/FOTreeBuilder.java17
-rw-r--r--src/org/apache/fop/fo/Property.java33
-rw-r--r--src/org/apache/fop/fo/Title.java1
-rw-r--r--src/org/apache/fop/fo/ToBeImplementedElement.java3
-rw-r--r--src/org/apache/fop/fo/TreeBuilder.java1
-rw-r--r--src/org/apache/fop/fo/Unknown.java3
-rw-r--r--src/org/apache/fop/fo/flow/BidiOverride.java1
-rw-r--r--src/org/apache/fop/fo/flow/Block.java5
-rw-r--r--src/org/apache/fop/fo/flow/Character.java3
-rw-r--r--src/org/apache/fop/fo/flow/ExternalGraphic.java5
-rw-r--r--src/org/apache/fop/fo/flow/Float.java1
-rw-r--r--src/org/apache/fop/fo/flow/Flow.java3
-rw-r--r--src/org/apache/fop/fo/flow/Footnote.java2
-rw-r--r--src/org/apache/fop/fo/flow/InitialPropertySet.java1
-rw-r--r--src/org/apache/fop/fo/flow/InlineContainer.java1
-rw-r--r--src/org/apache/fop/fo/flow/Leader.java5
-rw-r--r--src/org/apache/fop/fo/flow/ListBlock.java3
-rw-r--r--src/org/apache/fop/fo/flow/Marker.java3
-rw-r--r--src/org/apache/fop/fo/flow/MultiCase.java1
-rw-r--r--src/org/apache/fop/fo/flow/MultiProperties.java1
-rw-r--r--src/org/apache/fop/fo/flow/MultiPropertySet.java1
-rw-r--r--src/org/apache/fop/fo/flow/MultiSwitch.java1
-rw-r--r--src/org/apache/fop/fo/flow/MultiToggle.java1
-rw-r--r--src/org/apache/fop/fo/flow/PageNumber.java3
-rw-r--r--src/org/apache/fop/fo/flow/PageNumberCitation.java3
-rw-r--r--src/org/apache/fop/fo/flow/RetrieveMarker.java1
-rw-r--r--src/org/apache/fop/fo/flow/StaticContent.java3
-rw-r--r--src/org/apache/fop/fo/flow/Table.java9
-rw-r--r--src/org/apache/fop/fo/flow/TableAndCaption.java1
-rw-r--r--src/org/apache/fop/fo/flow/TableCaption.java1
-rw-r--r--src/org/apache/fop/fo/flow/TableRow.java1
-rw-r--r--src/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java5
-rw-r--r--src/org/apache/fop/fo/pagination/PageMasterReference.java3
-rw-r--r--src/org/apache/fop/fo/pagination/PageNumberGenerator.java13
-rw-r--r--src/org/apache/fop/fo/pagination/PageSequence.java19
-rw-r--r--src/org/apache/fop/fo/pagination/PageSequenceMaster.java3
-rw-r--r--src/org/apache/fop/fo/pagination/RegionBody.java5
-rw-r--r--src/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java1
-rw-r--r--src/org/apache/fop/fo/pagination/Root.java3
-rw-r--r--src/org/apache/fop/fo/pagination/SimplePageMaster.java5
-rw-r--r--src/org/apache/fop/fo/pagination/SinglePageMasterReference.java3
-rw-r--r--src/org/apache/fop/messaging/MessageHandler.java22
-rw-r--r--src/org/apache/fop/tools/TestConverter.java26
-rw-r--r--src/org/apache/fop/tools/anttasks/Fop.java35
61 files changed, 314 insertions, 216 deletions
diff --git a/src/org/apache/fop/apps/CommandLineOptions.java b/src/org/apache/fop/apps/CommandLineOptions.java
index c13e65518..5bb0d700d 100644
--- a/src/org/apache/fop/apps/CommandLineOptions.java
+++ b/src/org/apache/fop/apps/CommandLineOptions.java
@@ -17,6 +17,13 @@ import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.configuration.Configuration;
import org.apache.fop.apps.FOPException;
+import org.apache.log.*;
+import org.apache.log.format.*;
+import org.apache.log.output.io.*;
+import org.apache.log.output.*;
+
+import java.io.*;
+
/**
* Options parses the commandline arguments
*/
@@ -80,8 +87,30 @@ public class CommandLineOptions {
private java.util.Hashtable rendererOptions;
+ private Logger log;
+
public CommandLineOptions(String[] args)
throws FOPException, FileNotFoundException {
+
+ Hierarchy hierarchy = Hierarchy.getDefaultHierarchy();
+ PatternFormatter formatter = new PatternFormatter(
+ "[%{priority}]: %{message}\n%{throwable}" );
+
+ LogTarget target = null;
+ boolean doConsoleLogging = true;
+ if (doConsoleLogging) {
+ target = new StreamTarget(System.out, formatter);
+ } else {
+ try {
+ File f = new File("fop.log");
+ target = new FileTarget(f, false, formatter);
+ } catch (IOException e) {}
+ }
+
+ hierarchy.setDefaultLogTarget(target);
+ log = hierarchy.getLoggerFor("fop");
+ log.setPriority(Priority.INFO);
+
boolean optionsParsed = true;
rendererOptions = new java.util.Hashtable();
try {
@@ -232,12 +261,12 @@ public class CommandLineOptions {
if (buffermode == NOT_SET) {
buffermode = BUFFER_FILE;
} else {
- MessageHandler.errorln("ERROR: you can only set one buffer method");
+ log.error("you can only set one buffer method");
printUsage();
}
if ((i + 1 == args.length)
|| (args[i + 1].charAt(0) == '-')) {
- MessageHandler.errorln("ERROR: you must specify the buffer output file");
+ log.error("you must specify the buffer output file");
printUsage();
} else {
bufferFile = new File(args[i + 1]);
@@ -291,7 +320,7 @@ public class CommandLineOptions {
// warning if fofile has been set in xslt mode
if (fofile != null) {
- MessageHandler.errorln("WARNING: Can't use fo file with transform mode! Ignoring.\n"
+ log.warn("Can't use fo file with transform mode! Ignoring.\n"
+ "Your input is " + "\n xmlfile: "
+ xmlfile.getAbsolutePath()
+ "\nxsltfile: "
@@ -312,9 +341,9 @@ public class CommandLineOptions {
} else if (inputmode == FO_INPUT) {
if (xmlfile != null || xsltfile != null) {
- MessageHandler.errorln("WARNING: fo input mode, but xmlfile or xslt file are set:");
- MessageHandler.errorln("xml file: " + xmlfile.toString());
- MessageHandler.errorln("xslt file: " + xsltfile.toString());
+ log.warn("fo input mode, but xmlfile or xslt file are set:");
+ log.error("xml file: " + xmlfile.toString());
+ log.error("xslt file: " + xsltfile.toString());
}
if (!fofile.exists()) {
throw new FileNotFoundException("fo file "
@@ -373,10 +402,11 @@ public class CommandLineOptions {
}
public Starter getStarter() throws FOPException {
+ Starter starter = null;
switch (outputmode) {
case AWT_OUTPUT:
try {
- return ((Starter)Class.forName("org.apache.fop.apps.AWTStarter").getConstructor(new Class[] {
+ starter = ((Starter)Class.forName("org.apache.fop.apps.AWTStarter").getConstructor(new Class[] {
CommandLineOptions.class
}).newInstance(new Object[] {
this
@@ -389,7 +419,7 @@ public class CommandLineOptions {
}
case PRINT_OUTPUT:
try {
- return ((Starter)Class.forName("org.apache.fop.apps.PrintStarter").getConstructor(new Class[] {
+ starter = ((Starter)Class.forName("org.apache.fop.apps.PrintStarter").getConstructor(new Class[] {
CommandLineOptions.class
}).newInstance(new Object[] {
this
@@ -403,8 +433,10 @@ public class CommandLineOptions {
}
default:
- return new CommandLineStarter(this);
+ starter = new CommandLineStarter(this);
}
+ starter.setLogger(log);
+ return starter;
}
public int getInputMode() {
@@ -477,7 +509,7 @@ public class CommandLineOptions {
* shows the commandline syntax including a summary of all available options and some examples
*/
public static void printUsage() {
- MessageHandler.errorln("\nUSAGE\nFop [options] [-fo|-xml] infile [-xsl file] [-awt|-pdf|-mif|-pcl|-ps|-txt|-at|-print] <outfile>\n"
+ System.err.println("\nUSAGE\nFop [options] [-fo|-xml] infile [-xsl file] [-awt|-pdf|-mif|-pcl|-ps|-txt|-at|-print] <outfile>\n"
+ " [OPTIONS] \n"
+ " -d debug mode \n"
+ " -x dump configuration settings \n"
@@ -513,7 +545,7 @@ public class CommandLineOptions {
* shows the options for print output
*/
public void printUsagePrintOutput() {
- MessageHandler.errorln("USAGE: -print [-Dstart=i] [-Dend=i] [-Dcopies=i] [-Deven=true|false] "
+ System.err.println("USAGE: -print [-Dstart=i] [-Dend=i] [-Dcopies=i] [-Deven=true|false] "
+ " org.apache.fop.apps.Fop (..) -print \n"
+ "Example:\n"
+ "java -Dstart=1 -Dend=2 org.apache.Fop.apps.Fop infile.fo -print ");
@@ -524,88 +556,88 @@ public class CommandLineOptions {
* debug mode. outputs all commandline settings
*/
private void debug() {
- System.out.print("Input mode: ");
+ log.debug("Input mode: ");
switch (inputmode) {
case NOT_SET:
- MessageHandler.logln("not set");
+ log.debug("not set");
break;
case FO_INPUT:
- MessageHandler.logln("FO ");
- MessageHandler.logln("fo input file: " + fofile.toString());
+ log.debug("FO ");
+ log.debug("fo input file: " + fofile.toString());
break;
case XSLT_INPUT:
- MessageHandler.logln("xslt transformation");
- MessageHandler.logln("xml input file: " + xmlfile.toString());
- MessageHandler.logln("xslt stylesheet: " + xsltfile.toString());
+ log.debug("xslt transformation");
+ log.debug("xml input file: " + xmlfile.toString());
+ log.debug("xslt stylesheet: " + xsltfile.toString());
break;
default:
- MessageHandler.logln("unknown input type");
+ log.debug("unknown input type");
}
- System.out.print("Output mode: ");
+ log.debug("Output mode: ");
switch (outputmode) {
case NOT_SET:
- MessageHandler.logln("not set");
+ log.debug("not set");
break;
case PDF_OUTPUT:
- MessageHandler.logln("pdf");
- MessageHandler.logln("output file: " + outfile.toString());
+ log.debug("pdf");
+ log.debug("output file: " + outfile.toString());
break;
case AWT_OUTPUT:
- MessageHandler.logln("awt on screen");
+ log.debug("awt on screen");
if (outfile != null) {
- MessageHandler.logln("ERROR: awt mode, but outfile is set:");
- MessageHandler.logln("out file: " + outfile.toString());
+ log.error("awt mode, but outfile is set:");
+ log.debug("out file: " + outfile.toString());
}
break;
case MIF_OUTPUT:
- MessageHandler.logln("mif");
- MessageHandler.logln("output file: " + outfile.toString());
+ log.debug("mif");
+ log.debug("output file: " + outfile.toString());
break;
case PRINT_OUTPUT:
- MessageHandler.logln("print directly");
+ log.debug("print directly");
if (outfile != null) {
- MessageHandler.logln("ERROR: print mode, but outfile is set:");
- MessageHandler.logln("out file: " + outfile.toString());
+ log.error("print mode, but outfile is set:");
+ log.error("out file: " + outfile.toString());
}
break;
case PCL_OUTPUT:
- MessageHandler.logln("pcl");
- MessageHandler.logln("output file: " + outfile.toString());
+ log.debug("pcl");
+ log.debug("output file: " + outfile.toString());
break;
case PS_OUTPUT:
- MessageHandler.logln("PostScript");
- MessageHandler.logln("output file: " + outfile.toString());
+ log.debug("PostScript");
+ log.debug("output file: " + outfile.toString());
break;
case TXT_OUTPUT:
- MessageHandler.logln("txt");
- MessageHandler.logln("output file: " + outfile.toString());
+ log.debug("txt");
+ log.debug("output file: " + outfile.toString());
break;
default:
- MessageHandler.logln("unknown input type");
+ log.debug("unknown input type");
}
- MessageHandler.logln("OPTIONS");
+ log.debug("OPTIONS");
if (userConfigFile != null) {
- MessageHandler.logln("user configuration file: "
+ log.debug("user configuration file: "
+ userConfigFile.toString());
} else {
- MessageHandler.logln("no user configuration file is used [default]");
+ log.debug("no user configuration file is used [default]");
}
if (errorDump != null) {
- MessageHandler.logln("debug mode on");
+ log.debug("debug mode on");
} else {
- MessageHandler.logln("debug mode off [default]");
+ log.debug("debug mode off [default]");
}
if (dumpConfiguration != null) {
- MessageHandler.logln("dump configuration");
+ log.debug("dump configuration");
} else {
- MessageHandler.logln("don't dump configuration [default]");
+ log.debug("don't dump configuration [default]");
}
if (quiet != null) {
- MessageHandler.logln("quiet mode on");
+ log.debug("quiet mode on");
} else {
- MessageHandler.logln("quiet mode off [default]");
+ log.debug("quiet mode off [default]");
}
}
@@ -614,7 +646,7 @@ public class CommandLineOptions {
public static void main(String args[]) {
/*
* for (int i = 0; i < args.length; i++) {
- * MessageHandler.logln(">"+args[i]+"<");
+ * log.debug(">"+args[i]+"<");
* }
*/
try {
diff --git a/src/org/apache/fop/apps/CommandLineStarter.java b/src/org/apache/fop/apps/CommandLineStarter.java
index 556be58ce..b516ee938 100644
--- a/src/org/apache/fop/apps/CommandLineStarter.java
+++ b/src/org/apache/fop/apps/CommandLineStarter.java
@@ -13,6 +13,8 @@ import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
+import org.apache.log.*;
+
// Java
import java.io.*;
import java.net.URL;
@@ -37,7 +39,8 @@ public class CommandLineStarter extends Starter {
throws FOPException {
this.commandLineOptions = commandLineOptions;
options.setCommandLineOptions(commandLineOptions);
- errorDump = Configuration.getBooleanValue("debugMode").booleanValue();
+ errorDump =
+ Configuration.getBooleanValue("debugMode").booleanValue();
super.setInputHandler(commandLineOptions.getInputHandler());
}
@@ -47,12 +50,14 @@ public class CommandLineStarter extends Starter {
*/
public void run() throws FOPException {
String version = Version.getVersion();
- MessageHandler.logln(version);
+
+ log.info(version);
XMLReader parser = inputHandler.getParser();
setParserFeatures(parser);
Driver driver = new Driver();
+ driver.setLogger(log);
driver.setBufferFile(commandLineOptions.getBufferFile());
if (errorDump) {
@@ -61,13 +66,15 @@ public class CommandLineStarter extends Starter {
try {
driver.setRenderer(commandLineOptions.getRenderer());
- driver.setOutputStream(new FileOutputStream(commandLineOptions.getOutputFile()));
- driver.getRenderer().setOptions(commandLineOptions.getRendererOptions());
+ driver.setOutputStream( new FileOutputStream(
+ commandLineOptions.getOutputFile()));
+ driver.getRenderer().setOptions(
+ commandLineOptions.getRendererOptions());
driver.render(parser, inputHandler.getInputSource());
System.exit(0);
} catch (Exception e) {
if (e instanceof FOPException) {
- throw (FOPException)e;
+ throw (FOPException) e;
}
throw new FOPException(e);
}
diff --git a/src/org/apache/fop/apps/Driver.java b/src/org/apache/fop/apps/Driver.java
index 0b593a56c..dbd4f7a0c 100644
--- a/src/org/apache/fop/apps/Driver.java
+++ b/src/org/apache/fop/apps/Driver.java
@@ -12,7 +12,6 @@ import org.apache.fop.fo.FOTreeBuilder;
import org.apache.fop.fo.ElementMapping;
import org.apache.fop.layout.AreaTree;
import org.apache.fop.render.Renderer;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.configuration.ConfigurationReader;
import org.apache.fop.configuration.Configuration;
import org.apache.fop.tools.DocumentInputSource;
@@ -22,6 +21,12 @@ import org.apache.fop.render.pdf.PDFRenderer;
import org.apache.fop.system.BufferManager;
+import org.apache.log.*;
+import org.apache.log.format.*;
+import org.apache.log.output.io.*;
+import org.apache.log.output.*;
+import org.apache.avalon.framework.logger.Loggable;
+
// DOM
import org.w3c.dom.Document;
import org.w3c.dom.Node;
@@ -84,7 +89,7 @@ import java.util.*;
* driver.render(parser, fileInputSource(args[0]));
* </PRE>
*/
-public class Driver {
+public class Driver implements Loggable {
/**
* Render to PDF. OutputStream must be set
@@ -166,6 +171,8 @@ public class Driver {
*/
private BufferManager _bufferManager;
+ private Logger log;
+
public static final String getParserClassName() {
String parserClassName = null;
try {
@@ -195,6 +202,11 @@ public class Driver {
_stream = stream;
}
+ public void setLogger(Logger logger) {
+ log = logger;
+ _treeBuilder.setLogger(log);
+ }
+
/**
* Resets the Driver so it can be reused. Property and element
* mappings are reset to defaults.
@@ -408,6 +420,24 @@ public class Driver {
* events but isn't a SAX Parser itself.
*/
public ContentHandler getContentHandler() {
+ if(log == null) {
+ Hierarchy hierarchy = Hierarchy.getDefaultHierarchy();
+ PatternFormatter formatter = new PatternFormatter(
+ "[%{priority}]: %{message}\n%{throwable}" );
+
+ LogTarget target = null;
+ target = new StreamTarget(System.out, formatter);
+
+ hierarchy.setDefaultLogTarget(target);
+ log = hierarchy.getLoggerFor("fop");
+ log.setPriority(Priority.INFO);
+ log.error("Logger not set");
+ }
+
+ StreamRenderer streamRenderer = new StreamRenderer(_stream, _renderer);
+ streamRenderer.setLogger(log);
+ _treeBuilder.setStreamRenderer(streamRenderer);
+
return _treeBuilder;
}
@@ -417,9 +447,7 @@ public class Driver {
*/
public synchronized void render(XMLReader parser, InputSource source)
throws FOPException {
- StreamRenderer streamRenderer = new StreamRenderer(_stream, _renderer);
- _treeBuilder.setStreamRenderer(streamRenderer);
- parser.setContentHandler(_treeBuilder);
+ parser.setContentHandler(getContentHandler());
try {
parser.parse(source);
} catch (SAXException e) {
@@ -439,13 +467,11 @@ public class Driver {
*/
public synchronized void render(Document document)
throws FOPException {
- StreamRenderer streamRenderer = new StreamRenderer(_stream, _renderer);
- _treeBuilder.setStreamRenderer(streamRenderer);
try {
DocumentInputSource source = new DocumentInputSource(document);
DocumentReader reader = new DocumentReader();
- reader.setContentHandler(_treeBuilder);
+ reader.setContentHandler(getContentHandler());
reader.parse(source);
} catch (SAXException e) {
throw new FOPException(e);
@@ -462,17 +488,17 @@ public class Driver {
public void dumpError(Exception e) {
if (_errorDump) {
if (e instanceof SAXException) {
- e.printStackTrace();
+ log.error("", e);
if (((SAXException)e).getException() != null) {
- ((SAXException)e).getException().printStackTrace();
+ log.error("", ((SAXException)e).getException());
}
} else if (e instanceof FOPException) {
e.printStackTrace();
if (((FOPException)e).getException() != null) {
- ((FOPException)e).getException().printStackTrace();
+ log.error("", ((FOPException)e).getException());
}
} else {
- e.printStackTrace();
+ log.error("", e);
}
}
}
diff --git a/src/org/apache/fop/apps/PDFOutputHandler.java b/src/org/apache/fop/apps/PDFOutputHandler.java
index 0b39c67c8..d7b16043d 100644
--- a/src/org/apache/fop/apps/PDFOutputHandler.java
+++ b/src/org/apache/fop/apps/PDFOutputHandler.java
@@ -125,7 +125,7 @@ public class PDFOutputHandler extends XTFOTreeBuilder
FontInfo fontInfo = new FontInfo();
this.renderer.setupFontInfo(fontInfo);
- this.areaTree = new AreaTree();
+// this.areaTree = new AreaTree();
this.areaTree.setFontInfo(fontInfo);
format(areaTree);
@@ -137,7 +137,7 @@ public class PDFOutputHandler extends XTFOTreeBuilder
* render the area tree to the output form
*/
public void doRender() throws IOException, FOPException {
- this.renderer.render(areaTree, this.stream);
+ //this.renderer.render(areaTree, this.stream);
}
// ////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/org/apache/fop/apps/Starter.java b/src/org/apache/fop/apps/Starter.java
index c0882e93f..29e620f33 100644
--- a/src/org/apache/fop/apps/Starter.java
+++ b/src/org/apache/fop/apps/Starter.java
@@ -7,6 +7,8 @@
package org.apache.fop.apps;
+import org.apache.log.*;
+
// SAX
import org.xml.sax.XMLReader;
import org.xml.sax.SAXException;
@@ -27,11 +29,16 @@ public abstract class Starter {
Options options;
InputHandler inputHandler;
+ protected Logger log;
public Starter() throws FOPException {
options = new Options();
}
+ public void setLogger(Logger logger) {
+ log = logger;
+ }
+
public void setInputHandler(InputHandler inputHandler) {
this.inputHandler = inputHandler;
}
diff --git a/src/org/apache/fop/apps/StreamRenderer.java b/src/org/apache/fop/apps/StreamRenderer.java
index 448ec0d66..d18ddd6cd 100644
--- a/src/org/apache/fop/apps/StreamRenderer.java
+++ b/src/org/apache/fop/apps/StreamRenderer.java
@@ -14,7 +14,8 @@ import org.apache.fop.layout.AreaTree;
import org.apache.fop.datatypes.IDReferences;
import org.apache.fop.extensions.ExtensionObj;
import org.apache.fop.fo.pagination.PageSequence;
-import org.apache.fop.messaging.MessageHandler;
+
+import org.apache.log.Logger;
/**
This class acts as a bridge between the XML:FO parser
@@ -27,7 +28,7 @@ import org.apache.fop.messaging.MessageHandler;
FOTreeBuilder when a PageSequence is created,
and AreaTree when a Page is formatted.<P>
*/
-public class StreamRenderer extends Object {
+public class StreamRenderer {
private static final boolean MEM_PROFILE_WITH_GC = false;
/**
@@ -81,11 +82,17 @@ public class StreamRenderer extends Object {
*/
private IDReferences idReferences = new IDReferences();
+ private Logger log;
+
public StreamRenderer(OutputStream outputStream, Renderer renderer) {
this.outputStream = outputStream;
this.renderer = renderer;
}
+ public void setLogger(Logger logger) {
+ log = logger;
+ }
+
public IDReferences getIDReferences() {
return idReferences;
}
@@ -130,20 +137,20 @@ public class StreamRenderer extends Object {
long memoryNow = runtime.totalMemory() - runtime.freeMemory();
long memoryUsed = (memoryNow - initialMemory) / 1024L;
- MessageHandler.logln("Initial heap size: " + (initialMemory/1024L) + "Kb");
- MessageHandler.logln("Current heap size: " + (memoryNow/1024L) + "Kb");
- MessageHandler.logln("Total memory used: " + memoryUsed + "Kb");
+ log.info("Initial heap size: " + (initialMemory/1024L) + "Kb");
+ log.info("Current heap size: " + (memoryNow/1024L) + "Kb");
+ log.info("Total memory used: " + memoryUsed + "Kb");
if (!MEM_PROFILE_WITH_GC) {
- MessageHandler.logln(" Memory use is indicative; no GC was performed");
- MessageHandler.logln(" These figures should not be used comparatively");
+ log.info(" Memory use is indicative; no GC was performed");
+ log.info(" These figures should not be used comparatively");
}
long timeUsed = System.currentTimeMillis() - startTime;
- MessageHandler.logln("Total time used: " + timeUsed + "ms");
- MessageHandler.logln("Pages rendererd: " + pageCount);
- MessageHandler.logln("Avg render time: " + (timeUsed / pageCount) + "ms/page");
+ log.info("Total time used: " + timeUsed + "ms");
+ log.info("Pages rendererd: " + pageCount);
+ log.info("Avg render time: " + (timeUsed / pageCount) + "ms/page");
}
/**
diff --git a/src/org/apache/fop/apps/XTDriver.java b/src/org/apache/fop/apps/XTDriver.java
index 5a0e5f1fb..1551760fa 100644
--- a/src/org/apache/fop/apps/XTDriver.java
+++ b/src/org/apache/fop/apps/XTDriver.java
@@ -10,7 +10,6 @@ package org.apache.fop.apps;
// FOP
import org.apache.fop.fo.XTFOTreeBuilder;
import org.apache.fop.fo.ElementMapping;
-import org.apache.fop.fo.PropertyListMapping;
import org.apache.fop.layout.AreaTree;
import org.apache.fop.layout.FontInfo;
import org.apache.fop.render.Renderer;
@@ -321,7 +320,7 @@ public class XTDriver {
FontInfo fontInfo = new FontInfo();
this.renderer.setupFontInfo(fontInfo);
- this.areaTree = new AreaTree();
+ //this.areaTree = new AreaTree();
this.areaTree.setFontInfo(fontInfo);
this.treeBuilder.format(areaTree);
@@ -331,7 +330,7 @@ public class XTDriver {
* render the area tree to the output form
*/
public void render() throws IOException, FOPException {
- this.renderer.render(areaTree, this.stream);
+ //this.renderer.render(areaTree, this.stream);
}
}
diff --git a/src/org/apache/fop/datatypes/LengthPair.java b/src/org/apache/fop/datatypes/LengthPair.java
index 2144a0366..f643ff168 100644
--- a/src/org/apache/fop/datatypes/LengthPair.java
+++ b/src/org/apache/fop/datatypes/LengthPair.java
@@ -7,7 +7,6 @@
package org.apache.fop.datatypes;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.fo.Property;
/**
diff --git a/src/org/apache/fop/datatypes/LengthRange.java b/src/org/apache/fop/datatypes/LengthRange.java
index 92d365b49..007323299 100644
--- a/src/org/apache/fop/datatypes/LengthRange.java
+++ b/src/org/apache/fop/datatypes/LengthRange.java
@@ -7,7 +7,6 @@
package org.apache.fop.datatypes;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.fo.Property;
/**
diff --git a/src/org/apache/fop/datatypes/MixedLength.java b/src/org/apache/fop/datatypes/MixedLength.java
index 53216399e..246ebd2b0 100644
--- a/src/org/apache/fop/datatypes/MixedLength.java
+++ b/src/org/apache/fop/datatypes/MixedLength.java
@@ -7,8 +7,6 @@
package org.apache.fop.datatypes;
-import org.apache.fop.messaging.MessageHandler;
-
/**
* A length quantity in XSL which is specified with a mixture
* of absolute and relative and/or percent components.
diff --git a/src/org/apache/fop/datatypes/PercentLength.java b/src/org/apache/fop/datatypes/PercentLength.java
index 28848eef9..35d1e2367 100644
--- a/src/org/apache/fop/datatypes/PercentLength.java
+++ b/src/org/apache/fop/datatypes/PercentLength.java
@@ -7,8 +7,6 @@
package org.apache.fop.datatypes;
-import org.apache.fop.messaging.MessageHandler;
-
/**
* a percent specified length quantity in XSL
*/
diff --git a/src/org/apache/fop/datatypes/TableColLength.java b/src/org/apache/fop/datatypes/TableColLength.java
index 0a4df466a..77b035b96 100644
--- a/src/org/apache/fop/datatypes/TableColLength.java
+++ b/src/org/apache/fop/datatypes/TableColLength.java
@@ -7,8 +7,6 @@
package org.apache.fop.datatypes;
-import org.apache.fop.messaging.MessageHandler;
-
/**
* A table-column width specification, possibly including some
* number of proportional "column-units". The absolute size of a
diff --git a/src/org/apache/fop/datatypes/ToBeImplementedProperty.java b/src/org/apache/fop/datatypes/ToBeImplementedProperty.java
index b58ec5116..f21d08e57 100644
--- a/src/org/apache/fop/datatypes/ToBeImplementedProperty.java
+++ b/src/org/apache/fop/datatypes/ToBeImplementedProperty.java
@@ -8,7 +8,8 @@
package org.apache.fop.datatypes;
import org.apache.fop.fo.*;
-import org.apache.fop.messaging.MessageHandler;
+
+import org.apache.log.*;
public class ToBeImplementedProperty extends Property {
@@ -30,7 +31,8 @@ public class ToBeImplementedProperty extends Property {
}
public ToBeImplementedProperty(String propName) {
- MessageHandler.errorln("Warning: property - \"" + propName
+ Logger log = Hierarchy.getDefaultHierarchy().getLoggerFor("fop");
+ log.warn("property - \"" + propName
+ "\" is not implemented yet.");
}
diff --git a/src/org/apache/fop/fo/ColorProfile.java b/src/org/apache/fop/fo/ColorProfile.java
index 14cdc0c2b..020b6cce6 100644
--- a/src/org/apache/fop/fo/ColorProfile.java
+++ b/src/org/apache/fop/fo/ColorProfile.java
@@ -9,7 +9,6 @@ package org.apache.fop.fo;
// FOP
import org.apache.fop.fo.*;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.fo.flow.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.AreaTree;
diff --git a/src/org/apache/fop/fo/Declarations.java b/src/org/apache/fop/fo/Declarations.java
index fe9ba9349..ce711f4f0 100644
--- a/src/org/apache/fop/fo/Declarations.java
+++ b/src/org/apache/fop/fo/Declarations.java
@@ -9,7 +9,6 @@ package org.apache.fop.fo;
// FOP
import org.apache.fop.fo.*;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.fo.flow.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.AreaTree;
diff --git a/src/org/apache/fop/fo/FONode.java b/src/org/apache/fop/fo/FONode.java
index 2467ee076..a620eb235 100644
--- a/src/org/apache/fop/fo/FONode.java
+++ b/src/org/apache/fop/fo/FONode.java
@@ -16,6 +16,8 @@ import org.apache.fop.layout.LinkSet;
import org.apache.fop.system.BufferManager;
import org.apache.fop.fo.flow.Marker;
+import org.apache.log.Logger;
+
// Java
import java.util.Vector;
import java.util.Hashtable;
@@ -73,6 +75,8 @@ abstract public class FONode {
// markers
protected Hashtable markers;
+ protected Logger log;
+
protected FONode(FObj parent) {
this.parent = parent;
if (parent != null) {
@@ -85,6 +89,10 @@ abstract public class FONode {
this.areaClass = parent.areaClass;
}
+ public void setLogger(Logger logger) {
+ log = logger;
+ }
+
public void setIsInTableCell() {
this.isInTableCell = true;
// made recursive by Eric Schaeffer
diff --git a/src/org/apache/fop/fo/FOText.java b/src/org/apache/fop/fo/FOText.java
index 4a4be3cc6..d289a549e 100644
--- a/src/org/apache/fop/fo/FOText.java
+++ b/src/org/apache/fop/fo/FOText.java
@@ -9,7 +9,6 @@ package org.apache.fop.fo;
// FOP
import org.apache.fop.layout.Area;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.layout.BlockArea;
import org.apache.fop.layout.FontState;
import org.apache.fop.layout.*;
@@ -106,7 +105,7 @@ public class FOText extends FONode {
// ML - remove refs to BufferManager
// char ca[] = this.bufferManager.readBuffer((Object)this);
if (!(area instanceof BlockArea)) {
- MessageHandler.errorln("WARNING: text outside block area"
+ log.error("WARNING: text outside block area"
+ new String(ca, start, length));
return new Status(Status.OK);
}
@@ -193,8 +192,8 @@ public class FOText extends FONode {
FontVariant.NORMAL);
} catch (FOPException ex) {
smallCapsFontState = fontState;
- MessageHandler.errorln("Error creating small-caps FontState: "
- + ex.getMessage());
+ //log.error("Error creating small-caps FontState: "
+ // + ex.getMessage());
}
// parse text for upper/lower case and call addRealText
diff --git a/src/org/apache/fop/fo/FOTreeBuilder.java b/src/org/apache/fop/fo/FOTreeBuilder.java
index 0ebaecc01..8b9d8e955 100644
--- a/src/org/apache/fop/fo/FOTreeBuilder.java
+++ b/src/org/apache/fop/fo/FOTreeBuilder.java
@@ -9,13 +9,14 @@ package org.apache.fop.fo;
// FOP
import org.apache.fop.layout.AreaTree;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.StreamRenderer;
import org.apache.fop.fo.pagination.Root;
import org.apache.fop.system.BufferManager;
import org.apache.fop.fo.pagination.PageSequence;
+import org.apache.log.Logger;
+
// SAX
import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.SAXException;
@@ -75,8 +76,13 @@ public class FOTreeBuilder extends DefaultHandler implements TreeBuilder {
*/
private StreamRenderer streamRenderer;
+ private Logger log;
+
public FOTreeBuilder() {}
+ public void setLogger(Logger logger) {
+ log = logger;
+ }
public void setStreamRenderer(StreamRenderer streamRenderer) {
this.streamRenderer = streamRenderer;
@@ -165,13 +171,13 @@ public class FOTreeBuilder extends DefaultHandler implements TreeBuilder {
public void startDocument()
throws SAXException {
rootFObj = null; // allows FOTreeBuilder to be reused
- MessageHandler.logln("building formatting object tree");
+ log.info("building formatting object tree");
streamRenderer.startRenderer();
}
public void endDocument()
throws SAXException {
- MessageHandler.logln("Parsing of document complete, stopping renderer");
+ log.info("Parsing of document complete, stopping renderer");
streamRenderer.stopRenderer();
}
@@ -195,7 +201,7 @@ public class FOTreeBuilder extends DefaultHandler implements TreeBuilder {
if (fobjMaker == null) {
if (!this.unknownFOs.containsKey(fullName)) {
this.unknownFOs.put(fullName, "");
- MessageHandler.errorln("WARNING: Unknown formatting object "
+ log.error("Unknown formatting object "
+ fullName);
}
fobjMaker = new Unknown.Maker(); // fall back
@@ -215,6 +221,7 @@ public class FOTreeBuilder extends DefaultHandler implements TreeBuilder {
list = currentFObj.properties;
}
fobj = fobjMaker.make(currentFObj, list);
+ fobj.setLogger(log);
} catch (FOPException e) {
throw new SAXException(e);
}
@@ -240,7 +247,7 @@ public class FOTreeBuilder extends DefaultHandler implements TreeBuilder {
* @param areaTree the area tree to format into
*/
public void format(AreaTree areaTree) throws FOPException {
- MessageHandler.logln("formatting FOs into areas");
+ log.info("formatting FOs into areas");
this.bufferManager.readComplete();
((Root)this.rootFObj).format(areaTree);
}
diff --git a/src/org/apache/fop/fo/Property.java b/src/org/apache/fop/fo/Property.java
index d56d67ceb..aa623395e 100644
--- a/src/org/apache/fop/fo/Property.java
+++ b/src/org/apache/fop/fo/Property.java
@@ -7,7 +7,6 @@
package org.apache.fop.fo;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.datatypes.*;
import org.apache.fop.fo.expr.Numeric;
import org.apache.fop.fo.expr.PropertyParser;
@@ -16,6 +15,8 @@ import org.apache.fop.fo.expr.PropertyException;
import org.apache.fop.apps.FOPException;
import java.util.Vector;
+import org.apache.log.Logger;
+
public class Property {
public static class Maker {
@@ -131,8 +132,8 @@ public class Property {
return setSubprop(baseProp, partName, p);
}
} else {
- MessageHandler.errorln("WARNING: compound property component "
- + partName + " unknown.");
+ //MessageHandler.errorln("WARNING: compound property component "
+ // + partName + " unknown.");
}
return baseProp;
}
@@ -187,9 +188,9 @@ public class Property {
}
return pret;
} catch (org.apache.fop.fo.expr.PropertyException propEx) {
- MessageHandler.errorln("Error in " + propName
- + " property value '" + value + "': "
- + propEx);
+ //MessageHandler.errorln("Error in " + propName
+ // + " property value '" + value + "': "
+ // + propEx);
throw new FOPException("Property error");
}
}
@@ -223,11 +224,11 @@ public class Property {
}
} catch (FOPException e) {
- MessageHandler.errorln("convertShorthandProperty caught FOPException "
- + e);
+ //MessageHandler.errorln("convertShorthandProperty caught FOPException "
+ // + e);
} catch (org.apache.fop.fo.expr.PropertyException propEx) {
- MessageHandler.errorln("convertShorthandProperty caught PropertyException "
- + propEx);
+ //MessageHandler.errorln("convertShorthandProperty caught PropertyException "
+ // + propEx);
}
if (pret != null) {
/*
@@ -332,9 +333,9 @@ public class Property {
return make(propertyList, specVal,
propertyList.getParentFObj());
} catch (FOPException e) {
- MessageHandler.errorln("Error computing property value for "
- + propName + " from "
- + specVal);
+ //MessageHandler.errorln("Error computing property value for "
+ // + propName + " from "
+ // + specVal);
return null;
}
}
@@ -359,6 +360,12 @@ public class Property {
*/
private String specVal;
+ protected Logger log;
+
+ public void setLogger(Logger logger) {
+ log = logger;
+ }
+
/**
* Set the original value specified for the property attribute.
* @param specVal The specified value.
diff --git a/src/org/apache/fop/fo/Title.java b/src/org/apache/fop/fo/Title.java
index 10c3387af..b55b0aeea 100644
--- a/src/org/apache/fop/fo/Title.java
+++ b/src/org/apache/fop/fo/Title.java
@@ -11,7 +11,6 @@ package org.apache.fop.fo;
import org.apache.fop.fo.*;
import org.apache.fop.datatypes.*;
import org.apache.fop.layout.*;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.fo.flow.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.AreaTree;
diff --git a/src/org/apache/fop/fo/ToBeImplementedElement.java b/src/org/apache/fop/fo/ToBeImplementedElement.java
index 914294553..f1df7e563 100644
--- a/src/org/apache/fop/fo/ToBeImplementedElement.java
+++ b/src/org/apache/fop/fo/ToBeImplementedElement.java
@@ -9,7 +9,6 @@ package org.apache.fop.fo;
// FOP
import org.apache.fop.fo.*;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.fo.flow.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.Area;
@@ -25,7 +24,7 @@ public class ToBeImplementedElement extends FObj {
}
public Status layout(Area area) throws FOPException {
- MessageHandler.logln("This element \"" + this.name
+ log.debug("This element \"" + this.name
+ "\" is not yet implemented.");
return new Status(Status.OK);
}
diff --git a/src/org/apache/fop/fo/TreeBuilder.java b/src/org/apache/fop/fo/TreeBuilder.java
index 1549f7dbe..6b98b7539 100644
--- a/src/org/apache/fop/fo/TreeBuilder.java
+++ b/src/org/apache/fop/fo/TreeBuilder.java
@@ -9,7 +9,6 @@ package org.apache.fop.fo;
// FOP
import org.apache.fop.layout.AreaTree;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.pagination.Root;
diff --git a/src/org/apache/fop/fo/Unknown.java b/src/org/apache/fop/fo/Unknown.java
index bc5049211..43cd255e8 100644
--- a/src/org/apache/fop/fo/Unknown.java
+++ b/src/org/apache/fop/fo/Unknown.java
@@ -10,7 +10,6 @@ package org.apache.fop.fo;
// FOP
import org.apache.fop.fo.*;
import org.apache.fop.layout.*;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.fo.flow.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.AreaTree;
@@ -43,7 +42,7 @@ public class Unknown extends FObj {
}
public Status layout(Area area) throws FOPException {
- MessageHandler.logln("Layout Unknown element");
+ log.debug("Layout Unknown element");
return new Status(Status.OK);
}
}
diff --git a/src/org/apache/fop/fo/flow/BidiOverride.java b/src/org/apache/fop/fo/flow/BidiOverride.java
index ea1566cc7..5133369bf 100644
--- a/src/org/apache/fop/fo/flow/BidiOverride.java
+++ b/src/org/apache/fop/fo/flow/BidiOverride.java
@@ -10,7 +10,6 @@ package org.apache.fop.fo.flow;
// FOP
import org.apache.fop.fo.*;
import org.apache.fop.layout.*;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.fo.flow.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.AreaTree;
diff --git a/src/org/apache/fop/fo/flow/Block.java b/src/org/apache/fop/fo/flow/Block.java
index 7ba0bed04..1b6c812fa 100644
--- a/src/org/apache/fop/fo/flow/Block.java
+++ b/src/org/apache/fop/fo/flow/Block.java
@@ -9,7 +9,6 @@ package org.apache.fop.fo.flow;
// FOP
import org.apache.fop.fo.*;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.*;
import org.apache.fop.datatypes.*;
@@ -76,7 +75,7 @@ public class Block extends FObjMixed {
public Status layout(Area area) throws FOPException {
BlockArea blockArea;
- // MessageHandler.error(" b:LAY[" + marker + "] ");
+ // log.error(" b:LAY[" + marker + "] ");
if (this.marker == BREAK_AFTER) {
@@ -337,7 +336,7 @@ public class Block extends FObjMixed {
return new Status(Status.KEEP_WITH_NEXT);
}
- // MessageHandler.error(" b:OK" + marker + " ");
+ // log.error(" b:OK" + marker + " ");
blockArea.isLast(true);
blockArea = null; // Faster GC - BlockArea is big
return new Status(Status.OK);
diff --git a/src/org/apache/fop/fo/flow/Character.java b/src/org/apache/fop/fo/flow/Character.java
index eea3c77d2..79727d441 100644
--- a/src/org/apache/fop/fo/flow/Character.java
+++ b/src/org/apache/fop/fo/flow/Character.java
@@ -18,7 +18,6 @@ import org.apache.fop.fo.FObj;
import org.apache.fop.layout.FontState;
import org.apache.fop.layout.LineArea;
import org.apache.fop.apps.FOPException;
-import org.apache.fop.messaging.MessageHandler;
/**
@@ -60,7 +59,7 @@ public class Character extends FObj {
public Status layout(Area area) throws FOPException {
BlockArea blockArea;
if (!(area instanceof BlockArea)) {
- MessageHandler.errorln("WARNING: currently Character can only be in a BlockArea");
+ log.error("WARNING: currently Character can only be in a BlockArea");
return new Status(Status.OK);
}
blockArea = (BlockArea)area;
diff --git a/src/org/apache/fop/fo/flow/ExternalGraphic.java b/src/org/apache/fop/fo/flow/ExternalGraphic.java
index 4647ce846..ff175c124 100644
--- a/src/org/apache/fop/fo/flow/ExternalGraphic.java
+++ b/src/org/apache/fop/fo/flow/ExternalGraphic.java
@@ -9,7 +9,6 @@ package org.apache.fop.fo.flow;
// FOP
import org.apache.fop.fo.*;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.*;
import org.apache.fop.apps.FOPException;
@@ -236,11 +235,11 @@ public class ExternalGraphic extends FObj {
} catch (MalformedURLException urlex) {
// bad URL
- MessageHandler.errorln("Error while creating area : "
+ log.error("Error while creating area : "
+ urlex.getMessage());
} catch (FopImageException imgex) {
// image error
- MessageHandler.errorln("Error while creating area : "
+ log.error("Error while creating area : "
+ imgex.getMessage());
}
diff --git a/src/org/apache/fop/fo/flow/Float.java b/src/org/apache/fop/fo/flow/Float.java
index c5eb15188..b88e7873c 100644
--- a/src/org/apache/fop/fo/flow/Float.java
+++ b/src/org/apache/fop/fo/flow/Float.java
@@ -9,7 +9,6 @@ package org.apache.fop.fo.flow;
// FOP
import org.apache.fop.fo.*;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.fo.flow.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.*;
diff --git a/src/org/apache/fop/fo/flow/Flow.java b/src/org/apache/fop/fo/flow/Flow.java
index 9f90dca51..cf08e9a1e 100644
--- a/src/org/apache/fop/fo/flow/Flow.java
+++ b/src/org/apache/fop/fo/flow/Flow.java
@@ -14,7 +14,6 @@ import org.apache.fop.fo.pagination.*;
import org.apache.fop.layout.Area;
import org.apache.fop.layout.BodyAreaContainer;
import org.apache.fop.apps.FOPException;
-import org.apache.fop.messaging.MessageHandler;
// Java
import java.util.Hashtable;
@@ -91,7 +90,7 @@ public class Flow extends FObj {
protected void setFlowName(String name) throws FOPException {
if (name == null || name.equals("")) {
- MessageHandler.errorln("WARNING: A 'flow-name' is required for "
+ log.error("WARNING: A 'flow-name' is required for "
+ getElementName()
+ ". This constraint will be enforced in future versions of FOP");
_flowName = "xsl-region-body";
diff --git a/src/org/apache/fop/fo/flow/Footnote.java b/src/org/apache/fop/fo/flow/Footnote.java
index 3f72d49fb..d4a239f49 100644
--- a/src/org/apache/fop/fo/flow/Footnote.java
+++ b/src/org/apache/fop/fo/flow/Footnote.java
@@ -65,7 +65,7 @@ public class Footnote extends FObj {
}
}
if (fbody == null) {
- MessageHandler.errorln("WARNING: no footnote-body in footnote");
+ log.error("WARNING: no footnote-body in footnote");
}
if (area instanceof BlockArea) {}
return new Status(Status.OK);
diff --git a/src/org/apache/fop/fo/flow/InitialPropertySet.java b/src/org/apache/fop/fo/flow/InitialPropertySet.java
index 7406146d2..aa53341a3 100644
--- a/src/org/apache/fop/fo/flow/InitialPropertySet.java
+++ b/src/org/apache/fop/fo/flow/InitialPropertySet.java
@@ -10,7 +10,6 @@ package org.apache.fop.fo.flow;
// FOP
import org.apache.fop.fo.*;
import org.apache.fop.layout.*;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.fo.flow.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.AreaTree;
diff --git a/src/org/apache/fop/fo/flow/InlineContainer.java b/src/org/apache/fop/fo/flow/InlineContainer.java
index 5332a2dc6..61aba7695 100644
--- a/src/org/apache/fop/fo/flow/InlineContainer.java
+++ b/src/org/apache/fop/fo/flow/InlineContainer.java
@@ -9,7 +9,6 @@ package org.apache.fop.fo.flow;
// FOP
import org.apache.fop.fo.*;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.fo.flow.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.*;
diff --git a/src/org/apache/fop/fo/flow/Leader.java b/src/org/apache/fop/fo/flow/Leader.java
index 97d1e00c8..989b863fb 100644
--- a/src/org/apache/fop/fo/flow/Leader.java
+++ b/src/org/apache/fop/fo/flow/Leader.java
@@ -17,7 +17,6 @@ import org.apache.fop.layout.inline.LeaderArea;
import org.apache.fop.layout.LineArea;
import org.apache.fop.layout.FontState;
import org.apache.fop.apps.FOPException;
-import org.apache.fop.messaging.MessageHandler;
/**
* Implements fo:leader; main property of leader leader-pattern.
@@ -48,7 +47,7 @@ public class Leader extends FObjMixed {
BlockArea blockArea;
// restriction in this version
if (!(area instanceof BlockArea)) {
- MessageHandler.errorln("WARNING: in this version of Fop fo:leader must be a direct child of fo:block ");
+ log.error("WARNING: in this version of Fop fo:leader must be a direct child of fo:block ");
return new Status(Status.OK);
} else {
blockArea = (BlockArea)area;
@@ -198,7 +197,7 @@ public class Leader extends FObjMixed {
ruleStyle, ruleThickness, leaderPatternWidth,
leaderAlignment);
} else {
- MessageHandler.errorln("Leader doesn't fit into line, it will be clipped to fit.");
+ log.error("Leader doesn't fit into line, it will be clipped to fit.");
la.addLeader(leaderPattern, la.getRemainingWidth(),
leaderLengthOptimum, leaderLengthMaximum,
ruleStyle, ruleThickness, leaderPatternWidth,
diff --git a/src/org/apache/fop/fo/flow/ListBlock.java b/src/org/apache/fop/fo/flow/ListBlock.java
index 3b93659d3..935ba9ccb 100644
--- a/src/org/apache/fop/fo/flow/ListBlock.java
+++ b/src/org/apache/fop/fo/flow/ListBlock.java
@@ -9,7 +9,6 @@ package org.apache.fop.fo.flow;
// FOP
import org.apache.fop.fo.*;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.fo.properties.*;
import org.apache.fop.datatypes.*;
import org.apache.fop.layout.*;
@@ -143,7 +142,7 @@ public class ListBlock extends FObj {
int numChildren = this.children.size();
for (int i = this.marker; i < numChildren; i++) {
if (!(children.elementAt(i) instanceof ListItem)) {
- MessageHandler.errorln("children of list-blocks must be list-items");
+ log.error("children of list-blocks must be list-items");
return new Status(Status.OK);
}
ListItem listItem = (ListItem)children.elementAt(i);
diff --git a/src/org/apache/fop/fo/flow/Marker.java b/src/org/apache/fop/fo/flow/Marker.java
index aba8b54a9..762ed8327 100644
--- a/src/org/apache/fop/fo/flow/Marker.java
+++ b/src/org/apache/fop/fo/flow/Marker.java
@@ -9,7 +9,6 @@ package org.apache.fop.fo.flow;
// FOP
import org.apache.fop.fo.*;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.*;
import org.apache.fop.datatypes.*;
@@ -46,7 +45,7 @@ public class Marker extends FObjMixed {
try {
parent.addMarker(this);
} catch (FOPException fopex) {
- MessageHandler.error("marker cannot be added to '" + parent
+ log.error("marker cannot be added to '" + parent
+ "'");
}
}
diff --git a/src/org/apache/fop/fo/flow/MultiCase.java b/src/org/apache/fop/fo/flow/MultiCase.java
index 9cd7a1073..d3c0884c2 100644
--- a/src/org/apache/fop/fo/flow/MultiCase.java
+++ b/src/org/apache/fop/fo/flow/MultiCase.java
@@ -9,7 +9,6 @@ package org.apache.fop.fo.flow;
// FOP
import org.apache.fop.fo.*;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.fo.flow.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.*;
diff --git a/src/org/apache/fop/fo/flow/MultiProperties.java b/src/org/apache/fop/fo/flow/MultiProperties.java
index 03a42b289..19cd50019 100644
--- a/src/org/apache/fop/fo/flow/MultiProperties.java
+++ b/src/org/apache/fop/fo/flow/MultiProperties.java
@@ -9,7 +9,6 @@ package org.apache.fop.fo.flow;
// FOP
import org.apache.fop.fo.*;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.fo.flow.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.*;
diff --git a/src/org/apache/fop/fo/flow/MultiPropertySet.java b/src/org/apache/fop/fo/flow/MultiPropertySet.java
index 7263f702d..f9c9fb96e 100644
--- a/src/org/apache/fop/fo/flow/MultiPropertySet.java
+++ b/src/org/apache/fop/fo/flow/MultiPropertySet.java
@@ -9,7 +9,6 @@ package org.apache.fop.fo.flow;
// FOP
import org.apache.fop.fo.*;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.fo.flow.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.*;
diff --git a/src/org/apache/fop/fo/flow/MultiSwitch.java b/src/org/apache/fop/fo/flow/MultiSwitch.java
index 42e6e185a..eabd80535 100644
--- a/src/org/apache/fop/fo/flow/MultiSwitch.java
+++ b/src/org/apache/fop/fo/flow/MultiSwitch.java
@@ -9,7 +9,6 @@ package org.apache.fop.fo.flow;
// FOP
import org.apache.fop.fo.*;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.fo.flow.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.*;
diff --git a/src/org/apache/fop/fo/flow/MultiToggle.java b/src/org/apache/fop/fo/flow/MultiToggle.java
index 8fce89f14..f49fcd170 100644
--- a/src/org/apache/fop/fo/flow/MultiToggle.java
+++ b/src/org/apache/fop/fo/flow/MultiToggle.java
@@ -9,7 +9,6 @@ package org.apache.fop.fo.flow;
// FOP
import org.apache.fop.fo.*;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.fo.flow.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.*;
diff --git a/src/org/apache/fop/fo/flow/PageNumber.java b/src/org/apache/fop/fo/flow/PageNumber.java
index ddfb60473..65925e54e 100644
--- a/src/org/apache/fop/fo/flow/PageNumber.java
+++ b/src/org/apache/fop/fo/flow/PageNumber.java
@@ -10,7 +10,6 @@ package org.apache.fop.fo.flow;
// FOP
import org.apache.fop.fo.*;
import org.apache.fop.layout.*;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.datatypes.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.*;
@@ -47,7 +46,7 @@ public class PageNumber extends FObj {
public Status layout(Area area) throws FOPException {
if (!(area instanceof BlockArea)) {
- MessageHandler.errorln("WARNING: page-number outside block area");
+ log.error("WARNING: page-number outside block area");
return new Status(Status.OK);
}
if (this.marker == START) {
diff --git a/src/org/apache/fop/fo/flow/PageNumberCitation.java b/src/org/apache/fop/fo/flow/PageNumberCitation.java
index 95d93b627..034be267e 100644
--- a/src/org/apache/fop/fo/flow/PageNumberCitation.java
+++ b/src/org/apache/fop/fo/flow/PageNumberCitation.java
@@ -9,7 +9,6 @@ package org.apache.fop.fo.flow;
// FOP
import org.apache.fop.fo.*;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.fo.pagination.*;
import org.apache.fop.datatypes.*;
import org.apache.fop.fo.properties.*;
@@ -105,7 +104,7 @@ public class PageNumberCitation extends FObj {
public Status layout(Area area) throws FOPException {
if (!(area instanceof BlockArea)) {
- MessageHandler.errorln("WARNING: page-number-citation outside block area");
+ log.error("WARNING: page-number-citation outside block area");
return new Status(Status.OK);
}
diff --git a/src/org/apache/fop/fo/flow/RetrieveMarker.java b/src/org/apache/fop/fo/flow/RetrieveMarker.java
index 55376ac65..67e9f5047 100644
--- a/src/org/apache/fop/fo/flow/RetrieveMarker.java
+++ b/src/org/apache/fop/fo/flow/RetrieveMarker.java
@@ -9,7 +9,6 @@ package org.apache.fop.fo.flow;
// FOP
import org.apache.fop.fo.*;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.*;
import org.apache.fop.datatypes.*;
diff --git a/src/org/apache/fop/fo/flow/StaticContent.java b/src/org/apache/fop/fo/flow/StaticContent.java
index e433ef83e..f6a919fc7 100644
--- a/src/org/apache/fop/fo/flow/StaticContent.java
+++ b/src/org/apache/fop/fo/flow/StaticContent.java
@@ -13,7 +13,6 @@ import org.apache.fop.fo.properties.*;
import org.apache.fop.fo.pagination.*;
import org.apache.fop.layout.Area;
import org.apache.fop.apps.FOPException;
-import org.apache.fop.messaging.MessageHandler;
// Java
import java.util.Enumeration;
@@ -78,7 +77,7 @@ public class StaticContent extends Flow {
Status status;
if ((status = fo.layout(area)).isIncomplete()) {
// in fact all should be laid out and clip, error etc depending on 'overflow'
- MessageHandler.logln("Warning: Some static content could not fit in the area.");
+ log.debug("Warning: Some static content could not fit in the area.");
this.marker = i;
if ((i != 0) && (status.getCode() == Status.AREA_FULL_NONE)) {
status = new Status(Status.AREA_FULL_SOME);
diff --git a/src/org/apache/fop/fo/flow/Table.java b/src/org/apache/fop/fo/flow/Table.java
index 4f67da52b..b6c828b2c 100644
--- a/src/org/apache/fop/fo/flow/Table.java
+++ b/src/org/apache/fop/fo/flow/Table.java
@@ -9,7 +9,6 @@ package org.apache.fop.fo.flow;
// FOP
import org.apache.fop.fo.*;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.*;
import org.apache.fop.datatypes.*;
@@ -199,21 +198,21 @@ public class Table extends FObj {
FONode fo = (FONode)children.elementAt(i);
if (fo instanceof TableHeader) {
if (columns.size() == 0) {
- MessageHandler.errorln("WARNING: current implementation of tables requires a table-column for each column, indicating column-width");
+ log.error("WARNING: current implementation of tables requires a table-column for each column, indicating column-width");
return new Status(Status.OK);
}
tableHeader = (TableHeader)fo;
tableHeader.setColumns(columns);
} else if (fo instanceof TableFooter) {
if (columns.size() == 0) {
- MessageHandler.errorln("WARNING: current implementation of tables requires a table-column for each column, indicating column-width");
+ log.error("WARNING: current implementation of tables requires a table-column for each column, indicating column-width");
return new Status(Status.OK);
}
tableFooter = (TableFooter)fo;
tableFooter.setColumns(columns);
} else if (fo instanceof TableBody) {
if (columns.size() == 0) {
- MessageHandler.errorln("WARNING: current implementation of tables requires a table-column for each column, indicating column-width");
+ log.error("WARNING: current implementation of tables requires a table-column for each column, indicating column-width");
return new Status(Status.OK);
}
Status status;
@@ -291,7 +290,7 @@ public class Table extends FObj {
// from the last table body and place it on the
// next page so that it can have a footer at
// the end of the table.
- MessageHandler.errorln("WARNING: footer could not fit on page, moving last body row to next page");
+ log.error("WARNING: footer could not fit on page, moving last body row to next page");
area.addChild(areaContainer);
area.increaseHeight(areaContainer.getHeight());
area.setAbsoluteHeight(areaContainer.getAbsoluteHeight());
diff --git a/src/org/apache/fop/fo/flow/TableAndCaption.java b/src/org/apache/fop/fo/flow/TableAndCaption.java
index b9243aeea..d7cbebf20 100644
--- a/src/org/apache/fop/fo/flow/TableAndCaption.java
+++ b/src/org/apache/fop/fo/flow/TableAndCaption.java
@@ -9,7 +9,6 @@ package org.apache.fop.fo.flow;
// FOP
import org.apache.fop.fo.*;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.fo.flow.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.*;
diff --git a/src/org/apache/fop/fo/flow/TableCaption.java b/src/org/apache/fop/fo/flow/TableCaption.java
index 93712f309..396f08863 100644
--- a/src/org/apache/fop/fo/flow/TableCaption.java
+++ b/src/org/apache/fop/fo/flow/TableCaption.java
@@ -9,7 +9,6 @@ package org.apache.fop.fo.flow;
// FOP
import org.apache.fop.fo.*;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.fo.flow.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.*;
diff --git a/src/org/apache/fop/fo/flow/TableRow.java b/src/org/apache/fop/fo/flow/TableRow.java
index d2d879c97..d06e04784 100644
--- a/src/org/apache/fop/fo/flow/TableRow.java
+++ b/src/org/apache/fop/fo/flow/TableRow.java
@@ -9,7 +9,6 @@ package org.apache.fop.fo.flow;
// FOP
import org.apache.fop.fo.*;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.fo.properties.*;
import org.apache.fop.datatypes.*;
import org.apache.fop.layout.*;
diff --git a/src/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java b/src/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java
index b186bf74c..c87dd5082 100644
--- a/src/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java
+++ b/src/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java
@@ -10,7 +10,6 @@ package org.apache.fop.fo.pagination;
import org.apache.fop.fo.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.apps.FOPException;
-import org.apache.fop.messaging.MessageHandler;
public class ConditionalPageMasterReference extends FObj {
@@ -75,7 +74,7 @@ public class ConditionalPageMasterReference extends FObj {
break;
case PagePosition.LAST:
// how the hell do you know at this point?
- MessageHandler.log("LAST PagePosition NYI");
+ log.debug("LAST PagePosition NYI");
okOnPagePosition = true;
break;
case PagePosition.REST:
@@ -148,7 +147,7 @@ public class ConditionalPageMasterReference extends FObj {
(RepeatablePageMasterAlternatives)parent;
if (getMasterName() == null) {
- MessageHandler.errorln("WARNING: single-page-master-reference"
+ log.error("WARNING: single-page-master-reference"
+ "does not have a master-name and so is being ignored");
} else {
this.repeatablePageMasterAlternatives.addConditionalPageMasterReference(this);
diff --git a/src/org/apache/fop/fo/pagination/PageMasterReference.java b/src/org/apache/fop/fo/pagination/PageMasterReference.java
index 1cae307d3..33e31419a 100644
--- a/src/org/apache/fop/fo/pagination/PageMasterReference.java
+++ b/src/org/apache/fop/fo/pagination/PageMasterReference.java
@@ -10,7 +10,6 @@ package org.apache.fop.fo.pagination;
import org.apache.fop.fo.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.apps.FOPException;
-import org.apache.fop.messaging.MessageHandler;
/**
* Base PageMasterReference class. Provides implementation for handling the
@@ -72,7 +71,7 @@ public abstract class PageMasterReference extends FObj
_pageSequenceMaster = (PageSequenceMaster)parent;
if (getMasterName() == null) {
- MessageHandler.errorln("WARNING: " + getElementName()
+ log.error("WARNING: " + getElementName()
+ " does not have a master-name and so is being ignored");
} else {
_pageSequenceMaster.addSubsequenceSpecifier(this);
diff --git a/src/org/apache/fop/fo/pagination/PageNumberGenerator.java b/src/org/apache/fop/fo/pagination/PageNumberGenerator.java
index 26153d4e6..8c3e6c257 100644
--- a/src/org/apache/fop/fo/pagination/PageNumberGenerator.java
+++ b/src/org/apache/fop/fo/pagination/PageNumberGenerator.java
@@ -8,7 +8,8 @@
package org.apache.fop.fo.pagination;
import org.apache.fop.fo.properties.*;
-import org.apache.fop.messaging.MessageHandler;
+
+import org.apache.log.*;
// Java
import java.util.*;
@@ -41,6 +42,8 @@ public class PageNumberGenerator {
"", "0", "00", "000", "0000", "00000"
};
+ private Logger log;
+
public PageNumberGenerator(String format, char groupingSeparator,
int groupingSize, int letterValue) {
this.format = format;
@@ -65,7 +68,7 @@ public class PageNumberGenerator {
formatType = UPPERROMAN;
} else {
// token not handled
- MessageHandler.log("'format' token not recognized; using '1'");
+ //log.debug("'format' token not recognized; using '1'");
formatType = DECIMAL;
minPadding = 0;
}
@@ -75,7 +78,7 @@ public class PageNumberGenerator {
// loop
for (int i = 0; i < fmtLen - 1; i++) {
if (format.charAt(i) != '0') {
- MessageHandler.log("'format' token not recognized; using '1'");
+ //log.debug("'format' token not recognized; using '1'");
formatType = DECIMAL;
minPadding = 0;
} else {
@@ -85,6 +88,10 @@ public class PageNumberGenerator {
}
}
+ public void setLogger(Logger logger) {
+ log = logger;
+ }
+
public String makeFormattedPageNumber(int number) {
String pn = null;
if (formatType == DECIMAL) {
diff --git a/src/org/apache/fop/fo/pagination/PageSequence.java b/src/org/apache/fop/fo/pagination/PageSequence.java
index 6b3bf6e6c..801ce7a36 100644
--- a/src/org/apache/fop/fo/pagination/PageSequence.java
+++ b/src/org/apache/fop/fo/pagination/PageSequence.java
@@ -14,7 +14,6 @@ package org.apache.fop.fo.pagination;
// FOP
import org.apache.fop.fo.*;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.fo.properties.*;
import org.apache.fop.fo.flow.Flow;
import org.apache.fop.fo.flow.StaticContent;
@@ -200,7 +199,7 @@ public class PageSequence extends FObj {
throw new FOPException("flow-names must be unique within an fo:page-sequence");
}
if (!this.layoutMasterSet.regionNameExists(flow.getFlowName())) {
- MessageHandler.errorln("WARNING: region-name '"
+ log.error("WARNING: region-name '"
+ flow.getFlowName()
+ "' doesn't exist in the layout-master-set.");
}
@@ -273,7 +272,7 @@ public class PageSequence extends FObj {
currentPage.setFormattedNumber(formattedPageNumber);
this.root.setRunningPageNumberCounter(this.currentPageNumber);
- MessageHandler.log(" [" + currentPageNumber);
+ log.info(" [" + currentPageNumber);
if ((status.getCode() == Status.FORCE_PAGE_BREAK_EVEN)
&& ((currentPageNumber % 2) == 1)) {}
@@ -286,7 +285,7 @@ public class PageSequence extends FObj {
Flow flow = getCurrentFlow(RegionBody.REGION_CLASS);
if (null == flow) {
- MessageHandler.errorln("No flow found for region-body "
+ log.error("No flow found for region-body "
+ "in page-master '"
+ currentPageMasterName + "'");
break;
@@ -302,7 +301,7 @@ public class PageSequence extends FObj {
currentPage.setPageSequence(this);
formatStaticContent(areaTree);
- MessageHandler.log("]");
+ log.info("]");
areaTree.addPage(currentPage);
this.pageCount++; // used for 'force-page-count' calculations
}
@@ -311,8 +310,6 @@ public class PageSequence extends FObj {
forcePage(areaTree, firstAvailPageNumber);
currentPage = null;
-
- MessageHandler.logln("");
}
/**
@@ -415,7 +412,7 @@ public class PageSequence extends FObj {
AreaContainer beforeArea = currentPage.getBefore();
((StaticContent)flow).layout(area, region);
} else {
- MessageHandler.errorln("WARNING: " + region.getName()
+ log.error("WARNING: " + region.getName()
+ " only supports static-content flows currently. Cannot use flow named '"
+ flow.getFlowName() + "'");
}
@@ -479,7 +476,7 @@ public class PageSequence extends FObj {
SubSequenceSpecifier nextSubsequence =
getNextSubsequence(sequenceMaster);
if (nextSubsequence == null) {
- MessageHandler.errorln("\nWARNING: Page subsequences exhausted. Using previous subsequence.");
+ log.error("\nWARNING: Page subsequences exhausted. Using previous subsequence.");
thisIsFirstPage =
true; // this becomes the first page in the new (old really) page master
currentSubsequence.reset();
@@ -674,12 +671,12 @@ public class PageSequence extends FObj {
currentPage.setFormattedNumber(formattedPageNumber);
currentPage.setPageSequence(this);
formatStaticContent(areaTree);
- MessageHandler.log("[forced-" + firstAvailPageNumber + "]");
+ log.debug("[forced-" + firstAvailPageNumber + "]");
areaTree.addPage(currentPage);
this.root.setRunningPageNumberCounter(this.currentPageNumber);
this.isForcing = false;
} catch (FOPException fopex) {
- MessageHandler.log("'force-page-count' failure");
+ log.debug("'force-page-count' failure");
}
}
}
diff --git a/src/org/apache/fop/fo/pagination/PageSequenceMaster.java b/src/org/apache/fop/fo/pagination/PageSequenceMaster.java
index e7598c475..d81af406a 100644
--- a/src/org/apache/fop/fo/pagination/PageSequenceMaster.java
+++ b/src/org/apache/fop/fo/pagination/PageSequenceMaster.java
@@ -12,7 +12,6 @@ import org.apache.fop.fo.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.PageMaster;
import org.apache.fop.apps.FOPException;
-import org.apache.fop.messaging.MessageHandler;
// Java
import java.util.*;
@@ -52,7 +51,7 @@ public class PageSequenceMaster extends FObj {
this.layoutMasterSet = (LayoutMasterSet)parent;
String pm = this.properties.get("master-name").getString();
if (pm == null) {
- MessageHandler.errorln("WARNING: page-sequence-master does not have "
+ log.error("WARNING: page-sequence-master does not have "
+ "a page-master-name and so is being ignored");
} else {
this.layoutMasterSet.addPageSequenceMaster(pm, this);
diff --git a/src/org/apache/fop/fo/pagination/RegionBody.java b/src/org/apache/fop/fo/pagination/RegionBody.java
index 1eae1bb70..9c4d46078 100644
--- a/src/org/apache/fop/fo/pagination/RegionBody.java
+++ b/src/org/apache/fop/fo/pagination/RegionBody.java
@@ -18,7 +18,6 @@ import org.apache.fop.layout.BodyRegionArea;
import org.apache.fop.layout.BorderAndPadding;
import org.apache.fop.layout.BackgroundProps;
import org.apache.fop.layout.MarginProps;
-import org.apache.fop.messaging.MessageHandler;
public class RegionBody extends Region {
@@ -83,13 +82,13 @@ public class RegionBody extends Region {
try {
columnCount = Integer.parseInt(columnCountAsString);
} catch (NumberFormatException nfe) {
- MessageHandler.errorln("Bad value on region body 'column-count'");
+ log.error("Bad value on region body 'column-count'");
columnCount = 1;
}
if ((columnCount > 1) && (overflow == Overflow.SCROLL)) {
// recover by setting 'column-count' to 1. This is allowed but
// not required by the spec.
- MessageHandler.errorln("Setting 'column-count' to 1 because "
+ log.error("Setting 'column-count' to 1 because "
+ "'overflow' is set to 'scroll'");
columnCount = 1;
}
diff --git a/src/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java b/src/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java
index c7eded73f..a7ef8632c 100644
--- a/src/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java
+++ b/src/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java
@@ -9,7 +9,6 @@ package org.apache.fop.fo.pagination;
import org.apache.fop.fo.*;
import org.apache.fop.apps.FOPException;
-import org.apache.fop.messaging.MessageHandler;
// Java
import java.util.Vector;
diff --git a/src/org/apache/fop/fo/pagination/Root.java b/src/org/apache/fop/fo/pagination/Root.java
index e98d8f1c5..7f054162a 100644
--- a/src/org/apache/fop/fo/pagination/Root.java
+++ b/src/org/apache/fop/fo/pagination/Root.java
@@ -9,7 +9,6 @@ package org.apache.fop.fo.pagination;
// FOP
import org.apache.fop.fo.*;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.fo.flow.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.AreaTree;
@@ -104,7 +103,7 @@ public class Root extends FObj {
}
public void format(AreaTree areaTree) throws FOPException {
- // MessageHandler.errorln(" Root[" + marker + "] ");
+ // log.debug(" Root[" + marker + "] ");
if (layoutMasterSet == null) {
throw new FOPException("No layout master set.");
}
diff --git a/src/org/apache/fop/fo/pagination/SimplePageMaster.java b/src/org/apache/fop/fo/pagination/SimplePageMaster.java
index fed72e95c..58c912b93 100644
--- a/src/org/apache/fop/fo/pagination/SimplePageMaster.java
+++ b/src/org/apache/fop/fo/pagination/SimplePageMaster.java
@@ -9,7 +9,6 @@ package org.apache.fop.fo.pagination;
// FOP
import org.apache.fop.fo.*;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.PageMaster;
import org.apache.fop.layout.RegionArea;
@@ -58,7 +57,7 @@ public class SimplePageMaster extends FObj {
this.layoutMasterSet = (LayoutMasterSet)parent;
masterName = this.properties.get("master-name").getString();
if (masterName == null) {
- MessageHandler.errorln("WARNING: simple-page-master does not have "
+ log.error("WARNING: simple-page-master does not have "
+ "a master-name and so is being ignored");
} else {
this.layoutMasterSet.addSimplePageMaster(this);
@@ -99,7 +98,7 @@ public class SimplePageMaster extends FObj {
contentRectangleHeight);
this.pageMaster.addBody(body);
} else {
- MessageHandler.errorln("ERROR: simple-page-master must have a region of class "
+ log.error("ERROR: simple-page-master must have a region of class "
+ RegionBody.REGION_CLASS);
}
diff --git a/src/org/apache/fop/fo/pagination/SinglePageMasterReference.java b/src/org/apache/fop/fo/pagination/SinglePageMasterReference.java
index 315107cf3..7422aa257 100644
--- a/src/org/apache/fop/fo/pagination/SinglePageMasterReference.java
+++ b/src/org/apache/fop/fo/pagination/SinglePageMasterReference.java
@@ -8,7 +8,6 @@ package org.apache.fop.fo.pagination;
import org.apache.fop.fo.*;
import org.apache.fop.apps.FOPException;
-import org.apache.fop.messaging.MessageHandler;
public class SinglePageMasterReference extends PageMasterReference
implements SubSequenceSpecifier {
@@ -53,10 +52,8 @@ public class SinglePageMasterReference extends PageMasterReference
this.state = FIRST;
}
-
protected String getElementName() {
return "fo:single-page-master-reference";
}
-
}
diff --git a/src/org/apache/fop/messaging/MessageHandler.java b/src/org/apache/fop/messaging/MessageHandler.java
index e6ca11828..b9229f897 100644
--- a/src/org/apache/fop/messaging/MessageHandler.java
+++ b/src/org/apache/fop/messaging/MessageHandler.java
@@ -10,6 +10,7 @@ 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
@@ -79,16 +80,22 @@ public class MessageHandler {
}
}
+ // 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:
- System.out.print(getMessage());
+ logger.debug(getMessage());
break;
case FILE:
if (fileOpened) {
@@ -111,7 +118,7 @@ public class MessageHandler {
// do nothing
break;
default:
- System.out.print(message);
+ logger.debug(message);
}
}
}
@@ -121,7 +128,7 @@ public class MessageHandler {
* @param message the message for the user
*/
public static void logln(String message) {
- log(message + "\n");
+ log(message);
}
/**
@@ -130,10 +137,13 @@ public class MessageHandler {
*/
public static void error(String errorMessage) {
+ if(logger == null) {
+ logger = Hierarchy.getDefaultHierarchy().getLoggerFor("fop");
+ }
setMessage(errorMessage);
switch (outputMethod) {
case SCREEN:
- System.err.print(getMessage());
+ logger.error(getMessage());
break;
case FILE:
if (fileOpened) {
@@ -158,7 +168,7 @@ public class MessageHandler {
// do nothing
break;
default:
- System.err.print(errorMessage);
+ logger.error(errorMessage);
}
}
@@ -167,7 +177,7 @@ public class MessageHandler {
* @param errorMessage the message for the user
*/
public static void errorln(String errorMessage) {
- error(errorMessage + "\n");
+ error(errorMessage);
}
/**
diff --git a/src/org/apache/fop/tools/TestConverter.java b/src/org/apache/fop/tools/TestConverter.java
index c18cd6ecd..676b86346 100644
--- a/src/org/apache/fop/tools/TestConverter.java
+++ b/src/org/apache/fop/tools/TestConverter.java
@@ -10,6 +10,8 @@ package org.apache.fop.tools;
import org.apache.fop.apps.*;
import org.apache.fop.configuration.*;
+import org.apache.log.*;
+
import java.io.*;
import java.util.*;
@@ -41,6 +43,7 @@ public class TestConverter {
File compare = null;
String baseDir = "./";
Hashtable differ = new Hashtable();
+ private Logger log;
/**
* This main method can be used to run the test converter from
@@ -77,8 +80,13 @@ public class TestConverter {
tc.runTests(testFile, "results", null);
}
- public TestConverter() {}
+ public TestConverter() {
+ setupLogging();
+ }
+ private void setupLogging() {
+ log = Hierarchy.getDefaultHierarchy().getLoggerFor("testing");
+ }
public void setOutputPDF(boolean pdf) {
outputPDF = pdf;
@@ -98,7 +106,7 @@ public class TestConverter {
* The document is read as a dom and each testcase is covered.
*/
public Hashtable runTests(String fname, String dest, String compDir) {
- // System.out.println("running tests in file:" + fname);
+ log.debug("running tests in file:" + fname);
try {
if (compDir != null) {
compare = new File(baseDir + "/" + compDir);
@@ -122,7 +130,7 @@ public class TestConverter {
if (testsuite.hasAttributes()) {
String profile =
testsuite.getAttributes().getNamedItem("profile").getNodeValue();
- // System.out.println("testing test suite:" + profile);
+ log.debug("testing test suite:" + profile);
}
NodeList testcases = testsuite.getChildNodes();
@@ -148,7 +156,7 @@ public class TestConverter {
if (tcase.hasAttributes()) {
String profile =
tcase.getAttributes().getNamedItem("profile").getNodeValue();
- // System.out.println("testing profile:" + profile);
+ log.debug("testing profile:" + profile);
}
NodeList cases = tcase.getChildNodes();
@@ -192,8 +200,8 @@ public class TestConverter {
if (xslNode != null) {
xsl = xslNode.getNodeValue();
}
- // System.out.println("converting xml:" + xml + " and xsl:" +
- // xsl + " to area tree");
+ log.debug("converting xml:" + xml + " and xsl:" +
+ xsl + " to area tree");
try {
File xmlFile = new File(baseDir + "/" + xml);
@@ -202,7 +210,7 @@ public class TestConverter {
Configuration.put("baseDir",
xmlFile.getParentFile().toURL().toExternalForm());
} catch (Exception e) {
- System.err.println("Error setting base directory");
+ log.error("Error setting base directory");
}
InputHandler inputHandler = null;
@@ -217,7 +225,9 @@ public class TestConverter {
XMLReader parser = inputHandler.getParser();
setParserFeatures(parser);
+ Logger logger = log.getChildLogger("fop");
Driver driver = new Driver();
+ driver.setLogger(logger);
if (outputPDF) {
driver.setRenderer(Driver.RENDER_PDF);
} else {
@@ -236,7 +246,7 @@ public class TestConverter {
}
driver.setOutputStream(new FileOutputStream(new File(destdir,
outname + (outputPDF ? ".pdf" : ".at.xml"))));
- // System.out.println("ddir:" + destdir + " on:" + outname + ".pdf");
+ log.debug("ddir:" + destdir + " on:" + outname + ".pdf");
driver.render(parser, inputHandler.getInputSource());
// check difference
diff --git a/src/org/apache/fop/tools/anttasks/Fop.java b/src/org/apache/fop/tools/anttasks/Fop.java
index 4369c7119..fdf5f906b 100644
--- a/src/org/apache/fop/tools/anttasks/Fop.java
+++ b/src/org/apache/fop/tools/anttasks/Fop.java
@@ -10,6 +10,10 @@ package org.apache.fop.tools.anttasks;
// Ant
import org.apache.tools.ant.*;
+import org.apache.log.*;
+import org.apache.log.format.*;
+import org.apache.log.output.io.*;
+import org.apache.log.output.*;
// SAX
import org.xml.sax.XMLReader;
@@ -143,13 +147,30 @@ public class Fop extends Task {
class FOPTaskStarter extends Starter {
Fop task;
- MessageLogger logger;
+ Logger log;
FOPTaskStarter(Fop task) throws FOPException {
this.task = task;
- MessageHandler.setOutputMethod(MessageHandler.EVENT);
- logger = new MessageLogger(new MessageHandler(), task);
- logger.setMessageLevel(task.getMessageType());
+
+ Hierarchy hierarchy = new Hierarchy();
+ // PatternFormatter formatter = new PatternFormatter(
+ // "[%{priority}] %{category}: %{message}\n%{throwable}" );
+ PatternFormatter formatter = new PatternFormatter("%{message}\n%{throwable}");
+
+ LogTarget target = null;
+ boolean doConsoleLogging = true;
+ if (doConsoleLogging) {
+ target = new StreamTarget(System.out, formatter);
+ } else {
+ try {
+ File f = new File("fop.log");
+ target = new FileTarget(f, false, formatter);
+ } catch (IOException e) {}
+ }
+
+ hierarchy.setDefaultLogTarget(target);
+ log = hierarchy.getLoggerFor("fop");
+ log.setPriority(Priority.INFO);
}
public void run() throws FOPException {
@@ -169,7 +190,7 @@ class FOPTaskStarter extends Starter {
try {
pdfOut = new FileOutputStream(task.getPdffile());
} catch (Exception ex) {
- MessageHandler.errorln("Failed to open " + task.getPdffile());
+ log.error("Failed to open " + task.getPdffile());
throw new BuildException(ex);
}
@@ -180,14 +201,14 @@ class FOPTaskStarter extends Starter {
try {
Driver driver = new Driver(inputHandler.getInputSource(), pdfOut);
+ driver.setLogger(log);
driver.setRenderer(Driver.RENDER_PDF);
driver.setXMLReader(parser);
driver.run();
} catch (Exception ex) {
- MessageHandler.logln("Error: " + ex.getMessage());
+ log.error("Couldn't render pdf: " + ex.getMessage());
throw new BuildException(ex);
}
- logger.die();
}
}