Bugzilla 52348: Avoid exception when creating cell style in a workbook that has an empty xf table
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1220659 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b2461c5c59
commit
ac6c00b6df
@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
<changes>
|
<changes>
|
||||||
<release version="3.8-beta6" date="2012-??-??">
|
<release version="3.8-beta6" date="2012-??-??">
|
||||||
|
<action dev="poi-developers" type="fix">52348 - Avoid exception when creating cell style in a workbook that has an empty xf table</action>
|
||||||
<action dev="poi-developers" type="fix">52219 - fixed XSSFSimpleShape to set rich text attributes from XSSFRichtextString</action>
|
<action dev="poi-developers" type="fix">52219 - fixed XSSFSimpleShape to set rich text attributes from XSSFRichtextString</action>
|
||||||
<action dev="poi-developers" type="fix">52314 - enhanced SheetUtil.getColumnWidth</action>
|
<action dev="poi-developers" type="fix">52314 - enhanced SheetUtil.getColumnWidth</action>
|
||||||
</release>
|
</release>
|
||||||
|
@ -68,15 +68,15 @@ public class XSSFCellStyle implements CellStyle {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a Cell Style from the supplied parts
|
* Creates a Cell Style from the supplied parts
|
||||||
* @param cellXfId The main XF for the cell
|
* @param cellXfId The main XF for the cell. Must be a valid 0-based index into the XF table
|
||||||
* @param cellStyleXfId Optional, style xf
|
* @param cellStyleXfId Optional, style xf. A value of <code>-1</code> means no xf.
|
||||||
* @param stylesSource Styles Source to work off
|
* @param stylesSource Styles Source to work off
|
||||||
*/
|
*/
|
||||||
public XSSFCellStyle(int cellXfId, int cellStyleXfId, StylesTable stylesSource, ThemesTable theme) {
|
public XSSFCellStyle(int cellXfId, int cellStyleXfId, StylesTable stylesSource, ThemesTable theme) {
|
||||||
_cellXfId = cellXfId;
|
_cellXfId = cellXfId;
|
||||||
_stylesSource = stylesSource;
|
_stylesSource = stylesSource;
|
||||||
_cellXf = stylesSource.getCellXfAt(this._cellXfId);
|
_cellXf = stylesSource.getCellXfAt(this._cellXfId);
|
||||||
_cellStyleXf = stylesSource.getCellStyleXfAt(cellStyleXfId);
|
_cellStyleXf = cellStyleXfId == -1 ? null : stylesSource.getCellStyleXfAt(cellStyleXfId);
|
||||||
_theme = theme;
|
_theme = theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -691,4 +691,19 @@ public class TestXSSFCellStyle extends TestCase {
|
|||||||
assertEquals(fmtClone.getFormat("Test##"), reload.getDataFormat());
|
assertEquals(fmtClone.getFormat("Test##"), reload.getDataFormat());
|
||||||
assertFalse(fmtClone.getFormat("Test##") == fmt.getFormat("Test##"));
|
assertFalse(fmtClone.getFormat("Test##") == fmt.getFormat("Test##"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Avoid ArrayIndexOutOfBoundsException when creating cell style
|
||||||
|
* in a workbook that has an empty xf table.
|
||||||
|
*/
|
||||||
|
public void testBug52348() {
|
||||||
|
XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("52348.xlsx");
|
||||||
|
StylesTable st = workbook.getStylesSource();
|
||||||
|
assertEquals(0, st._getStyleXfsSize());
|
||||||
|
|
||||||
|
|
||||||
|
XSSFCellStyle style = workbook.createCellStyle(); // no exception at this point
|
||||||
|
assertNull(style.getStyleXf());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
BIN
test-data/spreadsheet/52348.xlsx
Normal file
BIN
test-data/spreadsheet/52348.xlsx
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user