Bug 57355

Summary: XSSFPicture.resize() throws ArrayIndexOutOfBoundsException
Product: POI Reporter: Dominik Stadler <dominik.stadler>
Component: XSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: critical    
Priority: P2    
Version: 3.11-dev   
Target Milestone: ---   
Hardware: PC   
OS: All   

Description Dominik Stadler 2014-12-16 10:28:50 UTC
The change "r1638623: Picture method to resize with different scales in width and height, Date: Mittwoch, 12. November 2014 01:19:00" introduced a method XSSFSheet.getColumnWidthInPixels() which causes the following:

java.lang.ArrayIndexOutOfBoundsException: -1
    at java.util.ArrayList.elementData(ArrayList.java:400)
    at java.util.ArrayList.get(ArrayList.java:413)
    at org.apache.poi.xssf.model.StylesTable.getStyleAt(StylesTable.java:239)
    at org.apache.poi.xssf.usermodel.XSSFSheet.getColumnWidthInPixels(XSSFSheet.java:718)
    at org.apache.poi.ss.util.ImageUtils.getDimensionFromAnchor(ImageUtils.java:231)
    at org.apache.poi.ss.util.ImageUtils.setPreferredSize(ImageUtils.java:143)
    at org.apache.poi.xssf.usermodel.XSSFPicture.getPreferredSize(XSSFPicture.java:221)
    at org.apache.poi.xssf.usermodel.XSSFPicture.resize(XSSFPicture.java:180)
    at org.apache.poi.xssf.usermodel.XSSFPicture.resize(XSSFPicture.java:155)
    at org.apache.poi.xssf.usermodel.XSSFPicture.resize(XSSFPicture.java:146)
    at org.apache.poi.xssf.usermodel.TestXSSFPicture.testResizeWithColumns(TestXSSFPicture.java:260)

Fix is likely to simply remove two lines from the new method which are actually not needed, but cause this error.
Comment 1 Dominik Stadler 2014-12-16 10:40:45 UTC
Fixed on trunk by removing the two unnecessary lines.