<changes>
<release version="3.8-beta4" date="2011-??-??">
+ <action dev="poi-developers" type="fix">51514 - allow HSSFObjectData to work with both POIFS and NPOIFS</action>
<action dev="poi-developers" type="fix">51514 - avoid NPE when copying nodes from one HSSF workbook to a new one, when opened from NPOIFS</action>
<action dev="poi-developers" type="fix">51504 - avoid NPE when DefaultRowHeight or DefaultColumnWidth records are missing</action>
<action dev="poi-developers" type="fix">51502 - Correct Subtotal function javadoc entry</action>
import org.apache.poi.hssf.record.SubRecord;
import org.apache.poi.poifs.filesystem.DirectoryEntry;
import org.apache.poi.poifs.filesystem.Entry;
-import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.util.HexDump;
/**
private final ObjRecord _record;
/**
- * Reference to the filesystem, required for retrieving the object data.
+ * Reference to the filesystem root, required for retrieving the object data.
*/
- private final POIFSFileSystem _poifs;
+ private final DirectoryEntry _root;
/**
* Constructs object data by wrapping a lower level object record.
*
* @param record the low-level object record.
- * @param poifs the filesystem, required for retrieving the object data.
+ * @param root the root of the filesystem, required for retrieving the object data.
*/
- public HSSFObjectData(ObjRecord record, POIFSFileSystem poifs)
+ public HSSFObjectData(ObjRecord record, DirectoryEntry root)
{
_record = record;
- _poifs = poifs;
+ _root = root;
}
/**
int streamId = subRecord.getStreamId().intValue();
String streamName = "MBD" + HexDump.toHex(streamId);
- Entry entry = _poifs.getRoot().getEntry(streamName);
+ Entry entry = _root.getEntry(streamName);
if (entry instanceof DirectoryEntry) {
return (DirectoryEntry) entry;
}
* @param records the list of records to search.
* @param objects the list of embedded objects to populate.
*/
- private void getAllEmbeddedObjects(List records, List<HSSFObjectData> objects)
+ private void getAllEmbeddedObjects(List<RecordBase> records, List<HSSFObjectData> objects)
{
- Iterator recordIter = records.iterator();
- while (recordIter.hasNext())
- {
- Object obj = recordIter.next();
- if (obj instanceof ObjRecord)
- {
- // TODO: More convenient way of determining if there is stored binary.
- // TODO: Link to the data stored in the other stream.
- Iterator subRecordIter = ((ObjRecord) obj).getSubRecords().iterator();
- while (subRecordIter.hasNext())
+ for (RecordBase obj : records) {
+ if (obj instanceof ObjRecord)
+ {
+ // TODO: More convenient way of determining if there is stored binary.
+ // TODO: Link to the data stored in the other stream.
+ Iterator<SubRecord> subRecordIter = ((ObjRecord) obj).getSubRecords().iterator();
+ while (subRecordIter.hasNext())
+ {
+ SubRecord sub = subRecordIter.next();
+ if (sub instanceof EmbeddedObjectRefSubRecord)
{
- Object sub = subRecordIter.next();
- if (sub instanceof EmbeddedObjectRefSubRecord)
- {
- objects.add(new HSSFObjectData((ObjRecord) obj, directory.getFileSystem()));
- }
+ objects.add(new HSSFObjectData((ObjRecord) obj, directory));
}
- }
- }
+ }
+ }
+ }
}
public HSSFCreationHelper getCreationHelper() {