]> source.dussan.org Git - poi.git/commitdiff
Patch from thaichat04 from bug #56194 - HPSF thumbnail format tags are int not unit
authorNick Burch <nick@apache.org>
Thu, 24 Jul 2014 19:34:19 +0000 (19:34 +0000)
committerNick Burch <nick@apache.org>
Thu, 24 Jul 2014 19:34:19 +0000 (19:34 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1613256 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hpsf/Thumbnail.java
src/testcases/org/apache/poi/hpsf/extractor/TestHPSFPropertiesExtractor.java
test-data/hpsf/TestThumbnail.xls [new file with mode: 0644]

index 8d8ba7d20974f434a8d61fcaa2f58a0bcf4746e7..3ab1106397ab137ba3ee75af6ac8b4e5becd2aef 100644 (file)
@@ -202,7 +202,7 @@ public final class Thumbnail {
      */
     public long getClipboardFormatTag()
     {
-        long clipboardFormatTag = LittleEndian.getUInt(getThumbnail(),
+        long clipboardFormatTag = LittleEndian.getInt(getThumbnail(),
                                                        OFFSET_CFTAG);
         return clipboardFormatTag;
     }
@@ -234,7 +234,7 @@ public final class Thumbnail {
             throw new HPSFException("Clipboard Format Tag of Thumbnail must " +
                                     "be CFTAG_WINDOWS.");
 
-        return LittleEndian.getUInt(getThumbnail(), OFFSET_CF);
+        return LittleEndian.getInt(getThumbnail(), OFFSET_CF);
     }
 
 
index ac5283eeabd62bdb5b143bf734c193695e46f22c..22238d75f1a1b663911708875d9f56992821d613 100644 (file)
@@ -22,6 +22,7 @@ import java.io.IOException;
 import junit.framework.TestCase;
 
 import org.apache.poi.POIDataSamples;
+import org.apache.poi.hpsf.Thumbnail;
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.hssf.extractor.ExcelExtractor;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
@@ -120,4 +121,14 @@ public final class TestHPSFPropertiesExtractor extends TestCase {
                assertTrue(txt.indexOf("PID_REVNUMBER") != -1);
                assertTrue(txt.indexOf("PID_THUMBNAIL") != -1);
        }
+       
+    public void testThumbnail() throws Exception {
+        POIFSFileSystem fs = new POIFSFileSystem(_samples.openResourceAsStream("TestThumbnail.xls"));
+        HSSFWorkbook wb = new HSSFWorkbook(fs);
+        Thumbnail thumbnail = new Thumbnail(wb.getSummaryInformation().getThumbnail());
+        assertEquals(-1, thumbnail.getClipboardFormatTag());
+        assertEquals(3, thumbnail.getClipboardFormat());
+        assertNotNull(thumbnail.getThumbnailAsWMF());
+        wb.close();
+    }
 }
diff --git a/test-data/hpsf/TestThumbnail.xls b/test-data/hpsf/TestThumbnail.xls
new file mode 100644 (file)
index 0000000..69cca03
Binary files /dev/null and b/test-data/hpsf/TestThumbnail.xls differ