You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2014/07/19 00:50:54 UTC

svn commit: r1611830 - in /poi/trunk: src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationWorkbook.java src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java test-data/spreadsheet/ref-56737.xlsx

Author: nick
Date: Fri Jul 18 22:50:54 2014
New Revision: 1611830

URL: http://svn.apache.org/r1611830
Log:
Bit more towards XSSF name support for #56737, will need some deeper changes though to fully implement

Added:
    poi/trunk/test-data/spreadsheet/ref-56737.xlsx   (with props)
Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationWorkbook.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationWorkbook.java?rev=1611830&r1=1611829&r2=1611830&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationWorkbook.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationWorkbook.java Fri Jul 18 22:50:54 2014
@@ -103,16 +103,39 @@ public final class XSSFEvaluationWorkboo
 	}
 
 	public NameXPtg getNameXPtg(String name, int sheetRefIndex) {
+	    // First, try to find it as a User Defined Function
         IndexedUDFFinder udfFinder = (IndexedUDFFinder)getUDFFinder();
         FreeRefFunction func = udfFinder.findFunction(name);
-		if(func == null) return null;
-        else return new NameXPtg(0, udfFinder.getFunctionIndex(name));
+        if (func != null) {
+            return new NameXPtg(0, udfFinder.getFunctionIndex(name));
+        }
+        
+        // Otherwise, try it as a named range
+        XSSFName xname = _uBook.getName(name);
+        if (xname != null) {
+            int nameAt = _uBook.getNameIndex(name);
+            return new NameXPtg(xname.getSheetIndex(), nameAt);
+        } else {
+            return null;
+        }
 	}
 
     public String resolveNameXText(NameXPtg n) {
         int idx = n.getNameIndex();
+        String name = null;
+        
+        // First, try to find it as a User Defined Function
         IndexedUDFFinder udfFinder = (IndexedUDFFinder)getUDFFinder();
-        return udfFinder.getFunctionName(idx);
+        name = udfFinder.getFunctionName(idx);
+        if (name != null) return name;
+        
+        // Otherwise, try it as a named range
+        XSSFName xname = _uBook.getNameAt(idx);
+        if (xname != null) {
+            name = xname.getNameName();
+        }
+        
+        return name;
     }
 
 	public EvaluationSheet getSheet(int sheetIndex) {

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=1611830&r1=1611829&r2=1611830&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 Fri Jul 18 22:50:54 2014
@@ -2678,10 +2678,5 @@ public final class TestBugs extends Base
         
         // Try to evaluate everything
         eval.evaluateAll();
-        
-        // Try to set the same kinds of formula elsewhere
-        Cell newF = s.getRow(0).createCell(10, Cell.CELL_TYPE_FORMULA);
-        // TODO Fix this
-        //newF.setCellFormula("Defines!NR_To_A1");
     }
 }

Added: poi/trunk/test-data/spreadsheet/ref-56737.xlsx
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/ref-56737.xlsx?rev=1611830&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/test-data/spreadsheet/ref-56737.xlsx
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



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