tika-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1221110 - /tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/microsoft/ExcelExtractor.java
Date Tue, 20 Dec 2011 06:04:52 GMT
Author: nick
Date: Tue Dec 20 06:04:51 2011
New Revision: 1221110

URL: http://svn.apache.org/viewvc?rev=1221110&view=rev
Log:
TIKA-757 Tidy Excel extractor code after POI upgrade

Modified:
    tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/microsoft/ExcelExtractor.java

Modified: tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/microsoft/ExcelExtractor.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/microsoft/ExcelExtractor.java?rev=1221110&r1=1221109&r2=1221110&view=diff
==============================================================================
--- tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/microsoft/ExcelExtractor.java
(original)
+++ tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/microsoft/ExcelExtractor.java
Tue Dec 20 06:04:51 2011
@@ -28,9 +28,7 @@ import java.util.SortedMap;
 import java.util.TreeMap;
 
 import org.apache.poi.ddf.EscherBSERecord;
-import org.apache.poi.ddf.EscherBitmapBlip;
 import org.apache.poi.ddf.EscherBlipRecord;
-import org.apache.poi.ddf.EscherMetafileBlip;
 import org.apache.poi.ddf.EscherRecord;
 import org.apache.poi.hssf.eventusermodel.FormatTrackingHSSFListener;
 import org.apache.poi.hssf.eventusermodel.HSSFEventFactory;
@@ -56,6 +54,7 @@ import org.apache.poi.hssf.record.SSTRec
 import org.apache.poi.hssf.record.TextObjectRecord;
 import org.apache.poi.hssf.record.chart.SeriesTextRecord;
 import org.apache.poi.hssf.record.common.UnicodeString;
+import org.apache.poi.hssf.usermodel.HSSFPictureData;
 import org.apache.poi.poifs.filesystem.DirectoryEntry;
 import org.apache.poi.poifs.filesystem.DirectoryNode;
 import org.apache.poi.poifs.filesystem.DocumentInputStream;
@@ -550,37 +549,9 @@ public class ExcelExtractor extends Abst
               if (escherRecord instanceof EscherBSERecord) {
                  EscherBlipRecord blip = ((EscherBSERecord) escherRecord).getBlipRecord();
                  if (blip != null) {
-                    // TODO When we have upgraded POI, we can use this code instead
-                    //HSSFPictureData picture = new HSSFPictureData(blip);
-                    //String mimeType = picture.getMimeType();
-                    //TikaInputStream stream = TikaInputStream.get(picture.getData());
-                    
-                    // This code is cut'n'paste from a newer version of POI
-                    String mimeType = "";
-                    switch (blip.getRecordId()) {
-                    case EscherMetafileBlip.RECORD_ID_WMF:
-                       mimeType =  "image/x-wmf";
-                       break;
-                    case EscherMetafileBlip.RECORD_ID_EMF:
-                       mimeType =  "image/x-emf";
-                       break;
-                    case EscherMetafileBlip.RECORD_ID_PICT:
-                       mimeType =  "image/x-pict";
-                       break;
-                    case EscherBitmapBlip.RECORD_ID_PNG:
-                       mimeType =  "image/png";
-                       break;
-                    case EscherBitmapBlip.RECORD_ID_JPEG:
-                       mimeType =  "image/jpeg";
-                       break;
-                    case EscherBitmapBlip.RECORD_ID_DIB:
-                       mimeType =  "image/bmp";
-                       break;
-                    default:
-                       mimeType =  "image/unknown";
-                       break;
-                    }
-                    TikaInputStream stream = TikaInputStream.get(blip.getPicturedata());
+                    HSSFPictureData picture = new HSSFPictureData(blip);
+                    String mimeType = picture.getMimeType();
+                    TikaInputStream stream = TikaInputStream.get(picture.getData());
                     
                     // Handle the embeded resource
                     extractor.handleEmbeddedResource(



Mime
View raw message