aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2004-04-02 09:15:16 +0000
committerJeremias Maerki <jeremias@apache.org>2004-04-02 09:15:16 +0000
commit59019477e8e889b07db387c538570d93c355f1b8 (patch)
treea4e3c480a33d78a40746036de25763a2112e56f9 /src/java/org/apache
parentee49a2515ca927e7f51e4f3e0efb773d945e2acc (diff)
downloadxmlgraphics-fop-59019477e8e889b07db387c538570d93c355f1b8.tar.gz
xmlgraphics-fop-59019477e8e889b07db387c538570d93c355f1b8.zip
Changed logging to use "static" loggers from Jakarta Commons Logging (via LogFactory).
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197479 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache')
-rw-r--r--src/java/org/apache/fop/fonts/truetype/TTFFile.java148
-rw-r--r--src/java/org/apache/fop/fonts/type1/PFMFile.java34
-rw-r--r--src/java/org/apache/fop/pdf/PDFDocument.java24
-rw-r--r--src/java/org/apache/fop/pdf/PDFEncryptionJCE.java16
-rw-r--r--src/java/org/apache/fop/pdf/PDFFactory.java12
-rw-r--r--src/java/org/apache/fop/pdf/PDFInfo.java4
-rw-r--r--src/java/org/apache/fop/pdf/PDFObject.java9
-rw-r--r--src/java/org/apache/fop/pdf/PDFOutline.java6
-rw-r--r--src/java/org/apache/fop/pdf/PDFT1Stream.java5
-rw-r--r--src/java/org/apache/fop/pdf/PDFTTFStream.java5
10 files changed, 97 insertions, 166 deletions
diff --git a/src/java/org/apache/fop/fonts/truetype/TTFFile.java b/src/java/org/apache/fop/fonts/truetype/TTFFile.java
index fc4df27fb..b5f20cfb6 100644
--- a/src/java/org/apache/fop/fonts/truetype/TTFFile.java
+++ b/src/java/org/apache/fop/fonts/truetype/TTFFile.java
@@ -23,8 +23,8 @@ import java.util.Iterator;
import java.util.Map;
import java.util.List;
-import org.apache.commons.logging.impl.SimpleLog;
import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.fop.fonts.Glyphs;
/**
@@ -70,7 +70,7 @@ public class TTFFile {
/**
* Contains glyph data
*/
- protected TTFMtxEntry mtxTab[]; // Contains glyph data
+ protected TTFMtxEntry[] mtxTab; // Contains glyph data
private int[] mtxEncoded = null;
private String fontName = "";
@@ -94,7 +94,7 @@ public class TTFFile {
private short lastChar = 0;
- private int ansiWidth[];
+ private int[] ansiWidth;
private Map ansiIndex;
private TTFDirTabEntry currentDirTab;
@@ -102,23 +102,7 @@ public class TTFFile {
/**
* 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;
- }
+ protected Log log = LogFactory.getLog(TTFFile.class);
/**
* Position inputstream to position indicated
@@ -128,9 +112,7 @@ public class TTFFile {
long offset) throws IOException {
TTFDirTabEntry dt = (TTFDirTabEntry)dirTabs.get(name);
if (dt == null) {
- if (logger != null) {
- logger.error("Dirtab " + name + " not found.");
- }
+ log.error("Dirtab " + name + " not found.");
} else {
in.seekSet(dt.getOffset() + offset);
this.currentDirTab = dt;
@@ -175,9 +157,7 @@ public class TTFFile {
int numCMap = in.readTTFUShort(); // Number of cmap subtables
long cmapUniOffset = 0;
- if (logger != null) {
- logger.info(numCMap + " cmap tables");
- }
+ log.info(numCMap + " cmap tables");
//Read offset for all tables. We are only interested in the unicode table
for (int i = 0; i < numCMap; i++) {
@@ -185,10 +165,7 @@ public class TTFFile {
int cmapEID = in.readTTFUShort();
long cmapOffset = in.readTTFULong();
- if (logger != null) {
- logger.debug("Platform ID: " + cmapPID
- + " Encoding: " + cmapEID);
- }
+ log.debug("Platform ID: " + cmapPID + " Encoding: " + cmapEID);
if (cmapPID == 3 && cmapEID == 1) {
cmapUniOffset = cmapOffset;
@@ -196,10 +173,8 @@ public class TTFFile {
}
if (cmapUniOffset <= 0) {
- if (logger != null) {
- logger.fatal("Unicode cmap table not present");
- logger.fatal("Unsupported format: Aborting");
- }
+ log.fatal("Unicode cmap table not present");
+ log.fatal("Unsupported format: Aborting");
return false;
}
@@ -208,9 +183,7 @@ public class TTFFile {
int cmapFormat = in.readTTFUShort();
/*int cmap_length =*/ in.readTTFUShort(); //skip cmap length
- if (logger != null) {
- logger.info("CMAP format: " + cmapFormat);
- }
+ log.info("CMAP format: " + cmapFormat);
if (cmapFormat == 4) {
in.skip(2); // Skip version number
@@ -219,18 +192,18 @@ public class TTFFile {
int cmapEntrySelector = in.readTTFUShort();
int cmapRangeShift = in.readTTFUShort();
- if (logger != null & logger.isDebugEnabled()) {
- logger.debug("segCountX2 : " + cmapSegCountX2);
- logger.debug("searchRange : " + cmapSearchRange);
- logger.debug("entrySelector: " + cmapEntrySelector);
- logger.debug("rangeShift : " + cmapRangeShift);
+ if (log.isDebugEnabled()) {
+ log.debug("segCountX2 : " + cmapSegCountX2);
+ log.debug("searchRange : " + cmapSearchRange);
+ log.debug("entrySelector: " + cmapEntrySelector);
+ log.debug("rangeShift : " + cmapRangeShift);
}
- int cmapEndCounts[] = new int[cmapSegCountX2 / 2];
- int cmapStartCounts[] = new int[cmapSegCountX2 / 2];
- int cmapDeltas[] = new int[cmapSegCountX2 / 2];
- int cmapRangeOffsets[] = new int[cmapSegCountX2 / 2];
+ int[] cmapEndCounts = new int[cmapSegCountX2 / 2];
+ int[] cmapStartCounts = new int[cmapSegCountX2 / 2];
+ int[] cmapDeltas = new int[cmapSegCountX2 / 2];
+ int[] cmapRangeOffsets = new int[cmapSegCountX2 / 2];
for (int i = 0; i < (cmapSegCountX2 / 2); i++) {
cmapEndCounts[i] = in.readTTFUShort();
@@ -259,10 +232,8 @@ public class TTFFile {
for (int i = 0; i < cmapStartCounts.length; i++) {
- if (logger != null) {
- logger.debug(i + ": " + cmapStartCounts[i]
- + " - " + cmapEndCounts[i]);
- }
+ log.debug(i + ": " + cmapStartCounts[i]
+ + " - " + cmapEndCounts[i]);
for (int j = cmapStartCounts[i]; j <= cmapEndCounts[i]; j++) {
@@ -295,47 +266,39 @@ public class TTFFile {
Iterator e = v.listIterator();
while (e.hasNext()) {
Integer aIdx = (Integer)e.next();
- ansiWidth[aIdx.intValue()] =
- mtxTab[glyphIdx].getWx();
+ ansiWidth[aIdx.intValue()]
+ = mtxTab[glyphIdx].getWx();
- if (logger != null) {
- logger.debug("Added width "
+ log.debug("Added width "
+ mtxTab[glyphIdx].getWx()
+ " uni: " + j
+ " ansi: " + aIdx.intValue());
- }
}
}
- if (logger != null) {
- logger.debug("Idx: "
+ log.debug("Idx: "
+ glyphIdx
+ " Delta: " + cmapDeltas[i]
+ " Unicode: " + j
+ " name: " + mtxTab[glyphIdx].getName());
- }
} else {
glyphIdx = (j + cmapDeltas[i]) & 0xffff;
if (glyphIdx < mtxTab.length) {
mtxTab[glyphIdx].getUnicodeIndex().add(new Integer(j));
} else {
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("Glyph " + glyphIdx
+ log.debug("Glyph " + glyphIdx
+ " out of range: "
+ mtxTab.length);
- }
}
unicodeMapping.add(new UnicodeMapping(glyphIdx, j));
if (glyphIdx < mtxTab.length) {
mtxTab[glyphIdx].getUnicodeIndex().add(new Integer(j));
} else {
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("Glyph " + glyphIdx
+ log.debug("Glyph " + glyphIdx
+ " out of range: "
+ mtxTab.length);
- }
}
// Also add winAnsiWidth
@@ -382,8 +345,8 @@ public class TTFFile {
max = mtxTab[i].getIndex();
}
}
- getLogger().info("Min: " + min);
- getLogger().info("Max: " + max);
+ log.info("Min: " + min);
+ log.info("Max: " + max);
}
@@ -455,7 +418,7 @@ public class TTFFile {
readDirTabs(in);
readFontHeader(in);
getNumGlyphs(in);
- getLogger().info("Number of glyphs in font: " + numberOfGlyphs);
+ log.info("Number of glyphs in font: " + numberOfGlyphs);
readHorizontalHeader(in);
readHorizontalMetrics(in);
initAnsiWidths();
@@ -711,7 +674,7 @@ public class TTFFile {
dirTabs = new java.util.HashMap();
TTFDirTabEntry[] pd = new TTFDirTabEntry[ntabs];
- getLogger().debug("Reading " + ntabs + " dir tables");
+ log.debug("Reading " + ntabs + " dir tables");
for (int i = 0; i < ntabs; i++) {
pd[i] = new TTFDirTabEntry();
dirTabs.put(pd[i].read(in), pd[i]);
@@ -766,7 +729,7 @@ public class TTFFile {
in.skip(2 + 2 + 3 * 2 + 8 * 2);
nhmtx = in.readTTFUShort();
- getLogger().debug("Number of horizontal metrics: " + nhmtx);
+ log.debug("Number of horizontal metrics: " + nhmtx);
//Check OS/2 table for ascender/descender if necessary
if (ascender == 0 || descender == 0) {
@@ -795,7 +758,7 @@ public class TTFFile {
mtxTab = new TTFMtxEntry[mtxSize];
if (TRACE_ENABLED) {
- getLogger().debug("*** Widths array: \n");
+ log.debug("*** Widths array: \n");
}
for (int i = 0; i < mtxSize; i++) {
mtxTab[i] = new TTFMtxEntry();
@@ -805,8 +768,8 @@ public class TTFFile {
mtxTab[i].setLsb(in.readTTFUShort());
if (TRACE_ENABLED) {
- if (getLogger().isDebugEnabled()) {
- getLogger().debug(" width[" + i + "] = "
+ if (log.isDebugEnabled()) {
+ log.debug(" width[" + i + "] = "
+ convertTTFUnit2PDFUnit(mtxTab[i].getWx()) + ";");
}
}
@@ -838,16 +801,16 @@ public class TTFFile {
//Skip memory usage values
in.skip(4 * 4);
- getLogger().debug("PostScript format: " + postFormat);
+ log.debug("PostScript format: " + postFormat);
switch (postFormat) {
case 0x00010000:
- getLogger().debug("PostScript format 1");
+ log.debug("PostScript format 1");
for (int i = 0; i < Glyphs.MAC_GLYPH_NAMES.length; i++) {
mtxTab[i].setName(Glyphs.MAC_GLYPH_NAMES[i]);
}
break;
case 0x00020000:
- getLogger().debug("PostScript format 2");
+ log.debug("PostScript format 2");
int numGlyphStrings = 0;
// Read Number of Glyphs
@@ -862,15 +825,15 @@ public class TTFFile {
numGlyphStrings++;
}
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("PostScript index: " + mtxTab[i].getIndexAsString());
+ if (log.isDebugEnabled()) {
+ log.debug("PostScript index: " + mtxTab[i].getIndexAsString());
}
}
// firstChar=minIndex;
String[] psGlyphsBuffer = new String[numGlyphStrings];
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("Reading " + numGlyphStrings
+ if (log.isDebugEnabled()) {
+ log.debug("Reading " + numGlyphStrings
+ " glyphnames, that are not in the standard Macintosh"
+ " set. Total number of glyphs=" + l);
}
@@ -886,8 +849,8 @@ public class TTFFile {
if (!mtxTab[i].isIndexReserved()) {
int k = mtxTab[i].getIndex() - NMACGLYPHS;
- if (getLogger().isDebugEnabled()) {
- getLogger().debug(k + " i=" + i + " mtx=" + mtxTab.length
+ if (log.isDebugEnabled()) {
+ log.debug(k + " i=" + i + " mtx=" + mtxTab.length
+ " ps=" + psGlyphsBuffer.length);
}
@@ -899,10 +862,10 @@ public class TTFFile {
break;
case 0x00030000:
// PostScript format 3 contains no glyph names
- getLogger().debug("PostScript format 3");
+ log.debug("PostScript format 3");
break;
default:
- getLogger().error("Unknown PostScript format: " + postFormat);
+ log.error("Unknown PostScript format: " + postFormat);
}
}
@@ -987,7 +950,7 @@ public class TTFFile {
mtxTab[i].bbox[2] = mtxTab[0].bbox[0];
mtxTab[i].bbox[3] = mtxTab[0].bbox[0]; */
}
- getLogger().debug(mtxTab[i].toString(this));
+ log.debug(mtxTab[i].toString(this));
}
}
@@ -1019,7 +982,7 @@ public class TTFFile {
in.seekSet(j + in.readTTFUShort());
String txt = in.readTTFString(l);
- getLogger().debug(platformID + " "
+ log.debug(platformID + " "
+ encodingID + " "
+ languageID + " "
+ k + " " + txt);
@@ -1201,9 +1164,9 @@ public class TTFFile {
dirOffsets[i] = in.readTTFULong();
}
- getLogger().info("This is a TrueType collection file with "
+ log.info("This is a TrueType collection file with "
+ numDirectories + " fonts");
- getLogger().info("Containing the following fonts: ");
+ log.info("Containing the following fonts: ");
// Read all the directories and name tables to check
// If the font exists - this is a bit ugly, but...
boolean found = false;
@@ -1220,9 +1183,9 @@ public class TTFFile {
if (fullName.equals(name)) {
found = true;
dirTabOffset = dirOffsets[i];
- getLogger().info(fullName + " <-- selected");
+ log.info(fullName + " <-- selected");
} else {
- getLogger().info(fullName);
+ log.info(fullName);
}
// Reset names
@@ -1289,12 +1252,8 @@ public class TTFFile {
* @param args The command line arguments
*/
public static void main(String[] args) {
- SimpleLog log = new SimpleLog("FOP/Fonts");
- log.setLevel(SimpleLog.LOG_LEVEL_WARN);
-
try {
TTFFile ttfFile = new TTFFile();
- ttfFile.setLogger(log);
FontFileReader reader = new FontFileReader(args[0]);
@@ -1307,7 +1266,8 @@ public class TTFFile {
ttfFile.printStuff();
} catch (IOException ioe) {
- log.error("Problem reading font: " + ioe.toString(), ioe);
+ System.err.println("Problem reading font: " + ioe.toString());
+ ioe.printStackTrace(System.err);
}
}
diff --git a/src/java/org/apache/fop/fonts/type1/PFMFile.java b/src/java/org/apache/fop/fonts/type1/PFMFile.java
index f2cd1391c..515d0e9ea 100644
--- a/src/java/org/apache/fop/fonts/type1/PFMFile.java
+++ b/src/java/org/apache/fop/fonts/type1/PFMFile.java
@@ -25,6 +25,7 @@ import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
// FOP
@@ -65,24 +66,7 @@ public class PFMFile {
/**
* 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;
- }
+ protected Log log = LogFactory.getLog(PFMFile.class);
/**
* Parses a PFM file
@@ -97,7 +81,7 @@ public class PFMFile {
/*final int version =*/ in.readShort();
final long filesize = in.readInt();
if (filesize != buf.length) {
- logger.warn("Effective file size is not the same as indicated in the header.");
+ log.warn("Effective file size is not the same as indicated in the header.");
}
bufin.reset();
@@ -142,7 +126,7 @@ public class PFMFile {
private void loadExtension(PFMInputStream inStream) throws IOException {
final int size = inStream.readShort();
if (size != 30) {
- logger.warn("Size of extension block was expected to be "
+ log.warn("Size of extension block was expected to be "
+ "30 bytes, but was " + size + " bytes.");
}
final long extMetricsOffset = inStream.readInt();
@@ -184,7 +168,7 @@ public class PFMFile {
int i = inStream.readShort();
- logger.info(i + " kerning pairs");
+ log.info(i + " kerning pairs");
while (i > 0) {
int g1 = (int)inStream.readByte();
i--;
@@ -195,12 +179,12 @@ public class PFMFile {
if (adj > 0x8000) {
adj = -(0x10000 - adj);
}
- logger.debug("Char no: (" + g1 + ", " + g2 + ") kern: " + adj);
+ log.debug("Char no: (" + g1 + ", " + g2 + ") kern: " + adj);
- if (logger.isDebugEnabled()) {
+ if (log.isDebugEnabled()) {
final String glyph1 = Glyphs.TEX8R_GLYPH_NAMES[g1];
final String glyph2 = Glyphs.TEX8R_GLYPH_NAMES[g2];
- logger.debug("glyphs: " + glyph1 + ", " + glyph2);
+ log.debug("glyphs: " + glyph1 + ", " + glyph2);
}
Map adjTab = (Map)kerningTab.get(new Integer(g1));
@@ -220,7 +204,7 @@ public class PFMFile {
private void loadExtMetrics(PFMInputStream inStream) throws IOException {
final int size = inStream.readShort();
if (size != 52) {
- logger.warn("Size of extension block was expected to be "
+ log.warn("Size of extension block was expected to be "
+ "52 bytes, but was " + size + " bytes.");
}
inStream.skip(12); //Skip etmPointSize, etmOrientation, etmMasterHeight,
diff --git a/src/java/org/apache/fop/pdf/PDFDocument.java b/src/java/org/apache/fop/pdf/PDFDocument.java
index 9ac36e29d..12960d6c3 100644
--- a/src/java/org/apache/fop/pdf/PDFDocument.java
+++ b/src/java/org/apache/fop/pdf/PDFDocument.java
@@ -29,6 +29,7 @@ import java.util.Map;
import java.util.Iterator;
import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/* image support modified from work of BoBoGi */
/* font support based on work by Takayuki Takeuchi */
@@ -67,7 +68,7 @@ public class PDFDocument {
*/
public static final String ENCODING = "ISO-8859-1";
- private Log logger;
+ private Log log = LogFactory.getLog("org.apache.fop.pdf");
/**
* the current character position
@@ -234,14 +235,6 @@ public class PDFDocument {
}
/**
- * 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
*/
@@ -260,17 +253,6 @@ public class PDFDocument {
}
/**
- * Helper method to allow sub-classes to aquire logger.
- *
- * <p>There is no performance penalty as this is a final method
- * and will be inlined by the JVM.</p>
- * @return the Logger
- */
- protected final Log getLogger() {
- return this.logger;
- }
-
- /**
* Converts text to a byte array for writing to a PDF file.
* @param text text to convert/encode
* @return byte[] the resulting byte array
@@ -485,7 +467,7 @@ public class PDFDocument {
/**@todo this cast is ugly. PDFObject should be transformed to an interface. */
addTrailerObject((PDFObject)this.encryption);
} else {
- getLogger().warn(
+ log.warn(
"PDF encryption is unavailable. PDF will be "
+ "generated without encryption.");
}
diff --git a/src/java/org/apache/fop/pdf/PDFEncryptionJCE.java b/src/java/org/apache/fop/pdf/PDFEncryptionJCE.java
index 989fe6edf..66bf5dd45 100644
--- a/src/java/org/apache/fop/pdf/PDFEncryptionJCE.java
+++ b/src/java/org/apache/fop/pdf/PDFEncryptionJCE.java
@@ -57,8 +57,8 @@ public class PDFEncryptionJCE extends PDFObject implements PDFEncryption {
this.encryption = encryption;
this.number = number;
this.generation = generation;
- //System.out.println("new encryption filter for number "
- // +number+" and generation "+generation);
+ log.debug("new encryption filter for number "
+ + number + " and generation " + generation);
}
/**
@@ -108,11 +108,11 @@ public class PDFEncryptionJCE extends PDFObject implements PDFEncryption {
}
- private static final char [] PAD =
- { 0x28, 0xBF, 0x4E, 0x5E, 0x4E, 0x75, 0x8A, 0x41,
- 0x64, 0x00, 0x4E, 0x56, 0xFF, 0xFA, 0x01, 0x08,
- 0x2E, 0x2E, 0x00, 0xB6, 0xD0, 0x68, 0x3E, 0x80,
- 0x2F, 0x0C, 0xA9, 0xFE, 0x64, 0x53, 0x69, 0x7A };
+ private static final char [] PAD
+ = {0x28, 0xBF, 0x4E, 0x5E, 0x4E, 0x75, 0x8A, 0x41,
+ 0x64, 0x00, 0x4E, 0x56, 0xFF, 0xFA, 0x01, 0x08,
+ 0x2E, 0x2E, 0x00, 0xB6, 0xD0, 0x68, 0x3E, 0x80,
+ 0x2F, 0x0C, 0xA9, 0xFE, 0x64, 0x53, 0x69, 0x7A};
/** Value of PRINT permission */
public static final int PERMISSION_PRINT = 4;
@@ -357,7 +357,7 @@ public class PDFEncryptionJCE extends PDFObject implements PDFEncryption {
if (this.encryptionKey == null) {
throw new IllegalStateException("PDF Encryption has not been initialized");
}
- //getDocument().getLogger().debug("encrypting with for "+number+" "+generation);
+ log.debug("encrypting with for " + number + " " + generation);
byte[] hash = calcHash(number, generation);
return encryptWithHash(data, hash, hash.length);
diff --git a/src/java/org/apache/fop/pdf/PDFFactory.java b/src/java/org/apache/fop/pdf/PDFFactory.java
index 1fd969dbb..80833b164 100644
--- a/src/java/org/apache/fop/pdf/PDFFactory.java
+++ b/src/java/org/apache/fop/pdf/PDFFactory.java
@@ -28,6 +28,8 @@ import java.util.Map;
// Apache libs
import org.apache.avalon.framework.container.ContainerUtil;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
// FOP
import org.apache.fop.fonts.CIDFont;
@@ -50,6 +52,8 @@ public class PDFFactory {
private PDFDocument document;
+ private Log log = LogFactory.getLog("org.apache.fop.pdf");
+
/**
* Creates a new PDFFactory.
* @param document the parent PDFDocument needed to register the generated
@@ -1103,7 +1107,7 @@ public class PDFFactory {
try {
in = getDocument().resolveURI(font.getEmbedFileName());
} catch (Exception e) {
- getDocument().getLogger().error("Failed to embed fontfile: "
+ log.error("Failed to embed fontfile: "
+ font.getEmbedFileName()
+ "(" + e.getMessage() + ")");
}
@@ -1116,7 +1120,7 @@ public class PDFFactory {
this.getClass().getResourceAsStream(
font.getEmbedResourceName()));
} catch (Exception e) {
- getDocument().getLogger().error(
+ log.error(
"Failed to embed fontresource: "
+ font.getEmbedResourceName()
+ "(" + e.getMessage() + ")");
@@ -1133,8 +1137,6 @@ public class PDFFactory {
FontFileReader reader = new FontFileReader(in);
TTFSubSetFile subset = new TTFSubSetFile();
- subset.setLogger(getDocument().getLogger());
-
byte[] subsetFont = subset.readFont(reader,
mbfont.getTTCName(), mbfont.getUsedGlyphs());
// Only TrueType CID fonts are supported now
@@ -1166,7 +1168,7 @@ public class PDFFactory {
}
}
} catch (IOException ioe) {
- getDocument().getLogger().error(
+ log.error(
"Failed to embed font [" + desc + "] "
+ desc.getFontName(), ioe);
return (PDFStream) null;
diff --git a/src/java/org/apache/fop/pdf/PDFInfo.java b/src/java/org/apache/fop/pdf/PDFInfo.java
index a80da22bf..e9833082c 100644
--- a/src/java/org/apache/fop/pdf/PDFInfo.java
+++ b/src/java/org/apache/fop/pdf/PDFInfo.java
@@ -153,7 +153,7 @@ public class PDFInfo extends PDFObject {
bout.write(encode("\n"));
// creation date in form (D:YYYYMMDDHHmmSSOHH'mm')
- if(creationDate==null) {
+ if (creationDate == null) {
creationDate = new Date();
}
final SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
@@ -162,7 +162,7 @@ public class PDFInfo extends PDFObject {
bout.write(encodeString("D:" + str));
bout.write(encode("\n>>\nendobj\n"));
} catch (IOException ioe) {
- getDocumentSafely().getLogger().error("Ignored I/O exception", ioe);
+ log.error("Ignored I/O exception", ioe);
}
return bout.toByteArray();
}
diff --git a/src/java/org/apache/fop/pdf/PDFObject.java b/src/java/org/apache/fop/pdf/PDFObject.java
index 49f78681c..272cd01c7 100644
--- a/src/java/org/apache/fop/pdf/PDFObject.java
+++ b/src/java/org/apache/fop/pdf/PDFObject.java
@@ -22,6 +22,9 @@ package org.apache.fop.pdf;
import java.io.IOException;
import java.io.OutputStream;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
/**
* generic PDF object.
*
@@ -31,6 +34,9 @@ import java.io.OutputStream;
*/
public abstract class PDFObject {
+ /** logger for all PDFObjects (and descendants) */
+ protected static Log log = LogFactory.getLog(PDFObject.class.getPackage().getName());
+
/**
* the object's number
*/
@@ -60,7 +66,6 @@ public abstract class PDFObject {
public int getObjectNumber() {
if (this.objnum == 0) {
throw new IllegalStateException("Object has no number assigned: " + this.toString());
- //System.out.println("Object has no number assigned: " + this.toString());
}
return this.objnum;
}
@@ -80,7 +85,7 @@ public abstract class PDFObject {
*/
public void setObjectNumber(int objnum) {
this.objnum = objnum;
- //System.out.println("Assigning "+this+" object number "+objnum);
+ log.trace("Assigning " + this + " object number " + objnum);
}
/**
diff --git a/src/java/org/apache/fop/pdf/PDFOutline.java b/src/java/org/apache/fop/pdf/PDFOutline.java
index 0f3cc86a0..d9e555b6e 100644
--- a/src/java/org/apache/fop/pdf/PDFOutline.java
+++ b/src/java/org/apache/fop/pdf/PDFOutline.java
@@ -92,8 +92,8 @@ public class PDFOutline extends PDFObject {
*/
public void addOutline(PDFOutline outline) {
if (subentries.size() > 0) {
- outline.prev =
- (PDFOutline)subentries.get(subentries.size() - 1);
+ outline.prev
+ = (PDFOutline)subentries.get(subentries.size() - 1);
outline.prev.next = outline;
} else {
first = outline;
@@ -163,7 +163,7 @@ public class PDFOutline extends PDFObject {
}
bout.write(encode(">> endobj\n"));
} catch (IOException ioe) {
- getDocumentSafely().getLogger().error("Ignored I/O exception", ioe);
+ log.error("Ignored I/O exception", ioe);
}
return bout.toByteArray();
}
diff --git a/src/java/org/apache/fop/pdf/PDFT1Stream.java b/src/java/org/apache/fop/pdf/PDFT1Stream.java
index 7ea6bbb9f..63fc6a0d5 100644
--- a/src/java/org/apache/fop/pdf/PDFT1Stream.java
+++ b/src/java/org/apache/fop/pdf/PDFT1Stream.java
@@ -53,11 +53,10 @@ public class PDFT1Stream extends AbstractPDFStream {
if (pfb == null) {
throw new IllegalStateException("pfb must not be null at this point");
}
- getDocumentSafely().getLogger().debug("Writing "
- + pfb.getLength() + " bytes of Type 1 font data");
+ log.debug("Writing " + pfb.getLength() + " bytes of Type 1 font data");
int length = super.output(stream);
- getDocumentSafely().getLogger().debug("Embedded Type1 font");
+ log.debug("Embedded Type1 font");
return length;
}
diff --git a/src/java/org/apache/fop/pdf/PDFTTFStream.java b/src/java/org/apache/fop/pdf/PDFTTFStream.java
index 7724dbbfb..7371b9327 100644
--- a/src/java/org/apache/fop/pdf/PDFTTFStream.java
+++ b/src/java/org/apache/fop/pdf/PDFTTFStream.java
@@ -43,11 +43,10 @@ public class PDFTTFStream extends PDFStream {
*/
protected int output(java.io.OutputStream stream)
throws java.io.IOException {
- getDocumentSafely().getLogger().debug("Writing "
- + origLength + " bytes of TTF font data");
+ log.debug("Writing " + origLength + " bytes of TTF font data");
int length = super.output(stream);
- getDocumentSafely().getLogger().debug("Embedded TrueType/OpenType font");
+ log.debug("Embedded TrueType/OpenType font");
return length;
}