mirror of https://github.com/apache/poi.git
added HSSFPictureData.getFormat() as requested in #46320
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@730213 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
70847d620e
commit
8a446dc155
|
@ -37,6 +37,8 @@
|
|||
|
||||
<!-- Don't forget to update status.xml too! -->
|
||||
<release version="3.5-beta5" date="2008-??-??">
|
||||
<action dev="POI-DEVELOPERS" type="add">46320 - added HSSFPictureData.getFormat()</action>
|
||||
<action dev="POI-DEVELOPERS" type="fix">fixed HSSFSheet.shiftRow to move hyperlinks</action>
|
||||
<action dev="POI-DEVELOPERS" type="fix">fixed formula parser to correctly resolve sheet-level names</action>
|
||||
<action dev="POI-DEVELOPERS" type="fix">46433 - support for shared formulas in XSSF</action>
|
||||
<action dev="POI-DEVELOPERS" type="add">46299 - support for carriage return and line break in XWPFRun</action>
|
||||
|
|
|
@ -34,6 +34,8 @@
|
|||
<!-- Don't forget to update changes.xml too! -->
|
||||
<changes>
|
||||
<release version="3.5-beta5" date="2008-??-??">
|
||||
<action dev="POI-DEVELOPERS" type="add">46320 - added HSSFPictureData.getFormat()</action>
|
||||
<action dev="POI-DEVELOPERS" type="fix">fixed HSSFSheet.shiftRow to move hyperlinks</action>
|
||||
<action dev="POI-DEVELOPERS" type="fix">fixed formula parser to correctly resolve sheet-level names</action>
|
||||
<action dev="POI-DEVELOPERS" type="fix">46433 - support for shared formulas in XSSF</action>
|
||||
<action dev="POI-DEVELOPERS" type="add">46299 - support for carriage return and line break in XWPFRun</action>
|
||||
|
|
|
@ -62,9 +62,23 @@ public class HSSFPictureData implements PictureData
|
|||
return blip.getPicturedata();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.poi.hssf.usermodel.PictureData#suggestFileExtension()
|
||||
/**
|
||||
*
|
||||
* @return format of the picture.
|
||||
* @see HSSFWorkbook#PICTURE_TYPE_DIB
|
||||
* @see HSSFWorkbook#PICTURE_TYPE_WMF
|
||||
* @see HSSFWorkbook#PICTURE_TYPE_EMF
|
||||
* @see HSSFWorkbook#PICTURE_TYPE_PNG
|
||||
* @see HSSFWorkbook#PICTURE_TYPE_JPEG
|
||||
* @see HSSFWorkbook#PICTURE_TYPE_PICT
|
||||
*/
|
||||
public int getFormat(){
|
||||
return blip.getRecordId() - (short)0xF018;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #getFormat
|
||||
*/
|
||||
public String suggestFileExtension()
|
||||
{
|
||||
switch (blip.getRecordId())
|
||||
|
|
|
@ -55,12 +55,14 @@ public final class TestHSSFPictureData extends TestCase{
|
|||
assertNotNull(jpg);
|
||||
assertEquals(192, jpg.getWidth());
|
||||
assertEquals(176, jpg.getHeight());
|
||||
assertEquals(HSSFWorkbook.PICTURE_TYPE_JPEG, pict.getFormat());
|
||||
} else if (ext.equals("png")){
|
||||
//try to read image data using javax.imageio.* (JDK 1.4+)
|
||||
BufferedImage png = ImageIO.read(new ByteArrayInputStream(data));
|
||||
assertNotNull(png);
|
||||
assertEquals(300, png.getWidth());
|
||||
assertEquals(300, png.getHeight());
|
||||
assertEquals(HSSFWorkbook.PICTURE_TYPE_PNG, pict.getFormat());
|
||||
} else {
|
||||
//TODO: test code for PICT, WMF and EMF
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue