poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r1243232 - in /poi/trunk/src: documentation/content/xdocs/status.xml ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
Date Sun, 12 Feb 2012 10:44:17 GMT
Author: yegor
Date: Sun Feb 12 10:44:17 2012
New Revision: 1243232

URL: http://svn.apache.org/viewvc?rev=1243232&view=rev
Log:
validate row and column indexes in SXSSF

Modified:
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.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=1243232&r1=1243231&r2=1243232&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Sun Feb 12 10:44:17 2012
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.8-beta6" date="2012-??-??">
+           <action dev="poi-developers" type="add">validate row number and column index
in SXSSF when creating new rows / cells</action>
            <action dev="poi-developers" type="fix">51498 - fixed evaluation of blank
cells in COUNTIF</action>
            <action dev="poi-developers" type="add">52576 - support changing external
file references in HSSFWorkbook</action>
            <action dev="poi-developers" type="add">49896 - support external references
in FormulaRenderer</action>

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java?rev=1243232&r1=1243231&r2=1243232&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java Sun Feb 12 10:44:17
2012
@@ -20,6 +20,7 @@ package org.apache.poi.xssf.streaming;
 import java.util.Iterator;
 import java.util.NoSuchElementException;
 
+import org.apache.poi.ss.SpreadsheetVersion;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.CellStyle;
 import org.apache.poi.ss.usermodel.Row;
@@ -88,6 +89,8 @@ public class SXSSFRow implements Row
      */
     public Cell createCell(int column, int type)
     {
+        checkBounds(column);
+
         if(column>=_cells.length)
         {
             SXSSFCell[] newCells=new SXSSFCell[Math.max(column+1,_cells.length*2)];
@@ -100,6 +103,19 @@ public class SXSSFRow implements Row
     }
 
     /**
+     * @throws RuntimeException if the bounds are exceeded.
+     */
+    private static void checkBounds(int cellIndex) {
+        SpreadsheetVersion v = SpreadsheetVersion.EXCEL2007;
+        int maxcol = SpreadsheetVersion.EXCEL2007.getLastColumnIndex();
+        if (cellIndex < 0 || cellIndex > maxcol) {
+            throw new IllegalArgumentException("Invalid column index (" + cellIndex
+                    + ").  Allowable column range for " + v.name() + " is (0.."
+                    + maxcol + ") or ('A'..'" + v.getLastColumnName() + "')");
+        }
+    }
+
+    /**
      * Remove the Cell from this row.
      *
      * @param cell the cell to remove

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java?rev=1243232&r1=1243231&r2=1243232&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java Sun Feb 12 10:44:17
2012
@@ -22,6 +22,7 @@ import java.util.Iterator;
 import java.util.TreeMap;
 import java.util.Map;
 
+import org.apache.poi.ss.SpreadsheetVersion;
 import org.apache.poi.ss.usermodel.*;
 
 import org.apache.poi.ss.util.SheetUtil;
@@ -84,6 +85,12 @@ public class SXSSFSheet implements Sheet
      */
     public Row createRow(int rownum)
     {
+        int maxrow = SpreadsheetVersion.EXCEL2007.getLastRowIndex();
+        if (rownum < 0 || rownum > maxrow) {
+            throw new IllegalArgumentException("Invalid row number (" + rownum
+                    + ") outside allowable range (0.." + maxrow + ")");
+        }
+
 //Make the initial allocation as big as the row above.
         Row previousRow=rownum>0?getRow(rownum-1):null;
         int initialAllocationSize=0;



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


Mime
View raw message