Patch from thaichat04 from bug #56194 - HPSF thumbnail format tags are int not unit

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1613256 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2014-07-24 19:34:19 +00:00
parent 7db6e8557e
commit f3dba52888
3 changed files with 13 additions and 2 deletions

View File

@ -202,7 +202,7 @@ public final class Thumbnail {
*/ */
public long getClipboardFormatTag() public long getClipboardFormatTag()
{ {
long clipboardFormatTag = LittleEndian.getUInt(getThumbnail(), long clipboardFormatTag = LittleEndian.getInt(getThumbnail(),
OFFSET_CFTAG); OFFSET_CFTAG);
return clipboardFormatTag; return clipboardFormatTag;
} }
@ -234,7 +234,7 @@ public final class Thumbnail {
throw new HPSFException("Clipboard Format Tag of Thumbnail must " + throw new HPSFException("Clipboard Format Tag of Thumbnail must " +
"be CFTAG_WINDOWS."); "be CFTAG_WINDOWS.");
return LittleEndian.getUInt(getThumbnail(), OFFSET_CF); return LittleEndian.getInt(getThumbnail(), OFFSET_CF);
} }

View File

@ -22,6 +22,7 @@ import java.io.IOException;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.poi.POIDataSamples; import org.apache.poi.POIDataSamples;
import org.apache.poi.hpsf.Thumbnail;
import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.extractor.ExcelExtractor; import org.apache.poi.hssf.extractor.ExcelExtractor;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; 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_REVNUMBER") != -1);
assertTrue(txt.indexOf("PID_THUMBNAIL") != -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();
}
} }

Binary file not shown.