diff --git a/src/documentation/content/xdocs/changes.xml b/src/documentation/content/xdocs/changes.xml index 179b0fdac..62100ceab 100644 --- a/src/documentation/content/xdocs/changes.xml +++ b/src/documentation/content/xdocs/changes.xml @@ -37,6 +37,8 @@ + 46320 - added HSSFPictureData.getFormat() + fixed HSSFSheet.shiftRow to move hyperlinks fixed formula parser to correctly resolve sheet-level names 46433 - support for shared formulas in XSSF 46299 - support for carriage return and line break in XWPFRun diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 245f8a1a3..1ba3333f2 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,8 @@ + 46320 - added HSSFPictureData.getFormat() + fixed HSSFSheet.shiftRow to move hyperlinks fixed formula parser to correctly resolve sheet-level names 46433 - support for shared formulas in XSSF 46299 - support for carriage return and line break in XWPFRun diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFPictureData.java b/src/java/org/apache/poi/hssf/usermodel/HSSFPictureData.java index 077035055..81d7c72c6 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFPictureData.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFPictureData.java @@ -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()) diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPictureData.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPictureData.java index bac1ad578..4e7d18253 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPictureData.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPictureData.java @@ -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 }