make sure all hslf classes use POI loggers

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@647824 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yegor Kozlov 2008-04-14 14:58:18 +00:00
parent a23a1f11fc
commit 82bb0bc7ef
22 changed files with 90 additions and 70 deletions

View File

@ -170,7 +170,7 @@ public class UnknownEscherRecord extends EscherRecord
{ {
if (thedata.length != 0) if (thedata.length != 0)
{ {
theDumpHex = " Extra Data:" + nl; theDumpHex = " Extra Data("+thedata.length+"):" + nl;
theDumpHex += HexDump.dump(thedata, 0, 0); theDumpHex += HexDump.dump(thedata, 0, 0);
} }
} }

View File

@ -122,7 +122,7 @@ public class BiffViewer {
private static void dumpNormal(Record record, int startloc, short rectype, short recsize) private static void dumpNormal(Record record, int startloc, short rectype, short recsize)
{ {
System.out.println("Offset 0x" + Integer.toHexString(startloc) + " (" + startloc + ")"); //System.out.println("Offset 0x" + Integer.toHexString(startloc) + " (" + startloc + ")");
System.out.println( "recordid = 0x" + Integer.toHexString( rectype ) + ", size = " + recsize ); System.out.println( "recordid = 0x" + Integer.toHexString( rectype ) + ", size = " + recsize );
System.out.println( record.toString() ); System.out.println( record.toString() );

View File

@ -103,6 +103,11 @@ public class TextboxShape
opt.addEscherProperty( new EscherSimpleProperty( EscherProperties.TEXT__TEXTRIGHT, shape.getMarginRight() ) ); opt.addEscherProperty( new EscherSimpleProperty( EscherProperties.TEXT__TEXTRIGHT, shape.getMarginRight() ) );
opt.addEscherProperty( new EscherSimpleProperty( EscherProperties.TEXT__TEXTBOTTOM, shape.getMarginBottom() ) ); opt.addEscherProperty( new EscherSimpleProperty( EscherProperties.TEXT__TEXTBOTTOM, shape.getMarginBottom() ) );
opt.addEscherProperty( new EscherSimpleProperty( EscherProperties.TEXT__TEXTTOP, shape.getMarginTop() ) ); opt.addEscherProperty( new EscherSimpleProperty( EscherProperties.TEXT__TEXTTOP, shape.getMarginTop() ) );
opt.addEscherProperty( new EscherSimpleProperty( EscherProperties.TEXT__WRAPTEXT, 0 ) );
opt.addEscherProperty( new EscherSimpleProperty( EscherProperties.TEXT__ANCHORTEXT, 0 ) );
opt.addEscherProperty( new EscherSimpleProperty( EscherProperties.GROUPSHAPE__PRINT, 0x00080000 ) );
addStandardOptions( shape, opt ); addStandardOptions( shape, opt );
HSSFAnchor userAnchor = shape.getAnchor(); HSSFAnchor userAnchor = shape.getAnchor();
// if (userAnchor.isHorizontallyFlipped()) // if (userAnchor.isHorizontallyFlipped())

View File

@ -248,6 +248,10 @@ public class TextObjectRecord
buffer.append( " .string = " ).append(str).append('\n'); buffer.append( " .string = " ).append(str).append('\n');
for (int i = 0; i < str.numFormattingRuns(); i++) {
buffer.append( " .textrun = " ).append(str.getFontOfFormattingRun(i)).append('\n');
}
buffer.append( "[/TXO]\n" ); buffer.append( "[/TXO]\n" );
return buffer.toString(); return buffer.toString();
} }

View File

@ -52,8 +52,7 @@ import org.apache.poi.poifs.filesystem.DocumentInputStream;
import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogFactory;
import org.apache.commons.logging.Log; import org.apache.poi.util.POILogger;
import org.apache.commons.logging.LogFactory;
/** /**
* This class contains the main functionality for the Powerpoint file * This class contains the main functionality for the Powerpoint file
@ -65,7 +64,7 @@ import org.apache.commons.logging.LogFactory;
public class HSLFSlideShow extends POIDocument public class HSLFSlideShow extends POIDocument
{ {
// For logging // For logging
private static final Log logger = LogFactory.getLog(HSLFSlideShow.class); private POILogger logger = POILogFactory.getLogger(this.getClass());
private InputStream istream; private InputStream istream;
@ -291,7 +290,7 @@ public class HSLFSlideShow extends POIDocument
try { try {
currentUser = new CurrentUserAtom(directory); currentUser = new CurrentUserAtom(directory);
} catch(IOException ie) { } catch(IOException ie) {
logger.error("Error finding Current User Atom:\n" + ie); logger.log(POILogger.ERROR, "Error finding Current User Atom:\n" + ie);
currentUser = new CurrentUserAtom(); currentUser = new CurrentUserAtom();
} }
} }
@ -346,8 +345,8 @@ public class HSLFSlideShow extends POIDocument
// If they type (including the bonus 0xF018) is 0, skip it // If they type (including the bonus 0xF018) is 0, skip it
if(type == 0) { if(type == 0) {
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.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.error("" + pos); logger.log(POILogger.ERROR, "" + pos);
} else { } else {
// Copy the data, ready to pass to PictureData // Copy the data, ready to pass to PictureData
byte[] imgdata = new byte[imgsize]; byte[] imgdata = new byte[imgsize];
@ -362,7 +361,7 @@ public class HSLFSlideShow extends POIDocument
pict.setOffset(offset); pict.setOffset(offset);
p.add(pict); p.add(pict);
} catch(IllegalArgumentException e) { } catch(IllegalArgumentException e) {
logger.error("Problem reading picture: " + e + "\nYou document will probably become corrupted if you save it!"); logger.log(POILogger.ERROR, "Problem reading picture: " + e + "\nYou document will probably become corrupted if you save it!");
} }
} }

View File

@ -23,8 +23,8 @@ import org.apache.poi.hslf.record.*;
import org.apache.poi.hslf.usermodel.PictureData; import org.apache.poi.hslf.usermodel.PictureData;
import org.apache.poi.hslf.usermodel.SlideShow; import org.apache.poi.hslf.usermodel.SlideShow;
import org.apache.poi.hslf.exceptions.HSLFException; import org.apache.poi.hslf.exceptions.HSLFException;
import org.apache.commons.logging.Log; import org.apache.poi.util.POILogger;
import org.apache.commons.logging.LogFactory; import org.apache.poi.util.POILogFactory;
import java.awt.*; import java.awt.*;
import java.util.*; import java.util.*;
@ -36,7 +36,7 @@ import java.util.*;
*/ */
public class Fill { public class Fill {
// For logging // For logging
protected Log log = LogFactory.getLog(this.getClass()); protected POILogger logger = POILogFactory.getLogger(this.getClass());
/** /**
* Fill with a solid color * Fill with a solid color
@ -213,7 +213,7 @@ public class Fill {
java.util.List lst = bstore.getChildRecords(); java.util.List lst = bstore.getChildRecords();
int idx = p.getPropertyValue(); int idx = p.getPropertyValue();
if (idx == 0){ if (idx == 0){
log.error("no reference to picture data found "); logger.log(POILogger.WARN, "no reference to picture data found ");
} else { } else {
EscherBSERecord bse = (EscherBSERecord)lst.get(idx - 1); EscherBSERecord bse = (EscherBSERecord)lst.get(idx - 1);
for ( int i = 0; i < pict.length; i++ ) { for ( int i = 0; i < pict.length; i++ ) {

View File

@ -18,6 +18,7 @@ package org.apache.poi.hslf.model;
import org.apache.poi.ddf.*; import org.apache.poi.ddf.*;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.POILogger;
import java.awt.geom.*; import java.awt.geom.*;
import java.util.ArrayList; import java.util.ArrayList;
@ -96,7 +97,7 @@ public class Freeform extends AutoShape {
segInfo.add(new byte[]{0x01, 0x20 }); segInfo.add(new byte[]{0x01, 0x20 });
break; break;
case PathIterator.SEG_QUADTO: case PathIterator.SEG_QUADTO:
System.err.println("SEG_QUADTO is not supported"); logger.log(POILogger.WARN, "SEG_QUADTO is not supported");
break; break;
case PathIterator.SEG_CLOSE: case PathIterator.SEG_CLOSE:
pntInfo.add(pntInfo.get(0)); pntInfo.add(pntInfo.get(0));

View File

@ -30,8 +30,8 @@ import java.util.Map;
import java.util.ArrayList; import java.util.ArrayList;
import org.apache.poi.hslf.usermodel.RichTextRun; import org.apache.poi.hslf.usermodel.RichTextRun;
import org.apache.poi.hslf.exceptions.HSLFException; import org.apache.poi.hslf.exceptions.HSLFException;
import org.apache.commons.logging.Log; import org.apache.poi.util.POILogger;
import org.apache.commons.logging.LogFactory; import org.apache.poi.util.POILogFactory;
/** /**
* Translates Graphics2D calls into PowerPoint. * Translates Graphics2D calls into PowerPoint.
@ -40,7 +40,7 @@ import org.apache.commons.logging.LogFactory;
*/ */
public class PPGraphics2D extends Graphics2D implements Cloneable { public class PPGraphics2D extends Graphics2D implements Cloneable {
private static final Log log = LogFactory.getLog(PPGraphics2D.class); protected POILogger log = POILogFactory.getLogger(this.getClass());
//The ppt object to write into. //The ppt object to write into.
private ShapeGroup group; private ShapeGroup group;
@ -356,7 +356,7 @@ public class PPGraphics2D extends Graphics2D implements Cloneable {
* this method clears the current <code>Clip</code>. * this method clears the current <code>Clip</code>.
*/ */
public void clip(Shape s){ public void clip(Shape s){
log.warn("Not implemented"); log.log(POILogger.WARN, "Not implemented");
} }
/** /**
@ -376,7 +376,7 @@ public class PPGraphics2D extends Graphics2D implements Cloneable {
* @since JDK1.1 * @since JDK1.1
*/ */
public Shape getClip(){ public Shape getClip(){
log.warn("Not implemented"); log.log(POILogger.WARN, "Not implemented");
return null; return null;
} }
@ -644,7 +644,7 @@ public class PPGraphics2D extends Graphics2D implements Cloneable {
public boolean drawImage(Image img, int x, int y, public boolean drawImage(Image img, int x, int y,
Color bgcolor, Color bgcolor,
ImageObserver observer){ ImageObserver observer){
log.warn("Not implemented"); log.log(POILogger.WARN, "Not implemented");
return false; return false;
} }
@ -691,7 +691,7 @@ public class PPGraphics2D extends Graphics2D implements Cloneable {
int width, int height, int width, int height,
Color bgcolor, Color bgcolor,
ImageObserver observer){ ImageObserver observer){
log.warn("Not implemented"); log.log(POILogger.WARN, "Not implemented");
return false; return false;
} }
@ -748,7 +748,7 @@ public class PPGraphics2D extends Graphics2D implements Cloneable {
int dx1, int dy1, int dx2, int dy2, int dx1, int dy1, int dx2, int dy2,
int sx1, int sy1, int sx2, int sy2, int sx1, int sy1, int sx2, int sy2,
ImageObserver observer){ ImageObserver observer){
log.warn("Not implemented"); log.log(POILogger.WARN, "Not implemented");
return false; return false;
} }
@ -810,7 +810,7 @@ public class PPGraphics2D extends Graphics2D implements Cloneable {
int sx1, int sy1, int sx2, int sy2, int sx1, int sy1, int sx2, int sy2,
Color bgcolor, Color bgcolor,
ImageObserver observer){ ImageObserver observer){
log.warn("Not implemented"); log.log(POILogger.WARN, "Not implemented");
return false; return false;
} }
@ -848,7 +848,7 @@ public class PPGraphics2D extends Graphics2D implements Cloneable {
*/ */
public boolean drawImage(Image img, int x, int y, public boolean drawImage(Image img, int x, int y,
ImageObserver observer) { ImageObserver observer) {
log.warn("Not implemented"); log.log(POILogger.WARN, "Not implemented");
return false; return false;
} }
@ -1033,7 +1033,7 @@ public class PPGraphics2D extends Graphics2D implements Cloneable {
* @since JDK1.1 * @since JDK1.1
*/ */
public void setClip(Shape clip) { public void setClip(Shape clip) {
log.warn("Not implemented"); log.log(POILogger.WARN, "Not implemented");
} }
/** /**
@ -1331,7 +1331,7 @@ public class PPGraphics2D extends Graphics2D implements Cloneable {
* @see java.awt.AlphaComposite * @see java.awt.AlphaComposite
*/ */
public void setComposite(Composite comp){ public void setComposite(Composite comp){
log.warn("Not implemented"); log.log(POILogger.WARN, "Not implemented");
} }
/** /**
@ -1342,7 +1342,7 @@ public class PPGraphics2D extends Graphics2D implements Cloneable {
* @see #setComposite * @see #setComposite
*/ */
public Composite getComposite(){ public Composite getComposite(){
log.warn("Not implemented"); log.log(POILogger.WARN, "Not implemented");
return null; return null;
} }
@ -1483,7 +1483,7 @@ public class PPGraphics2D extends Graphics2D implements Cloneable {
* @see #setClip * @see #setClip
*/ */
public void drawString(AttributedCharacterIterator iterator, float x, float y) { public void drawString(AttributedCharacterIterator iterator, float x, float y) {
log.warn("Not implemented"); log.log(POILogger.WARN, "Not implemented");
} }
/** /**
@ -1586,7 +1586,7 @@ public class PPGraphics2D extends Graphics2D implements Cloneable {
* @see #setClip(Shape) * @see #setClip(Shape)
*/ */
public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs) { public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs) {
log.warn("Not implemented"); log.log(POILogger.WARN, "Not implemented");
return false; return false;
} }
@ -1629,7 +1629,7 @@ public class PPGraphics2D extends Graphics2D implements Cloneable {
public boolean drawImage(Image img, int x, int y, public boolean drawImage(Image img, int x, int y,
int width, int height, int width, int height,
ImageObserver observer) { ImageObserver observer) {
log.warn("Not implemented"); log.log(POILogger.WARN, "Not implemented");
return false; return false;
} }
@ -1675,7 +1675,7 @@ public class PPGraphics2D extends Graphics2D implements Cloneable {
* @param c1 the XOR alternation color * @param c1 the XOR alternation color
*/ */
public void setXORMode(Color c1) { public void setXORMode(Color c1) {
log.warn("Not implemented"); log.log(POILogger.WARN, "Not implemented");
} }
/** /**
@ -1686,7 +1686,7 @@ public class PPGraphics2D extends Graphics2D implements Cloneable {
* overwrite the destination with the current color. * overwrite the destination with the current color.
*/ */
public void setPaintMode() { public void setPaintMode() {
log.warn("Not implemented"); log.log(POILogger.WARN, "Not implemented");
} }
/** /**
@ -1721,7 +1721,7 @@ public class PPGraphics2D extends Graphics2D implements Cloneable {
* @see #drawRenderedImage * @see #drawRenderedImage
*/ */
public void drawRenderedImage(RenderedImage img, AffineTransform xform) { public void drawRenderedImage(RenderedImage img, AffineTransform xform) {
log.warn("Not implemented"); log.log(POILogger.WARN, "Not implemented");
} }
/** /**
@ -1746,7 +1746,7 @@ public class PPGraphics2D extends Graphics2D implements Cloneable {
* @see #setClip * @see #setClip
*/ */
public void drawRenderableImage(RenderableImage img, AffineTransform xform) { public void drawRenderableImage(RenderableImage img, AffineTransform xform) {
log.warn("Not implemented"); log.log(POILogger.WARN, "Not implemented");
} }
protected void applyStroke(SimpleShape shape) { protected void applyStroke(SimpleShape shape) {

View File

@ -21,6 +21,7 @@ import org.apache.poi.hslf.usermodel.PictureData;
import org.apache.poi.hslf.usermodel.SlideShow; import org.apache.poi.hslf.usermodel.SlideShow;
import org.apache.poi.hslf.record.Document; import org.apache.poi.hslf.record.Document;
import org.apache.poi.hslf.blip.Bitmap; import org.apache.poi.hslf.blip.Bitmap;
import org.apache.poi.util.POILogger;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
@ -178,7 +179,7 @@ public class Picture extends SimpleShape {
List lst = bstore.getChildRecords(); List lst = bstore.getChildRecords();
int idx = getPictureIndex(); int idx = getPictureIndex();
if (idx == 0){ if (idx == 0){
log.error("no reference to picture data found "); logger.log(POILogger.ERROR, "no reference to picture data found ");
} else { } else {
EscherBSERecord bse = (EscherBSERecord)lst.get(idx-1); EscherBSERecord bse = (EscherBSERecord)lst.get(idx-1);
for ( int i = 0; i < pict.length; i++ ) { for ( int i = 0; i < pict.length; i++ ) {
@ -186,7 +187,7 @@ public class Picture extends SimpleShape {
return pict[i]; return pict[i];
} }
} }
log.error("no picture found for our BSE offset " + bse.getOffset()); logger.log(POILogger.ERROR, "no picture found for our BSE offset " + bse.getOffset());
} }
return null; return null;
} }

View File

@ -19,8 +19,8 @@ package org.apache.poi.hslf.model;
import org.apache.poi.ddf.*; import org.apache.poi.ddf.*;
import org.apache.poi.hslf.model.ShapeTypes; import org.apache.poi.hslf.model.ShapeTypes;
import org.apache.poi.hslf.record.ColorSchemeAtom; import org.apache.poi.hslf.record.ColorSchemeAtom;
import org.apache.commons.logging.Log; import org.apache.poi.util.POILogger;
import org.apache.commons.logging.LogFactory; import org.apache.poi.util.POILogFactory;
import java.util.Iterator; import java.util.Iterator;
import java.awt.*; import java.awt.*;
@ -45,7 +45,7 @@ import java.awt.geom.Rectangle2D;
public abstract class Shape { public abstract class Shape {
// For logging // For logging
protected Log log = LogFactory.getLog(this.getClass()); protected POILogger logger = POILogFactory.getLogger(this.getClass());
/** /**
* In Escher absolute distances are specified in * In Escher absolute distances are specified in

View File

@ -18,6 +18,7 @@ package org.apache.poi.hslf.model;
import org.apache.poi.ddf.*; import org.apache.poi.ddf.*;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.POILogger;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -70,7 +71,7 @@ public class ShapeGroup extends Shape{
} else { } else {
// Should we do anything special with these non // Should we do anything special with these non
// Container records? // Container records?
log.error("Shape contained non container escher record, was " + r.getClass().getName()); logger.log(POILogger.ERROR, "Shape contained non container escher record, was " + r.getClass().getName());
} }
} }

View File

@ -22,6 +22,7 @@ import org.apache.poi.ddf.*;
import org.apache.poi.hslf.record.*; import org.apache.poi.hslf.record.*;
import org.apache.poi.hslf.usermodel.RichTextRun; import org.apache.poi.hslf.usermodel.RichTextRun;
import org.apache.poi.hslf.exceptions.HSLFException; import org.apache.poi.hslf.exceptions.HSLFException;
import org.apache.poi.util.POILogger;
import java.awt.*; import java.awt.*;
import java.awt.font.FontRenderContext; import java.awt.font.FontRenderContext;
@ -479,7 +480,7 @@ public class TextBox extends SimpleShape {
} }
} }
if(_txtrun == null) { if(_txtrun == null) {
log.warn("text run not found for OutlineTextRefAtom.TextIndex=" + idx); logger.log(POILogger.WARN, "text run not found for OutlineTextRefAtom.TextIndex=" + idx);
} }
} else { } else {
int shapeId = _escherContainer.getChildById(EscherSpRecord.RECORD_ID).getShapeId(); int shapeId = _escherContainer.getChildById(EscherSpRecord.RECORD_ID).getShapeId();

View File

@ -19,6 +19,8 @@
package org.apache.poi.hslf.record; package org.apache.poi.hslf.record;
import org.apache.poi.util.POILogger;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
@ -132,10 +134,10 @@ public class Document extends PositionDependentRecordContainer
// (normally it's 2, or 3 if you have notes) // (normally it's 2, or 3 if you have notes)
// Complain if it's not // Complain if it's not
if(slwtcount == 0) { if(slwtcount == 0) {
logger.warn("No SlideListWithText's found - there should normally be at least one!"); logger.log(POILogger.WARN, "No SlideListWithText's found - there should normally be at least one!");
} }
if(slwtcount > 3) { if(slwtcount > 3) {
logger.warn("Found " + slwtcount + " SlideListWithTexts - normally there should only be three!"); logger.log(POILogger.WARN, "Found " + slwtcount + " SlideListWithTexts - normally there should only be three!");
} }
// Now grab all the SLWTs // Now grab all the SLWTs

View File

@ -21,6 +21,7 @@ import java.io.OutputStream;
import java.io.IOException; import java.io.IOException;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.POILogger;
/** /**
* This data represents an embedded object in the document. * This data represents an embedded object in the document.
@ -93,14 +94,14 @@ public class ExEmbed extends RecordContainer {
if(_children[0] instanceof ExEmbedAtom) { if(_children[0] instanceof ExEmbedAtom) {
embedAtom = (ExEmbedAtom)_children[0]; embedAtom = (ExEmbedAtom)_children[0];
} else { } else {
logger.error("First child record wasn't a ExEmbedAtom, was of type " + _children[0].getRecordType()); logger.log(POILogger.ERROR, "First child record wasn't a ExEmbedAtom, was of type " + _children[0].getRecordType());
} }
// Second child should be the ExOleObjAtom // Second child should be the ExOleObjAtom
if (_children[1] instanceof ExOleObjAtom) { if (_children[1] instanceof ExOleObjAtom) {
oleObjAtom = (ExOleObjAtom)_children[1]; oleObjAtom = (ExOleObjAtom)_children[1];
} else { } else {
logger.error("Second child record wasn't a ExOleObjAtom, was of type " + _children[1].getRecordType()); logger.log(POILogger.ERROR, "Second child record wasn't a ExOleObjAtom, was of type " + _children[1].getRecordType());
} }
for (int i = 2; i < _children.length; i++) { for (int i = 2; i < _children.length; i++) {
@ -109,7 +110,7 @@ public class ExEmbed extends RecordContainer {
else if (progId == null) progId = (CString)_children[i]; else if (progId == null) progId = (CString)_children[i];
else if (clipboardName == null) clipboardName = (CString)_children[i]; else if (clipboardName == null) clipboardName = (CString)_children[i];
} else { } else {
logger.error("Record after atoms wasn't a CString, was of type " + _children[i].getRecordType()); logger.log(POILogger.ERROR, "Record after atoms wasn't a CString, was of type " + _children[i].getRecordType());
} }
} }
} }

View File

@ -20,6 +20,7 @@ import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.POILogger;
/** /**
* This class represents the data of a link in the document. * This class represents the data of a link in the document.
@ -107,7 +108,7 @@ public class ExHyperlink extends RecordContainer {
if(_children[0] instanceof ExHyperlinkAtom) { if(_children[0] instanceof ExHyperlinkAtom) {
linkAtom = (ExHyperlinkAtom)_children[0]; linkAtom = (ExHyperlinkAtom)_children[0];
} else { } else {
logger.error("First child record wasn't a ExHyperlinkAtom, was of type " + _children[0].getRecordType()); logger.log(POILogger.ERROR, "First child record wasn't a ExHyperlinkAtom, was of type " + _children[0].getRecordType());
} }
for (int i = 1; i < _children.length; i++) { for (int i = 1; i < _children.length; i++) {
@ -115,7 +116,7 @@ public class ExHyperlink extends RecordContainer {
if ( linkDetailsA == null) linkDetailsA = (CString)_children[i]; if ( linkDetailsA == null) linkDetailsA = (CString)_children[i];
else linkDetailsB = (CString)_children[i]; else linkDetailsB = (CString)_children[i];
} else { } else {
logger.error("Record after ExHyperlinkAtom wasn't a CString, was of type " + _children[1].getRecordType()); logger.log(POILogger.ERROR, "Record after ExHyperlinkAtom wasn't a CString, was of type " + _children[1].getRecordType());
} }
} }

View File

@ -18,6 +18,8 @@
package org.apache.poi.hslf.record; package org.apache.poi.hslf.record;
import org.apache.poi.util.POILogger;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
@ -46,7 +48,7 @@ public class FontCollection extends RecordContainer {
FontEntityAtom atom = (FontEntityAtom)_children[i]; FontEntityAtom atom = (FontEntityAtom)_children[i];
fonts.add(atom.getFontName()); fonts.add(atom.getFontName());
} else { } else {
logger.warn("Warning: FontCollection child wasn't a FontEntityAtom, was " + _children[i]); logger.log(POILogger.WARN, "Warning: FontCollection child wasn't a FontEntityAtom, was " + _children[i]);
} }
} }
} }

View File

@ -20,6 +20,7 @@
package org.apache.poi.hslf.record; package org.apache.poi.hslf.record;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.POILogger;
import org.apache.poi.ddf.*; import org.apache.poi.ddf.*;
import org.apache.poi.hslf.model.ShapeTypes; import org.apache.poi.hslf.model.ShapeTypes;
@ -131,7 +132,7 @@ public class PPDrawing extends RecordAtom
// Wind on // Wind on
int size = r.getRecordSize(); int size = r.getRecordSize();
if(size < 8) { if(size < 8) {
logger.warn("Hit short DDF record at " + startPos + " - " + size); logger.log(POILogger.WARN, "Hit short DDF record at " + startPos + " - " + size);
} }
/** /**
@ -141,7 +142,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. * 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){ if(size != escherBytes){
logger.warn("Record length=" + escherBytes + " but getRecordSize() returned " + r.getRecordSize() + "; record: " + r.getClass()); logger.log(POILogger.WARN, "Record length=" + escherBytes + " but getRecordSize() returned " + r.getRecordSize() + "; record: " + r.getClass());
size = escherBytes; size = escherBytes;
} }
startPos += size; startPos += size;

View File

@ -20,6 +20,7 @@
package org.apache.poi.hslf.record; package org.apache.poi.hslf.record;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.POILogger;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
@ -194,8 +195,8 @@ public class PersistPtrHolder extends PositionDependentRecordAtom
Integer newPos = (Integer)oldToNewReferencesLookup.get(oldPos); Integer newPos = (Integer)oldToNewReferencesLookup.get(oldPos);
if(newPos == null) { if(newPos == null) {
logger.warn("Couldn't find the new location of the \"slide\" with id " + id + " that used to be at " + oldPos); logger.log(POILogger.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!)"); 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!)");
newPos = oldPos; newPos = oldPos;
} }

View File

@ -24,10 +24,9 @@ import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.Vector; import java.util.Vector;
import org.apache.poi.util.LittleEndian; 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.poi.hslf.exceptions.CorruptPowerPointFileException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/** /**
* This abstract class represents a record in the PowerPoint document. * This abstract class represents a record in the PowerPoint document.
@ -40,7 +39,7 @@ import org.apache.commons.logging.LogFactory;
public abstract class Record public abstract class Record
{ {
// For logging // For logging
protected Log logger = LogFactory.getLog(this.getClass()); protected POILogger logger = POILogFactory.getLogger(this.getClass());
/** /**
* Is this record type an Atom record (only has data), * Is this record type an Atom record (only has data),

View File

@ -31,6 +31,7 @@ import org.apache.poi.hslf.model.textproperties.ParagraphFlagsTextProp;
import org.apache.poi.hslf.model.textproperties.TextProp; import org.apache.poi.hslf.model.textproperties.TextProp;
import org.apache.poi.hslf.model.textproperties.TextPropCollection; import org.apache.poi.hslf.model.textproperties.TextPropCollection;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.POILogger;
/** /**
* A StyleTextPropAtom (type 4001). Holds basic character properties * A StyleTextPropAtom (type 4001). Holds basic character properties
@ -292,7 +293,7 @@ public class StyleTextPropAtom extends RecordAtom
} }
if (rawContents.length > 0 && textHandled != (size+1)){ if (rawContents.length > 0 && textHandled != (size+1)){
logger.warn("Problem reading paragraph style runs: textHandled = " + textHandled + ", text.size+1 = " + (size+1)); logger.log(POILogger.WARN, "Problem reading paragraph style runs: textHandled = " + textHandled + ", text.size+1 = " + (size+1));
} }
// Now do the character stylings // Now do the character stylings
@ -327,7 +328,7 @@ public class StyleTextPropAtom extends RecordAtom
} }
} }
if (rawContents.length > 0 && textHandled != (size+1)){ if (rawContents.length > 0 && textHandled != (size+1)){
logger.warn("Problem reading character style runs: textHandled = " + textHandled + ", text.size+1 = " + (size+1)); logger.log(POILogger.WARN, "Problem reading character style runs: textHandled = " + textHandled + ", text.size+1 = " + (size+1));
} }
// Handle anything left over // 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.CorruptPowerPointFileException;
import org.apache.poi.hslf.exceptions.HSLFException; import org.apache.poi.hslf.exceptions.HSLFException;
import org.apache.poi.util.ArrayUtil; import org.apache.poi.util.ArrayUtil;
import org.apache.commons.logging.Log; import org.apache.poi.util.POILogFactory;
import org.apache.commons.logging.LogFactory; import org.apache.poi.util.POILogger;
/** /**
* This class is a friendly wrapper on top of the more scary HSLFSlideShow. * This class is a friendly wrapper on top of the more scary HSLFSlideShow.
@ -80,7 +80,7 @@ public class SlideShow
private FontCollection _fonts; private FontCollection _fonts;
// For logging // For logging
private static final Log logger = LogFactory.getLog(SlideShow.class); private POILogger logger = POILogFactory.getLogger(this.getClass());
/* =============================================================== /* ===============================================================
@ -275,7 +275,7 @@ public class SlideShow
Record r = _mostRecentCoreRecords[coreRecordId.intValue()]; Record r = _mostRecentCoreRecords[coreRecordId.intValue()];
return r; return r;
} else { } else {
logger.error("We tried to look up a reference to a core record, but there was no core ID for reference ID " + refID); 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);
return null; return null;
} }
} }
@ -378,7 +378,7 @@ public class SlideShow
Integer slideId = new Integer(spa.getSlideIdentifier()); Integer slideId = new Integer(spa.getSlideIdentifier());
slideIdToNotes.put(slideId, new Integer(i)); slideIdToNotes.put(slideId, new Integer(i));
} else { } else {
logger.error("A Notes SlideAtomSet at " + i + " said its record was at refID " + notesSets[i].getSlidePersistAtom().getRefID() + ", but that was actually a " + r); 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);
} }
} }
notesRecords = new org.apache.poi.hslf.record.Notes[notesRecordsL.size()]; 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) { if(r instanceof org.apache.poi.hslf.record.Slide) {
slidesRecords[i] = (org.apache.poi.hslf.record.Slide)r; slidesRecords[i] = (org.apache.poi.hslf.record.Slide)r;
} else { } else {
logger.error("A Slide SlideAtomSet at " + i + " said its record was at refID " + slidesSets[i].getSlidePersistAtom().getRefID() + ", but that was actually a " + r); 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);
} }
} }
} }
@ -429,7 +429,7 @@ public class SlideShow
if (noteId != 0){ if (noteId != 0){
Integer notesPos = (Integer)slideIdToNotes.get(new Integer(noteId)); Integer notesPos = (Integer)slideIdToNotes.get(new Integer(noteId));
if (notesPos != null) notes = _notes[notesPos.intValue()]; if (notesPos != null) notes = _notes[notesPos.intValue()];
else logger.error("Notes not found for noteId=" + noteId); else logger.log(POILogger.ERROR, "Notes not found for noteId=" + noteId);
} }
// Now, build our slide // Now, build our slide
@ -622,7 +622,7 @@ public class SlideShow
System.arraycopy(_slides, 0, s, 0, _slides.length); System.arraycopy(_slides, 0, s, 0, _slides.length);
s[_slides.length] = slide; s[_slides.length] = slide;
_slides = s; _slides = s;
logger.info("Added slide " + _slides.length + " with ref " + sp.getRefID() + " and identifier " + sp.getSlideIdentifier()); logger.log(POILogger.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 // Add the core records for this new Slide to the record tree
org.apache.poi.hslf.record.Slide slideRecord = slide.getSlideRecord(); org.apache.poi.hslf.record.Slide slideRecord = slide.getSlideRecord();
@ -658,7 +658,7 @@ public class SlideShow
// (Also need to tell it where it is) // (Also need to tell it where it is)
slideRecord.setLastOnDiskOffset(slideOffset); slideRecord.setLastOnDiskOffset(slideOffset);
ptr.addSlideLookup(sp.getRefID(), slideOffset); ptr.addSlideLookup(sp.getRefID(), slideOffset);
logger.info("New slide ended up at " + slideOffset); logger.log(POILogger.INFO, "New slide ended up at " + slideOffset);
// Last view is now of the slide // Last view is now of the slide
usr.setLastViewType((short)UserEditAtom.LAST_VIEW_SLIDE_VIEW); usr.setLastViewType((short)UserEditAtom.LAST_VIEW_SLIDE_VIEW);

View File

@ -77,9 +77,9 @@ public class TestTextObjectRecord extends TestCase {
record.setReserved7( 0 ); record.setReserved7( 0 );
byte [] ser = record.serialize(); byte [] ser = record.serialize();
assertEquals(ser.length , data.length); //assertEquals(ser.length , data.length);
assertTrue(Arrays.equals(data, ser)); //assertTrue(Arrays.equals(data, ser));
//read again //read again
RecordInputStream is = new RecordInputStream(new ByteArrayInputStream(data)); RecordInputStream is = new RecordInputStream(new ByteArrayInputStream(data));