use commons logging throughout the code

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@647712 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yegor Kozlov 2008-04-14 09:20:20 +00:00
parent 0d7b9ae941
commit 874b349c58
10 changed files with 38 additions and 46 deletions

View File

@ -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!");
}
}

View File

@ -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

View File

@ -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()
{

View File

@ -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());
}
}

View File

@ -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]);
}
}
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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),

View File

@ -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

View File

@ -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);