poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1496516 - in /poi/trunk/src: java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java
Date Tue, 25 Jun 2013 15:19:57 GMT
Author: nick
Date: Tue Jun 25 15:19:56 2013
New Revision: 1496516

URL: http://svn.apache.org/r1496516
Log:
Fix from Florian Hopf from bug #54564 - Fix error message text
 for a workbook with no sheets when a sheet operation is performed

Modified:
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java?rev=1496516&r1=1496515&r2=1496516&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java Tue Jun 25 15:19:56
2013
@@ -429,8 +429,12 @@ public final class HSSFWorkbook extends 
     private void validateSheetIndex(int index) {
         int lastSheetIx = _sheets.size() - 1;
         if (index < 0 || index > lastSheetIx) {
+            String range = "(0.." +    lastSheetIx + ")";
+            if (lastSheetIx == -1) {
+                range = "(no sheets)";
+            }
             throw new IllegalArgumentException("Sheet index ("
-                    + index +") is out of range (0.." +    lastSheetIx + ")");
+                    + index +") is out of range " + range);
         }
     }
 

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java?rev=1496516&r1=1496515&r2=1496516&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java Tue Jun 25 15:19:56
2013
@@ -1040,8 +1040,12 @@ public class XSSFWorkbook extends POIXML
     private void validateSheetIndex(int index) {
         int lastSheetIx = sheets.size() - 1;
         if (index < 0 || index > lastSheetIx) {
+            String range = "(0.." +    lastSheetIx + ")";
+            if (lastSheetIx == -1) {
+                range = "(no sheets)";
+            }
             throw new IllegalArgumentException("Sheet index ("
-                    + index +") is out of range (0.." +    lastSheetIx + ")");
+                    + index +") is out of range " + range);
         }
     }
 

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java?rev=1496516&r1=1496515&r2=1496516&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java Tue Jun 25 15:19:56
2013
@@ -45,6 +45,8 @@ public abstract class BaseTestWorkbook e
             fail("should have thrown exceptiuon due to invalid sheet index");
         } catch (IllegalArgumentException e) {
             // expected during successful test
+            // no negative index in the range message
+            assertFalse(e.getMessage().contains("-1"));
         }
 
         Sheet sheet0 = wb.createSheet();



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


Mime
View raw message