Bug 52628 - Replace System.err info messages with a POILogger
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1410318 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
87073d28da
commit
133c0d7c0b
@ -34,6 +34,7 @@
|
||||
|
||||
<changes>
|
||||
<release version="3.9-beta1" date="2012-??-??">
|
||||
<action dev="poi-developers" type="fix">52628 - Replace System.err info messages with a POILogger</action>
|
||||
<action dev="poi-developers" type="fix">54137 - improved performance of DataFormatter with Fractions</action>
|
||||
<action dev="poi-developers" type="fix">54099 - Ensure that CTHMerge and CTTcBorders go to poi-ooxml-schemas jar</action>
|
||||
<action dev="poi-developers" type="fix">54111 - Fixed extracting text from table cells in HSLF</action>
|
||||
|
@ -221,7 +221,7 @@ public abstract class POIDocument {
|
||||
|
||||
logger.log(POILogger.INFO, "Wrote property set " + name + " of size " + data.length);
|
||||
} catch(org.apache.poi.hpsf.WritingNotSupportedException wnse) {
|
||||
System.err.println("Couldn't write property set with name " + name + " as not supported by HPSF yet");
|
||||
logger.log( POILogger.ERROR, "Couldn't write property set with name " + name + " as not supported by HPSF yet");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,8 +17,6 @@
|
||||
|
||||
package org.apache.poi.hpsf;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
/**
|
||||
* <p>This exception is the superclass of all other unchecked
|
||||
@ -30,8 +28,8 @@ import java.io.PrintWriter;
|
||||
*/
|
||||
public class HPSFRuntimeException extends RuntimeException
|
||||
{
|
||||
|
||||
/** <p>The underlying reason for this exception - may be
|
||||
private static final long serialVersionUID = -7804271670232727159L;
|
||||
/** <p>The underlying reason for this exception - may be
|
||||
* <code>null</code>.</p> */
|
||||
private Throwable reason;
|
||||
|
||||
@ -105,44 +103,44 @@ public class HPSFRuntimeException extends RuntimeException
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @see Throwable#printStackTrace()
|
||||
*/
|
||||
public void printStackTrace()
|
||||
{
|
||||
printStackTrace(System.err);
|
||||
}
|
||||
// /**
|
||||
// * @see Throwable#printStackTrace()
|
||||
// */
|
||||
// public void printStackTrace()
|
||||
// {
|
||||
// printStackTrace(System.err);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @see Throwable#printStackTrace(java.io.PrintStream)
|
||||
*/
|
||||
public void printStackTrace(final PrintStream p)
|
||||
{
|
||||
final Throwable reason = getReason();
|
||||
super.printStackTrace(p);
|
||||
if (reason != null)
|
||||
{
|
||||
p.println("Caused by:");
|
||||
reason.printStackTrace(p);
|
||||
}
|
||||
}
|
||||
// /**
|
||||
// * @see Throwable#printStackTrace(java.io.PrintStream)
|
||||
// */
|
||||
// public void printStackTrace(final PrintStream p)
|
||||
// {
|
||||
// final Throwable reason = getReason();
|
||||
// super.printStackTrace(p);
|
||||
// if (reason != null)
|
||||
// {
|
||||
// p.println("Caused by:");
|
||||
// reason.printStackTrace(p);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @see Throwable#printStackTrace(java.io.PrintWriter)
|
||||
*/
|
||||
public void printStackTrace(final PrintWriter p)
|
||||
{
|
||||
final Throwable reason = getReason();
|
||||
super.printStackTrace(p);
|
||||
if (reason != null)
|
||||
{
|
||||
p.println("Caused by:");
|
||||
reason.printStackTrace(p);
|
||||
}
|
||||
}
|
||||
// /**
|
||||
// * @see Throwable#printStackTrace(java.io.PrintWriter)
|
||||
// */
|
||||
// public void printStackTrace(final PrintWriter p)
|
||||
// {
|
||||
// final Throwable reason = getReason();
|
||||
// super.printStackTrace(p);
|
||||
// if (reason != null)
|
||||
// {
|
||||
// p.println("Caused by:");
|
||||
// reason.printStackTrace(p);
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
@ -24,6 +24,9 @@ import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
|
||||
/**
|
||||
* <p>Supports reading and writing of variant data.</p>
|
||||
*
|
||||
@ -45,7 +48,7 @@ import java.util.List;
|
||||
*/
|
||||
public class VariantSupport extends Variant
|
||||
{
|
||||
|
||||
private static POILogger logger = POILogFactory.getLogger(VariantSupport.class);
|
||||
private static boolean logUnsupportedTypes = false;
|
||||
|
||||
/**
|
||||
@ -78,7 +81,7 @@ public class VariantSupport extends Variant
|
||||
* <p>Keeps a list of the variant types an "unsupported" message has already
|
||||
* been issued for.</p>
|
||||
*/
|
||||
protected static List unsupportedMessage;
|
||||
protected static List<Long> unsupportedMessage;
|
||||
|
||||
/**
|
||||
* <p>Writes a warning to <code>System.err</code> that a variant type is
|
||||
@ -93,11 +96,11 @@ public class VariantSupport extends Variant
|
||||
if (isLogUnsupportedTypes())
|
||||
{
|
||||
if (unsupportedMessage == null)
|
||||
unsupportedMessage = new LinkedList();
|
||||
unsupportedMessage = new LinkedList<Long>();
|
||||
Long vt = Long.valueOf(ex.getVariantType());
|
||||
if (!unsupportedMessage.contains(vt))
|
||||
{
|
||||
System.err.println(ex.getMessage());
|
||||
logger.log( POILogger.ERROR, ex.getMessage());
|
||||
unsupportedMessage.add(vt);
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,8 @@ import org.apache.poi.hssf.record.NumberRecord;
|
||||
import org.apache.poi.hssf.record.Record;
|
||||
import org.apache.poi.hssf.usermodel.HSSFDataFormat;
|
||||
import org.apache.poi.hssf.usermodel.HSSFDataFormatter;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
|
||||
/**
|
||||
* A proxy HSSFListener that keeps track of the document formatting records, and
|
||||
@ -38,6 +40,7 @@ import org.apache.poi.hssf.usermodel.HSSFDataFormatter;
|
||||
* ids.
|
||||
*/
|
||||
public class FormatTrackingHSSFListener implements HSSFListener {
|
||||
private static POILogger logger = POILogFactory.getLogger(FormatTrackingHSSFListener.class);
|
||||
private final HSSFListener _childListener;
|
||||
private final HSSFDataFormatter _formatter;
|
||||
private final NumberFormat _defaultFormat;
|
||||
@ -137,7 +140,7 @@ public class FormatTrackingHSSFListener implements HSSFListener {
|
||||
if (formatIndex >= HSSFDataFormat.getNumberOfBuiltinBuiltinFormats()) {
|
||||
FormatRecord tfr = _customFormatRecords.get(Integer.valueOf(formatIndex));
|
||||
if (tfr == null) {
|
||||
System.err.println("Requested format at index " + formatIndex
|
||||
logger.log( POILogger.ERROR, "Requested format at index " + formatIndex
|
||||
+ ", but it wasn't found");
|
||||
} else {
|
||||
format = tfr.getFormatString();
|
||||
@ -167,7 +170,7 @@ public class FormatTrackingHSSFListener implements HSSFListener {
|
||||
public int getFormatIndex(CellValueRecordInterface cell) {
|
||||
ExtendedFormatRecord xfr = _xfRecords.get(cell.getXFIndex());
|
||||
if (xfr == null) {
|
||||
System.err.println("Cell " + cell.getRow() + "," + cell.getColumn()
|
||||
logger.log( POILogger.ERROR, "Cell " + cell.getRow() + "," + cell.getColumn()
|
||||
+ " uses XF with index " + cell.getXFIndex() + ", but we don't have that");
|
||||
return -1;
|
||||
}
|
||||
|
@ -29,6 +29,8 @@ import org.apache.poi.util.LittleEndian;
|
||||
import org.apache.poi.util.LittleEndianInput;
|
||||
import org.apache.poi.util.LittleEndianInputStream;
|
||||
import org.apache.poi.util.LittleEndianOutput;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
import org.apache.poi.util.StringUtil;
|
||||
|
||||
/**
|
||||
@ -39,6 +41,7 @@ import org.apache.poi.util.StringUtil;
|
||||
* @author Daniel Noll
|
||||
*/
|
||||
public final class EmbeddedObjectRefSubRecord extends SubRecord {
|
||||
private static POILogger logger = POILogFactory.getLogger(EmbeddedObjectRefSubRecord.class);
|
||||
public static final short sid = 0x0009;
|
||||
|
||||
private static final byte[] EMPTY_BYTE_ARRAY = { };
|
||||
@ -137,7 +140,7 @@ public final class EmbeddedObjectRefSubRecord extends SubRecord {
|
||||
int nUnexpectedPadding = remaining - dataLenAfterFormula;
|
||||
|
||||
if (nUnexpectedPadding > 0) {
|
||||
System.err.println("Discarding " + nUnexpectedPadding + " unexpected padding bytes ");
|
||||
logger.log( POILogger.ERROR, "Discarding " + nUnexpectedPadding + " unexpected padding bytes ");
|
||||
readRawData(in, nUnexpectedPadding);
|
||||
remaining-=nUnexpectedPadding;
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ import org.apache.poi.hssf.record.common.FtrHeader;
|
||||
import org.apache.poi.hssf.record.common.SharedFeature;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.util.LittleEndianOutput;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
|
||||
/**
|
||||
* Title: Feat (Feature) Record
|
||||
@ -32,6 +34,7 @@ import org.apache.poi.util.LittleEndianOutput;
|
||||
* up with a {@link FeatHdrRecord}.
|
||||
*/
|
||||
public final class FeatRecord extends StandardRecord {
|
||||
private static POILogger logger = POILogFactory.getLogger(FeatRecord.class);
|
||||
public final static short sid = 0x0868;
|
||||
|
||||
private FtrHeader futureHeader;
|
||||
@ -90,7 +93,7 @@ public final class FeatRecord extends StandardRecord {
|
||||
sharedFeature = new FeatSmartTag(in);
|
||||
break;
|
||||
default:
|
||||
System.err.println("Unknown Shared Feature " + isf_sharedFeatureType + " found!");
|
||||
logger.log( POILogger.ERROR, "Unknown Shared Feature " + isf_sharedFeatureType + " found!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ import org.apache.poi.util.StringUtil;
|
||||
*/
|
||||
public final class HyperlinkRecord extends StandardRecord {
|
||||
public final static short sid = 0x01B8;
|
||||
private POILogger logger = POILogFactory.getLogger(getClass());
|
||||
private static POILogger logger = POILogFactory.getLogger(HyperlinkRecord.class);
|
||||
|
||||
static final class GUID {
|
||||
/*
|
||||
@ -641,7 +641,7 @@ public final class HyperlinkRecord extends StandardRecord {
|
||||
if (false) { // Quite a few examples in the unit tests which don't have the exact expected tail
|
||||
for (int i = 0; i < expectedTail.length; i++) {
|
||||
if (expectedTail[i] != result[i]) {
|
||||
System.err.println("Mismatch in tail byte [" + i + "]"
|
||||
logger.log( POILogger.ERROR, "Mismatch in tail byte [" + i + "]"
|
||||
+ "expected " + (expectedTail[i] & 0xFF) + " but got " + (result[i] & 0xFF));
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,8 @@ package org.apache.poi.hssf.record;
|
||||
|
||||
import org.apache.poi.hssf.record.common.UnicodeString;
|
||||
import org.apache.poi.util.IntMapper;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
|
||||
/**
|
||||
* Handles the task of deserializing a SST string. The two main entry points are
|
||||
@ -30,7 +32,7 @@ import org.apache.poi.util.IntMapper;
|
||||
*/
|
||||
class SSTDeserializer
|
||||
{
|
||||
|
||||
private static POILogger logger = POILogFactory.getLogger(SSTDeserializer.class);
|
||||
private IntMapper<UnicodeString> strings;
|
||||
|
||||
public SSTDeserializer( IntMapper<UnicodeString> strings )
|
||||
@ -49,7 +51,7 @@ class SSTDeserializer
|
||||
// Extract exactly the count of strings from the SST record.
|
||||
UnicodeString str;
|
||||
if(in.available() == 0 && ! in.hasNextRecord()) {
|
||||
System.err.println("Ran out of data before creating all the strings! String at index " + i + "");
|
||||
logger.log( POILogger.ERROR, "Ran out of data before creating all the strings! String at index " + i + "");
|
||||
str = new UnicodeString("");
|
||||
} else {
|
||||
str = new UnicodeString(in);
|
||||
|
@ -179,7 +179,7 @@ public class UnicodeString implements Comparable<UnicodeString> { // TODO - make
|
||||
|
||||
int extraDataLength = runData - (numRuns*6);
|
||||
if(extraDataLength < 0) {
|
||||
System.err.println("Warning - ExtRst overran by " + (0-extraDataLength) + " bytes");
|
||||
_logger.log( POILogger.WARN, "Warning - ExtRst overran by " + (0-extraDataLength) + " bytes");
|
||||
extraDataLength = 0;
|
||||
}
|
||||
extraData = new byte[extraDataLength];
|
||||
|
@ -34,6 +34,8 @@ import org.apache.poi.ss.formula.FormulaParsingWorkbook;
|
||||
import org.apache.poi.ss.formula.FormulaRenderingWorkbook;
|
||||
import org.apache.poi.ss.formula.FormulaType;
|
||||
import org.apache.poi.ss.formula.udf.UDFFinder;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
|
||||
/**
|
||||
* Internal POI use only
|
||||
@ -41,7 +43,7 @@ import org.apache.poi.ss.formula.udf.UDFFinder;
|
||||
* @author Josh Micich
|
||||
*/
|
||||
public final class HSSFEvaluationWorkbook implements FormulaRenderingWorkbook, EvaluationWorkbook, FormulaParsingWorkbook {
|
||||
|
||||
private static POILogger logger = POILogFactory.getLogger(HSSFEvaluationWorkbook.class);
|
||||
private final HSSFWorkbook _uBook;
|
||||
private final InternalWorkbook _iBook;
|
||||
|
||||
@ -139,7 +141,7 @@ public final class HSSFEvaluationWorkbook implements FormulaRenderingWorkbook, E
|
||||
// Note - as of Bugzilla 48036 (svn r828244, r828247) POI is capable of evaluating
|
||||
// IntesectionPtg. However it is still not capable of parsing it.
|
||||
// So FormulaEvalTestData.xls now contains a few formulas that produce errors here.
|
||||
System.err.println(e.getMessage());
|
||||
logger.log( POILogger.ERROR, e.getMessage());
|
||||
}
|
||||
}
|
||||
FormulaRecordAggregate fra = (FormulaRecordAggregate) cell.getCellValueRecord();
|
||||
|
@ -27,6 +27,8 @@ import org.apache.poi.hssf.record.EscherAggregate;
|
||||
import org.apache.poi.hssf.record.ObjRecord;
|
||||
import org.apache.poi.ss.usermodel.Picture;
|
||||
import org.apache.poi.ss.util.ImageUtils;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
import org.apache.poi.hssf.model.InternalWorkbook;
|
||||
|
||||
/**
|
||||
@ -36,6 +38,8 @@ import org.apache.poi.hssf.model.InternalWorkbook;
|
||||
* @author Yegor Kozlov (yegor at apache.org)
|
||||
*/
|
||||
public class HSSFPicture extends HSSFSimpleShape implements Picture {
|
||||
private static POILogger logger = POILogFactory.getLogger(HSSFPicture.class);
|
||||
|
||||
public static final int PICTURE_TYPE_EMF = HSSFWorkbook.PICTURE_TYPE_EMF; // Windows Enhanced Metafile
|
||||
public static final int PICTURE_TYPE_WMF = HSSFWorkbook.PICTURE_TYPE_WMF; // Windows Metafile
|
||||
public static final int PICTURE_TYPE_PICT = HSSFWorkbook.PICTURE_TYPE_PICT; // Macintosh PICT
|
||||
@ -283,7 +287,7 @@ public class HSSFPicture extends HSSFSimpleShape implements Picture {
|
||||
EscherComplexProperty prop = new EscherComplexProperty(EscherProperties.BLIP__BLIPFILENAME, true, data.getBytes("UTF-16LE"));
|
||||
setPropertyValue(prop);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
System.out.println("Unsupported encoding: UTF-16LE");
|
||||
logger.log( POILogger.ERROR, "Unsupported encoding: UTF-16LE");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,12 +20,14 @@ package org.apache.poi.hssf.usermodel;
|
||||
import org.apache.poi.ddf.*;
|
||||
import org.apache.poi.hssf.record.*;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
|
||||
/**
|
||||
* @author Glen Stampoultzis (glens at superlinksoftware.com)
|
||||
*/
|
||||
public class HSSFPolygon extends HSSFSimpleShape {
|
||||
|
||||
private static POILogger logger = POILogFactory.getLogger(HSSFPolygon.class);
|
||||
public final static short OBJECT_TYPE_MICROSOFT_OFFICE_DRAWING = 0x1E;
|
||||
|
||||
public HSSFPolygon(EscherContainerRecord spContainer, ObjRecord objRecord, TextObjectRecord _textObjectRecord) {
|
||||
@ -157,11 +159,11 @@ public class HSSFPolygon extends HSSFSimpleShape {
|
||||
*/
|
||||
public void setPoints(int[] xPoints, int[] yPoints) {
|
||||
if (xPoints.length != yPoints.length){
|
||||
System.out.println("xPoint.length must be equal to yPoints.length");
|
||||
logger.log( POILogger.ERROR, "xPoint.length must be equal to yPoints.length");
|
||||
return;
|
||||
}
|
||||
if (xPoints.length == 0){
|
||||
System.out.println("HSSFPolygon must have at least one point");
|
||||
logger.log( POILogger.ERROR, "HSSFPolygon must have at least one point");
|
||||
}
|
||||
EscherArrayProperty verticesProp = new EscherArrayProperty(EscherProperties.GEOMETRY__VERTICES, false, new byte[0] );
|
||||
verticesProp.setNumberOfElementsInArray(xPoints.length+1);
|
||||
|
@ -36,7 +36,7 @@ public class EntryUtils
|
||||
public static void copyNodeRecursively( Entry entry, DirectoryEntry target )
|
||||
throws IOException
|
||||
{
|
||||
// System.err.println("copyNodeRecursively called with "+entry.getName()+
|
||||
// logger.log( POILogger.ERROR, "copyNodeRecursively called with "+entry.getName()+
|
||||
// ","+target.getName());
|
||||
DirectoryEntry newTarget = null;
|
||||
if ( entry.isDirectoryEntry() )
|
||||
|
@ -18,6 +18,8 @@
|
||||
package org.apache.poi.ss.formula.constant;
|
||||
|
||||
import org.apache.poi.ss.usermodel.ErrorConstants;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
/**
|
||||
* Represents a constant error code value as encoded in a constant values array. <p/>
|
||||
*
|
||||
@ -27,6 +29,7 @@ import org.apache.poi.ss.usermodel.ErrorConstants;
|
||||
* @author Josh Micich
|
||||
*/
|
||||
public class ErrorConstant {
|
||||
private static POILogger logger = POILogFactory.getLogger(ErrorConstant.class);
|
||||
// convenient access to name space
|
||||
private static final ErrorConstants EC = null;
|
||||
|
||||
@ -64,7 +67,7 @@ public class ErrorConstant {
|
||||
case ErrorConstants.ERROR_NUM: return NUM;
|
||||
case ErrorConstants.ERROR_NA: return NA;
|
||||
}
|
||||
System.err.println("Warning - unexpected error code (" + errorCode + ")");
|
||||
logger.log( POILogger.WARN, "Warning - unexpected error code (" + errorCode + ")");
|
||||
return new ErrorConstant(errorCode);
|
||||
}
|
||||
public String toString() {
|
||||
|
@ -24,6 +24,9 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
|
||||
/**
|
||||
* Convert java DateFormat patterns into Excel custom number formats.
|
||||
* For example, to format a date in excel using the "dd MMMM, yyyy" pattern and Japanese
|
||||
@ -45,6 +48,7 @@ import java.util.Map;
|
||||
*
|
||||
*/
|
||||
public class DateFormatConverter {
|
||||
private static POILogger logger = POILogFactory.getLogger(DateFormatConverter.class);
|
||||
|
||||
public static class DateFormatTokenizer {
|
||||
String format;
|
||||
@ -329,7 +333,7 @@ public class DateFormatConverter {
|
||||
result = localePrefixes.get( localeString.substring( 0, 2 ) );
|
||||
if( result == null ) {
|
||||
Locale parentLocale = new Locale(localeString.substring( 0, 2 ));
|
||||
System.out.println( "Unable to find prefix for " + locale + "(" + locale.getDisplayName() + ") or "
|
||||
logger.log( POILogger.ERROR, "Unable to find prefix for " + locale + "(" + locale.getDisplayName() + ") or "
|
||||
+ localeString.substring( 0, 2 ) + "(" + parentLocale.getDisplayName() + ")" );
|
||||
return "";
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public final class ChunkFactory {
|
||||
"/org/apache/poi/hdgf/chunks_parse_cmds.tbl";
|
||||
|
||||
/** For logging problems we spot with the file */
|
||||
private POILogger logger = POILogFactory.getLogger(ChunkFactory.class);
|
||||
private static POILogger logger = POILogFactory.getLogger(ChunkFactory.class);
|
||||
|
||||
public ChunkFactory(int version) throws IOException {
|
||||
this.version = version;
|
||||
@ -153,7 +153,7 @@ public final class ChunkFactory {
|
||||
data, endOfDataPos);
|
||||
endOfDataPos += 8;
|
||||
} else {
|
||||
System.err.println("Header claims a length to " + endOfDataPos + " there's then no space for the trailer in the data (" + data.length + ")");
|
||||
logger.log(POILogger.ERROR, "Header claims a length to " + endOfDataPos + " there's then no space for the trailer in the data (" + data.length + ")");
|
||||
}
|
||||
}
|
||||
if(header.hasSeparator()) {
|
||||
@ -161,7 +161,7 @@ public final class ChunkFactory {
|
||||
separator = new ChunkSeparator(
|
||||
data, endOfDataPos);
|
||||
} else {
|
||||
System.err.println("Header claims a length to " + endOfDataPos + " there's then no space for the separator in the data (" + data.length + ")");
|
||||
logger.log(POILogger.ERROR, "Header claims a length to " + endOfDataPos + " there's then no space for the separator in the data (" + data.length + ")");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,12 @@ import org.apache.poi.hdgf.chunks.Chunk;
|
||||
import org.apache.poi.hdgf.chunks.ChunkFactory;
|
||||
import org.apache.poi.hdgf.chunks.ChunkHeader;
|
||||
import org.apache.poi.hdgf.pointers.Pointer;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
|
||||
public final class ChunkStream extends Stream {
|
||||
private static POILogger logger = POILogFactory.getLogger(ChunkStream.class);
|
||||
|
||||
private ChunkFactory chunkFactory;
|
||||
/** All the Chunks we contain */
|
||||
private Chunk[] chunks;
|
||||
@ -62,14 +66,14 @@ public final class ChunkStream extends Stream {
|
||||
|
||||
pos += chunk.getOnDiskSize();
|
||||
} else {
|
||||
System.err.println("Needed " + headerSize + " bytes to create the next chunk header, but only found " + (contents.length-pos) + " bytes, ignoring rest of data");
|
||||
logger.log(POILogger.WARN, "Needed " + headerSize + " bytes to create the next chunk header, but only found " + (contents.length-pos) + " bytes, ignoring rest of data");
|
||||
pos = contents.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.err.println("Failed to create chunk at " + pos + ", ignoring rest of data." + e);
|
||||
logger.log(POILogger.ERROR, "Failed to create chunk at " + pos + ", ignoring rest of data." + e);
|
||||
}
|
||||
|
||||
chunks = chunksA.toArray(new Chunk[chunksA.size()]);
|
||||
|
@ -24,12 +24,15 @@ import org.apache.poi.hmef.HMEFMessage;
|
||||
import org.apache.poi.hpsf.Util;
|
||||
import org.apache.poi.hsmf.datatypes.MAPIProperty;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
|
||||
/**
|
||||
* A pure-MAPI attribute holding a Date, which applies
|
||||
* to a {@link HMEFMessage} or one of its {@link Attachment}s.
|
||||
*/
|
||||
public final class MAPIDateAttribute extends MAPIAttribute {
|
||||
private static POILogger logger = POILogFactory.getLogger(MAPIDateAttribute.class);
|
||||
private Date data;
|
||||
|
||||
/**
|
||||
@ -64,7 +67,7 @@ public final class MAPIDateAttribute extends MAPIAttribute {
|
||||
return ((MAPIDateAttribute)attr).getDate();
|
||||
}
|
||||
|
||||
System.err.println("Warning, non date property found: " + attr.toString());
|
||||
logger.log(POILogger.WARN, "Warning, non date property found: " + attr.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ import org.apache.poi.hmef.Attachment;
|
||||
import org.apache.poi.hmef.HMEFMessage;
|
||||
import org.apache.poi.hsmf.datatypes.MAPIProperty;
|
||||
import org.apache.poi.hsmf.datatypes.Types;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
import org.apache.poi.util.StringUtil;
|
||||
|
||||
/**
|
||||
@ -30,6 +32,7 @@ import org.apache.poi.util.StringUtil;
|
||||
* to a {@link HMEFMessage} or one of its {@link Attachment}s.
|
||||
*/
|
||||
public final class MAPIStringAttribute extends MAPIAttribute {
|
||||
private static POILogger logger = POILogFactory.getLogger(MAPIStringAttribute.class);
|
||||
private static final String CODEPAGE = "CP1252";
|
||||
private final String data;
|
||||
|
||||
@ -78,7 +81,7 @@ public final class MAPIStringAttribute extends MAPIAttribute {
|
||||
return ((MAPIRtfAttribute)attr).getDataString();
|
||||
}
|
||||
|
||||
System.err.println("Warning, non string property found: " + attr.toString());
|
||||
logger.log(POILogger.WARN, "Warning, non string property found: " + attr.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -27,12 +27,15 @@ import org.apache.poi.hmef.Attachment;
|
||||
import org.apache.poi.hmef.HMEFMessage;
|
||||
import org.apache.poi.hpsf.Util;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
|
||||
/**
|
||||
* A Date attribute which applies to a {@link HMEFMessage}
|
||||
* or one of its {@link Attachment}s.
|
||||
*/
|
||||
public final class TNEFDateAttribute extends TNEFAttribute {
|
||||
private static POILogger logger = POILogFactory.getLogger(TNEFDateAttribute.class);
|
||||
private Date data;
|
||||
|
||||
/**
|
||||
@ -85,7 +88,7 @@ public final class TNEFDateAttribute extends TNEFAttribute {
|
||||
return ((TNEFDateAttribute)attr).getDate();
|
||||
}
|
||||
|
||||
System.err.println("Warning, non date property found: " + attr.toString());
|
||||
logger.log(POILogger.WARN, "Warning, non date property found: " + attr.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,8 @@ import java.io.InputStream;
|
||||
|
||||
import org.apache.poi.hmef.Attachment;
|
||||
import org.apache.poi.hmef.HMEFMessage;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
import org.apache.poi.util.StringUtil;
|
||||
|
||||
/**
|
||||
@ -29,6 +31,7 @@ import org.apache.poi.util.StringUtil;
|
||||
* or one of its {@link Attachment}s.
|
||||
*/
|
||||
public final class TNEFStringAttribute extends TNEFAttribute {
|
||||
private static POILogger logger = POILogFactory.getLogger(TNEFStringAttribute.class);
|
||||
private String data;
|
||||
|
||||
/**
|
||||
@ -75,7 +78,7 @@ public final class TNEFStringAttribute extends TNEFAttribute {
|
||||
return ((TNEFStringAttribute)attr).getString();
|
||||
}
|
||||
|
||||
System.err.println("Warning, non string property found: " + attr.toString());
|
||||
logger.log(POILogger.WARN, "Warning, non string property found: " + attr.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,8 @@ package org.apache.poi.hslf.model;
|
||||
import org.apache.poi.ddf.*;
|
||||
import org.apache.poi.hslf.record.*;
|
||||
import org.apache.poi.hslf.usermodel.SlideShow;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
@ -35,6 +37,8 @@ import java.awt.*;
|
||||
*/
|
||||
|
||||
public abstract class Sheet {
|
||||
private static POILogger logger = POILogFactory.getLogger(Sheet.class);
|
||||
|
||||
/**
|
||||
* The <code>SlideShow</code> we belong to
|
||||
*/
|
||||
@ -194,7 +198,7 @@ public abstract class Sheet {
|
||||
} else if (records[i + 1].getRecordType() == 4010l) {
|
||||
// TextSpecInfoAtom - Safe to ignore
|
||||
} else {
|
||||
System.err.println("Found a TextHeaderAtom not followed by a TextBytesAtom or TextCharsAtom: Followed by " + records[i + 1].getRecordType());
|
||||
logger.log(POILogger.ERROR, "Found a TextHeaderAtom not followed by a TextBytesAtom or TextCharsAtom: Followed by " + records[i + 1].getRecordType());
|
||||
}
|
||||
|
||||
if (trun != null) {
|
||||
|
@ -23,6 +23,8 @@ package org.apache.poi.hslf.record;
|
||||
import java.io.*;
|
||||
import org.apache.poi.poifs.filesystem.*;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
import org.apache.poi.util.StringUtil;
|
||||
import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException;
|
||||
import org.apache.poi.hslf.exceptions.EncryptedPowerPointFileException;
|
||||
@ -39,6 +41,8 @@ import org.apache.poi.hslf.exceptions.OldPowerPointFormatException;
|
||||
|
||||
public class CurrentUserAtom
|
||||
{
|
||||
private static POILogger logger = POILogFactory.getLogger(CurrentUserAtom.class);
|
||||
|
||||
/** Standard Atom header */
|
||||
public static final byte[] atomHeader = new byte[] { 0, 0, -10, 15 };
|
||||
/** The PowerPoint magic number for a non-encrypted file */
|
||||
@ -128,7 +132,7 @@ public class CurrentUserAtom
|
||||
if(_contents.length >= 4) {
|
||||
// PPT95 has 4 byte size, then data
|
||||
int size = LittleEndian.getInt(_contents);
|
||||
System.err.println(size);
|
||||
//System.err.println(size);
|
||||
if(size + 4 == _contents.length) {
|
||||
throw new OldPowerPointFormatException("Based on the Current User stream, you seem to have supplied a PowerPoint95 file, which isn't supported");
|
||||
}
|
||||
@ -173,7 +177,7 @@ public class CurrentUserAtom
|
||||
long usernameLen = LittleEndian.getUShort(_contents,20);
|
||||
if(usernameLen > 512) {
|
||||
// Handle the case of it being garbage
|
||||
System.err.println("Warning - invalid username length " + usernameLen + " found, treating as if there was no username set");
|
||||
logger.log(POILogger.WARN, "Warning - invalid username length " + usernameLen + " found, treating as if there was no username set");
|
||||
usernameLen = 0;
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ import org.apache.poi.util.POILogger;
|
||||
public abstract class Record
|
||||
{
|
||||
// For logging
|
||||
protected POILogger logger = POILogFactory.getLogger(this.getClass());
|
||||
protected static POILogger logger = POILogFactory.getLogger(Record.class);
|
||||
|
||||
/**
|
||||
* Is this record type an Atom record (only has data),
|
||||
@ -155,7 +155,7 @@ public abstract class Record
|
||||
// Handle case of a corrupt last record, whose claimed length
|
||||
// would take us passed the end of the file
|
||||
if(start + len > b.length) {
|
||||
System.err.println("Warning: Skipping record of type " + type + " at position " + start + " which claims to be longer than the file! (" + len + " vs " + (b.length-start) + ")");
|
||||
logger.log(POILogger.WARN, "Warning: Skipping record of type " + type + " at position " + start + " which claims to be longer than the file! (" + len + " vs " + (b.length-start) + ")");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -37,11 +37,14 @@ import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.hsmf.MAPIMessage;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
|
||||
/**
|
||||
* Collection of convenence chunks for standard parts of the MSG file attachment.
|
||||
*/
|
||||
public class AttachmentChunks implements ChunkGroup {
|
||||
private static POILogger logger = POILogFactory.getLogger(AttachmentChunks.class);
|
||||
public static final String PREFIX = "__attach_version1.0_#";
|
||||
|
||||
public ByteChunk attachData;
|
||||
@ -131,7 +134,7 @@ public class AttachmentChunks implements ChunkGroup {
|
||||
} else if(chunk instanceof DirectoryChunk) {
|
||||
attachmentDirectory = (DirectoryChunk)chunk;
|
||||
} else {
|
||||
System.err.println("Unexpected data chunk of type " + chunk);
|
||||
logger.log(POILogger.ERROR, "Unexpected data chunk of type " + chunk);
|
||||
}
|
||||
}
|
||||
else if(chunk.getChunkId() == ATTACH_DISPOSITION.id) {
|
||||
|
@ -26,6 +26,8 @@ import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.poi.hsmf.datatypes.Types.MAPIType;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
|
||||
/**
|
||||
* A Chunk that holds the details given back by the
|
||||
@ -36,6 +38,7 @@ import org.apache.poi.util.IOUtils;
|
||||
*/
|
||||
|
||||
public class MessageSubmissionChunk extends Chunk {
|
||||
private static POILogger logger = POILogFactory.getLogger(MessageSubmissionChunk.class);
|
||||
private String rawId;
|
||||
private Calendar date;
|
||||
|
||||
@ -87,7 +90,7 @@ public class MessageSubmissionChunk extends Chunk {
|
||||
date.set(Calendar.SECOND, Integer.parseInt(m.group(6)));
|
||||
date.set(Calendar.MILLISECOND, 0);
|
||||
} else {
|
||||
System.err.println("Warning - unable to make sense of date " + dateS);
|
||||
logger.log(POILogger.WARN, "Warning - unable to make sense of date " + dateS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,9 @@ import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
|
||||
|
||||
/**
|
||||
* Collection of convenience chunks for the
|
||||
@ -30,6 +33,8 @@ import java.util.List;
|
||||
* several of these.
|
||||
*/
|
||||
public final class RecipientChunks implements ChunkGroup {
|
||||
private static POILogger logger = POILogFactory.getLogger(RecipientChunks.class);
|
||||
|
||||
public static final String PREFIX = "__recip_version1.0_#";
|
||||
|
||||
public static final MAPIProperty RECIPIENT_NAME = MAPIProperty.DISPLAY_NAME;
|
||||
@ -82,7 +87,7 @@ public final class RecipientChunks implements ChunkGroup {
|
||||
try {
|
||||
recipientNumber = Integer.parseInt(number, 16);
|
||||
} catch(NumberFormatException e) {
|
||||
System.err.println("Invalid recipient number in name " + name);
|
||||
logger.log(POILogger.ERROR, "Invalid recipient number in name " + name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,8 @@ import org.apache.poi.poifs.filesystem.DocumentInputStream;
|
||||
import org.apache.poi.poifs.filesystem.DocumentNode;
|
||||
import org.apache.poi.poifs.filesystem.Entry;
|
||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
|
||||
/**
|
||||
* Processes a POIFS of a .msg file into groups of Chunks, such as
|
||||
@ -48,6 +50,8 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||
* data and so on.
|
||||
*/
|
||||
public final class POIFSChunkParser {
|
||||
private static POILogger logger = POILogFactory.getLogger(POIFSChunkParser.class);
|
||||
|
||||
public static ChunkGroup[] parse(POIFSFileSystem fs) throws IOException {
|
||||
return parse(fs.getRoot());
|
||||
}
|
||||
@ -200,7 +204,7 @@ public final class POIFSChunkParser {
|
||||
chunk.readValue(inp);
|
||||
grouping.record(chunk);
|
||||
} catch(IOException e) {
|
||||
System.err.println("Error reading from part " + entry.getName() + " - " + e.toString());
|
||||
logger.log(POILogger.ERROR, "Error reading from part " + entry.getName() + " - " + e.toString());
|
||||
}
|
||||
} else {
|
||||
grouping.record(chunk);
|
||||
|
@ -453,7 +453,7 @@ public class AbstractWordUtils
|
||||
{
|
||||
|
||||
if ( format != 0 )
|
||||
System.err.println( "NYI: toListItemNumberLabel(): " + format );
|
||||
logger.log( POILogger.INFO, "NYI: toListItemNumberLabel(): " + format );
|
||||
|
||||
return String.valueOf( number );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user