Bladeren bron

PR:

Obtained from:
Submitted by:
Reviewed by:
Conversion of Avalon to Commons-Logger.  (Will still need to update the
examples, which I will take care of next; Jeremias will be modifying
the PDF libraries for more efficient use of the CL loggers.)


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197474 13f79535-47bb-0310-9956-ffa450edef68
tags/Root_Temp_KnuthStylePageBreaking
Glen Mazza 20 jaren geleden
bovenliggende
commit
a054ab3b7e
53 gewijzigde bestanden met toevoegingen van 597 en 362 verwijderingen
  1. 6
    1
      build.xml
  2. 1
    0
      fop.bat
  3. 5
    5
      src/documentation/content/xdocs/embedding.xml
  4. 1
    1
      src/documentation/content/xdocs/servlets.xml
  5. 9
    8
      src/java/org/apache/fop/apps/CommandLineOptions.java
  6. 2
    3
      src/java/org/apache/fop/apps/Document.java
  7. 15
    32
      src/java/org/apache/fop/apps/Driver.java
  8. 5
    9
      src/java/org/apache/fop/apps/FOUserAgent.java
  9. 5
    3
      src/java/org/apache/fop/apps/Fop.java
  10. 2
    3
      src/java/org/apache/fop/area/AreaTreeControl.java
  11. 23
    4
      src/java/org/apache/fop/fo/FOInputHandler.java
  12. 2
    3
      src/java/org/apache/fop/fo/FONode.java
  13. 2
    2
      src/java/org/apache/fop/fo/FOTreeBuilder.java
  14. 2
    3
      src/java/org/apache/fop/fo/FOTreeControl.java
  15. 11
    11
      src/java/org/apache/fop/fo/FOTreeHandler.java
  16. 24
    3
      src/java/org/apache/fop/fo/pagination/PageNumberGenerator.java
  17. 1
    1
      src/java/org/apache/fop/fo/pagination/PageSequence.java
  18. 1
    1
      src/java/org/apache/fop/fo/properties/ToBeImplementedProperty.java
  19. 64
    39
      src/java/org/apache/fop/fonts/apps/PFMReader.java
  20. 61
    38
      src/java/org/apache/fop/fonts/apps/TTFReader.java
  21. 59
    25
      src/java/org/apache/fop/fonts/truetype/TTFFile.java
  22. 32
    10
      src/java/org/apache/fop/fonts/type1/PFMFile.java
  23. 5
    5
      src/java/org/apache/fop/image/AbstractFopImage.java
  24. 2
    2
      src/java/org/apache/fop/image/BmpImage.java
  25. 3
    3
      src/java/org/apache/fop/image/FopImage.java
  26. 2
    2
      src/java/org/apache/fop/image/GifImage.java
  27. 3
    4
      src/java/org/apache/fop/image/ImageFactory.java
  28. 4
    5
      src/java/org/apache/fop/image/JimiImage.java
  29. 2
    2
      src/java/org/apache/fop/image/JpegImage.java
  30. 2
    3
      src/java/org/apache/fop/image/analyser/SVGReader.java
  31. 2
    2
      src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
  32. 12
    13
      src/java/org/apache/fop/pdf/PDFDocument.java
  33. 2
    2
      src/java/org/apache/fop/pdf/PDFEncryptionManager.java
  34. 1
    2
      src/java/org/apache/fop/pdf/PDFFactory.java
  35. 23
    2
      src/java/org/apache/fop/render/AbstractRenderer.java
  36. 9
    0
      src/java/org/apache/fop/render/Renderer.java
  37. 1
    1
      src/java/org/apache/fop/render/pdf/PDFRenderer.java
  38. 1
    1
      src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java
  39. 3
    3
      src/java/org/apache/fop/render/rtf/PageAttributesConverter.java
  40. 3
    3
      src/java/org/apache/fop/render/rtf/RTFHandler.java
  41. 3
    3
      src/java/org/apache/fop/render/rtf/TableAttributesConverter.java
  42. 3
    3
      src/java/org/apache/fop/render/rtf/TableContext.java
  43. 3
    3
      src/java/org/apache/fop/render/rtf/TextAttributesConverter.java
  44. 10
    7
      src/java/org/apache/fop/servlet/FopPrintServlet.java
  45. 6
    6
      src/java/org/apache/fop/servlet/FopServlet.java
  46. 10
    13
      src/java/org/apache/fop/svg/AbstractFOPTranscoder.java
  47. 12
    13
      src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java
  48. 3
    2
      src/java/org/apache/fop/svg/PDFImageElementBridge.java
  49. 2
    1
      src/java/org/apache/fop/svg/PDFTranscoder.java
  50. 5
    5
      src/java/org/apache/fop/svg/SVGUserAgent.java
  51. 46
    14
      src/java/org/apache/fop/tools/AreaTreeBuilder.java
  52. 42
    14
      src/java/org/apache/fop/tools/TestConverter.java
  53. 39
    18
      src/java/org/apache/fop/tools/anttasks/Fop.java

+ 6
- 1
build.xml Bestand weergeven

@@ -79,6 +79,7 @@ list of possible build targets.
<include name="lib/xml-apis.jar"/>
<include name="lib/batik.jar"/>
<include name="lib/avalon-framework*.jar"/>
<include name="lib/commons-logging*.jar"/>
</fileset>

<fileset dir="${basedir}" id="dist.src">
@@ -503,6 +504,7 @@ list of possible build targets.
<war warfile="${build.dir}/fop.war" webxml="${src.dir}/conf/web.xml">
<lib dir="${lib.dir}">
<include name="avalon-framework*.jar"/>
<include name="commons-logging*.jar"/>
<include name="batik*.jar"/>
<include name="commons-io*.jar"/>
</lib>
@@ -575,6 +577,7 @@ list of possible build targets.
<unjar dest="${transcoder-deps}">
<patternset>
<include name="org/apache/avalon/framework/*"/>
<include name="org/apache/commons/logging/*"/>
<include name="org/apache/commons/io/CopyUtils.class"/>
<include name="org/apache/commons/io/IOUtils.class"/>
<include name="org/apache/commons/io/output/ProxyOutputStream.class"/>
@@ -584,13 +587,15 @@ list of possible build targets.
<fileset dir="${lib.dir}">
<include name="commons-io*.jar"/>
<include name="avalon-framework*.jar"/>
</fileset>
<include name="commons-logging*.jar"/>
</fileset>
</unjar>
<mkdir dir="${transcoder-deps}/legal"/>
<copy todir="${transcoder-deps}/legal">
<fileset dir="${lib.dir}">
<include name="avalon.LICENSE.txt"/>
<include name="commons-io.LICENSE.txt"/>
<include name="commons-logging.LICENSE.txt"/>
</fileset>
</copy>
<jar jarfile="${build.dir}/fop-transcoder-allinone.jar">

+ 1
- 0
fop.bat Bestand weergeven

@@ -29,6 +29,7 @@ set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\xalan-2.4.1.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\batik.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\avalon-framework-4.1.4.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\commons-io-dev-20040206.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\commons-logging-1.0.3.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\jimi-1.0.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\jai_core.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\jai_codec.jar

+ 5
- 5
src/documentation/content/xdocs/embedding.xml Bestand weergeven

@@ -71,7 +71,7 @@ args[1] contains a path for the target PDF file.
You also need to set up logging. Global logging for all FOP
processes is managed by MessageHandler. Per-instance logging
is handled by Driver. You want to set both using an implementation
of org.apache.avalon.framework.logger.Logger. See
of org.apache.commons.logging.Log. See
<jump href="#logging">below</jump> for more information.
</p>
<p>
@@ -79,13 +79,13 @@ args[1] contains a path for the target PDF file.
instantiating the Driver object. See here:
</p>
<source><![CDATA[
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.impl.SimpleLog;

/*..*/

Driver driver = new Driver();
Logger logger = new ConsoleLogger(ConsoleLogger.LEVEL_INFO);
Log logger = new SimpleLog(SimpleLog.LOG_LEVEL_INFO);
MessageHandler.setScreenLogger(logger);
driver.setLogger(logger);]]></source>
</section>
@@ -167,7 +167,7 @@ transformer.transform(src, res);]]></source>
for more information.
</p>
<p>
Per default FOP uses the ConsoleLogger which logs to System.out. If you want to do logging using a
Per default FOP uses the SimpleLog which logs to System.out. If you want to do logging using a
logging framework (such as LogKit, Log4J or JDK 1.4 Logging) you can set a
different Logger implementation on the Driver object. Here's an example how you would use LogKit:
</p>

+ 1
- 1
src/documentation/content/xdocs/servlets.xml Bestand weergeven

@@ -89,7 +89,7 @@ protected Logger log;
protected TransformerFactory transformerFactory;

public void init() throws ServletException {
this.log = new ConsoleLogger(ConsoleLogger.LEVEL_WARN);
this.log = new SimpleLog(SimpleLog.LOG_LEVEL_WARN);
this.transformerFactory = TransformerFactory.newInstance();
}


+ 9
- 8
src/java/org/apache/fop/apps/CommandLineOptions.java Bestand weergeven

@@ -24,9 +24,7 @@ import java.io.FileNotFoundException;
import java.util.Locale;
import java.util.Vector;

// Avalon
import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.impl.SimpleLog;

