poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r628035 - in /poi/trunk/src: documentation/content/xdocs/ scratchpad/src/org/apache/poi/hssf/record/formula/functions/ scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/
Date Fri, 15 Feb 2008 12:13:36 GMT
Author: nick
Date: Fri Feb 15 04:13:25 2008
New Revision: 628035

URL: http://svn.apache.org/viewvc?rev=628035&view=rev
Log:
Fix from Josh from bug #44421 - Update Match function to properly support Area references

Modified:
    poi/trunk/src/documentation/content/xdocs/changes.xml
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Match.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestMatch.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=628035&r1=628034&r2=628035&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/changes.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/changes.xml Fri Feb 15 04:13:25 2008
@@ -36,6 +36,7 @@
 
 		<!-- Don't forget to update status.xml too! -->
         <release version="3.1-beta1" date="2008-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">44421 - Update Match function to
properly support Area references</action>
            <action dev="POI-DEVELOPERS" type="fix">44417 - Improved handling of references
for the need to quote the sheet name for some formulas, but not when fetching a sheet by name</action>
            <action dev="POI-DEVELOPERS" type="fix">44413 - Fix for circular references
in INDEX, OFFSET, VLOOKUP formulas, where a cell is actually allowed to reference itself</action>
            <action dev="POI-DEVELOPERS" type="fix">44403 - Fix for Mid function handling
its arguments wrong</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=628035&r1=628034&r2=628035&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Fri Feb 15 04:13:25 2008
@@ -33,6 +33,7 @@
 	<!-- Don't forget to update changes.xml too! -->
     <changes>
         <release version="3.1-beta1" date="2008-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">44421 - Update Match function to
properly support Area references</action>
            <action dev="POI-DEVELOPERS" type="fix">44417 - Improved handling of references
for the need to quote the sheet name for some formulas, but not when fetching a sheet by name</action>
            <action dev="POI-DEVELOPERS" type="fix">44413 - Fix for circular references
in INDEX, OFFSET, VLOOKUP formulas, where a cell is actually allowed to reference itself</action>
            <action dev="POI-DEVELOPERS" type="fix">44403 - Fix for Mid function handling
its arguments wrong</action>

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Match.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Match.java?rev=628035&r1=628034&r2=628035&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Match.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Match.java Fri
Feb 15 04:13:25 2008
@@ -26,7 +26,6 @@
 import org.apache.poi.hssf.record.formula.eval.RefEval;
 import org.apache.poi.hssf.record.formula.eval.StringEval;
 import org.apache.poi.hssf.record.formula.eval.ValueEval;
-import org.apache.poi.hssf.util.AreaReference;
 
 /**
  * Implementation for the MATCH() Excel function.<p/>
@@ -188,7 +187,7 @@
 	private static double evaluateMatchTypeArg(Eval arg, int srcCellRow, short srcCellCol) 
 			throws EvalEx {
 		Eval match_type = arg;
-		if(arg instanceof AreaReference) {
+		if(arg instanceof AreaEval) {
 			AreaEval ae = (AreaEval) arg;
 			// an area ref can work as a scalar value if it is 1x1
 			if(ae.isColumn() &&  ae.isRow()) {

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestMatch.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestMatch.java?rev=628035&r1=628034&r2=628035&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestMatch.java
(original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestMatch.java
Fri Feb 15 04:13:25 2008
@@ -21,6 +21,7 @@
 
 import org.apache.poi.hssf.record.formula.AreaPtg;
 import org.apache.poi.hssf.record.formula.eval.Area2DEval;
+import org.apache.poi.hssf.record.formula.eval.AreaEval;
 import org.apache.poi.hssf.record.formula.eval.BoolEval;
 import org.apache.poi.hssf.record.formula.eval.ErrorEval;
 import org.apache.poi.hssf.record.formula.eval.Eval;
@@ -53,6 +54,13 @@
 		NumericValueEval nve = (NumericValueEval)actualEval;
 		assertEquals(expected, nve.getNumberValue(), 0);
 	}
+	/**
+	 * Convenience method
+	 * @return <code>new Area2DEval(new AreaPtg(ref), values)</code>
+	 */
+	private static AreaEval createAreaEval(String ref, ValueEval[] values) {
+		return new Area2DEval(new AreaPtg(ref), values);
+	}
 	
 	public void testSimpleNumber() {
 		
@@ -64,9 +72,7 @@
 			new NumberEval(25),	
 		};
 		
