poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r676995 - in /poi/trunk/src: documentation/content/xdocs/ java/org/apache/poi/hssf/usermodel/ testcases/org/apache/poi/hssf/data/ testcases/org/apache/poi/hssf/usermodel/
Date Tue, 15 Jul 2008 18:13:51 GMT
Author: yegor
Date: Tue Jul 15 11:13:50 2008
New Revision: 676995

URL: http://svn.apache.org/viewvc?rev=676995&view=rev
Log:
fixed bug #45322: HSSFSheet.autoSizeColumn() throws NPE when cell number format was not found

Added:
    poi/trunk/src/testcases/org/apache/poi/hssf/data/45322.xls   (with props)
Modified:
    poi/trunk/src/documentation/content/xdocs/changes.xml
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java

Modified: poi/trunk/src/documentation/content/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/changes.xml?rev=676995&r1=676994&r2=676995&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/changes.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/changes.xml Tue Jul 15 11:13:50 2008
@@ -37,6 +37,7 @@
 
 		<!-- Don't forget to update status.xml too! -->
         <release version="3.1.1-alpha1" date="2008-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">45322 - Fixed NPE in HSSFSheet.autoSizeColumn()
when cell number format was not found</action>
            <action dev="POI-DEVELOPERS" type="add">45380 - Missing return keyword in
ArrayPtg.toFormulaString()</action>
            <action dev="POI-DEVELOPERS" type="add">44958 - Record level support for
Data Tables. (No formula parser support though)</action>
            <action dev="POI-DEVELOPERS" type="add">35583 - Include a version class,
org.apache.poi.Version, to allow easy introspection of the POI version</action>

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=676995&r1=676994&r2=676995&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Tue Jul 15 11:13:50 2008
@@ -34,6 +34,7 @@
 	<!-- Don't forget to update changes.xml too! -->
     <changes>
         <release version="3.1.1-alpha1" date="2008-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">45322 - Fixed NPE in HSSFSheet.autoSizeColumn()
when cell number format was not found</action>
            <action dev="POI-DEVELOPERS" type="add">45380 - Missing return keyword in
ArrayPtg.toFormulaString()</action>
            <action dev="POI-DEVELOPERS" type="add">44958 - Record level support for
Data Tables. (No formula parser support though)</action>
            <action dev="POI-DEVELOPERS" type="add">35583 - Include a version class,
org.apache.poi.Version, to allow easy introspection of the POI version</action>

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java?rev=676995&r1=676994&r2=676995&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java Tue Jul 15 11:13:50
2008
@@ -278,21 +278,23 @@
      * Get the contents of the format string, by looking up
      *  the DataFormat against the bound workbook
      * @see org.apache.poi.hssf.usermodel.HSSFDataFormat
+     * @return the format string or "General" if not found
      */
     public String getDataFormatString() {
-    	HSSFDataFormat format = new HSSFDataFormat(workbook);
-    	
-        return format.getFormat(getDataFormat());
+        return getDataFormatString(workbook);
     }
     /**
      * Get the contents of the format string, by looking up
      *  the DataFormat against the supplied workbook
      * @see org.apache.poi.hssf.usermodel.HSSFDataFormat
+     *
+     * @return the format string or "General" if not found
      */
     public String getDataFormatString(Workbook workbook) {
     	HSSFDataFormat format = new HSSFDataFormat(workbook);
     	
-        return format.getFormat(getDataFormat());
+        int idx = getDataFormat();
+        return idx == -1 ? "General" : format.getFormat(getDataFormat());
     }
 
     /**

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java?rev=676995&r1=676994&r2=676995&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java Tue Jul 15 11:13:50 2008
@@ -1851,9 +1851,7 @@
             } else {
                 String sval = null;
                 if (cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC) {
-                    HSSFDataFormat dataformat = wb.createDataFormat();
-                    short idx = style.getDataFormat();
-                    String format = dataformat.getFormat(idx).replaceAll("\"", "");
+                    String format = style.getDataFormatString().replaceAll("\"", "");
                     double value = cell.getNumericCellValue();
                     try {
                         NumberFormat fmt;

Added: poi/trunk/src/testcases/org/apache/poi/hssf/data/45322.xls
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/data/45322.xls?rev=676995&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/src/testcases/org/apache/poi/hssf/data/45322.xls
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java?rev=676995&r1=676994&r2=676995&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java Tue Jul 15 11:13:50
2008
@@ -1353,4 +1353,13 @@
         // TODO - check the formula once tables and
         //  arrays are properly supported
     }
+
+    /**
+     * 45322: HSSFSheet.autoSizeColumn fails when style.getDataFormat() returns -1
+     */
+    public void test45322() throws Exception {
+        HSSFWorkbook wb = openSample("44958.xls");
+        HSSFSheet sh = wb.getSheetAt(0);
+        for(short i=0; i < 30; i++) sh.autoSizeColumn(i);
+     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message