/**
* Options parses the commandline arguments
@@ -83,7 +81,7 @@ public class CommandLineOptions {

private java.util.HashMap rendererOptions;

private Logger log;
private SimpleLog log;

private Vector xsltParams = null;
@@ -96,7 +94,8 @@ public class CommandLineOptions {
public CommandLineOptions(String[] args)
throws FOPException, FileNotFoundException {

log = new ConsoleLogger(ConsoleLogger.LEVEL_INFO);
log = new SimpleLog("FOP");
log.setLevel(SimpleLog.LOG_LEVEL_INFO);

boolean optionsParsed = true;
rendererOptions = new java.util.HashMap();
@@ -118,7 +117,7 @@ public class CommandLineOptions {
* Get the logger.
* @return the logger
*/
public Logger getLogger() {
public SimpleLog getLogger() {
return log;
}

@@ -131,13 +130,15 @@ public class CommandLineOptions {
private boolean parseOptions(String[] args) throws FOPException {
for (int i = 0; i < args.length; i++) {
if (args[i].equals("-d") || args[i].equals("--full-error-dump")) {
log = new ConsoleLogger(ConsoleLogger.LEVEL_DEBUG);
log = new SimpleLog("FOP");
log.setLevel(SimpleLog.LOG_LEVEL_DEBUG);
} else if (args[i].equals("-x")
|| args[i].equals("--dump-config")) {
dumpConfiguration = Boolean.TRUE;
} else if (args[i].equals("-q") || args[i].equals("--quiet")) {
quiet = Boolean.TRUE;
log = new ConsoleLogger(ConsoleLogger.LEVEL_ERROR);
log = new SimpleLog("FOP");
log.setLevel(SimpleLog.LOG_LEVEL_ERROR);
} else if (args[i].equals("-c")) {
i = i + parseConfigurationOption(args, i);
} else if (args[i].equals("-l")) {

+ 2
- 3
src/java/org/apache/fop/apps/Document.java Bestand weergeven

@@ -45,8 +45,7 @@ import org.apache.fop.layout.LayoutStrategy;
// SAX
import org.xml.sax.SAXException;

// Avalon
import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.Log;

/**
* Class storing information for the FOP Document being processed, and managing
@@ -376,7 +375,7 @@ public class Document implements FOTreeControl, FOTreeListener,
/**
* @return the Logger to be used for processing this Document
*/
public Logger getLogger() {
public Log getLogger() {
return getDriver().getLogger();
}


+ 15
- 32
src/java/org/apache/fop/apps/Driver.java Bestand weergeven

@@ -36,10 +36,8 @@ import org.apache.fop.tools.DocumentReader;
import org.apache.fop.tools.ProxyContentHandler;
import org.apache.fop.layoutmgr.LayoutManagerLS;

// Avalon
import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.avalon.framework.logger.LogEnabled;
import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.impl.SimpleLog;
import org.apache.commons.logging.Log;

// DOM
/* org.w3c.dom.Document is not imported to reduce confusion with
@@ -67,7 +65,7 @@ import java.io.OutputStream;
* <PRE>
* Driver driver = new Driver(new InputSource (args[0]),
* new FileOutputStream(args[1]));
* driver.enableLogging(myLogger); //optional
* driver.setLogger(myLogger); //optional
* driver.setRenderer(RENDER_PDF);
* driver.run();
* </PRE>
@@ -97,12 +95,12 @@ import java.io.OutputStream;
*
* <PRE>
* Driver driver = new Driver();
* driver.enableLogging(myLogger); //optional
* driver.setLogger(myLogger); //optional
* driver.setRenderer(new org.apache.fop.render.awt.AWTRenderer(translator));
* driver.render(parser, fileInputSource(args[0]));
* </PRE>
*/
public class Driver implements LogEnabled {
public class Driver {

/**
* private constant to indicate renderer was not defined.
@@ -197,7 +195,7 @@ public class Driver implements LogEnabled {
/**
* the system resources that FOP will use
*/
private Logger log = null;
private Log log = null;
private FOUserAgent userAgent = null;

private Document currentDocument = null;
@@ -247,20 +245,16 @@ public class Driver implements LogEnabled {
protected FOUserAgent getUserAgent() {
if (userAgent == null) {
userAgent = new FOUserAgent();
userAgent.enableLogging(getLogger());
userAgent.setLogger(getLogger());
}
return userAgent;
}

/**
* Provide the Driver instance with a logger. More information on Avalon
* logging can be found at the
* <a href="http://avalon.apache.org">Avalon site</a>.
*
* Provide the Driver instance with a logger.
* @param log the logger. Must not be <code>null</code>.
* @see org.apache.avalon.framework.logger.LogEnabled#enableLogging(Logger)
*/
public void enableLogging(Logger log) {
public void setLogger(Log log) {
if (this.log == null) {
this.log = log;
} else {
@@ -268,25 +262,16 @@ public class Driver implements LogEnabled {
}
}

/**
* Provide the Driver instance with a logger.
* @param log the logger. Must not be <code>null</code>.
* @deprecated Use #enableLogging(Logger) instead.
*/
public void setLogger(Logger log) {
enableLogging(log);
}


/**
* Returns the logger for use by FOP.
* @return the logger
* @see #enableLogging(Logger)
*/
public Logger getLogger() {
public Log getLogger() {
if (this.log == null) {
// use ConsoleLogger as default when logger not explicitly set
this.log = new ConsoleLogger(ConsoleLogger.LEVEL_INFO);
// use SimpleLog as default when logger not explicitly set
log = new SimpleLog("FOP");
((SimpleLog) log).setLevel(SimpleLog.LOG_LEVEL_INFO);
}

return this.log;
@@ -436,9 +421,7 @@ public class Driver implements LogEnabled {
throws IllegalArgumentException {
try {
renderer = (Renderer)Class.forName(rendererClassName).newInstance();
if (renderer instanceof LogEnabled) {
((LogEnabled)renderer).enableLogging(getLogger());
}
renderer.setLogger(getLogger());
renderer.setProducer(Version.getVersion());
renderer.setUserAgent(getUserAgent());
} catch (ClassNotFoundException e) {
@@ -535,7 +518,7 @@ public class Driver implements LogEnabled {
}
}

foInputHandler.enableLogging(getLogger());
foInputHandler.setLogger(getLogger());

treeBuilder.setUserAgent(getUserAgent());
treeBuilder.setFOInputHandler(foInputHandler);

+ 5
- 9
src/java/org/apache/fop/apps/FOUserAgent.java Bestand weergeven

@@ -23,9 +23,7 @@ import java.util.Map;
import java.io.IOException;
import java.io.InputStream;

// Avalon
import org.apache.avalon.framework.logger.LogEnabled;
import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.Log;

// FOP
import org.apache.fop.pdf.PDFEncryptionParams;
@@ -50,9 +48,9 @@ import org.apache.fop.pdf.PDFEncryptionParams;
* These areas may contain resolveable areas that will be processed
* with other resolveable areas
*/
public class FOUserAgent implements LogEnabled {
public class FOUserAgent {

private Logger log;
private Log log;
/** Map containing various default values */
public Map defaults = new java.util.HashMap();
/** Map containing XML handlers for various document types */
@@ -64,18 +62,16 @@ public class FOUserAgent implements LogEnabled {
/**
* Sets the logger.
* @param log Logger to use
* @see org.apache.avalon.framework.logger.LogEnabled#enableLogging(Logger)
*/
public void enableLogging(Logger log) {
public void setLogger(Log log) {
this.log = log;
}

/**
* Returns the logger to use.
* @see org.apache.avalon.framework.logger.AbstractLogEnabled#getLogger()
* (todo) This breaks IoC/SoC. Should be improved.
*/
public Logger getLogger() {
public Log getLogger() {
return this.log;
}


+ 5
- 3
src/java/org/apache/fop/apps/Fop.java Bestand weergeven

@@ -22,8 +22,7 @@ package org.apache.fop.apps;
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;

// Avalon
import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.commons.logging.impl.SimpleLog;

// FOP
import org.apache.fop.render.awt.AWTRenderer;
@@ -46,7 +45,10 @@ public class Fop {

try {
Driver driver = new Driver();
driver.enableLogging(new ConsoleLogger(ConsoleLogger.LEVEL_INFO));
SimpleLog log = new SimpleLog("FOP");
log.setLevel(SimpleLog.LOG_LEVEL_INFO);
driver.setLogger(log);
driver.getLogger().info(version);
options = new CommandLineOptions(args);
inputHandler = options.getInputHandler();

+ 2
- 3
src/java/org/apache/fop/area/AreaTreeControl.java Bestand weergeven

@@ -22,8 +22,7 @@ package org.apache.fop.area;
// FOP
import org.apache.fop.fo.extensions.Bookmarks;

// Avalon
import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.Log;

// Java
import java.util.Set;
@@ -45,7 +44,7 @@ public interface AreaTreeControl {
/**
* @return the Logger being used with this FO Tree
*/
Logger getLogger();
Log getLogger();

/**
* The current set of IDs in the document.

+ 23
- 4
src/java/org/apache/fop/fo/FOInputHandler.java Bestand weergeven

@@ -18,9 +18,6 @@

package org.apache.fop.fo;

// Avalon
import org.apache.avalon.framework.logger.AbstractLogEnabled;

// FOP
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.flow.BasicLink;
@@ -41,6 +38,7 @@ import org.apache.fop.fo.flow.TableCell;
import org.apache.fop.fo.flow.TableRow;
import org.apache.fop.fo.pagination.Flow;
import org.apache.fop.fo.pagination.PageSequence;
import org.apache.commons.logging.Log;

import org.xml.sax.SAXException;

@@ -55,12 +53,17 @@ import org.xml.sax.SAXException;
* handler that builds a structured (as opposed to formatted) document, such
* as our MIF and RTF output targets.
*/
public abstract class FOInputHandler extends AbstractLogEnabled {
public abstract class FOInputHandler {
/**
* The FOTreeControl object that is controlling the FO Tree being built
*/
public FOTreeControl foTreeControl = null;

/**
* logging instance
*/
protected Log logger = null;

/**
* Main constructor
* @param foTreeControl the FOTreeControl implementation that is controlling
@@ -70,6 +73,22 @@ public abstract class FOInputHandler extends AbstractLogEnabled {
this.foTreeControl = foTreeControl;
}

/**
* Sets the Commons-Logging instance for this class
* @param logger The Commons-Logging instance
*/
public void setLogger(Log logger) {
this.logger = logger;
}

/**
* Returns the Commons-Logging instance for this class
* @return The Commons-Logging instance
*/
protected Log getLogger(Log logger) {
return logger;
}

/**
* Returns the FontInfo object associated with this FOInputHandler.
* @return the FontInof object

+ 2
- 3
src/java/org/apache/fop/fo/FONode.java Bestand weergeven

@@ -25,8 +25,7 @@ import java.util.ListIterator;
import org.xml.sax.Attributes;
import org.xml.sax.Locator;

// Avalon
import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.Log;

// FOP
import org.apache.fop.apps.FOPException;
@@ -71,7 +70,7 @@ public abstract class FONode {
* Returns the logger for the node.
* @return the logger
*/
public Logger getLogger() {
public Log getLogger() {
return getFOTreeControl().getLogger();
}


+ 2
- 2
src/java/org/apache/fop/fo/FOTreeBuilder.java Bestand weergeven

@@ -29,7 +29,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.Log;
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.fo.ElementMapping.Maker;
@@ -89,7 +89,7 @@ public class FOTreeBuilder extends DefaultHandler {
setupDefaultMappings();
}

private Logger getLogger() {
private Log getLogger() {
return userAgent.getLogger();
}


+ 2
- 3
src/java/org/apache/fop/fo/FOTreeControl.java Bestand weergeven

@@ -28,8 +28,7 @@ import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.fo.extensions.Bookmarks;
import org.apache.fop.fonts.FontMetrics;

// Avalon
import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.Log;

/**
* An interface for classes that are conceptually the parent class of the
@@ -94,7 +93,7 @@ public interface FOTreeControl {
/**
* @return the Logger being used with this FO Tree
*/
Logger getLogger();
Log getLogger();

/**
* @return the FOUserAgent used for processing this FO Tree

+ 11
- 11
src/java/org/apache/fop/fo/FOTreeHandler.java Bestand weergeven

@@ -135,18 +135,18 @@ public class FOTreeHandler extends FOInputHandler {
long memoryNow = runtime.totalMemory() - runtime.freeMemory();
long memoryUsed = (memoryNow - initialMemory) / 1024L;
long timeUsed = System.currentTimeMillis() - startTime;
if (getLogger().isDebugEnabled()) {
getLogger().debug("Initial heap size: " + (initialMemory / 1024L) + "Kb");
getLogger().debug("Current heap size: " + (memoryNow / 1024L) + "Kb");
getLogger().debug("Total memory used: " + memoryUsed + "Kb");
if (logger != null && logger.isDebugEnabled()) {
logger.debug("Initial heap size: " + (initialMemory / 1024L) + "Kb");
logger.debug("Current heap size: " + (memoryNow / 1024L) + "Kb");
logger.debug("Total memory used: " + memoryUsed + "Kb");
if (!MEM_PROFILE_WITH_GC) {
getLogger().debug(" Memory use is indicative; no GC was performed");
getLogger().debug(" These figures should not be used comparatively");
logger.debug(" Memory use is indicative; no GC was performed");
logger.debug(" These figures should not be used comparatively");
}
getLogger().debug("Total time used: " + timeUsed + "ms");
getLogger().debug("Pages rendered: " + pageCount);
logger.debug("Total time used: " + timeUsed + "ms");
logger.debug("Pages rendered: " + pageCount);
if (pageCount > 0) {
getLogger().debug("Avg render time: " + (timeUsed / pageCount) + "ms/page");
logger.debug("Avg render time: " + (timeUsed / pageCount) + "ms/page");
}
}
}
@@ -180,8 +180,8 @@ public class FOTreeHandler extends FOInputHandler {
System.gc();
}
long memoryNow = runtime.totalMemory() - runtime.freeMemory();
if (getLogger().isDebugEnabled()) {
getLogger().debug("Current heap size: " + (memoryNow / 1024L) + "Kb");
if (logger != null) {
logger.debug("Current heap size: " + (memoryNow / 1024L) + "Kb");
}
}
notifyPageSequenceComplete(pageSequence);

+ 24
- 3
src/java/org/apache/fop/fo/pagination/PageNumberGenerator.java Bestand weergeven

@@ -18,21 +18,26 @@
package org.apache.fop.fo.pagination;

// Avalon
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.commons.logging.Log;

/**
* This class uses the 'format', 'groupingSeparator', 'groupingSize',
* and 'letterValue' properties on fo:page-sequence to return a String
* corresponding to the supplied integer page number.
*/
public class PageNumberGenerator extends AbstractLogEnabled {
public class PageNumberGenerator {

private String format;
private char groupingSeparator;
private int groupingSize;
private int letterValue;

/**
* logging instance
*/
protected Log logger = null;

// constants
private static final int DECIMAL = 1; // '0*1'
private static final int LOWERALPHA = 2; // 'a'
@@ -101,6 +106,22 @@ public class PageNumberGenerator extends AbstractLogEnabled {
}
}

/**
* Sets the Commons-Logging instance for this class
* @param logger The Commons-Logging instance
*/
public void setLogger(Log logger) {
this.logger = logger;
}

/**
* Returns the Commons-Logging instance for this class
* @return The Commons-Logging instance
*/
protected Log getLogger(Log logger) {
return logger;
}

/**
* Formats a page number.
* @param number page number to format

+ 1
- 1
src/java/org/apache/fop/fo/pagination/PageSequence.java Bestand weergeven

@@ -196,7 +196,7 @@ public class PageSequence extends FObj {
this.propertyList.get(PR_GROUPING_SEPARATOR).getCharacter(),
this.propertyList.get(PR_GROUPING_SIZE).getNumber().intValue(),
this.propertyList.get(PR_LETTER_VALUE).getEnum());
this.pageNumberGenerator.enableLogging(getLogger());
this.pageNumberGenerator.setLogger(getLogger());

this.forcePageCount =
this.propertyList.get(PR_FORCE_PAGE_COUNT).getEnum();

+ 1
- 1
src/java/org/apache/fop/fo/properties/ToBeImplementedProperty.java Bestand weergeven

@@ -51,7 +51,7 @@ public class ToBeImplementedProperty extends Property {
//UnimplementedPropertyException or something similar should
//get thrown here instead.

// Logger log = Hierarchy.getDefaultHierarchy().getLoggerFor("fop");
// Log log = Hierarchy.getDefaultHierarchy().getLoggerFor("fop");
// log.warn("property - \"" + propName
// + "\" is not implemented yet.");
}

+ 64
- 39
src/java/org/apache/fop/fonts/apps/PFMReader.java Bestand weergeven

@@ -32,10 +32,8 @@ import javax.xml.transform.TransformerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

//Avalon
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.impl.SimpleLog;

//FOP
import org.apache.fop.fonts.type1.PFMFile;
@@ -44,8 +42,29 @@ import org.apache.fop.fonts.type1.PFMFile;
* A tool which reads PFM files from Adobe Type 1 fonts and creates
* XML font metrics file for use in FOP.
*/
public class PFMReader extends AbstractLogEnabled {
public class PFMReader {
/**
* logging instance
*/
protected Log logger = null;

/**
* Sets the Commons-Logging instance for this class
* @param logger The Commons-Logging instance
*/
public void setLogger(Log logger) {
this.logger = logger;
}

/**
* Returns the Commons-Logging instance for this class
* @return The Commons-Logging instance
*/
protected Log getLogger(Log logger) {
return logger;
}

/**
* Parse commandline arguments. put options in the HashMap and return
* arguments in the String array
@@ -72,15 +91,17 @@ public class PFMReader extends AbstractLogEnabled {
}

private void displayUsage() {
getLogger().info(
" java org.apache.fop.fonts.apps.PFMReader [options] metricfile.pfm xmlfile.xml");
getLogger().info(" where options can be:");
getLogger().info(" -fn <fontname>");
getLogger().info(" default is to use the fontname in the .pfm file, but");
getLogger().info(" you can override that name to make sure that the");
getLogger().info(" embedded font is used (if you're embedding fonts)");
getLogger().info(" instead of installed fonts when viewing documents ");
getLogger().info(" with Acrobat Reader.");
if (logger != null && logger.isInfoEnabled()) {
logger.info(
" java org.apache.fop.fonts.apps.PFMReader [options] metricfile.pfm xmlfile.xml");
logger.info(" where options can be:");
logger.info(" -fn <fontname>");
logger.info(" default is to use the fontname in the .pfm file, but");
logger.info(" you can override that name to make sure that the");
logger.info(" embedded font is used (if you're embedding fonts)");
logger.info(" instead of installed fonts when viewing documents ");
logger.info(" with Acrobat Reader.");
}
}


@@ -113,13 +134,15 @@ public class PFMReader extends AbstractLogEnabled {
String[] arguments = parseArguments(options, args);

PFMReader app = new PFMReader();
Logger log;
Log log;
if (options.get("-d") != null) {
log = new ConsoleLogger(ConsoleLogger.LEVEL_DEBUG);
log = new SimpleLog("FOP/Fonts");
((SimpleLog) log).setLevel(SimpleLog.LOG_LEVEL_DEBUG);
} else {
log = new ConsoleLogger(ConsoleLogger.LEVEL_INFO);
log = new SimpleLog("FOP/Fonts");
((SimpleLog) log).setLevel(SimpleLog.LOG_LEVEL_INFO);
}
app.enableLogging(log);
app.setLogger(log);

log.info("PFM Reader v1.1a");
log.info("");
@@ -170,12 +193,12 @@ public class PFMReader extends AbstractLogEnabled {
* @throws IOException In case of an I/O problem
*/
public PFMFile loadPFM(String filename) throws IOException {
getLogger().info("Reading " + filename + "...");
getLogger().info("");
logger.info("Reading " + filename + "...");
logger.info("");
InputStream in = new java.io.FileInputStream(filename);
try {
PFMFile pfm = new PFMFile();
setupLogger(pfm);
pfm.setLogger(logger);
pfm.load(in);
return pfm;
} finally {
@@ -189,19 +212,21 @@ public class PFMReader extends AbstractLogEnabled {
* @param pfm The PFM file to preview.
*/
public void preview(PFMFile pfm) {
getLogger().info("Font: " + pfm.getWindowsName());
getLogger().info("Name: " + pfm.getPostscriptName());
getLogger().info("CharSet: " + pfm.getCharSetName());
getLogger().info("CapHeight: " + pfm.getCapHeight());
getLogger().info("XHeight: " + pfm.getXHeight());
getLogger().info("LowerCaseAscent: " + pfm.getLowerCaseAscent());
getLogger().info("LowerCaseDescent: " + pfm.getLowerCaseDescent());
getLogger().info("Having widths for " + (pfm.getLastChar() - pfm.getFirstChar())
+ " characters (" + pfm.getFirstChar()
+ "-" + pfm.getLastChar() + ").");
getLogger().info("for example: Char " + pfm.getFirstChar()
+ " has a width of " + pfm.getCharWidth(pfm.getFirstChar()));
getLogger().info("");
if (logger != null & logger.isInfoEnabled()) {
logger.info("Font: " + pfm.getWindowsName());
logger.info("Name: " + pfm.getPostscriptName());
logger.info("CharSet: " + pfm.getCharSetName());
logger.info("CapHeight: " + pfm.getCapHeight());
logger.info("XHeight: " + pfm.getXHeight());
logger.info("LowerCaseAscent: " + pfm.getLowerCaseAscent());
logger.info("LowerCaseDescent: " + pfm.getLowerCaseDescent());
logger.info("Having widths for " + (pfm.getLastChar() - pfm.getFirstChar())
+ " characters (" + pfm.getFirstChar()
+ "-" + pfm.getLastChar() + ").");
logger.info("for example: Char " + pfm.getFirstChar()
+ " has a width of " + pfm.getCharWidth(pfm.getFirstChar()));
logger.info("");
}
}

/**
@@ -213,8 +238,8 @@ public class PFMReader extends AbstractLogEnabled {
*/
public void writeFontXML(org.w3c.dom.Document doc, String target)
throws TransformerException {
getLogger().info("Writing xml font file " + target + "...");
getLogger().info("");
logger.info("Writing xml font file " + target + "...");
logger.info("");

TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
@@ -235,15 +260,15 @@ public class PFMReader extends AbstractLogEnabled {
*/
public org.w3c.dom.Document constructFontXML(PFMFile pfm,
String fontName, String className, String resource, String file) {
getLogger().info("Creating xml font file...");
getLogger().info("");
logger.info("Creating xml font file...");
logger.info("");

Document doc;
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
doc = factory.newDocumentBuilder().newDocument();
} catch (javax.xml.parsers.ParserConfigurationException e) {
getLogger().error("Can't create DOM implementation", e);
logger.error("Can't create DOM implementation", e);
return null;
}
Element root = doc.createElement("font-metrics");

+ 61
- 38
src/java/org/apache/fop/fonts/apps/TTFReader.java Bestand weergeven

@@ -31,21 +31,42 @@ import javax.xml.transform.TransformerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

//Avalon
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.impl.SimpleLog;
import org.apache.commons.logging.Log;

//FOP
import org.apache.fop.fonts.truetype.FontFileReader;
import org.apache.fop.fonts.truetype.TTFCmapEntry;
import org.apache.fop.fonts.truetype.TTFFile;
import org.apache.commons.logging.Log;


/**
* A tool which reads TTF files and generates
* XML font metrics file for use in FOP.
*/
public class TTFReader extends AbstractLogEnabled {
public class TTFReader {

/**
* logging instance
*/
protected Log logger = null;

/**
* Sets the Commons-Logging instance for this class
* @param logger The Commons-Logging instance
*/
public void setLogger(Log logger) {
this.logger = logger;
}

/**
* Returns the Commons-Logging instance for this class
* @return The Commons-Logging instance
*/
protected Log getLogger(Log logger) {
return logger;
}

/**
* Parse commandline arguments. put options in the HashMap and return
@@ -74,29 +95,31 @@ public class TTFReader extends AbstractLogEnabled {


private void displayUsage() {
getLogger().info(
" java org.apache.fop.fonts.apps.TTFReader [options] fontfile.ttf xmlfile.xml");
getLogger().info(" where options can be:");
getLogger().info("-d <DEBUG|INFO>");
getLogger().info(" Set debug level (default: INFO).");
getLogger().info("-enc ansi");
getLogger().info(" With this option you create a WinAnsi encoded font.");
getLogger().info(" The default is to create a CID keyed font.");
getLogger().info(" If you're not going to use characters outside the");
getLogger().info(" pdfencoding range (almost the same as iso-8889-1)");
getLogger().info(" you can add this option.");
getLogger().info("-ttcname <fontname>");
getLogger().info(" If you're reading data from a TrueType Collection");
getLogger().info(" (.ttc file) you must specify which font from the");
getLogger().info(" collection you will read metrics from. If you read");
getLogger().info(" from a .ttc file without this option, the fontnames");
getLogger().info(" will be listed for you.");
getLogger().info(" -fn <fontname>");
getLogger().info(" default is to use the fontname in the .ttf file, but");
getLogger().info(" you can override that name to make sure that the");
getLogger().info(" embedded font is used (if you're embedding fonts)");
getLogger().info(" instead of installed fonts when viewing documents ");
getLogger().info(" with Acrobat Reader.");
if (logger != null & logger.isInfoEnabled()) {
logger.info(
" java org.apache.fop.fonts.apps.TTFReader [options] fontfile.ttf xmlfile.xml");
logger.info(" where options can be:");
logger.info("-d <DEBUG|INFO>");
logger.info(" Set debug level (default: INFO).");
logger.info("-enc ansi");
logger.info(" With this option you create a WinAnsi encoded font.");
logger.info(" The default is to create a CID keyed font.");
logger.info(" If you're not going to use characters outside the");
logger.info(" pdfencoding range (almost the same as iso-8889-1)");
logger.info(" you can add this option.");
logger.info("-ttcname <fontname>");
logger.info(" If you're reading data from a TrueType Collection");
logger.info(" (.ttc file) you must specify which font from the");
logger.info(" collection you will read metrics from. If you read");
logger.info(" from a .ttc file without this option, the fontnames");
logger.info(" will be listed for you.");
logger.info(" -fn <fontname>");
logger.info(" default is to use the fontname in the .ttf file, but");
logger.info(" you can override that name to make sure that the");
logger.info(" embedded font is used (if you're embedding fonts)");
logger.info(" instead of installed fonts when viewing documents ");
logger.info(" with Acrobat Reader.");
}
}


@@ -130,19 +153,20 @@ public class TTFReader extends AbstractLogEnabled {
Map options = new java.util.HashMap();
String[] arguments = parseArguments(options, args);

int level = ConsoleLogger.LEVEL_INFO;
int level = SimpleLog.LOG_LEVEL_INFO;
if (options.get("-d") != null) {
String lev = (String)options.get("-d");
if (lev.equals("DEBUG")) {
level = ConsoleLogger.LEVEL_DEBUG;
level = SimpleLog.LOG_LEVEL_DEBUG;
} else if (lev.equals("INFO")) {
level = ConsoleLogger.LEVEL_INFO;
level = SimpleLog.LOG_LEVEL_INFO;
}
}
Logger log = new ConsoleLogger(level);

SimpleLog log = new SimpleLog("FOP/Fonts");

TTFReader app = new TTFReader();
app.enableLogging(log);
app.setLogger(log);

log.info("TTF Reader v1.1.4");

@@ -218,8 +242,7 @@ public class TTFReader extends AbstractLogEnabled {
*/
public TTFFile loadTTF(String fileName, String fontName) throws IOException {
TTFFile ttfFile = new TTFFile();
setupLogger(ttfFile);
getLogger().info("Reading " + fileName + "...");
logger.info("Reading " + fileName + "...");

FontFileReader reader = new FontFileReader(fileName);
boolean supported = ttfFile.readFont(reader, fontName);
@@ -239,7 +262,7 @@ public class TTFReader extends AbstractLogEnabled {
*/
public void writeFontXML(org.w3c.dom.Document doc, String target)
throws TransformerException {
getLogger().info("Writing xml font file " + target + "...");
logger.info("Writing xml font file " + target + "...");

TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
@@ -263,14 +286,14 @@ public class TTFReader extends AbstractLogEnabled {
public org.w3c.dom.Document constructFontXML(TTFFile ttf,
String fontName, String className, String resource, String file,
boolean isCid, String ttcName) {
getLogger().info("Creating xml font file...");
logger.info("Creating xml font file...");

Document doc;
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
doc = factory.newDocumentBuilder().newDocument();
} catch (javax.xml.parsers.ParserConfigurationException e) {
getLogger().error("Can't create DOM implementation", e);
logger.error("Can't create DOM implementation", e);
return null;
}
Element root = doc.createElement("font-metrics");

+ 59
- 25
src/java/org/apache/fop/fonts/truetype/TTFFile.java Bestand weergeven

@@ -23,9 +23,8 @@ import java.util.Iterator;
import java.util.Map;
import java.util.List;

import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.impl.SimpleLog;
import org.apache.commons.logging.Log;
import org.apache.fop.fonts.Glyphs;

/**
@@ -33,7 +32,7 @@ import org.apache.fop.fonts.Glyphs;
* The TrueType spec can be found at the Microsoft.
* Typography site: http://www.microsoft.com/truetype/
*/
public class TTFFile extends AbstractLogEnabled {
public class TTFFile {

static final byte NTABS = 24;
static final int NMACGLYPHS = 258;
@@ -100,6 +99,27 @@ public class TTFFile extends AbstractLogEnabled {

private TTFDirTabEntry currentDirTab;

/**
* logging instance
*/
protected Log logger = null;

/**
* Sets the Commons-Logging instance for this class
* @param logger The Commons-Logging instance
*/
public void setLogger(Log logger) {
this.logger = logger;
}

/**
* Returns the Commons-Logging instance for this class
* @return The Commons-Logging instance
*/
protected Log getLogger() {
return logger;
}

/**
* Position inputstream to position indicated
* in the dirtab offset + offset
@@ -108,7 +128,9 @@ public class TTFFile extends AbstractLogEnabled {
long offset) throws IOException {
TTFDirTabEntry dt = (TTFDirTabEntry)dirTabs.get(name);
if (dt == null) {
getLogger().error("Dirtab " + name + " not found.");
if (logger != null) {
logger.error("Dirtab " + name + " not found.");
}
} else {
in.seekSet(dt.getOffset() + offset);
this.currentDirTab = dt;
@@ -153,7 +175,9 @@ public class TTFFile extends AbstractLogEnabled {
int numCMap = in.readTTFUShort(); // Number of cmap subtables
long cmapUniOffset = 0;

getLogger().info(numCMap + " cmap tables");
if (logger != null) {
logger.info(numCMap + " cmap tables");
}

//Read offset for all tables. We are only interested in the unicode table
for (int i = 0; i < numCMap; i++) {
@@ -161,8 +185,10 @@ public class TTFFile extends AbstractLogEnabled {
int cmapEID = in.readTTFUShort();
long cmapOffset = in.readTTFULong();

getLogger().debug("Platform ID: " + cmapPID
+ " Encoding: " + cmapEID);
if (logger != null) {
logger.debug("Platform ID: " + cmapPID
+ " Encoding: " + cmapEID);
}

if (cmapPID == 3 && cmapEID == 1) {
cmapUniOffset = cmapOffset;
@@ -170,8 +196,10 @@ public class TTFFile extends AbstractLogEnabled {
}

if (cmapUniOffset <= 0) {
getLogger().fatalError("Unicode cmap table not present");
getLogger().fatalError("Unsupported format: Aborting");
if (logger != null) {
logger.fatal("Unicode cmap table not present");
logger.fatal("Unsupported format: Aborting");
}
return false;
}

@@ -180,7 +208,10 @@ public class TTFFile extends AbstractLogEnabled {
int cmapFormat = in.readTTFUShort();
/*int cmap_length =*/ in.readTTFUShort(); //skip cmap length

getLogger().info("CMAP format: " + cmapFormat);
if (logger != null) {
logger.info("CMAP format: " + cmapFormat);
}

if (cmapFormat == 4) {
in.skip(2); // Skip version number
int cmapSegCountX2 = in.readTTFUShort();
@@ -188,11 +219,11 @@ public class TTFFile extends AbstractLogEnabled {
int cmapEntrySelector = in.readTTFUShort();
int cmapRangeShift = in.readTTFUShort();

if (getLogger().isDebugEnabled()) {
getLogger().debug("segCountX2 : " + cmapSegCountX2);
getLogger().debug("searchRange : " + cmapSearchRange);
getLogger().debug("entrySelector: " + cmapEntrySelector);
getLogger().debug("rangeShift : " + cmapRangeShift);
if (logger != null & logger.isDebugEnabled()) {
logger.debug("segCountX2 : " + cmapSegCountX2);
logger.debug("searchRange : " + cmapSearchRange);
logger.debug("entrySelector: " + cmapEntrySelector);
logger.debug("rangeShift : " + cmapRangeShift);
}


@@ -228,8 +259,10 @@ public class TTFFile extends AbstractLogEnabled {

for (int i = 0; i < cmapStartCounts.length; i++) {

getLogger().debug(i + ": " + cmapStartCounts[i]
+ " - " + cmapEndCounts[i]);
if (logger != null) {
logger.debug(i + ": " + cmapStartCounts[i]
+ " - " + cmapEndCounts[i]);
}

for (int j = cmapStartCounts[i]; j <= cmapEndCounts[i]; j++) {

@@ -265,8 +298,8 @@ public class TTFFile extends AbstractLogEnabled {
ansiWidth[aIdx.intValue()] =
mtxTab[glyphIdx].getWx();

if (getLogger().isDebugEnabled()) {
getLogger().debug("Added width "
if (logger != null) {
logger.debug("Added width "
+ mtxTab[glyphIdx].getWx()
+ " uni: " + j
+ " ansi: " + aIdx.intValue());
@@ -274,8 +307,8 @@ public class TTFFile extends AbstractLogEnabled {
}
}

if (getLogger().isDebugEnabled()) {
getLogger().debug("Idx: "
if (logger != null) {
logger.debug("Idx: "
+ glyphIdx
+ " Delta: " + cmapDeltas[i]
+ " Unicode: " + j
@@ -1256,11 +1289,12 @@ public class TTFFile extends AbstractLogEnabled {
* @param args The command line arguments
*/
public static void main(String[] args) {
int level = ConsoleLogger.LEVEL_WARN;
Logger log = new ConsoleLogger(level);
SimpleLog log = new SimpleLog("FOP/Fonts");
log.setLevel(SimpleLog.LOG_LEVEL_WARN);
try {
TTFFile ttfFile = new TTFFile();
ttfFile.enableLogging(log);
ttfFile.setLogger(log);

FontFileReader reader = new FontFileReader(args[0]);


+ 32
- 10
src/java/org/apache/fop/fonts/type1/PFMFile.java Bestand weergeven

@@ -23,9 +23,9 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.Map;

// Apache libs
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;


// FOP
import org.apache.fop.fonts.Glyphs;
@@ -33,7 +33,7 @@ import org.apache.fop.fonts.Glyphs;
/**
* This class represents a PFM file (or parts of it) as a Java object.
*/
public class PFMFile extends AbstractLogEnabled {
public class PFMFile {

// Header stuff
private String windowsName;
@@ -62,6 +62,28 @@ public class PFMFile extends AbstractLogEnabled {

private Map kerningTab = new java.util.HashMap();

/**
* logging instance
*/
protected Log logger = null;


/**
* Sets the Commons-Logging instance for this class
* @param logger The Commons-Logging instance
*/
public void setLogger(Log logger) {
this.logger = logger;
}

/**
* Returns the Commons-Logging instance for this class
* @return The Commons-Logging instance
*/
protected Log getLogger() {
return logger;
}

/**
* Parses a PFM file
*
@@ -75,7 +97,7 @@ public class PFMFile extends AbstractLogEnabled {
/*final int version =*/ in.readShort();
final long filesize = in.readInt();
if (filesize != buf.length) {
getLogger().warn("Effective file size is not the same as indicated in the header.");
logger.warn("Effective file size is not the same as indicated in the header.");
}
bufin.reset();

@@ -120,7 +142,7 @@ public class PFMFile extends AbstractLogEnabled {
private void loadExtension(PFMInputStream inStream) throws IOException {
final int size = inStream.readShort();
if (size != 30) {
getLogger().warn("Size of extension block was expected to be "
logger.warn("Size of extension block was expected to be "
+ "30 bytes, but was " + size + " bytes.");
}
final long extMetricsOffset = inStream.readInt();
@@ -162,7 +184,7 @@ public class PFMFile extends AbstractLogEnabled {
int i = inStream.readShort();


getLogger().info(i + " kerning pairs");
logger.info(i + " kerning pairs");
while (i > 0) {
int g1 = (int)inStream.readByte();
i--;
@@ -173,12 +195,12 @@ public class PFMFile extends AbstractLogEnabled {
if (adj > 0x8000) {
adj = -(0x10000 - adj);
}
getLogger().debug("Char no: (" + g1 + ", " + g2 + ") kern: " + adj);
logger.debug("Char no: (" + g1 + ", " + g2 + ") kern: " + adj);

if (getLogger().isDebugEnabled()) {
if (logger.isDebugEnabled()) {
final String glyph1 = Glyphs.TEX8R_GLYPH_NAMES[g1];
final String glyph2 = Glyphs.TEX8R_GLYPH_NAMES[g2];
getLogger().debug("glyphs: " + glyph1 + ", " + glyph2);
logger.debug("glyphs: " + glyph1 + ", " + glyph2);
}

Map adjTab = (Map)kerningTab.get(new Integer(g1));
@@ -198,7 +220,7 @@ public class PFMFile extends AbstractLogEnabled {
private void loadExtMetrics(PFMInputStream inStream) throws IOException {
final int size = inStream.readShort();
if (size != 52) {
getLogger().warn("Size of extension block was expected to be "
logger.warn("Size of extension block was expected to be "
+ "52 bytes, but was " + size + " bytes.");
}
inStream.skip(12); //Skip etmPointSize, etmOrientation, etmMasterHeight,

+ 5
- 5
src/java/org/apache/fop/image/AbstractFopImage.java Bestand weergeven

@@ -25,7 +25,7 @@ import java.io.InputStream;
import java.awt.Color;

// FOP
import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.Log;

/**
* Base class to implement the FopImage interface.
@@ -125,7 +125,7 @@ public abstract class AbstractFopImage implements FopImage {
* @param ua the user agent for handling logging etc.
* @return true if the loading was successful
*/
public synchronized boolean load(int type, Logger logger) {
public synchronized boolean load(int type, Log logger) {
if ((loaded & type) != 0) {
return true;
}
@@ -161,7 +161,7 @@ public abstract class AbstractFopImage implements FopImage {
* @param ua the user agent
* @return true if the loading was successful
*/
protected boolean loadDimensions(Logger logger) {
protected boolean loadDimensions(Log logger) {
return false;
}

@@ -173,7 +173,7 @@ public abstract class AbstractFopImage implements FopImage {
* @param ua the user agent
* @return true if the loading was successful
*/
protected boolean loadBitmap(Logger logger) {
protected boolean loadBitmap(Log logger) {
return false;
}

@@ -185,7 +185,7 @@ public abstract class AbstractFopImage implements FopImage {
* @param ua the user agent
* @return true if the loading was successful
*/
protected boolean loadOriginalData(Logger logger) {
protected boolean loadOriginalData(Log logger) {
return false;
}


+ 2
- 2
src/java/org/apache/fop/image/BmpImage.java Bestand weergeven

@@ -23,7 +23,7 @@ import java.io.IOException;
import java.awt.color.ColorSpace;

// FOP
import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.Log;

/**
* Bitmap image.
@@ -50,7 +50,7 @@ public class BmpImage extends AbstractFopImage {
* @param ua the user agent
* @return true if it was loaded successfully
*/
protected boolean loadBitmap(Logger logger) {
protected boolean loadBitmap(Log logger) {
int wpos = 18;
int hpos = 22; // offset positioning for w and height in bmp files
int[] headermap = new int[54];

+ 3
- 3
src/java/org/apache/fop/image/FopImage.java Bestand weergeven

@@ -23,7 +23,7 @@ import java.awt.color.ColorSpace;
import java.awt.color.ICC_Profile;
import java.awt.Color;

import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.Log;

/**
* Fop image interface for loading images.
@@ -61,10 +61,10 @@ public interface FopImage {
* the information.
*
* @param type the type of loading required
* @param logger the Avalon logger
* @param logger the Commons-logging component
* @return boolean true if the information could be loaded
*/
boolean load(int type, Logger logger);
boolean load(int type, Log logger);

/**
* Returns the image width.

+ 2
- 2
src/java/org/apache/fop/image/GifImage.java Bestand weergeven

@@ -29,7 +29,7 @@ import java.io.IOException;
import java.net.URLConnection;

// FOP
import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.Log;

/**
* FopImage object for GIF images, using Java native classes.
@@ -58,7 +58,7 @@ public class GifImage extends AbstractFopImage {
* @param ua the user agent for loading
* @return True if the load process succeeded
*/
protected boolean loadBitmap(Logger logger) {
protected boolean loadBitmap(Log logger) {
int[] tmpMap = null;
try {
URLConnection con = new DummyConnection(inputStream);

+ 3
- 4
src/java/org/apache/fop/image/ImageFactory.java Bestand weergeven

@@ -29,8 +29,7 @@ import java.util.Set;
import java.util.Collections;
import java.util.Iterator;

// Avalon
import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.Log;

// FOP
import org.apache.fop.image.analyser.ImageReaderFactory;
@@ -130,7 +129,7 @@ public class ImageFactory {
* @return the fop image instance
*/
public static FopImage loadImage(String href, FOUserAgent ua) {
Logger log = ua.getLogger();
Log log = ua.getLogger();

InputStream in = openStream(href, ua);

@@ -215,7 +214,7 @@ public class ImageFactory {
* @return a new FopImage object
*/
protected static InputStream openStream(String href, FOUserAgent ua) {
Logger log = ua.getLogger();
Log log = ua.getLogger();
// Get the absolute URL
URL absoluteURL = null;
InputStream in = null;

+ 4
- 5
src/java/org/apache/fop/image/JimiImage.java Bestand weergeven

@@ -28,8 +28,7 @@ import java.awt.Color;
// Jimi
import com.sun.jimi.core.Jimi;

// Avalon
import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.Log;

/**
* FopImage object for several images types, using Jimi.
@@ -49,7 +48,7 @@ public class JimiImage extends AbstractFopImage {
}
}

protected boolean loadDimensions(Logger logger) {
protected boolean loadDimensions(Log logger) {
if (this.bitmaps == null) {
loadImage(logger);
}
@@ -60,7 +59,7 @@ public class JimiImage extends AbstractFopImage {
/**
* @see org.apache.fop.image.AbstractFopImage#loadBitmap(Logger)
*/
protected boolean loadBitmap(Logger logger) {
protected boolean loadBitmap(Log logger) {
if (this.bitmaps == null) {
loadImage(logger);
}
@@ -68,7 +67,7 @@ public class JimiImage extends AbstractFopImage {
return this.bitmaps != null;
}

protected void loadImage(Logger log) {
protected void loadImage(Log log) {
int[] tmpMap = null;
try {
ImageProducer ip =

+ 2
- 2
src/java/org/apache/fop/image/JpegImage.java Bestand weergeven

@@ -24,7 +24,7 @@ import java.awt.color.ColorSpace;
import java.awt.color.ICC_Profile;

// FOP
import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.Log;
import org.apache.fop.util.CMYKColorSpace;

/**
@@ -55,7 +55,7 @@ public class JpegImage extends AbstractFopImage {
* @param ua the user agent
* @return true if loaded false for any error
*/
protected boolean loadOriginalData(Logger logger) {
protected boolean loadOriginalData(Log logger) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ByteArrayOutputStream iccStream = new ByteArrayOutputStream();
int index = 0;

+ 2
- 3
src/java/org/apache/fop/image/analyser/SVGReader.java Bestand weergeven

@@ -27,8 +27,7 @@ import java.awt.geom.AffineTransform;
import org.w3c.dom.Element;
import org.w3c.dom.svg.SVGDocument;

// Avalon
import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.Log;

// Batik
import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
@@ -108,7 +107,7 @@ public class SVGReader implements ImageReader {
*/
class Loader {
private FopImage.ImageInfo getImage(String uri, InputStream fis,
Logger logger, float pixelUnitToMM) {
Log logger, float pixelUnitToMM) {
// parse document and get the size attributes of the svg element

try {

+ 2
- 2
src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java Bestand weergeven

@@ -27,7 +27,7 @@ import org.apache.fop.area.PageViewport;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.PropertyManager;

import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.Log;

import java.util.ListIterator;
import java.util.Map;
@@ -93,7 +93,7 @@ public abstract class AbstractLayoutManager implements LayoutManager, Constants
return userAgent;
}

protected Logger getLogger() {
protected Log getLogger() {
return userAgent.getLogger();
}


+ 12
- 13
src/java/org/apache/fop/pdf/PDFDocument.java Bestand weergeven

@@ -28,9 +28,7 @@ import java.util.List;
import java.util.Map;
import java.util.Iterator;

// Avalon
import org.apache.avalon.framework.logger.LogEnabled;
import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.Log;

/* image support modified from work of BoBoGi */
/* font support based on work by Takayuki Takeuchi */
@@ -56,7 +54,7 @@ import org.apache.avalon.framework.logger.Logger;
* the object list; enhanced trailer output; cleanups.
*
*/
public class PDFDocument implements LogEnabled {
public class PDFDocument {

private static final Integer LOCATION_PLACEHOLDER = new Integer(0);
/**
@@ -69,7 +67,7 @@ public class PDFDocument implements LogEnabled {
*/
public static final String ENCODING = "ISO-8859-1";

private Logger logger;
private Log logger;

/**
* the current character position
@@ -235,6 +233,14 @@ public class PDFDocument implements LogEnabled {
this.info = getFactory().makeInfo(prod);
}

/**
* Sets the Commons-Logging instance for this class
* @param logger The Commons-Logging instance
*/
public void setLogger(Log logger) {
this.logger = logger;
}

/**
* Returns the factory for PDF objects.
* @return PDFFactory the factory
@@ -253,13 +259,6 @@ public class PDFDocument implements LogEnabled {
return this.encodingOnTheFly;
}

/**
* @see org.apache.avalon.framework.logger.LogEnabled#enableLogging(Logger)
*/
public void enableLogging(Logger logger) {
this.logger = logger;
}

/**
* Helper method to allow sub-classes to aquire logger.
*
@@ -267,7 +266,7 @@ public class PDFDocument implements LogEnabled {
* and will be inlined by the JVM.</p>
* @return the Logger
*/
protected final Logger getLogger() {
protected final Log getLogger() {
return this.logger;
}


+ 2
- 2
src/java/org/apache/fop/pdf/PDFEncryptionManager.java Bestand weergeven

@@ -23,7 +23,7 @@ import java.lang.reflect.Method;
import java.security.Provider;
import java.security.Security;

import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.Log;
import org.apache.fop.apps.FOUserAgent;

/**
@@ -77,7 +77,7 @@ public class PDFEncryptionManager {
*/
public static void setupPDFEncryption(FOUserAgent userAgent,
PDFDocument pdf,
Logger log) {
Log log) {
if (userAgent == null) {
throw new NullPointerException("User agent must not be null");
}

+ 1
- 2
src/java/org/apache/fop/pdf/PDFFactory.java Bestand weergeven

@@ -1133,8 +1133,7 @@ public class PDFFactory {
FontFileReader reader = new FontFileReader(in);

TTFSubSetFile subset = new TTFSubSetFile();
ContainerUtil.enableLogging(subset,
getDocument().getLogger().getChildLogger("fonts"));
subset.setLogger(getDocument().getLogger());

byte[] subsetFont = subset.readFont(reader,
mbfont.getTTCName(), mbfont.getUsedGlyphs());

+ 23
- 2
src/java/org/apache/fop/render/AbstractRenderer.java Bestand weergeven

@@ -63,9 +63,9 @@ import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.FOTreeControl;
import org.apache.fop.fo.pagination.Region;
import org.apache.commons.logging.Log;

// Avalon
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
@@ -75,7 +75,7 @@ import org.apache.avalon.framework.configuration.ConfigurationException;
* top level processing of the area tree and adds some abstract methods to
* handle viewports. This keeps track of the current block and inline position.
*/
public abstract class AbstractRenderer extends AbstractLogEnabled
public abstract class AbstractRenderer
implements Renderer, Configurable, Constants {

/**
@@ -83,6 +83,11 @@ public abstract class AbstractRenderer extends AbstractLogEnabled
*/
protected FOUserAgent userAgent;

/**
* logging instance
*/
protected Log logger = null;

/**
* producer (usually "FOP")
*/
@@ -136,6 +141,22 @@ public abstract class AbstractRenderer extends AbstractLogEnabled
public void configure(Configuration conf) throws ConfigurationException {
}

/**
* Sets the Commons-Logging instance for this class
* @param logger The Commons-Logging instance
*/
public void setLogger(Log logger) {
this.logger = logger;
}

/**
* Returns the Commons-Logging instance for this class
* @return The Commons-Logging instance
*/
protected Log getLogger() {
return logger;
}

/** @see org.apache.fop.render.Renderer */
public void setProducer(String inProducer) {
producer = inProducer;

+ 9
- 0
src/java/org/apache/fop/render/Renderer.java Bestand weergeven

@@ -37,6 +37,8 @@ import org.apache.fop.area.inline.Viewport;
import org.apache.fop.area.inline.TextArea;
import org.apache.fop.fo.FOTreeControl;
import org.apache.fop.apps.FOUserAgent;
import org.apache.commons.logging.Log;


/**
* Interface implemented by all renderers. This interface is used to control
@@ -185,6 +187,13 @@ public interface Renderer {
* @param cont The inline container area
*/
void renderContainer(Container cont);
/**
* Tells the renderer to render an inline container.
*
* @param cont The inline container area
*/
void setLogger(Log logger);

}


+ 1
- 1
src/java/org/apache/fop/render/pdf/PDFRenderer.java Bestand weergeven

@@ -249,7 +249,7 @@ public class PDFRenderer extends PrintRenderer {
ostream = stream;
producer = "FOP " + Version.getVersion();
this.pdfDoc = new PDFDocument(producer);
setupLogger(this.pdfDoc);
this.pdfDoc.setLogger(logger);
this.pdfDoc.setCreator(creator);
this.pdfDoc.setCreationDate(creationDate);
this.pdfDoc.setFilterMap(filterMap);

+ 1
- 1
src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java Bestand weergeven

@@ -105,7 +105,7 @@ public abstract class AbstractPSTranscoder extends AbstractFOPTranscoder {
throws TranscoderException {

graphics = createDocumentGraphics2D();
ContainerUtil.enableLogging(graphics, getLogger());
try {
if (this.cfg != null) {
ContainerUtil.configure(graphics, this.cfg);

+ 3
- 3
src/java/org/apache/fop/render/rtf/PageAttributesConverter.java Bestand weergeven

@@ -19,8 +19,8 @@

package org.apache.fop.render.rtf;

import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.impl.SimpleLog;

//FOP
import org.apache.fop.apps.FOPException;
@@ -40,7 +40,7 @@ import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfPage;

class PageAttributesConverter {

private static Logger log = new ConsoleLogger();
private static Log log = new SimpleLog("FOP/RTF");

/** convert xsl:fo attributes to RTF text attributes */
static RtfAttributes convertPageAttributes(SimplePageMaster pagemaster) {

+ 3
- 3
src/java/org/apache/fop/render/rtf/RTFHandler.java Bestand weergeven

@@ -24,8 +24,8 @@ import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.Iterator;

import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.impl.SimpleLog;
import org.apache.commons.logging.Log;
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.FOInputHandler;
import org.apache.fop.fo.FObj;
@@ -98,7 +98,7 @@ public class RTFHandler extends FOInputHandler {

private RtfFile rtfFile;
private final OutputStream os;
private final Logger log = new ConsoleLogger();
private final Log log = new SimpleLog("FOP/RTF");
private RtfSection sect;
private RtfDocumentArea docArea;
private int iNestCount;

+ 3
- 3
src/java/org/apache/fop/render/rtf/TableAttributesConverter.java Bestand weergeven

@@ -22,8 +22,8 @@ package org.apache.fop.render.rtf;
import org.apache.fop.render.rtf.rtflib.rtfdoc.BorderAttributesConverter;

//FOP
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.impl.SimpleLog;
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.expr.NCnameProperty;
import org.apache.fop.fo.properties.ColorTypeProperty;
@@ -57,7 +57,7 @@ import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfColorTable;

public class TableAttributesConverter {

private static Logger log = new ConsoleLogger();
private static Log log = new SimpleLog("FOP/RTF");

//////////////////////////////////////////////////
// @@ Construction

+ 3
- 3
src/java/org/apache/fop/render/rtf/TableContext.java Bestand weergeven

@@ -20,8 +20,8 @@ package org.apache.fop.render.rtf;

import java.util.List;

import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.impl.SimpleLog;
import org.apache.commons.logging.Log;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAttributes;
import org.apache.fop.render.rtf.rtflib.interfaces.ITableColumnsInfo;

@@ -39,7 +39,7 @@ import org.apache.fop.render.rtf.rtflib.interfaces.ITableColumnsInfo;
*/

class TableContext implements ITableColumnsInfo {
private final Logger log = new ConsoleLogger();
private final Log log = new SimpleLog("FOP/RTF");
private final BuilderContext context;
private final List colWidths = new java.util.ArrayList();
private int colIndex;

+ 3
- 3
src/java/org/apache/fop/render/rtf/TextAttributesConverter.java Bestand weergeven

@@ -20,8 +20,8 @@
package org.apache.fop.render.rtf;

//FOP
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.impl.SimpleLog;
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.PropertyList;
@@ -49,7 +49,7 @@ import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfText;
*/

class TextAttributesConverter {
private static Logger log = new ConsoleLogger();
private static Log log = new SimpleLog("FOP/RTF");

/**
* Converts all known text FO properties to RtfAttributes

+ 10
- 7
src/java/org/apache/fop/servlet/FopPrintServlet.java Bestand weergeven

@@ -28,8 +28,8 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.transform.TransformerFactory;

import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.impl.SimpleLog;
import org.apache.commons.logging.Log;
import org.apache.fop.apps.Driver;
import org.apache.fop.apps.XSLTInputHandler;
import org.apache.fop.render.awt.AWTPrintRenderer;
@@ -69,7 +69,8 @@ public class FopPrintServlet extends HttpServlet {
protected static final String XSLT_REQUEST_PARAM = "xslt";

/** Logger to give to FOP */
protected Logger log = null;
protected SimpleLog log = null;
/** The TransformerFactory to use to create Transformer instances */
protected TransformerFactory transFactory = null;

@@ -77,7 +78,8 @@ public class FopPrintServlet extends HttpServlet {
* @see javax.servlet.GenericServlet#init()
*/
public void init() throws ServletException {
this.log = new ConsoleLogger(ConsoleLogger.LEVEL_WARN);
this.log = new SimpleLog("FOP/Print Servlet");
log.setLevel(SimpleLog.LOG_LEVEL_WARN);
this.transFactory = TransformerFactory.newInstance();
}

@@ -87,7 +89,8 @@ public class FopPrintServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException {
if (log == null) {
log = new ConsoleLogger(ConsoleLogger.LEVEL_WARN);
log = new SimpleLog("FOP/Print Servlet");
log.setLevel(SimpleLog.LOG_LEVEL_WARN);
}

try {
@@ -131,7 +134,7 @@ public class FopPrintServlet extends HttpServlet {
Driver driver = new Driver(foFile, null);
AWTPrintRenderer renderer = new AWTPrintRenderer();

driver.enableLogging(log);
driver.setLogger(log);
driver.setRenderer(renderer);
driver.run();

@@ -153,7 +156,7 @@ public class FopPrintServlet extends HttpServlet {
Driver driver = new Driver();
AWTPrintRenderer renderer = new AWTPrintRenderer();

driver.enableLogging(log);
driver.setLogger(log);
driver.setRenderer(renderer);
driver.render(input.getParser(), input.getInputSource());


+ 6
- 6
src/java/org/apache/fop/servlet/FopServlet.java Bestand weergeven

@@ -34,9 +34,8 @@ import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.stream.StreamSource;

// Avalon
import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.impl.SimpleLog;
import org.apache.commons.logging.Log;

//FOP
import org.apache.fop.apps.Driver;
@@ -76,7 +75,7 @@ public class FopServlet extends HttpServlet {
protected static final String XSLT_REQUEST_PARAM = "xslt";

/** Logger to give to FOP */
protected Logger log = null;
protected SimpleLog log = null;
/** The TransformerFactory to use to create Transformer instances */
protected TransformerFactory transFactory = null;

@@ -84,7 +83,8 @@ public class FopServlet extends HttpServlet {
* @see javax.servlet.GenericServlet#init()
*/
public void init() throws ServletException {
this.log = new ConsoleLogger(ConsoleLogger.LEVEL_WARN);
this.log = new SimpleLog("FOP/Servlet");
log.setLevel(SimpleLog.LOG_LEVEL_WARN);
this.transFactory = TransformerFactory.newInstance();
}

@@ -202,7 +202,7 @@ public class FopServlet extends HttpServlet {

//Setup FOP
Driver driver = new Driver();
driver.enableLogging(this.log);
driver.setLogger(this.log);
driver.setRenderer(Driver.RENDER_PDF);
driver.initialize();


+ 10
- 13
src/java/org/apache/fop/svg/AbstractFOPTranscoder.java Bestand weergeven

@@ -20,9 +20,8 @@ package org.apache.fop.svg;

import org.xml.sax.EntityResolver;

import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.avalon.framework.logger.LogEnabled;
import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.impl.SimpleLog;
import org.apache.commons.logging.Log;
import org.apache.batik.bridge.UserAgent;
import org.apache.batik.dom.svg.SVGDOMImplementation;
import org.apache.batik.dom.util.DocumentFactory;
@@ -39,7 +38,7 @@ import org.w3c.dom.DOMImplementation;
* This is the common base class of all of FOP's transcoders.
*/
public abstract class AbstractFOPTranscoder extends SVGAbstractTranscoder
implements LogEnabled {
{

/**
* The key to specify whether to stroke text instead of using text
@@ -58,7 +57,7 @@ public abstract class AbstractFOPTranscoder extends SVGAbstractTranscoder
*/
protected UserAgent userAgent = createUserAgent();

private Logger logger;
private Log logger;
private EntityResolver resolver;

/**
@@ -81,10 +80,7 @@ public abstract class AbstractFOPTranscoder extends SVGAbstractTranscoder
return new FOPTranscoderUserAgent();
}
/**
* @see org.apache.avalon.framework.logger.LogEnabled#enableLogging(Logger)
*/
public void enableLogging(Logger logger) {
public void setLogger(Log logger) {
this.logger = logger;
}

@@ -98,12 +94,13 @@ public abstract class AbstractFOPTranscoder extends SVGAbstractTranscoder
/**
* Returns the logger associated with this transcoder. It returns a
* ConsoleLogger if no logger has been explicitly set.
* SimpleLog if no logger has been explicitly set.
* @return Logger the logger for the transcoder.
*/
protected final Logger getLogger() {
protected final Log getLogger() {
if (this.logger == null) {
this.logger = new ConsoleLogger(ConsoleLogger.LEVEL_INFO);
this.logger = new SimpleLog("FOP/Transcoder");
((SimpleLog) logger).setLevel(SimpleLog.LOG_LEVEL_INFO);
}
return this.logger;
}
@@ -133,7 +130,7 @@ public abstract class AbstractFOPTranscoder extends SVGAbstractTranscoder

/**
* This is the default transcoder error handler for FOP. It logs error
* to an Avalon Logger instead of to System.out. The remaining behaviour
* to an Commons Logger instead of to System.out. The remaining behaviour
* is the same as Batik's DefaultErrorHandler.
*/
protected class FOPErrorHandler implements ErrorHandler {

+ 12
- 13
src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java Bestand weergeven

@@ -34,9 +34,8 @@ import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.container.ContainerUtil;
import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.avalon.framework.logger.LogEnabled;
import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.impl.SimpleLog;
import org.apache.commons.logging.Log;
import org.apache.fop.apps.Document;

import java.awt.Graphics;
@@ -60,7 +59,7 @@ import java.util.List;
* @see org.apache.fop.svg.PDFGraphics2D
*/
public class PDFDocumentGraphics2D extends PDFGraphics2D
implements LogEnabled, Configurable, Initializable {
implements Configurable, Initializable {

private PDFPage currentPage;
private PDFStream pdfStream;
@@ -68,8 +67,9 @@ public class PDFDocumentGraphics2D extends PDFGraphics2D
private int height;
private List fontList;

//Avalon-dependent stuff
private Logger logger;
private Log logger;

//Avalon component
private Configuration cfg;

/**
@@ -132,10 +132,7 @@ public class PDFDocumentGraphics2D extends PDFGraphics2D
super(false);
}

/**
* @see org.apache.avalon.framework.logger.LogEnabled#enableLogging(Logger)
*/
public void enableLogging(Logger logger) {
public void setLogger(Log logger) {
this.logger = logger;
}

@@ -143,9 +140,10 @@ public class PDFDocumentGraphics2D extends PDFGraphics2D
* Returns the logger.
* @return Logger the logger
*/
protected final Logger getLogger() {
protected final Log getLogger() {
if (this.logger == null) {
this.logger = new ConsoleLogger(ConsoleLogger.LEVEL_INFO);
this.logger = new SimpleLog("FOP/PDF");
((SimpleLog) logger).setLevel(SimpleLog.LOG_LEVEL_INFO);
}
return this.logger;
}
@@ -170,7 +168,8 @@ public class PDFDocumentGraphics2D extends PDFGraphics2D
}

this.pdfDoc = new PDFDocument("Apache FOP: SVG to PDF Transcoder");
ContainerUtil.enableLogging(this.pdfDoc, getLogger().getChildLogger("pdf"));
this.pdfDoc.setLogger(getLogger());

if (this.cfg != null) {
this.pdfDoc.setFilterMap(
PDFFilterList.buildFilterMapFromConfiguration(cfg));

+ 3
- 2
src/java/org/apache/fop/svg/PDFImageElementBridge.java Bestand weergeven

@@ -30,7 +30,7 @@ import java.awt.geom.Rectangle2D;

import org.w3c.dom.Element;

import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.commons.logging.impl.SimpleLog;
import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.gvt.AbstractGraphicsNode;
import org.apache.batik.gvt.GraphicsNode;
@@ -66,7 +66,8 @@ public class PDFImageElementBridge extends SVGImageElementBridge {
(purl.toString(), purl.openStream(), null);
if (ii.mimeType.toLowerCase() == "image/jpeg") {
JpegImage jpeg = new JpegImage(ii);
ConsoleLogger logger = new ConsoleLogger(ConsoleLogger.LEVEL_INFO);
SimpleLog logger = new SimpleLog("FOP/SVG");
logger.setLevel(SimpleLog.LOG_LEVEL_INFO);
jpeg.load(FopImage.ORIGINAL_DATA, logger);
PDFJpegNode node = new PDFJpegNode(jpeg, origGN);


+ 2
- 1
src/java/org/apache/fop/svg/PDFTranscoder.java Bestand weergeven

@@ -108,7 +108,8 @@ public class PDFTranscoder extends AbstractFOPTranscoder
throws TranscoderException {

graphics = new PDFDocumentGraphics2D();
ContainerUtil.enableLogging(graphics, getLogger());
graphics.setLogger(getLogger());
try {
if (this.cfg != null) {
ContainerUtil.configure(graphics, this.cfg);

+ 5
- 5
src/java/org/apache/fop/svg/SVGUserAgent.java Bestand weergeven

@@ -20,7 +20,7 @@ package org.apache.fop.svg;

import org.apache.fop.apps.FOFileHandler;
import org.apache.batik.bridge.UserAgentAdapter;
import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.Log;

// Java
import java.awt.geom.AffineTransform;
@@ -34,17 +34,17 @@ import java.awt.Dimension;
*/
public class SVGUserAgent extends UserAgentAdapter {
private AffineTransform currentTransform = null;
private Logger logger;
private Log logger;
private float pixelUnitToMillimeter = 0.0f;

/**
* Creates a new SVGUserAgent.
* @param log an Avalon logging instance
* @param log an Commons logging instance
* @param pixelUnitToMM The pixel to millimeter conversion factor
* currently in effect
* @param at the current transform
*/
public SVGUserAgent(Logger log, float pixelUnitToMM, AffineTransform at) {
public SVGUserAgent(Log log, float pixelUnitToMM, AffineTransform at) {
logger = log;
pixelUnitToMillimeter = pixelUnitToMM;
currentTransform = at;
@@ -54,7 +54,7 @@ public class SVGUserAgent extends UserAgentAdapter {
* Returns the logger associated with this user agent.
* @return Logger the logger
*/
protected final Logger getLogger() {
protected final Log getLogger() {
return logger;
}


+ 46
- 14
src/java/org/apache/fop/tools/AreaTreeBuilder.java Bestand weergeven

@@ -79,9 +79,8 @@ import org.apache.fop.fo.Constants;
import org.apache.fop.fo.pagination.Region;
import org.apache.fop.fonts.FontMetrics;

// Avalon
import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.impl.SimpleLog;


/**
@@ -96,7 +95,28 @@ import org.apache.avalon.framework.logger.AbstractLogEnabled;
* Tests: different renderers, saving and loading pages with serialization
* out of order rendering
*/
public class AreaTreeBuilder extends AbstractLogEnabled {
public class AreaTreeBuilder {

/**
* logging instance
*/
protected Log logger = null;

/**
* Sets the Commons-Logging instance for this class
* @param logger The Commons-Logging instance
*/
public void setLogger(Log logger) {
this.logger = logger;
}

/**
* Returns the Commons-Logging instance for this class
* @return The Commons-Logging instance
*/
protected Log getLogger() {
return logger;
}

/**
* Main method
@@ -104,7 +124,9 @@ public class AreaTreeBuilder extends AbstractLogEnabled {
*/
public static void main(String[] args) {
AreaTreeBuilder atb = new AreaTreeBuilder();
atb.enableLogging(new ConsoleLogger(ConsoleLogger.LEVEL_DEBUG));
SimpleLog logger = new SimpleLog("FOP");
logger.setLevel(SimpleLog.LOG_LEVEL_DEBUG);
atb.setLogger(logger);

atb.runTests(args[0], args[1], args[2]);
System.exit(0);
@@ -117,9 +139,9 @@ public class AreaTreeBuilder extends AbstractLogEnabled {
* @param out output filename
*/
protected void runTests(String in, String type, String out) {
getLogger().debug("Starting tests");
logger.debug("Starting tests");
runTest(in, type, out);
getLogger().debug("Finished");
logger.debug("Finished");
}

/**
@@ -137,16 +159,17 @@ public class AreaTreeBuilder extends AbstractLogEnabled {
} else if ("svg".equals(type)) {
rend = new SVGRenderer();
}
setupLogger(rend);

rend.setLogger(logger);
Document fi = new Document(null);
rend.setupFontInfo(fi);
FOUserAgent ua = new FOUserAgent();
setupLogger(ua);
ua.setLogger(logger);
rend.setUserAgent(ua);

StorePagesModel sm = AreaTree.createStorePagesModel();
TreeLoader tl = new TreeLoader(fi);
setupLogger(tl);
tl.setLogger(logger);
tl.setTreeModel(sm);
try {
InputStream is =
@@ -154,7 +177,7 @@ public class AreaTreeBuilder extends AbstractLogEnabled {
tl.buildAreaTree(is);
renderAreaTree(sm, rend, out);
} catch (IOException e) {
getLogger().error("error reading file" + e.getMessage(), e);
logger.error("error reading file" + e.getMessage(), e);
}
}

@@ -205,7 +228,7 @@ public class AreaTreeBuilder extends AbstractLogEnabled {
rend.stopRenderer();
os.close();
} catch (Exception e) {
getLogger().error("error rendering output", e);
logger.error("error rendering output", e);
}
}

@@ -214,16 +237,25 @@ public class AreaTreeBuilder extends AbstractLogEnabled {

// this loads an area tree from an xml file
// the xml format is the same as the xml renderer output
class TreeLoader extends AbstractLogEnabled {
class TreeLoader {
private AreaTree areaTree;
private AreaTreeModel model;
private Document fontInfo;
private Font currentFontState;
private Log logger = null;

TreeLoader(Document fi) {
fontInfo = fi;
}

/**
* Sets the Commons-Logging instance for this class
* @param logger The Commons-Logging instance
*/
public void setLogger(Log logger) {
this.logger = logger;
}

public void setTreeModel(AreaTreeModel mo) {
model = mo;
}
@@ -720,7 +752,7 @@ class TreeLoader extends AbstractLogEnabled {
Trait.makeTraitValue(traitCode,
tok.substring(index + 1)));
} else {
getLogger().error("Unknown trait: " + id);
logger.error("Unknown trait: " + id);
}
}
}

+ 42
- 14
src/java/org/apache/fop/tools/TestConverter.java Bestand weergeven

@@ -26,8 +26,6 @@ import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.fop.apps.Driver;
import org.apache.fop.apps.FOFileHandler;
import org.apache.fop.apps.FOUserAgent;
@@ -37,6 +35,10 @@ import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.impl.SimpleLog;


/**
* TestConverter is used to process a set of tests specified in
* a testsuite.
@@ -50,7 +52,7 @@ import org.w3c.dom.NodeList;
* Modified by Mark Lillywhite mark-fop@inomial.com to use the new Driver
* interface.
*/
public class TestConverter extends AbstractLogEnabled {
public class TestConverter {
private boolean failOnly = false;
private boolean outputPDF = false;
@@ -59,6 +61,28 @@ public class TestConverter extends AbstractLogEnabled {
private String baseDir = "./";
private Map differ = new java.util.HashMap();

/**
* logging instance
*/
protected Log logger = null;


/**
* Sets the Commons-Logging instance for this class
* @param logger The Commons-Logging instance
*/
public void setLogger(Log logger) {
this.logger = logger;
}

/**
* Returns the Commons-Logging instance for this class
* @return The Commons-Logging instance
*/
protected Log getLogger() {
return logger;
}

/**
* This main method can be used to run the test converter from
* the command line.
@@ -104,7 +128,9 @@ public class TestConverter extends AbstractLogEnabled {
* Construct a new TestConverter
*/
public TestConverter() {
enableLogging(new ConsoleLogger(ConsoleLogger.LEVEL_ERROR));
SimpleLog log = new SimpleLog("FOP/Test");
log.setLevel(SimpleLog.LOG_LEVEL_ERROR);
setLogger(log);
}

/**
@@ -138,7 +164,9 @@ public class TestConverter extends AbstractLogEnabled {
*/
public void setDebug(boolean debug) {
if (debug) {
enableLogging(new ConsoleLogger(ConsoleLogger.LEVEL_DEBUG));
SimpleLog log = new SimpleLog("FOP/Test");
log.setLevel(SimpleLog.LOG_LEVEL_DEBUG);
setLogger(log);
}
}

@@ -152,7 +180,7 @@ public class TestConverter extends AbstractLogEnabled {
* @return Map a Map containing differences
*/
public Map runTests(String fname, String dest, String compDir) {
getLogger().debug("running tests in file:" + fname);
logger.debug("running tests in file:" + fname);
try {
if (compDir != null) {
compare = new File(baseDir + "/" + compDir);
@@ -176,7 +204,7 @@ public class TestConverter extends AbstractLogEnabled {
if (testsuite.hasAttributes()) {
String profile =
testsuite.getAttributes().getNamedItem("profile").getNodeValue();
getLogger().debug("testing test suite:" + profile);
logger.debug("testing test suite:" + profile);
}

NodeList testcases = testsuite.getChildNodes();
@@ -187,7 +215,7 @@ public class TestConverter extends AbstractLogEnabled {
}
}
} catch (Exception e) {
getLogger().error("Error while running tests", e);
logger.error("Error while running tests", e);
}
return differ;
}
@@ -203,7 +231,7 @@ public class TestConverter extends AbstractLogEnabled {
if (tcase.hasAttributes()) {
String profile =
tcase.getAttributes().getNamedItem("profile").getNodeValue();
getLogger().debug("testing profile:" + profile);
logger.debug("testing profile:" + profile);
}

NodeList cases = tcase.getChildNodes();
@@ -251,7 +279,7 @@ public class TestConverter extends AbstractLogEnabled {
if (xslNode != null) {
xsl = xslNode.getNodeValue();
}
getLogger().debug("converting xml:" + xml + " and xsl:"
logger.debug("converting xml:" + xml + " and xsl:"
+ xsl + " to area tree");

String res = xml;
@@ -265,7 +293,7 @@ public class TestConverter extends AbstractLogEnabled {
try {
baseURL = xmlFile.getParentFile().toURL().toExternalForm();
} catch (Exception e) {
getLogger().error("Error setting base directory");
logger.error("Error setting base directory");
}

InputHandler inputHandler = null;
@@ -279,7 +307,7 @@ public class TestConverter extends AbstractLogEnabled {

Driver driver = new Driver();
FOUserAgent userAgent = new FOUserAgent();
setupLogger(userAgent, "fop");
userAgent.setLogger(getLogger());
userAgent.setBaseURL(baseURL);
driver.setUserAgent(userAgent);
if (outputPDF) {
@@ -305,7 +333,7 @@ public class TestConverter extends AbstractLogEnabled {
OutputStream outStream = new java.io.BufferedOutputStream(
new java.io.FileOutputStream(outputFile));
driver.setOutputStream(outStream);
getLogger().debug("ddir:" + destdir + " on:" +
logger.debug("ddir:" + destdir + " on:" +
outputFile.getName());
driver.render(inputHandler);
outStream.close();
@@ -348,7 +376,7 @@ public class TestConverter extends AbstractLogEnabled {
}
}
} catch (Exception e) {
getLogger().error("Error while comparing files", e);
logger.error("Error while comparing files", e);
}

return false;

+ 39
- 18
src/java/org/apache/fop/tools/anttasks/Fop.java Bestand weergeven

@@ -40,10 +40,8 @@ import org.apache.fop.apps.Driver;
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;

// Avalon
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.impl.SimpleLog;
import org.apache.commons.logging.Log;

/**
* Wrapper for FOP which allows it to be accessed from within an Ant task.
@@ -279,18 +277,19 @@ public class Fop extends Task {
* @see org.apache.tools.ant.Task#execute()
*/
public void execute() throws BuildException {
int logLevel = ConsoleLogger.LEVEL_INFO;
int logLevel = SimpleLog.LOG_LEVEL_INFO;
switch (getMessageType()) {
case Project.MSG_DEBUG : logLevel = ConsoleLogger.LEVEL_DEBUG; break;
case Project.MSG_INFO : logLevel = ConsoleLogger.LEVEL_INFO; break;
case Project.MSG_WARN : logLevel = ConsoleLogger.LEVEL_WARN; break;
case Project.MSG_ERR : logLevel = ConsoleLogger.LEVEL_ERROR; break;
case Project.MSG_VERBOSE: logLevel = ConsoleLogger.LEVEL_DEBUG; break;
case Project.MSG_DEBUG : logLevel = SimpleLog.LOG_LEVEL_DEBUG; break;
case Project.MSG_INFO : logLevel = SimpleLog.LOG_LEVEL_INFO; break;
case Project.MSG_WARN : logLevel = SimpleLog.LOG_LEVEL_WARN; break;
case Project.MSG_ERR : logLevel = SimpleLog.LOG_LEVEL_ERROR; break;
case Project.MSG_VERBOSE: logLevel = SimpleLog.LOG_LEVEL_DEBUG; break;
}
Logger log = new ConsoleLogger(logLevel);
SimpleLog logger = new SimpleLog("FOP/Anttask");
logger.setLevel(logLevel);
try {
FOPTaskStarter starter = new FOPTaskStarter(this);
starter.enableLogging(log);
starter.setLogger(logger);
starter.run();
} catch (FOPException ex) {
throw new BuildException(ex);
@@ -300,11 +299,33 @@ public class Fop extends Task {

}

class FOPTaskStarter extends AbstractLogEnabled {
class FOPTaskStarter {

private Fop task;
private String baseURL = null;

/**
* logging instance
*/
protected Log logger = null;


/**
* Sets the Commons-Logging instance for this class
* @param logger The Commons-Logging instance
*/
public void setLogger(Log logger) {
this.logger = logger;
}

/**
* Returns the Commons-Logging instance for this class
* @return The Commons-Logging instance
*/
protected Log getLogger() {
return logger;
}

FOPTaskStarter(Fop task) throws FOPException {
this.task = task;
}
@@ -386,7 +407,7 @@ class FOPTaskStarter extends AbstractLogEnabled {
try {
this.baseURL = task.getBasedir().toURL().toExternalForm();
} catch (MalformedURLException mfue) {
getLogger().error("Error creating base URL from base directory", mfue);
logger.error("Error creating base URL from base directory", mfue);
}
} else {
try {
@@ -395,7 +416,7 @@ class FOPTaskStarter extends AbstractLogEnabled {
toExternalForm();
}
} catch (MalformedURLException mfue) {
getLogger().error("Error creating base URL from XSL-FO input file", mfue);
logger.error("Error creating base URL from XSL-FO input file", mfue);
}
}

@@ -511,10 +532,10 @@ class FOPTaskStarter extends AbstractLogEnabled {

try {
Driver driver = new Driver();
setupLogger(driver);
driver.setLogger(getLogger());
FOUserAgent userAgent = new FOUserAgent();
userAgent.setBaseURL(this.baseURL);
userAgent.enableLogging(getLogger());
userAgent.setLogger(getLogger());
driver.setUserAgent(userAgent);
driver.setRenderer(renderer);
driver.setOutputStream(out);
@@ -525,7 +546,7 @@ class FOPTaskStarter extends AbstractLogEnabled {
try {
out.close();
} catch (IOException ioe) {
getLogger().error("Error closing output file", ioe);
logger.error("Error closing output file", ioe);
}
}
}

Laden…
Annuleren
Opslaan