poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1611950 - in /poi/trunk/src: java/org/apache/poi/ss/formula/ java/org/apache/poi/ss/formula/ptg/ ooxml/java/org/apache/poi/xssf/usermodel/
Date Sat, 19 Jul 2014 19:42:07 GMT
Author: nick
Date: Sat Jul 19 19:42:07 2014
New Revision: 1611950

URL: http://svn.apache.org/r1611950
Log:
Provide XSSF-style external sheet support for areas, similar to the recent cell reference
support. #56737

Modified:
    poi/trunk/src/java/org/apache/poi/ss/formula/OperationEvaluationContext.java
    poi/trunk/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java
    poi/trunk/src/java/org/apache/poi/ss/formula/ptg/Area3DPtg.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationWorkbook.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=1611950&r1=1611949&r2=1611950&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 Jul 19
19:42:07 2014
@@ -28,6 +28,7 @@ import org.apache.poi.ss.formula.eval.Re
 import org.apache.poi.ss.formula.eval.ValueEval;
 import org.apache.poi.ss.formula.functions.FreeRefFunction;
 import org.apache.poi.ss.formula.ptg.Area3DPtg;
+import org.apache.poi.ss.formula.ptg.Area3DPxg;
 import org.apache.poi.ss.formula.ptg.NameXPtg;
 import org.apache.poi.ss.formula.ptg.Ptg;
 import org.apache.poi.ss.formula.ptg.Ref3DPtg;
@@ -279,17 +280,25 @@ public final class OperationEvaluationCo
         SheetRefEvaluator sre = createExternSheetRefEvaluator(rptg.getSheetName(), rptg.getExternalWorkbookNumber());
         return new LazyRefEval(rptg.getRow(), rptg.getColumn(), sre);
     }
+    
 	public ValueEval getAreaEval(int firstRowIndex, int firstColumnIndex,
 			int lastRowIndex, int lastColumnIndex) {
 		SheetRefEvaluator sre = getRefEvaluatorForCurrentSheet();
 		return new LazyAreaEval(firstRowIndex, firstColumnIndex, lastRowIndex, lastColumnIndex,
sre);
 	}
