]> source.dussan.org Git - poi.git/commitdiff
Fix bug #51514 - Allow HSSFObjectData to work with both POIFS and NPOIFS, and fix...
authorNick Burch <nick@apache.org>
Fri, 15 Jul 2011 15:08:51 +0000 (15:08 +0000)
committerNick Burch <nick@apache.org>
Fri, 15 Jul 2011 15:08:51 +0000 (15:08 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1147183 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/status.xml
src/java/org/apache/poi/hssf/usermodel/HSSFObjectData.java
src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java

index bd5eb5bde1949d7b3ca617f6e5f0eac540c27ee5..707aca954358789df1375b7ce08c4118460c1366 100644 (file)
@@ -34,6 +34,7 @@
 
     <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>
index afcfc00ee8824b3f0fe0b066b06b60390fa923d0..5b2a463f4c30eeaee85b29bb64c8c6cdd5698bb6 100644 (file)
@@ -26,7 +26,6 @@ import org.apache.poi.hssf.record.ObjRecord;
 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;
 
 /**
@@ -41,20 +40,20 @@ public final class HSSFObjectData {
     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;
     }
 
     /**
@@ -77,7 +76,7 @@ public final class HSSFObjectData {
         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;
         }
index 54f9c62e5d78add395f5b5664fca02d7f7aa5a47..0acaa140a7b312210c2e7eb785fd62d7901af7ab 100644 (file)
@@ -1726,27 +1726,24 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      * @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() {