Add some @Overrides suggested by Eclipse, generics and some warnings,
convert some tabs to spaces. git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1553466 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3f39b60f53
commit
60ca1a5de4
@ -27,106 +27,109 @@ import org.apache.poi.util.LittleEndianOutput;
|
|||||||
* @author Josh Micich
|
* @author Josh Micich
|
||||||
*/
|
*/
|
||||||
public abstract class CellRecord extends StandardRecord implements CellValueRecordInterface {
|
public abstract class CellRecord extends StandardRecord implements CellValueRecordInterface {
|
||||||
private int _rowIndex;
|
private int _rowIndex;
|
||||||
private int _columnIndex;
|
private int _columnIndex;
|
||||||
private int _formatIndex;
|
private int _formatIndex;
|
||||||
|
|
||||||
protected CellRecord() {
|
protected CellRecord() {
|
||||||
// fields uninitialised
|
// fields uninitialised
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CellRecord(RecordInputStream in) {
|
protected CellRecord(RecordInputStream in) {
|
||||||
_rowIndex = in.readUShort();
|
_rowIndex = in.readUShort();
|
||||||
_columnIndex = in.readUShort();
|
_columnIndex = in.readUShort();
|
||||||
_formatIndex = in.readUShort();
|
_formatIndex = in.readUShort();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setRow(int row) {
|
public final void setRow(int row) {
|
||||||
_rowIndex = row;
|
_rowIndex = row;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setColumn(short col) {
|
public final void setColumn(short col) {
|
||||||
_columnIndex = col;
|
_columnIndex = col;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set the index to the ExtendedFormat
|
* set the index to the ExtendedFormat
|
||||||
*
|
*
|
||||||
* @see org.apache.poi.hssf.record.ExtendedFormatRecord
|
* @see org.apache.poi.hssf.record.ExtendedFormatRecord
|
||||||
* @param xf index to the XF record
|
* @param xf index to the XF record
|
||||||
*/
|
*/
|
||||||
public final void setXFIndex(short xf) {
|
public final void setXFIndex(short xf) {
|
||||||
_formatIndex = xf;
|
_formatIndex = xf;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int getRow() {
|
public final int getRow() {
|
||||||
return _rowIndex;
|
return _rowIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final short getColumn() {
|
public final short getColumn() {
|
||||||
return (short) _columnIndex;
|
return (short) _columnIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the index to the ExtendedFormat
|
* get the index to the ExtendedFormat
|
||||||
*
|
*
|
||||||
* @see org.apache.poi.hssf.record.ExtendedFormatRecord
|
* @see org.apache.poi.hssf.record.ExtendedFormatRecord
|
||||||
* @return index to the XF record
|
* @return index to the XF record
|
||||||
*/
|
*/
|
||||||
public final short getXFIndex() {
|
public final short getXFIndex() {
|
||||||
return (short) _formatIndex;
|
return (short) _formatIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String toString() {
|
@Override
|
||||||
StringBuilder sb = new StringBuilder();
|
public final String toString() {
|
||||||
String recordName = getRecordName();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
String recordName = getRecordName();
|
||||||
|
|
||||||
sb.append("[").append(recordName).append("]\n");
|
sb.append("[").append(recordName).append("]\n");
|
||||||
sb.append(" .row = ").append(HexDump.shortToHex(getRow())).append("\n");
|
sb.append(" .row = ").append(HexDump.shortToHex(getRow())).append("\n");
|
||||||
sb.append(" .col = ").append(HexDump.shortToHex(getColumn())).append("\n");
|
sb.append(" .col = ").append(HexDump.shortToHex(getColumn())).append("\n");
|
||||||
sb.append(" .xfindex= ").append(HexDump.shortToHex(getXFIndex())).append("\n");
|
sb.append(" .xfindex= ").append(HexDump.shortToHex(getXFIndex())).append("\n");
|
||||||
appendValueText(sb);
|
appendValueText(sb);
|
||||||
sb.append("\n");
|
sb.append("\n");
|
||||||
sb.append("[/").append(recordName).append("]\n");
|
sb.append("[/").append(recordName).append("]\n");
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Append specific debug info (used by {@link #toString()} for the value
|
* Append specific debug info (used by {@link #toString()} for the value
|
||||||
* contained in this record. Trailing new-line should not be appended
|
* contained in this record. Trailing new-line should not be appended
|
||||||
* (superclass does that).
|
* (superclass does that).
|
||||||
*/
|
*/
|
||||||
protected abstract void appendValueText(StringBuilder sb);
|
protected abstract void appendValueText(StringBuilder sb);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the debug info BIFF record type name (used by {@link #toString()}.
|
* Gets the debug info BIFF record type name (used by {@link #toString()}.
|
||||||
*/
|
*/
|
||||||
protected abstract String getRecordName();
|
protected abstract String getRecordName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* writes out the value data for this cell record
|
* writes out the value data for this cell record
|
||||||
*/
|
*/
|
||||||
protected abstract void serializeValue(LittleEndianOutput out);
|
protected abstract void serializeValue(LittleEndianOutput out);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the size (in bytes) of the value data for this cell record
|
* @return the size (in bytes) of the value data for this cell record
|
||||||
*/
|
*/
|
||||||
protected abstract int getValueDataSize();
|
protected abstract int getValueDataSize();
|
||||||
|
|
||||||
public final void serialize(LittleEndianOutput out) {
|
@Override
|
||||||
out.writeShort(getRow());
|
public final void serialize(LittleEndianOutput out) {
|
||||||
out.writeShort(getColumn());
|
out.writeShort(getRow());
|
||||||
out.writeShort(getXFIndex());
|
out.writeShort(getColumn());
|
||||||
serializeValue(out);
|
out.writeShort(getXFIndex());
|
||||||
}
|
serializeValue(out);
|
||||||
|
}
|
||||||
|
|
||||||
protected final int getDataSize() {
|
@Override
|
||||||
return 6 + getValueDataSize();
|
protected final int getDataSize() {
|
||||||
}
|
return 6 + getValueDataSize();
|
||||||
|
}
|
||||||
|
|
||||||
protected final void copyBaseFields(CellRecord rec) {
|
protected final void copyBaseFields(CellRecord rec) {
|
||||||
rec._rowIndex = _rowIndex;
|
rec._rowIndex = _rowIndex;
|
||||||
rec._columnIndex = _columnIndex;
|
rec._columnIndex = _columnIndex;
|
||||||
rec._formatIndex = _formatIndex;
|
rec._formatIndex = _formatIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,6 +124,7 @@ public final class ExternalNameRecord extends StandardRecord {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
protected int getDataSize(){
|
protected int getDataSize(){
|
||||||
int result = 2 + 4; // short and int
|
int result = 2 + 4; // short and int
|
||||||
result += StringUtil.getEncodedSize(field_4_name) - 1; //size is byte, not short
|
result += StringUtil.getEncodedSize(field_4_name) - 1; //size is byte, not short
|
||||||
@ -141,6 +142,7 @@ public final class ExternalNameRecord extends StandardRecord {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void serialize(LittleEndianOutput out) {
|
public void serialize(LittleEndianOutput out) {
|
||||||
out.writeShort(field_1_option_flag);
|
out.writeShort(field_1_option_flag);
|
||||||
out.writeShort(field_2_ixals);
|
out.writeShort(field_2_ixals);
|
||||||
@ -198,10 +200,12 @@ public final class ExternalNameRecord extends StandardRecord {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public short getSid() {
|
public short getSid() {
|
||||||
return sid;
|
return sid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
sb.append("[EXTERNALNAME]\n");
|
sb.append("[EXTERNALNAME]\n");
|
||||||
|
@ -81,10 +81,12 @@ public final class NumberRecord extends CellRecord {
|
|||||||
return 8;
|
return 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public short getSid() {
|
public short getSid() {
|
||||||
return sid;
|
return sid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object clone() {
|
public Object clone() {
|
||||||
NumberRecord rec = new NumberRecord();
|
NumberRecord rec = new NumberRecord();
|
||||||
copyBaseFields(rec);
|
copyBaseFields(rec);
|
||||||
|
@ -28,69 +28,71 @@ import java.io.ByteArrayInputStream;
|
|||||||
*/
|
*/
|
||||||
public abstract class Record extends RecordBase {
|
public abstract class Record extends RecordBase {
|
||||||
|
|
||||||
protected Record() {
|
protected Record() {
|
||||||
// no fields to initialise
|
// no fields to initialise
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* called by the class that is responsible for writing this sucker.
|
* called by the class that is responsible for writing this sucker.
|
||||||
* Subclasses should implement this so that their data is passed back in a
|
* Subclasses should implement this so that their data is passed back in a
|
||||||
* byte array.
|
* byte array.
|
||||||
*
|
*
|
||||||
* @return byte array containing instance data
|
* @return byte array containing instance data
|
||||||
*/
|
*/
|
||||||
public final byte[] serialize() {
|
public final byte[] serialize() {
|
||||||
byte[] retval = new byte[ getRecordSize() ];
|
byte[] retval = new byte[ getRecordSize() ];
|
||||||
|
|
||||||
serialize(0, retval);
|
serialize(0, retval);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get a string representation of the record (for biffview/debugging)
|
* get a string representation of the record (for biffview/debugging)
|
||||||
*/
|
*/
|
||||||
public String toString() {
|
@Override
|
||||||
return super.toString();
|
public String toString() {
|
||||||
}
|
return super.toString();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return the non static version of the id for this record.
|
* return the non static version of the id for this record.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public abstract short getSid();
|
public abstract short getSid();
|
||||||
|
|
||||||
public Object clone() {
|
@Override
|
||||||
if (false) {
|
public Object clone() {
|
||||||
// TODO - implement clone in a more standardised way
|
if (false) {
|
||||||
try {
|
// TODO - implement clone in a more standardised way
|
||||||
return super.clone();
|
try {
|
||||||
} catch (CloneNotSupportedException e) {
|
return super.clone();
|
||||||
throw new RuntimeException(e);
|
} catch (CloneNotSupportedException e) {
|
||||||
}
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
throw new RuntimeException("The class "+getClass().getName()+" needs to define a clone method");
|
}
|
||||||
}
|
throw new RuntimeException("The class "+getClass().getName()+" needs to define a clone method");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clone the current record, via a call to serialize
|
* Clone the current record, via a call to serialize
|
||||||
* it, and another to create a new record from the
|
* it, and another to create a new record from the
|
||||||
* bytes.
|
* bytes.
|
||||||
* May only be used for classes which don't have
|
* May only be used for classes which don't have
|
||||||
* internal counts / ids in them. For those which
|
* internal counts / ids in them. For those which
|
||||||
* do, a full model-aware cloning is needed, which
|
* do, a full model-aware cloning is needed, which
|
||||||
* allocates new ids / counts as needed.
|
* allocates new ids / counts as needed.
|
||||||
*/
|
*/
|
||||||
public Record cloneViaReserialise() {
|
public Record cloneViaReserialise() {
|
||||||
// Do it via a re-serialization
|
// Do it via a re-serialization
|
||||||
// It's a cheat, but it works...
|
// It's a cheat, but it works...
|
||||||
byte[] b = serialize();
|
byte[] b = serialize();
|
||||||
RecordInputStream rinp = new RecordInputStream(new ByteArrayInputStream(b));
|
RecordInputStream rinp = new RecordInputStream(new ByteArrayInputStream(b));
|
||||||
rinp.nextRecord();
|
rinp.nextRecord();
|
||||||
|
|
||||||
Record[] r = RecordFactory.createRecord(rinp);
|
Record[] r = RecordFactory.createRecord(rinp);
|
||||||
if(r.length != 1) {
|
if(r.length != 1) {
|
||||||
throw new IllegalStateException("Re-serialised a record to clone it, but got " + r.length + " records back!");
|
throw new IllegalStateException("Re-serialised a record to clone it, but got " + r.length + " records back!");
|
||||||
}
|
}
|
||||||
return r[0];
|
return r[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,254 +33,259 @@ import org.apache.poi.util.LittleEndianOutput;
|
|||||||
*/
|
*/
|
||||||
public final class UnknownRecord extends StandardRecord {
|
public final class UnknownRecord extends StandardRecord {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Some Record IDs used by POI as 'milestones' in the record stream
|
* Some Record IDs used by POI as 'milestones' in the record stream
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* seems to be part of the {@link PageSettingsBlock}. Not interpreted by POI.
|
* seems to be part of the {@link PageSettingsBlock}. Not interpreted by POI.
|
||||||
* The name 'PRINTSIZE' was taken from OOO source.<br/>
|
* The name 'PRINTSIZE' was taken from OOO source.<br/>
|
||||||
* The few POI test samples with this record have data { 0x03, 0x00 }.
|
* The few POI test samples with this record have data { 0x03, 0x00 }.
|
||||||
*/
|
*/
|
||||||
public static final int PRINTSIZE_0033 = 0x0033;
|
public static final int PRINTSIZE_0033 = 0x0033;
|
||||||
/**
|
/**
|
||||||
* Environment-Specific Print Record
|
* Environment-Specific Print Record
|
||||||
*/
|
*/
|
||||||
public static final int PLS_004D = 0x004D;
|
public static final int PLS_004D = 0x004D;
|
||||||
public static final int SHEETPR_0081 = 0x0081;
|
public static final int SHEETPR_0081 = 0x0081;
|
||||||
public static final int SORT_0090 = 0x0090;
|
public static final int SORT_0090 = 0x0090;
|
||||||
public static final int STANDARDWIDTH_0099 = 0x0099;
|
public static final int STANDARDWIDTH_0099 = 0x0099;
|
||||||
public static final int SCL_00A0 = 0x00A0;
|
public static final int SCL_00A0 = 0x00A0;
|
||||||
public static final int BITMAP_00E9 = 0x00E9;
|
public static final int BITMAP_00E9 = 0x00E9;
|
||||||
public static final int PHONETICPR_00EF = 0x00EF;
|
public static final int PHONETICPR_00EF = 0x00EF;
|
||||||
public static final int LABELRANGES_015F = 0x015F;
|
public static final int LABELRANGES_015F = 0x015F;
|
||||||
public static final int QUICKTIP_0800 = 0x0800;
|
public static final int QUICKTIP_0800 = 0x0800;
|
||||||
public static final int SHEETEXT_0862 = 0x0862; // OOO calls this SHEETLAYOUT
|
public static final int SHEETEXT_0862 = 0x0862; // OOO calls this SHEETLAYOUT
|
||||||
public static final int SHEETPROTECTION_0867 = 0x0867;
|
public static final int SHEETPROTECTION_0867 = 0x0867;
|
||||||
public static final int HEADER_FOOTER_089C = 0x089C;
|
public static final int HEADER_FOOTER_089C = 0x089C;
|
||||||
public static final int CODENAME_1BA = 0x01BA;
|
public static final int CODENAME_1BA = 0x01BA;
|
||||||
public static final int PLV_MAC = 0x08C8;
|
public static final int PLV_MAC = 0x08C8;
|
||||||
|
|
||||||
private int _sid;
|
private int _sid;
|
||||||
private byte[] _rawData;
|
private byte[] _rawData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param id id of the record -not validated, just stored for serialization
|
* @param id id of the record -not validated, just stored for serialization
|
||||||
* @param data the data
|
* @param data the data
|
||||||
*/
|
*/
|
||||||
public UnknownRecord(int id, byte[] data) {
|
public UnknownRecord(int id, byte[] data) {
|
||||||
_sid = id & 0xFFFF;
|
_sid = id & 0xFFFF;
|
||||||
_rawData = data;
|
_rawData = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* construct an unknown record. No fields are interpreted and the record will
|
* construct an unknown record. No fields are interpreted and the record will
|
||||||
* be serialized in its original form more or less
|
* be serialized in its original form more or less
|
||||||
* @param in the RecordInputstream to read the record from
|
* @param in the RecordInputstream to read the record from
|
||||||
*/
|
*/
|
||||||
public UnknownRecord(RecordInputStream in) {
|
public UnknownRecord(RecordInputStream in) {
|
||||||
_sid = in.getSid();
|
_sid = in.getSid();
|
||||||
_rawData = in.readRemainder();
|
_rawData = in.readRemainder();
|
||||||
if (false && getBiffName(_sid) == null) {
|
if (false && getBiffName(_sid) == null) {
|
||||||
// unknown sids in the range 0x0004-0x0013 are probably 'sub-records' of ObjectRecord
|
// unknown sids in the range 0x0004-0x0013 are probably 'sub-records' of ObjectRecord
|
||||||
// those sids are in a different number space.
|
// those sids are in a different number space.
|
||||||
// TODO - put unknown OBJ sub-records in a different class
|
// TODO - put unknown OBJ sub-records in a different class
|
||||||
System.out.println("Unknown record 0x" + Integer.toHexString(_sid).toUpperCase());
|
System.out.println("Unknown record 0x" + Integer.toHexString(_sid).toUpperCase());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* spit the record out AS IS. no interpretation or identification
|
* spit the record out AS IS. no interpretation or identification
|
||||||
*/
|
*/
|
||||||
public void serialize(LittleEndianOutput out) {
|
@Override
|
||||||
out.write(_rawData);
|
public void serialize(LittleEndianOutput out) {
|
||||||
}
|
out.write(_rawData);
|
||||||
|
}
|
||||||
|
|
||||||
protected int getDataSize() {
|
@Override
|
||||||
return _rawData.length;
|
protected int getDataSize() {
|
||||||
}
|
return _rawData.length;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* print a sort of string representation ([UNKNOWN RECORD] id = x [/UNKNOWN RECORD])
|
* print a sort of string representation ([UNKNOWN RECORD] id = x [/UNKNOWN RECORD])
|
||||||
*/
|
*/
|
||||||
public String toString() {
|
@Override
|
||||||
String biffName = getBiffName(_sid);
|
public String toString() {
|
||||||
if (biffName == null) {
|
String biffName = getBiffName(_sid);
|
||||||
biffName = "UNKNOWNRECORD";
|
if (biffName == null) {
|
||||||
}
|
biffName = "UNKNOWNRECORD";
|
||||||
StringBuffer sb = new StringBuffer();
|
}
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
|
||||||
sb.append("[").append(biffName).append("] (0x");
|
sb.append("[").append(biffName).append("] (0x");
|
||||||
sb.append(Integer.toHexString(_sid).toUpperCase() + ")\n");
|
sb.append(Integer.toHexString(_sid).toUpperCase() + ")\n");
|
||||||
if (_rawData.length > 0) {
|
if (_rawData.length > 0) {
|
||||||
sb.append(" rawData=").append(HexDump.toHex(_rawData)).append("\n");
|
sb.append(" rawData=").append(HexDump.toHex(_rawData)).append("\n");
|
||||||
}
|
}
|
||||||
sb.append("[/").append(biffName).append("]\n");
|
sb.append("[/").append(biffName).append("]\n");
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public short getSid() {
|
@Override
|
||||||
return (short) _sid;
|
public short getSid() {
|
||||||
}
|
return (short) _sid;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These BIFF record types are known but still uninterpreted by POI
|
* These BIFF record types are known but still uninterpreted by POI
|
||||||
*
|
*
|
||||||
* @return the documented name of this BIFF record type, <code>null</code> if unknown to POI
|
* @return the documented name of this BIFF record type, <code>null</code> if unknown to POI
|
||||||
*/
|
*/
|
||||||
public static String getBiffName(int sid) {
|
public static String getBiffName(int sid) {
|
||||||
// Note to POI developers:
|
// Note to POI developers:
|
||||||
// Make sure you delete the corresponding entry from
|
// Make sure you delete the corresponding entry from
|
||||||
// this method any time a new Record subclass is created.
|
// this method any time a new Record subclass is created.
|
||||||
switch (sid) {
|
switch (sid) {
|
||||||
case PRINTSIZE_0033: return "PRINTSIZE";
|
case PRINTSIZE_0033: return "PRINTSIZE";
|
||||||
case PLS_004D: return "PLS";
|
case PLS_004D: return "PLS";
|
||||||
case 0x0050: return "DCON"; // Data Consolidation Information
|
case 0x0050: return "DCON"; // Data Consolidation Information
|
||||||
case 0x007F: return "IMDATA";
|
case 0x007F: return "IMDATA";
|
||||||
case SHEETPR_0081: return "SHEETPR";
|
case SHEETPR_0081: return "SHEETPR";
|
||||||
case SORT_0090: return "SORT"; // Sorting Options
|
case SORT_0090: return "SORT"; // Sorting Options
|
||||||
case 0x0094: return "LHRECORD"; // .WK? File Conversion Information
|
case 0x0094: return "LHRECORD"; // .WK? File Conversion Information
|
||||||
case STANDARDWIDTH_0099: return "STANDARDWIDTH"; //Standard Column Width
|
case STANDARDWIDTH_0099: return "STANDARDWIDTH"; //Standard Column Width
|
||||||
case SCL_00A0: return "SCL"; // Window Zoom Magnification
|
case SCL_00A0: return "SCL"; // Window Zoom Magnification
|
||||||
case 0x00AE: return "SCENMAN"; // Scenario Output Data
|
case 0x00AE: return "SCENMAN"; // Scenario Output Data
|
||||||
|
|
||||||
case 0x00B2: return "SXVI"; // (pivot table) View Item
|
case 0x00B2: return "SXVI"; // (pivot table) View Item
|
||||||
case 0x00B4: return "SXIVD"; // (pivot table) Row/Column Field IDs
|
case 0x00B4: return "SXIVD"; // (pivot table) Row/Column Field IDs
|
||||||
case 0x00B5: return "SXLI"; // (pivot table) Line Item Array
|
case 0x00B5: return "SXLI"; // (pivot table) Line Item Array
|
||||||
|
|
||||||
case 0x00D3: return "OBPROJ";
|
case 0x00D3: return "OBPROJ";
|
||||||
case 0x00DC: return "PARAMQRY";
|
case 0x00DC: return "PARAMQRY";
|
||||||
case 0x00DE: return "OLESIZE";
|
case 0x00DE: return "OLESIZE";
|
||||||
case BITMAP_00E9: return "BITMAP";
|
case BITMAP_00E9: return "BITMAP";
|
||||||
case PHONETICPR_00EF: return "PHONETICPR";
|
case PHONETICPR_00EF: return "PHONETICPR";
|
||||||
case 0x00F1: return "SXEX"; // PivotTable View Extended Information
|
case 0x00F1: return "SXEX"; // PivotTable View Extended Information
|
||||||
|
|
||||||
case LABELRANGES_015F: return "LABELRANGES";
|
case LABELRANGES_015F: return "LABELRANGES";
|
||||||
case 0x01BA: return "CODENAME";
|
case 0x01BA: return "CODENAME";
|
||||||
case 0x01A9: return "USERBVIEW";
|
case 0x01A9: return "USERBVIEW";
|
||||||
case 0x01AD: return "QSI";
|
case 0x01AD: return "QSI";
|
||||||
|
|
||||||
case 0x01C0: return "EXCEL9FILE";
|
case 0x01C0: return "EXCEL9FILE";
|
||||||
|
|
||||||
case 0x0802: return "QSISXTAG"; // Pivot Table and Query Table Extensions
|
case 0x0802: return "QSISXTAG"; // Pivot Table and Query Table Extensions
|
||||||
case 0x0803: return "DBQUERYEXT";
|
case 0x0803: return "DBQUERYEXT";
|
||||||
case 0x0805: return "TXTQUERY";
|
case 0x0805: return "TXTQUERY";
|
||||||
case 0x0810: return "SXVIEWEX9"; // Pivot Table Extensions
|
case 0x0810: return "SXVIEWEX9"; // Pivot Table Extensions
|
||||||
|
|
||||||
case 0x0812: return "CONTINUEFRT";
|
case 0x0812: return "CONTINUEFRT";
|
||||||
case QUICKTIP_0800: return "QUICKTIP";
|
case QUICKTIP_0800: return "QUICKTIP";
|
||||||
case SHEETEXT_0862: return "SHEETEXT";
|
case SHEETEXT_0862: return "SHEETEXT";
|
||||||
case 0x0863: return "BOOKEXT";
|
case 0x0863: return "BOOKEXT";
|
||||||
case 0x0864: return "SXADDL"; // Pivot Table Additional Info
|
case 0x0864: return "SXADDL"; // Pivot Table Additional Info
|
||||||
case SHEETPROTECTION_0867: return "SHEETPROTECTION";
|
case SHEETPROTECTION_0867: return "SHEETPROTECTION";
|
||||||
case 0x086B: return "DATALABEXTCONTENTS";
|
case 0x086B: return "DATALABEXTCONTENTS";
|
||||||
case 0x086C: return "CELLWATCH";
|
case 0x086C: return "CELLWATCH";
|
||||||
case 0x0874: return "DROPDOWNOBJIDS";
|
case 0x0874: return "DROPDOWNOBJIDS";
|
||||||
case 0x0876: return "DCONN";
|
case 0x0876: return "DCONN";
|
||||||
case 0x087B: return "CFEX";
|
case 0x087B: return "CFEX";
|
||||||
case 0x087C: return "XFCRC";
|
case 0x087C: return "XFCRC";
|
||||||
case 0x087D: return "XFEXT";
|
case 0x087D: return "XFEXT";
|
||||||
case 0x087F: return "CONTINUEFRT12";
|
case 0x087F: return "CONTINUEFRT12";
|
||||||
case 0x088B: return "PLV";
|
case 0x088B: return "PLV";
|
||||||
case 0x088C: return "COMPAT12";
|
case 0x088C: return "COMPAT12";
|
||||||
case 0x088D: return "DXF";
|
case 0x088D: return "DXF";
|
||||||
case 0x0892: return "STYLEEXT";
|
case 0x0892: return "STYLEEXT";
|
||||||
case 0x0896: return "THEME";
|
case 0x0896: return "THEME";
|
||||||
case 0x0897: return "GUIDTYPELIB";
|
case 0x0897: return "GUIDTYPELIB";
|
||||||
case 0x089A: return "MTRSETTINGS";
|
case 0x089A: return "MTRSETTINGS";
|
||||||
case 0x089B: return "COMPRESSPICTURES";
|
case 0x089B: return "COMPRESSPICTURES";
|
||||||
case HEADER_FOOTER_089C: return "HEADERFOOTER";
|
case HEADER_FOOTER_089C: return "HEADERFOOTER";
|
||||||
case 0x08A1: return "SHAPEPROPSSTREAM";
|
case 0x08A1: return "SHAPEPROPSSTREAM";
|
||||||
case 0x08A3: return "FORCEFULLCALCULATION";
|
case 0x08A3: return "FORCEFULLCALCULATION";
|
||||||
case 0x08A4: return "SHAPEPROPSSTREAM";
|
case 0x08A4: return "SHAPEPROPSSTREAM";
|
||||||
case 0x08A5: return "TEXTPROPSSTREAM";
|
case 0x08A5: return "TEXTPROPSSTREAM";
|
||||||
case 0x08A6: return "RICHTEXTSTREAM";
|
case 0x08A6: return "RICHTEXTSTREAM";
|
||||||
|
|
||||||
case 0x08C8: return "PLV{Mac Excel}";
|
case 0x08C8: return "PLV{Mac Excel}";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if (isObservedButUnknown(sid)) {
|
if (isObservedButUnknown(sid)) {
|
||||||
return "UNKNOWN-" + Integer.toHexString(sid).toUpperCase();
|
return "UNKNOWN-" + Integer.toHexString(sid).toUpperCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return <code>true</code> if the unknown record id has been observed in POI unit tests
|
* @return <code>true</code> if the unknown record id has been observed in POI unit tests
|
||||||
*/
|
*/
|
||||||
private static boolean isObservedButUnknown(int sid) {
|
private static boolean isObservedButUnknown(int sid) {
|
||||||
switch (sid) {
|
switch (sid) {
|
||||||
case 0x0033:
|
case 0x0033:
|
||||||
// contains 2 bytes of data: 0x0001 or 0x0003
|
// contains 2 bytes of data: 0x0001 or 0x0003
|
||||||
case 0x0034:
|
case 0x0034:
|
||||||
// Seems to be written by MSAccess
|
// Seems to be written by MSAccess
|
||||||
// contains text "[Microsoft JET Created Table]0021010"
|
// contains text "[Microsoft JET Created Table]0021010"
|
||||||
// appears after last cell value record and before WINDOW2
|
// appears after last cell value record and before WINDOW2
|
||||||
case 0x01BD:
|
case 0x01BD:
|
||||||
case 0x01C2:
|
case 0x01C2:
|
||||||
// Written by Excel 2007
|
// Written by Excel 2007
|
||||||
// rawData is multiple of 12 bytes long
|
// rawData is multiple of 12 bytes long
|
||||||
// appears after last cell value record and before WINDOW2 or drawing records
|
// appears after last cell value record and before WINDOW2 or drawing records
|
||||||
case 0x089D:
|
case 0x089D:
|
||||||
case 0x089E:
|
case 0x089E:
|
||||||
case 0x08A7:
|
case 0x08A7:
|
||||||
|
|
||||||
case 0x1001:
|
case 0x1001:
|
||||||
case 0x1006:
|
case 0x1006:
|
||||||
case 0x1007:
|
case 0x1007:
|
||||||
case 0x1009:
|
case 0x1009:
|
||||||
case 0x100A:
|
case 0x100A:
|
||||||
case 0x100B:
|
case 0x100B:
|
||||||
case 0x100C:
|
case 0x100C:
|
||||||
case 0x1014:
|
case 0x1014:
|
||||||
case 0x1017:
|
case 0x1017:
|
||||||
case 0x1018:
|
case 0x1018:
|
||||||
case 0x1019:
|
case 0x1019:
|
||||||
case 0x101A:
|
case 0x101A:
|
||||||
case 0x101B:
|
case 0x101B:
|
||||||
case 0x101D:
|
case 0x101D:
|
||||||
case 0x101E:
|
case 0x101E:
|
||||||
case 0x101F:
|
case 0x101F:
|
||||||
case 0x1020:
|
case 0x1020:
|
||||||
case 0x1021:
|
case 0x1021:
|
||||||
case 0x1022:
|
case 0x1022:
|
||||||
case 0x1024:
|
case 0x1024:
|
||||||
case 0x1025:
|
case 0x1025:
|
||||||
case 0x1026:
|
case 0x1026:
|
||||||
case 0x1027:
|
case 0x1027:
|
||||||
case 0x1032:
|
case 0x1032:
|
||||||
case 0x1033:
|
case 0x1033:
|
||||||
case 0x1034:
|
case 0x1034:
|
||||||
case 0x1035:
|
case 0x1035:
|
||||||
case 0x103A:
|
case 0x103A:
|
||||||
case 0x1041:
|
case 0x1041:
|
||||||
case 0x1043:
|
case 0x1043:
|
||||||
case 0x1044:
|
case 0x1044:
|
||||||
case 0x1045:
|
case 0x1045:
|
||||||
case 0x1046:
|
case 0x1046:
|
||||||
case 0x104A:
|
case 0x104A:
|
||||||
case 0x104B:
|
case 0x104B:
|
||||||
case 0x104E:
|
case 0x104E:
|
||||||
case 0x104F:
|
case 0x104F:
|
||||||
case 0x1051:
|
case 0x1051:
|
||||||
case 0x105C:
|
case 0x105C:
|
||||||
case 0x105D:
|
case 0x105D:
|
||||||
case 0x105F:
|
case 0x105F:
|
||||||
case 0x1060:
|
case 0x1060:
|
||||||
case 0x1062:
|
case 0x1062:
|
||||||
case 0x1063:
|
case 0x1063:
|
||||||
case 0x1064:
|
case 0x1064:
|
||||||
case 0x1065:
|
case 0x1065:
|
||||||
case 0x1066:
|
case 0x1066:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object clone() {
|
@Override
|
||||||
// immutable - OK to return this
|
public Object clone() {
|
||||||
return this;
|
// immutable - OK to return this
|
||||||
}
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,12 @@
|
|||||||
|
|
||||||
package org.apache.poi.poifs.dev;
|
package org.apache.poi.poifs.dev;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.IOException;
|
||||||
|
import java.io.LineNumberReader;
|
||||||
import java.util.*;
|
import java.io.StringReader;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class contains methods used to inspect POIFSViewable objects
|
* This class contains methods used to inspect POIFSViewable objects
|
||||||
@ -47,12 +50,12 @@ public class POIFSViewEngine
|
|||||||
* @return a List of Strings holding the content
|
* @return a List of Strings holding the content
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static List inspectViewable(final Object viewable,
|
public static List<String> inspectViewable(final Object viewable,
|
||||||
final boolean drilldown,
|
final boolean drilldown,
|
||||||
final int indentLevel,
|
final int indentLevel,
|
||||||
final String indentString)
|
final String indentString)
|
||||||
{
|
{
|
||||||
List objects = new ArrayList();
|
List<String> objects = new ArrayList<String>();
|
||||||
|
|
||||||
if (viewable instanceof POIFSViewable)
|
if (viewable instanceof POIFSViewable)
|
||||||
{
|
{
|
||||||
@ -75,7 +78,7 @@ public class POIFSViewEngine
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Iterator iter = inspected.getViewableIterator();
|
Iterator<Object> iter = inspected.getViewableIterator();
|
||||||
|
|
||||||
while (iter.hasNext())
|
while (iter.hasNext())
|
||||||
{
|
{
|
||||||
|
@ -54,8 +54,7 @@ public interface POIFSViewable
|
|||||||
* @return an Iterator; may not be null, but may have an empty
|
* @return an Iterator; may not be null, but may have an empty
|
||||||
* back end store
|
* back end store
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
public Iterator<Object> getViewableIterator();
|
||||||
public Iterator getViewableIterator();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Give viewers a hint as to whether to call getViewableArray or
|
* Give viewers a hint as to whether to call getViewableArray or
|
||||||
|
@ -19,9 +19,10 @@
|
|||||||
|
|
||||||
package org.apache.poi.poifs.dev;
|
package org.apache.poi.poifs.dev;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||||
|
|
||||||
@ -76,9 +77,9 @@ public class POIFSViewer
|
|||||||
{
|
{
|
||||||
POIFSViewable fs =
|
POIFSViewable fs =
|
||||||
new POIFSFileSystem(new FileInputStream(filename));
|
new POIFSFileSystem(new FileInputStream(filename));
|
||||||
List strings = POIFSViewEngine.inspectViewable(fs, true,
|
List<String> strings = POIFSViewEngine.inspectViewable(fs, true,
|
||||||
0, " ");
|
0, " ");
|
||||||
Iterator iter = strings.iterator();
|
Iterator<String> iter = strings.iterator();
|
||||||
|
|
||||||
while (iter.hasNext())
|
while (iter.hasNext())
|
||||||
{
|
{
|
||||||
|
@ -521,10 +521,9 @@ public class DirectoryNode
|
|||||||
* @return an Iterator; may not be null, but may have an empty
|
* @return an Iterator; may not be null, but may have an empty
|
||||||
* back end store
|
* back end store
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
public Iterator<Object> getViewableIterator()
|
||||||
public Iterator getViewableIterator()
|
|
||||||
{
|
{
|
||||||
List components = new ArrayList();
|
List<Object> components = new ArrayList<Object>();
|
||||||
|
|
||||||
components.add(getProperty());
|
components.add(getProperty());
|
||||||
Iterator<Entry> iter = _entries.iterator();
|
Iterator<Entry> iter = _entries.iterator();
|
||||||
|
@ -19,7 +19,9 @@
|
|||||||
|
|
||||||
package org.apache.poi.poifs.filesystem;
|
package org.apache.poi.poifs.filesystem;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.poi.poifs.dev.POIFSViewable;
|
import org.apache.poi.poifs.dev.POIFSViewable;
|
||||||
import org.apache.poi.poifs.property.DocumentProperty;
|
import org.apache.poi.poifs.property.DocumentProperty;
|
||||||
@ -85,6 +87,7 @@ public class DocumentNode
|
|||||||
* @return true if the Entry is a DocumentEntry, else false
|
* @return true if the Entry is a DocumentEntry, else false
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isDocumentEntry()
|
public boolean isDocumentEntry()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@ -101,6 +104,7 @@ public class DocumentNode
|
|||||||
* false
|
* false
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@Override
|
||||||
protected boolean isDeleteOK()
|
protected boolean isDeleteOK()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@ -129,9 +133,9 @@ public class DocumentNode
|
|||||||
* back end store
|
* back end store
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public Iterator getViewableIterator()
|
public Iterator<Object> getViewableIterator()
|
||||||
{
|
{
|
||||||
List components = new ArrayList();
|
List<Object> components = new ArrayList<Object>();
|
||||||
|
|
||||||
components.add(getProperty());
|
components.add(getProperty());
|
||||||
components.add(_document);
|
components.add(_document);
|
||||||
|
@ -168,8 +168,8 @@ public final class NPOIFSDocument implements POIFSViewable {
|
|||||||
* @return an Iterator; may not be null, but may have an empty back end
|
* @return an Iterator; may not be null, but may have an empty back end
|
||||||
* store
|
* store
|
||||||
*/
|
*/
|
||||||
public Iterator getViewableIterator() {
|
public Iterator<Object> getViewableIterator() {
|
||||||
return Collections.EMPTY_LIST.iterator();
|
return Collections.emptyList().iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,17 +46,15 @@ import org.apache.poi.poifs.nio.FileBackedDataSource;
|
|||||||
import org.apache.poi.poifs.property.DirectoryProperty;
|
import org.apache.poi.poifs.property.DirectoryProperty;
|
||||||
import org.apache.poi.poifs.property.NPropertyTable;
|
import org.apache.poi.poifs.property.NPropertyTable;
|
||||||
import org.apache.poi.poifs.storage.BATBlock;
|
import org.apache.poi.poifs.storage.BATBlock;
|
||||||
|
import org.apache.poi.poifs.storage.BATBlock.BATBlockAndIndex;
|
||||||
import org.apache.poi.poifs.storage.BlockAllocationTableReader;
|
import org.apache.poi.poifs.storage.BlockAllocationTableReader;
|
||||||
import org.apache.poi.poifs.storage.BlockAllocationTableWriter;
|
import org.apache.poi.poifs.storage.BlockAllocationTableWriter;
|
||||||
import org.apache.poi.poifs.storage.HeaderBlock;
|
import org.apache.poi.poifs.storage.HeaderBlock;
|
||||||
import org.apache.poi.poifs.storage.HeaderBlockConstants;
|
import org.apache.poi.poifs.storage.HeaderBlockConstants;
|
||||||
import org.apache.poi.poifs.storage.HeaderBlockWriter;
|
import org.apache.poi.poifs.storage.HeaderBlockWriter;
|
||||||
import org.apache.poi.poifs.storage.BATBlock.BATBlockAndIndex;
|
|
||||||
import org.apache.poi.util.CloseIgnoringInputStream;
|
import org.apache.poi.util.CloseIgnoringInputStream;
|
||||||
import org.apache.poi.util.IOUtils;
|
import org.apache.poi.util.IOUtils;
|
||||||
import org.apache.poi.util.LongField;
|
import org.apache.poi.util.LongField;
|
||||||
import org.apache.poi.util.POILogFactory;
|
|
||||||
import org.apache.poi.util.POILogger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the main class of the POIFS system; it manages the entire
|
* This is the main class of the POIFS system; it manages the entire
|
||||||
@ -67,8 +65,8 @@ import org.apache.poi.util.POILogger;
|
|||||||
public class NPOIFSFileSystem extends BlockStore
|
public class NPOIFSFileSystem extends BlockStore
|
||||||
implements POIFSViewable, Closeable
|
implements POIFSViewable, Closeable
|
||||||
{
|
{
|
||||||
private static final POILogger _logger =
|
// private static final POILogger _logger =
|
||||||
POILogFactory.getLogger(NPOIFSFileSystem.class);
|
// POILogFactory.getLogger(NPOIFSFileSystem.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience method for clients that want to avoid the auto-close behaviour of the constructor.
|
* Convenience method for clients that want to avoid the auto-close behaviour of the constructor.
|
||||||
@ -157,6 +155,7 @@ public class NPOIFSFileSystem extends BlockStore
|
|||||||
*
|
*
|
||||||
* @exception IOException on errors reading, or on invalid data
|
* @exception IOException on errors reading, or on invalid data
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("resource")
|
||||||
public NPOIFSFileSystem(File file, boolean readOnly)
|
public NPOIFSFileSystem(File file, boolean readOnly)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
@ -420,6 +419,7 @@ public class NPOIFSFileSystem extends BlockStore
|
|||||||
/**
|
/**
|
||||||
* Load the block at the given offset.
|
* Load the block at the given offset.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected ByteBuffer getBlockAt(final int offset) throws IOException {
|
protected ByteBuffer getBlockAt(final int offset) throws IOException {
|
||||||
// The header block doesn't count, so add one
|
// The header block doesn't count, so add one
|
||||||
long startAt = (offset+1) * bigBlockSize.getBigBlockSize();
|
long startAt = (offset+1) * bigBlockSize.getBigBlockSize();
|
||||||
@ -430,6 +430,7 @@ public class NPOIFSFileSystem extends BlockStore
|
|||||||
* Load the block at the given offset,
|
* Load the block at the given offset,
|
||||||
* extending the file if needed
|
* extending the file if needed
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected ByteBuffer createBlockIfNeeded(final int offset) throws IOException {
|
protected ByteBuffer createBlockIfNeeded(final int offset) throws IOException {
|
||||||
try {
|
try {
|
||||||
return getBlockAt(offset);
|
return getBlockAt(offset);
|
||||||
@ -448,6 +449,7 @@ public class NPOIFSFileSystem extends BlockStore
|
|||||||
* Returns the BATBlock that handles the specified offset,
|
* Returns the BATBlock that handles the specified offset,
|
||||||
* and the relative index within it
|
* and the relative index within it
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected BATBlockAndIndex getBATBlockAndIndex(final int offset) {
|
protected BATBlockAndIndex getBATBlockAndIndex(final int offset) {
|
||||||
return BATBlock.getBATBlockAndIndex(
|
return BATBlock.getBATBlockAndIndex(
|
||||||
offset, _header, _bat_blocks
|
offset, _header, _bat_blocks
|
||||||
@ -457,6 +459,7 @@ public class NPOIFSFileSystem extends BlockStore
|
|||||||
/**
|
/**
|
||||||
* Works out what block follows the specified one.
|
* Works out what block follows the specified one.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected int getNextBlock(final int offset) {
|
protected int getNextBlock(final int offset) {
|
||||||
BATBlockAndIndex bai = getBATBlockAndIndex(offset);
|
BATBlockAndIndex bai = getBATBlockAndIndex(offset);
|
||||||
return bai.getBlock().getValueAt( bai.getIndex() );
|
return bai.getBlock().getValueAt( bai.getIndex() );
|
||||||
@ -465,6 +468,7 @@ public class NPOIFSFileSystem extends BlockStore
|
|||||||
/**
|
/**
|
||||||
* Changes the record of what block follows the specified one.
|
* Changes the record of what block follows the specified one.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected void setNextBlock(final int offset, final int nextBlock) {
|
protected void setNextBlock(final int offset, final int nextBlock) {
|
||||||
BATBlockAndIndex bai = getBATBlockAndIndex(offset);
|
BATBlockAndIndex bai = getBATBlockAndIndex(offset);
|
||||||
bai.getBlock().setValueAt(
|
bai.getBlock().setValueAt(
|
||||||
@ -477,6 +481,7 @@ public class NPOIFSFileSystem extends BlockStore
|
|||||||
* This method will extend the file if needed, and if doing
|
* This method will extend the file if needed, and if doing
|
||||||
* so, allocate new FAT blocks to address the extra space.
|
* so, allocate new FAT blocks to address the extra space.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected int getFreeBlock() throws IOException {
|
protected int getFreeBlock() throws IOException {
|
||||||
// First up, do we have any spare ones?
|
// First up, do we have any spare ones?
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
@ -743,11 +748,21 @@ public class NPOIFSFileSystem extends BlockStore
|
|||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
FileInputStream istream = new FileInputStream(args[ 0 ]);
|
FileInputStream istream = new FileInputStream(args[ 0 ]);
|
||||||
FileOutputStream ostream = new FileOutputStream(args[ 1 ]);
|
try {
|
||||||
|
FileOutputStream ostream = new FileOutputStream(args[ 1 ]);
|
||||||
new NPOIFSFileSystem(istream).writeFilesystem(ostream);
|
try {
|
||||||
istream.close();
|
NPOIFSFileSystem fs = new NPOIFSFileSystem(istream);
|
||||||
ostream.close();
|
try {
|
||||||
|
fs.writeFilesystem(ostream);
|
||||||
|
} finally {
|
||||||
|
fs.close();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
ostream.close();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
istream.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -818,13 +833,13 @@ public class NPOIFSFileSystem extends BlockStore
|
|||||||
* back end store
|
* back end store
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public Iterator getViewableIterator()
|
public Iterator<Object> getViewableIterator()
|
||||||
{
|
{
|
||||||
if (!preferArray())
|
if (!preferArray())
|
||||||
{
|
{
|
||||||
return (( POIFSViewable ) getRoot()).getViewableIterator();
|
return (( POIFSViewable ) getRoot()).getViewableIterator();
|
||||||
}
|
}
|
||||||
return Collections.EMPTY_LIST.iterator();
|
return Collections.emptyList().iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -860,12 +875,15 @@ public class NPOIFSFileSystem extends BlockStore
|
|||||||
public int getBigBlockSize() {
|
public int getBigBlockSize() {
|
||||||
return bigBlockSize.getBigBlockSize();
|
return bigBlockSize.getBigBlockSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The Big Block size, normally 512 bytes, sometimes 4096 bytes
|
* @return The Big Block size, normally 512 bytes, sometimes 4096 bytes
|
||||||
*/
|
*/
|
||||||
public POIFSBigBlockSize getBigBlockSizeDetails() {
|
public POIFSBigBlockSize getBigBlockSizeDetails() {
|
||||||
return bigBlockSize;
|
return bigBlockSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected int getBlockStoreBlockSize() {
|
protected int getBlockStoreBlockSize() {
|
||||||
return getBigBlockSize();
|
return getBigBlockSize();
|
||||||
}
|
}
|
||||||
|
@ -376,8 +376,8 @@ public final class POIFSDocument implements BATManaged, BlockWritable, POIFSView
|
|||||||
* @return an Iterator; may not be null, but may have an empty back end
|
* @return an Iterator; may not be null, but may have an empty back end
|
||||||
* store
|
* store
|
||||||
*/
|
*/
|
||||||
public Iterator getViewableIterator() {
|
public Iterator<Object> getViewableIterator() {
|
||||||
return Collections.EMPTY_LIST.iterator();
|
return Collections.emptyList().iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,17 +37,7 @@ import org.apache.poi.poifs.dev.POIFSViewable;
|
|||||||
import org.apache.poi.poifs.property.DirectoryProperty;
|
import org.apache.poi.poifs.property.DirectoryProperty;
|
||||||
import org.apache.poi.poifs.property.Property;
|
import org.apache.poi.poifs.property.Property;
|
||||||
import org.apache.poi.poifs.property.PropertyTable;
|
import org.apache.poi.poifs.property.PropertyTable;
|
||||||
import org.apache.poi.poifs.storage.BATBlock;
|
import org.apache.poi.poifs.storage.*;
|
||||||
import org.apache.poi.poifs.storage.BlockAllocationTableReader;
|
|
||||||
import org.apache.poi.poifs.storage.BlockAllocationTableWriter;
|
|
||||||
import org.apache.poi.poifs.storage.BlockList;
|
|
||||||
import org.apache.poi.poifs.storage.BlockWritable;
|
|
||||||
import org.apache.poi.poifs.storage.HeaderBlockConstants;
|
|
||||||
import org.apache.poi.poifs.storage.HeaderBlock;
|
|
||||||
import org.apache.poi.poifs.storage.HeaderBlockWriter;
|
|
||||||
import org.apache.poi.poifs.storage.RawDataBlockList;
|
|
||||||
import org.apache.poi.poifs.storage.SmallBlockTableReader;
|
|
||||||
import org.apache.poi.poifs.storage.SmallBlockTableWriter;
|
|
||||||
import org.apache.poi.util.CloseIgnoringInputStream;
|
import org.apache.poi.util.CloseIgnoringInputStream;
|
||||||
import org.apache.poi.util.IOUtils;
|
import org.apache.poi.util.IOUtils;
|
||||||
import org.apache.poi.util.LongField;
|
import org.apache.poi.util.LongField;
|
||||||
@ -75,7 +65,7 @@ public class POIFSFileSystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
private PropertyTable _property_table;
|
private PropertyTable _property_table;
|
||||||
private List _documents;
|
private List<POIFSViewable> _documents;
|
||||||
private DirectoryNode _root;
|
private DirectoryNode _root;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -92,7 +82,7 @@ public class POIFSFileSystem
|
|||||||
{
|
{
|
||||||
HeaderBlock header_block = new HeaderBlock(bigBlockSize);
|
HeaderBlock header_block = new HeaderBlock(bigBlockSize);
|
||||||
_property_table = new PropertyTable(header_block);
|
_property_table = new PropertyTable(header_block);
|
||||||
_documents = new ArrayList();
|
_documents = new ArrayList<POIFSViewable>();
|
||||||
_root = null;
|
_root = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,7 +300,7 @@ public class POIFSFileSystem
|
|||||||
|
|
||||||
// create a list of BATManaged objects: the documents plus the
|
// create a list of BATManaged objects: the documents plus the
|
||||||
// property table and the small block table
|
// property table and the small block table
|
||||||
List bm_objects = new ArrayList();
|
List<Object> bm_objects = new ArrayList<Object>();
|
||||||
|
|
||||||
bm_objects.addAll(_documents);
|
bm_objects.addAll(_documents);
|
||||||
bm_objects.add(_property_table);
|
bm_objects.add(_property_table);
|
||||||
@ -319,7 +309,7 @@ public class POIFSFileSystem
|
|||||||
|
|
||||||
// walk the list, allocating space for each and assigning each
|
// walk the list, allocating space for each and assigning each
|
||||||
// a starting block number
|
// a starting block number
|
||||||
Iterator iter = bm_objects.iterator();
|
Iterator<Object> iter = bm_objects.iterator();
|
||||||
|
|
||||||
while (iter.hasNext())
|
while (iter.hasNext())
|
||||||
{
|
{
|
||||||
@ -363,7 +353,7 @@ public class POIFSFileSystem
|
|||||||
// property table, the small block store, the small block
|
// property table, the small block store, the small block
|
||||||
// allocation table, the block allocation table, and the
|
// allocation table, the block allocation table, and the
|
||||||
// extended block allocation table blocks)
|
// extended block allocation table blocks)
|
||||||
List writers = new ArrayList();
|
List<Object> writers = new ArrayList<Object>();
|
||||||
|
|
||||||
writers.add(header_block_writer);
|
writers.add(header_block_writer);
|
||||||
writers.addAll(_documents);
|
writers.addAll(_documents);
|
||||||
@ -485,14 +475,14 @@ public class POIFSFileSystem
|
|||||||
|
|
||||||
private void processProperties(final BlockList small_blocks,
|
private void processProperties(final BlockList small_blocks,
|
||||||
final BlockList big_blocks,
|
final BlockList big_blocks,
|
||||||
final Iterator properties,
|
final Iterator<Property> properties,
|
||||||
final DirectoryNode dir,
|
final DirectoryNode dir,
|
||||||
final int headerPropertiesStartAt)
|
final int headerPropertiesStartAt)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
while (properties.hasNext())
|
while (properties.hasNext())
|
||||||
{
|
{
|
||||||
Property property = ( Property ) properties.next();
|
Property property = properties.next();
|
||||||
String name = property.getName();
|
String name = property.getName();
|
||||||
DirectoryNode parent = (dir == null)
|
DirectoryNode parent = (dir == null)
|
||||||
? (( DirectoryNode ) getRoot())
|
? (( DirectoryNode ) getRoot())
|
||||||
@ -561,13 +551,13 @@ public class POIFSFileSystem
|
|||||||
* back end store
|
* back end store
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public Iterator getViewableIterator()
|
public Iterator<Object> getViewableIterator()
|
||||||
{
|
{
|
||||||
if (!preferArray())
|
if (!preferArray())
|
||||||
{
|
{
|
||||||
return (( POIFSViewable ) getRoot()).getViewableIterator();
|
return (( POIFSViewable ) getRoot()).getViewableIterator();
|
||||||
}
|
}
|
||||||
return Collections.EMPTY_LIST.iterator();
|
return Collections.emptyList().iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,6 +36,7 @@ public class ByteArrayBackedDataSource extends DataSource {
|
|||||||
this(data, data.length);
|
this(data, data.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ByteBuffer read(int length, long position) {
|
public ByteBuffer read(int length, long position) {
|
||||||
if(position >= size) {
|
if(position >= size) {
|
||||||
throw new IndexOutOfBoundsException(
|
throw new IndexOutOfBoundsException(
|
||||||
@ -48,6 +49,7 @@ public class ByteArrayBackedDataSource extends DataSource {
|
|||||||
return ByteBuffer.wrap(buffer, (int)position, toRead);
|
return ByteBuffer.wrap(buffer, (int)position, toRead);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void write(ByteBuffer src, long position) {
|
public void write(ByteBuffer src, long position) {
|
||||||
// Extend if needed
|
// Extend if needed
|
||||||
long endPosition = position + src.capacity();
|
long endPosition = position + src.capacity();
|
||||||
@ -79,14 +81,17 @@ public class ByteArrayBackedDataSource extends DataSource {
|
|||||||
buffer = nb;
|
buffer = nb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void copyTo(OutputStream stream) throws IOException {
|
public void copyTo(OutputStream stream) throws IOException {
|
||||||
stream.write(buffer, 0, (int)size);
|
stream.write(buffer, 0, (int)size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public long size() {
|
public long size() {
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
buffer = null;
|
buffer = null;
|
||||||
size = -1;
|
size = -1;
|
||||||
|
@ -35,16 +35,19 @@ import org.apache.poi.util.IOUtils;
|
|||||||
public class FileBackedDataSource extends DataSource {
|
public class FileBackedDataSource extends DataSource {
|
||||||
private FileChannel channel;
|
private FileChannel channel;
|
||||||
|
|
||||||
|
@SuppressWarnings("resource")
|
||||||
public FileBackedDataSource(File file) throws FileNotFoundException {
|
public FileBackedDataSource(File file) throws FileNotFoundException {
|
||||||
if(!file.exists()) {
|
if(!file.exists()) {
|
||||||
throw new FileNotFoundException(file.toString());
|
throw new FileNotFoundException(file.toString());
|
||||||
}
|
}
|
||||||
this.channel = (new RandomAccessFile(file, "r")).getChannel();
|
this.channel = (new RandomAccessFile(file, "r")).getChannel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileBackedDataSource(FileChannel channel) {
|
public FileBackedDataSource(FileChannel channel) {
|
||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ByteBuffer read(int length, long position) throws IOException {
|
public ByteBuffer read(int length, long position) throws IOException {
|
||||||
if(position >= size()) {
|
if(position >= size()) {
|
||||||
throw new IllegalArgumentException("Position " + position + " past the end of the file");
|
throw new IllegalArgumentException("Position " + position + " past the end of the file");
|
||||||
@ -67,10 +70,12 @@ public class FileBackedDataSource extends DataSource {
|
|||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void write(ByteBuffer src, long position) throws IOException {
|
public void write(ByteBuffer src, long position) throws IOException {
|
||||||
channel.write(src, position);
|
channel.write(src, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void copyTo(OutputStream stream) throws IOException {
|
public void copyTo(OutputStream stream) throws IOException {
|
||||||
// Wrap the OutputSteam as a channel
|
// Wrap the OutputSteam as a channel
|
||||||
WritableByteChannel out = Channels.newChannel(stream);
|
WritableByteChannel out = Channels.newChannel(stream);
|
||||||
@ -78,10 +83,12 @@ public class FileBackedDataSource extends DataSource {
|
|||||||
channel.transferTo(0, channel.size(), out);
|
channel.transferTo(0, channel.size(), out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public long size() throws IOException {
|
public long size() throws IOException {
|
||||||
return channel.size();
|
return channel.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
channel.close();
|
channel.close();
|
||||||
}
|
}
|
||||||
|
@ -19,12 +19,13 @@
|
|||||||
|
|
||||||
package org.apache.poi.poifs.property;
|
package org.apache.poi.poifs.property;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.util.*;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.apache.poi.hpsf.ClassID;
|
import org.apache.poi.hpsf.ClassID;
|
||||||
|
|
||||||
import org.apache.poi.poifs.common.POIFSConstants;
|
import org.apache.poi.poifs.common.POIFSConstants;
|
||||||
import org.apache.poi.poifs.dev.POIFSViewable;
|
import org.apache.poi.poifs.dev.POIFSViewable;
|
||||||
import org.apache.poi.util.ByteField;
|
import org.apache.poi.util.ByteField;
|
||||||
@ -498,9 +499,9 @@ public abstract class Property implements Child, POIFSViewable {
|
|||||||
* @return an Iterator; may not be null, but may have an empty
|
* @return an Iterator; may not be null, but may have an empty
|
||||||
* back end store
|
* back end store
|
||||||
*/
|
*/
|
||||||
public Iterator getViewableIterator()
|
public Iterator<Object> getViewableIterator()
|
||||||
{
|
{
|
||||||
return Collections.EMPTY_LIST.iterator();
|
return Collections.emptyList().iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,12 +42,14 @@ public final class ExpPtg extends ControlPtg {
|
|||||||
this.field_2_first_col = firstCol;
|
this.field_2_first_col = firstCol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void write(LittleEndianOutput out) {
|
public void write(LittleEndianOutput out) {
|
||||||
out.writeByte(sid + getPtgClass());
|
out.writeByte(sid + getPtgClass());
|
||||||
out.writeShort(field_1_first_row);
|
out.writeShort(field_1_first_row);
|
||||||
out.writeShort(field_2_first_col);
|
out.writeShort(field_2_first_col);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
return SIZE;
|
return SIZE;
|
||||||
}
|
}
|
||||||
@ -60,10 +62,12 @@ public final class ExpPtg extends ControlPtg {
|
|||||||
return field_2_first_col;
|
return field_2_first_col;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String toFormulaString() {
|
public String toFormulaString() {
|
||||||
throw new RuntimeException("Coding Error: Expected ExpPtg to be converted from Shared to Non-Shared Formula by ValueRecordsAggregate, but it wasn't");
|
throw new RuntimeException("Coding Error: Expected ExpPtg to be converted from Shared to Non-Shared Formula by ValueRecordsAggregate, but it wasn't");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer buffer = new StringBuffer("[Array Formula or Shared Formula]\n");
|
StringBuffer buffer = new StringBuffer("[Array Formula or Shared Formula]\n");
|
||||||
buffer.append("row = ").append(getRow()).append("\n");
|
buffer.append("row = ").append(getRow()).append("\n");
|
||||||
|
@ -245,6 +245,7 @@ public abstract class Ptg {
|
|||||||
* This helps get rid of gratuitous diffs when comparing two dumps
|
* This helps get rid of gratuitous diffs when comparing two dumps
|
||||||
* Subclasses may output more relevant information by overriding this method
|
* Subclasses may output more relevant information by overriding this method
|
||||||
**/
|
**/
|
||||||
|
@Override
|
||||||
public String toString(){
|
public String toString(){
|
||||||
return this.getClass().toString();
|
return this.getClass().toString();
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,7 @@ public final class TestAbortableListener extends TestCase {
|
|||||||
countSeen = 0;
|
countSeen = 0;
|
||||||
lastRecordSeen = null;
|
lastRecordSeen = null;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public short abortableProcessRecord(Record record) {
|
public short abortableProcessRecord(Record record) {
|
||||||
countSeen++;
|
countSeen++;
|
||||||
lastRecordSeen = record;
|
lastRecordSeen = record;
|
||||||
|
@ -549,22 +549,27 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook {
|
|||||||
// Open the two filesystems
|
// Open the two filesystems
|
||||||
DirectoryNode[] files = new DirectoryNode[2];
|
DirectoryNode[] files = new DirectoryNode[2];
|
||||||
files[0] = (new POIFSFileSystem(HSSFTestDataSamples.openSampleFileStream("Simple.xls"))).getRoot();
|
files[0] = (new POIFSFileSystem(HSSFTestDataSamples.openSampleFileStream("Simple.xls"))).getRoot();
|
||||||
files[1] = (new NPOIFSFileSystem(HSSFTestDataSamples.getSampleFile("Simple.xls"))).getRoot();
|
NPOIFSFileSystem npoifsFileSystem = new NPOIFSFileSystem(HSSFTestDataSamples.getSampleFile("Simple.xls"));
|
||||||
|
try {
|
||||||
|
files[1] = npoifsFileSystem.getRoot();
|
||||||
|
|
||||||
// Open without preserving nodes
|
// Open without preserving nodes
|
||||||
for(DirectoryNode dir : files) {
|
for(DirectoryNode dir : files) {
|
||||||
HSSFWorkbook workbook = new HSSFWorkbook(dir, false);
|
HSSFWorkbook workbook = new HSSFWorkbook(dir, false);
|
||||||
HSSFSheet sheet = workbook.getSheetAt(0);
|
HSSFSheet sheet = workbook.getSheetAt(0);
|
||||||
HSSFCell cell = sheet.getRow(0).getCell(0);
|
HSSFCell cell = sheet.getRow(0).getCell(0);
|
||||||
assertEquals("replaceMe", cell .getRichStringCellValue().getString());
|
assertEquals("replaceMe", cell .getRichStringCellValue().getString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now re-check with preserving
|
// Now re-check with preserving
|
||||||
for(DirectoryNode dir : files) {
|
for(DirectoryNode dir : files) {
|
||||||
HSSFWorkbook workbook = new HSSFWorkbook(dir, true);
|
HSSFWorkbook workbook = new HSSFWorkbook(dir, true);
|
||||||
HSSFSheet sheet = workbook.getSheetAt(0);
|
HSSFSheet sheet = workbook.getSheetAt(0);
|
||||||
HSSFCell cell = sheet.getRow(0).getCell(0);
|
HSSFCell cell = sheet.getRow(0).getCell(0);
|
||||||
assertEquals("replaceMe", cell .getRichStringCellValue().getString());
|
assertEquals("replaceMe", cell .getRichStringCellValue().getString());
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
npoifsFileSystem.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -572,26 +577,31 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook {
|
|||||||
// Open the two filesystems
|
// Open the two filesystems
|
||||||
DirectoryNode[] files = new DirectoryNode[2];
|
DirectoryNode[] files = new DirectoryNode[2];
|
||||||
files[0] = (new POIFSFileSystem(HSSFTestDataSamples.openSampleFileStream("WithEmbeddedObjects.xls"))).getRoot();
|
files[0] = (new POIFSFileSystem(HSSFTestDataSamples.openSampleFileStream("WithEmbeddedObjects.xls"))).getRoot();
|
||||||
files[1] = (new NPOIFSFileSystem(HSSFTestDataSamples.getSampleFile("WithEmbeddedObjects.xls"))).getRoot();
|
NPOIFSFileSystem npoifsFileSystem = new NPOIFSFileSystem(HSSFTestDataSamples.getSampleFile("WithEmbeddedObjects.xls"));
|
||||||
|
try {
|
||||||
|
files[1] = npoifsFileSystem.getRoot();
|
||||||
|
|
||||||
// Check the embedded parts
|
// Check the embedded parts
|
||||||
for(DirectoryNode root : files) {
|
for(DirectoryNode root : files) {
|
||||||
HSSFWorkbook hw = new HSSFWorkbook(root, true);
|
HSSFWorkbook hw = new HSSFWorkbook(root, true);
|
||||||
List<HSSFObjectData> objects = hw.getAllEmbeddedObjects();
|
List<HSSFObjectData> objects = hw.getAllEmbeddedObjects();
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (int i = 0; i < objects.size(); i++) {
|
for (int i = 0; i < objects.size(); i++) {
|
||||||
HSSFObjectData embeddedObject = objects.get(i);
|
HSSFObjectData embeddedObject = objects.get(i);
|
||||||
if (embeddedObject.hasDirectoryEntry()) {
|
if (embeddedObject.hasDirectoryEntry()) {
|
||||||
DirectoryEntry dir = embeddedObject.getDirectory();
|
DirectoryEntry dir = embeddedObject.getDirectory();
|
||||||
if (dir instanceof DirectoryNode) {
|
if (dir instanceof DirectoryNode) {
|
||||||
DirectoryNode dNode = (DirectoryNode)dir;
|
DirectoryNode dNode = (DirectoryNode)dir;
|
||||||
if (hasEntry(dNode,"WordDocument")) {
|
if (hasEntry(dNode,"WordDocument")) {
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertTrue(found);
|
assertTrue(found);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
npoifsFileSystem.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user