]> source.dussan.org Git - poi.git/commitdiff
Initial checkin for FormulaEvaluator and associated tests
authorAvik Sengupta <avik@apache.org>
Thu, 19 May 2005 12:15:52 +0000 (12:15 +0000)
committerAvik Sengupta <avik@apache.org>
Thu, 19 May 2005 12:15:52 +0000 (12:15 +0000)
Author: Amol Deshmukh

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353688 13f79535-47bb-0310-9956-ffa450edef68

396 files changed:
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/AddEval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/Area2DEval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/Area3DEval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/AreaEval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/BlankEval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/BoolEval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/ConcatEval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/DivideEval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/EqualEval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/ErrorEval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/Eval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/FuncVarEval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/FunctionEval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/GreaterEqualEval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/GreaterThanEval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/LessEqualEval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/LessThanEval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/MultiplyEval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/NotEqualEval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/NumberEval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/NumericOperationEval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/NumericValueEval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/OperationEval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/PowerEval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/Ref2DEval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/Ref3DEval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/RefEval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/RelationalOperationEval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/StringEval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/StringOperationEval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/StringValueEval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/SubtractEval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/UnaryMinusEval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/UnaryPlusEval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/ValueEval.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/ValueEvalToNumericXlator.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Abs.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Absref.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Acos.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Acosh.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Activecell.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Addbar.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Addcommand.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Addmenu.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Address.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Addtoolbar.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/And.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Apptitle.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Areas.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Argument.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Asc.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Asin.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Asinh.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Atan.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Atan2.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Atanh.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Avedev.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Average.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Averagea.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Betadist.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Betainv.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Binomdist.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/BooleanFunction.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Call.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Caller.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Cancelkey.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Ceiling.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Cell.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Char.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Checkcommand.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Chidist.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Chiinv.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Chitest.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Choose.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Clean.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Code.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Column.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Columns.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Combin.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Concatenate.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Confidence.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Correl.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Cos.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Cosh.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Count.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Counta.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Countblank.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Countif.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Covar.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Createobject.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Critbinom.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Customrepeat.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Customundo.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Date.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Datedif.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Datestring.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Datevalue.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Daverage.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Day.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Days360.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Db.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dbcs.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dcount.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dcounta.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Ddb.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/DefaultFunctionImpl.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Degrees.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Deletebar.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Deletecommand.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Deletemenu.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Deletetoolbar.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Deref.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Devsq.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dget.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dialogbox.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Directory.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dmax.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dmin.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Documents.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dollar.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dproduct.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dstdev.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dstdevp.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dsum.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dvar.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dvarp.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Echo.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Enablecommand.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Enabletool.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Error.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Errortype.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Evaluate.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Even.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Exact.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Exec.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Execute.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Exp.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Expondist.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Externalflag.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fact.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/False.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fclose.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fdist.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Files.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Find.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Findb.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Finv.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fisher.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fisherinv.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fixed.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Floor.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fopen.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Forecast.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Formulaconvert.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fpos.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fread.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Freadln.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Frequency.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fsize.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Ftest.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Function.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fv.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fwrite.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fwriteln.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Gammadist.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Gammainv.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Gammaln.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Geomean.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getbar.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getcell.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getchartitem.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getdef.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getdocument.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getformula.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getlinkinfo.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getmovie.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getname.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getnote.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getobject.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getpivotdata.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getpivotfield.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getpivotitem.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getpivottable.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Gettool.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Gettoolbar.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getwindow.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getworkbook.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getworkspace.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Goto.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Group.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Growth.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Halt.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Harmean.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Help.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Hlookup.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Hour.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Hyperlink.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Hypgeomdist.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Index.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Indirect.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Info.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Initiate.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Input.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Int.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Intercept.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Ipmt.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Irr.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/IsError.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/IsNa.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Isblank.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Iserr.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Islogical.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Isnontext.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Isnumber.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Ispmt.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Isref.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Istext.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Kurt.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Large.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Lasterror.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Left.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Leftb.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Len.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Lenb.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Linest.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Links.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Ln.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Log.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Log10.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Logest.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Loginv.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Lognormdist.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Lookup.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Lower.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Match.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Max.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Maxa.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Mdeterm.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Median.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Mid.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Midb.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Min.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Mina.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Minute.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Minverse.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Mirr.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Mmult.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Mod.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Mode.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Month.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Moviecommand.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/N.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Na.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Names.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Negbinomdist.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Normdist.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Norminv.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Normsdist.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Normsinv.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Not.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Note.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Now.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Nper.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Npv.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Numberstring.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/NumericFunction.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Odd.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Offset.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Opendialog.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Optionslistsget.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Or.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Pause.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Pearson.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Percentile.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Percentrank.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Permut.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Phonetic.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Pi.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Pivotadddata.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Pmt.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Poisson.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Poke.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Power.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Ppmt.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Presstool.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Prob.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Product.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Proper.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Pv.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Quartile.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Radians.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Rand.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Rank.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Rate.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Reftext.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Register.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Registerid.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Relref.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Renamecommand.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Replace.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Replaceb.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Rept.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Request.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Resettoolbar.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Restart.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Result.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Resume.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Right.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Rightb.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Roman.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Round.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Rounddown.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Roundup.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Row.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Rows.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Rsq.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Savedialog.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Savetoolbar.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Scenarioget.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Search.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Searchb.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Second.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Selection.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Series.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Setname.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Setvalue.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Showbar.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sign.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sin.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sinh.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Skew.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sln.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Slope.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Small.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Spellingcheck.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sqrt.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Standardize.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Stdev.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Stdeva.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Stdevp.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Stdevpa.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Step.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Steyx.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Substitute.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Subtotal.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sum.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sumif.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sumproduct.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sumsq.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sumx2my2.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sumx2py2.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sumxmy2.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Syd.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/T.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Tan.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Tanh.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Tdist.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Terminate.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Text.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Textbox.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Textref.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Time.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Timevalue.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Tinv.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Today.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Transpose.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Trend.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Trim.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Trimmean.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/True.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Trunc.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Ttest.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Type.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Unregister.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Upper.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Usdollar.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Value.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Var.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Vara.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Varp.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Varpa.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Vdb.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Viewget.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Vlookup.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Volatile.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Weekday.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Weibull.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Windows.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Windowtitle.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Year.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Ztest.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java [new file with mode: 0644]
src/scratchpad/testcases/org/apache/poi/hssf/data/FormulaEvalTestData.xls [new file with mode: 0644]
src/scratchpad/testcases/org/apache/poi/hssf/record/formula/eval/GenericFormulaTestCase.java [new file with mode: 0644]
src/scratchpad/testcases/org/apache/poi/hssf/record/formula/eval/TestEverything.java [new file with mode: 0644]
src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestEverything.java [new file with mode: 0644]

diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/AddEval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/AddEval.java
new file mode 100644 (file)
index 0000000..bc993a6
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Created on May 8, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+import org.apache.poi.hssf.record.formula.AddPtg;
+import org.apache.poi.hssf.record.formula.Ptg;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ * This is a documentation of the observed behaviour of 
+ * the '+' operator in Excel:
+ * <ol>
+ * <li> 1+TRUE = 2
+ * <li> 1+FALSE = 1
+ * <li> 1+"true" = #VALUE!
+ * <li> 1+"1" = 2
+ * <li> 1+A1 = #VALUE if A1 contains "1"
+ * <li> 1+A1 = 2 if A1 contains ="1"
+ * <li> 1+A1 = 2 if A1 contains TRUE or =TRUE
+ * <li> 1+A1 = #VALUE! if A1 contains "TRUE" or ="TRUE"
+ */
+public class AddEval extends NumericOperationEval {
+
+    private AddPtg delegate;
+    private static final ValueEvalToNumericXlator NUM_XLATOR = 
+        new ValueEvalToNumericXlator((short)
+                ( ValueEvalToNumericXlator.BOOL_IS_PARSED 
+                | ValueEvalToNumericXlator.EVALUATED_REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.EVALUATED_REF_STRING_IS_PARSED
+                | ValueEvalToNumericXlator.REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.STRING_IS_PARSED
+                ));
+
+    public AddEval(Ptg ptg) {
+        delegate = (AddPtg) ptg;
+    }
+
+    public ValueEvalToNumericXlator getXlator() {
+        return NUM_XLATOR;
+    }
+    
+    
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        Eval retval = null;
+        double d = 0;
+        switch (operands.length) {
+        default: // will rarely happen. currently the parser itself fails.
+            retval = ErrorEval.UNKNOWN_ERROR;
+            break;
+        case 2:
+            for (int i = 0, iSize = 2; retval==null && i < iSize; i++) {
+                ValueEval ve = singleOperandEvaluate(operands[i], srcRow, srcCol);
+                if (ve instanceof NumericValueEval) {
+                    d += ((NumericValueEval) ve).getNumberValue();
+                }
+                else if (ve instanceof BlankEval) {
+                    // do nothing
+                }
+                else {
+                    retval = ErrorEval.VALUE_INVALID;
+                }
+            } // end for inside case
+        } // end switch
+        
+        if (retval == null) {
+            retval = Double.isNaN(d) ? (ValueEval) ErrorEval.VALUE_INVALID : new NumberEval(d);
+        }
+
+        return retval;
+    }
+
+    public int getNumberOfOperands() {
+        return delegate.getNumberOfOperands();
+    }
+
+    public int getType() {
+        return delegate.getType();
+    }
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/Area2DEval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/Area2DEval.java
new file mode 100644 (file)
index 0000000..4156a3c
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Created on May 8, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+import org.apache.poi.hssf.record.formula.AreaPtg;
+import org.apache.poi.hssf.record.formula.Ptg;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *   
+ */
+public class Area2DEval implements AreaEval {
+
+    private AreaPtg delegate;
+
+    private ValueEval[] values;
+
+    public Area2DEval(Ptg ptg, ValueEval[] values) {
+        this.delegate = (AreaPtg) ptg;
+        this.values = values;
+    }
+
+    public short getFirstColumn() {
+        return delegate.getFirstColumn();
+    }
+
+    public int getFirstRow() {
+        return delegate.getFirstRow();
+    }
+
+    public short getLastColumn() {
+        return delegate.getLastColumn();
+    }
+
+    public int getLastRow() {
+        return delegate.getLastRow();
+    }
+
+    public ValueEval[] getValues() {
+        return values;
+    }
+    
+    public ValueEval getValueAt(int row, short col) {
+        ValueEval retval;
+        int index = ((row-getFirstRow())*(getLastColumn()-getFirstColumn()+1))+(col-getFirstColumn());
+        if (index <0 || index >= values.length)
+            retval = ErrorEval.VALUE_INVALID;
+        else 
+            retval = values[index];
+        return retval;
+    }
+    
+    public boolean contains(int row, short col) {
+        return (getFirstRow() <= row) && (getLastRow() >= row) 
+            && (getFirstColumn() <= col) && (getLastColumn() >= col);
+    }
+    
+    public boolean containsRow(int row) {
+        return (getFirstRow() <= row) && (getLastRow() >= row);
+    }
+    
+    public boolean containsColumn(short col) {
+        return (getFirstColumn() <= col) && (getLastColumn() >= col);
+    }
+    
+    public boolean isColumn() {
+        return delegate.getFirstColumn() == delegate.getLastColumn();
+    }
+
+    public boolean isRow() {
+        return delegate.getFirstRow() == delegate.getLastRow();
+    }
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/Area3DEval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/Area3DEval.java
new file mode 100644 (file)
index 0000000..50d7820
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Created on May 8, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+import org.apache.poi.hssf.record.formula.Area3DPtg;
+import org.apache.poi.hssf.record.formula.Ptg;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class Area3DEval implements AreaEval {
+
+    private Area3DPtg delegate;
+
+    private ValueEval[] values;
+
+    public Area3DEval(Ptg ptg, ValueEval[] values) {
+        this.values = values;
+        this.delegate = (Area3DPtg) ptg;
+    }
+
+    public short getFirstColumn() {
+        return delegate.getFirstColumn();
+    }
+
+    public int getFirstRow() {
+        return delegate.getFirstRow();
+    }
+
+    public short getLastColumn() {
+        return delegate.getLastColumn();
+    }
+
+    public int getLastRow() {
+        return delegate.getLastRow();
+    }
+
+    public ValueEval[] getValues() {
+        return values;
+    }
+    
+    public ValueEval getValueAt(int row, short col) {
+        ValueEval retval;
+        int index = (row-getFirstRow())*(col-getFirstColumn());
+        if (index <0 || index >= values.length)
+            retval = ErrorEval.VALUE_INVALID;
+        else 
+            retval = values[index];
+        return retval;
+    }
+    
+    public boolean contains(int row, short col) {
+        return (getFirstRow() <= row) && (getLastRow() >= row) 
+            && (getFirstColumn() <= col) && (getLastColumn() >= col);
+    }
+    
+    public boolean containsRow(int row) {
+        return (getFirstRow() <= row) && (getLastRow() >= row);
+    }
+    
+    public boolean containsColumn(short col) {
+        return (getFirstColumn() <= col) && (getLastColumn() >= col);
+    }
+    
+    
+    public boolean isColumn() {
+        return delegate.getFirstColumn() == delegate.getLastColumn();
+    }
+
+    public boolean isRow() {
+        return delegate.getFirstRow() == delegate.getLastRow();
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/AreaEval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/AreaEval.java
new file mode 100644 (file)
index 0000000..3db24b7
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * Created on May 8, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public interface AreaEval extends ValueEval {
+
+    /**
+     * returns the 0-based index of the first row in
+     * this area.
+     * @return
+     */
+    public int getFirstRow();
+
+    /**
+     * returns the 0-based index of the last row in
+     * this area.
+     * @return
+     */
+    public int getLastRow();
+
+    /**
+     * returns the 0-based index of the first col in
+     * this area.
+     * @return
+     */
+    public short getFirstColumn();
+
+    /**
+     * returns the 0-based index of the last col in
+     * this area.
+     * @return
+     */
+    public short getLastColumn();
+    
+    /**
+     * returns true if the Area's start and end row indexes
+     * are same. This result of this method should agree
+     * with getFirstRow() == getLastRow().
+     * @return
+     */
+    public boolean isRow();
+    
+    /**
+     * returns true if the Area's start and end col indexes
+     * are same. This result of this method should agree
+     * with getFirstColumn() == getLastColumn().
+     * @return
+     */
+    public boolean isColumn();
+
+    /**
+     * The array of values  in this area. Although the area
+     * maybe 1D (ie. isRow() or isColumn() returns true) or 2D
+     * the returned array is 1D.
+     * @return
+     */
+    public ValueEval[] getValues();
+
+    /**
+     * returns the ValueEval from the values array at the specified 
+     * row and col index. The specified indexes should be absolute indexes
+     * in the sheet and not relative indexes within the area. Also,
+     * if contains(row, col) evaluates to true, a null value will
+     * bre returned.
+     * @param row
+     * @param col
+     * @return
+     */
+    public ValueEval getValueAt(int row, short col);
+    
+    /**
+     * returns true if the cell at row and col specified 
+     * as absolute indexes in the sheet is contained in 
+     * this area.
+     * @param row
+     * @param col
+     * @return
+     */
+    public boolean contains(int row, short col);
+    
+    /**
+     * returns true if the specified col is in range
+     * @param col
+     * @return
+     */
+    public boolean containsColumn(short col);
+    
+    /**
+     * returns true if the specified row is in range
+     * @param row
+     * @return
+     */
+    public boolean containsRow(int row);
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/BlankEval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/BlankEval.java
new file mode 100644 (file)
index 0000000..76c6d41
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Created on May 9, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt; This class is a
+ *         marker class. It is a special value for empty cells.
+ */
+public class BlankEval implements ValueEval {
+
+    public static BlankEval INSTANCE = new BlankEval();
+
+    private BlankEval() {
+    }
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/BoolEval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/BoolEval.java
new file mode 100644 (file)
index 0000000..f7b22b4
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Created on May 8, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+import org.apache.poi.hssf.record.formula.BoolPtg;
+import org.apache.poi.hssf.record.formula.Ptg;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class BoolEval implements NumericValueEval, StringValueEval {
+
+    private boolean value;
+    
+    public static final BoolEval FALSE = new BoolEval(false);
+    
+    public static final BoolEval TRUE = new BoolEval(true);
+
+    public BoolEval(Ptg ptg) {
+        this.value = ((BoolPtg) ptg).getValue();
+    }
+
+    private BoolEval(boolean value) {
+        this.value = value;
+    }
+
+    public boolean getBooleanValue() {
+        return value;
+    }
+
+    public double getNumberValue() {
+        return value ? (short) 1 : (short) 0;
+    }
+
+    public String getStringValue() {
+        return value ? "TRUE" : "FALSE";
+    }
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/ConcatEval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/ConcatEval.java
new file mode 100644 (file)
index 0000000..8b5b882
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Created on May 8, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+import org.apache.poi.hssf.record.formula.ConcatPtg;
+import org.apache.poi.hssf.record.formula.Ptg;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class ConcatEval extends StringOperationEval {
+
+    private ConcatPtg delegate;
+
+    public ConcatEval(Ptg ptg) {
+        this.delegate = (ConcatPtg) ptg;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        Eval retval = null;
+        StringBuffer sb = null;
+        
+        switch (operands.length) {
+        default: // paranoid check :)
+            retval = ErrorEval.UNKNOWN_ERROR;
+            break;
+        case 2:
+            sb = new StringBuffer();
+            for (int i = 0, iSize = 2; retval == null && i < iSize; i++) { 
+                
+                ValueEval ve = singleOperandEvaluate(operands[i], srcRow, srcCol);
+                if (ve instanceof StringValueEval) {
+                    StringValueEval sve = (StringValueEval) ve;
+                    sb.append(sve.getStringValue());
+                }
+                else if (ve instanceof BlankEval) {
+                    // do nothing
+                }
+                else { // must be an error eval
+                    retval = ve;
+                }
+            }
+        }
+        
+        if (retval == null) {
+            retval = new StringEval(sb.toString());
+        }
+        return retval;
+    }
+
+    public int getNumberOfOperands() {
+        return delegate.getNumberOfOperands();
+    }
+
+    public int getType() {
+        return delegate.getType();
+    }
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/DivideEval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/DivideEval.java
new file mode 100644 (file)
index 0000000..3b9d193
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Created on May 8, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+import org.apache.poi.hssf.record.formula.Ptg;
+import org.apache.poi.hssf.record.formula.DividePtg;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class DivideEval extends NumericOperationEval {
+
+    private DividePtg delegate;
+
+    private static final ValueEvalToNumericXlator NUM_XLATOR = 
+        new ValueEvalToNumericXlator((short)
+                ( ValueEvalToNumericXlator.BOOL_IS_PARSED 
+                | ValueEvalToNumericXlator.EVALUATED_REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.EVALUATED_REF_STRING_IS_PARSED
+                | ValueEvalToNumericXlator.REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.STRING_IS_PARSED
+                ));
+
+    public DivideEval(Ptg ptg) {
+        delegate = (DividePtg) ptg;
+    }
+    
+    protected ValueEvalToNumericXlator getXlator() {
+        return NUM_XLATOR;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        Eval retval = null;
+        double d0 = 0;
+        double d1 = 0;
+        switch (operands.length) {
+        default: // will rarely happen. currently the parser itself fails.
+            retval = ErrorEval.UNKNOWN_ERROR;
+            break;
+        case 2:
+            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
+            if (ve instanceof NumericValueEval) {
+                d0 = ((NumericValueEval) ve).getNumberValue();
+            }
+            else if (ve instanceof BlankEval) {
+                // do nothing
+            }
+            else {
+                retval = ErrorEval.VALUE_INVALID;
+            }
+            
+            if (retval == null) { // no error yet
+                ve = singleOperandEvaluate(operands[1], srcRow, srcCol);
+                if (ve instanceof NumericValueEval) {
+                    d1 = ((NumericValueEval) ve).getNumberValue();
+                }
+                else if (ve instanceof BlankEval) {
+                    // do nothing
+                }
+                else {
+                    retval = ErrorEval.VALUE_INVALID;
+                }
+            }
+        } // end switch
+
+        if (retval == null) {
+            retval = (d1 == 0) 
+                ? ErrorEval.DIV_ZERO
+                : (Double.isNaN(d0) || Double.isNaN(d1)) 
+                    ? (ValueEval) ErrorEval.VALUE_INVALID 
+                    : new NumberEval(d0 / d1);
+        }
+        return retval;
+    }
+
+    public int getNumberOfOperands() {
+        return delegate.getNumberOfOperands();
+    }
+
+    public int getType() {
+        return delegate.getType();
+    }
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/EqualEval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/EqualEval.java
new file mode 100644 (file)
index 0000000..0fdd8cb
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Created on May 8, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+import org.apache.poi.hssf.record.formula.EqualPtg;
+import org.apache.poi.hssf.record.formula.Ptg;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class EqualEval extends RelationalOperationEval {
+
+    private EqualPtg delegate;
+
+    public EqualEval(Ptg ptg) {
+        this.delegate = (EqualPtg) ptg;
+    }
+
+    
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        ValueEval retval = null;
+        
+        RelationalValues rvs = super.doEvaluate(operands, srcRow, srcCol);
+        retval = rvs.ee;
+        int result = 0;
+        if (retval == null) {
+            result = doComparison(rvs.bs);
+            if (result == 0) {
+                result = doComparison(rvs.ss);
+            }
+            if (result == 0) {
+                result = doComparison(rvs.ds);
+            }
+
+            retval = (result == 0) ? BoolEval.TRUE : BoolEval.FALSE;
+        }
+
+        return retval;
+    }
+
+    public int getNumberOfOperands() {
+        return delegate.getNumberOfOperands();
+    }
+
+    public int getType() {
+        return delegate.getType();
+    }
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/ErrorEval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/ErrorEval.java
new file mode 100644 (file)
index 0000000..e1c8a7f
--- /dev/null
@@ -0,0 +1,609 @@
+/*
+ * Created on May 8, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ * 
+ * Error code reference from OpenOffice documentation: <br/><TABLE WIDTH=575
+ * BORDER=1 CELLPADDING=2 CELLSPACING=0 BGCOLOR="#ffffff"> <COL WIDTH=42> <COL
+ * WIDTH=118> <COL WIDTH=401>
+ * <TR VALIGN=TOP>
+ * <TD WIDTH=42 BGCOLOR="#ffffff">
+ * <P CLASS="tablehead" ALIGN=LEFT>
+ * Error Code
+ * </P>
+ * </TD>
+ * <TD WIDTH=118 BGCOLOR="#ffffff">
+ * <P CLASS="tablehead" ALIGN=LEFT>
+ * Message
+ * </P>
+ * </TD>
+ * <TD WIDTH=401 BGCOLOR="#ffffff">
+ * <P CLASS="tablehead" ALIGN=LEFT>
+ * Explanation
+ * </P>
+ * </TD>
+ * </TR>
+ * <TR VALIGN=TOP>
+ * <TD WIDTH=42 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * 501
+ * </P>
+ * </TD>
+ * <TD WIDTH=118 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Invalid character
+ * </P>
+ * </TD>
+ * <TD WIDTH=401 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Character in a formula is not valid, for example, &quot;=1Eq&quot; instead of
+ * &quot;=1E2&quot;.
+ * </P>
+ * </TD>
+ * </TR>
+ * <TR VALIGN=TOP>
+ * <TD WIDTH=42 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * 502
+ * </P>
+ * </TD>
+ * <TD WIDTH=118 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Invalid argument
+ * </P>
+ * </TD>
+ * <TD WIDTH=401 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Function argument is not valid, for example, a negative number for the root
+ * function.
+ * </P>
+ * </TD>
+ * </TR>
+ * <TR VALIGN=TOP>
+ * <TD WIDTH=42 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * 503
+ * </P>
+ * </TD>
+ * <TD WIDTH=118 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Invalid floating point operation
+ * </P>
+ * </TD>
+ * <TD WIDTH=401 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Division by 0, or another calculation that results in an overflow of the
+ * defined value range.
+ * </P>
+ * </TD>
+ * </TR>
+ * <TR VALIGN=TOP>
+ * <TD WIDTH=42 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * 504
+ * </P>
+ * </TD>
+ * <TD WIDTH=118 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Parameter list error
+ * </P>
+ * </TD>
+ * <TD WIDTH=401 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Function parameter is not valid, for example, text instead of a number, or a
+ * domain reference instead of cell reference.
+ * </P>
+ * </TD>
+ * </TR>
+ * <TR VALIGN=TOP>
+ * <TD WIDTH=42 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * 505
+ * </P>
+ * </TD>
+ * <TD WIDTH=118 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Internal syntax error
+ * </P>
+ * </TD>
+ * <TD WIDTH=401 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Not used
+ * </P>
+ * </TD>
+ * </TR>
+ * <TR VALIGN=TOP>
+ * <TD WIDTH=42 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * 506
+ * </P>
+ * </TD>
+ * <TD WIDTH=118 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Invalid semicolon
+ * </P>
+ * </TD>
+ * <TD WIDTH=401 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Not used
+ * </P>
+ * </TD>
+ * </TR>
+ * <TR VALIGN=TOP>
+ * <TD WIDTH=42 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * 507
+ * </P>
+ * </TD>
+ * <TD WIDTH=118 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Error: Pair missing
+ * </P>
+ * </TD>
+ * <TD WIDTH=401 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Not used
+ * </P>
+ * </TD>
+ * </TR>
+ * <TR VALIGN=TOP>
+ * <TD WIDTH=42 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * 508
+ * </P>
+ * </TD>
+ * <TD WIDTH=118 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Error: Pair missing
+ * </P>
+ * </TD>
+ * <TD WIDTH=401 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Missing bracket, for example, closing brackets, but no opening brackets
+ * </P>
+ * </TD>
+ * </TR>
+ * <TR VALIGN=TOP>
+ * <TD WIDTH=42 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * 509
+ * </P>
+ * </TD>
+ * <TD WIDTH=118 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Missing operator
+ * </P>
+ * </TD>
+ * <TD WIDTH=401 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Operator is missing, for example, &quot;=2(3+4) * &quot;, where the operator
+ * between &quot;2&quot; and &quot;(&quot; is missing.
+ * </P>
+ * </TD>
+ * </TR>
+ * <TR VALIGN=TOP>
+ * <TD WIDTH=42 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * 510
+ * </P>
+ * </TD>
+ * <TD WIDTH=118 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Missing variable
+ * </P>
+ * </TD>
+ * <TD WIDTH=401 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Variable is missing, for example when two operators are together
+ * &quot;=1+*2&quot;.
+ * </P>
+ * </TD>
+ * </TR>
+ * <TR VALIGN=TOP>
+ * <TD WIDTH=42 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * 511
+ * </P>
+ * </TD>
+ * <TD WIDTH=118 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Missing variable
+ * </P>
+ * </TD>
+ * <TD WIDTH=401 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Function requires more variables than are provided, for example, AND() and
+ * OR().
+ * </P>
+ * </TD>
+ * </TR>
+ * <TR VALIGN=TOP>
+ * <TD WIDTH=42 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * 512
+ * </P>
+ * </TD>
+ * <TD WIDTH=118 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Formula overflow
+ * </P>
+ * </TD>
+ * <TD WIDTH=401 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * <B>Compiler: </B> the total number of internal tokens, (that is, operators,
+ * variables, brackets) in the formula exceeds 512. <B>Interpreter: </B> the
+ * total number of matrices that the formula creates exceeds 150. This includes
+ * basic functions that receive too large an array as a parameter (max. 0xFFFE,
+ * for example, 65534 bytes).
+ * </P>
+ * </TD>
+ * </TR>
+ * <TR VALIGN=TOP>
+ * <TD WIDTH=42 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * 513
+ * </P>
+ * </TD>
+ * <TD WIDTH=118 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * String overflow
+ * </P>
+ * </TD>
+ * <TD WIDTH=401 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * <B>Compiler: </B> an identifier in the formula exceeds 64 KB in size.
+ * <B>Interpreter: </B> a result of a string operation exceeds 64 KB in size.
+ * </P>
+ * </TD>
+ * </TR>
+ * <TR VALIGN=TOP>
+ * <TD WIDTH=42 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * 514
+ * </P>
+ * </TD>
+ * <TD WIDTH=118 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Internal overflow
+ * </P>
+ * </TD>
+ * <TD WIDTH=401 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Sort operation attempted on too much numerical data (max. 100000) or a
+ * calculation stack overflow.
+ * </P>
+ * </TD>
+ * </TR>
+ * <TR VALIGN=TOP>
+ * <TD WIDTH=42 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * 515
+ * </P>
+ * </TD>
+ * <TD WIDTH=118 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Internal syntax error
+ * </P>
+ * </TD>
+ * <TD WIDTH=401 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Not used
+ * </P>
+ * </TD>
+ * </TR>
+ * <TR VALIGN=TOP>
+ * <TD WIDTH=42 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * 516
+ * </P>
+ * </TD>
+ * <TD WIDTH=118 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Internal syntax error
+ * </P>
+ * </TD>
+ * <TD WIDTH=401 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Matrix is expected on the calculation stack, but is not available.
+ * </P>
+ * </TD>
+ * </TR>
+ * <TR VALIGN=TOP>
+ * <TD WIDTH=42 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * 517
+ * </P>
+ * </TD>
+ * <TD WIDTH=118 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Internal syntax error
+ * </P>
+ * </TD>
+ * <TD WIDTH=401 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Unknown code, for example, a document with a newer function is loaded in an
+ * older version that does not contain the function.
+ * </P>
+ * </TD>
+ * </TR>
+ * <TR VALIGN=TOP>
+ * <TD WIDTH=42 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * 518
+ * </P>
+ * </TD>
+ * <TD WIDTH=118 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Internal syntax error
+ * </P>
+ * </TD>
+ * <TD WIDTH=401 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Variable is not available
+ * </P>
+ * </TD>
+ * </TR>
+ * <TR VALIGN=TOP>
+ * <TD WIDTH=42 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * 519
+ * </P>
+ * </TD>
+ * <TD WIDTH=118 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * No result (#VALUE is in the cell rather than Err:519!)
+ * </P>
+ * </TD>
+ * <TD WIDTH=401 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Formula yields a value that does not corresponds to the definition, or a cell
+ * that is referenced in the formula contains text instead of a number.
+ * </P>
+ * </TD>
+ * </TR>
+ * <TR VALIGN=TOP>
+ * <TD WIDTH=42 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * 520
+ * </P>
+ * </TD>
+ * <TD WIDTH=118 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Internal syntax error
+ * </P>
+ * </TD>
+ * <TD WIDTH=401 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Compiler creates an unknown compiler code.
+ * </P>
+ * </TD>
+ * </TR>
+ * <TR VALIGN=TOP>
+ * <TD WIDTH=42 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * 521
+ * </P>
+ * </TD>
+ * <TD WIDTH=118 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Internal syntax error
+ * </P>
+ * </TD>
+ * <TD WIDTH=401 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * No result.
+ * </P>
+ * </TD>
+ * </TR>
+ * <TR VALIGN=TOP>
+ * <TD WIDTH=42 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * 522
+ * </P>
+ * </TD>
+ * <TD WIDTH=118 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Circular reference
+ * </P>
+ * </TD>
+ * <TD WIDTH=401 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Formula refers directly or indirectly to itself and the iterations option is
+ * not selected under Tools - Options - Table Document - Calculate.
+ * </P>
+ * </TD>
+ * </TR>
+ * <TR VALIGN=TOP>
+ * <TD WIDTH=42 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * 523
+ * </P>
+ * </TD>
+ * <TD WIDTH=118 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * The calculation procedure does not converge
+ * </P>
+ * </TD>
+ * <TD WIDTH=401 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Financial statistics function missed a targeted value or iterations of
+ * circular references do not reach the minimum change within the maximum steps
+ * that are set.
+ * </P>
+ * </TD>
+ * </TR>
+ * <TR VALIGN=TOP>
+ * <TD WIDTH=42 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * 524
+ * </P>
+ * </TD>
+ * <TD WIDTH=118 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * <A NAME="kw66944_5"> </A><A NAME="kw66944_4"> </A> invalid references
+ * (instead of Err:524 cell contains #REF)
+ * </P>
+ * </TD>
+ * <TD WIDTH=401 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * <B>Compiler: </B> a column or row description name could not be resolved.
+ * <B>Interpreter: </B> in a formula, the column, row, or sheet that contains a
+ * referenced cell is missing.
+ * </P>
+ * </TD>
+ * </TR>
+ * <TR VALIGN=TOP>
+ * <TD WIDTH=42 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * 525
+ * </P>
+ * </TD>
+ * <TD WIDTH=118 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * <A NAME="kw66944_3"> </A><A NAME="kw66944_2"> </A> invalid names (instead of
+ * Err:525 cell contains #NAME?)
+ * </P>
+ * </TD>
+ * <TD WIDTH=401 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * An identifier could not be evaluated, for example, no valid reference, no
+ * valid domain name, no column/row label, no macro, incorrect decimal divider,
+ * add-in not found.
+ * </P>
+ * </TD>
+ * </TR>
+ * <TR VALIGN=TOP>
+ * <TD WIDTH=42 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * 526
+ * </P>
+ * </TD>
+ * <TD WIDTH=118 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Internal syntax error
+ * </P>
+ * </TD>
+ * <TD WIDTH=401 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Obsolete, no longer used, but could come from old documents if the result is
+ * a formula from a domain.
+ * </P>
+ * </TD>
+ * </TR>
+ * <TR VALIGN=TOP>
+ * <TD WIDTH=42 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * 527
+ * </P>
+ * </TD>
+ * <TD WIDTH=118 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * Internal overflow
+ * </P>
+ * </TD>
+ * <TD WIDTH=401 BGCOLOR="#ffffff">
+ * <P CLASS="textintable" ALIGN=LEFT>
+ * <B>Interpreter: </B>References, such as when a cell references a cell, are
+ * too encapsulated.
+ * </P>
+ * </TD>
+ * </TR>
+ * </TABLE>
+ *  
+ */
+public class ErrorEval implements ValueEval {
+
+    private int errorCode;
+
+    // Oo std error codes
+    public static final ErrorEval ERROR_501 = new ErrorEval(501);
+
+    public static final ErrorEval ERROR_502 = new ErrorEval(502);
+
+    public static final ErrorEval ERROR_503 = new ErrorEval(503);
+
+    public static final ErrorEval ERROR_504 = new ErrorEval(504);
+
+    public static final ErrorEval ERROR_505 = new ErrorEval(505);
+
+    public static final ErrorEval ERROR_506 = new ErrorEval(506);
+
+    public static final ErrorEval ERROR_507 = new ErrorEval(507);
+
+    public static final ErrorEval ERROR_508 = new ErrorEval(508);
+
+    public static final ErrorEval ERROR_509 = new ErrorEval(509);
+
+    public static final ErrorEval ERROR_510 = new ErrorEval(510);
+
+    public static final ErrorEval ERROR_511 = new ErrorEval(511);
+
+    public static final ErrorEval ERROR_512 = new ErrorEval(512);
+
+    public static final ErrorEval ERROR_513 = new ErrorEval(513);
+
+    public static final ErrorEval ERROR_514 = new ErrorEval(514);
+
+    public static final ErrorEval ERROR_515 = new ErrorEval(515);
+
+    public static final ErrorEval ERROR_516 = new ErrorEval(516);
+
+    public static final ErrorEval ERROR_517 = new ErrorEval(517);
+
+    public static final ErrorEval ERROR_518 = new ErrorEval(518);
+
+    public static final ErrorEval ERROR_519 = new ErrorEval(519);
+
+    public static final ErrorEval ERROR_520 = new ErrorEval(520);
+
+    public static final ErrorEval ERROR_521 = new ErrorEval(521);
+
+    public static final ErrorEval ERROR_522 = new ErrorEval(522);
+
+    public static final ErrorEval ERROR_523 = new ErrorEval(523);
+
+    public static final ErrorEval ERROR_524 = new ErrorEval(524);
+
+    public static final ErrorEval ERROR_525 = new ErrorEval(525);
+
+    public static final ErrorEval ERROR_526 = new ErrorEval(526);
+
+    public static final ErrorEval ERROR_527 = new ErrorEval(527);
+
+    public static final ErrorEval NAME_INVALID = ERROR_525;
+
+    public static final ErrorEval VALUE_INVALID = ERROR_519;
+
+    
+    // Non std error codes
+    public static final ErrorEval UNKNOWN_ERROR = new ErrorEval(-20);
+
+    public static final ErrorEval FUNCTION_NOT_IMPLEMENTED = new ErrorEval(-30);
+
+    public static final ErrorEval REF_INVALID = new ErrorEval(-40);
+
+    public static final ErrorEval NA = new ErrorEval(-50);
+    
+    public static final ErrorEval CIRCULAR_REF_ERROR = new ErrorEval(-60);
+    
+    public static final ErrorEval DIV_ZERO = new ErrorEval(-70);
+    
+    public static final ErrorEval NUM_ERROR = new ErrorEval(-80);
+
+    private ErrorEval(int errorCode) {
+        this.errorCode = errorCode;
+    }
+
+    public int getErrorCode() {
+        return errorCode;
+    }
+
+    public String getStringValue() {
+        return "Err:" + Integer.toString(errorCode);
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/Eval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/Eval.java
new file mode 100644 (file)
index 0000000..e60e061
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 8, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public interface Eval {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/FuncVarEval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/FuncVarEval.java
new file mode 100644 (file)
index 0000000..a9ce8d3
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Created on May 8, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+import org.apache.poi.hssf.record.formula.AbstractFunctionPtg;
+import org.apache.poi.hssf.record.formula.Ptg;
+import org.apache.poi.hssf.record.formula.functions.Function;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class FuncVarEval extends FunctionEval {
+
+    private AbstractFunctionPtg delegate;
+
+    public FuncVarEval(Ptg funcPtg) {
+        delegate = (AbstractFunctionPtg) funcPtg;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        Eval retval = null;
+        Function f = getFunction();
+        if (f != null)
+            retval = f.evaluate(operands, srcRow, srcCol);
+        else
+            retval = ErrorEval.FUNCTION_NOT_IMPLEMENTED;
+        return retval;
+    }
+
+    public int getNumberOfOperands() {
+        return delegate.getNumberOfOperands();
+    }
+
+    public int getType() {
+        return delegate.getType();
+    }
+
+    public short getFunctionIndex() {
+        return delegate.getFunctionIndex();
+    }
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/FunctionEval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/FunctionEval.java
new file mode 100644 (file)
index 0000000..3a487f7
--- /dev/null
@@ -0,0 +1,379 @@
+/*
+ * Created on May 8, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+import org.apache.poi.hssf.record.formula.functions.*;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public abstract class FunctionEval implements OperationEval {
+    protected static Function[] functions = produceFunctions();
+
+    public Function getFunction() {
+        short fidx = getFunctionIndex();
+        return functions[fidx];
+    }
+
+    public abstract short getFunctionIndex();
+
+    private static Function[] produceFunctions() {
+        Function[] retval = new Function[368];
+        retval[0] = new Count(); // COUNT
+        retval[1] = null; // Specialflag(); // SPECIALFLAG
+        retval[2] = new IsNa(); // ISNA
+        retval[3] = new IsError(); // ISERROR
+        retval[4] = new Sum(); // SUM
+        retval[5] = new Average(); // AVERAGE
+        retval[6] = new Min(); // MIN
+        retval[7] = new Max(); // MAX
+        retval[8] = new Row(); // ROW
+        retval[9] = new Column(); // COLUMN
+        retval[10] = new Na(); // NA
+        retval[11] = new Npv(); // NPV
+        retval[12] = new Stdev(); // STDEV
+        retval[13] = new Dollar(); // DOLLAR
+        retval[14] = new Fixed(); // FIXED
+        retval[15] = new Sin(); // SIN
+        retval[16] = new Cos(); // COS
+        retval[17] = new Tan(); // TAN
+        retval[18] = new Atan(); // ATAN
+        retval[19] = new Pi(); // PI
+        retval[20] = new Sqrt(); // SQRT
+        retval[21] = new Exp(); // EXP
+        retval[22] = new Ln(); // LN
+        retval[23] = new Log10(); // LOG10
+        retval[24] = new Abs(); // ABS
+        retval[25] = new Int(); // INT
+        retval[26] = new Sign(); // SIGN
+        retval[27] = new Round(); // ROUND
+        retval[28] = new Lookup(); // LOOKUP
+        retval[29] = new Index(); // INDEX
+        retval[30] = new Rept(); // REPT
+        retval[31] = new Mid(); // MID
+        retval[32] = new Len(); // LEN
+        retval[33] = new Value(); // VALUE
+        retval[34] = new True(); // TRUE
+        retval[35] = new False(); // FALSE
+        retval[36] = new And(); // AND
+        retval[37] = new Or(); // OR
+        retval[38] = new Not(); // NOT
+        retval[39] = new Mod(); // MOD
+        retval[40] = new Dcount(); // DCOUNT
+        retval[41] = new Dsum(); // DSUM
+        retval[42] = new Daverage(); // DAVERAGE
+        retval[43] = new Dmin(); // DMIN
+        retval[44] = new Dmax(); // DMAX
+        retval[45] = new Dstdev(); // DSTDEV
+        retval[46] = new Var(); // VAR
+        retval[47] = new Dvar(); // DVAR
+        retval[48] = new Text(); // TEXT
+        retval[49] = new Linest(); // LINEST
+        retval[50] = new Trend(); // TREND
+        retval[51] = new Logest(); // LOGEST
+        retval[52] = new Growth(); // GROWTH
+        retval[53] = new Goto(); // GOTO
+        retval[54] = new Halt(); // HALT
+        retval[56] = new Pv(); // PV
+        retval[57] = new Fv(); // FV
+        retval[58] = new Nper(); // NPER
+        retval[59] = new Pmt(); // PMT
+        retval[60] = new Rate(); // RATE
+        retval[61] = new Mirr(); // MIRR
+        retval[62] = new Irr(); // IRR
+        retval[63] = new Rand(); // RAND
+        retval[64] = new Match(); // MATCH
+        retval[65] = new Date(); // DATE
+        retval[66] = new Time(); // TIME
+        retval[67] = new Day(); // DAY
+        retval[68] = new Month(); // MONTH
+        retval[69] = new Year(); // YEAR
+        retval[70] = new Weekday(); // WEEKDAY
+        retval[71] = new Hour(); // HOUR
+        retval[72] = new Minute(); // MINUTE
+        retval[73] = new Second(); // SECOND
+        retval[74] = new Now(); // NOW
+        retval[75] = new Areas(); // AREAS
+        retval[76] = new Rows(); // ROWS
+        retval[77] = new Columns(); // COLUMNS
+        retval[78] = new Offset(); // OFFSET
+        retval[79] = new Absref(); // ABSREF
+        retval[80] = new Relref(); // RELREF
+        retval[81] = new Argument(); // ARGUMENT
+        retval[82] = new Search(); // SEARCH
+        retval[83] = new Transpose(); // TRANSPOSE
+        retval[84] = new org.apache.poi.hssf.record.formula.functions.Error(); // ERROR
+        retval[85] = new Step(); // STEP
+        retval[86] = new Type(); // TYPE
+        retval[87] = new Echo(); // ECHO
+        retval[88] = new Setname(); // SETNAME
+        retval[89] = new Caller(); // CALLER
+        retval[90] = new Deref(); // DEREF
+        retval[91] = new Windows(); // WINDOWS
+        retval[92] = new Series(); // SERIES
+        retval[93] = new Documents(); // DOCUMENTS
+        retval[94] = new Activecell(); // ACTIVECELL
+        retval[95] = new Selection(); // SELECTION
+        retval[96] = new Result(); // RESULT
+        retval[97] = new Atan2(); // ATAN2
+        retval[98] = new Asin(); // ASIN
+        retval[99] = new Acos(); // ACOS
+        retval[100] = new Choose(); // CHOOSE
+        retval[101] = new Hlookup(); // HLOOKUP
+        retval[102] = new Vlookup(); // VLOOKUP
+        retval[103] = new Links(); // LINKS
+        retval[104] = new Input(); // INPUT
+        retval[105] = new Isref(); // ISREF
+        retval[106] = new Getformula(); // GETFORMULA
+        retval[107] = new Getname(); // GETNAME
+        retval[108] = new Setvalue(); // SETVALUE
+        retval[109] = new Log(); // LOG
+        retval[110] = new Exec(); // EXEC
+        retval[111] = new Char(); // CHAR
+        retval[112] = new Lower(); // LOWER
+        retval[113] = new Upper(); // UPPER
+        retval[114] = new Proper(); // PROPER
+        retval[115] = new Left(); // LEFT
+        retval[116] = new Right(); // RIGHT
+        retval[117] = new Exact(); // EXACT
+        retval[118] = new Trim(); // TRIM
+        retval[119] = new Replace(); // REPLACE
+        retval[120] = new Substitute(); // SUBSTITUTE
+        retval[121] = new Code(); // CODE
+        retval[122] = new Names(); // NAMES
+        retval[123] = new Directory(); // DIRECTORY
+        retval[124] = new Find(); // FIND
+        retval[125] = new Cell(); // CELL
+        retval[126] = new Iserr(); // ISERR
+        retval[127] = new Istext(); // ISTEXT
+        retval[128] = new Isnumber(); // ISNUMBER
+        retval[129] = new Isblank(); // ISBLANK
+        retval[130] = new T(); // T
+        retval[131] = new N(); // N
+        retval[132] = new Fopen(); // FOPEN
+        retval[133] = new Fclose(); // FCLOSE
+        retval[134] = new Fsize(); // FSIZE
+        retval[135] = new Freadln(); // FREADLN
+        retval[136] = new Fread(); // FREAD
+        retval[137] = new Fwriteln(); // FWRITELN
+        retval[138] = new Fwrite(); // FWRITE
+        retval[139] = new Fpos(); // FPOS
+        retval[140] = new Datevalue(); // DATEVALUE
+        retval[141] = new Timevalue(); // TIMEVALUE
+        retval[142] = new Sln(); // SLN
+        retval[143] = new Syd(); // SYD
+        retval[144] = new Ddb(); // DDB
+        retval[145] = new Getdef(); // GETDEF
+        retval[146] = new Reftext(); // REFTEXT
+        retval[147] = new Textref(); // TEXTREF
+        retval[148] = new Indirect(); // INDIRECT
+        retval[149] = new Register(); // REGISTER
+        retval[150] = new Call(); // CALL
+        retval[151] = new Addbar(); // ADDBAR
+        retval[152] = new Addmenu(); // ADDMENU
+        retval[153] = new Addcommand(); // ADDCOMMAND
+        retval[154] = new Enablecommand(); // ENABLECOMMAND
+        retval[155] = new Checkcommand(); // CHECKCOMMAND
+        retval[156] = new Renamecommand(); // RENAMECOMMAND
+        retval[157] = new Showbar(); // SHOWBAR
+        retval[158] = new Deletemenu(); // DELETEMENU
+        retval[159] = new Deletecommand(); // DELETECOMMAND
+        retval[160] = new Getchartitem(); // GETCHARTITEM
+        retval[161] = new Dialogbox(); // DIALOGBOX
+        retval[162] = new Clean(); // CLEAN
+        retval[163] = new Mdeterm(); // MDETERM
+        retval[164] = new Minverse(); // MINVERSE
+        retval[165] = new Mmult(); // MMULT
+        retval[166] = new Files(); // FILES
+        retval[167] = new Ipmt(); // IPMT
+        retval[168] = new Ppmt(); // PPMT
+        retval[169] = new Counta(); // COUNTA
+        retval[170] = new Cancelkey(); // CANCELKEY
+        retval[175] = new Initiate(); // INITIATE
+        retval[176] = new Request(); // REQUEST
+        retval[177] = new Poke(); // POKE
+        retval[178] = new Execute(); // EXECUTE
+        retval[179] = new Terminate(); // TERMINATE
+        retval[180] = new Restart(); // RESTART
+        retval[181] = new Help(); // HELP
+        retval[182] = new Getbar(); // GETBAR
+        retval[183] = new Product(); // PRODUCT
+        retval[184] = new Fact(); // FACT
+        retval[185] = new Getcell(); // GETCELL
+        retval[186] = new Getworkspace(); // GETWORKSPACE
+        retval[187] = new Getwindow(); // GETWINDOW
+        retval[188] = new Getdocument(); // GETDOCUMENT
+        retval[189] = new Dproduct(); // DPRODUCT
+        retval[190] = new Isnontext(); // ISNONTEXT
+        retval[191] = new Getnote(); // GETNOTE
+        retval[192] = new Note(); // NOTE
+        retval[193] = new Stdevp(); // STDEVP
+        retval[194] = new Varp(); // VARP
+        retval[195] = new Dstdevp(); // DSTDEVP
+        retval[196] = new Dvarp(); // DVARP
+        retval[197] = new Trunc(); // TRUNC
+        retval[198] = new Islogical(); // ISLOGICAL
+        retval[199] = new Dcounta(); // DCOUNTA
+        retval[200] = new Deletebar(); // DELETEBAR
+        retval[201] = new Unregister(); // UNREGISTER
+        retval[204] = new Usdollar(); // USDOLLAR
+        retval[205] = new Findb(); // FINDB
+        retval[206] = new Searchb(); // SEARCHB
+        retval[207] = new Replaceb(); // REPLACEB
+        retval[208] = new Leftb(); // LEFTB
+        retval[209] = new Rightb(); // RIGHTB
+        retval[210] = new Midb(); // MIDB
+        retval[211] = new Lenb(); // LENB
+        retval[212] = new Roundup(); // ROUNDUP
+        retval[213] = new Rounddown(); // ROUNDDOWN
+        retval[214] = new Asc(); // ASC
+        retval[215] = new Dbcs(); // DBCS
+        retval[216] = new Rank(); // RANK
+        retval[219] = new Address(); // ADDRESS
+        retval[220] = new Days360(); // DAYS360
+        retval[221] = new Today(); // TODAY
+        retval[222] = new Vdb(); // VDB
+        retval[227] = new Median(); // MEDIAN
+        retval[228] = new Sumproduct(); // SUMPRODUCT
+        retval[229] = new Sinh(); // SINH
+        retval[230] = new Cosh(); // COSH
+        retval[231] = new Tanh(); // TANH
+        retval[232] = new Asinh(); // ASINH
+        retval[233] = new Acosh(); // ACOSH
+        retval[234] = new Atanh(); // ATANH
+        retval[235] = new Dget(); // DGET
+        retval[236] = new Createobject(); // CREATEOBJECT
+        retval[237] = new Volatile(); // VOLATILE
+        retval[238] = new Lasterror(); // LASTERROR
+        retval[239] = new Customundo(); // CUSTOMUNDO
+        retval[240] = new Customrepeat(); // CUSTOMREPEAT
+        retval[241] = new Formulaconvert(); // FORMULACONVERT
+        retval[242] = new Getlinkinfo(); // GETLINKINFO
+        retval[243] = new Textbox(); // TEXTBOX
+        retval[244] = new Info(); // INFO
+        retval[245] = new Group(); // GROUP
+        retval[246] = new Getobject(); // GETOBJECT
+        retval[247] = new Db(); // DB
+        retval[248] = new Pause(); // PAUSE
+        retval[250] = new Resume(); // RESUME
+        retval[252] = new Frequency(); // FREQUENCY
+        retval[253] = new Addtoolbar(); // ADDTOOLBAR
+        retval[254] = new Deletetoolbar(); // DELETETOOLBAR
+        retval[255] = new Externalflag(); // EXTERNALFLAG
+        retval[256] = new Resettoolbar(); // RESETTOOLBAR
+        retval[257] = new Evaluate(); // EVALUATE
+        retval[258] = new Gettoolbar(); // GETTOOLBAR
+        retval[259] = new Gettool(); // GETTOOL
+        retval[260] = new Spellingcheck(); // SPELLINGCHECK
+        retval[261] = new Errortype(); // ERRORTYPE
+        retval[262] = new Apptitle(); // APPTITLE
+        retval[263] = new Windowtitle(); // WINDOWTITLE
+        retval[264] = new Savetoolbar(); // SAVETOOLBAR
+        retval[265] = new Enabletool(); // ENABLETOOL
+        retval[266] = new Presstool(); // PRESSTOOL
+        retval[267] = new Registerid(); // REGISTERID
+        retval[268] = new Getworkbook(); // GETWORKBOOK
+        retval[269] = new Avedev(); // AVEDEV
+        retval[270] = new Betadist(); // BETADIST
+        retval[271] = new Gammaln(); // GAMMALN
+        retval[272] = new Betainv(); // BETAINV
+        retval[273] = new Binomdist(); // BINOMDIST
+        retval[274] = new Chidist(); // CHIDIST
+        retval[275] = new Chiinv(); // CHIINV
+        retval[276] = new Combin(); // COMBIN
+        retval[277] = new Confidence(); // CONFIDENCE
+        retval[278] = new Critbinom(); // CRITBINOM
+        retval[279] = new Even(); // EVEN
+        retval[280] = new Expondist(); // EXPONDIST
+        retval[281] = new Fdist(); // FDIST
+        retval[282] = new Finv(); // FINV
+        retval[283] = new Fisher(); // FISHER
+        retval[284] = new Fisherinv(); // FISHERINV
+        retval[285] = new Floor(); // FLOOR
+        retval[286] = new Gammadist(); // GAMMADIST
+        retval[287] = new Gammainv(); // GAMMAINV
+        retval[288] = new Ceiling(); // CEILING
+        retval[289] = new Hypgeomdist(); // HYPGEOMDIST
+        retval[290] = new Lognormdist(); // LOGNORMDIST
+        retval[291] = new Loginv(); // LOGINV
+        retval[292] = new Negbinomdist(); // NEGBINOMDIST
+        retval[293] = new Normdist(); // NORMDIST
+        retval[294] = new Normsdist(); // NORMSDIST
+        retval[295] = new Norminv(); // NORMINV
+        retval[296] = new Normsinv(); // NORMSINV
+        retval[297] = new Standardize(); // STANDARDIZE
+        retval[298] = new Odd(); // ODD
+        retval[299] = new Permut(); // PERMUT
+        retval[300] = new Poisson(); // POISSON
+        retval[301] = new Tdist(); // TDIST
+        retval[302] = new Weibull(); // WEIBULL
+        retval[303] = new Sumxmy2(); // SUMXMY2
+        retval[304] = new Sumx2my2(); // SUMX2MY2
+        retval[305] = new Sumx2py2(); // SUMX2PY2
+        retval[306] = new Chitest(); // CHITEST
+        retval[307] = new Correl(); // CORREL
+        retval[308] = new Covar(); // COVAR
+        retval[309] = new Forecast(); // FORECAST
+        retval[310] = new Ftest(); // FTEST
+        retval[311] = new Intercept(); // INTERCEPT
+        retval[312] = new Pearson(); // PEARSON
+        retval[313] = new Rsq(); // RSQ
+        retval[314] = new Steyx(); // STEYX
+        retval[315] = new Slope(); // SLOPE
+        retval[316] = new Ttest(); // TTEST
+        retval[317] = new Prob(); // PROB
+        retval[318] = new Devsq(); // DEVSQ
+        retval[319] = new Geomean(); // GEOMEAN
+        retval[320] = new Harmean(); // HARMEAN
+        retval[321] = new Sumsq(); // SUMSQ
+        retval[322] = new Kurt(); // KURT
+        retval[323] = new Skew(); // SKEW
+        retval[324] = new Ztest(); // ZTEST
+        retval[325] = new Large(); // LARGE
+        retval[326] = new Small(); // SMALL
+        retval[327] = new Quartile(); // QUARTILE
+        retval[328] = new Percentile(); // PERCENTILE
+        retval[329] = new Percentrank(); // PERCENTRANK
+        retval[330] = new Mode(); // MODE
+        retval[331] = new Trimmean(); // TRIMMEAN
+        retval[332] = new Tinv(); // TINV
+        retval[334] = new Moviecommand(); // MOVIECOMMAND
+        retval[335] = new Getmovie(); // GETMOVIE
+        retval[336] = new Concatenate(); // CONCATENATE
+        retval[337] = new Power(); // POWER
+        retval[338] = new Pivotadddata(); // PIVOTADDDATA
+        retval[339] = new Getpivottable(); // GETPIVOTTABLE
+        retval[340] = new Getpivotfield(); // GETPIVOTFIELD
+        retval[341] = new Getpivotitem(); // GETPIVOTITEM
+        retval[342] = new Radians(); // RADIANS
+        retval[343] = new Degrees(); // DEGREES
+        retval[344] = new Subtotal(); // SUBTOTAL
+        retval[345] = new Sumif(); // SUMIF
+        retval[346] = new Countif(); // COUNTIF
+        retval[347] = new Countblank(); // COUNTBLANK
+        retval[348] = new Scenarioget(); // SCENARIOGET
+        retval[349] = new Optionslistsget(); // OPTIONSLISTSGET
+        retval[350] = new Ispmt(); // ISPMT
+        retval[351] = new Datedif(); // DATEDIF
+        retval[352] = new Datestring(); // DATESTRING
+        retval[353] = new Numberstring(); // NUMBERSTRING
+        retval[354] = new Roman(); // ROMAN
+        retval[355] = new Opendialog(); // OPENDIALOG
+        retval[356] = new Savedialog(); // SAVEDIALOG
+        retval[357] = new Viewget(); // VIEWGET
+        retval[358] = new Getpivotdata(); // GETPIVOTDATA
+        retval[359] = new Hyperlink(); // HYPERLINK
+        retval[360] = new Phonetic(); // PHONETIC
+        retval[361] = new Averagea(); // AVERAGEA
+        retval[362] = new Maxa(); // MAXA
+        retval[363] = new Mina(); // MINA
+        retval[364] = new Stdevpa(); // STDEVPA
+        retval[365] = new Varpa(); // VARPA
+        retval[366] = new Stdeva(); // STDEVA
+        retval[367] = new Vara(); // VARA
+        return retval;
+    }
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/GreaterEqualEval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/GreaterEqualEval.java
new file mode 100644 (file)
index 0000000..894a7f0
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Created on May 8, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+import org.apache.poi.hssf.record.formula.GreaterEqualPtg;
+import org.apache.poi.hssf.record.formula.Ptg;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class GreaterEqualEval extends RelationalOperationEval {
+
+    private GreaterEqualPtg delegate;
+
+    public GreaterEqualEval(Ptg ptg) {
+        this.delegate = (GreaterEqualPtg) ptg;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        ValueEval retval = null;
+        
+        RelationalValues rvs = super.doEvaluate(operands, srcRow, srcCol);
+        retval = rvs.ee;
+        int result = 0;
+        if (retval == null) {
+            result = doComparison(rvs.bs);
+            if (result == 0) {
+                result = doComparison(rvs.ss);
+            }
+            if (result == 0) {
+                result = doComparison(rvs.ds);
+            }
+
+            retval = (result >= 0) ? BoolEval.TRUE : BoolEval.FALSE;
+        }
+
+        return retval;
+    }
+
+    public int getNumberOfOperands() {
+        return delegate.getNumberOfOperands();
+    }
+
+    public int getType() {
+        return delegate.getType();
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/GreaterThanEval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/GreaterThanEval.java
new file mode 100644 (file)
index 0000000..587c7e6
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Created on May 8, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+import org.apache.poi.hssf.record.formula.GreaterThanPtg;
+import org.apache.poi.hssf.record.formula.Ptg;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class GreaterThanEval extends RelationalOperationEval {
+
+    private GreaterThanPtg delegate;
+
+    public GreaterThanEval(Ptg ptg) {
+        this.delegate = (GreaterThanPtg) ptg;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        ValueEval retval = null;
+        
+        RelationalValues rvs = super.doEvaluate(operands, srcRow, srcCol);
+        retval = rvs.ee;
+        int result = 0;
+        if (retval == null) {
+            result = doComparison(rvs.bs);
+            if (result == 0) {
+                result = doComparison(rvs.ss);
+            }
+            if (result == 0) {
+                result = doComparison(rvs.ds);
+            }
+
+            retval = (result > 0) ? BoolEval.TRUE : BoolEval.FALSE;;
+        }
+
+        return retval;
+    }
+
+    public int getNumberOfOperands() {
+        return delegate.getNumberOfOperands();
+    }
+
+    public int getType() {
+        return delegate.getType();
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/LessEqualEval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/LessEqualEval.java
new file mode 100644 (file)
index 0000000..3e4000f
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Created on May 8, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+import org.apache.poi.hssf.record.formula.LessEqualPtg;
+import org.apache.poi.hssf.record.formula.Ptg;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class LessEqualEval extends RelationalOperationEval {
+
+    private LessEqualPtg delegate;
+
+    public LessEqualEval(Ptg ptg) {
+        this.delegate = (LessEqualPtg) ptg;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        ValueEval retval = null;
+        
+        RelationalValues rvs = super.doEvaluate(operands, srcRow, srcCol);
+        retval = rvs.ee;
+        int result = 0;
+        if (retval == null) {
+            result = doComparison(rvs.bs);
+            if (result == 0) {
+                result = doComparison(rvs.ss);
+            }
+            if (result == 0) {
+                result = doComparison(rvs.ds);
+            }
+
+            retval = (result <= 0) ? BoolEval.TRUE : BoolEval.FALSE;;
+        }
+
+        return retval;
+    }
+
+    public int getNumberOfOperands() {
+        return delegate.getNumberOfOperands();
+    }
+
+    public int getType() {
+        return delegate.getType();
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/LessThanEval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/LessThanEval.java
new file mode 100644 (file)
index 0000000..5b625e0
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Created on May 8, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+import org.apache.poi.hssf.record.formula.LessThanPtg;
+import org.apache.poi.hssf.record.formula.Ptg;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class LessThanEval extends RelationalOperationEval {
+
+    private LessThanPtg delegate;
+
+    public LessThanEval(Ptg ptg) {
+        this.delegate = (LessThanPtg) ptg;
+    }
+
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        ValueEval retval = null;
+        
+        RelationalValues rvs = super.doEvaluate(operands, srcRow, srcCol);
+        retval = rvs.ee;
+        int result = 0;
+        if (retval == null) {
+            result = doComparison(rvs.bs);
+            if (result == 0) {
+                result = doComparison(rvs.ss);
+            }
+            if (result == 0) {
+                result = doComparison(rvs.ds);
+            }
+
+            retval = (result < 0) ? BoolEval.TRUE : BoolEval.FALSE;;
+        }
+
+        return retval;
+    }
+
+    public int getNumberOfOperands() {
+        return delegate.getNumberOfOperands();
+    }
+
+    public int getType() {
+        return delegate.getType();
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/MultiplyEval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/MultiplyEval.java
new file mode 100644 (file)
index 0000000..e55d532
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Created on May 8, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+import org.apache.poi.hssf.record.formula.Ptg;
+import org.apache.poi.hssf.record.formula.MultiplyPtg;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class MultiplyEval extends NumericOperationEval {
+
+    private MultiplyPtg delegate;
+
+    private static final ValueEvalToNumericXlator NUM_XLATOR = 
+        new ValueEvalToNumericXlator((short)
+                ( ValueEvalToNumericXlator.BOOL_IS_PARSED 
+                | ValueEvalToNumericXlator.EVALUATED_REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.EVALUATED_REF_STRING_IS_PARSED
+                | ValueEvalToNumericXlator.REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.STRING_IS_PARSED
+                ));
+
+    public MultiplyEval(Ptg ptg) {
+        delegate = (MultiplyPtg) ptg;
+    }
+    
+    protected ValueEvalToNumericXlator getXlator() {
+        return NUM_XLATOR;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        Eval retval = null;
+        double d0 = 0;
+        double d1 = 0;
+        switch (operands.length) {
+        default: // will rarely happen. currently the parser itself fails.
+            retval = ErrorEval.UNKNOWN_ERROR;
+            break;
+        case 2:
+            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
+            if (ve instanceof NumericValueEval) {
+                d0 = ((NumericValueEval) ve).getNumberValue();
+            }
+            else if (ve instanceof BlankEval) {
+                // do nothing
+            }
+            else {
+                retval = ErrorEval.VALUE_INVALID;
+            }
+            
+            if (retval == null) { // no error yet
+                ve = singleOperandEvaluate(operands[1], srcRow, srcCol);
+                if (ve instanceof NumericValueEval) {
+                    d1 = ((NumericValueEval) ve).getNumberValue();
+                }
+                else if (ve instanceof BlankEval) {
+                    // do nothing
+                }
+                else {
+                    retval = ErrorEval.VALUE_INVALID;
+                }
+            }
+        } // end switch
+
+        if (retval == null) {
+            retval = (Double.isNaN(d0) || Double.isNaN(d1)) 
+                    ? (ValueEval) ErrorEval.VALUE_INVALID 
+                    : new NumberEval(d0 * d1);
+        }
+        return retval;
+    }
+
+    public int getNumberOfOperands() {
+        return delegate.getNumberOfOperands();
+    }
+
+    public int getType() {
+        return delegate.getType();
+    }
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/NotEqualEval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/NotEqualEval.java
new file mode 100644 (file)
index 0000000..e868864
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Created on May 8, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+import org.apache.poi.hssf.record.formula.NotEqualPtg;
+import org.apache.poi.hssf.record.formula.Ptg;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class NotEqualEval extends RelationalOperationEval {
+
+    private NotEqualPtg delegate;
+
+    public NotEqualEval(Ptg ptg) {
+        this.delegate = (NotEqualPtg) ptg;
+    }
+
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        ValueEval retval = null;
+        
+        RelationalValues rvs = super.doEvaluate(operands, srcRow, srcCol);
+        retval = rvs.ee;
+        int result = 0;
+        if (retval == null) {
+            result = doComparison(rvs.bs);
+            if (result == 0) {
+                result = doComparison(rvs.ss);
+            }
+            if (result == 0) {
+                result = doComparison(rvs.ds);
+            }
+
+            retval = (result != 0) ? BoolEval.TRUE : BoolEval.FALSE;
+        }
+
+        return retval;
+    }
+
+    public int getNumberOfOperands() {
+        return delegate.getNumberOfOperands();
+    }
+
+    public int getType() {
+        return delegate.getType();
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/NumberEval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/NumberEval.java
new file mode 100644 (file)
index 0000000..764c59f
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Created on May 8, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+import org.apache.poi.hssf.record.formula.IntPtg;
+import org.apache.poi.hssf.record.formula.NumberPtg;
+import org.apache.poi.hssf.record.formula.Ptg;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class NumberEval implements NumericValueEval, StringValueEval {
+
+    private double value;
+    private String stringValue;
+
+    public NumberEval(Ptg ptg) {
+        if (ptg instanceof IntPtg) {
+            this.value = ((IntPtg) ptg).getValue();
+        }
+        else if (ptg instanceof NumberPtg) {
+            this.value = ((NumberPtg) ptg).getValue();
+        }
+    }
+
+    public NumberEval(double value) {
+        this.value = value;
+    }
+
+    public double getNumberValue() {
+        return value;
+    }
+
+    public String getStringValue() { // TODO: limit to 15 decimal places
+        if (stringValue == null)
+            makeString();
+        return stringValue;
+    }
+    
+    protected void makeString() {
+        if (!Double.isNaN(value)) {
+            long lvalue = Math.round(value);
+            if (lvalue == value) {
+                stringValue = String.valueOf(lvalue);
+            }
+            else {
+                stringValue = String.valueOf(value);
+            }
+        }
+    }
+    
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/NumericOperationEval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/NumericOperationEval.java
new file mode 100644 (file)
index 0000000..8c40306
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Created on May 14, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *
+ */
+public abstract class NumericOperationEval implements OperationEval {
+
+    protected abstract ValueEvalToNumericXlator getXlator();
+    
+    protected ValueEval singleOperandEvaluate(Eval eval, int srcRow, short srcCol) {
+        ValueEval retval;
+        if (eval instanceof AreaEval) {
+            AreaEval ae = (AreaEval) eval;
+            if (ae.contains(srcRow, srcCol)) { // circular ref!
+                retval = ErrorEval.CIRCULAR_REF_ERROR;
+            }
+            else if (ae.isRow()) {
+                if (ae.containsColumn(srcCol)) {
+                    ValueEval ve = ae.getValueAt(ae.getFirstRow(), srcCol);
+                    ve = getXlator().attemptXlateToNumeric(ve);
+                    retval = getXlator().attemptXlateToNumeric(ve);
+                }
+                else {
+                    retval = ErrorEval.VALUE_INVALID;
+                }
+            }
+            else if (ae.isColumn()) {
+                if (ae.containsRow(srcRow)) {
+                    ValueEval ve = ae.getValueAt(srcRow, ae.getFirstColumn());
+                    retval = getXlator().attemptXlateToNumeric(ve);
+                }
+                else {
+                    retval = ErrorEval.VALUE_INVALID;
+                }
+            }
+            else {
+                retval = ErrorEval.VALUE_INVALID;
+            }
+        }
+        else {
+            retval = getXlator().attemptXlateToNumeric((ValueEval) eval);
+        }
+        return retval;
+    }
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/NumericValueEval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/NumericValueEval.java
new file mode 100644 (file)
index 0000000..06ead84
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * Created on May 8, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public interface NumericValueEval extends ValueEval {
+
+    public abstract double getNumberValue();
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/OperationEval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/OperationEval.java
new file mode 100644 (file)
index 0000000..1472cb5
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Created on May 8, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public interface OperationEval extends Eval {
+
+    /*
+     * Read this, this will make your work easier when coding 
+     * an "evaluate()"
+     * 
+     * Things to note when implementing evaluate():
+     * 1. Check the length of operands
+     *    (use "switch(operands[x])" if possible)
+     * 
+     * 2. The possible Evals that you can get as args to evaluate are one of:
+     * NumericValueEval, StringValueEval, RefEval, AreaEval
+     * 3. If it is RefEval, the innerValueEval could be one of:
+     * NumericValueEval, StringValueEval, BlankEval
+     * 4. If it is AreaEval, each of the values could be one of:
+     * NumericValueEval, StringValueEval, BlankEval, RefEval
+     * 
+     * 5. For numeric functions/operations, keep the result in double
+     * till the end and before returning a new NumberEval, check to see
+     * if the double is a NaN - if NaN, return ErrorEval.ERROR_503 
+     */
+    public abstract Eval evaluate(Eval[] evals, int srcCellRow, short srcCellCol);
+
+    public abstract int getNumberOfOperands();
+
+    public abstract int getType();
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/PowerEval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/PowerEval.java
new file mode 100644 (file)
index 0000000..641cf10
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Created on May 8, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+import org.apache.poi.hssf.record.formula.Ptg;
+import org.apache.poi.hssf.record.formula.PowerPtg;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class PowerEval extends NumericOperationEval {
+
+    private PowerPtg delegate;
+
+    private static final ValueEvalToNumericXlator NUM_XLATOR = 
+        new ValueEvalToNumericXlator((short)
+                ( ValueEvalToNumericXlator.BOOL_IS_PARSED 
+                | ValueEvalToNumericXlator.EVALUATED_REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.EVALUATED_REF_STRING_IS_PARSED
+                | ValueEvalToNumericXlator.REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.STRING_IS_PARSED
+                ));
+
+    public PowerEval(Ptg ptg) {
+        delegate = (PowerPtg) ptg;
+    }
+    
+    protected ValueEvalToNumericXlator getXlator() {
+        return NUM_XLATOR;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        Eval retval = null;
+        double d0 = 0;
+        double d1 = 0;
+        
+        switch (operands.length) {
+        default: // will rarely happen. currently the parser itself fails.
+            retval = ErrorEval.UNKNOWN_ERROR;
+            break;
+        case 2:
+            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
+            if (ve instanceof NumericValueEval) {
+                d0 = ((NumericValueEval) ve).getNumberValue();
+            }
+            else if (ve instanceof BlankEval) {
+                // do nothing
+            }
+            else {
+                retval = ErrorEval.VALUE_INVALID;
+            }
+            
+            if (retval == null) { // no error yet
+                ve = singleOperandEvaluate(operands[1], srcRow, srcCol);
+                if (ve instanceof NumericValueEval) {
+                    d1 = ((NumericValueEval) ve).getNumberValue();
+                }
+                else if (ve instanceof BlankEval) {
+                    // do nothing
+                }
+                else {
+                    retval = ErrorEval.VALUE_INVALID;
+                }
+            }
+        } // end switch
+
+        if (retval == null) {
+            double p = Math.pow(d0, d1);
+            retval = (Double.isNaN(p)) 
+                    ? (ValueEval) ErrorEval.VALUE_INVALID 
+                    : new NumberEval(p);
+        }
+        return retval;
+    }
+
+    public int getNumberOfOperands() {
+        return delegate.getNumberOfOperands();
+    }
+
+    public int getType() {
+        return delegate.getType();
+    }
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/Ref2DEval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/Ref2DEval.java
new file mode 100644 (file)
index 0000000..410188f
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Created on May 9, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+import org.apache.poi.hssf.record.formula.Ptg;
+import org.apache.poi.hssf.record.formula.ReferencePtg;
+
+/**
+ * @author adeshmukh
+ *  
+ */
+public class Ref2DEval implements RefEval {
+
+    private ValueEval value;
+
+    private ReferencePtg delegate;
+    
+    private boolean evaluated;
+
+    public Ref2DEval(Ptg ptg, ValueEval value, boolean evaluated) {
+        this.value = value;
+        this.delegate = (ReferencePtg) ptg;
+        this.evaluated = evaluated;
+    }
+
+    public ValueEval getInnerValueEval() {
+        return value;
+    }
+
+    public short getRow() {
+        return delegate.getRow();
+    }
+
+    public short getColumn() {
+        return delegate.getColumn();
+    }
+    
+    public boolean isEvaluated() {
+        return evaluated;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/Ref3DEval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/Ref3DEval.java
new file mode 100644 (file)
index 0000000..56df7a7
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Created on May 9, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+import org.apache.poi.hssf.record.formula.Ptg;
+import org.apache.poi.hssf.record.formula.Ref3DPtg;
+
+/**
+ * @author Amol S. Deshmukh
+ *  
+ */
+public class Ref3DEval implements RefEval {
+
+    private ValueEval value;
+
+    private Ref3DPtg delegate;
+
+    private boolean evaluated;
+
+    public Ref3DEval(Ptg ptg, ValueEval value, boolean evaluated) {
+        this.value = value;
+        this.delegate = (Ref3DPtg) ptg;
+        this.evaluated = evaluated;
+    }
+
+    public ValueEval getInnerValueEval() {
+        return value;
+    }
+
+    public short getRow() {
+        return delegate.getRow();
+    }
+
+    public short getColumn() {
+        return delegate.getColumn();
+    }
+    
+    public boolean isEvaluated() {
+        return evaluated;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/RefEval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/RefEval.java
new file mode 100644 (file)
index 0000000..f10a040
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Created on May 9, 2005
+ *
+ * 
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+/**
+ * @author Amol S Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ * 
+ * RefEval is the super interface for Ref2D and Ref3DEval. Basically a RefEval
+ * impl should contain reference to the original ReferencePtg or Ref3DPtg as
+ * well as the final "value" resulting from the evaluation of the cell
+ * reference. Thus if the HSSFCell has type CELL_TYPE_NUMERIC, the contained
+ * value object should be of type NumberEval; if cell type is CELL_TYPE_STRING,
+ * contained value object should be of type StringEval
+ */
+public interface RefEval extends ValueEval {
+
+    /**
+     * The (possibly evaluated) ValueEval contained
+     * in this RefEval. eg. if cell A1 contains "test"
+     * then in a formula referring to cell A1 
+     * the RefEval representing
+     * A1 will return as the getInnerValueEval() the
+     * object of concrete type StringEval
+     * @return
+     */
+    public ValueEval getInnerValueEval();
+
+    /**
+     * returns the column index.
+     * @return
+     */
+    public short getColumn();
+
+    /**
+     * returns the row index.
+     * @return
+     */
+    public short getRow();
+    
+    /**
+     * returns true if this RefEval contains an
+     * evaluated value instead of a direct value.
+     * eg. say cell A1 has the value: ="test"
+     * Then the RefEval representing A1 will return
+     * isEvaluated() equal to false. On the other
+     * hand, say cell A1 has the value: =B1 and
+     * B1 has the value "test", then the RefEval
+     * representing A1 will return isEvaluated()
+     * equal to true.
+     * @return
+     */
+    public boolean isEvaluated();
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/RelationalOperationEval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/RelationalOperationEval.java
new file mode 100644 (file)
index 0000000..de5004d
--- /dev/null
@@ -0,0 +1,200 @@
+/*
+ * Created on May 10, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *
+ */
+public abstract class RelationalOperationEval implements OperationEval {
+
+    protected class RelationalValues {
+        public Double[] ds = new Double[2];
+        public Boolean[] bs = new Boolean[2];
+        public String[] ss = new String[3];
+        public ErrorEval ee = null;
+    }
+
+    
+    /*
+     * This is a description of how the relational operators apply in MS Excel.
+     * Use this as a guideline when testing/implementing the evaluate methods 
+     * for the relational operators Evals.
+     * 
+     * Bool > any number. ALWAYS
+     * Bool > any string. ALWAYS
+     * Bool.TRUE > Bool.FALSE
+     * 
+     * String > any number. ALWAYS
+     * String > Blank. ALWAYS
+     * String are sorted dictionary wise
+     * 
+     * Blank == 0 (numeric)
+     */
+    public RelationalValues doEvaluate(Eval[] operands, int srcRow, short srcCol) {
+        RelationalValues retval = new RelationalValues();
+        
+        switch (operands.length) {
+        default:
+            retval.ee = ErrorEval.ERROR_520;
+            break;
+        case 2:
+            internalDoEvaluate(operands, srcRow, srcCol, retval, 0);
+            internalDoEvaluate(operands, srcRow, srcCol, retval, 1);
+        } // end switch
+        return retval;
+    }
+    
+    /**
+     * convenience method to avoid code duplication for multiple operands
+     * @param operands
+     * @param srcRow
+     * @param srcCol
+     * @param retval
+     * @param index
+     */
+    private void internalDoEvaluate(Eval[] operands, int srcRow, short srcCol, RelationalValues retval, int index) {
+        if (operands[index] instanceof BoolEval) {
+            BoolEval be = (BoolEval) operands[index];
+            retval.bs[index] = Boolean.valueOf(be.getBooleanValue());
+        }
+        else if (operands[index] instanceof NumericValueEval) {
+            NumericValueEval ne = (NumericValueEval) operands[index];
+            retval.ds[index] = new Double(ne.getNumberValue());
+        }
+        else if (operands[index] instanceof StringValueEval) {
+            StringValueEval se = (StringValueEval) operands[index];
+            retval.ss[index] = se.getStringValue();
+        }
+        else if (operands[index] instanceof RefEval) {
+            RefEval re = (RefEval) operands[index];
+            ValueEval ve = re.getInnerValueEval();
+            if (ve instanceof BoolEval) {
+                BoolEval be = (BoolEval) ve;
+                retval.bs[index] = Boolean.valueOf(be.getBooleanValue());
+            }
+            else if (ve instanceof BlankEval) {
+                retval.ds[index] = new Double(0);
+            }
+            else if (ve instanceof NumericValueEval) {
+                NumericValueEval ne = (NumericValueEval) ve;
+                retval.ds[index] = new Double(ne.getNumberValue());
+            }
+            else if (ve instanceof StringValueEval) {
+                StringValueEval se = (StringValueEval) ve;
+                retval.ss[index] = se.getStringValue();
+            }
+        }
+        else if (operands[index] instanceof AreaEval) {
+            AreaEval ae = (AreaEval) operands[index];
+            if (ae.isRow()) {
+                if (ae.containsColumn(srcCol)) {
+                    ValueEval ve = ae.getValueAt(ae.getFirstRow(), srcCol);
+                    if (ve instanceof BoolEval) {
+                        BoolEval be = (BoolEval) ve;
+                        retval.bs[index] = Boolean.valueOf(be.getBooleanValue());
+                    }
+                    else if (ve instanceof BlankEval) {
+                        retval.ds[index] = new Double(0);
+                    }
+                    else if (ve instanceof NumericValueEval) {
+                        NumericValueEval ne = (NumericValueEval) ve;
+                        retval.ds[index] = new Double(ne.getNumberValue());
+                    }
+                    else if (ve instanceof StringValueEval) {
+                        StringValueEval se = (StringValueEval) ve;
+                        retval.ss[index] = se.getStringValue();
+                    }
+                    else {
+                        retval.ee = ErrorEval.VALUE_INVALID;
+                    }
+                }
+                else {
+                    retval.ee = ErrorEval.VALUE_INVALID;
+                }
+            }
+            else if (ae.isColumn()) {
+                if (ae.containsRow(srcRow)) {
+                    ValueEval ve = ae.getValueAt(srcRow, ae.getFirstColumn());
+                    if (ve instanceof BoolEval) {
+                        BoolEval be = (BoolEval) ve;
+                        retval.bs[index] = Boolean.valueOf(be.getBooleanValue());
+                    }
+                    else if (ve instanceof BlankEval) {
+                        retval.ds[index] = new Double(0);
+                    }
+                    else if (ve instanceof NumericValueEval) {
+                        NumericValueEval ne = (NumericValueEval) ve;
+                        retval.ds[index] = new Double(ne.getNumberValue());
+                    }
+                    else if (ve instanceof StringValueEval) {
+                        StringValueEval se = (StringValueEval) ve;
+                        retval.ss[index] = se.getStringValue();
+                    }
+                    else {
+                        retval.ee = ErrorEval.VALUE_INVALID;
+                    }
+                }
+                else {
+                    retval.ee = ErrorEval.VALUE_INVALID;
+                }
+            }
+            else {
+                retval.ee = ErrorEval.VALUE_INVALID;
+            }
+        }
+    }
+    
+    // if both null return 0, else non null wins, else TRUE wins
+    protected int doComparison(Boolean[] bs) {
+        int retval = 0;
+        if (bs[0] != null || bs[1] != null) {
+            retval = bs[0] != null
+                    ? bs[1] != null
+                            ? bs[0].booleanValue()
+                                    ? bs[1].booleanValue()
+                                            ? 0
+                                            : 1
+                                    : bs[1].booleanValue()
+                                            ? -1
+                                            : 0
+                            : 1
+                    : bs[1] != null
+                            ? -1
+                            : 0;
+        }
+        return retval;
+    }
+
+    // if both null return 0, else non null wins, else string compare
+    protected int doComparison(String[] ss) {
+        int retval = 0;
+        if (ss[0] != null || ss[1] != null) {
+            retval = ss[0] != null
+                    ? ss[1] != null
+                            ? ss[0].compareTo(ss[1])
+                            : 1
+                    : ss[1] != null
+                            ? -1
+                            : 0;
+        }
+        return retval;
+    }
+
+    // if both null return 0, else non null wins, else doublevalue compare
+    protected int doComparison(Double[] ds) {
+        int retval = 0;
+        if (ds[0] != null || ds[1] != null) {
+            retval = ds[0] != null
+                    ? ds[1] != null
+                            ? ds[0].compareTo(ds[1])
+                            : 1
+                    : ds[1] != null
+                            ? -1
+                            : 0;
+        }
+        return retval;
+    }
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/StringEval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/StringEval.java
new file mode 100644 (file)
index 0000000..f8b4cca
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Created on May 8, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+import org.apache.poi.hssf.record.formula.Ptg;
+import org.apache.poi.hssf.record.formula.StringPtg;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class StringEval implements StringValueEval {
+
+    private String value;
+
+    public StringEval(Ptg ptg) {
+        this.value = ((StringPtg) ptg).getValue();
+    }
+
+    public StringEval(String value) {
+        this.value = value;
+    }
+
+    public String getStringValue() {
+        return value;
+    }
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/StringOperationEval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/StringOperationEval.java
new file mode 100644 (file)
index 0000000..0f60740
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Created on May 14, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *
+ */
+public abstract class StringOperationEval implements OperationEval {
+
+
+
+    /**
+     * Returns an instanceof StringValueEval or ErrorEval or BlankEval
+     * 
+     * @param eval
+     * @param srcRow
+     * @param srcCol
+     * @return
+     */
+    protected ValueEval singleOperandEvaluate(Eval eval, int srcRow, short srcCol) {
+        ValueEval retval;
+        if (eval instanceof AreaEval) {
+            AreaEval ae = (AreaEval) eval;
+            if (ae.contains(srcRow, srcCol)) { // circular ref!
+                retval = ErrorEval.CIRCULAR_REF_ERROR;
+            }
+            else if (ae.isRow()) {
+                if (ae.containsColumn(srcCol)) {
+                    ValueEval ve = ae.getValueAt(ae.getFirstRow(), srcCol);
+                    retval = internalResolveEval(eval);
+                }
+                else {
+                    retval = ErrorEval.NAME_INVALID;
+                }
+            }
+            else if (ae.isColumn()) {
+                if (ae.containsRow(srcRow)) {
+                    ValueEval ve = ae.getValueAt(srcRow, ae.getFirstColumn());
+                    retval = internalResolveEval(eval);
+                }
+                else {
+                    retval = ErrorEval.NAME_INVALID;
+                }
+            }
+            else {
+                retval = ErrorEval.NAME_INVALID;
+            }
+        }
+        else {
+            retval = internalResolveEval(eval);
+        }
+        return retval;
+    }
+
+    private ValueEval internalResolveEval(Eval eval) {
+        ValueEval retval;
+        if (eval instanceof StringValueEval) {
+            retval = (StringValueEval) eval;
+        }
+        else if (eval instanceof RefEval) {
+            RefEval re = (RefEval) eval;
+            ValueEval tve = re.getInnerValueEval();
+            if (tve instanceof StringValueEval || tve instanceof BlankEval) {
+                retval = tve;
+            }
+            else {
+                retval = ErrorEval.NAME_INVALID;
+            }
+        }
+        else if (eval instanceof BlankEval) {
+            retval = (BlankEval) eval;
+        }
+        else {
+            retval = ErrorEval.NAME_INVALID;
+        }
+        return retval;
+    }
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/StringValueEval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/StringValueEval.java
new file mode 100644 (file)
index 0000000..9cadd30
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * Created on May 8, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public interface StringValueEval extends ValueEval {
+
+    public String getStringValue();
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/SubtractEval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/SubtractEval.java
new file mode 100644 (file)
index 0000000..6b2c989
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Created on May 8, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+import org.apache.poi.hssf.record.formula.Ptg;
+import org.apache.poi.hssf.record.formula.SubtractPtg;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class SubtractEval extends NumericOperationEval {
+
+    private SubtractPtg delegate;
+
+    private static final ValueEvalToNumericXlator NUM_XLATOR = 
+        new ValueEvalToNumericXlator((short)
+                ( ValueEvalToNumericXlator.BOOL_IS_PARSED 
+                | ValueEvalToNumericXlator.EVALUATED_REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.EVALUATED_REF_STRING_IS_PARSED
+                | ValueEvalToNumericXlator.REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.STRING_IS_PARSED
+                ));
+
+    public SubtractEval(Ptg ptg) {
+        delegate = (SubtractPtg) ptg;
+    }
+    
+    protected ValueEvalToNumericXlator getXlator() {
+        return NUM_XLATOR;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        Eval retval = null;
+        double d0 = 0;
+        double d1 = 0;
+        switch (operands.length) {
+        default: // will rarely happen. currently the parser itself fails.
+            retval = ErrorEval.UNKNOWN_ERROR;
+            break;
+        case 2:
+            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
+            if (ve instanceof NumericValueEval) {
+                d0 = ((NumericValueEval) ve).getNumberValue();
+            }
+            else if (ve instanceof BlankEval) {
+                // do nothing
+            }
+            else {
+                retval = ErrorEval.VALUE_INVALID;
+            }
+            
+            if (retval == null) { // no error yet
+                ve = singleOperandEvaluate(operands[1], srcRow, srcCol);
+                if (ve instanceof NumericValueEval) {
+                    d1 = ((NumericValueEval) ve).getNumberValue();
+                }
+                else if (ve instanceof BlankEval) {
+                    // do nothing
+                }
+                else {
+                    retval = ErrorEval.VALUE_INVALID;
+                }
+            }
+        } // end switch
+
+        if (retval == null) {
+            retval = (Double.isNaN(d0) || Double.isNaN(d1)) 
+                    ? (ValueEval) ErrorEval.VALUE_INVALID 
+                    : new NumberEval(d0 - d1);
+        }
+        return retval;
+    }
+
+    public int getNumberOfOperands() {
+        return delegate.getNumberOfOperands();
+    }
+
+    public int getType() {
+        return delegate.getType();
+    }
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/UnaryMinusEval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/UnaryMinusEval.java
new file mode 100644 (file)
index 0000000..84eecec
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Created on May 8, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+import org.apache.poi.hssf.record.formula.Ptg;
+import org.apache.poi.hssf.record.formula.UnaryMinusPtg;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class UnaryMinusEval extends NumericOperationEval {
+
+    private UnaryMinusPtg delegate;
+    private static final ValueEvalToNumericXlator NUM_XLATOR = 
+        new ValueEvalToNumericXlator((short)
+                ( ValueEvalToNumericXlator.BOOL_IS_PARSED 
+                | ValueEvalToNumericXlator.EVALUATED_REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.EVALUATED_REF_STRING_IS_PARSED
+                | ValueEvalToNumericXlator.REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.STRING_IS_PARSED
+                ));
+
+
+    public UnaryMinusEval(Ptg ptg) {
+        this.delegate = (UnaryMinusPtg) ptg;
+    }
+    
+    protected ValueEvalToNumericXlator getXlator() {
+        return NUM_XLATOR;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        ValueEval retval = null;
+        double d = 0;
+        
+        switch (operands.length) {
+        default:
+            retval = ErrorEval.UNKNOWN_ERROR;
+            break;
+        case 1:
+            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
+            if (ve instanceof NumericValueEval) {
+                d = ((NumericValueEval) ve).getNumberValue();
+            }
+            else if (ve instanceof BlankEval) {
+                // do nothing
+            }
+            else if (ve instanceof ErrorEval) {
+                retval = ve;
+            }
+        }
+        
+        if (retval == null) {
+            retval = new NumberEval(-d);
+        }
+
+        return retval;
+    }
+
+    public int getNumberOfOperands() {
+        return delegate.getNumberOfOperands();
+    }
+
+    public int getType() {
+        return delegate.getType();
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/UnaryPlusEval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/UnaryPlusEval.java
new file mode 100644 (file)
index 0000000..5b31166
--- /dev/null
@@ -0,0 +1,131 @@
+/*
+ * Created on May 8, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+import org.apache.poi.hssf.record.formula.Ptg;
+import org.apache.poi.hssf.record.formula.UnaryPlusPtg;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class UnaryPlusEval implements OperationEval /*extends NumericOperationEval*/ {
+
+    private UnaryPlusPtg delegate;
+    
+    /* 
+     * COMMENT FOR COMMENTED CODE IN THIS FILE
+     * 
+     * The loser who programmed this in excel didnt care to
+     * think about how strings were handled in other numeric
+     * operations when he/she was implementing this operation :P
+     * 
+     * Here's what I mean:
+     * 
+     * Q. If the formula -"hello" evaluates to #VALUE! in excel, what should
+     * the formula +"hello" evaluate to?
+     * 
+     * A. +"hello" evaluates to "hello"
+     * 
+     * DO NOT remove the commented code (In memory of the excel
+     * programmer who implemented the UnaryPlus operation :)
+     */
+
+    
+//    private static final ValueEvalToNumericXlator NUM_XLATOR = 
+//        new ValueEvalToNumericXlator((short)
+//                ( ValueEvalToNumericXlator.BOOL_IS_PARSED 
+//                | ValueEvalToNumericXlator.EVALUATED_REF_BOOL_IS_PARSED
+//                | ValueEvalToNumericXlator.EVALUATED_REF_STRING_IS_PARSED
+//                | ValueEvalToNumericXlator.REF_BOOL_IS_PARSED
+//                | ValueEvalToNumericXlator.STRING_IS_PARSED
+//                ));
+
+
+    public UnaryPlusEval(Ptg ptg) {
+        this.delegate = (UnaryPlusPtg) ptg;
+    }
+    
+//    protected ValueEvalToNumericXlator getXlator() {
+//        return NUM_XLATOR;
+//    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        ValueEval retval = null;
+        
+        switch (operands.length) {
+        default:
+            retval = ErrorEval.UNKNOWN_ERROR;
+            break;
+        case 1:
+
+//            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
+//            if (ve instanceof NumericValueEval) {
+//                d = ((NumericValueEval) ve).getNumberValue();
+//            }
+//            else if (ve instanceof BlankEval) {
+//                // do nothing
+//            }
+//            else if (ve instanceof ErrorEval) {
+//                retval = ve;
+//            }
+            if (operands[0] instanceof RefEval) {
+                RefEval re = (RefEval) operands[0];
+                retval = re.getInnerValueEval();
+            }
+            else if (operands[0] instanceof AreaEval) {
+                AreaEval ae = (AreaEval) operands[0];
+                if (ae.contains(srcRow, srcCol)) { // circular ref!
+                    retval = ErrorEval.CIRCULAR_REF_ERROR;
+                }
+                else if (ae.isRow()) {
+                    if (ae.containsColumn(srcCol)) {
+                        ValueEval ve = ae.getValueAt(ae.getFirstRow(), srcCol);
+                        if (ve instanceof RefEval) {
+                            ve = ((RefEval) ve).getInnerValueEval();
+                        }
+                        retval = ve;
+                    }
+                    else {
+                        retval = ErrorEval.VALUE_INVALID;
+                    }
+                }
+                else if (ae.isColumn()) {
+                    if (ae.containsRow(srcRow)) {
+                        ValueEval ve = ae.getValueAt(ae.getFirstRow(), srcCol);
+                        if (ve instanceof RefEval) {
+                            ve = ((RefEval) ve).getInnerValueEval();
+                        }
+                        retval = ve;
+                    }
+                    else {
+                        retval = ErrorEval.VALUE_INVALID;
+                    }
+                }
+                else {
+                    retval = ErrorEval.VALUE_INVALID;
+                }
+            }
+            else {
+                retval = (ValueEval) operands[0];
+            }
+        }
+        
+        if (retval instanceof BlankEval) {
+            retval = new NumberEval(0);
+        }
+
+        return retval;
+    }
+
+    public int getNumberOfOperands() {
+        return delegate.getNumberOfOperands();
+    }
+
+    public int getType() {
+        return delegate.getType();
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/ValueEval.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/ValueEval.java
new file mode 100644 (file)
index 0000000..44d0d6d
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 8, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public interface ValueEval extends Eval {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/ValueEvalToNumericXlator.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/ValueEvalToNumericXlator.java
new file mode 100644 (file)
index 0000000..fb08922
--- /dev/null
@@ -0,0 +1,203 @@
+/*
+ * Created on May 14, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *
+ */
+public class ValueEvalToNumericXlator {
+
+    public static final short STRING_IS_PARSED = 0x0001;
+    public static final short BOOL_IS_PARSED = 0x0002;
+    
+    public static final short REF_STRING_IS_PARSED = 0x0004;
+    public static final short REF_BOOL_IS_PARSED = 0x0008;
+    
+    public static final short EVALUATED_REF_STRING_IS_PARSED = 0x0010;
+    public static final short EVALUATED_REF_BOOL_IS_PARSED = 0x0020;
+    
+    public static final short STRING_TO_BOOL_IS_PARSED = 0x0040;
+    public static final short REF_STRING_TO_BOOL_IS_PARSED = 0x0080;
+    
+    public static final short STRING_IS_INVALID_VALUE = 0x0100;
+    public static final short REF_STRING_IS_INVALID_VALUE = 0x200;
+    
+    private final short flags;
+    
+    
+    public ValueEvalToNumericXlator(short flags) {
+        this.flags = flags;
+    }
+    
+    /**
+     * returned value can be either A NumericValueEval, BlankEval or ErrorEval.
+     * The params can be either NumberEval, BoolEval, StringEval, or
+     * RefEval
+     * @param eval
+     * @return
+     */
+    public ValueEval attemptXlateToNumeric(ValueEval eval) {
+        ValueEval retval = null;
+        
+        if (eval == null) {
+            retval = BlankEval.INSTANCE;
+        }
+        
+        // most common case - least worries :)
+        else if (eval instanceof NumberEval) {
+            retval = (NumberEval) eval; 
+        }
+        
+        // booleval
+        else if (((flags | BOOL_IS_PARSED) > 0) && eval instanceof BoolEval) {
+            retval = (NumericValueEval) eval;
+        } 
+        
+        // stringeval 
+        else if (eval instanceof StringEval) {
+            retval = handleStringEval((StringEval) eval);
+        }
+        
+        // refeval
+        else if (eval instanceof RefEval) {
+            retval = handleRefEval((RefEval) eval);
+        }
+        
+        //blankeval
+        else if (eval instanceof BlankEval) {
+            retval = eval;
+        }
+        
+        // erroreval
+        else if (eval instanceof ErrorEval) {
+            retval = eval;
+        }
+        
+        // probably AreaEval? then not acceptable.
+        else {
+            throw new RuntimeException("Invalid ValueEval type passed for conversion: " + eval.getClass());
+        }
+        return retval;
+    }
+    
+    /**
+     * uses the relevant flags to decode the supplied RefVal
+     * @param eval
+     * @return
+     */
+    private ValueEval handleRefEval(RefEval reval) {
+        ValueEval retval = null;
+        ValueEval eval = (ValueEval) reval.getInnerValueEval();
+        
+        // most common case - least worries :)
+        if (eval instanceof NumberEval) {
+            retval = (NumberEval) eval; // the cast is correct :)
+        }
+        
+        // booleval
+        else if (((flags | REF_BOOL_IS_PARSED) > 0) && eval instanceof BoolEval) {
+            retval = (NumericValueEval) eval;
+        } 
+        
+        // stringeval 
+        else if (eval instanceof StringEval) {
+            retval = handleRefStringEval((StringEval) eval);
+        }
+        
+        //blankeval
+        else if (eval instanceof BlankEval) {
+            retval = eval;
+        }
+        
+        // erroreval
+        else if (eval instanceof ErrorEval) {
+            retval = eval;
+        }
+        
+        // probably AreaEval or another RefEval? then not acceptable.
+        else {
+            throw new RuntimeException("Invalid ValueEval type passed for conversion: " + eval.getClass());
+        }
+        return retval;
+    }
+    
+    /**
+     * uses the relevant flags to decode the StringEval
+     * @param eval
+     * @return
+     */
+    private ValueEval handleStringEval(StringEval eval) {
+        ValueEval retval = null;
+        if ((flags | STRING_IS_PARSED) > 0) {
+            StringEval sve = (StringEval) eval;
+            String s = sve.getStringValue();
+            try { 
+                double d = Double.parseDouble(s);
+                retval = new NumberEval(d);
+            } 
+            catch (Exception e) { retval = ErrorEval.VALUE_INVALID; }
+        }
+        else if ((flags | STRING_TO_BOOL_IS_PARSED) > 0) {
+            StringEval sve = (StringEval) eval;
+            String s = sve.getStringValue();
+            try { 
+                boolean b = Boolean.getBoolean(s);
+                retval = b ? BoolEval.TRUE : BoolEval.FALSE;
+            } 
+            catch (Exception e) { retval = ErrorEval.VALUE_INVALID; }
+        }
+        
+        // strings are errors?
+        else if ((flags | STRING_IS_INVALID_VALUE) > 0) {
+            retval = ErrorEval.VALUE_INVALID;
+        }
+        
+        // ignore strings
+        else {
+            retval = BlankEval.INSTANCE;
+        }
+        return retval;
+    }
+    
+    /**
+     * uses the relevant flags to decode the StringEval
+     * @param eval
+     * @return
+     */
+    private ValueEval handleRefStringEval(StringEval eval) {
+        ValueEval retval = null;
+        if ((flags | REF_STRING_IS_PARSED) > 0) {
+            StringEval sve = (StringEval) eval;
+            String s = sve.getStringValue();
+            try { 
+                double d = Double.parseDouble(s);
+                retval = new NumberEval(d);
+            } 
+            catch (Exception e) { retval = ErrorEval.VALUE_INVALID; }
+        }
+        else if ((flags | REF_STRING_TO_BOOL_IS_PARSED) > 0) {
+            StringEval sve = (StringEval) eval;
+            String s = sve.getStringValue();
+            try { 
+                boolean b = Boolean.getBoolean(s);
+                retval = retval = b ? BoolEval.TRUE : BoolEval.FALSE;;
+            } 
+            catch (Exception e) { retval = ErrorEval.VALUE_INVALID; }
+        }
+        
+        // strings are errors?
+        else if ((flags | REF_STRING_IS_INVALID_VALUE) > 0) {
+            retval = ErrorEval.VALUE_INVALID;
+        }
+        
+        // ignore strings
+        else {
+            retval = BlankEval.INSTANCE;
+        }
+        return retval;
+    }
+    
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Abs.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Abs.java
new file mode 100644 (file)
index 0000000..9f29615
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Created on May 6, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.BlankEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEvalToNumericXlator;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class Abs extends NumericFunction {
+    
+    private static final ValueEvalToNumericXlator NUM_XLATOR = 
+        new ValueEvalToNumericXlator((short)
+                ( ValueEvalToNumericXlator.BOOL_IS_PARSED 
+                | ValueEvalToNumericXlator.EVALUATED_REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.EVALUATED_REF_STRING_IS_PARSED
+                | ValueEvalToNumericXlator.REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.STRING_IS_PARSED
+                ));
+
+    protected ValueEvalToNumericXlator getXlator() {
+        return NUM_XLATOR;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        double d = 0;
+        ValueEval retval = null;
+        
+        switch (operands.length) {
+        default:
+            retval = ErrorEval.VALUE_INVALID;
+            break;
+        case 1:
+            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
+            if (ve instanceof NumericValueEval) {
+                NumericValueEval ne = (NumericValueEval) ve;
+                d = ne.getNumberValue();
+            }
+            else if (ve instanceof BlankEval) {
+                // do nothing
+            }
+            else {
+                retval = ErrorEval.NUM_ERROR;
+            }
+        }
+        
+        if (retval == null) {
+            retval = (Double.isNaN(d)) ? (ValueEval) ErrorEval.VALUE_INVALID : new NumberEval(Math.abs(d));
+        }
+        return retval;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Absref.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Absref.java
new file mode 100644 (file)
index 0000000..875e382
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Absref extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Acos.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Acos.java
new file mode 100644 (file)
index 0000000..eb8e693
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Created on May 6, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.BlankEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEvalToNumericXlator;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class Acos extends NumericFunction {
+    
+    private static final ValueEvalToNumericXlator NUM_XLATOR = 
+        new ValueEvalToNumericXlator((short)
+                ( ValueEvalToNumericXlator.BOOL_IS_PARSED 
+                | ValueEvalToNumericXlator.EVALUATED_REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.EVALUATED_REF_STRING_IS_PARSED
+                | ValueEvalToNumericXlator.REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.STRING_IS_PARSED
+                ));
+
+    protected ValueEvalToNumericXlator getXlator() {
+        return NUM_XLATOR;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        double d = 0;
+        ValueEval retval = null;
+        
+        switch (operands.length) {
+        default:
+            break;
+        case 1:
+            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
+            if (ve instanceof NumericValueEval) {
+                NumericValueEval ne = (NumericValueEval) ve;
+                d = ne.getNumberValue();
+            }
+            else if (ve instanceof BlankEval) {
+                // do nothing
+            }
+            else {
+                retval = ErrorEval.NUM_ERROR;
+            }
+        }
+        
+        if (retval == null) {
+            d = Math.acos(d);
+            retval = (Double.isNaN(d)) ? (ValueEval) ErrorEval.VALUE_INVALID : new NumberEval(d);
+        }
+        return retval;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Acosh.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Acosh.java
new file mode 100644 (file)
index 0000000..570e109
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Created on May 6, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEvalToNumericXlator;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ * Support for hyperbolic trig functions was added as a part of 
+ * Java distribution only in JDK1.5. This class uses custom 
+ * naive implementation based on formulas at:
+ * http://www.math2.org/math/trig/hyperbolics.htm
+ * These formulas seem to agree with excel's implementation.
+ * 
+ */
+public class Acosh extends NumericFunction {
+    
+    private static final ValueEvalToNumericXlator NUM_XLATOR = 
+        new ValueEvalToNumericXlator((short)
+                ( ValueEvalToNumericXlator.BOOL_IS_PARSED 
+                | ValueEvalToNumericXlator.EVALUATED_REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.EVALUATED_REF_STRING_IS_PARSED
+                | ValueEvalToNumericXlator.REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.STRING_IS_PARSED
+                ));
+
+    protected ValueEvalToNumericXlator getXlator() {
+        return NUM_XLATOR;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        double d = 0;
+        ValueEval retval = null;
+        
+        switch (operands.length) {
+        default:
+            break;
+        case 1:
+            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
+            if (ve instanceof NumericValueEval) {
+                NumericValueEval ne = (NumericValueEval) ve;
+                d = ne.getNumberValue();
+            }
+        }
+        
+        if (retval == null) {
+            d = Math.log(Math.sqrt(Math.pow(d, 2) - 1) + d);
+            retval = (Double.isNaN(d) || Double.isInfinite(d)) ? (ValueEval) ErrorEval.NUM_ERROR : new NumberEval(d);
+        }
+        return retval;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Activecell.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Activecell.java
new file mode 100644 (file)
index 0000000..d8f08c2
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Activecell extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Addbar.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Addbar.java
new file mode 100644 (file)
index 0000000..70000ef
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Addbar extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Addcommand.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Addcommand.java
new file mode 100644 (file)
index 0000000..deab551
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Addcommand extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Addmenu.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Addmenu.java
new file mode 100644 (file)
index 0000000..9027fae
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Addmenu extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Address.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Address.java
new file mode 100644 (file)
index 0000000..402a361
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Address extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Addtoolbar.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Addtoolbar.java
new file mode 100644 (file)
index 0000000..1d73339
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Addtoolbar extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/And.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/And.java
new file mode 100644 (file)
index 0000000..bca5463
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Created on May 9, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+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;
+import org.apache.poi.hssf.record.formula.eval.StringEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+
+/**
+ * @author
+ *  
+ */
+public class And extends BooleanFunction {
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        ValueEval retval = null;
+        boolean b = true;
+        boolean atleastOneNonBlank = false;
+        
+        /*
+         * Note: do not abort the loop if b is false, since we could be
+         * dealing with errorevals later. 
+         */
+        outer:
+        for (int i=0, iSize=operands.length; i<iSize; i++) {
+            if (operands[i] instanceof AreaEval) {
+                AreaEval ae = (AreaEval) operands[i];
+                ValueEval[] values = ae.getValues();
+                for (int j=0, jSize=values.length; j<jSize; j++) {
+                    ValueEval tempVe = tempVe = singleOperandEvaluate(values[j], srcRow, srcCol, true);
+                    if (tempVe instanceof BoolEval) {
+                        b = b && ((BoolEval) tempVe).getBooleanValue();
+                        atleastOneNonBlank = true;
+                    }
+                    else if (tempVe instanceof ErrorEval) {
+                        retval = tempVe;
+                        break outer;
+                    }
+                }
+            }
+            else {
+                ValueEval tempVe = singleOperandEvaluate(operands[i], srcRow, srcCol, false);
+                if (tempVe instanceof BoolEval) {
+                    b = b && ((BoolEval) tempVe).getBooleanValue();
+                    atleastOneNonBlank = true;
+                }
+                else if (tempVe instanceof StringEval) {
+                    retval = ErrorEval.VALUE_INVALID;
+                }
+                else if (tempVe instanceof ErrorEval) {
+                    retval = tempVe;
+                    break outer;
+                }
+            }
+        }
+        
+        if (!atleastOneNonBlank) {
+            retval = ErrorEval.VALUE_INVALID;
+        }
+        
+        if (retval == null) { // if no error
+            retval = b ? BoolEval.TRUE : BoolEval.FALSE;
+        }
+        
+        return retval;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Apptitle.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Apptitle.java
new file mode 100644 (file)
index 0000000..c7326cd
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Apptitle extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Areas.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Areas.java
new file mode 100644 (file)
index 0000000..2ae8c27
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Areas extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Argument.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Argument.java
new file mode 100644 (file)
index 0000000..51e2a09
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Argument extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Asc.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Asc.java
new file mode 100644 (file)
index 0000000..0ba274c
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Asc extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Asin.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Asin.java
new file mode 100644 (file)
index 0000000..ebf169b
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Created on May 6, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.BlankEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEvalToNumericXlator;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class Asin extends NumericFunction {
+    
+    private static final ValueEvalToNumericXlator NUM_XLATOR = 
+        new ValueEvalToNumericXlator((short)
+                ( ValueEvalToNumericXlator.BOOL_IS_PARSED 
+                | ValueEvalToNumericXlator.EVALUATED_REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.EVALUATED_REF_STRING_IS_PARSED
+                | ValueEvalToNumericXlator.REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.STRING_IS_PARSED
+                ));
+
+    protected ValueEvalToNumericXlator getXlator() {
+        return NUM_XLATOR;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        double d = 0;
+        ValueEval retval = null;
+        
+        switch (operands.length) {
+        default:
+            break;
+        case 1:
+            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
+            if (ve instanceof NumericValueEval) {
+                NumericValueEval ne = (NumericValueEval) ve;
+                d = ne.getNumberValue();
+            }
+            else if (ve instanceof BlankEval) {
+                // do nothing
+            }
+            else {
+                retval = ErrorEval.NUM_ERROR;
+            }
+        }
+        
+        if (retval == null) {
+            d = Math.asin(d);
+            retval = (Double.isNaN(d)) ? (ValueEval) ErrorEval.VALUE_INVALID : new NumberEval(d);
+        }
+        return retval;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Asinh.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Asinh.java
new file mode 100644 (file)
index 0000000..b33f12c
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Created on May 6, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.BlankEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEvalToNumericXlator;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ * Support for hyperbolic trig functions was added as a part of 
+ * Java distribution only in JDK1.5. This class uses custom 
+ * naive implementation based on formulas at:
+ * http://www.math2.org/math/trig/hyperbolics.htm
+ * These formulas seem to agree with excel's implementation.
+ * 
+ */
+public class Asinh extends NumericFunction {
+    
+    private static final ValueEvalToNumericXlator NUM_XLATOR = 
+        new ValueEvalToNumericXlator((short)
+                ( ValueEvalToNumericXlator.BOOL_IS_PARSED 
+                | ValueEvalToNumericXlator.EVALUATED_REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.EVALUATED_REF_STRING_IS_PARSED
+                | ValueEvalToNumericXlator.REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.STRING_IS_PARSED
+                ));
+
+    protected ValueEvalToNumericXlator getXlator() {
+        return NUM_XLATOR;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        double d = 0;
+        ValueEval retval = null;
+        
+        switch (operands.length) {
+        default:
+            break;
+        case 1:
+            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
+            if (ve instanceof NumericValueEval) {
+                NumericValueEval ne = (NumericValueEval) ve;
+                d = ne.getNumberValue();
+            }
+            else if (ve instanceof BlankEval) {
+                // do nothing
+            }
+            else {
+                retval = ErrorEval.NUM_ERROR;
+            }
+        }
+        
+        if (retval == null) {
+            d = Math.log(Math.sqrt(Math.pow(d, 2) + 1) + d);
+            retval = (Double.isNaN(d)) ? (ValueEval) ErrorEval.NUM_ERROR : new NumberEval(d);
+        }
+        return retval;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Atan.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Atan.java
new file mode 100644 (file)
index 0000000..a156c0f
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Created on May 6, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.BlankEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEvalToNumericXlator;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class Atan extends NumericFunction {
+    
+    private static final ValueEvalToNumericXlator NUM_XLATOR = 
+        new ValueEvalToNumericXlator((short)
+                ( ValueEvalToNumericXlator.BOOL_IS_PARSED 
+                | ValueEvalToNumericXlator.EVALUATED_REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.EVALUATED_REF_STRING_IS_PARSED
+                | ValueEvalToNumericXlator.REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.STRING_IS_PARSED
+                ));
+
+    protected ValueEvalToNumericXlator getXlator() {
+        return NUM_XLATOR;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        double d = 0;
+        ValueEval retval = null;
+        
+        switch (operands.length) {
+        default:
+            break;
+        case 1:
+            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
+            if (ve instanceof NumericValueEval) {
+                NumericValueEval ne = (NumericValueEval) ve;
+                d = ne.getNumberValue();
+            }
+            else if (ve instanceof BlankEval) {
+                // do nothing
+            }
+            else {
+                retval = ErrorEval.NUM_ERROR;
+            }
+        }
+        
+        if (retval == null) {
+            d = Math.atan(d);
+            retval = (Double.isNaN(d)) ? (ValueEval) ErrorEval.VALUE_INVALID : new NumberEval(d);
+        }
+        return retval;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Atan2.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Atan2.java
new file mode 100644 (file)
index 0000000..89e6b09
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Created on May 6, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.BlankEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEvalToNumericXlator;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class Atan2 extends NumericFunction {
+    
+    private static final ValueEvalToNumericXlator NUM_XLATOR = 
+        new ValueEvalToNumericXlator((short)
+                ( ValueEvalToNumericXlator.BOOL_IS_PARSED 
+                | ValueEvalToNumericXlator.EVALUATED_REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.EVALUATED_REF_STRING_IS_PARSED
+                | ValueEvalToNumericXlator.REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.STRING_IS_PARSED
+                ));
+
+    protected ValueEvalToNumericXlator getXlator() {
+        return NUM_XLATOR;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        double d0 = 0;
+        double d1 = 0;
+        ValueEval retval = null;
+        
+        switch (operands.length) {
+        default:
+            break;
+        case 2:
+            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
+            if (ve instanceof NumericValueEval) {
+                NumericValueEval ne = (NumericValueEval) ve;
+                d0 = ne.getNumberValue();
+            }
+            else if (ve instanceof BlankEval) {
+                // do nothing
+            }
+            else {
+                retval = ErrorEval.NUM_ERROR;
+            }
+            
+            if (retval == null) {
+                ve = singleOperandEvaluate(operands[1], srcRow, srcCol);
+                if (ve instanceof NumericValueEval) {
+                    NumericValueEval ne = (NumericValueEval) ve;
+                    d1 = ne.getNumberValue();
+                }
+                else if (ve instanceof BlankEval) {
+                    // do nothing
+                }
+                else {
+                    retval = ErrorEval.NUM_ERROR;
+                }
+            }
+        }
+        
+        if (retval == null) {
+            double d = (d0 == d1 && d1 == 0) ? Double.NaN : Math.atan2(d1, d0);
+            retval = (Double.isNaN(d) || Double.isInfinite(d)) ? (ValueEval) ErrorEval.VALUE_INVALID : new NumberEval(d);
+        }
+        return retval;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Atanh.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Atanh.java
new file mode 100644 (file)
index 0000000..7049185
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Created on May 6, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.BlankEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEvalToNumericXlator;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ * Support for hyperbolic trig functions was added as a part of 
+ * Java distribution only in JDK1.5. This class uses custom 
+ * naive implementation based on formulas at:
+ * http://www.math2.org/math/trig/hyperbolics.htm
+ * These formulas seem to agree with excel's implementation.
+ * 
+ */
+public class Atanh extends NumericFunction {
+    
+    private static final ValueEvalToNumericXlator NUM_XLATOR = 
+        new ValueEvalToNumericXlator((short)
+                ( ValueEvalToNumericXlator.BOOL_IS_PARSED 
+                | ValueEvalToNumericXlator.EVALUATED_REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.EVALUATED_REF_STRING_IS_PARSED
+                | ValueEvalToNumericXlator.REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.STRING_IS_PARSED
+                ));
+
+    protected ValueEvalToNumericXlator getXlator() {
+        return NUM_XLATOR;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        double d = 0;
+        ValueEval retval = null;
+        
+        switch (operands.length) {
+        default:
+            break;
+        case 1:
+            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
+            if (ve instanceof NumericValueEval) {
+                NumericValueEval ne = (NumericValueEval) ve;
+                d = ne.getNumberValue();
+            }
+            else if (ve instanceof BlankEval) {
+                // do nothing
+            }
+            else {
+                retval = ErrorEval.NUM_ERROR;
+            }
+        }
+        
+        if (retval == null) {
+            d = Math.log((1 + d)/(1 - d)) / 2;
+            retval = (Double.isNaN(d) || Double.isInfinite(d)) ? (ValueEval) ErrorEval.NUM_ERROR : new NumberEval(d);
+        }
+        return retval;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Avedev.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Avedev.java
new file mode 100644 (file)
index 0000000..850e40e
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Avedev extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Average.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Average.java
new file mode 100644 (file)
index 0000000..90accd5
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Average extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Averagea.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Averagea.java
new file mode 100644 (file)
index 0000000..719b1b6
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Averagea extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Betadist.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Betadist.java
new file mode 100644 (file)
index 0000000..2dbd6ba
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Betadist extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Betainv.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Betainv.java
new file mode 100644 (file)
index 0000000..88eda06
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Betainv extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Binomdist.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Binomdist.java
new file mode 100644 (file)
index 0000000..d4fb69a
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Binomdist extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/BooleanFunction.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/BooleanFunction.java
new file mode 100644 (file)
index 0000000..3d771bd
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.BlankEval;
+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;
+import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
+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;
+
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ * Here are the general rules concerning Boolean functions:
+ * <ol>
+ * <li> Blanks are not either true or false
+ * <li> Strings are not either true or false (even strings "true" 
+ * or "TRUE" or "0" etc.)
+ * <li> Numbers: 0 is false. Any other number is TRUE.
+ * <li> References are evaluated and above rules apply.
+ * <li> Areas: Individual cells in area are evaluated and checked to 
+ * see if they are blanks, strings etc.
+ * </ol>
+ */
+public abstract class BooleanFunction implements Function {
+
+    protected ValueEval singleOperandEvaluate(Eval eval, int srcRow, short srcCol, boolean stringsAreBlanks) {
+        ValueEval retval;
+        
+        if (eval instanceof RefEval) {
+            RefEval re = (RefEval) eval;
+            ValueEval ve = re.getInnerValueEval();
+            retval = internalResolve(ve, true);
+        }
+        else {
+            retval = internalResolve(eval, stringsAreBlanks);
+        }
+        
+        return retval;
+    }
+    
+    private ValueEval internalResolve(Eval ve, boolean stringsAreBlanks) {
+        ValueEval retval = null;
+        
+        // blankeval is returned as is
+        if (ve instanceof BlankEval) {
+            retval = BlankEval.INSTANCE;
+        }
+        
+        // stringeval
+        else if (ve instanceof StringEval) {
+            retval = stringsAreBlanks ? (ValueEval) BlankEval.INSTANCE : (StringEval) ve;
+        }
+        
+        // bools are bools :)
+        else if (ve instanceof BoolEval) {
+            retval = (BoolEval) ve;
+        }
+        
+        // convert numbers to bool
+        else if (ve instanceof NumericValueEval) {
+            NumericValueEval ne = (NumericValueEval) ve;
+            double d = ne.getNumberValue();
+            retval = Double.isNaN(d) 
+                    ? (ValueEval) ErrorEval.VALUE_INVALID
+                    : (d != 0) 
+                        ? BoolEval.TRUE
+                        : BoolEval.FALSE;
+        }
+        
+        // since refevals
+        else {
+            retval = ErrorEval.VALUE_INVALID;
+        }
+        
+        return retval;
+        
+    }
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Call.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Call.java
new file mode 100644 (file)
index 0000000..ae571b3
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Call extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Caller.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Caller.java
new file mode 100644 (file)
index 0000000..44511b0
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Caller extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Cancelkey.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Cancelkey.java
new file mode 100644 (file)
index 0000000..e257d84
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Cancelkey extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Ceiling.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Ceiling.java
new file mode 100644 (file)
index 0000000..ee73137
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * Created on May 6, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+
+/**
+ * @author 
+ *  
+ */
+public class Ceiling extends DefaultFunctionImpl {
+    
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Cell.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Cell.java
new file mode 100644 (file)
index 0000000..a8764cd
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Cell extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Char.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Char.java
new file mode 100644 (file)
index 0000000..c62d72a
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Char extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Checkcommand.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Checkcommand.java
new file mode 100644 (file)
index 0000000..72d5d15
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Checkcommand extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Chidist.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Chidist.java
new file mode 100644 (file)
index 0000000..04aa57d
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Chidist extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Chiinv.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Chiinv.java
new file mode 100644 (file)
index 0000000..7807007
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Chiinv extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Chitest.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Chitest.java
new file mode 100644 (file)
index 0000000..c8a7076
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Chitest extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Choose.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Choose.java
new file mode 100644 (file)
index 0000000..b98d27c
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Choose extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Clean.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Clean.java
new file mode 100644 (file)
index 0000000..021e7ce
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Clean extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Code.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Code.java
new file mode 100644 (file)
index 0000000..f6a9be5
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Code extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Column.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Column.java
new file mode 100644 (file)
index 0000000..fa04a3c
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Column extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Columns.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Columns.java
new file mode 100644 (file)
index 0000000..5c11ea9
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Columns extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Combin.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Combin.java
new file mode 100644 (file)
index 0000000..1360d9a
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Combin extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Concatenate.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Concatenate.java
new file mode 100644 (file)
index 0000000..ed920f5
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Concatenate extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Confidence.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Confidence.java
new file mode 100644 (file)
index 0000000..031c030
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Confidence extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Correl.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Correl.java
new file mode 100644 (file)
index 0000000..3eba752
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Correl extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Cos.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Cos.java
new file mode 100644 (file)
index 0000000..52b2c30
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Created on May 6, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.BlankEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEvalToNumericXlator;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class Cos extends NumericFunction {
+    
+    private static final ValueEvalToNumericXlator NUM_XLATOR = 
+        new ValueEvalToNumericXlator((short)
+                ( ValueEvalToNumericXlator.BOOL_IS_PARSED 
+                | ValueEvalToNumericXlator.EVALUATED_REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.EVALUATED_REF_STRING_IS_PARSED
+                | ValueEvalToNumericXlator.REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.STRING_IS_PARSED
+                ));
+
+    protected ValueEvalToNumericXlator getXlator() {
+        return NUM_XLATOR;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        double d = 0;
+        ValueEval retval = null;
+        
+        switch (operands.length) {
+        default:
+            break;
+        case 1:
+            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
+            if (ve instanceof NumericValueEval) {
+                NumericValueEval ne = (NumericValueEval) ve;
+                d = ne.getNumberValue();
+            }
+            else if (ve instanceof BlankEval) {
+                // do nothing
+            }
+            else {
+                retval = ErrorEval.NUM_ERROR;
+            }
+        }
+        
+        if (retval == null) {
+            d = Math.cos(d);
+            retval = (Double.isNaN(d)) ? (ValueEval) ErrorEval.VALUE_INVALID : new NumberEval(d);
+        }
+        return retval;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Cosh.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Cosh.java
new file mode 100644 (file)
index 0000000..8956a29
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Created on May 6, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.BlankEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEvalToNumericXlator;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class Cosh extends NumericFunction {
+    
+    private static final ValueEvalToNumericXlator NUM_XLATOR = 
+        new ValueEvalToNumericXlator((short)
+                ( ValueEvalToNumericXlator.BOOL_IS_PARSED 
+                | ValueEvalToNumericXlator.EVALUATED_REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.EVALUATED_REF_STRING_IS_PARSED
+                | ValueEvalToNumericXlator.REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.STRING_IS_PARSED
+                ));
+
+    protected ValueEvalToNumericXlator getXlator() {
+        return NUM_XLATOR;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        double d = 0;
+        ValueEval retval = null;
+        
+        switch (operands.length) {
+        default:
+            break;
+        case 1:
+            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
+            if (ve instanceof NumericValueEval) {
+                NumericValueEval ne = (NumericValueEval) ve;
+                d = ne.getNumberValue();
+            }
+            else if (ve instanceof BlankEval) {
+                // do nothing
+            }
+            else {
+                retval = ErrorEval.NUM_ERROR;
+            }
+        }
+        
+        if (retval == null) {
+            double ePowX = Math.pow(E, d);
+            double ePowNegX = Math.pow(E, -d);
+            d = (ePowX + ePowNegX) / 2;
+            retval = (Double.isNaN(d) || Double.isInfinite(d)) ? (ValueEval) ErrorEval.VALUE_INVALID : new NumberEval(d);
+        }
+        return retval;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Count.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Count.java
new file mode 100644 (file)
index 0000000..acf93d4
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Count extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Counta.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Counta.java
new file mode 100644 (file)
index 0000000..5c510b1
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Counta extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Countblank.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Countblank.java
new file mode 100644 (file)
index 0000000..ed07a1e
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Countblank extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Countif.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Countif.java
new file mode 100644 (file)
index 0000000..e965ba6
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Countif extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Covar.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Covar.java
new file mode 100644 (file)
index 0000000..679d9c7
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Covar extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Createobject.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Createobject.java
new file mode 100644 (file)
index 0000000..ab44df1
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Createobject extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Critbinom.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Critbinom.java
new file mode 100644 (file)
index 0000000..aacbf86
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Critbinom extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Customrepeat.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Customrepeat.java
new file mode 100644 (file)
index 0000000..aac4d4d
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Customrepeat extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Customundo.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Customundo.java
new file mode 100644 (file)
index 0000000..d6bfc6a
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Customundo extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Date.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Date.java
new file mode 100644 (file)
index 0000000..e9d2afb
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Date extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Datedif.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Datedif.java
new file mode 100644 (file)
index 0000000..11a4126
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Datedif extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Datestring.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Datestring.java
new file mode 100644 (file)
index 0000000..e98a7dd
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Datestring extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Datevalue.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Datevalue.java
new file mode 100644 (file)
index 0000000..aa96ad1
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Datevalue extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Daverage.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Daverage.java
new file mode 100644 (file)
index 0000000..00e39b2
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Daverage extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Day.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Day.java
new file mode 100644 (file)
index 0000000..3ffa252
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Day extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Days360.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Days360.java
new file mode 100644 (file)
index 0000000..33988bc
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Days360 extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Db.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Db.java
new file mode 100644 (file)
index 0000000..676aa3f
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Db extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dbcs.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dbcs.java
new file mode 100644 (file)
index 0000000..b4bd560
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Dbcs extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dcount.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dcount.java
new file mode 100644 (file)
index 0000000..9afa9a5
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Dcount extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dcounta.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dcounta.java
new file mode 100644 (file)
index 0000000..b026d20
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Dcounta extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Ddb.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Ddb.java
new file mode 100644 (file)
index 0000000..3364be2
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Ddb extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/DefaultFunctionImpl.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/DefaultFunctionImpl.java
new file mode 100644 (file)
index 0000000..2a0ad6d
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Created on May 6, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+
+/**
+ * 
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ * This is the default implementation of a Function class. 
+ * The default behaviour is to return a non-standard ErrorEval
+ * "ErrorEval.FUNCTION_NOT_IMPLEMENTED". This error should alert 
+ * the user that the formula contained a function that is not
+ * yet implemented.
+ */
+public abstract class DefaultFunctionImpl implements Function {
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        return ErrorEval.FUNCTION_NOT_IMPLEMENTED;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Degrees.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Degrees.java
new file mode 100644 (file)
index 0000000..19485af
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Created on May 6, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.BlankEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEvalToNumericXlator;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class Degrees extends NumericFunction {
+    
+    private static final ValueEvalToNumericXlator NUM_XLATOR = 
+        new ValueEvalToNumericXlator((short)
+                ( ValueEvalToNumericXlator.BOOL_IS_PARSED 
+                | ValueEvalToNumericXlator.EVALUATED_REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.EVALUATED_REF_STRING_IS_PARSED
+                | ValueEvalToNumericXlator.REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.STRING_IS_PARSED
+                ));
+
+    protected ValueEvalToNumericXlator getXlator() {
+        return NUM_XLATOR;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        double d = 0;
+        ValueEval retval = null;
+        
+        switch (operands.length) {
+        default:
+            retval = ErrorEval.VALUE_INVALID;
+            break;
+        case 1:
+            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
+            if (ve instanceof NumericValueEval) {
+                NumericValueEval ne = (NumericValueEval) ve;
+                d = ne.getNumberValue();
+            }
+            else if (ve instanceof BlankEval) {
+                // do nothing
+            }
+            else {
+                retval = ErrorEval.NUM_ERROR;
+            }
+        }
+        
+        if (retval == null) {
+            d = Math.toDegrees(d);
+            retval = (Double.isNaN(d)) ? (ValueEval) ErrorEval.VALUE_INVALID : new NumberEval(d);
+        }
+        return retval;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Deletebar.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Deletebar.java
new file mode 100644 (file)
index 0000000..ab535a1
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Deletebar extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Deletecommand.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Deletecommand.java
new file mode 100644 (file)
index 0000000..6af3b7e
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Deletecommand extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Deletemenu.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Deletemenu.java
new file mode 100644 (file)
index 0000000..4f06c00
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Deletemenu extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Deletetoolbar.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Deletetoolbar.java
new file mode 100644 (file)
index 0000000..1020138
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Deletetoolbar extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Deref.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Deref.java
new file mode 100644 (file)
index 0000000..800678f
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Deref extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Devsq.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Devsq.java
new file mode 100644 (file)
index 0000000..74d56b2
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Devsq extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dget.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dget.java
new file mode 100644 (file)
index 0000000..67f4d25
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Dget extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dialogbox.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dialogbox.java
new file mode 100644 (file)
index 0000000..e208a59
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Dialogbox extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Directory.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Directory.java
new file mode 100644 (file)
index 0000000..13fd767
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Directory extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dmax.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dmax.java
new file mode 100644 (file)
index 0000000..9346756
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Dmax extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dmin.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dmin.java
new file mode 100644 (file)
index 0000000..da95d14
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Dmin extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Documents.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Documents.java
new file mode 100644 (file)
index 0000000..dcba8ae
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Documents extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dollar.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dollar.java
new file mode 100644 (file)
index 0000000..7fa2fe7
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Created on May 6, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.BlankEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEvalToNumericXlator;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class Dollar extends NumericFunction {
+    
+    private static final ValueEvalToNumericXlator NUM_XLATOR = 
+        new ValueEvalToNumericXlator((short)
+                ( ValueEvalToNumericXlator.BOOL_IS_PARSED 
+                | ValueEvalToNumericXlator.EVALUATED_REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.EVALUATED_REF_STRING_IS_PARSED
+                | ValueEvalToNumericXlator.REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.STRING_IS_PARSED
+                ));
+
+    protected ValueEvalToNumericXlator getXlator() {
+        return NUM_XLATOR;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        double d = 0;
+        ValueEval retval = null;
+        
+        switch (operands.length) {
+        default:
+            break;
+        case 1:
+            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
+            if (ve instanceof NumericValueEval) {
+                NumericValueEval ne = (NumericValueEval) ve;
+                d = ne.getNumberValue();
+            }
+            else if (ve instanceof BlankEval) {
+                // do nothing
+            }
+            else {
+                retval = ErrorEval.NUM_ERROR;
+            }
+        }
+        
+        if (retval == null) {
+            retval = (Double.isNaN(d)) ? (ValueEval) ErrorEval.VALUE_INVALID : new NumberEval(d);
+        }
+        return retval;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dproduct.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dproduct.java
new file mode 100644 (file)
index 0000000..36e4974
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Dproduct extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dstdev.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dstdev.java
new file mode 100644 (file)
index 0000000..6d79b46
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Dstdev extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dstdevp.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dstdevp.java
new file mode 100644 (file)
index 0000000..1f00c9c
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Dstdevp extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dsum.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dsum.java
new file mode 100644 (file)
index 0000000..2dacfbb
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Dsum extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dvar.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dvar.java
new file mode 100644 (file)
index 0000000..bb20af3
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Dvar extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dvarp.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Dvarp.java
new file mode 100644 (file)
index 0000000..4bc46ec
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Dvarp extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Echo.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Echo.java
new file mode 100644 (file)
index 0000000..4589b39
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Echo extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Enablecommand.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Enablecommand.java
new file mode 100644 (file)
index 0000000..85ef966
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Enablecommand extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Enabletool.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Enabletool.java
new file mode 100644 (file)
index 0000000..d060605
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Enabletool extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Error.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Error.java
new file mode 100644 (file)
index 0000000..a645e57
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Error extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Errortype.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Errortype.java
new file mode 100644 (file)
index 0000000..89635ee
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Errortype extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Evaluate.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Evaluate.java
new file mode 100644 (file)
index 0000000..dea6561
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Evaluate extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Even.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Even.java
new file mode 100644 (file)
index 0000000..1d5f2be
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Created on May 6, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.BlankEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEvalToNumericXlator;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class Even extends NumericFunction {
+    
+    private static final ValueEvalToNumericXlator NUM_XLATOR = 
+        new ValueEvalToNumericXlator((short)
+                ( ValueEvalToNumericXlator.BOOL_IS_PARSED 
+                | ValueEvalToNumericXlator.EVALUATED_REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.EVALUATED_REF_STRING_IS_PARSED
+                | ValueEvalToNumericXlator.REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.STRING_IS_PARSED
+                ));
+
+    protected ValueEvalToNumericXlator getXlator() {
+        return NUM_XLATOR;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        double d = 0;
+        ValueEval retval = null;
+        
+        switch (operands.length) {
+        default:
+            retval = ErrorEval.VALUE_INVALID;
+            break;
+        case 1:
+            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
+            if (ve instanceof NumericValueEval) {
+                NumericValueEval ne = (NumericValueEval) ve;
+                d = ne.getNumberValue();
+            }
+            else if (ve instanceof BlankEval) {
+                // do nothing
+            }
+            else {
+                retval = ErrorEval.NUM_ERROR;
+            }
+        }
+        
+        if (retval == null) {
+            if (!Double.isNaN(d) && !Double.isInfinite(d)) {
+                d = (d==0) 
+                    ? 0 
+                    : (((long) (d/2))*2 == d)
+                        ? d
+                        : (d < 0) 
+                            ? ((((long) (d/2))<<1)-2) 
+                            : ((((long) (d/2))<<1)+2);
+            }
+            retval = (Double.isNaN(d) || Double.isInfinite(d)) ? (ValueEval) ErrorEval.VALUE_INVALID : new NumberEval(d);
+        }
+        return retval;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Exact.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Exact.java
new file mode 100644 (file)
index 0000000..e4d1c3a
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Exact extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Exec.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Exec.java
new file mode 100644 (file)
index 0000000..362b903
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Exec extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Execute.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Execute.java
new file mode 100644 (file)
index 0000000..2f41bc3
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Execute extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Exp.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Exp.java
new file mode 100644 (file)
index 0000000..01d7979
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Created on May 6, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.BlankEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEvalToNumericXlator;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class Exp extends NumericFunction {
+    
+    private static final ValueEvalToNumericXlator NUM_XLATOR = 
+        new ValueEvalToNumericXlator((short)
+                ( ValueEvalToNumericXlator.BOOL_IS_PARSED 
+                | ValueEvalToNumericXlator.EVALUATED_REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.EVALUATED_REF_STRING_IS_PARSED
+                | ValueEvalToNumericXlator.REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.STRING_IS_PARSED
+                ));
+
+    protected ValueEvalToNumericXlator getXlator() {
+        return NUM_XLATOR;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        double d = 0;
+        ValueEval retval = null;
+        
+        switch (operands.length) {
+        default:
+            break;
+        case 1:
+            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
+            if (ve instanceof NumericValueEval) {
+                NumericValueEval ne = (NumericValueEval) ve;
+                d = ne.getNumberValue();
+            }
+            else if (ve instanceof BlankEval) {
+                // do nothing
+            }
+            else {
+                retval = ErrorEval.NUM_ERROR;
+            }
+        }
+        
+        if (retval == null) {
+            d = Math.pow(E, d);
+            retval = (Double.isNaN(d)) ? (ValueEval) ErrorEval.VALUE_INVALID : new NumberEval(d);
+        }
+        return retval;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Expondist.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Expondist.java
new file mode 100644 (file)
index 0000000..777136f
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Expondist extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Externalflag.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Externalflag.java
new file mode 100644 (file)
index 0000000..ee0772b
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Externalflag extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fact.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fact.java
new file mode 100644 (file)
index 0000000..cb28ed1
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Fact extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/False.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/False.java
new file mode 100644 (file)
index 0000000..3516d4b
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Created on May 6, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+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;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class False implements Function {
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        ValueEval retval;
+        switch (operands.length) {
+        default:
+            retval = ErrorEval.VALUE_INVALID;
+            break;
+        case 0:
+            retval = BoolEval.FALSE;
+        }
+        return retval;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fclose.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fclose.java
new file mode 100644 (file)
index 0000000..0f4f835
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Fclose extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fdist.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fdist.java
new file mode 100644 (file)
index 0000000..bdeccf7
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Fdist extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Files.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Files.java
new file mode 100644 (file)
index 0000000..332b521
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Files extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Find.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Find.java
new file mode 100644 (file)
index 0000000..8ff188b
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Find extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Findb.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Findb.java
new file mode 100644 (file)
index 0000000..f32506b
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Findb extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Finv.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Finv.java
new file mode 100644 (file)
index 0000000..5d49da7
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Finv extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fisher.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fisher.java
new file mode 100644 (file)
index 0000000..6523d24
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Fisher extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fisherinv.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fisherinv.java
new file mode 100644 (file)
index 0000000..c6160b1
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Fisherinv extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fixed.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fixed.java
new file mode 100644 (file)
index 0000000..3c08d51
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Fixed extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Floor.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Floor.java
new file mode 100644 (file)
index 0000000..17b9671
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Floor extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fopen.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fopen.java
new file mode 100644 (file)
index 0000000..82f393b
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Fopen extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Forecast.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Forecast.java
new file mode 100644 (file)
index 0000000..5d091c8
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Forecast extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Formulaconvert.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Formulaconvert.java
new file mode 100644 (file)
index 0000000..1d6d5d2
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Formulaconvert extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fpos.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fpos.java
new file mode 100644 (file)
index 0000000..521d204
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Fpos extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fread.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fread.java
new file mode 100644 (file)
index 0000000..033aadd
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Fread extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Freadln.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Freadln.java
new file mode 100644 (file)
index 0000000..039d4ca
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Freadln extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Frequency.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Frequency.java
new file mode 100644 (file)
index 0000000..069ae71
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Frequency extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fsize.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fsize.java
new file mode 100644 (file)
index 0000000..684b7ca
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Fsize extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Ftest.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Ftest.java
new file mode 100644 (file)
index 0000000..7941cc7
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Ftest extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Function.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Function.java
new file mode 100644 (file)
index 0000000..65a9bfc
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Created on May 9, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.Eval;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ * Function serves as a marker interface.
+ */
+public interface Function {
+
+    public Eval evaluate(Eval[] evals, int srcCellRow, short srcCellCol);
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fv.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fv.java
new file mode 100644 (file)
index 0000000..d0ef4ab
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Fv extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fwrite.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fwrite.java
new file mode 100644 (file)
index 0000000..54fb136
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Fwrite extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fwriteln.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Fwriteln.java
new file mode 100644 (file)
index 0000000..d3d5bd0
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Fwriteln extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Gammadist.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Gammadist.java
new file mode 100644 (file)
index 0000000..c5d2fe7
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Gammadist extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Gammainv.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Gammainv.java
new file mode 100644 (file)
index 0000000..44b2290
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Gammainv extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Gammaln.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Gammaln.java
new file mode 100644 (file)
index 0000000..985d6a9
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Gammaln extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Geomean.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Geomean.java
new file mode 100644 (file)
index 0000000..7c9353f
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Geomean extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getbar.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getbar.java
new file mode 100644 (file)
index 0000000..f098caf
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Getbar extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getcell.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getcell.java
new file mode 100644 (file)
index 0000000..bd4e9f3
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Getcell extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getchartitem.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getchartitem.java
new file mode 100644 (file)
index 0000000..ec62300
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Getchartitem extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getdef.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getdef.java
new file mode 100644 (file)
index 0000000..fd3b127
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Getdef extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getdocument.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getdocument.java
new file mode 100644 (file)
index 0000000..75a20fd
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Getdocument extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getformula.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getformula.java
new file mode 100644 (file)
index 0000000..e9155f1
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Getformula extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getlinkinfo.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getlinkinfo.java
new file mode 100644 (file)
index 0000000..11882aa
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Getlinkinfo extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getmovie.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getmovie.java
new file mode 100644 (file)
index 0000000..68d7578
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Getmovie extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getname.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getname.java
new file mode 100644 (file)
index 0000000..44ae930
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Getname extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getnote.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getnote.java
new file mode 100644 (file)
index 0000000..b3f12ea
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Getnote extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getobject.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getobject.java
new file mode 100644 (file)
index 0000000..0f00dad
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Getobject extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getpivotdata.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getpivotdata.java
new file mode 100644 (file)
index 0000000..23203af
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Getpivotdata extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getpivotfield.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getpivotfield.java
new file mode 100644 (file)
index 0000000..11da0d1
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Getpivotfield extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getpivotitem.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getpivotitem.java
new file mode 100644 (file)
index 0000000..833da49
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Getpivotitem extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getpivottable.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getpivottable.java
new file mode 100644 (file)
index 0000000..6cd548e
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Getpivottable extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Gettool.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Gettool.java
new file mode 100644 (file)
index 0000000..de963b9
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Gettool extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Gettoolbar.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Gettoolbar.java
new file mode 100644 (file)
index 0000000..0163dc4
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Gettoolbar extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getwindow.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getwindow.java
new file mode 100644 (file)
index 0000000..3ff4c1d
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Getwindow extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getworkbook.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getworkbook.java
new file mode 100644 (file)
index 0000000..b307f88
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Getworkbook extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getworkspace.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Getworkspace.java
new file mode 100644 (file)
index 0000000..73579c3
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Getworkspace extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Goto.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Goto.java
new file mode 100644 (file)
index 0000000..f39ff3e
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Goto extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Group.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Group.java
new file mode 100644 (file)
index 0000000..f52130a
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Group extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Growth.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Growth.java
new file mode 100644 (file)
index 0000000..a4426b9
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Growth extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Halt.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Halt.java
new file mode 100644 (file)
index 0000000..ab2e0a4
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Halt extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Harmean.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Harmean.java
new file mode 100644 (file)
index 0000000..a5353aa
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Harmean extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Help.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Help.java
new file mode 100644 (file)
index 0000000..ae95c54
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Help extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Hlookup.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Hlookup.java
new file mode 100644 (file)
index 0000000..31e14e0
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Hlookup extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Hour.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Hour.java
new file mode 100644 (file)
index 0000000..1bd3754
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Hour extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Hyperlink.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Hyperlink.java
new file mode 100644 (file)
index 0000000..ff9f6b0
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Hyperlink extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Hypgeomdist.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Hypgeomdist.java
new file mode 100644 (file)
index 0000000..f5fb433
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Hypgeomdist extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Index.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Index.java
new file mode 100644 (file)
index 0000000..9de10bd
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Index extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Indirect.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Indirect.java
new file mode 100644 (file)
index 0000000..98766ae
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Indirect extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Info.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Info.java
new file mode 100644 (file)
index 0000000..7fde490
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Info extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Initiate.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Initiate.java
new file mode 100644 (file)
index 0000000..a652ffb
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Initiate extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Input.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Input.java
new file mode 100644 (file)
index 0000000..aa089ab
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Input extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Int.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Int.java
new file mode 100644 (file)
index 0000000..fb60fc0
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Created on May 6, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.BlankEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEvalToNumericXlator;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class Int extends NumericFunction {
+    
+    private static final ValueEvalToNumericXlator NUM_XLATOR = 
+        new ValueEvalToNumericXlator((short)
+                ( ValueEvalToNumericXlator.BOOL_IS_PARSED 
+                | ValueEvalToNumericXlator.EVALUATED_REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.EVALUATED_REF_STRING_IS_PARSED
+                | ValueEvalToNumericXlator.REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.STRING_IS_PARSED
+                ));
+
+    protected ValueEvalToNumericXlator getXlator() {
+        return NUM_XLATOR;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        double d = 0;
+        ValueEval retval = null;
+        
+        switch (operands.length) {
+        default:
+            break;
+        case 1:
+            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
+            if (ve instanceof NumericValueEval) {
+                NumericValueEval ne = (NumericValueEval) ve;
+                d = ne.getNumberValue();
+            }
+            else if (ve instanceof BlankEval) {
+                // do nothing
+            }
+            else {
+                retval = ErrorEval.NUM_ERROR;
+            }
+        }
+        
+        if (retval == null) {
+            if (d < 0) {
+                d = Math.round(d-0.5);
+            }
+            retval = (Double.isNaN(d)) ? (ValueEval) ErrorEval.VALUE_INVALID : new NumberEval((long) d);
+        }
+        return retval;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Intercept.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Intercept.java
new file mode 100644 (file)
index 0000000..ca3eaed
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Intercept extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Ipmt.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Ipmt.java
new file mode 100644 (file)
index 0000000..b18605c
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Ipmt extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Irr.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Irr.java
new file mode 100644 (file)
index 0000000..8fba79a
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Irr extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/IsError.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/IsError.java
new file mode 100644 (file)
index 0000000..e3d24e0
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class IsError extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/IsNa.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/IsNa.java
new file mode 100644 (file)
index 0000000..91185e6
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class IsNa extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Isblank.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Isblank.java
new file mode 100644 (file)
index 0000000..7d47905
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Isblank extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Iserr.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Iserr.java
new file mode 100644 (file)
index 0000000..30777ec
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Iserr extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Islogical.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Islogical.java
new file mode 100644 (file)
index 0000000..2e0f53f
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Islogical extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Isnontext.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Isnontext.java
new file mode 100644 (file)
index 0000000..718b9c1
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Isnontext extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Isnumber.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Isnumber.java
new file mode 100644 (file)
index 0000000..a9bd8b0
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Isnumber extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Ispmt.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Ispmt.java
new file mode 100644 (file)
index 0000000..f47cd73
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Ispmt extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Isref.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Isref.java
new file mode 100644 (file)
index 0000000..8ca8a86
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Isref extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Istext.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Istext.java
new file mode 100644 (file)
index 0000000..f847139
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Istext extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Kurt.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Kurt.java
new file mode 100644 (file)
index 0000000..0f1771d
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Kurt extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Large.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Large.java
new file mode 100644 (file)
index 0000000..79c9e3c
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Large extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Lasterror.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Lasterror.java
new file mode 100644 (file)
index 0000000..6409fea
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Lasterror extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Left.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Left.java
new file mode 100644 (file)
index 0000000..6495d1c
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Left extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Leftb.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Leftb.java
new file mode 100644 (file)
index 0000000..c85327c
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Leftb extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Len.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Len.java
new file mode 100644 (file)
index 0000000..a9ac398
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Len extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Lenb.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Lenb.java
new file mode 100644 (file)
index 0000000..643889e
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Lenb extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Linest.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Linest.java
new file mode 100644 (file)
index 0000000..4344774
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Linest extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Links.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Links.java
new file mode 100644 (file)
index 0000000..14088fa
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Links extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Ln.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Ln.java
new file mode 100644 (file)
index 0000000..5e80259
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Created on May 6, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.BlankEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEvalToNumericXlator;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class Ln extends NumericFunction {
+    
+    private static final ValueEvalToNumericXlator NUM_XLATOR = 
+        new ValueEvalToNumericXlator((short)
+                ( ValueEvalToNumericXlator.BOOL_IS_PARSED 
+                | ValueEvalToNumericXlator.EVALUATED_REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.EVALUATED_REF_STRING_IS_PARSED
+                | ValueEvalToNumericXlator.REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.STRING_IS_PARSED
+                ));
+
+    protected ValueEvalToNumericXlator getXlator() {
+        return NUM_XLATOR;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        double d = 0;
+        ValueEval retval = null;
+        
+        switch (operands.length) {
+        default:
+            break;
+        case 1:
+            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
+            if (ve instanceof NumericValueEval) {
+                NumericValueEval ne = (NumericValueEval) ve;
+                d = ne.getNumberValue();
+            }
+            else if (ve instanceof BlankEval) {
+                // do nothing
+            }
+            else {
+                retval = ErrorEval.NUM_ERROR;
+            }
+        }
+        
+        if (retval == null) {
+            d = Math.log(d);
+            retval = (Double.isNaN(d) || Double.isInfinite(d)) ? (ValueEval) ErrorEval.VALUE_INVALID : new NumberEval(d);
+        }
+        return retval;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Log.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Log.java
new file mode 100644 (file)
index 0000000..044557b
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Created on May 6, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.BlankEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEvalToNumericXlator;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ * Log: LOG(number,[base])
+ */
+public class Log extends NumericFunction {
+    
+    private static final ValueEvalToNumericXlator NUM_XLATOR = 
+        new ValueEvalToNumericXlator((short)
+                ( ValueEvalToNumericXlator.BOOL_IS_PARSED 
+                | ValueEvalToNumericXlator.EVALUATED_REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.EVALUATED_REF_STRING_IS_PARSED
+                | ValueEvalToNumericXlator.REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.STRING_IS_PARSED
+                ));
+    
+    private static final double DEFAULT_BASE = 10;
+
+    protected ValueEvalToNumericXlator getXlator() {
+        return NUM_XLATOR;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        double d = 0;
+        double base = DEFAULT_BASE;
+        double num = 0;
+        ValueEval retval = null;
+        
+        switch (operands.length) {
+        default:
+            break;
+        case 2: // second arg is base 
+            ValueEval ve = singleOperandEvaluate(operands[1], srcRow, srcCol);
+            if (ve instanceof NumericValueEval) {
+                NumericValueEval ne = (NumericValueEval) ve;
+                base = ne.getNumberValue();
+            }
+            else if (ve instanceof BlankEval) {
+                // do nothing
+            }
+            else {
+                retval = ErrorEval.NUM_ERROR;
+            }
+            
+        case 1: // first arg is number
+            if (retval == null) {
+                ValueEval vev = singleOperandEvaluate(operands[0], srcRow, srcCol);
+                if (vev instanceof NumericValueEval) {
+                    NumericValueEval ne = (NumericValueEval) vev;
+                    num = ne.getNumberValue();
+                }
+                else if (vev instanceof BlankEval) {
+                    // do nothing
+                }
+                else {
+                    retval = ErrorEval.NUM_ERROR;
+                }
+            }
+        }
+        
+        if (retval == null) {
+            d = (base == E) 
+                ? Math.log(num)
+                : Math.log(num) / Math.log(base);
+            retval = (Double.isNaN(d) || Double.isInfinite(d)) ? (ValueEval) ErrorEval.VALUE_INVALID : new NumberEval(d);
+        }
+        return retval;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Log10.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Log10.java
new file mode 100644 (file)
index 0000000..ee8261c
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Created on May 6, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.BlankEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEvalToNumericXlator;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class Log10 extends NumericFunction {
+    private static final double LOG_10_TO_BASE_e = Math.log(10);
+
+    
+    private static final ValueEvalToNumericXlator NUM_XLATOR = 
+        new ValueEvalToNumericXlator((short)
+                ( ValueEvalToNumericXlator.BOOL_IS_PARSED 
+                | ValueEvalToNumericXlator.EVALUATED_REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.EVALUATED_REF_STRING_IS_PARSED
+                | ValueEvalToNumericXlator.REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.STRING_IS_PARSED
+                ));
+
+    protected ValueEvalToNumericXlator getXlator() {
+        return NUM_XLATOR;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        double d = 0;
+        ValueEval retval = null;
+        
+        switch (operands.length) {
+        default:
+            break;
+        case 1:
+            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
+            if (ve instanceof NumericValueEval) {
+                NumericValueEval ne = (NumericValueEval) ve;
+                d = ne.getNumberValue();
+            }
+            else if (ve instanceof BlankEval) {
+                // do nothing
+            }
+            else {
+                retval = ErrorEval.NUM_ERROR;
+            }
+        }
+        
+        if (retval == null) {
+            d = Math.log(d) / LOG_10_TO_BASE_e;
+            retval = (Double.isNaN(d) || Double.isInfinite(d)) ? (ValueEval) ErrorEval.VALUE_INVALID : new NumberEval(d);
+        }
+        return retval;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Logest.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Logest.java
new file mode 100644 (file)
index 0000000..ea60625
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Logest extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Loginv.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Loginv.java
new file mode 100644 (file)
index 0000000..0266452
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Loginv extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Lognormdist.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Lognormdist.java
new file mode 100644 (file)
index 0000000..ff2fc8c
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Lognormdist extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Lookup.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Lookup.java
new file mode 100644 (file)
index 0000000..fbb0bce
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Lookup extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Lower.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Lower.java
new file mode 100644 (file)
index 0000000..e5b6f9d
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Lower extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Match.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Match.java
new file mode 100644 (file)
index 0000000..a3a6f1f
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Match extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Max.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Max.java
new file mode 100644 (file)
index 0000000..521bc15
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Max extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Maxa.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Maxa.java
new file mode 100644 (file)
index 0000000..b9605ac
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Maxa extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Mdeterm.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Mdeterm.java
new file mode 100644 (file)
index 0000000..005a50f
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Mdeterm extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Median.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Median.java
new file mode 100644 (file)
index 0000000..917819c
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Median extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Mid.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Mid.java
new file mode 100644 (file)
index 0000000..71b7fcb
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Mid extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Midb.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Midb.java
new file mode 100644 (file)
index 0000000..e538b7c
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Midb extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Min.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Min.java
new file mode 100644 (file)
index 0000000..ee3355f
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Min extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Mina.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Mina.java
new file mode 100644 (file)
index 0000000..e75ab4d
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Mina extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Minute.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Minute.java
new file mode 100644 (file)
index 0000000..10e2a48
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Minute extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Minverse.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Minverse.java
new file mode 100644 (file)
index 0000000..234c567
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Minverse extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Mirr.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Mirr.java
new file mode 100644 (file)
index 0000000..47655bb
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Mirr extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Mmult.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Mmult.java
new file mode 100644 (file)
index 0000000..095baac
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Mmult extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Mod.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Mod.java
new file mode 100644 (file)
index 0000000..696dabb
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Mod extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Mode.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Mode.java
new file mode 100644 (file)
index 0000000..c2e3b38
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Mode extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Month.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Month.java
new file mode 100644 (file)
index 0000000..1cfda63
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Month extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Moviecommand.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Moviecommand.java
new file mode 100644 (file)
index 0000000..d1c7db3
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Moviecommand extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/N.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/N.java
new file mode 100644 (file)
index 0000000..ccc3b6a
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class N extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Na.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Na.java
new file mode 100644 (file)
index 0000000..e5a41eb
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Na extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Names.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Names.java
new file mode 100644 (file)
index 0000000..1592d04
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Names extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Negbinomdist.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Negbinomdist.java
new file mode 100644 (file)
index 0000000..bfd08a6
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Negbinomdist extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Normdist.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Normdist.java
new file mode 100644 (file)
index 0000000..ceac722
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Normdist extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Norminv.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Norminv.java
new file mode 100644 (file)
index 0000000..e0b5704
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Norminv extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Normsdist.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Normsdist.java
new file mode 100644 (file)
index 0000000..ad47b47
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Normsdist extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Normsinv.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Normsinv.java
new file mode 100644 (file)
index 0000000..96fa37a
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Normsinv extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Not.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Not.java
new file mode 100644 (file)
index 0000000..65893f5
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * Created on May 9, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+
+/**
+ * @author
+ *  
+ */
+public class Not extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Note.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Note.java
new file mode 100644 (file)
index 0000000..31f0ec7
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Note extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Now.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Now.java
new file mode 100644 (file)
index 0000000..427656a
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Now extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Nper.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Nper.java
new file mode 100644 (file)
index 0000000..709e493
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Nper extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Npv.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Npv.java
new file mode 100644 (file)
index 0000000..7d86a30
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Npv extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Numberstring.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Numberstring.java
new file mode 100644 (file)
index 0000000..3248cef
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Numberstring extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/NumericFunction.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/NumericFunction.java
new file mode 100644 (file)
index 0000000..24c4415
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Created on May 14, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.AreaEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEvalToNumericXlator;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *
+ */
+public abstract class NumericFunction implements Function {
+    
+    protected static final double E = Math.E;
+    protected static final double PI = Math.PI;
+
+    protected abstract ValueEvalToNumericXlator getXlator();
+    
+    protected ValueEval singleOperandEvaluate(Eval eval, int srcRow, short srcCol) {
+        ValueEval retval;
+        if (eval instanceof AreaEval) {
+            AreaEval ae = (AreaEval) eval;
+            if (ae.contains(srcRow, srcCol)) { // circular ref!
+                retval = ErrorEval.CIRCULAR_REF_ERROR;
+            }
+            else if (ae.isRow()) {
+                if (ae.containsColumn(srcCol)) {
+                    ValueEval ve = ae.getValueAt(ae.getFirstRow(), srcCol);
+                    ve = getXlator().attemptXlateToNumeric(ve);
+                    retval = getXlator().attemptXlateToNumeric(ve);
+                }
+                else {
+                    retval = ErrorEval.VALUE_INVALID;
+                }
+            }
+            else if (ae.isColumn()) {
+                if (ae.containsRow(srcRow)) {
+                    ValueEval ve = ae.getValueAt(srcRow, ae.getFirstColumn());
+                    retval = getXlator().attemptXlateToNumeric(ve);
+                }
+                else {
+                    retval = ErrorEval.VALUE_INVALID;
+                }
+            }
+            else {
+                retval = ErrorEval.VALUE_INVALID;
+            }
+        }
+        else {
+            retval = getXlator().attemptXlateToNumeric((ValueEval) eval);
+        }
+        return retval;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Odd.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Odd.java
new file mode 100644 (file)
index 0000000..3e35d4c
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Created on May 6, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.BlankEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEvalToNumericXlator;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class Odd extends NumericFunction {
+    
+    private static final ValueEvalToNumericXlator NUM_XLATOR = 
+        new ValueEvalToNumericXlator((short)
+                ( ValueEvalToNumericXlator.BOOL_IS_PARSED 
+                | ValueEvalToNumericXlator.EVALUATED_REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.EVALUATED_REF_STRING_IS_PARSED
+                | ValueEvalToNumericXlator.REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.STRING_IS_PARSED
+                ));
+
+    protected ValueEvalToNumericXlator getXlator() {
+        return NUM_XLATOR;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        double d = 0;
+        ValueEval retval = null;
+        
+        switch (operands.length) {
+        default:
+            retval = ErrorEval.VALUE_INVALID;
+            break;
+        case 1:
+            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
+            if (ve instanceof NumericValueEval) {
+                NumericValueEval ne = (NumericValueEval) ve;
+                d = ne.getNumberValue();
+            }
+            else if (ve instanceof BlankEval) {
+                // do nothing
+            }
+            else {
+                retval = ErrorEval.NUM_ERROR;
+            }
+        }
+        
+        if (retval == null) {
+            if (!Double.isNaN(d) && !Double.isInfinite(d)) {
+                d = (d==0) 
+                    ? 1 
+                    : ((((long) d) - 1) % 2 == 0)
+                        ? d
+                        : (d < 0) 
+                            ? ((((long) (d/2))<<1)-1) 
+                            : ((((long) (d/2))<<1)+1);
+            }
+            retval = (Double.isNaN(d) || Double.isInfinite(d)) ? (ValueEval) ErrorEval.VALUE_INVALID : new NumberEval(d);
+        }
+        return retval;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Offset.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Offset.java
new file mode 100644 (file)
index 0000000..ca84761
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Offset extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Opendialog.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Opendialog.java
new file mode 100644 (file)
index 0000000..aec9b1a
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Opendialog extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Optionslistsget.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Optionslistsget.java
new file mode 100644 (file)
index 0000000..cbc5766
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Optionslistsget extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Or.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Or.java
new file mode 100644 (file)
index 0000000..731ed9b
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Created on May 9, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+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;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+
+/**
+ * @author
+ *  
+ */
+public class Or extends BooleanFunction {
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        ValueEval retval = null;
+        boolean b = false;
+        boolean atleastOneNonBlank = false;
+        
+        /*
+         * Note: do not abort the loop if b is true, since we could be
+         * dealing with errorevals later. 
+         */
+        outer:
+        for (int i=0, iSize=operands.length; i<iSize; i++) {
+            if (operands[i] instanceof AreaEval) {
+                AreaEval ae = (AreaEval) operands[i];
+                ValueEval[] values = ae.getValues();
+                for (int j=0, jSize=values.length; j<jSize; j++) {
+                    ValueEval tempVe = tempVe = singleOperandEvaluate(values[j], srcRow, srcCol, true);
+                    if (tempVe instanceof BoolEval) {
+                        b = b || ((BoolEval) tempVe).getBooleanValue();
+                        atleastOneNonBlank = true;
+                    }
+                    else if (tempVe instanceof ErrorEval) {
+                        retval = tempVe;
+                        break outer;
+                    }
+                }
+            }
+            else {
+                ValueEval tempVe = singleOperandEvaluate(operands[i], srcRow, srcCol, false);
+                if (tempVe instanceof BoolEval) {
+                    b = b || ((BoolEval) tempVe).getBooleanValue();
+                    atleastOneNonBlank = true;
+                }
+                else if (tempVe instanceof ErrorEval) {
+                    retval = tempVe;
+                    break outer;
+                }
+            }
+        }
+        
+        if (!atleastOneNonBlank) {
+            retval = ErrorEval.VALUE_INVALID;
+        }
+        
+        if (retval == null) { // if no error
+            retval = b ? BoolEval.TRUE : BoolEval.FALSE;
+        }
+        
+        return retval;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Pause.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Pause.java
new file mode 100644 (file)
index 0000000..e8bb9c8
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Pause extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Pearson.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Pearson.java
new file mode 100644 (file)
index 0000000..15fa554
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Pearson extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Percentile.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Percentile.java
new file mode 100644 (file)
index 0000000..742cf83
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Percentile extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Percentrank.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Percentrank.java
new file mode 100644 (file)
index 0000000..c2ed8c3
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Percentrank extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Permut.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Permut.java
new file mode 100644 (file)
index 0000000..a941354
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Permut extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Phonetic.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Phonetic.java
new file mode 100644 (file)
index 0000000..f4898d2
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Phonetic extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Pi.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Pi.java
new file mode 100644 (file)
index 0000000..bd440ce
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Created on May 6, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class Pi implements Function {
+
+    private static final NumberEval PI_EVAL = new NumberEval(Math.PI);
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        ValueEval retval;
+        switch (operands.length) {
+        default:
+            retval = ErrorEval.VALUE_INVALID;
+            break;
+        case 0:
+            retval = PI_EVAL;
+        }
+        return retval;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Pivotadddata.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Pivotadddata.java
new file mode 100644 (file)
index 0000000..b3ab95e
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Pivotadddata extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Pmt.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Pmt.java
new file mode 100644 (file)
index 0000000..bde301a
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Pmt extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Poisson.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Poisson.java
new file mode 100644 (file)
index 0000000..83afe96
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Poisson extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Poke.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Poke.java
new file mode 100644 (file)
index 0000000..e549f04
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Poke extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Power.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Power.java
new file mode 100644 (file)
index 0000000..6721fc3
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Created on May 6, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.BlankEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEvalToNumericXlator;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class Power extends NumericFunction {
+    
+    private static final ValueEvalToNumericXlator NUM_XLATOR = 
+        new ValueEvalToNumericXlator((short)
+                ( ValueEvalToNumericXlator.BOOL_IS_PARSED 
+                | ValueEvalToNumericXlator.EVALUATED_REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.EVALUATED_REF_STRING_IS_PARSED
+                | ValueEvalToNumericXlator.REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.STRING_IS_PARSED
+                ));
+
+    protected ValueEvalToNumericXlator getXlator() {
+        return NUM_XLATOR;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        double d0 = 0;
+        double d1 = 0;
+        ValueEval retval = null;
+        
+        switch (operands.length) {
+        default:
+            retval = ErrorEval.VALUE_INVALID;
+            break;
+        case 2:
+            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
+            if (ve instanceof NumericValueEval) {
+                NumericValueEval ne = (NumericValueEval) ve;
+                d0 = ne.getNumberValue();
+            }
+            else if (ve instanceof BlankEval) {
+                // do nothing
+            }
+            else {
+                retval = ErrorEval.NUM_ERROR;
+            }
+            
+            if (retval == null) {
+                ValueEval vev = singleOperandEvaluate(operands[1], srcRow, srcCol);
+                if (vev instanceof NumericValueEval) {
+                    NumericValueEval ne = (NumericValueEval) vev;
+                    d1 = ne.getNumberValue();
+                }
+                else if (vev instanceof BlankEval) {
+                    // do nothing
+                }
+                else {
+                    retval = ErrorEval.NUM_ERROR;
+                }
+            }
+        }
+        
+        if (retval == null) {
+            double d = Math.pow(d0, d1);
+            retval = (Double.isNaN(d) || Double.isNaN(d)) ? (ValueEval) ErrorEval.VALUE_INVALID : new NumberEval(d);
+        }
+        return retval;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Ppmt.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Ppmt.java
new file mode 100644 (file)
index 0000000..d23716a
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Ppmt extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Presstool.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Presstool.java
new file mode 100644 (file)
index 0000000..5e8b313
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Presstool extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Prob.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Prob.java
new file mode 100644 (file)
index 0000000..b6eb593
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Prob extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Product.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Product.java
new file mode 100644 (file)
index 0000000..f6d6426
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Product extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Proper.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Proper.java
new file mode 100644 (file)
index 0000000..6315ea7
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Proper extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Pv.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Pv.java
new file mode 100644 (file)
index 0000000..8ce1e18
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Pv extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Quartile.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Quartile.java
new file mode 100644 (file)
index 0000000..d43254f
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Quartile extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Radians.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Radians.java
new file mode 100644 (file)
index 0000000..3df708b
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Created on May 6, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.BlankEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEvalToNumericXlator;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class Radians extends NumericFunction {
+    
+    private static final ValueEvalToNumericXlator NUM_XLATOR = 
+        new ValueEvalToNumericXlator((short)
+                ( ValueEvalToNumericXlator.BOOL_IS_PARSED 
+                | ValueEvalToNumericXlator.EVALUATED_REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.EVALUATED_REF_STRING_IS_PARSED
+                | ValueEvalToNumericXlator.REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.STRING_IS_PARSED
+                ));
+
+    protected ValueEvalToNumericXlator getXlator() {
+        return NUM_XLATOR;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        double d = 0;
+        ValueEval retval = null;
+        
+        switch (operands.length) {
+        default:
+            retval = ErrorEval.VALUE_INVALID;
+            break;
+        case 1:
+            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
+            if (ve instanceof NumericValueEval) {
+                NumericValueEval ne = (NumericValueEval) ve;
+                d = ne.getNumberValue();
+            }
+            else if (ve instanceof BlankEval) {
+                // do nothing
+            }
+            else {
+                retval = ErrorEval.NUM_ERROR;
+            }
+        }
+        
+        if (retval == null) {
+            d = Math.toRadians(d);
+            retval = (Double.isNaN(d) || Double.isInfinite(d)) ? (ValueEval) ErrorEval.VALUE_INVALID : new NumberEval(d);
+        }
+        return retval;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Rand.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Rand.java
new file mode 100644 (file)
index 0000000..15b1ff9
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Created on May 6, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class Rand implements Function {
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        ValueEval retval;
+        switch (operands.length) {
+        default:
+            retval = ErrorEval.VALUE_INVALID;
+            break;
+        case 0:
+            retval = new NumberEval(Math.random());
+        }
+        return retval;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Rank.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Rank.java
new file mode 100644 (file)
index 0000000..ed3c718
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Rank extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Rate.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Rate.java
new file mode 100644 (file)
index 0000000..99494db
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Rate extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Reftext.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Reftext.java
new file mode 100644 (file)
index 0000000..ce4c93d
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Reftext extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Register.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Register.java
new file mode 100644 (file)
index 0000000..6fed619
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Register extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Registerid.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Registerid.java
new file mode 100644 (file)
index 0000000..d5571fa
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Registerid extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Relref.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Relref.java
new file mode 100644 (file)
index 0000000..18dcd34
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Relref extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Renamecommand.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Renamecommand.java
new file mode 100644 (file)
index 0000000..e4685d8
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Renamecommand extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Replace.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Replace.java
new file mode 100644 (file)
index 0000000..d9faf78
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Replace extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Replaceb.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Replaceb.java
new file mode 100644 (file)
index 0000000..7a512d1
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Replaceb extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Rept.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Rept.java
new file mode 100644 (file)
index 0000000..f6b7299
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Rept extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Request.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Request.java
new file mode 100644 (file)
index 0000000..cd359b6
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Request extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Resettoolbar.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Resettoolbar.java
new file mode 100644 (file)
index 0000000..e022ecf
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Resettoolbar extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Restart.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Restart.java
new file mode 100644 (file)
index 0000000..f24c9f8
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Restart extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Result.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Result.java
new file mode 100644 (file)
index 0000000..185aa09
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Result extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Resume.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Resume.java
new file mode 100644 (file)
index 0000000..8a6d18d
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Resume extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Right.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Right.java
new file mode 100644 (file)
index 0000000..01b1781
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Right extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Rightb.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Rightb.java
new file mode 100644 (file)
index 0000000..f48af80
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Rightb extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Roman.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Roman.java
new file mode 100644 (file)
index 0000000..314c2a0
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Roman extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Round.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Round.java
new file mode 100644 (file)
index 0000000..93031f3
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Round extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Rounddown.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Rounddown.java
new file mode 100644 (file)
index 0000000..0b789d1
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Rounddown extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Roundup.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Roundup.java
new file mode 100644 (file)
index 0000000..b374be7
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Roundup extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Row.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Row.java
new file mode 100644 (file)
index 0000000..1f0496f
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Row extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Rows.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Rows.java
new file mode 100644 (file)
index 0000000..729ad0e
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Rows extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Rsq.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Rsq.java
new file mode 100644 (file)
index 0000000..0bb6680
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Rsq extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Savedialog.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Savedialog.java
new file mode 100644 (file)
index 0000000..9986bce
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Savedialog extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Savetoolbar.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Savetoolbar.java
new file mode 100644 (file)
index 0000000..1bcc74b
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Savetoolbar extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Scenarioget.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Scenarioget.java
new file mode 100644 (file)
index 0000000..ec49f9a
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Scenarioget extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Search.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Search.java
new file mode 100644 (file)
index 0000000..7518984
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Search extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Searchb.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Searchb.java
new file mode 100644 (file)
index 0000000..c0f7d6f
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Searchb extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Second.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Second.java
new file mode 100644 (file)
index 0000000..1f4df6d
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Second extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Selection.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Selection.java
new file mode 100644 (file)
index 0000000..d399ff4
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Selection extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Series.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Series.java
new file mode 100644 (file)
index 0000000..b1387d4
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Series extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Setname.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Setname.java
new file mode 100644 (file)
index 0000000..7129e27
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Setname extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Setvalue.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Setvalue.java
new file mode 100644 (file)
index 0000000..a28215d
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Setvalue extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Showbar.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Showbar.java
new file mode 100644 (file)
index 0000000..7655a7c
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Showbar extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sign.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sign.java
new file mode 100644 (file)
index 0000000..3894bee
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.BlankEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEvalToNumericXlator;
+
+/**
+ * @author 
+ *
+ */
+public class Sign extends NumericFunction {
+    
+    private static final ValueEvalToNumericXlator NUM_XLATOR = 
+        new ValueEvalToNumericXlator((short)
+                ( ValueEvalToNumericXlator.BOOL_IS_PARSED 
+                | ValueEvalToNumericXlator.EVALUATED_REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.EVALUATED_REF_STRING_IS_PARSED
+                | ValueEvalToNumericXlator.REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.STRING_IS_PARSED
+                ));
+
+    protected ValueEvalToNumericXlator getXlator() {
+        return NUM_XLATOR;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        double d = 0;
+        ValueEval retval = null;
+        
+        switch (operands.length) {
+        default:
+            retval = ErrorEval.VALUE_INVALID;
+            break;
+        case 1:
+            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
+            if (ve instanceof NumericValueEval) {
+                NumericValueEval ne = (NumericValueEval) ve;
+                d = ne.getNumberValue();
+            }
+            else if (ve instanceof BlankEval) {
+                // do nothing
+            }
+            else {
+                retval = ErrorEval.NUM_ERROR;
+            }
+        }
+        
+        if (retval == null) {
+            retval = (Double.isNaN(d) || Double.isInfinite(d)) 
+                    ? (ValueEval) ErrorEval.VALUE_INVALID 
+                    : (d == 0) 
+                        ? new NumberEval(0)
+                        : (d < 0)
+                            ? new NumberEval(-1)
+                            : new NumberEval(1);
+        }
+        return retval;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sin.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sin.java
new file mode 100644 (file)
index 0000000..8d36bcb
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Created on May 6, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.BlankEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEvalToNumericXlator;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class Sin extends NumericFunction {
+    
+    private static final ValueEvalToNumericXlator NUM_XLATOR = 
+        new ValueEvalToNumericXlator((short)
+                ( ValueEvalToNumericXlator.BOOL_IS_PARSED 
+                | ValueEvalToNumericXlator.EVALUATED_REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.EVALUATED_REF_STRING_IS_PARSED
+                | ValueEvalToNumericXlator.REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.STRING_IS_PARSED
+                ));
+
+    protected ValueEvalToNumericXlator getXlator() {
+        return NUM_XLATOR;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        double d = 0;
+        ValueEval retval = null;
+        
+        switch (operands.length) {
+        default:
+            break;
+        case 1:
+            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
+            if (ve instanceof NumericValueEval) {
+                NumericValueEval ne = (NumericValueEval) ve;
+                d = ne.getNumberValue();
+            }
+            else if (ve instanceof BlankEval) {
+                // do nothing
+            }
+            else {
+                retval = ErrorEval.NUM_ERROR;
+            }
+        }
+        
+        if (retval == null) {
+            d = Math.sin(d);
+            retval = (Double.isNaN(d)) ? (ValueEval) ErrorEval.VALUE_INVALID : new NumberEval(d);
+        }
+        return retval;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sinh.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sinh.java
new file mode 100644 (file)
index 0000000..5624bf2
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Created on May 6, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.BlankEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEvalToNumericXlator;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class Sinh extends NumericFunction {
+    
+    private static final ValueEvalToNumericXlator NUM_XLATOR = 
+        new ValueEvalToNumericXlator((short)
+                ( ValueEvalToNumericXlator.BOOL_IS_PARSED 
+                | ValueEvalToNumericXlator.EVALUATED_REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.EVALUATED_REF_STRING_IS_PARSED
+                | ValueEvalToNumericXlator.REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.STRING_IS_PARSED
+                ));
+
+    protected ValueEvalToNumericXlator getXlator() {
+        return NUM_XLATOR;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        double d = 0;
+        ValueEval retval = null;
+        
+        switch (operands.length) {
+        default:
+            break;
+        case 1:
+            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
+            if (ve instanceof NumericValueEval) {
+                NumericValueEval ne = (NumericValueEval) ve;
+                d = ne.getNumberValue();
+            }
+            else if (ve instanceof BlankEval) {
+                // do nothing
+            }
+            else {
+                retval = ErrorEval.NUM_ERROR;
+            }
+        }
+        
+        if (retval == null) {
+            double ePowX = Math.pow(E, d);
+            double ePowNegX = Math.pow(E, -d);
+            d = (ePowX - ePowNegX) / 2;
+            retval = (Double.isNaN(d) || Double.isInfinite(d)) ? (ValueEval) ErrorEval.VALUE_INVALID : new NumberEval(d);
+        }
+        return retval;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Skew.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Skew.java
new file mode 100644 (file)
index 0000000..6ebe1a1
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Skew extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sln.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sln.java
new file mode 100644 (file)
index 0000000..d01ad54
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Sln extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Slope.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Slope.java
new file mode 100644 (file)
index 0000000..7a57799
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Slope extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Small.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Small.java
new file mode 100644 (file)
index 0000000..667ab11
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Small extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Spellingcheck.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Spellingcheck.java
new file mode 100644 (file)
index 0000000..fd02055
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Spellingcheck extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sqrt.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sqrt.java
new file mode 100644 (file)
index 0000000..fd6b76b
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Created on May 6, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.BlankEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEvalToNumericXlator;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class Sqrt extends NumericFunction {
+    
+    private static final ValueEvalToNumericXlator NUM_XLATOR = 
+        new ValueEvalToNumericXlator((short)
+                ( ValueEvalToNumericXlator.BOOL_IS_PARSED 
+                | ValueEvalToNumericXlator.EVALUATED_REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.EVALUATED_REF_STRING_IS_PARSED
+                | ValueEvalToNumericXlator.REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.STRING_IS_PARSED
+                ));
+
+    protected ValueEvalToNumericXlator getXlator() {
+        return NUM_XLATOR;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        double d = 0;
+        ValueEval retval = null;
+        
+        switch (operands.length) {
+        default:
+            break;
+        case 1:
+            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
+            if (ve instanceof NumericValueEval) {
+                NumericValueEval ne = (NumericValueEval) ve;
+                d = ne.getNumberValue();
+            }
+            else if (ve instanceof BlankEval) {
+                // do nothing
+            }
+            else {
+                retval = ErrorEval.NUM_ERROR;
+            }
+        }
+        
+        if (retval == null) {
+            d = Math.sqrt(d);
+            retval = (Double.isNaN(d)) ? (ValueEval) ErrorEval.VALUE_INVALID : new NumberEval(d);
+        }
+        return retval;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Standardize.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Standardize.java
new file mode 100644 (file)
index 0000000..e8e5537
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Standardize extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Stdev.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Stdev.java
new file mode 100644 (file)
index 0000000..27559bc
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Stdev extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Stdeva.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Stdeva.java
new file mode 100644 (file)
index 0000000..e037fc3
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Stdeva extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Stdevp.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Stdevp.java
new file mode 100644 (file)
index 0000000..771d05b
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Stdevp extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Stdevpa.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Stdevpa.java
new file mode 100644 (file)
index 0000000..7bc982d
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Stdevpa extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Step.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Step.java
new file mode 100644 (file)
index 0000000..e918102
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Step extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Steyx.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Steyx.java
new file mode 100644 (file)
index 0000000..ea148cb
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Steyx extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Substitute.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Substitute.java
new file mode 100644 (file)
index 0000000..368f006
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Substitute extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Subtotal.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Subtotal.java
new file mode 100644 (file)
index 0000000..0bf80dd
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Subtotal extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sum.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sum.java
new file mode 100644 (file)
index 0000000..7b09653
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Sum extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sumif.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sumif.java
new file mode 100644 (file)
index 0000000..59117a7
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Sumif extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sumproduct.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sumproduct.java
new file mode 100644 (file)
index 0000000..8ef361d
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Sumproduct extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sumsq.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sumsq.java
new file mode 100644 (file)
index 0000000..2f13693
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Sumsq extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sumx2my2.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sumx2my2.java
new file mode 100644 (file)
index 0000000..4a0267e
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Sumx2my2 extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sumx2py2.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sumx2py2.java
new file mode 100644 (file)
index 0000000..5535612
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Sumx2py2 extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sumxmy2.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Sumxmy2.java
new file mode 100644 (file)
index 0000000..60aed2e
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Sumxmy2 extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Syd.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Syd.java
new file mode 100644 (file)
index 0000000..21f611e
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Syd extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/T.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/T.java
new file mode 100644 (file)
index 0000000..117e8a1
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class T extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Tan.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Tan.java
new file mode 100644 (file)
index 0000000..972148a
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Created on May 6, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.BlankEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEvalToNumericXlator;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class Tan extends NumericFunction {
+    
+    private static final ValueEvalToNumericXlator NUM_XLATOR = 
+        new ValueEvalToNumericXlator((short)
+                ( ValueEvalToNumericXlator.BOOL_IS_PARSED 
+                | ValueEvalToNumericXlator.EVALUATED_REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.EVALUATED_REF_STRING_IS_PARSED
+                | ValueEvalToNumericXlator.REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.STRING_IS_PARSED
+                ));
+
+    protected ValueEvalToNumericXlator getXlator() {
+        return NUM_XLATOR;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        double d = 0;
+        ValueEval retval = null;
+        
+        switch (operands.length) {
+        default:
+            break;
+        case 1:
+            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
+            if (ve instanceof NumericValueEval) {
+                NumericValueEval ne = (NumericValueEval) ve;
+                d = ne.getNumberValue();
+            }
+            else if (ve instanceof BlankEval) {
+                // do nothing
+            }
+            else {
+                retval = ErrorEval.NUM_ERROR;
+            }
+        }
+        
+        if (retval == null) {
+            d = Math.tan(d);
+            retval = (Double.isNaN(d)) ? (ValueEval) ErrorEval.VALUE_INVALID : new NumberEval(d);
+        }
+        return retval;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Tanh.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Tanh.java
new file mode 100644 (file)
index 0000000..1c6a1ec
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Created on May 6, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.BlankEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEvalToNumericXlator;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class Tanh extends NumericFunction {
+    
+    private static final ValueEvalToNumericXlator NUM_XLATOR = 
+        new ValueEvalToNumericXlator((short)
+                ( ValueEvalToNumericXlator.BOOL_IS_PARSED 
+                | ValueEvalToNumericXlator.EVALUATED_REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.EVALUATED_REF_STRING_IS_PARSED
+                | ValueEvalToNumericXlator.REF_BOOL_IS_PARSED
+                | ValueEvalToNumericXlator.STRING_IS_PARSED
+                ));
+
+    protected ValueEvalToNumericXlator getXlator() {
+        return NUM_XLATOR;
+    }
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        double d = 0;
+        ValueEval retval = null;
+        
+        switch (operands.length) {
+        default:
+            break;
+        case 1:
+            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
+            if (ve instanceof NumericValueEval) {
+                NumericValueEval ne = (NumericValueEval) ve;
+                d = ne.getNumberValue();
+            }
+            else if (ve instanceof BlankEval) {
+                // do nothing
+            }
+            else {
+                retval = ErrorEval.NUM_ERROR;
+            }
+        }
+        
+        if (retval == null) {
+            double ePowX = Math.pow(E, d);
+            double ePowNegX = Math.pow(E, -d);
+            d = (ePowX - ePowNegX) / (ePowX + ePowNegX);
+            retval = (Double.isNaN(d)) ? (ValueEval) ErrorEval.VALUE_INVALID : new NumberEval(d);
+        }
+        return retval;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Tdist.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Tdist.java
new file mode 100644 (file)
index 0000000..082588b
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Tdist extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Terminate.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Terminate.java
new file mode 100644 (file)
index 0000000..c0ece56
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Terminate extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Text.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Text.java
new file mode 100644 (file)
index 0000000..f306c30
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Text extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Textbox.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Textbox.java
new file mode 100644 (file)
index 0000000..f46f25d
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Textbox extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Textref.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Textref.java
new file mode 100644 (file)
index 0000000..4f3bb3d
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Textref extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Time.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Time.java
new file mode 100644 (file)
index 0000000..3165fb8
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Time extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Timevalue.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Timevalue.java
new file mode 100644 (file)
index 0000000..b723b00
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Timevalue extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Tinv.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Tinv.java
new file mode 100644 (file)
index 0000000..de23250
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Tinv extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Today.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Today.java
new file mode 100644 (file)
index 0000000..9a1da1c
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Today extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Transpose.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Transpose.java
new file mode 100644 (file)
index 0000000..bc5d2d4
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Transpose extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Trend.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Trend.java
new file mode 100644 (file)
index 0000000..14427cf
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Trend extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Trim.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Trim.java
new file mode 100644 (file)
index 0000000..fb1aa0f
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Trim extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Trimmean.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Trimmean.java
new file mode 100644 (file)
index 0000000..8060d78
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Trimmean extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/True.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/True.java
new file mode 100644 (file)
index 0000000..150d3f3
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Created on May 6, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+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;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *  
+ */
+public class True implements Function {
+
+    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+        ValueEval retval;
+        switch (operands.length) {
+        default:
+            retval = ErrorEval.VALUE_INVALID;
+            break;
+        case 0:
+            retval = BoolEval.TRUE;
+        }
+        return retval;
+    }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Trunc.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Trunc.java
new file mode 100644 (file)
index 0000000..2d01c2c
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Trunc extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Ttest.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Ttest.java
new file mode 100644 (file)
index 0000000..a9ddbac
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Ttest extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Type.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Type.java
new file mode 100644 (file)
index 0000000..3a33e30
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Type extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Unregister.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Unregister.java
new file mode 100644 (file)
index 0000000..f9d2bc4
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Unregister extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Upper.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Upper.java
new file mode 100644 (file)
index 0000000..46d1372
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Upper extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Usdollar.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Usdollar.java
new file mode 100644 (file)
index 0000000..0834681
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Usdollar extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Value.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Value.java
new file mode 100644 (file)
index 0000000..4a01843
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Value extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Var.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Var.java
new file mode 100644 (file)
index 0000000..db06376
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Var extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Vara.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Vara.java
new file mode 100644 (file)
index 0000000..e333320
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Vara extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Varp.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Varp.java
new file mode 100644 (file)
index 0000000..a6428fa
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Varp extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Varpa.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Varpa.java
new file mode 100644 (file)
index 0000000..0f4d646
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Varpa extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Vdb.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Vdb.java
new file mode 100644 (file)
index 0000000..55ff4e3
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Vdb extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Viewget.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Viewget.java
new file mode 100644 (file)
index 0000000..a3f500a
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Viewget extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Vlookup.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Vlookup.java
new file mode 100644 (file)
index 0000000..8ced4ae
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Vlookup extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Volatile.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Volatile.java
new file mode 100644 (file)
index 0000000..96fdcb7
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Volatile extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Weekday.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Weekday.java
new file mode 100644 (file)
index 0000000..6626d5f
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Weekday extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Weibull.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Weibull.java
new file mode 100644 (file)
index 0000000..36ac55b
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Weibull extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Windows.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Windows.java
new file mode 100644 (file)
index 0000000..72ad8cd
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Windows extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Windowtitle.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Windowtitle.java
new file mode 100644 (file)
index 0000000..970c5d8
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Windowtitle extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Year.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Year.java
new file mode 100644 (file)
index 0000000..9a5f0e2
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Year extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Ztest.java b/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Ztest.java
new file mode 100644 (file)
index 0000000..36480b6
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Created on May 15, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+/**
+ * @author 
+ *
+ */
+public class Ztest extends DefaultFunctionImpl {
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java b/src/scratchpad/src/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java
new file mode 100644 (file)
index 0000000..6d6aa1b
--- /dev/null
@@ -0,0 +1,699 @@
+/*
+ * Created on May 5, 2005
+ *
+ */
+package org.apache.poi.hssf.usermodel;
+
+import java.io.FileInputStream;
+import java.lang.reflect.Constructor;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+import org.apache.poi.hssf.model.FormulaParser;
+import org.apache.poi.hssf.record.formula.AddPtg;
+import org.apache.poi.hssf.record.formula.Area3DPtg;
+import org.apache.poi.hssf.record.formula.AreaPtg;
+import org.apache.poi.hssf.record.formula.AttrPtg;
+import org.apache.poi.hssf.record.formula.BoolPtg;
+import org.apache.poi.hssf.record.formula.ConcatPtg;
+import org.apache.poi.hssf.record.formula.ControlPtg;
+import org.apache.poi.hssf.record.formula.DividePtg;
+import org.apache.poi.hssf.record.formula.EqualPtg;
+import org.apache.poi.hssf.record.formula.FuncPtg;
+import org.apache.poi.hssf.record.formula.FuncVarPtg;
+import org.apache.poi.hssf.record.formula.GreaterEqualPtg;
+import org.apache.poi.hssf.record.formula.GreaterThanPtg;
+import org.apache.poi.hssf.record.formula.IntPtg;
+import org.apache.poi.hssf.record.formula.LessEqualPtg;
+import org.apache.poi.hssf.record.formula.LessThanPtg;
+import org.apache.poi.hssf.record.formula.MemErrPtg;
+import org.apache.poi.hssf.record.formula.MissingArgPtg;
+import org.apache.poi.hssf.record.formula.MultiplyPtg;
+import org.apache.poi.hssf.record.formula.NamePtg;
+import org.apache.poi.hssf.record.formula.NameXPtg;
+import org.apache.poi.hssf.record.formula.NotEqualPtg;
+import org.apache.poi.hssf.record.formula.NumberPtg;
+import org.apache.poi.hssf.record.formula.OperationPtg;
+import org.apache.poi.hssf.record.formula.ParenthesisPtg;
+import org.apache.poi.hssf.record.formula.PowerPtg;
+import org.apache.poi.hssf.record.formula.Ptg;
+import org.apache.poi.hssf.record.formula.Ref3DPtg;
+import org.apache.poi.hssf.record.formula.ReferencePtg;
+import org.apache.poi.hssf.record.formula.StringPtg;
+import org.apache.poi.hssf.record.formula.SubtractPtg;
+import org.apache.poi.hssf.record.formula.UnaryMinusPtg;
+import org.apache.poi.hssf.record.formula.UnaryPlusPtg;
+import org.apache.poi.hssf.record.formula.UnionPtg;
+import org.apache.poi.hssf.record.formula.UnknownPtg;
+import org.apache.poi.hssf.record.formula.eval.AddEval;
+import org.apache.poi.hssf.record.formula.eval.Area2DEval;
+import org.apache.poi.hssf.record.formula.eval.Area3DEval;
+import org.apache.poi.hssf.record.formula.eval.AreaEval;
+import org.apache.poi.hssf.record.formula.eval.BlankEval;
+import org.apache.poi.hssf.record.formula.eval.BoolEval;
+import org.apache.poi.hssf.record.formula.eval.ConcatEval;
+import org.apache.poi.hssf.record.formula.eval.DivideEval;
+import org.apache.poi.hssf.record.formula.eval.EqualEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.FuncVarEval;
+import org.apache.poi.hssf.record.formula.eval.GreaterEqualEval;
+import org.apache.poi.hssf.record.formula.eval.GreaterThanEval;
+import org.apache.poi.hssf.record.formula.eval.LessEqualEval;
+import org.apache.poi.hssf.record.formula.eval.LessThanEval;
+import org.apache.poi.hssf.record.formula.eval.MultiplyEval;
+import org.apache.poi.hssf.record.formula.eval.NotEqualEval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.OperationEval;
+import org.apache.poi.hssf.record.formula.eval.PowerEval;
+import org.apache.poi.hssf.record.formula.eval.Ref2DEval;
+import org.apache.poi.hssf.record.formula.eval.Ref3DEval;
+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.SubtractEval;
+import org.apache.poi.hssf.record.formula.eval.UnaryMinusEval;
+import org.apache.poi.hssf.record.formula.eval.UnaryPlusEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+import org.apache.poi.hssf.util.CellReference;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ * 
+ * Limitations: Unfortunately, cyclic references will cause stackoverflow
+ * exception
+ */
+public class HSSFFormulaEvaluator {
+
+    // params to lookup the right constructor using reflection
+    private static final Class[] OPERATION_CONSTRUCTOR_CLASS_ARRAY = new Class[] { Ptg.class };
+
+    private static final Class[] VALUE_CONTRUCTOR_CLASS_ARRAY = new Class[] { Ptg.class };
+
+    private static final Class[] AREA_CONSTRUCTOR_CLASS_ARRAY = new Class[] { Ptg.class, ValueEval[].class };
+
+    private static final Class[] AREA3D_CONSTRUCTOR_CLASS_ARRAY = new Class[] { Ptg.class, ValueEval[].class };
+
+    private static final Class[] REFERENCE_CONSTRUCTOR_CLASS_ARRAY = new Class[] { Ptg.class, ValueEval.class };
+
+    private static final Class[] REF3D_CONSTRUCTOR_CLASS_ARRAY = new Class[] { Ptg.class, ValueEval.class };
+
+    // Maps for mapping *Eval to *Ptg
+    private static final Map VALUE_EVALS_MAP = new HashMap();
+
+    private static final Map OPERATION_EVALS_MAP = new HashMap();
+
+    /*
+     * If you dont like this map, join the club :) I did this becoz it was
+     * desired to keep the FormulaEvaluator separate from FormulaParser and
+     * related classes in the CVS-HEAD. So now we need some mapping between the
+     * Ptg tokens that the FormulaParser returns and the *Eval classes taht are
+     * used by the FormulaEvaluator - hence the following :)
+     */
+    static {
+        VALUE_EVALS_MAP.put(BoolPtg.class, BoolEval.class);
+        VALUE_EVALS_MAP.put(IntPtg.class, NumberEval.class);
+        VALUE_EVALS_MAP.put(NumberPtg.class, NumberEval.class);
+        VALUE_EVALS_MAP.put(StringPtg.class, StringEval.class);
+
+        OPERATION_EVALS_MAP.put(AddPtg.class, AddEval.class);
+        OPERATION_EVALS_MAP.put(ConcatPtg.class, ConcatEval.class);
+        OPERATION_EVALS_MAP.put(DividePtg.class, DivideEval.class);
+        OPERATION_EVALS_MAP.put(EqualPtg.class, EqualEval.class);
+        //OPERATION_EVALS_MAP.put(ExpPtg.class, ExpEval.class); // TODO: check
+        // this
+        OPERATION_EVALS_MAP.put(FuncPtg.class, FuncVarEval.class); // TODO:
+                                                                   // check this
+        OPERATION_EVALS_MAP.put(FuncVarPtg.class, FuncVarEval.class);
+        OPERATION_EVALS_MAP.put(GreaterEqualPtg.class, GreaterEqualEval.class);
+        OPERATION_EVALS_MAP.put(GreaterThanPtg.class, GreaterThanEval.class);
+        OPERATION_EVALS_MAP.put(LessEqualPtg.class, LessEqualEval.class);
+        OPERATION_EVALS_MAP.put(LessThanPtg.class, LessThanEval.class);
+        OPERATION_EVALS_MAP.put(MultiplyPtg.class, MultiplyEval.class);
+        OPERATION_EVALS_MAP.put(NotEqualPtg.class, NotEqualEval.class);
+        OPERATION_EVALS_MAP.put(PowerPtg.class, PowerEval.class);
+        OPERATION_EVALS_MAP.put(SubtractPtg.class, SubtractEval.class);
+        OPERATION_EVALS_MAP.put(UnaryMinusPtg.class, UnaryMinusEval.class);
+        OPERATION_EVALS_MAP.put(UnaryPlusPtg.class, UnaryPlusEval.class);
+
+    }
+
+    
+    protected HSSFRow row;
+    protected HSSFSheet sheet;
+    protected HSSFWorkbook workbook;
+    
+    public HSSFFormulaEvaluator(HSSFSheet sheet, HSSFWorkbook workbook) {
+        this.sheet = sheet;
+        this.workbook = workbook;
+    }
+    
+    public void setCurrentRow(HSSFRow row) {
+        this.row = row;
+    }
+
+    
+    /**
+     * If cell contains a formula, the formula is evaluated and returned,
+     * else the CellValue simply copies the appropriate cell value from
+     * the cell and also its cell type. This method should be preferred over
+     * evaluateInCell() when the call should not modify the contents of the
+     * original cell. 
+     * @param cell
+     * @return
+     */
+    public CellValue evaluate(HSSFCell cell) {
+        CellValue retval = null;
+        if (cell != null) {
+            switch (cell.getCellType()) {
+            case HSSFCell.CELL_TYPE_BLANK:
+                retval = new CellValue(HSSFCell.CELL_TYPE_BLANK);
+                break;
+            case HSSFCell.CELL_TYPE_BOOLEAN:
+                retval = new CellValue(HSSFCell.CELL_TYPE_BOOLEAN);
+                retval.setBooleanValue(cell.getBooleanCellValue());
+                break;
+            case HSSFCell.CELL_TYPE_ERROR:
+                retval = new CellValue(HSSFCell.CELL_TYPE_ERROR);
+                retval.setErrorValue(cell.getErrorCellValue());
+                break;
+            case HSSFCell.CELL_TYPE_FORMULA:
+                retval = getCellValueForEval(internalEvaluate(cell, row, sheet, workbook));
+                break;
+            case HSSFCell.CELL_TYPE_NUMERIC:
+                retval = new CellValue(HSSFCell.CELL_TYPE_NUMERIC);
+                retval.setNumberValue(cell.getNumericCellValue());
+                break;
+            case HSSFCell.CELL_TYPE_STRING:
+                retval = new CellValue(HSSFCell.CELL_TYPE_STRING);
+                retval.setStringValue(cell.getStringCellValue());
+                break;
+            }
+        }
+        return retval;
+    }
+    
+    
+    /**
+     * If cell contains formula, it evaluates the formula, and puts the 
+     * formula result back into the cell.
+     * Else if cell does not contain formula, this method leaves the cell 
+     * unchanged. Note that the same instance of HSSFCell is returned to 
+     * allow chained calls like:
+     * <pre>
+     * int evaluatedCellType = evaluator.evaluateInCell(cell).getCellType();
+     * </pre>
+     * @param cell
+     */
+    public HSSFCell evaluateInCell(HSSFCell cell) {
+        if (cell != null) {
+            switch (cell.getCellType()) {
+            case HSSFCell.CELL_TYPE_FORMULA:
+                CellValue cv = getCellValueForEval(internalEvaluate(cell, row, sheet, workbook));
+                switch (cv.getCellType()) {
+                case HSSFCell.CELL_TYPE_BOOLEAN:
+                    cell.setCellValue(cv.getBooleanValue());
+                    break;
+                case HSSFCell.CELL_TYPE_ERROR:
+                    cell.setCellValue(cv.getErrorValue());
+                    break;
+                case HSSFCell.CELL_TYPE_NUMERIC:
+                    cell.setCellValue(cv.getNumberValue());
+                    break;
+                case HSSFCell.CELL_TYPE_STRING:
+                    cell.setCellValue(cv.getStringValue());
+                    break;
+                case HSSFCell.CELL_TYPE_BLANK:
+                    break;
+                case HSSFCell.CELL_TYPE_FORMULA: // this will never happen, we have already evaluated the formula
+                    break;
+                }
+            }
+        }
+        return cell;
+    }
+        
+    
+    /**
+     * Returns a CellValue wrapper around the supplied ValueEval instance.
+     * @param eval
+     * @return
+     */
+    protected static CellValue getCellValueForEval(ValueEval eval) {
+        CellValue retval = null;
+        if (eval != null) {
+            if (eval instanceof NumberEval) {
+                NumberEval ne = (NumberEval) eval;
+                retval = new CellValue(HSSFCell.CELL_TYPE_NUMERIC);
+                retval.setNumberValue(ne.getNumberValue());
+            }
+            else if (eval instanceof BoolEval) {
+                BoolEval be = (BoolEval) eval;
+                retval = new CellValue(HSSFCell.CELL_TYPE_BOOLEAN);
+                retval.setBooleanValue(be.getBooleanValue());
+            }
+            else if (eval instanceof StringEval) {
+                StringEval ne = (StringEval) eval;
+                retval = new CellValue(HSSFCell.CELL_TYPE_STRING);
+                retval.setStringValue(ne.getStringValue());
+            }
+            else if (eval instanceof BlankEval) {
+                retval = new CellValue(HSSFCell.CELL_TYPE_BLANK);
+            }
+            else {
+                retval = new CellValue(HSSFCell.CELL_TYPE_ERROR);
+            }
+        }
+        return retval;
+    }
+    
+    /**
+     * Dev. Note: Internal evaluate must be passed only a formula cell 
+     * else a runtime exception will be thrown somewhere inside the method.
+     * (Hence this is a private method.)
+     * 
+     * @param formula
+     * @param sheet
+     * @param workbook
+     * @return
+     */
+    protected static ValueEval internalEvaluate(HSSFCell srcCell, HSSFRow srcRow, HSSFSheet sheet, HSSFWorkbook workbook) {
+        int srcRowNum = srcRow.getRowNum();
+        short srcColNum = srcCell.getCellNum();
+        
+        FormulaParser parser = new FormulaParser(srcCell.getCellFormula(), workbook.getWorkbook());
+        parser.parse();
+        Ptg[] ptgs = parser.getRPNPtg();
+        // -- parsing over --
+        
+
+        Stack stack = new Stack();
+        for (int i = 0, iSize = ptgs.length; i < iSize; i++) {
+
+            // since we dont know how to handle these yet :(
+            if (ptgs[i] instanceof ControlPtg) { continue; }
+            if (ptgs[i] instanceof MemErrPtg) { continue; }
+            if (ptgs[i] instanceof MissingArgPtg) { continue; }
+            if (ptgs[i] instanceof NamePtg) { continue; }
+            if (ptgs[i] instanceof NameXPtg) { continue; }
+            if (ptgs[i] instanceof UnknownPtg) { continue; }
+
+            if (ptgs[i] instanceof OperationPtg) {
+                OperationPtg optg = (OperationPtg) ptgs[i];
+
+                // parens can be ignored since we have RPN tokens
+                if (optg instanceof ParenthesisPtg) { continue; }
+                if (optg instanceof AttrPtg) { continue; }
+                if (optg instanceof UnionPtg) { continue; }
+
+                OperationEval operation = (OperationEval) getOperationEvalForPtg(optg);
+
+                int numops = operation.getNumberOfOperands();
+                Eval[] ops = new Eval[numops];
+
+                // storing the ops in reverse order since they are popping
+                for (int j = numops - 1; j >= 0; j--) {
+                    Eval p = (Eval) stack.pop();
+                    if (p instanceof ErrorEval) { // fast fail
+                        return (ErrorEval) p;
+                    }
+                    ops[j] = p;
+                }
+                Eval opresult = operation.evaluate(ops, srcRowNum, srcColNum);
+                stack.push(opresult);
+            }
+            else if (ptgs[i] instanceof ReferencePtg) {
+                ReferencePtg ptg = (ReferencePtg) ptgs[i];
+                short colnum = ptg.getColumn();
+                short rownum = ptg.getRow();
+                HSSFRow row = sheet.getRow(rownum);
+                HSSFCell cell = (row != null) ? row.getCell(colnum) : null;
+                pushRef2DEval(ptg, stack, cell, row, sheet, workbook);
+            }
+            else if (ptgs[i] instanceof Ref3DPtg) {
+                Ref3DPtg ptg = (Ref3DPtg) ptgs[i];
+                short colnum = ptg.getColumn();
+                short rownum = ptg.getRow();
+                HSSFSheet xsheet = workbook.getSheetAt(ptg.getExternSheetIndex());
+                HSSFRow row = sheet.getRow(rownum);
+                HSSFCell cell = (row != null) ? row.getCell(colnum) : null;
+                pushRef3DEval(ptg, stack, cell, row, sheet, workbook);
+            }
+            else if (ptgs[i] instanceof AreaPtg) {
+                AreaPtg ap = (AreaPtg) ptgs[i];
+                short row0 = ap.getFirstRow();
+                short col0 = ap.getFirstColumn();
+                short row1 = ap.getLastRow();
+                short col1 = ap.getLastColumn();
+                ValueEval[] values = new ValueEval[(row1 - row0 + 1) * (col1 - col0 + 1)];
+                for (short x = row0; sheet != null && x < row1 + 1; x++) {
+                    HSSFRow row = sheet.getRow(x);
+                    for (short y = col0; row != null && y < col1 + 1; y++) {
+                        values[(x - row0) * (col1 - col0 + 1) + (y - col0)] = 
+                            getEvalForCell(row.getCell(y), row, sheet, workbook);
+                    }
+                }
+                AreaEval ae = new Area2DEval(ap, values);
+                stack.push(ae);
+            }
+            else if (ptgs[i] instanceof Area3DPtg) {
+                Area3DPtg a3dp = (Area3DPtg) ptgs[i];
+                short row0 = a3dp.getFirstRow();
+                short col0 = a3dp.getFirstColumn();
+                short row1 = a3dp.getLastRow();
+                short col1 = a3dp.getLastColumn();
+                HSSFSheet xsheet = workbook.getSheetAt(a3dp.getExternSheetIndex());
+                ValueEval[] values = new ValueEval[(row1 - row0 + 1) * (col1 - col0 + 1)];
+                for (short x = row0; sheet != null && x < row1 + 1; x++) {
+                    HSSFRow row = sheet.getRow(x);
+                    for (short y = col0; row != null && y < col1 + 1; y++) {
+                        values[(x - row0) * (col1 - col0 + 1) + (y - col0)] = 
+                            getEvalForCell(row.getCell(y), row, sheet, workbook);
+                    }
+                }
+                AreaEval ae = new Area3DEval(a3dp, values);
+                stack.push(ae);
+            }
+            else {
+                Eval ptgEval = getEvalForPtg(ptgs[i]);
+                stack.push(ptgEval);
+            }
+        }
+        ValueEval value = ((ValueEval) stack.pop());
+        if (value instanceof RefEval) {
+            RefEval rv = (RefEval) value;
+            value = rv.getInnerValueEval();
+        }
+        else if (value instanceof AreaEval) {
+            AreaEval ae = (AreaEval) value;
+            if (ae.isRow()) 
+                value = ae.getValueAt(ae.getFirstRow(), srcColNum);
+            else if (ae.isColumn()) 
+                value = ae.getValueAt(srcRowNum, ae.getFirstColumn());
+            else
+                value = ErrorEval.VALUE_INVALID;
+        }
+        return value;
+    }
+
+    /**
+     * returns the OperationEval concrete impl instance corresponding
+     * to the suplied operationPtg
+     * @param ptg
+     * @return
+     */
+    protected static Eval getOperationEvalForPtg(OperationPtg ptg) {
+        Eval retval = null;
+
+        Class clazz = (Class) OPERATION_EVALS_MAP.get(ptg.getClass());
+        try {
+            Constructor constructor = clazz.getConstructor(OPERATION_CONSTRUCTOR_CLASS_ARRAY);
+            retval = (OperationEval) constructor.newInstance(new Ptg[] { ptg });
+        }
+        catch (Exception e) {
+            throw new RuntimeException("Fatal Error: ", e);
+        }
+        return retval;
+    }
+
+    /**
+     * returns an appropriate Eval impl instance for the Ptg. The Ptg must be
+     * one of: Area3DPtg, AreaPtg, ReferencePtg, Ref3DPtg, IntPtg, NumberPtg,
+     * StringPtg, BoolPtg <br/>special Note: OperationPtg subtypes cannot be
+     * passed here!
+     * 
+     * @param ptg
+     * @return
+     */
+    protected static Eval getEvalForPtg(Ptg ptg) {
+        Eval retval = null;
+
+        Class clazz = (Class) VALUE_EVALS_MAP.get(ptg.getClass());
+        try {
+            if (ptg instanceof Area3DPtg) {
+                Constructor constructor = clazz.getConstructor(AREA3D_CONSTRUCTOR_CLASS_ARRAY);
+                retval = (OperationEval) constructor.newInstance(new Ptg[] { ptg });
+            }
+            else if (ptg instanceof AreaPtg) {
+                Constructor constructor = clazz.getConstructor(AREA3D_CONSTRUCTOR_CLASS_ARRAY);
+                retval = (OperationEval) constructor.newInstance(new Ptg[] { ptg });
+            }
+            else if (ptg instanceof ReferencePtg) {
+                Constructor constructor = clazz.getConstructor(REFERENCE_CONSTRUCTOR_CLASS_ARRAY);
+                retval = (OperationEval) constructor.newInstance(new Ptg[] { ptg });
+            }
+            else if (ptg instanceof Ref3DPtg) {
+                Constructor constructor = clazz.getConstructor(REF3D_CONSTRUCTOR_CLASS_ARRAY);
+                retval = (OperationEval) constructor.newInstance(new Ptg[] { ptg });
+            }
+            else {
+                if (ptg instanceof IntPtg || ptg instanceof NumberPtg || ptg instanceof StringPtg
+                        || ptg instanceof BoolPtg) {
+                    Constructor constructor = clazz.getConstructor(VALUE_CONTRUCTOR_CLASS_ARRAY);
+                    retval = (ValueEval) constructor.newInstance(new Ptg[] { ptg });
+                }
+            }
+        }
+        catch (Exception e) {
+            throw new RuntimeException("Fatal Error: ", e);
+        }
+        return retval;
+
+    }
+
+    /**
+     * Given a cell, find its type and from that create an appropriate ValueEval
+     * impl instance and return that. Since the cell could be an external
+     * reference, we need the sheet that this belongs to.
+     * Non existent cells are treated as empty.
+     * @param cell
+     * @param sheet
+     * @param workbook
+     * @return
+     */
+    protected static ValueEval getEvalForCell(HSSFCell cell, HSSFRow row, HSSFSheet sheet, HSSFWorkbook workbook) {
+        ValueEval retval = BlankEval.INSTANCE;
+        if (cell != null) {
+            switch (cell.getCellType()) {
+            case HSSFCell.CELL_TYPE_NUMERIC:
+                retval = new NumberEval(cell.getNumericCellValue());
+                break;
+            case HSSFCell.CELL_TYPE_STRING:
+                retval = new StringEval(cell.getStringCellValue());
+                break;
+            case HSSFCell.CELL_TYPE_FORMULA:
+                retval = (ValueEval) internalEvaluate(cell, row, sheet, workbook);
+                break;
+            case HSSFCell.CELL_TYPE_BOOLEAN:
+                retval = cell.getBooleanCellValue() ? BoolEval.TRUE : BoolEval.FALSE;
+                break;
+            case HSSFCell.CELL_TYPE_BLANK:
+                retval = BlankEval.INSTANCE;
+                break;
+            case HSSFCell.CELL_TYPE_ERROR:
+                retval = ErrorEval.UNKNOWN_ERROR; // TODO: think about this...
+                break;
+            }
+        }
+        return retval;
+    }
+
+    /**
+     * create a Ref2DEval for ReferencePtg and push it on the stack.
+     * Non existent cells are treated as RefEvals containing BlankEval.
+     * @param ptg
+     * @param stack
+     * @param cell
+     * @param sheet
+     * @param workbook
+     */
+    protected static void pushRef2DEval(ReferencePtg ptg, Stack stack, 
+            HSSFCell cell, HSSFRow row, HSSFSheet sheet, HSSFWorkbook workbook) {
+        if (cell != null)
+            switch (cell.getCellType()) {
+            case HSSFCell.CELL_TYPE_NUMERIC:
+                stack.push(new Ref2DEval(ptg, new NumberEval(cell.getNumericCellValue()), false));
+                break;
+            case HSSFCell.CELL_TYPE_STRING:
+                stack.push(new Ref2DEval(ptg, new StringEval(cell.getStringCellValue()), false));
+                break;
+            case HSSFCell.CELL_TYPE_FORMULA:
+                stack.push(new Ref2DEval(ptg, internalEvaluate(cell, row, sheet, workbook), true));
+                break;
+            case HSSFCell.CELL_TYPE_BOOLEAN:
+                stack.push(new Ref2DEval(ptg, cell.getBooleanCellValue() ? BoolEval.TRUE : BoolEval.FALSE, false));
+                break;
+            case HSSFCell.CELL_TYPE_BLANK:
+                stack.push(new Ref2DEval(ptg, BlankEval.INSTANCE, false));
+                break;
+            case HSSFCell.CELL_TYPE_ERROR:
+                stack.push(new Ref2DEval(ptg, ErrorEval.UNKNOWN_ERROR, false)); // TODO: think abt this
+                break;
+            }
+        else {
+            stack.push(new Ref2DEval(ptg, BlankEval.INSTANCE, false));
+        }
+    }
+
+    /**
+     * create a Ref3DEval for Ref3DPtg and push it on the stack.
+     * 
+     * @param ptg
+     * @param stack
+     * @param cell
+     * @param sheet
+     * @param workbook
+     */
+    protected static void pushRef3DEval(Ref3DPtg ptg, Stack stack, HSSFCell cell, 
+            HSSFRow row, HSSFSheet sheet, HSSFWorkbook workbook) {
+        if (cell != null)
+            switch (cell.getCellType()) {
+            case HSSFCell.CELL_TYPE_NUMERIC:
+                stack.push(new Ref3DEval(ptg, new NumberEval(cell.getNumericCellValue()), false));
+                break;
+            case HSSFCell.CELL_TYPE_STRING:
+                stack.push(new Ref3DEval(ptg, new StringEval(cell.getStringCellValue()), false));
+                break;
+            case HSSFCell.CELL_TYPE_FORMULA:
+                stack.push(new Ref3DEval(ptg, internalEvaluate(cell, row, sheet, workbook), true));
+                break;
+            case HSSFCell.CELL_TYPE_BOOLEAN:
+                stack.push(new Ref3DEval(ptg, cell.getBooleanCellValue() ? BoolEval.TRUE : BoolEval.FALSE, false));
+                break;
+            case HSSFCell.CELL_TYPE_BLANK:
+                stack.push(new Ref3DEval(ptg, BlankEval.INSTANCE, false));
+                break;
+            case HSSFCell.CELL_TYPE_ERROR:
+                stack.push(new Ref3DEval(ptg, ErrorEval.UNKNOWN_ERROR, false)); // TODO: think abt this
+                break;
+            }
+        else {
+            stack.push(new Ref3DEval(ptg, BlankEval.INSTANCE, false));
+        }
+    }
+    
+    /**
+     * Mimics the 'data view' of a cell. This allows formula evaluator 
+     * to return a CellValue instead of precasting the value to String
+     * or Number or boolean type.
+     * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+     */
+    public static final class CellValue {
+        private int cellType;
+        private String stringValue;
+        private double numberValue;
+        private boolean booleanValue;
+        private byte errorValue;
+        
+        /**
+         * CellType should be one of the types defined in HSSFCell
+         * @param cellType
+         */
+        public CellValue(int cellType) {
+            super();
+            this.cellType = cellType;
+        }
+        /**
+         * @return Returns the booleanValue.
+         */
+        public boolean getBooleanValue() {
+            return booleanValue;
+        }
+        /**
+         * @param booleanValue The booleanValue to set.
+         */
+        public void setBooleanValue(boolean booleanValue) {
+            this.booleanValue = booleanValue;
+        }
+        /**
+         * @return Returns the numberValue.
+         */
+        public double getNumberValue() {
+            return numberValue;
+        }
+        /**
+         * @param numberValue The numberValue to set.
+         */
+        public void setNumberValue(double numberValue) {
+            this.numberValue = numberValue;
+        }
+        /**
+         * @return Returns the stringValue.
+         */
+        public String getStringValue() {
+            return stringValue;
+        }
+        /**
+         * @param stringValue The stringValue to set.
+         */
+        public void setStringValue(String stringValue) {
+            this.stringValue = stringValue;
+        }
+        /**
+         * @return Returns the cellType.
+         */
+        public int getCellType() {
+            return cellType;
+        }
+        /**
+         * @return Returns the errorValue.
+         */
+        public byte getErrorValue() {
+            return errorValue;
+        }
+        /**
+         * @param errorValue The errorValue to set.
+         */
+        public void setErrorValue(byte errorValue) {
+            this.errorValue = errorValue;
+        }
+    }
+
+    /**
+     * Manual testing... needs "the" c:/temp/test1.xls file to be present.
+     * 
+     * @param args
+     * @throws Exception
+     */
+    public static void main(String[] args) throws Exception {
+        String FILE_NAME = "c:/temp/test1.xls";
+
+        FileInputStream fis = new FileInputStream(FILE_NAME);
+        HSSFWorkbook wb = new HSSFWorkbook(fis);
+        fis.close();
+        HSSFSheet sheet = wb.getSheetAt(0);
+        HSSFFormulaEvaluator instance = new HSSFFormulaEvaluator(sheet, wb);
+
+        for (int rn = 1, rnSize = 4; rn <= rnSize; rn++) {
+            HSSFRow row = sheet.getRow(rn);
+            for (int cn = 5, cnSize = 7; cn <= cnSize; cn++) {
+                HSSFCell cell = row.getCell((short) cn);
+                System.out.println(new CellReference(rn, cn).toString() + ": " + instance.evaluate(cell));
+            }
+        }
+    }
+
+    /**
+     * debug method
+     * 
+     * @param formula
+     * @param sheet
+     * @param workbook
+     */
+    void inspectPtgs(String formula) {
+        FormulaParser fp = new FormulaParser(formula, workbook.getWorkbook());
+        fp.parse();
+        Ptg[] ptgs = fp.getRPNPtg();
+        System.out.println("<ptg-group>");
+        for (int i = 0, iSize = ptgs.length; i < iSize; i++) {
+            System.out.println("<ptg>");
+            System.out.println(ptgs[i]);
+            if (ptgs[i] instanceof OperationPtg) {
+                System.out.println("numoperands: " + ((OperationPtg) ptgs[i]).getNumberOfOperands());
+            }
+            System.out.println("</ptg>");
+        }
+        System.out.println("</ptg-group>");
+    }
+
+}
diff --git a/src/scratchpad/testcases/org/apache/poi/hssf/data/FormulaEvalTestData.xls b/src/scratchpad/testcases/org/apache/poi/hssf/data/FormulaEvalTestData.xls
new file mode 100644 (file)
index 0000000..e7921e3
Binary files /dev/null and b/src/scratchpad/testcases/org/apache/poi/hssf/data/FormulaEvalTestData.xls differ
diff --git a/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/eval/GenericFormulaTestCase.java b/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/eval/GenericFormulaTestCase.java
new file mode 100644 (file)
index 0000000..57e1375
--- /dev/null
@@ -0,0 +1,131 @@
+/*
+ * Created on May 11, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+import java.io.File;
+import java.io.FileInputStream;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.hssf.util.CellReference;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *
+ */
+public class GenericFormulaTestCase extends TestCase {
+
+    protected static final String FILENAME = System.getProperty("HSSF.testdata.path")+ "/FormulaEvalTestData.xls";
+
+    protected static HSSFWorkbook workbook = null;
+    
+    static {
+        try {
+            FileInputStream fin = new FileInputStream( FILENAME );
+            workbook = new HSSFWorkbook( fin );
+            fin.close();
+            }
+            catch (Exception e) {e.printStackTrace();}
+    }
+    protected CellReference beginCell;
+    protected int getBeginRow() {
+        return beginCell.getRow();
+    }
+    
+    protected short getBeginCol() {
+        return beginCell.getCol();
+    }
+
+    protected static final HSSFCell getExpectedValueCell(HSSFSheet sheet, HSSFRow row, HSSFCell cell) {
+        HSSFCell retval = null;
+        if (sheet != null) {
+            row = sheet.getRow(row.getRowNum()+1);
+            if (row != null) {
+                retval = row.getCell(cell.getCellNum());
+            }
+        }
+        
+        return retval;
+    }
+
+    protected void assertEquals(String msg, HSSFCell expected, HSSFFormulaEvaluator.CellValue actual) {
+        if (expected != null && actual!=null) {
+            if (expected!=null && expected.getCellType() == HSSFCell.CELL_TYPE_STRING) {
+                String value = expected.getStringCellValue();
+                if (value.startsWith("#")) {
+                    expected.setCellType(HSSFCell.CELL_TYPE_ERROR);
+                }
+            }
+            if (!(expected == null || actual == null)) {
+                switch (expected.getCellType()) {
+                case HSSFCell.CELL_TYPE_BLANK:
+                    assertEquals(msg, HSSFCell.CELL_TYPE_BLANK, actual.getCellType());
+                    break;
+                case HSSFCell.CELL_TYPE_BOOLEAN:
+                    assertEquals(msg, HSSFCell.CELL_TYPE_BOOLEAN, actual.getCellType());
+                    assertEquals(msg, expected.getBooleanCellValue(), actual.getBooleanValue());
+                    break;
+                case HSSFCell.CELL_TYPE_ERROR:
+                    assertEquals(msg, HSSFCell.CELL_TYPE_ERROR, actual.getCellType()); // TODO: check if exact error matches
+                    break;
+                case HSSFCell.CELL_TYPE_FORMULA: // will never be used, since we will call method after formula evaluation
+                    throw new AssertionFailedError("Cannot expect formula as result of formula evaluation");
+                case HSSFCell.CELL_TYPE_NUMERIC:
+                    assertEquals(msg, HSSFCell.CELL_TYPE_NUMERIC, actual.getCellType());
+                    double delta = Math.abs(expected.getNumericCellValue()-actual.getNumberValue());
+                    double pctExpected = Math.abs(0.00001*expected.getNumericCellValue());
+                    assertTrue(msg, delta <= pctExpected);
+                    break;
+                case HSSFCell.CELL_TYPE_STRING:
+                    assertEquals(msg, HSSFCell.CELL_TYPE_STRING, actual.getCellType());
+                    assertEquals(msg, expected.getStringCellValue(), actual.getStringValue());
+                    break;
+                }
+            }
+            else {
+                throw new AssertionFailedError("expected: " + expected + " got:" + actual);
+            }
+        }
+    }
+
+    public GenericFormulaTestCase(String beginCell) {
+        super("genericTest");
+        this.beginCell = new CellReference(beginCell);
+    }
+    
+    public void setUp() {
+    }
+    
+    public void genericTest() throws Exception {
+        HSSFSheet s = workbook.getSheetAt( 0 );
+        HSSFRow r = s.getRow(getBeginRow());
+        short endcolnum = r.getLastCellNum();
+        HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(s, workbook);
+        evaluator.setCurrentRow(r);
+
+        HSSFCell c = null;
+        for (short colnum=getBeginCol(); colnum < endcolnum; colnum++) {
+            c = r.getCell(colnum);
+            if (c==null || c.getCellType() == HSSFCell.CELL_TYPE_BLANK)
+                continue;
+            
+            assertEquals("Sanity check input cell type ", HSSFCell.CELL_TYPE_FORMULA, c.getCellType());
+            
+            HSSFFormulaEvaluator.CellValue actualValue = evaluator.evaluate(c);
+            
+            HSSFCell expectedValueCell = getExpectedValueCell(s, r, c);
+            assertEquals("Formula: " + c.getCellFormula() 
+                    + " @ " + getBeginRow() + ":" + colnum, 
+                    expectedValueCell, actualValue);
+        }
+    }
+    
+}
diff --git a/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/eval/TestEverything.java b/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/eval/TestEverything.java
new file mode 100644 (file)
index 0000000..f7db5d4
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Created on May 11, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.eval;
+
+import junit.framework.TestSuite;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *
+ */
+public class TestEverything extends TestSuite {
+
+    public static TestSuite suite() {
+        TestSuite suite = new TestSuite("Tests for OperationEval concrete implementation classes.");
+        suite.addTest(new GenericFormulaTestCase("D23"));
+        suite.addTest(new GenericFormulaTestCase("D27"));
+        suite.addTest(new GenericFormulaTestCase("D31"));
+        suite.addTest(new GenericFormulaTestCase("D35"));
+        suite.addTest(new GenericFormulaTestCase("D39"));
+        suite.addTest(new GenericFormulaTestCase("D43"));
+        suite.addTest(new GenericFormulaTestCase("D47"));
+        suite.addTest(new GenericFormulaTestCase("D51"));
+        suite.addTest(new GenericFormulaTestCase("D55"));
+        suite.addTest(new GenericFormulaTestCase("D59"));
+        suite.addTest(new GenericFormulaTestCase("D63"));
+        suite.addTest(new GenericFormulaTestCase("D67"));
+        suite.addTest(new GenericFormulaTestCase("D71"));
+        suite.addTest(new GenericFormulaTestCase("D75"));
+        return suite;
+    }
+}
diff --git a/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestEverything.java b/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestEverything.java
new file mode 100644 (file)
index 0000000..6c30b30
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Created on May 11, 2005
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.GenericFormulaTestCase;
+
+import junit.framework.TestSuite;
+
+/**
+ * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
+ *
+ */
+public class TestEverything extends TestSuite {
+
+    public static TestSuite suite() {
+        TestSuite suite = new TestSuite("Tests for individual function classes");
+        String s;
+        for(int i=80; i<1481;i=i+4) {
+               s = "D"+Integer.toString(i).trim();
+               suite.addTest(new GenericFormulaTestCase(s));
+        }
+        return suite;
+    }
+}