You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ye...@apache.org on 2011/12/19 10:06:11 UTC
svn commit: r1220659 - in /poi/trunk:
src/documentation/content/xdocs/status.xml
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java
test-data/spreadsheet/52348.xlsx
Author: yegor
Date: Mon Dec 19 09:06:10 2011
New Revision: 1220659
URL: http://svn.apache.org/viewvc?rev=1220659&view=rev
Log:
Bugzilla 52348: Avoid exception when creating cell style in a workbook that has an empty xf table
Added:
poi/trunk/test-data/spreadsheet/52348.xlsx (with props)
Modified:
poi/trunk/src/documentation/content/xdocs/status.xml
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java
Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=1220659&r1=1220658&r2=1220659&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Mon Dec 19 09:06:10 2011
@@ -34,6 +34,7 @@
<changes>
<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">52314 - enhanced SheetUtil.getColumnWidth</action>
</release>
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java?rev=1220659&r1=1220658&r2=1220659&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java Mon Dec 19 09:06:10 2011
@@ -68,15 +68,15 @@ public class XSSFCellStyle implements Ce
/**
* Creates a Cell Style from the supplied parts
- * @param cellXfId The main XF for the cell
- * @param cellStyleXfId Optional, style xf
+ * @param cellXfId The main XF for the cell. Must be a valid 0-based index into the XF table
+ * @param cellStyleXfId Optional, style xf. A value of <code>-1</code> means no xf.
* @param stylesSource Styles Source to work off
*/
public XSSFCellStyle(int cellXfId, int cellStyleXfId, StylesTable stylesSource, ThemesTable theme) {
_cellXfId = cellXfId;
_stylesSource = stylesSource;
_cellXf = stylesSource.getCellXfAt(this._cellXfId);
- _cellStyleXf = stylesSource.getCellStyleXfAt(cellStyleXfId);
+ _cellStyleXf = cellStyleXfId == -1 ? null : stylesSource.getCellStyleXfAt(cellStyleXfId);
_theme = theme;
}
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java?rev=1220659&r1=1220658&r2=1220659&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java Mon Dec 19 09:06:10 2011
@@ -691,4 +691,19 @@ public class TestXSSFCellStyle extends T
assertEquals(fmtClone.getFormat("Test##"), reload.getDataFormat());
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());
+ }
+
}
Added: poi/trunk/test-data/spreadsheet/52348.xlsx
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/52348.xlsx?rev=1220659&view=auto
==============================================================================
Binary file - no diff available.
Propchange: poi/trunk/test-data/spreadsheet/52348.xlsx
------------------------------------------------------------------------------
svn:mime-type = application/zip
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org