You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by jo...@apache.org on 2009/02/03 00:10:31 UTC
svn commit: r740146 - in /poi/trunk/src:
documentation/content/xdocs/changes.xml
documentation/content/xdocs/status.xml
java/org/apache/poi/ss/formula/FormulaParser.java
testcases/org/apache/poi/hssf/model/TestFormulaParser.java
Author: josh
Date: Mon Feb 2 23:10:30 2009
New Revision: 740146
URL: http://svn.apache.org/viewvc?rev=740146&view=rev
Log:
Fix for bug 46643 - formula parser should encode range operator with tMemFunc
Modified:
poi/trunk/src/documentation/content/xdocs/changes.xml
poi/trunk/src/documentation/content/xdocs/status.xml
poi/trunk/src/java/org/apache/poi/ss/formula/FormulaParser.java
poi/trunk/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java
Modified: poi/trunk/src/documentation/content/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/changes.xml?rev=740146&r1=740145&r2=740146&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/changes.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/changes.xml Mon Feb 2 23:10:30 2009
@@ -37,6 +37,7 @@
<!-- Don't forget to update status.xml too! -->
<release version="3.5-beta5" date="2008-??-??">
+ <action dev="POI-DEVELOPERS" type="fix">46643 - Fixed formula parser to encode range operator with tMemFunc</action>
<action dev="POI-DEVELOPERS" type="fix">46647 - Fixed COUNTIF NE operator and other special cases involving type conversion</action>
<action dev="POI-DEVELOPERS" type="add">46635 - Added a method to remove slides</action>
<action dev="POI-DEVELOPERS" type="fix">46520 - Fixed HSSFFont.applyFont() to properly apply font to overlapping regions</action>
Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=740146&r1=740145&r2=740146&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Mon Feb 2 23:10:30 2009
@@ -34,6 +34,7 @@
<!-- Don't forget to update changes.xml too! -->
<changes>
<release version="3.5-beta5" date="2008-??-??">
+ <action dev="POI-DEVELOPERS" type="fix">46643 - Fixed formula parser to encode range operator with tMemFunc</action>
<action dev="POI-DEVELOPERS" type="fix">46647 - Fixed COUNTIF NE operator and other special cases involving type conversion</action>
<action dev="POI-DEVELOPERS" type="add">46635 - Added a method to remove slides</action>
<action dev="POI-DEVELOPERS" type="fix">46520 - Fixed HSSFFont.applyFont() to properly apply font to overlapping regions</action>
Modified: poi/trunk/src/java/org/apache/poi/ss/formula/FormulaParser.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/FormulaParser.java?rev=740146&r1=740145&r2=740146&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/FormulaParser.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/FormulaParser.java Mon Feb 2 23:10:30 2009
@@ -344,7 +344,9 @@
new ParseNode(ptgA),
new ParseNode(ptgB),
};
- return new ParseNode(RangePtg.instance, children);
+ ParseNode result = new ParseNode(RangePtg.instance, children);
+ MemFuncPtg memFuncPtg = new MemFuncPtg(result.getEncodedSize());
+ return new ParseNode(memFuncPtg, result);
}
return new ParseNode(simplified);
}
@@ -590,6 +592,10 @@
}
boolean isVarArgs = !fm.hasFixedArgsLength();
int funcIx = fm.getIndex();
+ if (false && funcIx == 4 && args.length == 1) {
+ // TODO - make POI behave more like Excel when summing a single argument:
+ // return new ParseNode(AttrPtg.getSumSingle(), args);
+ }
validateNumArgs(args.length, fm);
AbstractFunctionPtg retval;
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java?rev=740146&r1=740145&r2=740146&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java Mon Feb 2 23:10:30 2009
@@ -45,6 +45,7 @@
import org.apache.poi.hssf.record.formula.PercentPtg;
import org.apache.poi.hssf.record.formula.PowerPtg;
import org.apache.poi.hssf.record.formula.Ptg;
+import org.apache.poi.hssf.record.formula.RangePtg;
import org.apache.poi.hssf.record.formula.Ref3DPtg;
import org.apache.poi.hssf.record.formula.RefPtg;
import org.apache.poi.hssf.record.formula.StringPtg;
@@ -973,4 +974,26 @@
MemFuncPtg mf = (MemFuncPtg)ptgs[0];
assertEquals(45, mf.getLenRefSubexpression());
}
+
+ public void testRange_bug46643() {
+ String formula = "Sheet1!A1:Sheet1!B3";
+ HSSFWorkbook wb = new HSSFWorkbook();
+ wb.createSheet("Sheet1");
+ Ptg[] ptgs = FormulaParser.parse(formula, HSSFEvaluationWorkbook.create(wb));
+
+ if (ptgs.length == 3) {
+ confirmTokenClasses(ptgs, new Class[] { Ref3DPtg.class, Ref3DPtg.class, RangePtg.class,});
+ throw new AssertionFailedError("Identified bug 46643");
+ }
+
+ Class [] expectedClasses = {
+ MemFuncPtg.class,
+ Ref3DPtg.class,
+ Ref3DPtg.class,
+ RangePtg.class,
+ };
+ confirmTokenClasses(ptgs, expectedClasses);
+ MemFuncPtg mf = (MemFuncPtg)ptgs[0];
+ assertEquals(15, mf.getLenRefSubexpression());
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org