View | Details | Raw Unified | Return to bug 55650
Collapse All | Expand All

(-)a/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java (-1 / +1 lines)
Lines 302-308 public class StylesTable extends POIXMLDocumentPart { Link Here
302
   }
302
   }
303
303
304
	public CTXf getCellStyleXfAt(int idx) {
304
	public CTXf getCellStyleXfAt(int idx) {
305
		return styleXfs.get(idx);
305
		return idx < styleXfs.size() ? styleXfs.get(idx) : null;
306
	}
306
	}
307
	public int putCellStyleXf(CTXf cellStyleXf) {
307
	public int putCellStyleXf(CTXf cellStyleXf) {
308
		styleXfs.add(cellStyleXf);
308
		styleXfs.add(cellStyleXf);
(-)a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java (+14 lines)
Lines 836-839 public class TestXSSFCellStyle extends TestCase { Link Here
836
        assertNull(style.getStyleXf());
836
        assertNull(style.getStyleXf());
837
    }
837
    }
838
838
839
    /**
840
     * Avoid ArrayIndexOutOfBoundsException  when getting cell style
841
     * in a workbook that has an empty xf table.
842
     */
843
    public void testBug55650() {
844
        XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("52348.xlsx");
845
        StylesTable st = workbook.getStylesSource();
846
        assertEquals(0, st._getStyleXfsSize());
847
848
        // no exception at this point
849
        XSSFCellStyle style = workbook.getSheetAt(0).getRow(0).getCell(0).getCellStyle();
850
        assertNull(style.getStyleXf());
851
    }
852
839
}
853
}

Return to bug 55650