From: Yegor Kozlov Date: Mon, 14 Apr 2008 09:20:20 +0000 (+0000) Subject: use commons logging throughout the code X-Git-Tag: REL_3_0_3_BETA1~23 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=52421e20b9c9b2b8919879f459575032af67165f;p=poi.git use commons logging throughout the code git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@647712 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java b/src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java index 716651d1c6..00fc374fcc 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java +++ b/src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java @@ -45,13 +45,15 @@ import org.apache.poi.hslf.record.Record; import org.apache.poi.hslf.record.UserEditAtom; import org.apache.poi.hslf.usermodel.ObjectData; import org.apache.poi.hslf.usermodel.PictureData; +import org.apache.poi.hslf.model.Shape; import org.apache.poi.poifs.filesystem.DirectoryNode; import org.apache.poi.poifs.filesystem.DocumentEntry; import org.apache.poi.poifs.filesystem.DocumentInputStream; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.util.LittleEndian; import org.apache.poi.util.POILogFactory; -import org.apache.poi.util.POILogger; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; /** * This class contains the main functionality for the Powerpoint file @@ -63,7 +65,7 @@ import org.apache.poi.util.POILogger; public class HSLFSlideShow extends POIDocument { // For logging - protected POILogger logger = POILogFactory.getLogger(this.getClass()); + private static final Log logger = LogFactory.getLog(HSLFSlideShow.class); private InputStream istream; @@ -289,7 +291,7 @@ public class HSLFSlideShow extends POIDocument try { currentUser = new CurrentUserAtom(directory); } catch(IOException ie) { - logger.log(POILogger.ERROR, "Error finding Current User Atom:\n" + ie); + logger.error("Error finding Current User Atom:\n" + ie); currentUser = new CurrentUserAtom(); } } @@ -344,8 +346,8 @@ public class HSLFSlideShow extends POIDocument // If they type (including the bonus 0xF018) is 0, skip it if(type == 0) { - logger.log(POILogger.ERROR, "Problem reading picture: Invalid image type 0, on picture with length " + imgsize + ".\nYou document will probably become corrupted if you save it!"); - logger.log(POILogger.ERROR, "" + pos); + logger.error("Problem reading picture: Invalid image type 0, on picture with length " + imgsize + ".\nYou document will probably become corrupted if you save it!"); + logger.error("" + pos); } else { // Copy the data, ready to pass to PictureData byte[] imgdata = new byte[imgsize]; @@ -360,7 +362,7 @@ public class HSLFSlideShow extends POIDocument pict.setOffset(offset); p.add(pict); } catch(IllegalArgumentException e) { - logger.log(POILogger.ERROR, "Problem reading picture: " + e + "\nYou document will probably become corrupted if you save it!"); + logger.error("Problem reading picture: " + e + "\nYou document will probably become corrupted if you save it!"); } } diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/Document.java b/src/scratchpad/src/org/apache/poi/hslf/record/Document.java index f6252840cc..c5b217b367 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/record/Document.java +++ b/src/scratchpad/src/org/apache/poi/hslf/record/Document.java @@ -19,8 +19,6 @@ package org.apache.poi.hslf.record; -import org.apache.poi.util.POILogger; - import java.io.IOException; import java.io.OutputStream; @@ -134,10 +132,10 @@ public class Document extends PositionDependentRecordContainer // (normally it's 2, or 3 if you have notes) // Complain if it's not if(slwtcount == 0) { - logger.log(POILogger.WARN, "No SlideListWithText's found - there should normally be at least one!"); + logger.warn("No SlideListWithText's found - there should normally be at least one!"); } if(slwtcount > 3) { - logger.log(POILogger.WARN, "Found " + slwtcount + " SlideListWithTexts - normally there should only be three!"); + logger.warn("Found " + slwtcount + " SlideListWithTexts - normally there should only be three!"); } // Now grab all the SLWTs diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/ExEmbed.java b/src/scratchpad/src/org/apache/poi/hslf/record/ExEmbed.java index a021d6b10d..57c79afe11 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/record/ExEmbed.java +++ b/src/scratchpad/src/org/apache/poi/hslf/record/ExEmbed.java @@ -21,7 +21,6 @@ import java.io.OutputStream; import java.io.IOException; import org.apache.poi.util.LittleEndian; -import org.apache.poi.util.POILogger; /** * This data represents an embedded object in the document. @@ -94,14 +93,14 @@ public class ExEmbed extends RecordContainer { if(_children[0] instanceof ExEmbedAtom) { embedAtom = (ExEmbedAtom)_children[0]; } else { - logger.log(POILogger.ERROR, "First child record wasn't a ExEmbedAtom, was of type " + _children[0].getRecordType()); + logger.error("First child record wasn't a ExEmbedAtom, was of type " + _children[0].getRecordType()); } // Second child should be the ExOleObjAtom if (_children[1] instanceof ExOleObjAtom) { oleObjAtom = (ExOleObjAtom)_children[1]; } else { - logger.log(POILogger.ERROR, "Second child record wasn't a ExOleObjAtom, was of type " + _children[1].getRecordType()); + logger.error("Second child record wasn't a ExOleObjAtom, was of type " + _children[1].getRecordType()); } for (int i = 2; i < _children.length; i++) { @@ -110,15 +109,15 @@ public class ExEmbed extends RecordContainer { else if (progId == null) progId = (CString)_children[i]; else if (clipboardName == null) clipboardName = (CString)_children[i]; } else { - logger.log(POILogger.ERROR, "Record after atoms wasn't a CString, was of type " + _children[i].getRecordType()); + logger.error("Record after atoms wasn't a CString, was of type " + _children[i].getRecordType()); } } } /** - * Gets the {@code ExEmbedAtom}. + * Gets the {@link ExEmbedAtom}. * - * @return the {@code ExEmbedAtom}. + * @return the {@link ExEmbedAtom}. */ public ExEmbedAtom getExEmbedAtom() { @@ -126,9 +125,9 @@ public class ExEmbed extends RecordContainer { } /** - * Gets the {@code ExOleObjAtom}. + * Gets the {@link ExOleObjAtom}. * - * @return the {@code ExOleObjAtom}. + * @return the {@link ExOleObjAtom}. */ public ExOleObjAtom getExOleObjAtom() { diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/ExHyperlink.java b/src/scratchpad/src/org/apache/poi/hslf/record/ExHyperlink.java index 8ba58cdb61..1832e09019 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/record/ExHyperlink.java +++ b/src/scratchpad/src/org/apache/poi/hslf/record/ExHyperlink.java @@ -20,7 +20,6 @@ import java.io.IOException; import java.io.OutputStream; import org.apache.poi.util.LittleEndian; -import org.apache.poi.util.POILogger; /** * This class represents the data of a link in the document. @@ -108,7 +107,7 @@ public class ExHyperlink extends RecordContainer { if(_children[0] instanceof ExHyperlinkAtom) { linkAtom = (ExHyperlinkAtom)_children[0]; } else { - logger.log(POILogger.ERROR, "First child record wasn't a ExHyperlinkAtom, was of type " + _children[0].getRecordType()); + logger.error("First child record wasn't a ExHyperlinkAtom, was of type " + _children[0].getRecordType()); } for (int i = 1; i < _children.length; i++) { @@ -116,7 +115,7 @@ public class ExHyperlink extends RecordContainer { if ( linkDetailsA == null) linkDetailsA = (CString)_children[i]; else linkDetailsB = (CString)_children[i]; } else { - logger.log(POILogger.ERROR, "Record after ExHyperlinkAtom wasn't a CString, was of type " + _children[1].getRecordType()); + logger.error("Record after ExHyperlinkAtom wasn't a CString, was of type " + _children[1].getRecordType()); } } diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/FontCollection.java b/src/scratchpad/src/org/apache/poi/hslf/record/FontCollection.java index e4ee95657c..17ab338414 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/record/FontCollection.java +++ b/src/scratchpad/src/org/apache/poi/hslf/record/FontCollection.java @@ -18,9 +18,6 @@ package org.apache.poi.hslf.record; -import org.apache.poi.util.LittleEndian; -import org.apache.poi.util.POILogger; - import java.io.*; import java.util.*; @@ -49,7 +46,7 @@ public class FontCollection extends RecordContainer { FontEntityAtom atom = (FontEntityAtom)_children[i]; fonts.add(atom.getFontName()); } else { - logger.log(POILogger.WARN, "Warning: FontCollection child wasn't a FontEntityAtom, was " + _children[i]); + logger.warn("Warning: FontCollection child wasn't a FontEntityAtom, was " + _children[i]); } } } diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawing.java b/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawing.java index e42b358b89..b0602bc460 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawing.java +++ b/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawing.java @@ -20,7 +20,6 @@ package org.apache.poi.hslf.record; import org.apache.poi.util.LittleEndian; -import org.apache.poi.util.POILogger; import org.apache.poi.ddf.*; import org.apache.poi.hslf.model.ShapeTypes; @@ -132,7 +131,7 @@ public class PPDrawing extends RecordAtom // Wind on int size = r.getRecordSize(); if(size < 8) { - logger.log(POILogger.WARN, "Hit short DDF record at " + startPos + " - " + size); + logger.warn("Hit short DDF record at " + startPos + " - " + size); } /** @@ -142,7 +141,7 @@ public class PPDrawing extends RecordAtom * Sometimes it is not so, see an example in bug #44770. Most likely reason is that one of ddf records calculates wrong size. */ if(size != escherBytes){ - logger.log(POILogger.WARN, "Record length=" + escherBytes + " but getRecordSize() returned " + r.getRecordSize() + "; record: " + r.getClass()); + logger.warn("Record length=" + escherBytes + " but getRecordSize() returned " + r.getRecordSize() + "; record: " + r.getClass()); size = escherBytes; } startPos += size; diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/PersistPtrHolder.java b/src/scratchpad/src/org/apache/poi/hslf/record/PersistPtrHolder.java index 68b8b7cafe..7f9d646802 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/record/PersistPtrHolder.java +++ b/src/scratchpad/src/org/apache/poi/hslf/record/PersistPtrHolder.java @@ -20,7 +20,6 @@ package org.apache.poi.hslf.record; import org.apache.poi.util.LittleEndian; -import org.apache.poi.util.POILogger; import java.io.IOException; import java.io.OutputStream; @@ -195,8 +194,8 @@ public class PersistPtrHolder extends PositionDependentRecordAtom Integer newPos = (Integer)oldToNewReferencesLookup.get(oldPos); if(newPos == null) { - logger.log(POILogger.WARN, "Couldn't find the new location of the \"slide\" with id " + id + " that used to be at " + oldPos); - logger.log(POILogger.WARN, "Not updating the position of it, you probably won't be able to find it any more (if you ever could!)"); + logger.warn("Couldn't find the new location of the \"slide\" with id " + id + " that used to be at " + oldPos); + logger.warn("Not updating the position of it, you probably won't be able to find it any more (if you ever could!)"); newPos = oldPos; } diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/Record.java b/src/scratchpad/src/org/apache/poi/hslf/record/Record.java index 1aface94cd..44cde7595b 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/record/Record.java +++ b/src/scratchpad/src/org/apache/poi/hslf/record/Record.java @@ -24,9 +24,9 @@ import java.io.IOException; import java.io.OutputStream; import java.util.Vector; import org.apache.poi.util.LittleEndian; -import org.apache.poi.util.POILogger; -import org.apache.poi.util.POILogFactory; import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; /** @@ -40,7 +40,7 @@ import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException; public abstract class Record { // For logging - protected POILogger logger = POILogFactory.getLogger(this.getClass()); + protected Log logger = LogFactory.getLog(this.getClass()); /** * Is this record type an Atom record (only has data), diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java b/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java index fdaa9eec2c..72e17722ce 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java +++ b/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java @@ -31,7 +31,6 @@ import org.apache.poi.hslf.model.textproperties.ParagraphFlagsTextProp; import org.apache.poi.hslf.model.textproperties.TextProp; import org.apache.poi.hslf.model.textproperties.TextPropCollection; import org.apache.poi.util.LittleEndian; -import org.apache.poi.util.POILogger; /** * A StyleTextPropAtom (type 4001). Holds basic character properties @@ -293,7 +292,7 @@ public class StyleTextPropAtom extends RecordAtom } if (rawContents.length > 0 && textHandled != (size+1)){ - logger.log(POILogger.WARN, "Problem reading paragraph style runs: textHandled = " + textHandled + ", text.size+1 = " + (size+1)); + logger.warn("Problem reading paragraph style runs: textHandled = " + textHandled + ", text.size+1 = " + (size+1)); } // Now do the character stylings @@ -328,7 +327,7 @@ public class StyleTextPropAtom extends RecordAtom } } if (rawContents.length > 0 && textHandled != (size+1)){ - logger.log(POILogger.WARN, "Problem reading character style runs: textHandled = " + textHandled + ", text.size+1 = " + (size+1)); + logger.warn("Problem reading character style runs: textHandled = " + textHandled + ", text.size+1 = " + (size+1)); } // Handle anything left over diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java index 02db3567cc..105bca5d43 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java +++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java @@ -37,8 +37,8 @@ import org.apache.poi.hslf.record.*; import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException; import org.apache.poi.hslf.exceptions.HSLFException; import org.apache.poi.util.ArrayUtil; -import org.apache.poi.util.POILogFactory; -import org.apache.poi.util.POILogger; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; /** * This class is a friendly wrapper on top of the more scary HSLFSlideShow. @@ -80,7 +80,7 @@ public class SlideShow private FontCollection _fonts; // For logging - private POILogger logger = POILogFactory.getLogger(this.getClass()); + private static final Log logger = LogFactory.getLog(SlideShow.class); /* =============================================================== @@ -275,7 +275,7 @@ public class SlideShow Record r = _mostRecentCoreRecords[coreRecordId.intValue()]; return r; } else { - logger.log(POILogger.ERROR, "We tried to look up a reference to a core record, but there was no core ID for reference ID " + refID); + logger.error("We tried to look up a reference to a core record, but there was no core ID for reference ID " + refID); return null; } } @@ -378,7 +378,7 @@ public class SlideShow Integer slideId = new Integer(spa.getSlideIdentifier()); slideIdToNotes.put(slideId, new Integer(i)); } else { - logger.log(POILogger.ERROR, "A Notes SlideAtomSet at " + i + " said its record was at refID " + notesSets[i].getSlidePersistAtom().getRefID() + ", but that was actually a " + r); + logger.error("A Notes SlideAtomSet at " + i + " said its record was at refID " + notesSets[i].getSlidePersistAtom().getRefID() + ", but that was actually a " + r); } } notesRecords = new org.apache.poi.hslf.record.Notes[notesRecordsL.size()]; @@ -404,7 +404,7 @@ public class SlideShow if(r instanceof org.apache.poi.hslf.record.Slide) { slidesRecords[i] = (org.apache.poi.hslf.record.Slide)r; } else { - logger.log(POILogger.ERROR, "A Slide SlideAtomSet at " + i + " said its record was at refID " + slidesSets[i].getSlidePersistAtom().getRefID() + ", but that was actually a " + r); + logger.error("A Slide SlideAtomSet at " + i + " said its record was at refID " + slidesSets[i].getSlidePersistAtom().getRefID() + ", but that was actually a " + r); } } } @@ -429,7 +429,7 @@ public class SlideShow if (noteId != 0){ Integer notesPos = (Integer)slideIdToNotes.get(new Integer(noteId)); if (notesPos != null) notes = _notes[notesPos.intValue()]; - else logger.log(POILogger.ERROR, "Notes not found for noteId=" + noteId); + else logger.error("Notes not found for noteId=" + noteId); } // Now, build our slide @@ -622,7 +622,7 @@ public class SlideShow System.arraycopy(_slides, 0, s, 0, _slides.length); s[_slides.length] = slide; _slides = s; - logger.log(POILogger.INFO, "Added slide " + _slides.length + " with ref " + sp.getRefID() + " and identifier " + sp.getSlideIdentifier()); + logger.info("Added slide " + _slides.length + " with ref " + sp.getRefID() + " and identifier " + sp.getSlideIdentifier()); // Add the core records for this new Slide to the record tree org.apache.poi.hslf.record.Slide slideRecord = slide.getSlideRecord(); @@ -658,7 +658,7 @@ public class SlideShow // (Also need to tell it where it is) slideRecord.setLastOnDiskOffset(slideOffset); ptr.addSlideLookup(sp.getRefID(), slideOffset); - logger.log(POILogger.INFO, "New slide ended up at " + slideOffset); + logger.info("New slide ended up at " + slideOffset); // Last view is now of the slide usr.setLastViewType((short)UserEditAtom.LAST_VIEW_SLIDE_VIEW);