-	public ValueEval getArea3DEval(int firstRowIndex, int firstColumnIndex,
-			int lastRowIndex, int lastColumnIndex, int extSheetIndex) {
-		SheetRefEvaluator sre = createExternSheetRefEvaluator(extSheetIndex);
-		return new LazyAreaEval(firstRowIndex, firstColumnIndex, lastRowIndex, lastColumnIndex,
sre);
-	}
+    public ValueEval getArea3DEval(Area3DPtg aptg) {
+        SheetRefEvaluator sre = createExternSheetRefEvaluator(aptg.getExternSheetIndex());
+        return new LazyAreaEval(aptg.getFirstRow(), aptg.getFirstColumn(),
+                aptg.getLastRow(), aptg.getLastColumn(), sre);
+    }
+    public ValueEval getArea3DEval(Area3DPxg aptg) {
+        SheetRefEvaluator sre = createExternSheetRefEvaluator(aptg.getSheetName(), aptg.getExternalWorkbookNumber());
+        return new LazyAreaEval(aptg.getFirstRow(), aptg.getFirstColumn(),
+                aptg.getLastRow(), aptg.getLastColumn(), sre);
+    }
+    
 	public ValueEval getNameXEval(NameXPtg nameXPtg) {
+	    // TODO Need HSSF and XSSF versions of these
       ExternalSheet externSheet = _workbook.getExternalSheet(nameXPtg.getSheetRefIndex());
       if(externSheet == null)
          return new NameXEval(nameXPtg);

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java?rev=1611950&r1=1611949&r2=1611950&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java Sat Jul 19 19:42:07
2014
@@ -44,6 +44,7 @@ import org.apache.poi.ss.formula.functio
 import org.apache.poi.ss.formula.functions.Function;
 import org.apache.poi.ss.formula.functions.IfFunc;
 import org.apache.poi.ss.formula.ptg.Area3DPtg;
+import org.apache.poi.ss.formula.ptg.Area3DPxg;
 import org.apache.poi.ss.formula.ptg.AreaErrPtg;
 import org.apache.poi.ss.formula.ptg.AreaPtg;
 import org.apache.poi.ss.formula.ptg.AttrPtg;
@@ -679,8 +680,10 @@ public final class WorkbookEvaluator {
            return ec.getRef3DEval((Ref3DPxg)ptg);
        }
        if (ptg instanceof Area3DPtg) {
-           Area3DPtg aptg = (Area3DPtg) ptg;
-           return ec.getArea3DEval(aptg.getFirstRow(), aptg.getFirstColumn(), aptg.getLastRow(),
aptg.getLastColumn(), aptg.getExternSheetIndex());
+           return ec.getArea3DEval((Area3DPtg)ptg);
+       }
+       if (ptg instanceof Area3DPxg) {
+           return ec.getArea3DEval((Area3DPxg)ptg);
        }
        if (ptg instanceof RefPtg) {
            RefPtg rptg = (RefPtg) ptg;

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/ptg/Area3DPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/ptg/Area3DPtg.java?rev=1611950&r1=1611949&r2=1611950&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/ptg/Area3DPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/ptg/Area3DPtg.java Sat Jul 19 19:42:07 2014
@@ -25,12 +25,13 @@ import org.apache.poi.util.LittleEndianI
 import org.apache.poi.util.LittleEndianOutput;
 
 /**
- * Title:        Area 3D Ptg - 3D reference (Sheet + Area)<P>
- * Description:  Defined a area in Extern Sheet. <P>
- * REFERENCE:  <P>
- * @author Libin Roman (Vista Portal LDT. Developer)
- * @author avik
- * @author Jason Height (jheight at chariot dot net dot au)
+ * <p>Title:        Area 3D Ptg - 3D reference (Sheet + Area)</p>
+ * <p>Description:  Defined an area in Extern Sheet. </p>
+ * <p>REFERENCE:  </p>
+ * 
+ * <p>This is HSSF only, as it matches the HSSF file format way of
+ *  referring to the sheet by an extern index. The XSSF equivalent
+ *  is {@link Area3DPxg}
  */
 public final class Area3DPtg extends AreaPtgBase implements WorkbookDependentFormula, ExternSheetReferenceToken
{
 	public final static byte sid = 0x3b;

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=1611950&r1=1611949&r2=1611950&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 Sat
Jul 19 19:42:07 2014
@@ -28,7 +28,7 @@ import org.apache.poi.ss.formula.Formula
 import org.apache.poi.ss.formula.FormulaType;
 import org.apache.poi.ss.formula.SheetIdentifier;
 import org.apache.poi.ss.formula.functions.FreeRefFunction;
-import org.apache.poi.ss.formula.ptg.Area3DPtg;
+import org.apache.poi.ss.formula.ptg.Area3DPxg;
 import org.apache.poi.ss.formula.ptg.NamePtg;
 import org.apache.poi.ss.formula.ptg.NameXPtg;
 import org.apache.poi.ss.formula.ptg.Ptg;
@@ -150,8 +150,14 @@ public final class XSSFEvaluationWorkboo
         }
     }
     public Ptg get3DReferencePtg(AreaReference area, SheetIdentifier sheet) {
-        // TODO Implement properly
-        return new Area3DPtg(area, getExternalSheetIndex(sheet._sheetIdentifier.getName()));
+        String sheetName = sheet._sheetIdentifier.getName();
+        
+        if (sheet._bookName != null) {
+            int bookIndex = resolveBookIndex(sheet._bookName);
+            return new Area3DPxg(bookIndex, sheetName, area);
+        } else {
+            return new Area3DPxg(sheetName, area);
+        }
     }
 
     public String resolveNameXText(NameXPtg n) {



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


Mime
View raw message