-		AreaPtg areaPtg = new AreaPtg("A1:A5");
-		Area2DEval ae = new Area2DEval(areaPtg, values);
-		
+		AreaEval ae = createAreaEval("A1:A5", values);
 		
 		confirmInt(2, invokeMatch(new NumberEval(5), ae, MATCH_LARGEST_LTE));
 		confirmInt(2, invokeMatch(new NumberEval(5), ae, MATCH_EXACT));
@@ -86,9 +92,7 @@
 			new NumberEval(4),	
 		};
 		
-		AreaPtg areaPtg = new AreaPtg("A1:A5");
-		Area2DEval ae = new Area2DEval(areaPtg, values);
-		
+		AreaEval ae = createAreaEval("A1:A5", values);
 		
 		confirmInt(2, invokeMatch(new NumberEval(10), ae, MATCH_SMALLEST_GTE));
 		confirmInt(2, invokeMatch(new NumberEval(10), ae, MATCH_EXACT));
@@ -108,8 +112,7 @@
 			new StringEval("Ian"),	
 		};
 		
-		AreaPtg areaPtg = new AreaPtg("A1:A5");
-		Area2DEval ae = new Area2DEval(areaPtg, values);
+		AreaEval ae = createAreaEval("A1:A5", values);
 		
 		// Note String comparisons are case insensitive
 		confirmInt(3, invokeMatch(new StringEval("Ed"), ae, MATCH_LARGEST_LTE));
@@ -129,8 +132,7 @@
 				BoolEval.TRUE,	
 		};
 		
-		AreaPtg areaPtg = new AreaPtg("A1:A4");
-		Area2DEval ae = new Area2DEval(areaPtg, values);
+		AreaEval ae = createAreaEval("A1:A4", values);
 		
 		// Note String comparisons are case insensitive
 		confirmInt(2, invokeMatch(BoolEval.FALSE, ae, MATCH_LARGEST_LTE));
@@ -157,8 +159,7 @@
 				new StringEval("Ed"),	
 		};
 		
-		AreaPtg areaPtg = new AreaPtg("A1:A13");
-		Area2DEval ae = new Area2DEval(areaPtg, values);
+		AreaEval ae = createAreaEval("A1:A13", values);
 		
 		assertEquals(ErrorEval.NA, invokeMatch(new StringEval("Aaron"), ae, MATCH_LARGEST_LTE));
 		
@@ -181,4 +182,34 @@
 		confirmInt(12, invokeMatch(BoolEval.TRUE, ae, MATCH_LARGEST_LTE));
 	}
 	
+
+	/**
+	 * Ensures that the match_type argument can be an <tt>AreaEval</tt>.<br/>
+	 * Bugzilla 44421
+	 */
+	public void testMatchArgTypeArea() {
+		
+		ValueEval[] values = {
+			new NumberEval(4),	
+			new NumberEval(5),	
+			new NumberEval(10),	
+			new NumberEval(10),	
+			new NumberEval(25),	
+		};
+		
+		AreaEval ae = createAreaEval("A1:A5", values);
+
+		AreaEval matchAE = createAreaEval("C1:C1", new ValueEval[] { MATCH_LARGEST_LTE, });
+		
+		try {
+			confirmInt(4, invokeMatch(new NumberEval(10), ae, matchAE));
+		} catch (RuntimeException e) {
+			if(e.getMessage().startsWith("Unexpected match_type type")) {
+				// identified bug 44421 
+				fail(e.getMessage());
+			}
+			// some other error ??
+			throw e;
+		}
+	}
 }



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


Mime
View raw message