poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1703999 - in /poi/trunk: src/java/org/apache/poi/ss/formula/OperationEvaluationContext.java src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java test-data/spreadsheet/57925.xls
Date Sat, 19 Sep 2015 12:22:42 GMT
Author: centic
Date: Sat Sep 19 12:22:42 2015
New Revision: 1703999

URL: http://svn.apache.org/viewvc?rev=1703999&view=rev
Log:
Bug 57925: Add unit test and a simple fix to at least avoid the NPE when Workbooks have invalid
external references

Added:
    poi/trunk/test-data/spreadsheet/57925.xls
Modified:
    poi/trunk/src/java/org/apache/poi/ss/formula/OperationEvaluationContext.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/OperationEvaluationContext.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/OperationEvaluationContext.java?rev=1703999&r1=1703998&r2=1703999&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/OperationEvaluationContext.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/OperationEvaluationContext.java Sat Sep 19
12:22:42 2015
@@ -94,7 +94,11 @@ public final class OperationEvaluationCo
 		if (externalSheet == null || externalSheet.getWorkbookName() == null) {
 			// sheet is in same workbook
 			targetEvaluator = _bookEvaluator;
-			otherFirstSheetIndex = _workbook.getSheetIndex(externalSheet.getSheetName());
+			if(externalSheet == null) {
+			    otherFirstSheetIndex = 0;
+			} else {
+			    otherFirstSheetIndex = _workbook.getSheetIndex(externalSheet.getSheetName());
+			}
 			
 			if (externalSheet instanceof ExternalSheetRange) {
 			    String lastSheetName = ((ExternalSheetRange)externalSheet).getLastSheetName();

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=1703999&r1=1703998&r2=1703999&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 Sat Sep 19 12:22:42
2015
@@ -2846,4 +2846,22 @@ public final class TestBugs extends Base
 
         wb.close();
     }
+    
+    @Test
+    public void test57925() throws IOException {
+        Workbook wb = HSSFTestDataSamples.openSampleWorkbook("57925.xls");
+        
+        wb.getCreationHelper().createFormulaEvaluator().evaluateAll();
+        
+        for(int i = 0;i < wb.getNumberOfSheets();i++) {
+            Sheet sheet = wb.getSheetAt(i);
+            for(Row row : sheet) {
+                for(Cell cell : row) {
+                    new DataFormatter().formatCellValue(cell);
+                }
+            }
+        }
+        
+        wb.close();
+    }
 }

Added: poi/trunk/test-data/spreadsheet/57925.xls
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/57925.xls?rev=1703999&view=auto
==============================================================================
Binary files poi/trunk/test-data/spreadsheet/57925.xls (added) and poi/trunk/test-data/spreadsheet/57925.xls
Sat Sep 19 12:22:42 2015 differ



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


Mime
View raw message