]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Changed logging to use "static" loggers from Jakarta Commons Logging (via LogFactory).
authorJeremias Maerki <jeremias@apache.org>
Fri, 2 Apr 2004 09:15:16 +0000 (09:15 +0000)
committerJeremias Maerki <jeremias@apache.org>
Fri, 2 Apr 2004 09:15:16 +0000 (09:15 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197479 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/fonts/truetype/TTFFile.java
src/java/org/apache/fop/fonts/type1/PFMFile.java
src/java/org/apache/fop/pdf/PDFDocument.java
src/java/org/apache/fop/pdf/PDFEncryptionJCE.java
src/java/org/apache/fop/pdf/PDFFactory.java
src/java/org/apache/fop/pdf/PDFInfo.java
src/java/org/apache/fop/pdf/PDFObject.java
src/java/org/apache/fop/pdf/PDFOutline.java
src/java/org/apache/fop/pdf/PDFT1Stream.java
src/java/org/apache/fop/pdf/PDFTTFStream.java

index fc4df27fbb38e269fdf996506d498644fe95b951..b5f20cfb64bb8331ceffc08b59c8e25e67940163 100644 (file)
@@ -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);
         }
     }
 
index f2cd1391c76af438033f0897920b4df5961302b6..515d0e9eabd2eaed6afbd67624d564abee0415b9 100644 (file)
@@ -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,
index 9ac36e29d4d0a57014f79be6a86228168de29d8e..12960d6c32a95beb60159cdd8ad6296ac375d913 100644 (file)
@@ -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
@@ -233,14 +234,6 @@ public class PDFDocument {
         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
@@ -259,17 +252,6 @@ public class PDFDocument {
         return this.encodingOnTheFly;
     }
 
-    /**
-     * 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
@@ -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.");
         }
index 989fe6edf8a0fa486d6f213f2dfd0e2ddd00b961..66bf5dd45068fbce929d1a4fb7e1e3549e929f6f 100644 (file)
@@ -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);
index 1fd969dbbf3fd322d32d45ed3822d5d1448c1741..80833b16457ada510342a7d5b982aec983ec6ca6 100644 (file)
@@ -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;
index a80da22bf1ccda0e2c807c072a0826166c338b9b..e9833082c74ba913eb117c093ab19adcaa316cfd 100644 (file)
@@ -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();
     }
index 49f78681ca2a15c619b675edd27058f085a328d1..272cd01c744f659832eed521f8018be0467f2d4b 100644 (file)
@@ -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);
     }
 
     /**
index 0f3cc86a0b1bfb3dbf6b8b0b9ca4c2c303733b75..d9e555b6e88cd1a1fd422318d53523bc3b1c83c0 100644 (file)
@@ -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();
     }
index 7ea6bbb9f830be01b734013ab781e5b4fe884a8e..63fc6a0d50425d014af6b129c4628d185bccb73a 100644 (file)
@@ -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;
     }
 
index 7724dbbfbfee4fbde50e94f1f36ae55d13ef5e50..7371b9327adfb47c75db5ef75052b9341b6cb72c 100644 (file)
@@ -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;
     }