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:
Yegor Kozlov 2008-12-30 18:51:56 +00:00
parent 49297979bb
commit 0e193f895b
4 changed files with 22 additions and 2 deletions

View File

@ -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>

View File

@ -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>

View File

@ -62,8 +62,22 @@ 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()
{

View File

@ -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
}