View | Details | Raw Unified | Return to bug 34828
Collapse All | Expand All

(-)org/apache/poi/hssf/record/formula/eval/AddEval.java (+96 lines)
Added Link Here
1
/*
2
 * Created on May 8, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.eval;
6
7
import org.apache.poi.hssf.record.formula.AddPtg;
8
import org.apache.poi.hssf.record.formula.Ptg;
9
10
/**
11
 * @author Amol S. Deshmukh < amolweb at ya hoo dot com >
12
 *
13
 */
14
public class AddEval implements OperationEval {
15
16
    private AddPtg delegate;
17
    
18
    public AddEval(Ptg ptg) {
19
        delegate = (AddPtg) ptg;
20
    }
21
    
22
23
    
24
    /* (non-Javadoc)
25
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#evaluate(org.apache.poi.hssf.record.formula.eval.Eval[])
26
     */
27
    public Eval evaluate(Eval[] operands) {
28
        double d = 0;
29
        Eval retval = null;
30
        if (operands.length == 2) {
31
	    	for (int i=0, iSize=getNumberOfOperands(); i<iSize; i++) {
32
	        	if (operands[i] instanceof NumericValueEval) {
33
	        		d += ((NumericValueEval) operands[i]).getNumberValue();
34
	        	}
35
	        	else if (operands[i] instanceof RefEval) {
36
	        	    RefEval re = (RefEval) operands[i];
37
	        	    ValueEval ve = (ValueEval) re.getInnerValueEval();
38
	            	if (ve instanceof NumericValueEval) {
39
	            		d += ((NumericValueEval) ve).getNumberValue();
40
	            	}
41
	            	else {
42
	            	    retval = ErrorEval.ERROR_502;
43
	            	    break;
44
	            	}
45
	        	}
46
	        	else if (operands[i] instanceof AreaEval) {
47
	        	    AreaEval ae = (AreaEval) operands[i];
48
	        	    short frow = ae.getFirstRow();
49
	        	    short lrow = ae.getLastRow();
50
	        	    if (frow == lrow) {
51
	        	        ValueEval ve = ae.getValues()[0];
52
	    	        	if (ve instanceof NumericValueEval) {
53
	    	        		d += ((NumericValueEval) ve).getNumberValue();
54
	    	        	}
55
	    	        	else if (ve instanceof RefEval) {
56
	    	        	    RefEval re = (RefEval) ve;
57
	    	        	    ValueEval ve2 = (ValueEval) re.getInnerValueEval();
58
	    	            	if (ve2 instanceof NumericValueEval) {
59
	    	            		d += ((NumericValueEval) ve2).getNumberValue();
60
	    	            	}
61
	    	            	else {
62
	    	            	    retval = ErrorEval.ERROR_502;
63
	    	            	    break;
64
	    	            	}
65
	    	        	}
66
	        	    }
67
	        	}
68
	        	else {
69
	        	    retval = ErrorEval.ERROR_502;
70
	        	    break;
71
	        	}
72
	    	}
73
        }
74
        else {
75
            retval = ErrorEval.ERROR_520; // try "=2+" in Oo
76
        }
77
    	if (retval == null) {
78
    	    retval = Double.isNaN(d) ? (ValueEval) ErrorEval.ERROR_502 : new NumberEval(d);
79
    	}
80
    	return retval;
81
    }
82
    
83
    /* (non-Javadoc)
84
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#getNumberOfOperands()
85
     */
86
    public int getNumberOfOperands() {
87
        return delegate.getNumberOfOperands();
88
    }
89
    
90
    /* (non-Javadoc)
91
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#getType()
92
     */
93
    public int getType() {
94
        return delegate.getType();
95
    }
96
}
(-)org/apache/poi/hssf/record/formula/eval/Area2DEval.java (+58 lines)
Added Link Here
1
/*
2
 * Created on May 8, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.eval;
6
7
import org.apache.poi.hssf.record.formula.AreaPtg;
8
import org.apache.poi.hssf.record.formula.Ptg;
9
10
/**
11
 * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
12
 *
13
 */
14
public class Area2DEval implements AreaEval {
15
16
    private AreaPtg delegate;
17
    private ValueEval[] values;
18
    
19
    public Area2DEval(Ptg ptg, ValueEval[] values) {
20
        this.delegate = (AreaPtg) ptg;
21
        this.values = values;
22
    }
23
    
24
    /* (non-Javadoc)
25
     * @see org.apache.poi.hssf.record.formula.eval.AreaEval#getFirstCol()
26
     */
27
    public short getFirstColumn() {
28
        return delegate.getFirstColumn();
29
    }
30
    
31
    /* (non-Javadoc)
32
     * @see org.apache.poi.hssf.record.formula.eval.AreaEval#getFirstRow()
33
     */
34
    public short getFirstRow() {
35
        return delegate.getFirstRow();
36
    }
37
    
38
    /* (non-Javadoc)
39
     * @see org.apache.poi.hssf.record.formula.eval.AreaEval#getLastCol()
40
     */
41
    public short getLastColumn() {
42
        return delegate.getLastColumn();
43
    }
44
    
45
    /* (non-Javadoc)
46
     * @see org.apache.poi.hssf.record.formula.eval.AreaEval#getLastRow()
47
     */
48
    public short getLastRow() {
49
        return delegate.getLastRow();
50
    }
51
    
52
    /* (non-Javadoc)
53
     * @see org.apache.poi.hssf.record.formula.eval.AreaEval#getValues()
54
     */
55
    public ValueEval[] getValues() {
56
        return values;
57
    }
58
}
(-)org/apache/poi/hssf/record/formula/eval/Area3DEval.java (+73 lines)
Added Link Here
1
/*
2
 * Created on May 8, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.eval;
6
7
import java.lang.reflect.Constructor;
8
9
import org.apache.poi.hssf.record.formula.Area3DPtg;
10
import org.apache.poi.hssf.record.formula.Ptg;
11
12
/**
13
 * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
14
 *
15
 */
16
public class Area3DEval implements AreaEval {
17
18
    private Area3DPtg delegate;
19
    
20
    private ValueEval[] values;
21
    
22
    public Area3DEval(Ptg ptg, ValueEval[] values) {
23
        this.values = values;
24
        this.delegate = (Area3DPtg) ptg;
25
    }
26
    
27
    
28
    public static void main(String[] args) throws Exception {
29
        Class clazz = Area3DEval.class;
30
        Constructor[] carr = clazz.getDeclaredConstructors();
31
        for (int i=0, iSize=carr.length; i<iSize; i++) {
32
            Object[] o = carr[i].getParameterTypes();
33
            for (int j=0, jSize=o.length; j<jSize; j++) {
34
                System.out.println(o[j]);
35
            }
36
        }
37
    }
38
    /* (non-Javadoc)
39
     * @see org.apache.poi.hssf.record.formula.eval.AreaEval#getFirstCol()
40
     */
41
    public short getFirstColumn() {
42
        return delegate.getFirstColumn();
43
    }
44
    
45
    /* (non-Javadoc)
46
     * @see org.apache.poi.hssf.record.formula.eval.AreaEval#getFirstRow()
47
     */
48
    public short getFirstRow() {
49
        return delegate.getFirstRow();
50
    }
51
    
52
    /* (non-Javadoc)
53
     * @see org.apache.poi.hssf.record.formula.eval.AreaEval#getLastCol()
54
     */
55
    public short getLastColumn() {
56
        return delegate.getLastColumn();
57
    }
58
    
59
    /* (non-Javadoc)
60
     * @see org.apache.poi.hssf.record.formula.eval.AreaEval#getLastRow()
61
     */
62
    public short getLastRow() {
63
        return delegate.getLastRow();
64
    }
65
    
66
    /* (non-Javadoc)
67
     * @see org.apache.poi.hssf.record.formula.eval.AreaEval#getValues()
68
     */
69
    public ValueEval[] getValues() {
70
        return values;
71
    }
72
    
73
}
(-)org/apache/poi/hssf/record/formula/eval/AreaEval.java (+18 lines)
Added Link Here
1
/*
2
 * Created on May 8, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.eval;
6
7
/**
8
 * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
9
 *
10
 */
11
public interface AreaEval extends Eval {
12
13
    public short getFirstRow();
14
    public short getLastRow();
15
    public short getFirstColumn();
16
    public short getLastColumn();
17
    public ValueEval[] getValues();
18
}
(-)org/apache/poi/hssf/record/formula/eval/BlankEval.java (+17 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.eval;
6
7
/**
8
 * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
9
 * This class is a marker class. It is a special value for
10
 * empty cells.
11
 */
12
public class BlankEval implements ValueEval {
13
14
    public static BlankEval BLANK_EVAL = new BlankEval();
15
    
16
    private BlankEval() {}
17
}
(-)org/apache/poi/hssf/record/formula/eval/BoolEval.java (+37 lines)
Added Link Here
1
/*
2
 * Created on May 8, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.eval;
6
7
import org.apache.poi.hssf.record.formula.BoolPtg;
8
import org.apache.poi.hssf.record.formula.Ptg;
9
10
/**
11
 * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
12
 *
13
 */
14
public class BoolEval implements NumericValueEval, StringValueEval {
15
16
    private boolean value;
17
    
18
    public BoolEval(Ptg ptg) {
19
        this.value = ((BoolPtg) ptg).getValue();
20
    }
21
    
22
    public BoolEval(boolean value) {
23
        this.value = value;
24
    }
25
    
26
    public boolean getBooleanValue() {
27
        return value;
28
    }
29
    
30
    public double getNumberValue() {
31
        return value ? (short) 1 : (short) 0;
32
    }
33
    
34
    public String getStringValue() {
35
        return value ? "1" : "0";
36
    }
37
}
(-)org/apache/poi/hssf/record/formula/eval/ConcatEval.java (+54 lines)
Added Link Here
1
/*
2
 * Created on May 8, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.eval;
6
7
import org.apache.poi.hssf.record.formula.ConcatPtg;
8
import org.apache.poi.hssf.record.formula.Ptg;
9
10
/**
11
 * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
12
 *
13
 */
14
public class ConcatEval implements OperationEval {
15
16
    private ConcatPtg delegate;
17
    
18
    public ConcatEval(Ptg ptg) {
19
        this.delegate = (ConcatPtg) ptg;
20
    }
21
    
22
    /* (non-Javadoc)
23
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#evaluate(org.apache.poi.hssf.record.formula.eval.Eval[])
24
     */
25
    public Eval evaluate(Eval[] operands) {
26
        Eval retval = null;
27
        if (operands.length >= 2) {
28
            StringBuffer sb = new StringBuffer();
29
            for (int i=0, iSize=2; i<iSize; i++) { // if more than 2 operands, ignore excess
30
                if (operands[i] instanceof StringValueEval) {
31
                    sb.append(operands[i]);
32
                }
33
            }
34
        }
35
        else {
36
            retval = ErrorEval.ERROR_520;
37
        }
38
        return retval;
39
    }
40
    
41
    /* (non-Javadoc)
42
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#getNumberOfOperands()
43
     */
44
    public int getNumberOfOperands() {
45
        return delegate.getNumberOfOperands();
46
    }
47
    
48
    /* (non-Javadoc)
49
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#getType()
50
     */
51
    public int getType() {
52
        return delegate.getType();
53
    }
54
}
(-)org/apache/poi/hssf/record/formula/eval/DivideEval.java (+98 lines)
Added Link Here
1
/*
2
 * Created on May 8, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.eval;
6
7
import org.apache.poi.hssf.record.formula.DividePtg;
8
import org.apache.poi.hssf.record.formula.Ptg;
9
10
/**
11
 * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
12
 *
13
 */
14
public class DivideEval implements OperationEval {
15
16
    private DividePtg delegate;
17
    
18
    public DivideEval(Ptg ptg) {
19
        this.delegate = (DividePtg) ptg;
20
    }
21
    
22
    /* (non-Javadoc)
23
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#evaluate(org.apache.poi.hssf.record.formula.eval.Eval[])
24
     */
25
    public Eval evaluate(Eval[] operands) {
26
        double d0 = 0;
27
        double d1 = 0;
28
		ValueEval retval = null;
29
		if (operands.length >= 2) { // ignore operands other than 1st two
30
		    if (operands[0] != null) {
31
				if (operands[0] instanceof NumericValueEval) {
32
				    d0 = ((NumericValueEval) operands[0]).getNumberValue();
33
				}
34
				else if (operands[0] instanceof StringValueEval) {
35
				    retval = ErrorEval.ERROR_502;
36
				}
37
				else if (operands[0] instanceof ErrorEval) {
38
				    retval = (ErrorEval) operands[0];
39
				}
40
				else if (operands[0] instanceof RefEval) {
41
				    RefEval re = (RefEval) operands[0];
42
				    ValueEval ve = re.getInnerValueEval();
43
					if (operands[0] instanceof NumericValueEval) {
44
					    d0 = ((NumericValueEval) operands[0]).getNumberValue();
45
					}
46
					else if (operands[0] instanceof StringValueEval) {
47
					    retval = ErrorEval.ERROR_502;
48
					}
49
					else if (operands[0] instanceof ErrorEval) {
50
					    retval = (ErrorEval) operands[0];
51
					}
52
				}
53
				else {
54
				    retval = ErrorEval.INVALID_VALUE;
55
				}
56
		    }
57
		    if (retval == null && operands[1] != null) {
58
				if (operands[1] instanceof NumericValueEval) {
59
				    d1 = ((NumericValueEval) operands[1]).getNumberValue();
60
				}
61
				else if (operands[1] instanceof StringValueEval) {
62
				    retval = ErrorEval.ERROR_502;
63
				}
64
				else if (operands[0] instanceof ErrorEval) {
65
				    ErrorEval e = (ErrorEval) operands[0];
66
				    retval = e;
67
				}
68
				else {
69
				    retval = ErrorEval.INVALID_VALUE;
70
				}
71
		    }
72
			if (retval != null) {
73
			    retval = (Double.isNaN(d0) || Double.isNaN(d1) || d1==0)
74
			    		? (ValueEval) ErrorEval.ERROR_502
75
			            : new NumberEval(d0/d1);
76
			}
77
		}
78
		else {
79
		    retval = ErrorEval.ERROR_UNKNOWN;
80
		}
81
		return retval;
82
    }
83
    
84
    /* (non-Javadoc)
85
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#getNumberOfOperands()
86
     */
87
    public int getNumberOfOperands() {
88
        return delegate.getNumberOfOperands();
89
    }
90
    
91
    /* (non-Javadoc)
92
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#getType()
93
     */
94
    public int getType() {
95
        return delegate.getType();
96
    }
97
98
}
(-)org/apache/poi/hssf/record/formula/eval/EqualEval.java (+167 lines)
Added Link Here
1
/*
2
 * Created on May 8, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.eval;
6
7
import org.apache.poi.hssf.record.formula.EqualPtg;
8
import org.apache.poi.hssf.record.formula.Ptg;
9
10
/**
11
 * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
12
 *
13
 */
14
public class EqualEval implements OperationEval {
15
16
    private EqualPtg delegate;
17
    
18
    public EqualEval(Ptg ptg) {
19
        this.delegate = (EqualPtg) ptg;
20
    }
21
22
23
    /* (non-Javadoc)
24
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#evaluate(org.apache.poi.hssf.record.formula.eval.Eval[])
25
     */
26
    public Eval evaluate(Eval[] operands) {
27
        boolean b = false;
28
        double d0 = 0;
29
        double d1 = 0;
30
        String s0 = null;
31
        String s1 = null;
32
        ValueEval retval = null;
33
        if (operands.length >= 2) { // ignore >2 operands
34
            if (operands[0] instanceof NumericValueEval) {
35
                NumericValueEval ne = (NumericValueEval) operands[0];
36
                d0 = ne.getNumberValue();
37
            }
38
            else if (operands[0] instanceof RefEval) {
39
                RefEval re = (RefEval) operands[0];
40
                ValueEval ve = re.getInnerValueEval();
41
                if (ve instanceof NumericValueEval) {
42
                    NumericValueEval ne = (NumericValueEval) ve;
43
                    d0 = ne.getNumberValue();
44
                }
45
                else if (ve instanceof StringValueEval) {
46
                    StringValueEval se = (StringValueEval) ve;
47
                    s0 = se.getStringValue();
48
                }
49
            }
50
            // Oo does some weird things here.
51
            // ...works fine for row area, conks out for col/row-col area
52
            // Excel surprisingly does well for row & col, conks out
53
            // ...for row-col area.
54
            else if (operands[0] instanceof AreaEval) { 
55
                AreaEval ae = (AreaEval) operands[0];
56
                short frow = ae.getFirstRow();
57
                short lrow = ae.getLastRow();
58
                short fcol = ae.getFirstColumn();
59
                short lcol = ae.getLastColumn();
60
                if (frow == lrow || fcol == lcol) {
61
	                ValueEval ve = ae.getValues()[0];
62
	                if (ve instanceof NumericValueEval) {
63
	                    NumericValueEval ne = (NumericValueEval) ve;
64
	                    d0 = ne.getNumberValue();
65
	                }
66
	                else if (ve instanceof StringValueEval) {
67
	                    StringValueEval se = (StringValueEval) ve;
68
	                    s0 = se.getStringValue();
69
	                }
70
                }
71
                else {
72
                    retval = ErrorEval.INVALID_VALUE;
73
                }
74
            }
75
            
76
            // we're only done with the first operand by now...
77
            
78
            if (operands[1] instanceof NumericValueEval) {
79
                NumericValueEval ne = (NumericValueEval) operands[1];
80
                d1 = ne.getNumberValue();
81
            }
82
            else if (operands[1] instanceof RefEval) {
83
                RefEval re = (RefEval) operands[1];
84
                ValueEval ve = re.getInnerValueEval();
85
                if (ve instanceof NumericValueEval) {
86
                    NumericValueEval ne = (NumericValueEval) ve;
87
                    d1 = ne.getNumberValue();
88
                }
89
                else if (ve instanceof StringValueEval) {
90
                    StringValueEval se = (StringValueEval) ve;
91
                    s1 = se.getStringValue();
92
                }
93
            }
94
            // Oo does some weird things here.
95
            // ...works fine for row area, conks out for col/row-col area
96
            // Excel surprisingly does well for row & col, conks out
97
            // ...for row-col area.
98
            else if (operands[1] instanceof AreaEval) { 
99
                AreaEval ae = (AreaEval) operands[1];
100
                short frow = ae.getFirstRow();
101
                short lrow = ae.getLastRow();
102
                short fcol = ae.getFirstColumn();
103
                short lcol = ae.getLastColumn();
104
                if (frow == lrow || fcol == lcol) {
105
	                ValueEval ve = ae.getValues()[1];
106
	                if (ve instanceof NumericValueEval) {
107
	                    NumericValueEval ne = (NumericValueEval) ve;
108
	                    d1 = ne.getNumberValue();
109
	                }
110
	                else if (ve instanceof StringValueEval) {
111
	                    StringValueEval se = (StringValueEval) ve;
112
	                    s1 = se.getStringValue();
113
	                }
114
                }
115
                else {
116
                    retval = ErrorEval.INVALID_VALUE;
117
                }
118
            }
119
        }
120
        else {
121
            retval = ErrorEval.ERROR_520;
122
        }
123
        
124
        
125
        // now the comparison begins *drumroll*
126
        if (retval == null) {
127
            if (s0 == null) {
128
                if (s1 == null) {
129
                    retval = (Double.isNaN(d0) || Double.isNaN(d1))
130
                    		? (ValueEval) ErrorEval.ERROR_502
131
                            : new BoolEval(d0 == d1);
132
                }
133
                else {
134
                    retval = (Double.isNaN(d0))
135
            				? (ValueEval) ErrorEval.ERROR_502
136
                            : new BoolEval(false);
137
                }
138
            }
139
            else {
140
                if (s1 == null) {
141
                    retval = (Double.isNaN(d1))
142
                    		? (ValueEval) ErrorEval.ERROR_502
143
                            : new BoolEval(false);
144
                }
145
                else {
146
                    retval = new BoolEval(s0.compareTo(s1) == 0);
147
                }
148
            }
149
        }
150
        
151
        return new BoolEval(b);
152
    }     
153
    
154
    /* (non-Javadoc)
155
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#getNumberOfOperands()
156
     */
157
    public int getNumberOfOperands() {
158
        return delegate.getNumberOfOperands();
159
    }
160
    
161
    /* (non-Javadoc)
162
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#getType()
163
     */
164
    public int getType() {
165
        return delegate.getType();
166
    }
167
}
(-)org/apache/poi/hssf/record/formula/eval/ErrorEval.java (+423 lines)
Added Link Here
1
/*
2
 * Created on May 8, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.eval;
6
7
/**
8
 * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
9
 *
10
 * Error code reference from OpenOffice documentation:
11
 * <br/>
12
 * <TABLE WIDTH=575 BORDER=1 CELLPADDING=2 CELLSPACING=0 BGCOLOR="#ffffff">
13
 * 	<COL WIDTH=42>
14
 * 	<COL WIDTH=118>
15
 * 	<COL WIDTH=401>
16
 * 	<TR VALIGN=TOP>
17
 * 		<TD WIDTH=42 BGCOLOR="#ffffff">
18
 * 			<P CLASS="tablehead" ALIGN=LEFT>Error Code</P>
19
 * 		</TD>
20
 * 		<TD WIDTH=118 BGCOLOR="#ffffff">
21
 * 			<P CLASS="tablehead" ALIGN=LEFT>Message</P>
22
 * 		</TD>
23
 * 		<TD WIDTH=401 BGCOLOR="#ffffff">
24
 * 			<P CLASS="tablehead" ALIGN=LEFT>Explanation</P>
25
 * 		</TD>
26
 * 	</TR>
27
 * 	<TR VALIGN=TOP>
28
 * 		<TD WIDTH=42 BGCOLOR="#ffffff">
29
 * 			<P CLASS="textintable" ALIGN=LEFT>501</P>
30
 * 		</TD>
31
 * 		<TD WIDTH=118 BGCOLOR="#ffffff">
32
 * 			<P CLASS="textintable" ALIGN=LEFT>Invalid character</P>
33
 * 		</TD>
34
 * 		<TD WIDTH=401 BGCOLOR="#ffffff">
35
 * 			<P CLASS="textintable" ALIGN=LEFT>Character in a formula is not
36
 * 			valid, for example, &quot;=1Eq&quot; instead of &quot;=1E2&quot;.</P>
37
 * 		</TD>
38
 * 	</TR>
39
 * 	<TR VALIGN=TOP>
40
 * 		<TD WIDTH=42 BGCOLOR="#ffffff">
41
 * 			<P CLASS="textintable" ALIGN=LEFT>502</P>
42
 * 		</TD>
43
 * 		<TD WIDTH=118 BGCOLOR="#ffffff">
44
 * 			<P CLASS="textintable" ALIGN=LEFT>Invalid argument</P>
45
 * 		</TD>
46
 * 		<TD WIDTH=401 BGCOLOR="#ffffff">
47
 * 			<P CLASS="textintable" ALIGN=LEFT>Function argument is not valid,
48
 * 			for example, a negative number for the root function.</P>
49
 * 		</TD>
50
 * 	</TR>
51
 * 	<TR VALIGN=TOP>
52
 * 		<TD WIDTH=42 BGCOLOR="#ffffff">
53
 * 			<P CLASS="textintable" ALIGN=LEFT>503</P>
54
 * 		</TD>
55
 * 		<TD WIDTH=118 BGCOLOR="#ffffff">
56
 * 			<P CLASS="textintable" ALIGN=LEFT>Invalid floating point operation</P>
57
 * 		</TD>
58
 * 		<TD WIDTH=401 BGCOLOR="#ffffff">
59
 * 			<P CLASS="textintable" ALIGN=LEFT>Division by 0, or another
60
 * 			calculation that results in an overflow of the defined value
61
 * 			range.</P>
62
 * 		</TD>
63
 * 	</TR>
64
 * 	<TR VALIGN=TOP>
65
 * 		<TD WIDTH=42 BGCOLOR="#ffffff">
66
 * 			<P CLASS="textintable" ALIGN=LEFT>504</P>
67
 * 		</TD>
68
 * 		<TD WIDTH=118 BGCOLOR="#ffffff">
69
 * 			<P CLASS="textintable" ALIGN=LEFT>Parameter list error</P>
70
 * 		</TD>
71
 * 		<TD WIDTH=401 BGCOLOR="#ffffff">
72
 * 			<P CLASS="textintable" ALIGN=LEFT>Function parameter is not valid,
73
 * 			for example, text instead of a number, or a domain reference
74
 * 			instead of cell reference.</P>
75
 * 		</TD>
76
 * 	</TR>
77
 * 	<TR VALIGN=TOP>
78
 * 		<TD WIDTH=42 BGCOLOR="#ffffff">
79
 * 			<P CLASS="textintable" ALIGN=LEFT>505</P>
80
 * 		</TD>
81
 * 		<TD WIDTH=118 BGCOLOR="#ffffff">
82
 * 			<P CLASS="textintable" ALIGN=LEFT>Internal syntax error</P>
83
 * 		</TD>
84
 * 		<TD WIDTH=401 BGCOLOR="#ffffff">
85
 * 			<P CLASS="textintable" ALIGN=LEFT>Not used</P>
86
 * 		</TD>
87
 * 	</TR>
88
 * 	<TR VALIGN=TOP>
89
 * 		<TD WIDTH=42 BGCOLOR="#ffffff">
90
 * 			<P CLASS="textintable" ALIGN=LEFT>506</P>
91
 * 		</TD>
92
 * 		<TD WIDTH=118 BGCOLOR="#ffffff">
93
 * 			<P CLASS="textintable" ALIGN=LEFT>Invalid semicolon</P>
94
 * 		</TD>
95
 * 		<TD WIDTH=401 BGCOLOR="#ffffff">
96
 * 			<P CLASS="textintable" ALIGN=LEFT>Not used</P>
97
 * 		</TD>
98
 * 	</TR>
99
 * 	<TR VALIGN=TOP>
100
 * 		<TD WIDTH=42 BGCOLOR="#ffffff">
101
 * 			<P CLASS="textintable" ALIGN=LEFT>507</P>
102
 * 		</TD>
103
 * 		<TD WIDTH=118 BGCOLOR="#ffffff">
104
 * 			<P CLASS="textintable" ALIGN=LEFT>Error: Pair missing</P>
105
 * 		</TD>
106
 * 		<TD WIDTH=401 BGCOLOR="#ffffff">
107
 * 			<P CLASS="textintable" ALIGN=LEFT>Not used</P>
108
 * 		</TD>
109
 * 	</TR>
110
 * 	<TR VALIGN=TOP>
111
 * 		<TD WIDTH=42 BGCOLOR="#ffffff">
112
 * 			<P CLASS="textintable" ALIGN=LEFT>508</P>
113
 * 		</TD>
114
 * 		<TD WIDTH=118 BGCOLOR="#ffffff">
115
 * 			<P CLASS="textintable" ALIGN=LEFT>Error: Pair missing</P>
116
 * 		</TD>
117
 * 		<TD WIDTH=401 BGCOLOR="#ffffff">
118
 * 			<P CLASS="textintable" ALIGN=LEFT>Missing bracket, for example,
119
 * 			closing brackets, but no opening brackets</P>
120
 * 		</TD>
121
 * 	</TR>
122
 * 	<TR VALIGN=TOP>
123
 * 		<TD WIDTH=42 BGCOLOR="#ffffff">
124
 * 			<P CLASS="textintable" ALIGN=LEFT>509</P>
125
 * 		</TD>
126
 * 		<TD WIDTH=118 BGCOLOR="#ffffff">
127
 * 			<P CLASS="textintable" ALIGN=LEFT>Missing operator</P>
128
 * 		</TD>
129
 * 		<TD WIDTH=401 BGCOLOR="#ffffff">
130
 * 			<P CLASS="textintable" ALIGN=LEFT>Operator is missing, for
131
 * 			example, &quot;=2(3+4) * &quot;, where the operator between &quot;2&quot;
132
 * 			and &quot;(&quot; is missing.</P>
133
 * 		</TD>
134
 * 	</TR>
135
 * 	<TR VALIGN=TOP>
136
 * 		<TD WIDTH=42 BGCOLOR="#ffffff">
137
 * 			<P CLASS="textintable" ALIGN=LEFT>510</P>
138
 * 		</TD>
139
 * 		<TD WIDTH=118 BGCOLOR="#ffffff">
140
 * 			<P CLASS="textintable" ALIGN=LEFT>Missing variable</P>
141
 * 		</TD>
142
 * 		<TD WIDTH=401 BGCOLOR="#ffffff">
143
 * 			<P CLASS="textintable" ALIGN=LEFT>Variable is missing, for example
144
 * 			when two operators are together &quot;=1+*2&quot;.</P>
145
 * 		</TD>
146
 * 	</TR>
147
 * 	<TR VALIGN=TOP>
148
 * 		<TD WIDTH=42 BGCOLOR="#ffffff">
149
 * 			<P CLASS="textintable" ALIGN=LEFT>511</P>
150
 * 		</TD>
151
 * 		<TD WIDTH=118 BGCOLOR="#ffffff">
152
 * 			<P CLASS="textintable" ALIGN=LEFT>Missing variable</P>
153
 * 		</TD>
154
 * 		<TD WIDTH=401 BGCOLOR="#ffffff">
155
 * 			<P CLASS="textintable" ALIGN=LEFT>Function requires more variables
156
 * 			than are provided, for example, AND() and OR().</P>
157
 * 		</TD>
158
 * 	</TR>
159
 * 	<TR VALIGN=TOP>
160
 * 		<TD WIDTH=42 BGCOLOR="#ffffff">
161
 * 			<P CLASS="textintable" ALIGN=LEFT>512</P>
162
 * 		</TD>
163
 * 		<TD WIDTH=118 BGCOLOR="#ffffff">
164
 * 			<P CLASS="textintable" ALIGN=LEFT>Formula overflow</P>
165
 * 		</TD>
166
 * 		<TD WIDTH=401 BGCOLOR="#ffffff">
167
 * 			<P CLASS="textintable" ALIGN=LEFT><B>Compiler:</B> the total
168
 * 			number of internal tokens, (that is, operators, variables,
169
 * 			brackets) in the formula exceeds 512. <B>Interpreter:</B> the
170
 * 			total number of matrices that the formula creates exceeds 150.
171
 * 			This includes basic functions that receive too large an array as a
172
 * 			parameter (max. 0xFFFE, for example, 65534 bytes).</P>
173
 * 		</TD>
174
 * 	</TR>
175
 * 	<TR VALIGN=TOP>
176
 * 		<TD WIDTH=42 BGCOLOR="#ffffff">
177
 * 			<P CLASS="textintable" ALIGN=LEFT>513</P>
178
 * 		</TD>
179
 * 		<TD WIDTH=118 BGCOLOR="#ffffff">
180
 * 			<P CLASS="textintable" ALIGN=LEFT>String overflow</P>
181
 * 		</TD>
182
 * 		<TD WIDTH=401 BGCOLOR="#ffffff">
183
 * 			<P CLASS="textintable" ALIGN=LEFT><B>Compiler:</B> an identifier
184
 * 			in the formula exceeds 64 KB in size. <B>Interpreter:</B> a result
185
 * 			of a string operation exceeds 64 KB in size.</P>
186
 * 		</TD>
187
 * 	</TR>
188
 * 	<TR VALIGN=TOP>
189
 * 		<TD WIDTH=42 BGCOLOR="#ffffff">
190
 * 			<P CLASS="textintable" ALIGN=LEFT>514</P>
191
 * 		</TD>
192
 * 		<TD WIDTH=118 BGCOLOR="#ffffff">
193
 * 			<P CLASS="textintable" ALIGN=LEFT>Internal overflow</P>
194
 * 		</TD>
195
 * 		<TD WIDTH=401 BGCOLOR="#ffffff">
196
 * 			<P CLASS="textintable" ALIGN=LEFT>Sort operation attempted on too
197
 * 			much numerical data (max. 100000) or a calculation stack overflow.</P>
198
 * 		</TD>
199
 * 	</TR>
200
 * 	<TR VALIGN=TOP>
201
 * 		<TD WIDTH=42 BGCOLOR="#ffffff">
202
 * 			<P CLASS="textintable" ALIGN=LEFT>515</P>
203
 * 		</TD>
204
 * 		<TD WIDTH=118 BGCOLOR="#ffffff">
205
 * 			<P CLASS="textintable" ALIGN=LEFT>Internal syntax error</P>
206
 * 		</TD>
207
 * 		<TD WIDTH=401 BGCOLOR="#ffffff">
208
 * 			<P CLASS="textintable" ALIGN=LEFT>Not used</P>
209
 * 		</TD>
210
 * 	</TR>
211
 * 	<TR VALIGN=TOP>
212
 * 		<TD WIDTH=42 BGCOLOR="#ffffff">
213
 * 			<P CLASS="textintable" ALIGN=LEFT>516</P>
214
 * 		</TD>
215
 * 		<TD WIDTH=118 BGCOLOR="#ffffff">
216
 * 			<P CLASS="textintable" ALIGN=LEFT>Internal syntax error</P>
217
 * 		</TD>
218
 * 		<TD WIDTH=401 BGCOLOR="#ffffff">
219
 * 			<P CLASS="textintable" ALIGN=LEFT>Matrix is expected on the
220
 * 			calculation stack, but is not available.</P>
221
 * 		</TD>
222
 * 	</TR>
223
 * 	<TR VALIGN=TOP>
224
 * 		<TD WIDTH=42 BGCOLOR="#ffffff">
225
 * 			<P CLASS="textintable" ALIGN=LEFT>517</P>
226
 * 		</TD>
227
 * 		<TD WIDTH=118 BGCOLOR="#ffffff">
228
 * 			<P CLASS="textintable" ALIGN=LEFT>Internal syntax error</P>
229
 * 		</TD>
230
 * 		<TD WIDTH=401 BGCOLOR="#ffffff">
231
 * 			<P CLASS="textintable" ALIGN=LEFT>Unknown code, for example, a
232
 * 			document with a newer function is loaded in an older version that
233
 * 			does not contain the function.</P>
234
 * 		</TD>
235
 * 	</TR>
236
 * 	<TR VALIGN=TOP>
237
 * 		<TD WIDTH=42 BGCOLOR="#ffffff">
238
 * 			<P CLASS="textintable" ALIGN=LEFT>518</P>
239
 * 		</TD>
240
 * 		<TD WIDTH=118 BGCOLOR="#ffffff">
241
 * 			<P CLASS="textintable" ALIGN=LEFT>Internal syntax error</P>
242
 * 		</TD>
243
 * 		<TD WIDTH=401 BGCOLOR="#ffffff">
244
 * 			<P CLASS="textintable" ALIGN=LEFT>Variable is not available</P>
245
 * 		</TD>
246
 * 	</TR>
247
 * 	<TR VALIGN=TOP>
248
 * 		<TD WIDTH=42 BGCOLOR="#ffffff">
249
 * 			<P CLASS="textintable" ALIGN=LEFT>519</P>
250
 * 		</TD>
251
 * 		<TD WIDTH=118 BGCOLOR="#ffffff">
252
 * 			<P CLASS="textintable" ALIGN=LEFT>No result (#VALUE is in the cell
253
 * 			rather than Err:519!)</P>
254
 * 		</TD>
255
 * 		<TD WIDTH=401 BGCOLOR="#ffffff">
256
 * 			<P CLASS="textintable" ALIGN=LEFT>Formula yields a value that does
257
 * 			not corresponds to the definition, or a cell that is referenced in
258
 * 			the formula contains text instead of a number.</P>
259
 * 		</TD>
260
 * 	</TR>
261
 * 	<TR VALIGN=TOP>
262
 * 		<TD WIDTH=42 BGCOLOR="#ffffff">
263
 * 			<P CLASS="textintable" ALIGN=LEFT>520</P>
264
 * 		</TD>
265
 * 		<TD WIDTH=118 BGCOLOR="#ffffff">
266
 * 			<P CLASS="textintable" ALIGN=LEFT>Internal syntax error</P>
267
 * 		</TD>
268
 * 		<TD WIDTH=401 BGCOLOR="#ffffff">
269
 * 			<P CLASS="textintable" ALIGN=LEFT>Compiler creates an unknown
270
 * 			compiler code.</P>
271
 * 		</TD>
272
 * 	</TR>
273
 * 	<TR VALIGN=TOP>
274
 * 		<TD WIDTH=42 BGCOLOR="#ffffff">
275
 * 			<P CLASS="textintable" ALIGN=LEFT>521</P>
276
 * 		</TD>
277
 * 		<TD WIDTH=118 BGCOLOR="#ffffff">
278
 * 			<P CLASS="textintable" ALIGN=LEFT>Internal syntax error</P>
279
 * 		</TD>
280
 * 		<TD WIDTH=401 BGCOLOR="#ffffff">
281
 * 			<P CLASS="textintable" ALIGN=LEFT>No result.</P>
282
 * 		</TD>
283
 * 	</TR>
284
 * 	<TR VALIGN=TOP>
285
 * 		<TD WIDTH=42 BGCOLOR="#ffffff">
286
 * 			<P CLASS="textintable" ALIGN=LEFT>522</P>
287
 * 		</TD>
288
 * 		<TD WIDTH=118 BGCOLOR="#ffffff">
289
 * 			<P CLASS="textintable" ALIGN=LEFT>Circular reference</P>
290
 * 		</TD>
291
 * 		<TD WIDTH=401 BGCOLOR="#ffffff">
292
 * 			<P CLASS="textintable" ALIGN=LEFT>Formula refers directly or
293
 * 			indirectly to itself and the iterations option is not selected
294
 * 			under Tools - Options - Table Document - Calculate.</P>
295
 * 		</TD>
296
 * 	</TR>
297
 * 	<TR VALIGN=TOP>
298
 * 		<TD WIDTH=42 BGCOLOR="#ffffff">
299
 * 			<P CLASS="textintable" ALIGN=LEFT>523</P>
300
 * 		</TD>
301
 * 		<TD WIDTH=118 BGCOLOR="#ffffff">
302
 * 			<P CLASS="textintable" ALIGN=LEFT>The calculation procedure does
303
 * 			not converge</P>
304
 * 		</TD>
305
 * 		<TD WIDTH=401 BGCOLOR="#ffffff">
306
 * 			<P CLASS="textintable" ALIGN=LEFT>Financial statistics function
307
 * 			missed a targeted value or iterations of circular references do
308
 * 			not reach the minimum change within the maximum steps that are
309
 * 			set.</P>
310
 * 		</TD>
311
 * 	</TR>
312
 * 	<TR VALIGN=TOP>
313
 * 		<TD WIDTH=42 BGCOLOR="#ffffff">
314
 * 			<P CLASS="textintable" ALIGN=LEFT>524</P>
315
 * 		</TD>
316
 * 		<TD WIDTH=118 BGCOLOR="#ffffff">
317
 * 			<P CLASS="textintable" ALIGN=LEFT><A NAME="kw66944_5"></A><A NAME="kw66944_4"></A>
318
 * 			invalid references (instead of Err:524 cell contains #REF)</P>
319
 * 		</TD>
320
 * 		<TD WIDTH=401 BGCOLOR="#ffffff">
321
 * 			<P CLASS="textintable" ALIGN=LEFT><B>Compiler:</B> a column or row
322
 * 			description name could not be resolved. <B>Interpreter:</B> in a
323
 * 			formula, the column, row, or sheet that contains a referenced cell
324
 * 			is missing.</P>
325
 * 		</TD>
326
 * 	</TR>
327
 * 	<TR VALIGN=TOP>
328
 * 		<TD WIDTH=42 BGCOLOR="#ffffff">
329
 * 			<P CLASS="textintable" ALIGN=LEFT>525</P>
330
 * 		</TD>
331
 * 		<TD WIDTH=118 BGCOLOR="#ffffff">
332
 * 			<P CLASS="textintable" ALIGN=LEFT><A NAME="kw66944_3"></A><A NAME="kw66944_2"></A>
333
 * 			invalid names (instead of Err:525 cell contains #NAME?)</P>
334
 * 		</TD>
335
 * 		<TD WIDTH=401 BGCOLOR="#ffffff">
336
 * 			<P CLASS="textintable" ALIGN=LEFT>An identifier could not be
337
 * 			evaluated, for example, no valid reference, no valid domain name,
338
 * 			no column/row label, no macro, incorrect decimal divider, add-in
339
 * 			not found.</P>
340
 * 		</TD>
341
 * 	</TR>
342
 * 	<TR VALIGN=TOP>
343
 * 		<TD WIDTH=42 BGCOLOR="#ffffff">
344
 * 			<P CLASS="textintable" ALIGN=LEFT>526</P>
345
 * 		</TD>
346
 * 		<TD WIDTH=118 BGCOLOR="#ffffff">
347
 * 			<P CLASS="textintable" ALIGN=LEFT>Internal syntax error</P>
348
 * 		</TD>
349
 * 		<TD WIDTH=401 BGCOLOR="#ffffff">
350
 * 			<P CLASS="textintable" ALIGN=LEFT>Obsolete, no longer used, but
351
 * 			could come from old documents if the result is a formula from a
352
 * 			domain.</P>
353
 * 		</TD>
354
 * 	</TR>
355
 * 	<TR VALIGN=TOP>
356
 * 		<TD WIDTH=42 BGCOLOR="#ffffff">
357
 * 			<P CLASS="textintable" ALIGN=LEFT>527</P>
358
 * 		</TD>
359
 * 		<TD WIDTH=118 BGCOLOR="#ffffff">
360
 * 			<P CLASS="textintable" ALIGN=LEFT>Internal overflow</P>
361
 * 		</TD>
362
 * 		<TD WIDTH=401 BGCOLOR="#ffffff">
363
 * 			<P CLASS="textintable" ALIGN=LEFT><B>Interpreter: </B>References,
364
 * 			such as when a cell references a cell, are too encapsulated.</P>
365
 * 		</TD>
366
 * 	</TR>
367
 * </TABLE>
368
 * 
369
 */
370
public class ErrorEval implements ValueEval {
371
372
    private int errorCode;
373
    
374
    // Oo std error codes
375
    public static final ErrorEval ERROR_501 = new ErrorEval(501);
376
    public static final ErrorEval ERROR_502 = new ErrorEval(502);
377
    public static final ErrorEval ERROR_503 = new ErrorEval(503);
378
    public static final ErrorEval ERROR_504 = new ErrorEval(504);
379
    public static final ErrorEval ERROR_505 = new ErrorEval(505);
380
    public static final ErrorEval ERROR_506 = new ErrorEval(506);
381
    public static final ErrorEval ERROR_507 = new ErrorEval(507);
382
    public static final ErrorEval ERROR_508 = new ErrorEval(508);
383
    public static final ErrorEval ERROR_509 = new ErrorEval(509);
384
    public static final ErrorEval ERROR_510 = new ErrorEval(510);
385
    public static final ErrorEval ERROR_511 = new ErrorEval(511);
386
    public static final ErrorEval ERROR_512 = new ErrorEval(512);
387
    public static final ErrorEval ERROR_513 = new ErrorEval(513);
388
    public static final ErrorEval ERROR_514 = new ErrorEval(514);
389
    public static final ErrorEval ERROR_515 = new ErrorEval(515);
390
    public static final ErrorEval ERROR_516 = new ErrorEval(516);
391
    public static final ErrorEval ERROR_517 = new ErrorEval(517);
392
    public static final ErrorEval ERROR_518 = new ErrorEval(518);
393
    public static final ErrorEval ERROR_519 = new ErrorEval(519);
394
    public static final ErrorEval ERROR_520 = new ErrorEval(520);
395
    public static final ErrorEval ERROR_521 = new ErrorEval(521);
396
    public static final ErrorEval ERROR_522 = new ErrorEval(522);
397
    public static final ErrorEval ERROR_523 = new ErrorEval(523);
398
    public static final ErrorEval ERROR_524 = new ErrorEval(524);
399
    public static final ErrorEval ERROR_525 = new ErrorEval(525);
400
    public static final ErrorEval ERROR_526 = new ErrorEval(526);
401
    public static final ErrorEval ERROR_527 = new ErrorEval(527);
402
    public static final ErrorEval INVALID_NAME = ERROR_525;
403
    public static final ErrorEval INVALID_VALUE = ERROR_519;
404
405
    
406
    // Non std error codes
407
    public static final ErrorEval ERROR_UNKNOWN = new ErrorEval(-20);
408
    public static final ErrorEval FUNCTION_NOT_IMPLEMENTED = new ErrorEval(-30);
409
    
410
    
411
    private ErrorEval(int errorCode) {
412
        this.errorCode = errorCode;
413
    }
414
    
415
    public int getErrorCode() {
416
        return errorCode;
417
    }
418
    
419
    public String getStringValue() {
420
        return "Err:"+Integer.toString(errorCode);
421
    }
422
423
}
(-)org/apache/poi/hssf/record/formula/eval/Eval.java (+14 lines)
Added Link Here
1
/*
2
 * Created on May 8, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.eval;
6
7
/**
8
 * @author amolweb &lt; amolweb at ya hoo dot com &gt;
9
 *
10
 */
11
public interface Eval {
12
13
    
14
}
(-)org/apache/poi/hssf/record/formula/eval/FuncVarEval.java (+56 lines)
Added Link Here
1
/*
2
 * Created on May 8, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.eval;
6
7
import org.apache.poi.hssf.record.formula.AbstractFunctionPtg;
8
import org.apache.poi.hssf.record.formula.Ptg;
9
import org.apache.poi.hssf.record.formula.functions.Function;
10
11
/**
12
 * @author amolweb &lt; amolweb at ya hoo dot com &gt;
13
 *
14
 */
15
public class FuncVarEval extends FunctionEval {
16
17
    private AbstractFunctionPtg delegate;
18
    
19
    public FuncVarEval(Ptg funcPtg) {
20
        delegate = (AbstractFunctionPtg) funcPtg;
21
    }
22
    
23
    /* (non-Javadoc)
24
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#evaluate(org.apache.poi.hssf.record.formula.eval.Eval[])
25
     */
26
    public Eval evaluate(Eval[] operands) {
27
        Eval retval = null;
28
		Function f = getFunction();
29
		if (f!=null)
30
		    retval = f.evaluate(operands);
31
		else 
32
		    retval = ErrorEval.FUNCTION_NOT_IMPLEMENTED;
33
		return retval;
34
    }
35
    
36
    /* (non-Javadoc)
37
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#getNumberOfOperands()
38
     */
39
    public int getNumberOfOperands() {
40
        return delegate.getNumberOfOperands();
41
    }
42
    
43
    /* (non-Javadoc)
44
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#getType()
45
     */
46
    public int getType() {
47
        return delegate.getType();
48
    }
49
    
50
    /* (non-Javadoc)
51
     * @see org.apache.poi.hssf.record.formula.eval.FunctionEval#getFunctionIndex()
52
     */
53
    public short getFunctionIndex() {
54
        return delegate.getFunctionIndex();
55
    }
56
}
(-)org/apache/poi/hssf/record/formula/eval/FunctionEval.java (+377 lines)
Added Link Here
1
/*
2
 * Created on May 8, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.eval;
6
7
import org.apache.poi.hssf.record.formula.functions.*;
8
9
/**
10
 * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
11
 *
12
 */
13
public abstract class FunctionEval implements OperationEval {
14
    protected static Function[] functions = produceFunctions();
15
    public Function getFunction() {
16
    	short fidx = getFunctionIndex();
17
    	return functions[fidx];
18
    }
19
    public abstract short getFunctionIndex();
20
21
    private static Function[] produceFunctions() {
22
        Function[] retval = new Function[368];
23
    	retval[0]  = new Count();	//	COUNT
24
    	retval[1]  = null;	//	specialflag
25
    	retval[2]  = new IsNa();	//	ISNA
26
    	retval[3]  = new IsError();	//	ISERROR
27
    	retval[4]  = new Sum();	//	SUM
28
    	retval[5]  = new Average();	//	AVERAGE
29
    	retval[6]  = new Min();	//	MIN
30
    	retval[7]  = new Max();	//	MAX
31
    	retval[8]  = new Row();	//	ROW
32
    	retval[9]  = new Column();	//	COLUMN
33
    	retval[10] = new Na();	//	NA
34
    	retval[11] = new Npv();	//	NPV
35
    	retval[12] = new Stdev();	//	STDEV
36
    	retval[13] = new Dollar();	//	DOLLAR
37
    	retval[14] = new Fixed();	//	FIXED
38
    	retval[15] = new Sin();	//	SIN
39
    	retval[16] = new Cos();	//	COS
40
    	retval[17] = new Tan();	//	TAN
41
    	retval[18] = new Atan();	//	ATAN
42
    	retval[19] = new Pi();	//	PI
43
    	retval[20] = new Sqrt();	//	SQRT
44
    	retval[21] = new Exp();	//	EXP
45
    	retval[22] = new Ln();	//	LN
46
    	retval[23] = new Log10();	//	LOG10
47
    	retval[24] = new Abs();	//	ABS
48
    	retval[25] = new Int();	//	INT
49
    	retval[26] = new Sign();	//	SIGN
50
    	retval[27] = new Round();	//	ROUND
51
        retval[28] = new Lookup();  //  LOOKUP
52
        retval[29] = new Index();   //  INDEX
53
        retval[30] = new Rept();    //  REPT
54
        retval[31] = new Mid(); //  MID
55
        retval[32] = new Len(); //  LEN
56
        retval[33] = new Value();   //  VALUE
57
        retval[34] = new True();    //  TRUE
58
        retval[35] = new False();   //  FALSE
59
        retval[36] = new And(); //  AND
60
        retval[37] = new Or();  //  OR
61
        retval[38] = new Not(); //  NOT
62
        retval[39] = new Mod(); //  MOD
63
        retval[40] = new Dcount();  //  DCOUNT
64
        retval[41] = new Dsum();    //  DSUM
65
        retval[42] = new Daverage();    //  DAVERAGE
66
        retval[43] = new Dmin();    //  DMIN
67
        retval[44] = new Dmax();    //  DMAX
68
        retval[45] = new Dstdev();  //  DSTDEV
69
        retval[46] = new Var(); //  VAR
70
        retval[47] = new Dvar();    //  DVAR
71
        retval[48] = new Text();    //  TEXT
72
        retval[49] = new Linest();  //  LINEST
73
        retval[50] = new Trend();   //  TREND
74
        retval[51] = new Logest();  //  LOGEST
75
        retval[52] = new Growth();  //  GROWTH
76
        retval[53] = new Goto();    //  GOTO
77
        retval[54] = new Halt();    //  HALT
78
        retval[55] = new Pv();  //  PV
79
        retval[56] = new Fv();  //  FV
80
        retval[57] = new Nper();    //  NPER
81
        retval[58] = new Pmt(); //  PMT
82
        retval[59] = new Rate();    //  RATE
83
        retval[60] = new Mirr();    //  MIRR
84
        retval[61] = new Irr(); //  IRR
85
        retval[62] = new Rand();    //  RAND
86
        retval[63] = new Match();   //  MATCH
87
        retval[64] = new Date();    //  DATE
88
        retval[65] = new Time();    //  TIME
89
        retval[66] = new Day(); //  DAY
90
        retval[67] = new Month();   //  MONTH
91
        retval[68] = new Year();    //  YEAR
92
        retval[69] = new Weekday(); //  WEEKDAY
93
        retval[70] = new Hour();    //  HOUR
94
        retval[71] = new Minute();  //  MINUTE
95
        retval[72] = new Second();  //  SECOND
96
        retval[73] = new Now(); //  NOW
97
        retval[74] = new Areas();   //  AREAS
98
        retval[75] = new Rows();    //  ROWS
99
        retval[76] = new Columns(); //  COLUMNS
100
        retval[77] = new Offset();  //  OFFSET
101
        retval[78] = new Absref();  //  ABSREF
102
        retval[79] = new Relref();  //  RELREF
103
        retval[80] = new Argument();    //  ARGUMENT
104
        retval[81] = new Search();  //  SEARCH
105
        retval[82] = new Transpose();   //  TRANSPOSE
106
        retval[83] = new org.apache.poi.hssf.record.formula.functions.Error();   //  ERROR
107
        retval[84] = new Step();    //  STEP
108
        retval[85] = new Type();    //  TYPE
109
        retval[86] = new Echo();    //  ECHO
110
        retval[87] = new Setname(); //  SETNAME
111
        retval[88] = new Caller();  //  CALLER
112
        retval[89] = new Deref();   //  DEREF
113
        retval[90] = new Windows(); //  WINDOWS
114
        retval[91] = new Series();  //  SERIES
115
        retval[92] = new Documents();   //  DOCUMENTS
116
        retval[93] = new Activecell();  //  ACTIVECELL
117
        retval[94] = new Selection();   //  SELECTION
118
        retval[95] = new Result();  //  RESULT
119
        retval[96] = new Atan2();   //  ATAN2
120
        retval[97] = new Asin();    //  ASIN
121
        retval[98] = new Acos();    //  ACOS
122
        retval[99] = new Choose();  //  CHOOSE
123
        retval[100] = new Hlookup();    //  HLOOKUP
124
        retval[101] = new Vlookup();    //  VLOOKUP
125
        retval[102] = new Links();  //  LINKS
126
        retval[103] = new Input();  //  INPUT
127
        retval[104] = new Isref();  //  ISREF
128
        retval[105] = new Getformula(); //  GETFORMULA
129
        retval[106] = new Getname();    //  GETNAME
130
        retval[107] = new Setvalue();   //  SETVALUE
131
        retval[108] = new Log();    //  LOG
132
        retval[109] = new Exec();   //  EXEC
133
        retval[110] = new Char();   //  CHAR
134
        retval[111] = new Lower();  //  LOWER
135
        retval[112] = new Upper();  //  UPPER
136
        retval[113] = new Proper(); //  PROPER
137
        retval[114] = new Left();   //  LEFT
138
        retval[115] = new Right();  //  RIGHT
139
        retval[116] = new Exact();  //  EXACT
140
        retval[117] = new Trim();   //  TRIM
141
        retval[118] = new Replace();    //  REPLACE
142
        retval[119] = new Substitute(); //  SUBSTITUTE
143
        retval[120] = new Code();   //  CODE
144
        retval[121] = new Names();  //  NAMES
145
        retval[122] = new Directory();  //  DIRECTORY
146
        retval[123] = new Find();   //  FIND
147
        retval[124] = new Cell();   //  CELL
148
        retval[125] = new Iserr();  //  ISERR
149
        retval[126] = new Istext(); //  ISTEXT
150
        retval[127] = new Isnumber();   //  ISNUMBER
151
        retval[128] = new Isblank();    //  ISBLANK
152
        retval[129] = new T();  //  T
153
        retval[130] = new N();  //  N
154
        retval[131] = new Fopen();  //  FOPEN
155
        retval[132] = new Fclose(); //  FCLOSE
156
        retval[133] = new Fsize();  //  FSIZE
157
        retval[134] = new Freadln();    //  FREADLN
158
        retval[135] = new Fread();  //  FREAD
159
        retval[136] = new Fwriteln();   //  FWRITELN
160
        retval[137] = new Fwrite(); //  FWRITE
161
        retval[138] = new Fpos();   //  FPOS
162
        retval[139] = new Datevalue();  //  DATEVALUE
163
        retval[140] = new Timevalue();  //  TIMEVALUE
164
        retval[141] = new Sln();    //  SLN
165
        retval[142] = new Syd();    //  SYD
166
        retval[143] = new Ddb();    //  DDB
167
        retval[144] = new Getdef(); //  GETDEF
168
        retval[145] = new Reftext();    //  REFTEXT
169
        retval[146] = new Textref();    //  TEXTREF
170
        retval[147] = new Indirect();   //  INDIRECT
171
        retval[148] = new Register();   //  REGISTER
172
        retval[149] = new Call();   //  CALL
173
        retval[150] = new Addbar(); //  ADDBAR
174
        retval[151] = new Addmenu();    //  ADDMENU
175
        retval[152] = new Addcommand(); //  ADDCOMMAND
176
        retval[153] = new Enablecommand();  //  ENABLECOMMAND
177
        retval[154] = new Checkcommand();   //  CHECKCOMMAND
178
        retval[155] = new Renamecommand();  //  RENAMECOMMAND
179
        retval[156] = new Showbar();    //  SHOWBAR
180
        retval[157] = new Deletemenu(); //  DELETEMENU
181
        retval[158] = new Deletecommand();  //  DELETECOMMAND
182
        retval[159] = new Getchartitem();   //  GETCHARTITEM
183
        retval[160] = new Dialogbox();  //  DIALOGBOX
184
        retval[161] = new Clean();  //  CLEAN
185
        retval[162] = new Mdeterm();    //  MDETERM
186
        retval[163] = new Minverse();   //  MINVERSE
187
        retval[164] = new Mmult();  //  MMULT
188
        retval[165] = new Files();  //  FILES
189
        retval[166] = new Ipmt();   //  IPMT
190
        retval[167] = new Ppmt();   //  PPMT
191
        retval[168] = new Counta(); //  COUNTA
192
        retval[169] = new Cancelkey();  //  CANCELKEY
193
        retval[170] = new Initiate();   //  INITIATE
194
        retval[171] = new Request();    //  REQUEST
195
        retval[172] = new Poke();   //  POKE
196
        retval[173] = new Execute();    //  EXECUTE
197
        retval[174] = new Terminate();  //  TERMINATE
198
        retval[175] = new Restart();    //  RESTART
199
        retval[176] = new Help();   //  HELP
200
        retval[177] = new Getbar(); //  GETBAR
201
        retval[178] = new Product();    //  PRODUCT
202
        retval[179] = new Fact();   //  FACT
203
        retval[180] = new Getcell();    //  GETCELL
204
        retval[181] = new Getworkspace();   //  GETWORKSPACE
205
        retval[182] = new Getwindow();  //  GETWINDOW
206
        retval[183] = new Getdocument();    //  GETDOCUMENT
207
        retval[184] = new Dproduct();   //  DPRODUCT
208
        retval[185] = new Isnontext();  //  ISNONTEXT
209
        retval[186] = new Getnote();    //  GETNOTE
210
        retval[187] = new Note();   //  NOTE
211
        retval[188] = new Stdevp(); //  STDEVP
212
        retval[189] = new Varp();   //  VARP
213
        retval[190] = new Dstdevp();    //  DSTDEVP
214
        retval[191] = new Dvarp();  //  DVARP
215
        retval[192] = new Trunc();  //  TRUNC
216
        retval[193] = new Islogical();  //  ISLOGICAL
217
        retval[194] = new Dcounta();    //  DCOUNTA
218
        retval[195] = new Deletebar();  //  DELETEBAR
219
        retval[196] = new Unregister(); //  UNREGISTER
220
        retval[197] = new Usdollar();   //  USDOLLAR
221
        retval[198] = new Findb();  //  FINDB
222
        retval[199] = new Searchb();    //  SEARCHB
223
        retval[200] = new Replaceb();   //  REPLACEB
224
        retval[201] = new Leftb();  //  LEFTB
225
        retval[202] = new Rightb(); //  RIGHTB
226
        retval[203] = new Midb();   //  MIDB
227
        retval[204] = new Lenb();   //  LENB
228
        retval[205] = new Roundup();    //  ROUNDUP
229
        retval[206] = new Rounddown();  //  ROUNDDOWN
230
        retval[207] = new Asc();    //  ASC
231
        retval[208] = new Dbcs();   //  DBCS
232
        retval[209] = new Rank();   //  RANK
233
        retval[210] = new Address();    //  ADDRESS
234
        retval[211] = new Days360();    //  DAYS360
235
        retval[212] = new Today();  //  TODAY
236
        retval[213] = new Vdb();    //  VDB
237
        retval[214] = new Median(); //  MEDIAN
238
        retval[215] = new Sumproduct(); //  SUMPRODUCT
239
        retval[216] = new Sinh();   //  SINH
240
        retval[217] = new Cosh();   //  COSH
241
        retval[218] = new Tanh();   //  TANH
242
        retval[219] = new Asinh();  //  ASINH
243
        retval[220] = new Acosh();  //  ACOSH
244
        retval[221] = new Atanh();  //  ATANH
245
        retval[222] = new Dget();   //  DGET
246
        retval[223] = new Createobject();   //  CREATEOBJECT
247
        retval[224] = new Volatile();   //  VOLATILE
248
        retval[225] = new Lasterror();  //  LASTERROR
249
        retval[226] = new Customundo(); //  CUSTOMUNDO
250
        retval[227] = new Customrepeat();   //  CUSTOMREPEAT
251
        retval[228] = new Formulaconvert(); //  FORMULACONVERT
252
        retval[229] = new Getlinkinfo();    //  GETLINKINFO
253
        retval[230] = new Textbox();    //  TEXTBOX
254
        retval[231] = new Info();   //  INFO
255
        retval[232] = new Group();  //  GROUP
256
        retval[233] = new Getobject();  //  GETOBJECT
257
        retval[234] = new Db(); //  DB
258
        retval[235] = new Pause();  //  PAUSE
259
        retval[236] = new Resume(); //  RESUME
260
        retval[237] = new Frequency();  //  FREQUENCY
261
        retval[238] = new Addtoolbar(); //  ADDTOOLBAR
262
        retval[239] = new Deletetoolbar();  //  DELETETOOLBAR
263
        retval[240] = new Externalflag();   //  externalflag
264
        retval[241] = new Resettoolbar();   //  RESETTOOLBAR
265
        retval[242] = new Evaluate();   //  EVALUATE
266
        retval[243] = new Gettoolbar(); //  GETTOOLBAR
267
        retval[244] = new Gettool();    //  GETTOOL
268
        retval[245] = new Spellingcheck();  //  SPELLINGCHECK
269
        retval[246] = new Errortype();  //  ERRORTYPE
270
        retval[247] = new Apptitle();   //  APPTITLE
271
        retval[248] = new Windowtitle();    //  WINDOWTITLE
272
        retval[249] = new Savetoolbar();    //  SAVETOOLBAR
273
        retval[250] = new Enabletool(); //  ENABLETOOL
274
        retval[251] = new Presstool();  //  PRESSTOOL
275
        retval[252] = new Registerid(); //  REGISTERID
276
        retval[253] = new Getworkbook();    //  GETWORKBOOK
277
        retval[254] = new Avedev(); //  AVEDEV
278
        retval[255] = new Betadist();   //  BETADIST
279
        retval[256] = new Gammaln();    //  GAMMALN
280
        retval[257] = new Betainv();    //  BETAINV
281
        retval[258] = new Binomdist();  //  BINOMDIST
282
        retval[259] = new Chidist();    //  CHIDIST
283
        retval[260] = new Chiinv(); //  CHIINV
284
        retval[261] = new Combin(); //  COMBIN
285
        retval[262] = new Confidence(); //  CONFIDENCE
286
        retval[263] = new Critbinom();  //  CRITBINOM
287
        retval[264] = new Even();   //  EVEN
288
        retval[265] = new Expondist();  //  EXPONDIST
289
        retval[266] = new Fdist();  //  FDIST
290
        retval[267] = new Finv();   //  FINV
291
        retval[268] = new Fisher(); //  FISHER
292
        retval[269] = new Fisherinv();  //  FISHERINV
293
        retval[270] = new Floor();  //  FLOOR
294
        retval[271] = new Gammadist();  //  GAMMADIST
295
        retval[272] = new Gammainv();   //  GAMMAINV
296
        retval[273] = new Ceiling();    //  CEILING
297
        retval[274] = new Hypgeomdist();    //  HYPGEOMDIST
298
        retval[275] = new Lognormdist();    //  LOGNORMDIST
299
        retval[276] = new Loginv(); //  LOGINV
300
        retval[277] = new Negbinomdist();   //  NEGBINOMDIST
301
        retval[278] = new Normdist();   //  NORMDIST
302
        retval[279] = new Normsdist();  //  NORMSDIST
303
        retval[280] = new Norminv();    //  NORMINV
304
        retval[281] = new Normsinv();   //  NORMSINV
305
        retval[282] = new Standardize();    //  STANDARDIZE
306
        retval[283] = new Odd();    //  ODD
307
        retval[284] = new Permut(); //  PERMUT
308
        retval[285] = new Poisson();    //  POISSON
309
        retval[286] = new Tdist();  //  TDIST
310
        retval[287] = new Weibull();    //  WEIBULL
311
        retval[288] = new Sumxmy2();    //  SUMXMY2
312
        retval[289] = new Sumx2my2();   //  SUMX2MY2
313
        retval[290] = new Sumx2py2();   //  SUMX2PY2
314
        retval[291] = new Chitest();    //  CHITEST
315
        retval[292] = new Correl(); //  CORREL
316
        retval[293] = new Covar();  //  COVAR
317
        retval[294] = new Forecast();   //  FORECAST
318
        retval[295] = new Ftest();  //  FTEST
319
        retval[296] = new Intercept();  //  INTERCEPT
320
        retval[297] = new Pearson();    //  PEARSON
321
        retval[298] = new Rsq();    //  RSQ
322
        retval[299] = new Steyx();  //  STEYX
323
        retval[300] = new Slope();  //  SLOPE
324
        retval[301] = new Ttest();  //  TTEST
325
        retval[302] = new Prob();   //  PROB
326
        retval[303] = new Devsq();  //  DEVSQ
327
        retval[304] = new Geomean();    //  GEOMEAN
328
        retval[305] = new Harmean();    //  HARMEAN
329
        retval[306] = new Sumsq();  //  SUMSQ
330
        retval[307] = new Kurt();   //  KURT
331
        retval[308] = new Skew();   //  SKEW
332
        retval[309] = new Ztest();  //  ZTEST
333
        retval[310] = new Large();  //  LARGE
334
        retval[311] = new Small();  //  SMALL
335
        retval[312] = new Quartile();   //  QUARTILE
336
        retval[313] = new Percentile(); //  PERCENTILE
337
        retval[314] = new Percentrank();    //  PERCENTRANK
338
        retval[315] = new Mode();   //  MODE
339
        retval[316] = new Trimmean();   //  TRIMMEAN
340
        retval[317] = new Tinv();   //  TINV
341
        retval[318] = new Moviecommand();   //  MOVIECOMMAND
342
        retval[319] = new Getmovie();   //  GETMOVIE
343
        retval[320] = new Concatenate();    //  CONCATENATE
344
        retval[321] = new Power();  //  POWER
345
        retval[322] = new Pivotadddata();   //  PIVOTADDDATA
346
        retval[323] = new Getpivottable();  //  GETPIVOTTABLE
347
        retval[324] = new Getpivotfield();  //  GETPIVOTFIELD
348
        retval[325] = new Getpivotitem();   //  GETPIVOTITEM
349
        retval[326] = new Radians();    //  RADIANS
350
        retval[327] = new Degrees();    //  DEGREES
351
        retval[328] = new Subtotal();   //  SUBTOTAL
352
        retval[329] = new Sumif();  //  SUMIF
353
        retval[330] = new Countif();    //  COUNTIF
354
        retval[331] = new Countblank(); //  COUNTBLANK
355
        retval[332] = new Scenarioget();    //  SCENARIOGET
356
        retval[333] = new Optionslistsget();    //  OPTIONSLISTSGET
357
        retval[334] = new Ispmt();  //  ISPMT
358
        retval[335] = new Datedif();    //  DATEDIF
359
        retval[336] = new Datestring(); //  DATESTRING
360
        retval[337] = new Numberstring();   //  NUMBERSTRING
361
        retval[338] = new Roman();  //  ROMAN
362
        retval[339] = new Opendialog(); //  OPENDIALOG
363
        retval[340] = new Savedialog(); //  SAVEDIALOG
364
        retval[341] = new Viewget();    //  VIEWGET
365
        retval[342] = new Getpivotdata();   //  GETPIVOTDATA
366
        retval[343] = new Hyperlink();  //  HYPERLINK
367
        retval[344] = new Phonetic();   //  PHONETIC
368
        retval[345] = new Averagea();   //  AVERAGEA
369
        retval[346] = new Maxa();   //  MAXA
370
        retval[347] = new Mina();   //  MINA
371
        retval[348] = new Stdevpa();    //  STDEVPA
372
        retval[349] = new Varpa();  //  VARPA
373
        retval[350] = new Stdeva(); //  STDEVA
374
        retval[351] = new Vara();   //  VARA
375
    	return retval;
376
    }
377
}
(-)org/apache/poi/hssf/record/formula/eval/GreaterEqualEval.java (+167 lines)
Added Link Here
1
/*
2
 * Created on May 8, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.eval;
6
7
import org.apache.poi.hssf.record.formula.GreaterEqualPtg;
8
import org.apache.poi.hssf.record.formula.Ptg;
9
10
/**
11
 * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
12
 *
13
 */
14
public class GreaterEqualEval implements OperationEval {
15
16
    private GreaterEqualPtg delegate;
17
    
18
    public GreaterEqualEval(Ptg ptg) {
19
        this.delegate = (GreaterEqualPtg) ptg;
20
    }
21
    
22
    /* (non-Javadoc)
23
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#evaluate(org.apache.poi.hssf.record.formula.eval.Eval[])
24
     */
25
    public Eval evaluate(Eval[] operands) {
26
        boolean b = false;
27
        double d0 = 0;
28
        double d1 = 0;
29
        String s0 = null;
30
        String s1 = null;
31
        ValueEval retval = null;
32
        if (operands.length >= 2) { // ignore >2 operands
33
            if (operands[0] instanceof NumericValueEval) {
34
                NumericValueEval ne = (NumericValueEval) operands[0];
35
                d0 = ne.getNumberValue();
36
            }
37
            else if (operands[0] instanceof RefEval) {
38
                RefEval re = (RefEval) operands[0];
39
                ValueEval ve = re.getInnerValueEval();
40
                if (ve instanceof NumericValueEval) {
41
                    NumericValueEval ne = (NumericValueEval) ve;
42
                    d0 = ne.getNumberValue();
43
                }
44
                else if (ve instanceof StringValueEval) {
45
                    StringValueEval se = (StringValueEval) ve;
46
                    s0 = se.getStringValue();
47
                }
48
            }
49
            // Oo does some weird things here.
50
            // ...works fine for row area, conks out for col/row-col area
51
            // Excel surprisingly does well for row & col, conks out
52
            // ...for row-col area.
53
            else if (operands[0] instanceof AreaEval) { 
54
                AreaEval ae = (AreaEval) operands[0];
55
                short frow = ae.getFirstRow();
56
                short lrow = ae.getLastRow();
57
                short fcol = ae.getFirstColumn();
58
                short lcol = ae.getLastColumn();
59
                if (frow == lrow || fcol == lcol) {
60
	                ValueEval ve = ae.getValues()[0];
61
	                if (ve instanceof NumericValueEval) {
62
	                    NumericValueEval ne = (NumericValueEval) ve;
63
	                    d0 = ne.getNumberValue();
64
	                }
65
	                else if (ve instanceof StringValueEval) {
66
	                    StringValueEval se = (StringValueEval) ve;
67
	                    s0 = se.getStringValue();
68
	                }
69
                }
70
                else {
71
                    retval = ErrorEval.INVALID_VALUE;
72
                }
73
            }
74
            
75
            // we're only done with the first operand by now...
76
            
77
            if (operands[1] instanceof NumericValueEval) {
78
                NumericValueEval ne = (NumericValueEval) operands[1];
79
                d1 = ne.getNumberValue();
80
            }
81
            else if (operands[1] instanceof RefEval) {
82
                RefEval re = (RefEval) operands[1];
83
                ValueEval ve = re.getInnerValueEval();
84
                if (ve instanceof NumericValueEval) {
85
                    NumericValueEval ne = (NumericValueEval) ve;
86
                    d1 = ne.getNumberValue();
87
                }
88
                else if (ve instanceof StringValueEval) {
89
                    StringValueEval se = (StringValueEval) ve;
90
                    s1 = se.getStringValue();
91
                }
92
            }
93
            // Oo does some weird things here.
94
            // ...works fine for row area, conks out for col/row-col area
95
            // Excel surprisingly does well for row & col, conks out
96
            // ...for row-col area.
97
            else if (operands[1] instanceof AreaEval) { 
98
                AreaEval ae = (AreaEval) operands[1];
99
                short frow = ae.getFirstRow();
100
                short lrow = ae.getLastRow();
101
                short fcol = ae.getFirstColumn();
102
                short lcol = ae.getLastColumn();
103
                if (frow == lrow || fcol == lcol) {
104
	                ValueEval ve = ae.getValues()[1];
105
	                if (ve instanceof NumericValueEval) {
106
	                    NumericValueEval ne = (NumericValueEval) ve;
107
	                    d1 = ne.getNumberValue();
108
	                }
109
	                else if (ve instanceof StringValueEval) {
110
	                    StringValueEval se = (StringValueEval) ve;
111
	                    s1 = se.getStringValue();
112
	                }
113
                }
114
                else {
115
                    retval = ErrorEval.INVALID_VALUE;
116
                }
117
            }
118
        }
119
        else {
120
            retval = ErrorEval.ERROR_520;
121
        }
122
        
123
        
124
        // now the comparison begins *drumroll*
125
        if (retval == null) {
126
            if (s0 == null) {
127
                if (s1 == null) {
128
                    retval = (Double.isNaN(d0) || Double.isNaN(d1))
129
                    		? (ValueEval) ErrorEval.ERROR_502
130
                            : new BoolEval(d0 >= d1);
131
                }
132
                else {
133
                    retval = (Double.isNaN(d0))
134
            				? (ValueEval) ErrorEval.ERROR_502
135
                            : new BoolEval(false);
136
                }
137
            }
138
            else {
139
                if (s1 == null) {
140
                    retval = (Double.isNaN(d1))
141
                    		? (ValueEval) ErrorEval.ERROR_502
142
                            : new BoolEval(false);
143
                }
144
                else {
145
                    retval = new BoolEval(s0.compareTo(s1) >= 0);
146
                }
147
            }
148
        }
149
        
150
        return new BoolEval(b);
151
    }
152
    
153
    /* (non-Javadoc)
154
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#getNumberOfOperands()
155
     */
156
    public int getNumberOfOperands() {
157
        return delegate.getNumberOfOperands();
158
    }
159
    
160
    /* (non-Javadoc)
161
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#getType()
162
     */
163
    public int getType() {
164
        return delegate.getType();
165
    }
166
167
}
(-)org/apache/poi/hssf/record/formula/eval/GreaterThanEval.java (+167 lines)
Added Link Here
1
/*
2
 * Created on May 8, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.eval;
6
7
import org.apache.poi.hssf.record.formula.GreaterThanPtg;
8
import org.apache.poi.hssf.record.formula.Ptg;
9
10
/**
11
 * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
12
 *
13
 */
14
public class GreaterThanEval implements OperationEval {
15
16
    private GreaterThanPtg delegate;
17
    
18
    public GreaterThanEval(Ptg ptg) {
19
        this.delegate = (GreaterThanPtg) ptg;
20
    }
21
    
22
    /* (non-Javadoc)
23
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#evaluate(org.apache.poi.hssf.record.formula.eval.Eval[])
24
     */
25
    public Eval evaluate(Eval[] operands) {
26
        boolean b = false;
27
        double d0 = 0;
28
        double d1 = 0;
29
        String s0 = null;
30
        String s1 = null;
31
        ValueEval retval = null;
32
        if (operands.length >= 2) { // ignore >2 operands
33
            if (operands[0] instanceof NumericValueEval) {
34
                NumericValueEval ne = (NumericValueEval) operands[0];
35
                d0 = ne.getNumberValue();
36
            }
37
            else if (operands[0] instanceof RefEval) {
38
                RefEval re = (RefEval) operands[0];
39
                ValueEval ve = re.getInnerValueEval();
40
                if (ve instanceof NumericValueEval) {
41
                    NumericValueEval ne = (NumericValueEval) ve;
42
                    d0 = ne.getNumberValue();
43
                }
44
                else if (ve instanceof StringValueEval) {
45
                    StringValueEval se = (StringValueEval) ve;
46
                    s0 = se.getStringValue();
47
                }
48
            }
49
            // Oo does some weird things here.
50
            // ...works fine for row area, conks out for col/row-col area
51
            // Excel surprisingly does well for row & col, conks out
52
            // ...for row-col area.
53
            else if (operands[0] instanceof AreaEval) { 
54
                AreaEval ae = (AreaEval) operands[0];
55
                short frow = ae.getFirstRow();
56
                short lrow = ae.getLastRow();
57
                short fcol = ae.getFirstColumn();
58
                short lcol = ae.getLastColumn();
59
                if (frow == lrow || fcol == lcol) {
60
	                ValueEval ve = ae.getValues()[0];
61
	                if (ve instanceof NumericValueEval) {
62
	                    NumericValueEval ne = (NumericValueEval) ve;
63
	                    d0 = ne.getNumberValue();
64
	                }
65
	                else if (ve instanceof StringValueEval) {
66
	                    StringValueEval se = (StringValueEval) ve;
67
	                    s0 = se.getStringValue();
68
	                }
69
                }
70
                else {
71
                    retval = ErrorEval.INVALID_VALUE;
72
                }
73
            }
74
            
75
            // we're only done with the first operand by now...
76
            
77
            if (operands[1] instanceof NumericValueEval) {
78
                NumericValueEval ne = (NumericValueEval) operands[1];
79
                d1 = ne.getNumberValue();
80
            }
81
            else if (operands[1] instanceof RefEval) {
82
                RefEval re = (RefEval) operands[1];
83
                ValueEval ve = re.getInnerValueEval();
84
                if (ve instanceof NumericValueEval) {
85
                    NumericValueEval ne = (NumericValueEval) ve;
86
                    d1 = ne.getNumberValue();
87
                }
88
                else if (ve instanceof StringValueEval) {
89
                    StringValueEval se = (StringValueEval) ve;
90
                    s1 = se.getStringValue();
91
                }
92
            }
93
            // Oo does some weird things here.
94
            // ...works fine for row area, conks out for col/row-col area
95
            // Excel surprisingly does well for row & col, conks out
96
            // ...for row-col area.
97
            else if (operands[1] instanceof AreaEval) { 
98
                AreaEval ae = (AreaEval) operands[1];
99
                short frow = ae.getFirstRow();
100
                short lrow = ae.getLastRow();
101
                short fcol = ae.getFirstColumn();
102
                short lcol = ae.getLastColumn();
103
                if (frow == lrow || fcol == lcol) {
104
	                ValueEval ve = ae.getValues()[1];
105
	                if (ve instanceof NumericValueEval) {
106
	                    NumericValueEval ne = (NumericValueEval) ve;
107
	                    d1 = ne.getNumberValue();
108
	                }
109
	                else if (ve instanceof StringValueEval) {
110
	                    StringValueEval se = (StringValueEval) ve;
111
	                    s1 = se.getStringValue();
112
	                }
113
                }
114
                else {
115
                    retval = ErrorEval.INVALID_VALUE;
116
                }
117
            }
118
        }
119
        else {
120
            retval = ErrorEval.ERROR_520;
121
        }
122
        
123
        
124
        // now the comparison begins *drumroll*
125
        if (retval == null) {
126
            if (s0 == null) {
127
                if (s1 == null) {
128
                    retval = (Double.isNaN(d0) || Double.isNaN(d1))
129
                    		? (ValueEval) ErrorEval.ERROR_502
130
                            : new BoolEval(d0 > d1);
131
                }
132
                else {
133
                    retval = (Double.isNaN(d0))
134
            				? (ValueEval) ErrorEval.ERROR_502
135
                            : new BoolEval(false);
136
                }
137
            }
138
            else {
139
                if (s1 == null) {
140
                    retval = (Double.isNaN(d1))
141
                    		? (ValueEval) ErrorEval.ERROR_502
142
                            : new BoolEval(false);
143
                }
144
                else {
145
                    retval = new BoolEval(s0.compareTo(s1) > 0);
146
                }
147
            }
148
        }
149
        
150
        return new BoolEval(b);
151
    }
152
    
153
    /* (non-Javadoc)
154
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#getNumberOfOperands()
155
     */
156
    public int getNumberOfOperands() {
157
        return delegate.getNumberOfOperands();
158
    }
159
    
160
    /* (non-Javadoc)
161
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#getType()
162
     */
163
    public int getType() {
164
        return delegate.getType();
165
    }
166
167
}
(-)org/apache/poi/hssf/record/formula/eval/LessEqualEval.java (+167 lines)
Added Link Here
1
/*
2
 * Created on May 8, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.eval;
6
7
import org.apache.poi.hssf.record.formula.LessEqualPtg;
8
import org.apache.poi.hssf.record.formula.Ptg;
9
10
/**
11
 * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
12
 *
13
 */
14
public class LessEqualEval implements OperationEval {
15
16
    private LessEqualPtg delegate;
17
    
18
    public LessEqualEval(Ptg ptg) {
19
        this.delegate = (LessEqualPtg) ptg;
20
    }
21
    
22
    /* (non-Javadoc)
23
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#evaluate(org.apache.poi.hssf.record.formula.eval.Eval[])
24
     */
25
    public Eval evaluate(Eval[] operands) {
26
        boolean b = false;
27
        double d0 = 0;
28
        double d1 = 0;
29
        String s0 = null;
30
        String s1 = null;
31
        ValueEval retval = null;
32
        if (operands.length >= 2) { // ignore >2 operands
33
            if (operands[0] instanceof NumericValueEval) {
34
                NumericValueEval ne = (NumericValueEval) operands[0];
35
                d0 = ne.getNumberValue();
36
            }
37
            else if (operands[0] instanceof RefEval) {
38
                RefEval re = (RefEval) operands[0];
39
                ValueEval ve = re.getInnerValueEval();
40
                if (ve instanceof NumericValueEval) {
41
                    NumericValueEval ne = (NumericValueEval) ve;
42
                    d0 = ne.getNumberValue();
43
                }
44
                else if (ve instanceof StringValueEval) {
45
                    StringValueEval se = (StringValueEval) ve;
46
                    s0 = se.getStringValue();
47
                }
48
            }
49
            // Oo does some weird things here.
50
            // ...works fine for row area, conks out for col/row-col area
51
            // Excel surprisingly does well for row & col, conks out
52
            // ...for row-col area.
53
            else if (operands[0] instanceof AreaEval) { 
54
                AreaEval ae = (AreaEval) operands[0];
55
                short frow = ae.getFirstRow();
56
                short lrow = ae.getLastRow();
57
                short fcol = ae.getFirstColumn();
58
                short lcol = ae.getLastColumn();
59
                if (frow == lrow || fcol == lcol) {
60
	                ValueEval ve = ae.getValues()[0];
61
	                if (ve instanceof NumericValueEval) {
62
	                    NumericValueEval ne = (NumericValueEval) ve;
63
	                    d0 = ne.getNumberValue();
64
	                }
65
	                else if (ve instanceof StringValueEval) {
66
	                    StringValueEval se = (StringValueEval) ve;
67
	                    s0 = se.getStringValue();
68
	                }
69
                }
70
                else {
71
                    retval = ErrorEval.INVALID_VALUE;
72
                }
73
            }
74
            
75
            // we're only done with the first operand by now...
76
            
77
            if (operands[1] instanceof NumericValueEval) {
78
                NumericValueEval ne = (NumericValueEval) operands[1];
79
                d1 = ne.getNumberValue();
80
            }
81
            else if (operands[1] instanceof RefEval) {
82
                RefEval re = (RefEval) operands[1];
83
                ValueEval ve = re.getInnerValueEval();
84
                if (ve instanceof NumericValueEval) {
85
                    NumericValueEval ne = (NumericValueEval) ve;
86
                    d1 = ne.getNumberValue();
87
                }
88
                else if (ve instanceof StringValueEval) {
89
                    StringValueEval se = (StringValueEval) ve;
90
                    s1 = se.getStringValue();
91
                }
92
            }
93
            // Oo does some weird things here.
94
            // ...works fine for row area, conks out for col/row-col area
95
            // Excel surprisingly does well for row & col, conks out
96
            // ...for row-col area.
97
            else if (operands[1] instanceof AreaEval) { 
98
                AreaEval ae = (AreaEval) operands[1];
99
                short frow = ae.getFirstRow();
100
                short lrow = ae.getLastRow();
101
                short fcol = ae.getFirstColumn();
102
                short lcol = ae.getLastColumn();
103
                if (frow == lrow || fcol == lcol) {
104
	                ValueEval ve = ae.getValues()[1];
105
	                if (ve instanceof NumericValueEval) {
106
	                    NumericValueEval ne = (NumericValueEval) ve;
107
	                    d1 = ne.getNumberValue();
108
	                }
109
	                else if (ve instanceof StringValueEval) {
110
	                    StringValueEval se = (StringValueEval) ve;
111
	                    s1 = se.getStringValue();
112
	                }
113
                }
114
                else {
115
                    retval = ErrorEval.INVALID_VALUE;
116
                }
117
            }
118
        }
119
        else {
120
            retval = ErrorEval.ERROR_520;
121
        }
122
        
123
        
124
        // now the comparison begins *drumroll*
125
        if (retval == null) {
126
            if (s0 == null) {
127
                if (s1 == null) {
128
                    retval = (Double.isNaN(d0) || Double.isNaN(d1))
129
                    		? (ValueEval) ErrorEval.ERROR_502
130
                            : new BoolEval(d0 <= d1);
131
                }
132
                else {
133
                    retval = (Double.isNaN(d0))
134
            				? (ValueEval) ErrorEval.ERROR_502
135
                            : new BoolEval(false);
136
                }
137
            }
138
            else {
139
                if (s1 == null) {
140
                    retval = (Double.isNaN(d1))
141
                    		? (ValueEval) ErrorEval.ERROR_502
142
                            : new BoolEval(false);
143
                }
144
                else {
145
                    retval = new BoolEval(s0.compareTo(s1) <= 0);
146
                }
147
            }
148
        }
149
        
150
        return new BoolEval(b);
151
    }
152
    
153
    /* (non-Javadoc)
154
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#getNumberOfOperands()
155
     */
156
    public int getNumberOfOperands() {
157
        return delegate.getNumberOfOperands();
158
    }
159
    
160
    /* (non-Javadoc)
161
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#getType()
162
     */
163
    public int getType() {
164
        return delegate.getType();
165
    }
166
167
}
(-)org/apache/poi/hssf/record/formula/eval/LessThanEval.java (+167 lines)
Added Link Here
1
/*
2
 * Created on May 8, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.eval;
6
7
import org.apache.poi.hssf.record.formula.LessThanPtg;
8
import org.apache.poi.hssf.record.formula.Ptg;
9
10
/**
11
 * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
12
 *
13
 */
14
public class LessThanEval implements OperationEval {
15
16
    private LessThanPtg delegate;
17
    
18
    public LessThanEval(Ptg ptg) {
19
        this.delegate = (LessThanPtg) ptg;
20
    }
21
    
22
    /* (non-Javadoc)
23
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#evaluate(org.apache.poi.hssf.record.formula.eval.Eval[])
24
     */
25
    public Eval evaluate(Eval[] operands) {
26
        boolean b = false;
27
        double d0 = 0;
28
        double d1 = 0;
29
        String s0 = null;
30
        String s1 = null;
31
        ValueEval retval = null;
32
        if (operands.length >= 2) { // ignore >2 operands
33
            if (operands[0] instanceof NumericValueEval) {
34
                NumericValueEval ne = (NumericValueEval) operands[0];
35
                d0 = ne.getNumberValue();
36
            }
37
            else if (operands[0] instanceof RefEval) {
38
                RefEval re = (RefEval) operands[0];
39
                ValueEval ve = re.getInnerValueEval();
40
                if (ve instanceof NumericValueEval) {
41
                    NumericValueEval ne = (NumericValueEval) ve;
42
                    d0 = ne.getNumberValue();
43
                }
44
                else if (ve instanceof StringValueEval) {
45
                    StringValueEval se = (StringValueEval) ve;
46
                    s0 = se.getStringValue();
47
                }
48
            }
49
            // Oo does some weird things here.
50
            // ...works fine for row area, conks out for col/row-col area
51
            // Excel surprisingly does well for row & col, conks out
52
            // ...for row-col area.
53
            else if (operands[0] instanceof AreaEval) { 
54
                AreaEval ae = (AreaEval) operands[0];
55
                short frow = ae.getFirstRow();
56
                short lrow = ae.getLastRow();
57
                short fcol = ae.getFirstColumn();
58
                short lcol = ae.getLastColumn();
59
                if (frow == lrow || fcol == lcol) {
60
	                ValueEval ve = ae.getValues()[0];
61
	                if (ve instanceof NumericValueEval) {
62
	                    NumericValueEval ne = (NumericValueEval) ve;
63
	                    d0 = ne.getNumberValue();
64
	                }
65
	                else if (ve instanceof StringValueEval) {
66
	                    StringValueEval se = (StringValueEval) ve;
67
	                    s0 = se.getStringValue();
68
	                }
69
                }
70
                else {
71
                    retval = ErrorEval.INVALID_VALUE;
72
                }
73
            }
74
            
75
            // we're only done with the first operand by now...
76
            
77
            if (operands[1] instanceof NumericValueEval) {
78
                NumericValueEval ne = (NumericValueEval) operands[1];
79
                d1 = ne.getNumberValue();
80
            }
81
            else if (operands[1] instanceof RefEval) {
82
                RefEval re = (RefEval) operands[1];
83
                ValueEval ve = re.getInnerValueEval();
84
                if (ve instanceof NumericValueEval) {
85
                    NumericValueEval ne = (NumericValueEval) ve;
86
                    d1 = ne.getNumberValue();
87
                }
88
                else if (ve instanceof StringValueEval) {
89
                    StringValueEval se = (StringValueEval) ve;
90
                    s1 = se.getStringValue();
91
                }
92
            }
93
            // Oo does some weird things here.
94
            // ...works fine for row area, conks out for col/row-col area
95
            // Excel surprisingly does well for row & col, conks out
96
            // ...for row-col area.
97
            else if (operands[1] instanceof AreaEval) { 
98
                AreaEval ae = (AreaEval) operands[1];
99
                short frow = ae.getFirstRow();
100
                short lrow = ae.getLastRow();
101
                short fcol = ae.getFirstColumn();
102
                short lcol = ae.getLastColumn();
103
                if (frow == lrow || fcol == lcol) {
104
	                ValueEval ve = ae.getValues()[1];
105
	                if (ve instanceof NumericValueEval) {
106
	                    NumericValueEval ne = (NumericValueEval) ve;
107
	                    d1 = ne.getNumberValue();
108
	                }
109
	                else if (ve instanceof StringValueEval) {
110
	                    StringValueEval se = (StringValueEval) ve;
111
	                    s1 = se.getStringValue();
112
	                }
113
                }
114
                else {
115
                    retval = ErrorEval.INVALID_VALUE;
116
                }
117
            }
118
        }
119
        else {
120
            retval = ErrorEval.ERROR_520;
121
        }
122
        
123
        
124
        // now the comparison begins *drumroll*
125
        if (retval == null) {
126
            if (s0 == null) {
127
                if (s1 == null) {
128
                    retval = (Double.isNaN(d0) || Double.isNaN(d1))
129
                    		? (ValueEval) ErrorEval.ERROR_502
130
                            : new BoolEval(d0 < d1);
131
                }
132
                else {
133
                    retval = (Double.isNaN(d0))
134
            				? (ValueEval) ErrorEval.ERROR_502
135
                            : new BoolEval(false);
136
                }
137
            }
138
            else {
139
                if (s1 == null) {
140
                    retval = (Double.isNaN(d1))
141
                    		? (ValueEval) ErrorEval.ERROR_502
142
                            : new BoolEval(false);
143
                }
144
                else {
145
                    retval = new BoolEval(s0.compareTo(s1) < 0);
146
                }
147
            }
148
        }
149
        
150
        return new BoolEval(b);
151
    }
152
153
    /* (non-Javadoc)
154
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#getNumberOfOperands()
155
     */
156
    public int getNumberOfOperands() {
157
        return delegate.getNumberOfOperands();
158
    }
159
    
160
    /* (non-Javadoc)
161
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#getType()
162
     */
163
    public int getType() {
164
        return delegate.getType();
165
    }
166
167
}
(-)org/apache/poi/hssf/record/formula/eval/MultiplyEval.java (+98 lines)
Added Link Here
1
/*
2
 * Created on May 8, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.eval;
6
7
import org.apache.poi.hssf.record.formula.MultiplyPtg;
8
import org.apache.poi.hssf.record.formula.Ptg;
9
10
/**
11
 * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
12
 *
13
 */
14
public class MultiplyEval implements OperationEval {
15
16
    private MultiplyPtg delegate;
17
    
18
    public MultiplyEval(Ptg ptg) {
19
        this.delegate = (MultiplyPtg) ptg;
20
    }
21
    
22
    /* (non-Javadoc)
23
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#evaluate(org.apache.poi.hssf.record.formula.eval.Eval[])
24
     */
25
    public Eval evaluate(Eval[] operands) {
26
        double d0 = 0;
27
        double d1 = 0;
28
		ValueEval retval = null;
29
		if (operands.length >= 2) { // ignore operands other than 1st two
30
		    if (operands[0] != null) {
31
				if (operands[0] instanceof NumericValueEval) {
32
				    d0 = ((NumericValueEval) operands[0]).getNumberValue();
33
				}
34
				else if (operands[0] instanceof StringValueEval) {
35
				    retval = ErrorEval.ERROR_502;
36
				}
37
				else if (operands[0] instanceof ErrorEval) {
38
				    retval = (ErrorEval) operands[0];
39
				}
40
				else if (operands[0] instanceof RefEval) {
41
				    RefEval re = (RefEval) operands[0];
42
				    ValueEval ve = re.getInnerValueEval();
43
					if (operands[0] instanceof NumericValueEval) {
44
					    d0 = ((NumericValueEval) operands[0]).getNumberValue();
45
					}
46
					else if (operands[0] instanceof StringValueEval) {
47
					    retval = ErrorEval.ERROR_502;
48
					}
49
					else if (operands[0] instanceof ErrorEval) {
50
					    retval = (ErrorEval) operands[0];
51
					}
52
				}
53
				else {
54
				    retval = ErrorEval.INVALID_VALUE;
55
				}
56
		    }
57
		    if (retval == null && operands[1] != null) {
58
				if (operands[1] instanceof NumericValueEval) {
59
				    d1 = ((NumericValueEval) operands[1]).getNumberValue();
60
				}
61
				else if (operands[1] instanceof StringValueEval) {
62
				    retval = ErrorEval.ERROR_502;
63
				}
64
				else if (operands[0] instanceof ErrorEval) {
65
				    ErrorEval e = (ErrorEval) operands[0];
66
				    retval = e;
67
				}
68
				else {
69
				    retval = ErrorEval.INVALID_VALUE;
70
				}
71
		    }
72
			if (retval != null) {
73
			    retval = (Double.isNaN(d0) || Double.isNaN(d1))
74
			    		? (ValueEval) ErrorEval.ERROR_502
75
			    	    : new NumberEval(d0*d1);
76
			}
77
		}
78
		else {
79
		    retval = ErrorEval.ERROR_UNKNOWN;
80
		}
81
		return retval;
82
    }
83
    
84
    /* (non-Javadoc)
85
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#getNumberOfOperands()
86
     */
87
    public int getNumberOfOperands() {
88
        return delegate.getNumberOfOperands();
89
    }
90
    
91
    /* (non-Javadoc)
92
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#getType()
93
     */
94
    public int getType() {
95
        return delegate.getType();
96
    }
97
98
}
(-)org/apache/poi/hssf/record/formula/eval/NotEqualEval.java (+167 lines)
Added Link Here
1
/*
2
 * Created on May 8, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.eval;
6
7
import org.apache.poi.hssf.record.formula.NotEqualPtg;
8
import org.apache.poi.hssf.record.formula.Ptg;
9
10
/**
11
 * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
12
 *
13
 */
14
public class NotEqualEval implements OperationEval {
15
16
    private NotEqualPtg delegate;
17
    
18
    public NotEqualEval(Ptg ptg) {
19
        this.delegate = (NotEqualPtg) ptg;
20
    }
21
    
22
23
    /* (non-Javadoc)
24
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#evaluate(org.apache.poi.hssf.record.formula.eval.Eval[])
25
     */
26
    public Eval evaluate(Eval[] operands) {
27
        boolean b = false;
28
        double d0 = 0;
29
        double d1 = 0;
30
        String s0 = null;
31
        String s1 = null;
32
        ValueEval retval = null;
33
        if (operands.length >= 2) { // ignore >2 operands
34
            if (operands[0] instanceof NumericValueEval) {
35
                NumericValueEval ne = (NumericValueEval) operands[0];
36
                d0 = ne.getNumberValue();
37
            }
38
            else if (operands[0] instanceof RefEval) {
39
                RefEval re = (RefEval) operands[0];
40
                ValueEval ve = re.getInnerValueEval();
41
                if (ve instanceof NumericValueEval) {
42
                    NumericValueEval ne = (NumericValueEval) ve;
43
                    d0 = ne.getNumberValue();
44
                }
45
                else if (ve instanceof StringValueEval) {
46
                    StringValueEval se = (StringValueEval) ve;
47
                    s0 = se.getStringValue();
48
                }
49
            }
50
            // Oo does some weird things here.
51
            // ...works fine for row area, conks out for col/row-col area
52
            // Excel surprisingly does well for row & col, conks out
53
            // ...for row-col area.
54
            else if (operands[0] instanceof AreaEval) { 
55
                AreaEval ae = (AreaEval) operands[0];
56
                short frow = ae.getFirstRow();
57
                short lrow = ae.getLastRow();
58
                short fcol = ae.getFirstColumn();
59
                short lcol = ae.getLastColumn();
60
                if (frow == lrow || fcol == lcol) {
61
	                ValueEval ve = ae.getValues()[0];
62
	                if (ve instanceof NumericValueEval) {
63
	                    NumericValueEval ne = (NumericValueEval) ve;
64
	                    d0 = ne.getNumberValue();
65
	                }
66
	                else if (ve instanceof StringValueEval) {
67
	                    StringValueEval se = (StringValueEval) ve;
68
	                    s0 = se.getStringValue();
69
	                }
70
                }
71
                else {
72
                    retval = ErrorEval.INVALID_VALUE;
73
                }
74
            }
75
            
76
            // we're only done with the first operand by now...
77
            
78
            if (operands[1] instanceof NumericValueEval) {
79
                NumericValueEval ne = (NumericValueEval) operands[1];
80
                d1 = ne.getNumberValue();
81
            }
82
            else if (operands[1] instanceof RefEval) {
83
                RefEval re = (RefEval) operands[1];
84
                ValueEval ve = re.getInnerValueEval();
85
                if (ve instanceof NumericValueEval) {
86
                    NumericValueEval ne = (NumericValueEval) ve;
87
                    d1 = ne.getNumberValue();
88
                }
89
                else if (ve instanceof StringValueEval) {
90
                    StringValueEval se = (StringValueEval) ve;
91
                    s1 = se.getStringValue();
92
                }
93
            }
94
            // Oo does some weird things here.
95
            // ...works fine for row area, conks out for col/row-col area
96
            // Excel surprisingly does well for row & col, conks out
97
            // ...for row-col area.
98
            else if (operands[1] instanceof AreaEval) { 
99
                AreaEval ae = (AreaEval) operands[1];
100
                short frow = ae.getFirstRow();
101
                short lrow = ae.getLastRow();
102
                short fcol = ae.getFirstColumn();
103
                short lcol = ae.getLastColumn();
104
                if (frow == lrow || fcol == lcol) {
105
	                ValueEval ve = ae.getValues()[1];
106
	                if (ve instanceof NumericValueEval) {
107
	                    NumericValueEval ne = (NumericValueEval) ve;
108
	                    d1 = ne.getNumberValue();
109
	                }
110
	                else if (ve instanceof StringValueEval) {
111
	                    StringValueEval se = (StringValueEval) ve;
112
	                    s1 = se.getStringValue();
113
	                }
114
                }
115
                else {
116
                    retval = ErrorEval.INVALID_VALUE;
117
                }
118
            }
119
        }
120
        else {
121
            retval = ErrorEval.ERROR_520;
122
        }
123
        
124
        
125
        // now the comparison begins *drumroll*
126
        if (retval == null) {
127
            if (s0 == null) {
128
                if (s1 == null) {
129
                    retval = (Double.isNaN(d0) || Double.isNaN(d1))
130
                    		? (ValueEval) ErrorEval.ERROR_502
131
                            : new BoolEval(d0 != d1);
132
                }
133
                else {
134
                    retval = (Double.isNaN(d0))
135
            				? (ValueEval) ErrorEval.ERROR_502
136
                            : new BoolEval(false);
137
                }
138
            }
139
            else {
140
                if (s1 == null) {
141
                    retval = (Double.isNaN(d1))
142
                    		? (ValueEval) ErrorEval.ERROR_502
143
                            : new BoolEval(false);
144
                }
145
                else {
146
                    retval = new BoolEval(s0.compareTo(s1) != 0);
147
                }
148
            }
149
        }
150
        
151
        return new BoolEval(b);
152
    }    
153
    /* (non-Javadoc)
154
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#getNumberOfOperands()
155
     */
156
    public int getNumberOfOperands() {
157
        return delegate.getNumberOfOperands();
158
    }
159
    
160
    /* (non-Javadoc)
161
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#getType()
162
     */
163
    public int getType() {
164
        return delegate.getType();
165
    }
166
167
}
(-)org/apache/poi/hssf/record/formula/eval/NumberEval.java (+44 lines)
Added Link Here
1
/*
2
 * Created on May 8, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.eval;
6
7
import org.apache.poi.hssf.record.formula.IntPtg;
8
import org.apache.poi.hssf.record.formula.NumberPtg;
9
import org.apache.poi.hssf.record.formula.Ptg;
10
11
/**
12
 * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
13
 *
14
 */
15
public class NumberEval implements NumericValueEval, StringValueEval {
16
17
    private double value;
18
    
19
    
20
    public NumberEval(Ptg ptg) {
21
        if (ptg instanceof IntPtg) {
22
            this.value = ((IntPtg) ptg).getValue();
23
        }
24
        else if (ptg instanceof NumberPtg) {
25
            this.value = ((NumberPtg) ptg).getValue();
26
        }
27
    }
28
    
29
    public NumberEval(double value) {
30
        this.value = value;
31
    }
32
    
33
    public double getNumberValue() {
34
        return value;
35
    }
36
    
37
    /* (non-Javadoc)
38
     * @see org.apache.poi.hssf.record.formula.eval.StringValueEval#getStringValue()
39
     */
40
    public String getStringValue() {
41
        return String.valueOf(value);
42
    }
43
44
}
(-)org/apache/poi/hssf/record/formula/eval/NumericValueEval.java (+14 lines)
Added Link Here
1
/*
2
 * Created on May 8, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.eval;
6
7
/**
8
 * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
9
 *
10
 */
11
public interface NumericValueEval extends ValueEval {
12
13
    public abstract double getNumberValue();
14
}
(-)org/apache/poi/hssf/record/formula/eval/OperationEval.java (+18 lines)
Added Link Here
1
/*
2
 * Created on May 8, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.eval;
6
7
/**
8
 * @author amolweb &lt; amolweb at ya hoo dot com &gt;
9
 *
10
 */
11
public interface OperationEval extends Eval {
12
13
    public abstract Eval evaluate(Eval[] evals);
14
    
15
    public abstract int getNumberOfOperands();
16
    
17
    public abstract int getType();
18
}
(-)org/apache/poi/hssf/record/formula/eval/PowerEval.java (+99 lines)
Added Link Here
1
/*
2
 * Created on May 8, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.eval;
6
7
import org.apache.poi.hssf.record.formula.PowerPtg;
8
import org.apache.poi.hssf.record.formula.Ptg;
9
10
/**
11
 * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
12
 *
13
 */
14
public class PowerEval implements OperationEval {
15
16
    private PowerPtg delegate;
17
    
18
    public PowerEval(Ptg ptg) {
19
        this.delegate = (PowerPtg) ptg;
20
    }
21
    
22
23
    /* (non-Javadoc)
24
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#evaluate(org.apache.poi.hssf.record.formula.eval.Eval[])
25
     */
26
    public Eval evaluate(Eval[] operands) {
27
        double d0 = 0;
28
        double d1 = 0;
29
		ValueEval retval = null;
30
		if (operands.length >= 2) { // ignore operands other than 1st two
31
		    if (operands[0] != null) {
32
				if (operands[0] instanceof NumericValueEval) {
33
				    d0 = ((NumericValueEval) operands[0]).getNumberValue();
34
				}
35
				else if (operands[0] instanceof StringValueEval) {
36
				    retval = ErrorEval.ERROR_502;
37
				}
38
				else if (operands[0] instanceof ErrorEval) {
39
				    retval = (ErrorEval) operands[0];
40
				}
41
				else if (operands[0] instanceof RefEval) {
42
				    RefEval re = (RefEval) operands[0];
43
				    ValueEval ve = re.getInnerValueEval();
44
					if (operands[0] instanceof NumericValueEval) {
45
					    d0 = ((NumericValueEval) operands[0]).getNumberValue();
46
					}
47
					else if (operands[0] instanceof StringValueEval) {
48
					    retval = ErrorEval.ERROR_502;
49
					}
50
					else if (operands[0] instanceof ErrorEval) {
51
					    retval = (ErrorEval) operands[0];
52
					}
53
				}
54
				else {
55
				    retval = ErrorEval.INVALID_VALUE;
56
				}
57
		    }
58
		    if (retval == null && operands[1] != null) {
59
				if (operands[1] instanceof NumericValueEval) {
60
				    d1 = ((NumericValueEval) operands[1]).getNumberValue();
61
				}
62
				else if (operands[1] instanceof StringValueEval) {
63
				    retval = ErrorEval.ERROR_502;
64
				}
65
				else if (operands[0] instanceof ErrorEval) {
66
				    ErrorEval e = (ErrorEval) operands[0];
67
				    retval = e;
68
				}
69
				else {
70
				    retval = ErrorEval.INVALID_VALUE;
71
				}
72
		    }
73
			if (retval != null) {
74
			    retval = (Double.isNaN(d0) || Double.isNaN(d1) || d1==0)
75
			    		? (ValueEval) ErrorEval.ERROR_502
76
			            : new NumberEval(Math.pow(d0, d1));
77
			}
78
		}
79
		else {
80
		    retval = ErrorEval.ERROR_520;
81
		}
82
		return retval;
83
    }
84
        
85
    /* (non-Javadoc)
86
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#getNumberOfOperands()
87
     */
88
    public int getNumberOfOperands() {
89
        return delegate.getNumberOfOperands();
90
    }
91
    
92
    /* (non-Javadoc)
93
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#getType()
94
     */
95
    public int getType() {
96
        return delegate.getType();
97
    }
98
99
}
(-)org/apache/poi/hssf/record/formula/eval/Ref2DEval.java (+44 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 * TODO To change the template for this generated file go to
5
 * Window - Preferences - Java - Code Style - Code Templates
6
 */
7
package org.apache.poi.hssf.record.formula.eval;
8
9
import org.apache.poi.hssf.record.formula.Ptg;
10
import org.apache.poi.hssf.record.formula.ReferencePtg;
11
12
/**
13
 * @author adeshmukh
14
 *
15
 * TODO To change the template for this generated type comment go to
16
 * Window - Preferences - Java - Code Style - Code Templates
17
 */
18
public class Ref2DEval implements RefEval {
19
20
	private ValueEval value;
21
	
22
	private ReferencePtg delegate;
23
	
24
	public Ref2DEval(Ptg ptg, ValueEval value) {
25
		this.value = value;
26
		this.delegate = (ReferencePtg) ptg;
27
	}
28
	
29
	/* (non-Javadoc)
30
	 * @see org.apache.poi.hssf.record.formula.eval.RefEval#getInnerValueEval()
31
	 */
32
	public ValueEval getInnerValueEval() {
33
		return value;
34
	}
35
	
36
	public short getRow() {
37
		return delegate.getRow();
38
	}
39
	
40
	public short getColumn() {
41
		return delegate.getColumn();
42
	}
43
	
44
}
(-)org/apache/poi/hssf/record/formula/eval/Ref3DEval.java (+44 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 * TODO To change the template for this generated file go to
5
 * Window - Preferences - Java - Code Style - Code Templates
6
 */
7
package org.apache.poi.hssf.record.formula.eval;
8
9
import org.apache.poi.hssf.record.formula.Ptg;
10
import org.apache.poi.hssf.record.formula.Ref3DPtg;
11
12
/**
13
 * @author adeshmukh
14
 *
15
 * TODO To change the template for this generated type comment go to
16
 * Window - Preferences - Java - Code Style - Code Templates
17
 */
18
public class Ref3DEval implements RefEval {
19
20
	private ValueEval value;
21
	
22
	private Ref3DPtg delegate;
23
	
24
	public Ref3DEval(Ptg ptg, ValueEval value) {
25
		this.value = value;
26
		this.delegate = (Ref3DPtg) ptg;
27
	}
28
	
29
	/* (non-Javadoc)
30
	 * @see org.apache.poi.hssf.record.formula.eval.RefEval#getInnerValueEval()
31
	 */
32
	public ValueEval getInnerValueEval() {
33
		return value;
34
	}
35
	
36
	public short getRow() {
37
		return delegate.getRow();
38
	}
39
	
40
	public short getColumn() {
41
		return delegate.getColumn();
42
	}
43
	
44
}
(-)org/apache/poi/hssf/record/formula/eval/RefEval.java (+29 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 * 
5
 */
6
package org.apache.poi.hssf.record.formula.eval;
7
8
9
/**
10
 * @author Amol S Deshmukh &lt; amolweb at ya hoo dot com &gt;
11
 *
12
 * RefEval is the super interface for Ref2D and Ref3DEval.
13
 * Basically a RefEval impl should contain reference to
14
 * the original ReferencePtg or Ref3DPtg as well as the
15
 * final "value" resulting from the evaluation of the cell 
16
 * reference. Thus if the HSSFCell has type CELL_TYPE_NUMERIC,
17
 * the contained value object should be of type NumberEval;
18
 * if cell type is CELL_TYPE_STRING, contained value object
19
 * should be of type StringEval 
20
 */
21
public interface RefEval extends ValueEval {
22
23
	public ValueEval getInnerValueEval();
24
	
25
	public short getColumn();
26
	
27
	public short getRow();
28
29
}
(-)org/apache/poi/hssf/record/formula/eval/StringEval.java (+29 lines)
Added Link Here
1
/*
2
 * Created on May 8, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.eval;
6
7
import org.apache.poi.hssf.record.formula.Ptg;
8
import org.apache.poi.hssf.record.formula.StringPtg;
9
10
/**
11
 * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
12
 *
13
 */
14
public class StringEval implements StringValueEval {
15
16
    private String value;
17
    
18
    public StringEval(Ptg ptg) {
19
        this.value = ((StringPtg) ptg).getValue();
20
    }
21
    
22
    public StringEval(String value) {
23
        this.value = value;
24
    }
25
    
26
    public String getStringValue() {
27
        return value;
28
    }
29
}
(-)org/apache/poi/hssf/record/formula/eval/StringValueEval.java (+15 lines)
Added Link Here
1
/*
2
 * Created on May 8, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.eval;
6
7
8
/**
9
 * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
10
 *
11
 */
12
public interface StringValueEval extends ValueEval {
13
14
    public String getStringValue();
15
}
(-)org/apache/poi/hssf/record/formula/eval/SubtractEval.java (+89 lines)
Added Link Here
1
/*
2
 * Created on May 8, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.eval;
6
7
import org.apache.poi.hssf.record.formula.Ptg;
8
import org.apache.poi.hssf.record.formula.SubtractPtg;
9
10
/**
11
 * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
12
 *
13
 */
14
public class SubtractEval implements OperationEval {
15
16
    private SubtractPtg delegate;
17
    
18
    public SubtractEval(Ptg ptg) {
19
        delegate = (SubtractPtg) ptg;
20
    }
21
    
22
    /* (non-Javadoc)
23
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#evaluate(org.apache.poi.hssf.record.formula.eval.Eval[])
24
     */
25
    public Eval evaluate(Eval[] operands) {
26
        double d0 = 0;
27
        double d1 = 0;
28
        Eval retval = null;
29
    	if (operands.length != 2) {
30
    	    retval = ErrorEval.ERROR_520;
31
    	}
32
        else if (operands[0] instanceof NumericValueEval) {
33
    		d0 = ((NumericValueEval) operands[0]).getNumberValue();
34
    	}
35
    	else if (operands[0] instanceof RefEval) {
36
    	    RefEval re = (RefEval) operands[0];
37
    	    ValueEval ve = (ValueEval) re.getInnerValueEval();
38
        	if (ve instanceof NumericValueEval) {
39
        		d0 = ((NumericValueEval) ve).getNumberValue();
40
        	}
41
        	else {
42
        	    retval = ErrorEval.ERROR_502;
43
        	}
44
    	}
45
    	else {
46
    	    retval = ErrorEval.ERROR_502;
47
    	}
48
    	
49
    	if (retval == null) { // if not error already
50
	        if (operands[1] instanceof NumericValueEval) {
51
	    		d1 = ((NumericValueEval) operands[1]).getNumberValue();
52
	    	}
53
	    	else if (operands[1] instanceof RefEval) {
54
	    	    RefEval re = (RefEval) operands[1];
55
	    	    ValueEval ve = (ValueEval) re.getInnerValueEval();
56
	        	if (ve instanceof NumericValueEval) {
57
	        		d1 = ((NumericValueEval) ve).getNumberValue();
58
	        	}
59
	        	else {
60
	        	    retval = ErrorEval.ERROR_502;
61
	        	}
62
	    	}
63
	    	else {
64
	    	    retval = ErrorEval.ERROR_502;
65
	    	}
66
    	}
67
    	
68
    	if (retval == null) { 
69
    	    retval = (Double.isNaN(d0) || Double.isNaN(d1)) 
70
    	    		? (ValueEval) ErrorEval.ERROR_520 
71
    	            : new NumberEval(d0-d1);
72
    	}
73
    	return retval;
74
    }
75
    
76
    /* (non-Javadoc)
77
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#getNumberOfOperands()
78
     */
79
    public int getNumberOfOperands() {
80
        return delegate.getNumberOfOperands();
81
    }
82
    
83
    /* (non-Javadoc)
84
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#getType()
85
     */
86
    public int getType() {
87
        return delegate.getType();
88
    }
89
}
(-)org/apache/poi/hssf/record/formula/eval/UnaryMinusEval.java (+65 lines)
Added Link Here
1
/*
2
 * Created on May 8, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.eval;
6
7
import org.apache.poi.hssf.record.formula.Ptg;
8
import org.apache.poi.hssf.record.formula.UnaryMinusPtg;
9
10
/**
11
 * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
12
 *
13
 */
14
public class UnaryMinusEval implements OperationEval {
15
16
    private UnaryMinusPtg delegate;
17
    
18
    public UnaryMinusEval(Ptg ptg) {
19
        this.delegate = (UnaryMinusPtg) ptg;
20
    }
21
    
22
    /* (non-Javadoc)
23
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#evaluate(org.apache.poi.hssf.record.formula.eval.Eval[])
24
     */
25
    public Eval evaluate(Eval[] operands) {
26
        ValueEval retval = null;
27
        double d = 0;
28
        if (operands[0] instanceof NumericValueEval) {
29
            NumericValueEval nve = (NumericValueEval) operands[0];
30
            d = nve.getNumberValue();
31
        }
32
        else if (operands[0] instanceof RefEval) {
33
            RefEval re = (RefEval) operands[0];
34
            ValueEval ve = re.getInnerValueEval();
35
            if (ve instanceof NumericValueEval) {
36
                NumericValueEval nve = (NumericValueEval) ve;
37
                d = nve.getNumberValue();
38
            }
39
        }
40
        else {
41
            retval = ErrorEval.INVALID_VALUE;
42
        }
43
        
44
        if (retval == null) {
45
            retval = new NumberEval(-d);
46
        }
47
        
48
        return retval;
49
    }
50
    
51
    /* (non-Javadoc)
52
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#getNumberOfOperands()
53
     */
54
    public int getNumberOfOperands() {
55
        return delegate.getNumberOfOperands();
56
    }
57
    
58
    /* (non-Javadoc)
59
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#getType()
60
     */
61
    public int getType() {
62
        return delegate.getType();
63
    }
64
65
}
(-)org/apache/poi/hssf/record/formula/eval/UnaryPlusEval.java (+43 lines)
Added Link Here
1
/*
2
 * Created on May 8, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.eval;
6
7
import org.apache.poi.hssf.record.formula.Ptg;
8
import org.apache.poi.hssf.record.formula.UnaryPlusPtg;
9
10
/**
11
 * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
12
 *
13
 */
14
public class UnaryPlusEval implements OperationEval {
15
16
    private UnaryPlusPtg delegate;
17
    
18
    public UnaryPlusEval(Ptg ptg) {
19
        this.delegate = (UnaryPlusPtg) ptg;
20
    }
21
    
22
    /* (non-Javadoc)
23
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#evaluate(org.apache.poi.hssf.record.formula.eval.Eval[])
24
     */
25
    public Eval evaluate(Eval[] operands) {
26
        return operands[0];
27
    }
28
    
29
    /* (non-Javadoc)
30
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#getNumberOfOperands()
31
     */
32
    public int getNumberOfOperands() {
33
        return delegate.getNumberOfOperands();
34
    }
35
    
36
    /* (non-Javadoc)
37
     * @see org.apache.poi.hssf.record.formula.eval.OperationEval#getType()
38
     */
39
    public int getType() {
40
        return delegate.getType();
41
    }
42
43
}
(-)org/apache/poi/hssf/record/formula/eval/ValueEval.java (+13 lines)
Added Link Here
1
/*
2
 * Created on May 8, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.eval;
6
7
/**
8
 * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
9
 *
10
 */
11
public interface ValueEval extends Eval {
12
13
}
(-)org/apache/poi/hssf/record/formula/functions/Abs.java (+56 lines)
Added Link Here
1
/*
2
 * Created on May 6, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.AreaEval;
8
import org.apache.poi.hssf.record.formula.eval.ErrorEval;
9
import org.apache.poi.hssf.record.formula.eval.Eval;
10
import org.apache.poi.hssf.record.formula.eval.NumberEval;
11
import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
12
import org.apache.poi.hssf.record.formula.eval.ValueEval;
13
14
/**
15
 * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
16
 *
17
 */
18
public class Abs extends DefaultFunctionImpl {
19
20
    
21
	/* (non-Javadoc)
22
	 * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
23
	 */
24
	public Eval evaluate(Eval[] operands) {
25
		double d = 0;
26
		ValueEval retval = null;
27
		if (operands.length == 1) {
28
			if (operands[0] !=null && operands[0] instanceof NumericValueEval) {
29
			    d = Math.abs(((NumericValueEval) operands[0]).getNumberValue());
30
			}
31
			else if (operands[0] instanceof AreaEval) {
32
			    AreaEval ae = (AreaEval) operands[0];
33
			    ValueEval v = ae.getValues()[0];
34
			    if (v != null && v instanceof NumericValueEval) {
35
			        d = Math.abs(((NumericValueEval) v).getNumberValue());
36
			    }
37
			}
38
			else if (operands[0] instanceof ErrorEval) {
39
			    ErrorEval e = (ErrorEval) operands[0];
40
			    retval = e;
41
			}
42
			if (retval != null)
43
			    retval = new NumberEval(d);
44
		}
45
		else {
46
		    retval = ErrorEval.ERROR_508;
47
		}
48
		if (retval != null) {
49
		    retval = (Double.isNaN(d)) 
50
		    		? (ValueEval) ErrorEval.ERROR_502 
51
		            : new NumberEval(d);
52
		}
53
		return retval;
54
	}
55
56
}
(-)org/apache/poi/hssf/record/formula/functions/Absref.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Absref extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Acos.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Acos extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Acosh.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Acosh extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Activecell.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Activecell extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Addbar.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Addbar extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Addcommand.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Addcommand extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Addmenu.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Addmenu extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Address.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Address extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Addtoolbar.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Addtoolbar extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/And.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class And extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Apptitle.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Apptitle extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Areas.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Areas extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Argument.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Argument extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Asc.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Asc extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Asin.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Asin extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Asinh.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Asinh extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Atan.java (+22 lines)
Added Link Here
1
/*
2
 * Created on May 6, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author amolweb &lt; amolweb at ya hoo dot com &gt;
11
 *
12
 */
13
public class Atan extends DefaultFunctionImpl {
14
15
    /* (non-Javadoc)
16
     * @see org.apache.poi.hssf.record.formula.functions.DefaultFunctionImplEval#evaluate(org.apache.poi.hssf.record.formula.eval.Eval[])
17
     */
18
    public Eval evaluate(Eval[] operands) {
19
        return super.evaluate(operands);
20
    }
21
    
22
}
(-)org/apache/poi/hssf/record/formula/functions/Atan2.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Atan2 extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Atanh.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Atanh extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Avedev.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Avedev extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Average.java (+75 lines)
Added Link Here
1
/*
2
 * Created on May 6, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.AreaEval;
8
import org.apache.poi.hssf.record.formula.eval.ErrorEval;
9
import org.apache.poi.hssf.record.formula.eval.Eval;
10
import org.apache.poi.hssf.record.formula.eval.NumberEval;
11
import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
12
import org.apache.poi.hssf.record.formula.eval.RefEval;
13
import org.apache.poi.hssf.record.formula.eval.ValueEval;
14
15
/**
16
 * @author amolweb &lt; amolweb at ya hoo dot com &gt;
17
 *
18
 */
19
public class Average extends DefaultFunctionImpl {
20
21
	/* (non-Javadoc)
22
	 * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
23
	 */
24
	public Eval evaluate(Eval[] operands) {
25
		double d = 0;
26
		int count = 0;
27
		ValueEval retval = null;
28
		for (int i=0, iSize=operands.length; i<iSize; i++) {
29
		    if (operands[i] == null)
30
		         continue;
31
			if (operands[i] instanceof AreaEval) {
32
				AreaEval ap = (AreaEval) operands[i];
33
				Object[] values = ap.getValues();
34
				for (int j=0, jSize=values.length; j<jSize; j++) {
35
				    if (values[j]==null) 
36
				        continue;
37
					if (values[j] instanceof NumericValueEval) { 
38
						d += ((NumericValueEval) values[j]).getNumberValue();
39
						count++;
40
					}
41
					else if (values[j] instanceof RefEval) {
42
					    RefEval re = (RefEval) values[j];
43
					    ValueEval ve = re.getInnerValueEval();
44
						if (ve!=null && ve instanceof NumericValueEval) { 
45
							d += ((NumericValueEval) ve).getNumberValue();
46
							count++;
47
						}
48
					}
49
				}
50
			}
51
			else if (operands[i] instanceof NumericValueEval) {
52
				NumericValueEval np = (NumericValueEval) operands[i];
53
				d += np.getNumberValue();
54
				count++;
55
			}
56
			else if (operands[i] instanceof RefEval) {
57
			    RefEval re = (RefEval) operands[i];
58
			    ValueEval ve = re.getInnerValueEval();
59
			    if (ve instanceof NumericValueEval) {
60
			        NumericValueEval ne = (NumericValueEval) ve;
61
			        d += ne.getNumberValue();
62
			        count++;
63
			    }
64
			}
65
		}
66
67
		if (retval == null) {
68
		    retval = (Double.isNaN(d)) 
69
		    		? (ValueEval) ErrorEval.ERROR_502 
70
		            : new NumberEval(d/count);
71
		}
72
		return retval;
73
	}
74
75
}
(-)org/apache/poi/hssf/record/formula/functions/Averagea.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Averagea extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Betadist.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Betadist extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Betainv.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Betainv extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Binomdist.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Binomdist extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Call.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Call extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Caller.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Caller extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Cancelkey.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Cancelkey extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Ceiling.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Ceiling extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Cell.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Cell extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Char.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Char extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Checkcommand.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Checkcommand extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Chidist.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Chidist extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Chiinv.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Chiinv extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Chitest.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Chitest extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Choose.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Choose extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Clean.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Clean extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Code.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Code extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Column.java (+33 lines)
Added Link Here
1
/*
2
 * Created on May 6, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.ErrorEval;
8
import org.apache.poi.hssf.record.formula.eval.Eval;
9
import org.apache.poi.hssf.record.formula.eval.NumberEval;
10
import org.apache.poi.hssf.record.formula.eval.RefEval;
11
12
/**
13
 * @author amolweb &lt; amolweb at ya hoo dot com &gt;
14
 *
15
 */
16
public class Column extends DefaultFunctionImpl {
17
18
	/* (non-Javadoc)
19
	 * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
20
	 */
21
	public Eval evaluate(Eval[] operands) {
22
		Eval retval = null;
23
		if (operands[0] instanceof RefEval) {
24
			RefEval rp = (RefEval) operands[0];
25
			retval = new NumberEval(rp.getColumn()+1);
26
		}
27
		else {
28
			retval = ErrorEval.ERROR_504;
29
		}
30
		return retval;
31
	}
32
33
}
(-)org/apache/poi/hssf/record/formula/functions/Columns.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Columns extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Combin.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Combin extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Concatenate.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Concatenate extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Confidence.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Confidence extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Correl.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Correl extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Cos.java (+55 lines)
Added Link Here
1
/*
2
 * Created on May 6, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.AreaEval;
8
import org.apache.poi.hssf.record.formula.eval.ErrorEval;
9
import org.apache.poi.hssf.record.formula.eval.Eval;
10
import org.apache.poi.hssf.record.formula.eval.NumberEval;
11
import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
12
import org.apache.poi.hssf.record.formula.eval.RefEval;
13
import org.apache.poi.hssf.record.formula.eval.ValueEval;
14
15
/**
16
 * @author amolweb &lt; amolweb at ya hoo dot com &gt;
17
 *
18
 */
19
public class Cos extends DefaultFunctionImpl {
20
21
	/* (non-Javadoc)
22
	 * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
23
	 */
24
	public Eval evaluate(Eval[] operands) {
25
		ValueEval retval = null;
26
		double d = 0;
27
		if (operands.length == 1) {
28
			if (operands[0] instanceof NumericValueEval) {
29
			    NumericValueEval np = (NumericValueEval) operands[0];
30
				d = Math.cos(np.getNumberValue());
31
			}
32
			else if (operands[0] instanceof RefEval) {
33
			    RefEval re = (RefEval) operands[0];
34
			    ValueEval ve = re.getInnerValueEval();
35
			    if (ve!=null && ve instanceof NumericValueEval) {
36
			        NumericValueEval np = (NumericValueEval) ve;
37
					d = Math.cos(np.getNumberValue());
38
			    }
39
			}
40
			else if (operands[0] instanceof AreaEval) {
41
				retval = ErrorEval.INVALID_VALUE;
42
			}
43
			else {
44
				retval = ErrorEval.ERROR_502; 
45
			}
46
		}
47
		else {
48
			retval = ErrorEval.ERROR_508;
49
		}
50
		if (retval == null)
51
		    retval = new NumberEval(d);
52
		return retval;
53
	}
54
55
}
(-)org/apache/poi/hssf/record/formula/functions/Cosh.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Cosh extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Count.java (+63 lines)
Added Link Here
1
/*
2
 * Created on May 6, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.AreaEval;
8
import org.apache.poi.hssf.record.formula.eval.Eval;
9
import org.apache.poi.hssf.record.formula.eval.NumberEval;
10
import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
11
import org.apache.poi.hssf.record.formula.eval.RefEval;
12
import org.apache.poi.hssf.record.formula.eval.ValueEval;
13
14
/**
15
 * @author amolweb &lt; amolweb at ya hoo dot com &gt;
16
 *
17
 */
18
public class Count extends DefaultFunctionImpl {
19
20
	/* (non-Javadoc)
21
	 * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
22
	 */
23
	public Eval evaluate(Eval[] operands) {
24
		int count = 0;
25
		for (int i=0, iSize=operands.length; i<iSize; i++) {
26
			if (operands[i] instanceof AreaEval) {
27
				AreaEval ap = (AreaEval) operands[i];
28
				ValueEval[] values = ap.getValues();
29
				for (int j=0, jSize=values.length; j<jSize; j++) {
30
				    if (values[j]==null)
31
				        continue;
32
					if ((values[j] instanceof NumericValueEval)) {
33
					    count++;
34
					}
35
					else if (values[j] instanceof RefEval){
36
					    RefEval re = (RefEval) values[j];
37
					    ValueEval ve = re.getInnerValueEval();
38
						if ((values[j] instanceof NumericValueEval)) {
39
						    count++;
40
						}
41
					}
42
				}
43
			}
44
			else if (operands[i] instanceof NumericValueEval) {
45
			    count++;
46
			}
47
			else if (operands[i] instanceof RefEval){
48
			    RefEval re = (RefEval) operands[i];
49
			    ValueEval ve = re.getInnerValueEval();
50
				if ((operands[i] instanceof NumericValueEval)) {
51
				    count++;
52
				}
53
			}
54
		}
55
56
		// TODO: --Note-- 
57
		// Count behaves (slightly) differently in Oo and Excel.
58
		// Oo counts boolean values (whether true or false), Excel
59
		// ignores booleans. Strings are ignored by both Oo and Excel.
60
		return new NumberEval(count);
61
	}
62
63
}
(-)org/apache/poi/hssf/record/formula/functions/Counta.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Counta extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Countblank.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Countblank extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Countif.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Countif extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Covar.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Covar extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Createobject.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Createobject extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Critbinom.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Critbinom extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Customrepeat.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Customrepeat extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Customundo.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Customundo extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Date.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Date extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Datedif.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Datedif extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Datestring.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Datestring extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Datevalue.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Datevalue extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Daverage.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Daverage extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Day.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Day extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Days360.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Days360 extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Db.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Db extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Dbcs.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Dbcs extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Dcount.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Dcount extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Dcounta.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Dcounta extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Ddb.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Ddb extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/DefaultFunctionImpl.java (+21 lines)
Added Link Here
1
/*
2
 * Created on May 6, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.ErrorEval;
8
import org.apache.poi.hssf.record.formula.eval.Eval;
9
10
/**
11
 * 
12
 * @author amolweb &lt; amolweb at ya hoo dot com &gt;
13
 */
14
public abstract class DefaultFunctionImpl implements Function {
15
16
	public Eval evaluate(Eval[] operands) {
17
		return ErrorEval.FUNCTION_NOT_IMPLEMENTED;
18
	}
19
	
20
21
}
(-)org/apache/poi/hssf/record/formula/functions/Degrees.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Degrees extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Deletebar.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Deletebar extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Deletecommand.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Deletecommand extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Deletemenu.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Deletemenu extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Deletetoolbar.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Deletetoolbar extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Deref.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Deref extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Devsq.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Devsq extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Dget.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Dget extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Dialogbox.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Dialogbox extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Directory.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Directory extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Dmax.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Dmax extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Dmin.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Dmin extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Documents.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Documents extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Dollar.java (+77 lines)
Added Link Here
1
/*
2
 * Created on May 6, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.AreaEval;
8
import org.apache.poi.hssf.record.formula.eval.ErrorEval;
9
import org.apache.poi.hssf.record.formula.eval.Eval;
10
import org.apache.poi.hssf.record.formula.eval.NumberEval;
11
import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
12
import org.apache.poi.hssf.record.formula.eval.RefEval;
13
import org.apache.poi.hssf.record.formula.eval.StringEval;
14
import org.apache.poi.hssf.record.formula.eval.ValueEval;
15
16
/**
17
 * @author amolweb &lt; amolweb at ya hoo dot com &gt;
18
 * 
19
 */
20
public class Dollar extends DefaultFunctionImpl {
21
    //private static final DecimalFormat DOLLAR_FORMAT = new DecimalFormat("$#,##0.0#");
22
23
	/* (non-Javadoc)
24
	 * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
25
	 */
26
	public Eval evaluate(Eval[] operands) {
27
		double d = 0;
28
		ValueEval retval = null;
29
		if (operands[0] != null) {
30
			if (operands[0] instanceof NumericValueEval) {
31
				NumericValueEval np = (NumericValueEval) operands[0];
32
				d = np.getNumberValue();
33
			}
34
			else if (operands[0] instanceof RefEval) {
35
				RefEval re = (RefEval) operands[0];
36
				ValueEval ve = re.getInnerValueEval();
37
				if (ve!=null && ve instanceof NumericValueEval) {
38
					NumericValueEval np = (NumericValueEval) ve;
39
					d = np.getNumberValue();
40
				}
41
			}
42
			else if (operands[0] instanceof AreaEval) {
43
				 retval = ErrorEval.INVALID_VALUE;
44
			}
45
			else if (operands[0] instanceof StringEval) {
46
				StringEval se = (StringEval) operands[0];
47
				String s = se.getStringValue();
48
				try {
49
					d = Double.parseDouble(s);
50
				} catch (NumberFormatException nfe) {
51
					retval = ErrorEval.INVALID_VALUE;
52
				}
53
			}
54
			else {
55
				d=Math.tan(0); 
56
			}
57
		}
58
		if (retval == null) {
59
		    retval = new NumberEval(d);
60
		}
61
		
62
		// TODO: this is a little tricky function to implement:
63
		// because while display value is a dollar format string, 
64
		// the type is treated as numeric when used in formulas.
65
		// For now, the returned type is kept "NumberEval"
66
		// since it will cause it to work better with other
67
		// formulas.
68
		// MoreImportantly, OpenOffice and Excel differ in their
69
		// implementation of DOLLAR, Oo treats DOLLAr eval as 
70
		// String, Excel treats it as Number - This class
71
		// treats it as a number but/hence does not do the
72
		// formatting that DOLLAR should: In programs, this
73
		//  impl should be more useful.
74
		return retval;
75
	}
76
77
}
(-)org/apache/poi/hssf/record/formula/functions/Dproduct.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Dproduct extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Dstdev.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Dstdev extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Dstdevp.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Dstdevp extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Dsum.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Dsum extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Dvar.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Dvar extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Dvarp.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Dvarp extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Echo.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Echo extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Enablecommand.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Enablecommand extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Enabletool.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Enabletool extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Error.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Error extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Errortype.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Errortype extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Evaluate.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Evaluate extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Even.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Even extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Exact.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Exact extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Exec.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Exec extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Execute.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Execute extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Exp.java (+36 lines)
Added Link Here
1
/*
2
 * Created on May 6, 2005
3
 */
4
package org.apache.poi.hssf.record.formula.functions;
5
6
import org.apache.poi.hssf.record.formula.eval.ErrorEval;
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
import org.apache.poi.hssf.record.formula.eval.NumberEval;
9
import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
10
import org.apache.poi.hssf.record.formula.eval.ValueEval;
11
/**
12
 * @author amolweb &lt; amolweb at ya hoo dot com &gt;
13
 *
14
 */
15
public class Exp extends DefaultFunctionImpl {
16
17
	/* (non-Javadoc)
18
	 * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
19
	 */
20
	public Eval evaluate(Eval[] operands) {
21
		double d = 0;
22
		ValueEval retval = null;
23
		if (operands!=null) {
24
			if (operands[0] instanceof NumericValueEval) {
25
			    NumericValueEval np = (NumericValueEval) operands[0];
26
				d = Math.pow(Math.E, np.getNumberValue());
27
			}
28
			else {
29
				retval = ErrorEval.INVALID_VALUE;
30
			}
31
		}
32
		if (retval == null) 
33
		    retval = new NumberEval(d);
34
		return retval;
35
	}
36
}
(-)org/apache/poi/hssf/record/formula/functions/Expondist.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Expondist extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Externalflag.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Externalflag extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Fact.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Fact extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/False.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class False extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Fclose.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Fclose extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Fdist.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Fdist extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Files.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Files extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Find.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Find extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Findb.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Findb extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Finv.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Finv extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Fisher.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Fisher extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Fisherinv.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Fisherinv extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Fixed.java (+127 lines)
Added Link Here
1
/*
2
 * Created on May 6, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
import org.apache.poi.hssf.record.formula.eval.NumberEval;
9
import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
10
11
/**
12
 * @author amolweb &lt; amolweb at ya hoo dot com &gt;
13
 * <pre>
14
 * Function spec:
15
 * 1. numargs= 1-3
16
 * 2. args= 1: number; 2: decimal places; 3: show thousands separator?
17
 * </pre>
18
 */
19
public class Fixed extends DefaultFunctionImpl {
20
    
21
    private static final boolean DEFAULT_SHOW_THOUSANDS_SEP = true;
22
    private static final int DEFAULT_NUM_DIGITS_AFTER_DECIMALS = 2;
23
24
	/* (non-Javadoc)
25
	 * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
26
	 */
27
	public Eval evaluate(Eval[] operands) {
28
		double d;
29
		boolean showThousandsSep = DEFAULT_SHOW_THOUSANDS_SEP;
30
		int numdecimals=DEFAULT_NUM_DIGITS_AFTER_DECIMALS;
31
		
32
		switch (operands.length) {
33
		case 3:
34
		    if (operands[2] instanceof NumericValueEval) {
35
		        NumericValueEval np = (NumericValueEval) operands[2];
36
		        showThousandsSep = np.getNumberValue() != 0;
37
		    }
38
		    else {
39
		        showThousandsSep = false;
40
		    }
41
		case 2:
42
		    if (operands[1] instanceof NumericValueEval) {
43
		        NumericValueEval np = (NumericValueEval) operands[1];
44
		        numdecimals = (int) np.getNumberValue();
45
		    }
46
		    else {
47
		        numdecimals = 0;
48
		    }
49
		default: // 1 operand
50
		    if (operands[0] instanceof NumericValueEval) {
51
		        NumericValueEval np = (NumericValueEval) operands[0];
52
		        d = np.getNumberValue();
53
		    }
54
		    else {
55
		        d = 0;
56
		    }
57
		}
58
		
59
		// String str = formatDecimal(d, numdecimals, showThousandsSep);
60
		// return new StringPtg(str);
61
		// TODO: this is a little tricky function to implement:
62
		// because while display value is a fixed format string, 
63
		// the type is treated as numeric when used in formulas.
64
		// For now, the returned type is kept "NumberEval"
65
		// since it will cause it to work better with other
66
		// formulas.
67
		// MoreImportantly, OpenOffice and Excel differ in their
68
		// implementation of FIXED, Oo treats FIXED eval as 
69
		// String, Excel treats it as Number - This class
70
		// treats it as a number but/hence does not do the
71
		// formatting that FIXED should: In programs, this
72
		//  impl should be more useful. 
73
		// To switch to strictly Oo implementation, uncomment the 
74
		// 2 lines above this_TODO and remove the lines below 
75
		// this_TODO.
76
		
77
		return new NumberEval(d);
78
	}
79
	
80
	/**
81
	 * return string representation of double with specified formatting options
82
	 * @param d
83
	 * @param numdecimals
84
	 * @param showT
85
	 * @return
86
	 */
87
	static final String formatDecimal(double d, int numdecimals, boolean showT) {
88
	    StringBuffer sb = new StringBuffer(50); // 50 => optimze for speed for common values
89
	    long integral = (long) d;
90
	    double fraction = d-integral;
91
92
	    if (showT) {
93
	        String sintegral = String.valueOf(integral);
94
	        for (int i=sintegral.length()-1, j=1; i>=0; i--, j++) {
95
	            char c = sintegral.charAt(i);
96
	            sb.append(c);
97
	            if (j%3==0 && i!=0) sb.append(',');
98
	        }
99
	        sb.reverse();
100
	    }
101
	    else {
102
	        sb.append(integral);
103
	    }
104
	    sb.append(ensureLength(fraction, numdecimals));
105
	    return sb.toString();
106
	}
107
	
108
	// TODO: optimize this function
109
	/**
110
	 * returns a truncated or padded String representation of
111
	 * double fraction. double fraction MUST be >0 && <1.
112
	 */
113
	static final String ensureLength(double fraction, int numdecimals) {
114
	    StringBuffer sb = new StringBuffer();
115
	    if (numdecimals != 0) {
116
		    int ifraction = (int) (fraction * Math.pow(10, numdecimals));
117
		    String sfraction = String.valueOf(ifraction);
118
		    
119
		    sb.append('.').append(ifraction);
120
		    for (int i=numdecimals-sfraction.length(); i>0; i--) {
121
		        sb.append('0');
122
		    }
123
	    }
124
	    return sb.toString();
125
	}
126
127
}
(-)org/apache/poi/hssf/record/formula/functions/Floor.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Floor extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Fopen.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Fopen extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Forecast.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Forecast extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Formulaconvert.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Formulaconvert extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Fpos.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Fpos extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Fread.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Fread extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Freadln.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Freadln extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Frequency.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Frequency extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Fsize.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Fsize extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Ftest.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Ftest extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Function.java (+18 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 * TODO To change the template for this generated file go to
5
 * Window - Preferences - Java - Code Style - Code Templates
6
 */
7
package org.apache.poi.hssf.record.formula.functions;
8
9
import org.apache.poi.hssf.record.formula.eval.Eval;
10
11
/**
12
 * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
13
 *
14
 */
15
public interface Function {
16
17
    public Eval evaluate(Eval[] operands);
18
}
(-)org/apache/poi/hssf/record/formula/functions/Fv.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Fv extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Fwrite.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Fwrite extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Fwriteln.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Fwriteln extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Gammadist.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Gammadist extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Gammainv.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Gammainv extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Gammaln.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Gammaln extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Geomean.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Geomean extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Getbar.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Getbar extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Getcell.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Getcell extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Getchartitem.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Getchartitem extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Getdef.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Getdef extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Getdocument.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Getdocument extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Getformula.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Getformula extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Getlinkinfo.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Getlinkinfo extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Getmovie.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Getmovie extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Getname.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Getname extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Getnote.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Getnote extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Getobject.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Getobject extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Getpivotdata.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Getpivotdata extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Getpivotfield.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Getpivotfield extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Getpivotitem.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Getpivotitem extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Getpivottable.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Getpivottable extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Gettool.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Gettool extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Gettoolbar.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Gettoolbar extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Getwindow.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Getwindow extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Getworkbook.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Getworkbook extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Getworkspace.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Getworkspace extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Goto.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Goto extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Group.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Group extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Growth.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Growth extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Halt.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Halt extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Harmean.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Harmean extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Help.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Help extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Hlookup.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Hlookup extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Hour.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Hour extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Hyperlink.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Hyperlink extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Hypgeomdist.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Hypgeomdist extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Index.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Index extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Indirect.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Indirect extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Info.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Info extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Initiate.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Initiate extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Input.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Input extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Int.java (+52 lines)
Added Link Here
1
/*
2
 * Created on May 6, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.ErrorEval;
8
import org.apache.poi.hssf.record.formula.eval.Eval;
9
import org.apache.poi.hssf.record.formula.eval.NumberEval;
10
import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
11
import org.apache.poi.hssf.record.formula.eval.RefEval;
12
import org.apache.poi.hssf.record.formula.eval.StringEval;
13
import org.apache.poi.hssf.record.formula.eval.ValueEval;
14
15
/**
16
 * @author amolweb &lt; amolweb at ya hoo dot com &gt;
17
 *
18
 */
19
public class Int extends DefaultFunctionImpl {
20
21
	/* (non-Javadoc)
22
	 * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
23
	 */
24
	public Eval evaluate(Eval[] operands) {
25
		double d = 0;
26
		ValueEval retval = null;
27
		if (operands.length == 1) {
28
			if (operands[0] instanceof NumericValueEval) {
29
				NumericValueEval ne = (NumericValueEval) operands[0];
30
				d = ne.getNumberValue();
31
			}
32
			else if (operands[0] instanceof RefEval) {
33
			    
34
			}
35
			else if (operands[0] instanceof StringEval) {
36
				retval = ErrorEval.ERROR_502;
37
			}
38
		}
39
		else if (operands.length > 1) {
40
		    retval = ErrorEval.ERROR_508;
41
		}
42
		else {
43
		    retval = ErrorEval.ERROR_511;
44
		}
45
		if (retval == null) {
46
		    retval = new NumberEval(d);
47
		}
48
		
49
		return retval;
50
	}
51
52
}
(-)org/apache/poi/hssf/record/formula/functions/Intercept.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Intercept extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Ipmt.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Ipmt extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Irr.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Irr extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/IsError.java (+26 lines)
Added Link Here
1
/*
2
 * Created on May 6, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.AreaEval;
8
import org.apache.poi.hssf.record.formula.eval.BoolEval;
9
import org.apache.poi.hssf.record.formula.eval.ErrorEval;
10
import org.apache.poi.hssf.record.formula.eval.Eval;
11
12
/**
13
 * @author amolweb &lt; amolweb at ya hoo dot com &gt;
14
 *
15
 */
16
public class IsError extends DefaultFunctionImpl {
17
18
	/* (non-Javadoc)
19
	 * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
20
	 */
21
	public Eval evaluate(Eval[] operands) {
22
	    boolean b = (operands[0] instanceof ErrorEval) || (operands[0] instanceof AreaEval);
23
		return new BoolEval(b);
24
	}
25
26
}
(-)org/apache/poi/hssf/record/formula/functions/IsNa.java (+25 lines)
Added Link Here
1
/*
2
 * Created on May 6, 2005
3
 *
4
 * TODO To change the template for this generated file go to
5
 * Window - Preferences - Java - Code Style - Code Templates
6
 */
7
package org.apache.poi.hssf.record.formula.functions;
8
9
import org.apache.poi.hssf.record.formula.eval.Eval;
10
11
/**
12
 * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
13
 *
14
 * Window - Preferences - Java - Code Style - Code Templates
15
 */
16
public class IsNa extends DefaultFunctionImpl {
17
18
	/* (non-Javadoc)
19
	 * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
20
	 */
21
	public Eval evaluate(Eval[] operands) {
22
		return super.evaluate(operands);
23
	}
24
25
}
(-)org/apache/poi/hssf/record/formula/functions/Isblank.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Isblank extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Iserr.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Iserr extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Islogical.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Islogical extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Isnontext.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Isnontext extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Isnumber.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Isnumber extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Ispmt.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Ispmt extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Isref.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Isref extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Istext.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Istext extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Kurt.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Kurt extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Large.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Large extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Lasterror.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Lasterror extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Left.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Left extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Leftb.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Leftb extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Len.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Len extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Lenb.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Lenb extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Linest.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Linest extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Links.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Links extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Ln.java (+61 lines)
Added Link Here
1
/*
2
 * Created on May 6, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.AreaEval;
8
import org.apache.poi.hssf.record.formula.eval.ErrorEval;
9
import org.apache.poi.hssf.record.formula.eval.Eval;
10
import org.apache.poi.hssf.record.formula.eval.NumberEval;
11
import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
12
import org.apache.poi.hssf.record.formula.eval.RefEval;
13
import org.apache.poi.hssf.record.formula.eval.ValueEval;
14
15
/**
16
 * @author amolweb &lt; amolweb at ya hoo dot com &gt;
17
 *
18
 */
19
public class Ln extends DefaultFunctionImpl {
20
21
	/* (non-Javadoc)
22
	 * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
23
	 */
24
	public Eval evaluate(Eval[] operands) {
25
		double d = 0;
26
		ValueEval retval = null;
27
		switch (operands.length) {
28
		case 1:
29
			if (operands[0] instanceof NumericValueEval) {
30
			    NumericValueEval ne = (NumericValueEval) operands[0];
31
				d = Math.log(ne.getNumberValue());
32
			}
33
			else if (operands[0] instanceof RefEval) {
34
			    RefEval re = (RefEval) operands[0];
35
			    ValueEval ve = re.getInnerValueEval();
36
			    if (ve instanceof NumericValueEval) {
37
				    NumericValueEval ne = (NumericValueEval) ve;
38
					d = Math.log(ne.getNumberValue());
39
			    }
40
			}
41
			else if (operands[0] instanceof AreaEval) {
42
				 retval = ErrorEval.INVALID_VALUE;
43
			}
44
			else {
45
			    retval = ErrorEval.ERROR_502; 
46
			}
47
		    break;
48
		case 0:
49
		    retval = ErrorEval.ERROR_502;
50
		    break;
51
		default:
52
		    retval = ErrorEval.ERROR_508;
53
		}
54
		if (retval == null) {
55
		    retval = (Double.isNaN(d)) ? (ValueEval) ErrorEval.ERROR_503 : new NumberEval(d);
56
		}
57
		
58
		return retval;
59
	}
60
61
}
(-)org/apache/poi/hssf/record/formula/functions/Log.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Log extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Log10.java (+63 lines)
Added Link Here
1
/*
2
 * Created on May 6, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.AreaEval;
8
import org.apache.poi.hssf.record.formula.eval.ErrorEval;
9
import org.apache.poi.hssf.record.formula.eval.Eval;
10
import org.apache.poi.hssf.record.formula.eval.NumberEval;
11
import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
12
import org.apache.poi.hssf.record.formula.eval.RefEval;
13
import org.apache.poi.hssf.record.formula.eval.ValueEval;
14
15
/**
16
 * @author amolweb &lt; amolweb at ya hoo dot com &gt;
17
 *
18
 */
19
public class Log10 extends DefaultFunctionImpl {
20
	private static final double LOG_10_TO_BASE_e = Math.log(10);
21
	
22
23
	/* (non-Javadoc)
24
	 * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
25
	 */
26
	public Eval evaluate(Eval[] operands) {
27
		double d = 0;
28
		ValueEval retval = null;
29
		switch (operands.length) {
30
		case 1:
31
			if (operands[0] instanceof NumericValueEval) {
32
			    NumericValueEval ne = (NumericValueEval) operands[0];
33
				d = Math.log(ne.getNumberValue());
34
			}
35
			else if (operands[0] instanceof RefEval) {
36
			    RefEval re = (RefEval) operands[0];
37
			    ValueEval ve = re.getInnerValueEval();
38
			    if (ve instanceof NumericValueEval) {
39
				    NumericValueEval ne = (NumericValueEval) operands[0];
40
					d = Math.log(ne.getNumberValue());
41
			    }
42
			}
43
			else if (operands[0] instanceof AreaEval) {
44
				 retval = ErrorEval.INVALID_VALUE;
45
			}
46
			else {
47
			    retval = ErrorEval.ERROR_502; 
48
			}
49
		    break;
50
		case 0:
51
		    retval = ErrorEval.ERROR_502;
52
		    break;
53
		default:
54
		    retval = ErrorEval.ERROR_508;
55
		}
56
		if (retval != null) {
57
		    retval = (Double.isNaN(d)) ? (ValueEval) ErrorEval.ERROR_503 : new NumberEval(d/LOG_10_TO_BASE_e);
58
		}
59
		
60
		return retval;
61
	}
62
63
}
(-)org/apache/poi/hssf/record/formula/functions/Logest.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Logest extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Loginv.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Loginv extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Lognormdist.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Lognormdist extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Lookup.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Lookup extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Lower.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Lower extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Match.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Match extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Max.java (+54 lines)
Added Link Here
1
/*
2
 * Created on May 6, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.AreaEval;
8
import org.apache.poi.hssf.record.formula.eval.Eval;
9
import org.apache.poi.hssf.record.formula.eval.NumberEval;
10
import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
11
import org.apache.poi.hssf.record.formula.eval.RefEval;
12
import org.apache.poi.hssf.record.formula.eval.ValueEval;
13
14
/**
15
 * @author amolweb &lt; amolweb at ya hoo dot com &gt;
16
 *
17
 */
18
public class Max extends DefaultFunctionImpl {
19
20
	/* (non-Javadoc)
21
	 * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
22
	 */
23
	public Eval evaluate(Eval[] operands) {
24
		double d = 0;
25
		for (int i=0, iSize=operands.length; i<iSize; i++) {
26
			if (operands[i] instanceof AreaEval) {
27
			    AreaEval ap = (AreaEval) operands[i];
28
				ValueEval[] values = ap.getValues();
29
				for (int j=0, jSize=values.length; j<jSize; j++) {
30
				    if (values[j]!=null) {
31
						if (values[j] instanceof NumericValueEval) {
32
							d = Math.max(((NumericValueEval) values[j]).getNumberValue(), d);
33
						}
34
						else if (values[j] instanceof RefEval)	{
35
						    ValueEval ve = ((RefEval) values[j]).getInnerValueEval();
36
						    if (ve!=null)
37
						        d = Math.max(((NumericValueEval) ve).getNumberValue(), d);
38
						}
39
				    }
40
				}
41
			}
42
			else if (operands[i] instanceof NumericValueEval) {
43
				d = Math.max(((NumericValueEval) operands[i]).getNumberValue(), d);
44
			}
45
			else if (operands[i] instanceof RefEval)	{
46
			    ValueEval ve = ((RefEval) operands[i]).getInnerValueEval();
47
			    if (ve!=null)
48
			        d = Math.max(((NumericValueEval) ve).getNumberValue(), d);
49
			}
50
		}
51
		
52
		return new NumberEval(d);
53
	}
54
}
(-)org/apache/poi/hssf/record/formula/functions/Maxa.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Maxa extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Mdeterm.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Mdeterm extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Median.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Median extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Mid.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Mid extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Midb.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Midb extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Min.java (+54 lines)
Added Link Here
1
/*
2
 * Created on May 6, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.AreaEval;
8
import org.apache.poi.hssf.record.formula.eval.Eval;
9
import org.apache.poi.hssf.record.formula.eval.NumberEval;
10
import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
11
import org.apache.poi.hssf.record.formula.eval.RefEval;
12
import org.apache.poi.hssf.record.formula.eval.ValueEval;
13
14
/**
15
 * @author amolweb &lt; amolweb at ya hoo dot com &gt;
16
 *
17
 */
18
public class Min extends DefaultFunctionImpl {
19
20
	/* (non-Javadoc)
21
	 * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
22
	 */
23
	public Eval evaluate(Eval[] operands) {
24
		double d = 0;
25
		for (int i=0, iSize=operands.length; i<iSize; i++) {
26
			if (operands[i] instanceof AreaEval) {
27
			    AreaEval ap = (AreaEval) operands[i];
28
				ValueEval[] values = ap.getValues();
29
				for (int j=0, jSize=values.length; j<jSize; j++) {
30
				    if (values[j]!=null) {
31
						if (values[j] instanceof NumericValueEval) {
32
							d = Math.min(((NumericValueEval) values[j]).getNumberValue(), d);
33
						}
34
						else if (values[j] instanceof RefEval)	{
35
						    ValueEval ve = ((RefEval) values[j]).getInnerValueEval();
36
						    if (ve!=null)
37
						        d = Math.min(((NumericValueEval) ve).getNumberValue(), d);
38
						}
39
				    }
40
				}
41
			}
42
			else if (operands[i] instanceof NumericValueEval) {
43
				d = Math.min(((NumericValueEval) operands[i]).getNumberValue(), d);
44
			}
45
			else if (operands[i] instanceof RefEval)	{
46
			    ValueEval ve = ((RefEval) operands[i]).getInnerValueEval();
47
			    if (ve!=null)
48
			        d = Math.min(((NumericValueEval) ve).getNumberValue(), d);
49
			}
50
		}
51
		
52
		return new NumberEval(d);
53
	}
54
}
(-)org/apache/poi/hssf/record/formula/functions/Mina.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Mina extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Minute.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Minute extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Minverse.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Minverse extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Mirr.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Mirr extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Mmult.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Mmult extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Mod.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Mod extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Mode.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Mode extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Month.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Month extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Moviecommand.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Moviecommand extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/N.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class N extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Na.java (+24 lines)
Added Link Here
1
/*
2
 * Created on May 6, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
11
 *
12
 */
13
14
public class Na extends DefaultFunctionImpl {
15
16
    
17
	/* (non-Javadoc)
18
	 * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
19
	 */
20
	public Eval evaluate(Eval[] operands) {
21
	    return super.evaluate(operands);
22
	}
23
24
}
(-)org/apache/poi/hssf/record/formula/functions/Names.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Names extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Negbinomdist.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Negbinomdist extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Normdist.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Normdist extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Norminv.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Norminv extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Normsdist.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Normsdist extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Normsinv.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Normsinv extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Not.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Not extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Note.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Note extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Now.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Now extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Nper.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Nper extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Npv.java (+91 lines)
Added Link Here
1
/*
2
 * Created on May 6, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.AreaEval;
8
import org.apache.poi.hssf.record.formula.eval.ErrorEval;
9
import org.apache.poi.hssf.record.formula.eval.Eval;
10
import org.apache.poi.hssf.record.formula.eval.NumberEval;
11
import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
12
import org.apache.poi.hssf.record.formula.eval.RefEval;
13
import org.apache.poi.hssf.record.formula.eval.ValueEval;
14
15
/**
16
 * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
17
 *
18
 */
19
20
public class Npv extends DefaultFunctionImpl {
21
22
	/* (non-Javadoc)
23
	 * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Eval[])
24
	 */
25
	public Eval evaluate(Eval[] operands) {
26
		double d = 0;
27
		double rate = 0;
28
		ValueEval retval = null;
29
		
30
		if (operands[0] instanceof NumericValueEval) {
31
		    NumericValueEval np = (NumericValueEval) operands[0];
32
		    rate = np.getNumberValue();
33
		}
34
		else if (operands[0] instanceof RefEval) {
35
		    RefEval re = (RefEval) operands[0];
36
		    ValueEval ve = re.getInnerValueEval();
37
		    if (ve instanceof NumericValueEval) {
38
			    NumericValueEval np = (NumericValueEval) ve;
39
			    rate = np.getNumberValue();
40
			}				
41
		}
42
		else {
43
		    retval = ErrorEval.ERROR_503;
44
		}
45
		double denomVal = rate+1;
46
		
47
		if (retval == null) {
48
			for (int i=1, k=1, iSize=operands.length; i<iSize; i++) {
49
				if (operands[i] instanceof AreaEval) {
50
					AreaEval ap = (AreaEval) operands[i];
51
					Object[] values = ap.getValues();
52
					for (int j=0, jSize=values.length; j<jSize; j++) {
53
						if (values[j]==null || !(values[j] instanceof Number)) 
54
							continue;
55
						double value = ((Number) values[j]).doubleValue();
56
						d += value / denomVal;
57
						denomVal = (rate+1) * denomVal;
58
					}
59
				}
60
				else if (operands[i] instanceof NumericValueEval) {
61
					NumberEval np = (NumberEval) operands[i];
62
					double value = np.getNumberValue();
63
					d += value / denomVal;
64
					denomVal = (rate+1) * denomVal;
65
				}
66
				else if (operands[i] instanceof RefEval) {
67
				    RefEval re = (RefEval) operands[i];
68
				    ValueEval ve = re.getInnerValueEval();
69
				    if (ve instanceof NumericValueEval) {
70
						NumberEval np = (NumberEval) ve;
71
						double value = np.getNumberValue();
72
						d += value / denomVal;
73
						denomVal = (rate+1) * denomVal;
74
					}				
75
				}
76
				else {
77
				    retval = ErrorEval.ERROR_503;
78
				}
79
			}
80
		}
81
		else {
82
		    retval = ErrorEval.ERROR_503;
83
		}
84
		
85
		if (retval == null)
86
		    retval = new NumberEval(d);
87
		
88
		return retval;
89
	}
90
91
}
(-)org/apache/poi/hssf/record/formula/functions/Numberstring.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Numberstring extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Odd.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Odd extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Offset.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Offset extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Opendialog.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Opendialog extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Optionslistsget.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Optionslistsget extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Or.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Or extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Pause.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Pause extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Pearson.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Pearson extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Percentile.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Percentile extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Percentrank.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Percentrank extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Permut.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Permut extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Phonetic.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Phonetic extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Pi.java (+25 lines)
Added Link Here
1
/*
2
 * Created on May 6, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
import org.apache.poi.hssf.record.formula.eval.NumberEval;
9
10
/**
11
 * @author amolweb &lt; amolweb at ya hoo dot com &gt;
12
 *
13
 */
14
public class Pi extends DefaultFunctionImpl {
15
16
    private static final NumberEval PI_EVAL = new NumberEval(Math.PI);
17
    
18
	/* (non-Javadoc)
19
	 * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
20
	 */
21
	public Eval evaluate(Eval[] operands) {
22
		return PI_EVAL;
23
	}
24
25
}
(-)org/apache/poi/hssf/record/formula/functions/Pivotadddata.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Pivotadddata extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Pmt.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Pmt extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Poisson.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Poisson extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Poke.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Poke extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Power.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Power extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Ppmt.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Ppmt extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Presstool.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Presstool extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Prob.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Prob extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Product.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Product extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Proper.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Proper extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Pv.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Pv extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Quartile.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Quartile extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Radians.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Radians extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Rand.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Rand extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Rank.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Rank extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Rate.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Rate extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Reftext.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Reftext extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Register.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Register extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Registerid.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Registerid extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Relref.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Relref extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Renamecommand.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Renamecommand extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Replace.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Replace extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Replaceb.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Replaceb extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Rept.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Rept extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Request.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Request extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Resettoolbar.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Resettoolbar extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Restart.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Restart extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Result.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Result extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Resume.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Resume extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Right.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Right extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Rightb.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Rightb extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Roman.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Roman extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Round.java (+74 lines)
Added Link Here
1
/*
2
 * Created on May 6, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.ErrorEval;
8
import org.apache.poi.hssf.record.formula.eval.Eval;
9
import org.apache.poi.hssf.record.formula.eval.NumberEval;
10
import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
11
import org.apache.poi.hssf.record.formula.eval.RefEval;
12
import org.apache.poi.hssf.record.formula.eval.ValueEval;
13
14
/**
15
 * @author amolweb &lt; amolweb at ya hoo dot com &gt;
16
 *
17
 */
18
public class Round extends DefaultFunctionImpl {
19
20
    private static final short DEFAULT_ACCURACY = 0;
21
    
22
	/* (non-Javadoc)
23
	 * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
24
	 */
25
	public Eval evaluate(Eval[] operands) {
26
		short accuracy = DEFAULT_ACCURACY;
27
		double d = 0;
28
		ValueEval retval = null;
29
		if (operands[0] instanceof NumericValueEval) {
30
		    NumericValueEval bp = (NumericValueEval) operands[0];
31
		    d = bp.getNumberValue();
32
		}
33
		else if (operands[0] instanceof RefEval) {
34
		    RefEval re = (RefEval) operands[0];
35
		    ValueEval ve = re.getInnerValueEval();
36
			if (ve instanceof NumericValueEval) {
37
			    NumericValueEval n = (NumericValueEval) ve;
38
			    d = n.getNumberValue();
39
			}
40
		}
41
		else {
42
		    retval = ErrorEval.ERROR_502;
43
		}
44
		
45
		if (operands.length == 2) {
46
			if (operands[1] instanceof NumericValueEval) {
47
			    NumericValueEval bp = (NumericValueEval) operands[0];
48
			    accuracy = (short) bp.getNumberValue();
49
			}
50
			else if (operands[1] instanceof RefEval) {
51
			    RefEval re = (RefEval) operands[1];
52
			    ValueEval ve = re.getInnerValueEval();
53
				if (ve instanceof NumericValueEval) {
54
				    NumericValueEval n = (NumericValueEval) ve;
55
				    accuracy = (short) n.getNumberValue();
56
				}
57
			}
58
			else {
59
			    retval = ErrorEval.ERROR_502;
60
			}
61
		}
62
		else if (operands.length > 2) {
63
		    retval = ErrorEval.ERROR_504;
64
		}
65
		if (retval == null) {
66
			double power = Math.pow(10, accuracy);
67
			d *= power;
68
			d = Math.round(d);
69
			retval = new NumberEval(d/power);
70
		}
71
		return retval;
72
	}
73
74
}
(-)org/apache/poi/hssf/record/formula/functions/Rounddown.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Rounddown extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Roundup.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Roundup extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Row.java (+33 lines)
Added Link Here
1
/*
2
 * Created on May 6, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.ErrorEval;
8
import org.apache.poi.hssf.record.formula.eval.Eval;
9
import org.apache.poi.hssf.record.formula.eval.NumberEval;
10
import org.apache.poi.hssf.record.formula.eval.RefEval;
11
12
/**
13
 * @author amolweb &lt; amolweb at ya hoo dot com &gt;
14
 *
15
 */
16
public class Row extends DefaultFunctionImpl {
17
18
	/* (non-Javadoc)
19
	 * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
20
	 */
21
	public Eval evaluate(Eval[] operands) {
22
		Eval retval = null;
23
		if (operands[0] instanceof RefEval) {
24
			RefEval rp = (RefEval) operands[0];
25
			retval = new NumberEval(rp.getRow()+1);
26
		}
27
		else {
28
			retval = ErrorEval.ERROR_504;
29
		}
30
		return retval;
31
	}
32
33
}
(-)org/apache/poi/hssf/record/formula/functions/Rows.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Rows extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Rsq.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Rsq extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Savedialog.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Savedialog extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Savetoolbar.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Savetoolbar extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Scenarioget.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Scenarioget extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Search.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Search extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Searchb.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Searchb extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Second.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Second extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Selection.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Selection extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Series.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Series extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Setname.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Setname extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Setvalue.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Setvalue extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Showbar.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Showbar extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Sign.java (+44 lines)
Added Link Here
1
/*
2
 * Created on May 6, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
import org.apache.poi.hssf.record.formula.eval.NumberEval;
9
import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
10
import org.apache.poi.hssf.record.formula.eval.ValueEval;
11
12
/**
13
 * @author amolweb &lt; amolweb at ya hoo dot com &gt;
14
 *
15
 */
16
public class Sign extends DefaultFunctionImpl {
17
18
    private static final NumberEval NEG_SIGN_EVAL = new NumberEval(-1);
19
    private static final NumberEval POS_SIGN_EVAL = new NumberEval(1);
20
    private static final NumberEval ZERO_SIGN_EVAL = new NumberEval(0);
21
    
22
	/* (non-Javadoc)
23
	 * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
24
	 */
25
	public Eval evaluate(Eval[] operands) {
26
	    double d = 0;
27
	    ValueEval retval = null;
28
	    if (operands[0] instanceof NumericValueEval) {
29
	        NumericValueEval nve = (NumericValueEval) operands[0];
30
	        d = nve.getNumberValue();
31
	    }
32
	    if (d == 0) {
33
	        retval = ZERO_SIGN_EVAL;
34
	    }
35
	    else if (d < 0) {
36
	        retval = NEG_SIGN_EVAL;
37
	    }
38
	    else if (d > 0) {
39
	        retval = POS_SIGN_EVAL;
40
	    }
41
		return retval;
42
	}
43
44
}
(-)org/apache/poi/hssf/record/formula/functions/Sin.java (+55 lines)
Added Link Here
1
/*
2
 * Created on May 6, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.AreaEval;
8
import org.apache.poi.hssf.record.formula.eval.ErrorEval;
9
import org.apache.poi.hssf.record.formula.eval.Eval;
10
import org.apache.poi.hssf.record.formula.eval.NumberEval;
11
import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
12
import org.apache.poi.hssf.record.formula.eval.RefEval;
13
import org.apache.poi.hssf.record.formula.eval.ValueEval;
14
15
/**
16
 * @author amolweb &lt; amolweb at ya hoo dot com &gt;
17
 *
18
 */
19
public class Sin extends DefaultFunctionImpl {
20
21
	/* (non-Javadoc)
22
	 * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
23
	 */
24
	public Eval evaluate(Eval[] operands) {
25
		ValueEval retval = null;
26
		double d = 0;
27
		if (operands.length == 1) {
28
			if (operands[0] instanceof NumericValueEval) {
29
			    NumericValueEval np = (NumericValueEval) operands[0];
30
				d = Math.sin(np.getNumberValue());
31
			}
32
			else if (operands[0] instanceof RefEval) {
33
			    RefEval re = (RefEval) operands[0];
34
			    ValueEval ve = re.getInnerValueEval();
35
			    if (ve!=null && ve instanceof NumericValueEval) {
36
			        NumericValueEval np = (NumericValueEval) ve;
37
					d = Math.sin(np.getNumberValue());
38
			    }
39
			}
40
			else if (operands[0] instanceof AreaEval) {
41
				retval = ErrorEval.INVALID_VALUE;
42
			}
43
			else {
44
				retval = ErrorEval.ERROR_502; 
45
			}
46
		}
47
		else {
48
			retval = ErrorEval.ERROR_508;
49
		}
50
		if (retval == null)
51
		    retval = new NumberEval(d);
52
		return retval;
53
	}
54
55
}
(-)org/apache/poi/hssf/record/formula/functions/Sinh.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Sinh extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Skew.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Skew extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Sln.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Sln extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Slope.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Slope extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Small.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Small extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Spellingcheck.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Spellingcheck extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Sqrt.java (+56 lines)
Added Link Here
1
/*
2
 * Created on May 6, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.AreaEval;
8
import org.apache.poi.hssf.record.formula.eval.ErrorEval;
9
import org.apache.poi.hssf.record.formula.eval.Eval;
10
import org.apache.poi.hssf.record.formula.eval.NumberEval;
11
import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
12
import org.apache.poi.hssf.record.formula.eval.RefEval;
13
import org.apache.poi.hssf.record.formula.eval.ValueEval;
14
15
/**
16
 * @author amolweb &lt; amolweb at ya hoo dot com &gt;
17
 *
18
 */
19
public class Sqrt extends DefaultFunctionImpl {
20
21
	/* (non-Javadoc)
22
	 * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
23
	 */
24
	public Eval evaluate(Eval[] operands) {
25
		ValueEval retval = null;
26
		double d = 0;
27
		if (operands.length == 1) {
28
			if (operands[0] instanceof NumericValueEval) {
29
			    NumericValueEval np = (NumericValueEval) operands[0];
30
				d = Math.sqrt(np.getNumberValue());
31
			}
32
			else if (operands[0] instanceof RefEval) {
33
			    RefEval re = (RefEval) operands[0];
34
			    ValueEval ve = re.getInnerValueEval();
35
			    if (ve!=null && ve instanceof NumericValueEval) {
36
			        NumericValueEval np = (NumericValueEval) ve;
37
					d = Math.sqrt(np.getNumberValue());
38
			    }
39
			}
40
			else if (operands[0] instanceof AreaEval) {
41
				retval = ErrorEval.INVALID_VALUE;
42
			}
43
			else {
44
				retval = ErrorEval.ERROR_502; 
45
			}
46
		}
47
		else {
48
			retval = ErrorEval.ERROR_508;
49
		}
50
		if (retval != null) {
51
		    retval = (Double.isNaN(d)) ? (ValueEval) ErrorEval.ERROR_502 : new NumberEval(d);
52
		}
53
		return retval;
54
	}
55
56
}
(-)org/apache/poi/hssf/record/formula/functions/Standardize.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Standardize extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Stdev.java (+79 lines)
Added Link Here
1
/*
2
 * Created on May 6, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author amolweb &lt; amolweb at ya hoo dot com &gt;
11
 *
12
 */
13
public class Stdev extends DefaultFunctionImpl {
14
15
	/* (non-Javadoc)
16
	 * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
17
	 */
18
	public Eval evaluate(Eval[] operands) {
19
	    return super.evaluate(operands);
20
//		double mean = 0;
21
//		int count = 0;
22
//		double numerator = 0;
23
//		
24
//		for (int i=0, iSize=operands.length; i<iSize; i++) {
25
//			if (operands[i] instanceof AreaPtg) {
26
//				AreaPtg ap = (AreaPtg) operands[i];
27
//				Object[] values = ap.getValues();
28
//				for (int j=0, jSize=values.length; j<jSize; j++) {
29
//					if (values[j]!=null && !(values[j] instanceof Number)) { 
30
//						mean += ((Number) values[j]).doubleValue();
31
//						count++;
32
//					}
33
//					else if (values[j] instanceof Boolean) {
34
//					    mean += ((Boolean) values[j]).booleanValue() ? 1 : 0;
35
//					    count++;
36
//					}
37
//				}
38
//			}
39
//			else if (operands[i] instanceof IntPtg) {
40
//				IntPtg ip = (IntPtg) operands[i];
41
//				mean += ip.getValue();
42
//				count++;
43
//			}
44
//			else if (operands[i] instanceof NumberPtg) {
45
//				NumberPtg np = (NumberPtg) operands[i];
46
//				mean += np.getValue();
47
//				count++;
48
//			}
49
//		}
50
//		mean /= count;
51
//
52
//		for (int i=0, iSize=operands.length; i<iSize; i++) {
53
//			if (operands[i] instanceof AreaPtg) {
54
//				AreaPtg ap = (AreaPtg) operands[i];
55
//				Object[] values = ap.getValues();
56
//				for (int j=0, jSize=values.length; j<jSize; j++) {
57
//					if (values[j]==null || !(values[j] instanceof Number)) 
58
//						continue;
59
//					double d = (((Number) values[j]).doubleValue() - mean);
60
//					numerator += d*d;
61
//				}
62
//			}
63
//			else if (operands[i] instanceof IntPtg) {
64
//				IntPtg ip = (IntPtg) operands[i];
65
//				double d = (ip.getValue() - mean);
66
//				numerator += d*d;
67
//			}
68
//			else if (operands[i] instanceof NumberPtg) {
69
//				NumberPtg np = (NumberPtg) operands[i];
70
//				double d = (np.getValue() - mean);
71
//				numerator += d*d;
72
//			}
73
//		}
74
//		
75
//		
76
//		return new NumberPtg(Math.sqrt(mean/(count-1)));
77
	}
78
79
}
(-)org/apache/poi/hssf/record/formula/functions/Stdeva.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Stdeva extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Stdevp.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Stdevp extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Stdevpa.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Stdevpa extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Step.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Step extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Steyx.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Steyx extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Substitute.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Substitute extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Subtotal.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Subtotal extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Sum.java (+68 lines)
Added Link Here
1
/*
2
 * Created on May 6, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.AreaEval;
8
import org.apache.poi.hssf.record.formula.eval.ErrorEval;
9
import org.apache.poi.hssf.record.formula.eval.Eval;
10
import org.apache.poi.hssf.record.formula.eval.NumberEval;
11
import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
12
import org.apache.poi.hssf.record.formula.eval.RefEval;
13
import org.apache.poi.hssf.record.formula.eval.ValueEval;
14
15
/**
16
 * @author amolweb &lt; amolweb at ya hoo dot com &gt;
17
 *
18
 */
19
public class Sum extends DefaultFunctionImpl {
20
21
	/* (non-Javadoc)
22
	 * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
23
	 */
24
	public Eval evaluate(Eval[] operands) {
25
		double d = 0;
26
		ValueEval retval = null;
27
		for (int i=0, iSize=operands.length; i<iSize; i++) {
28
		    if (operands[i] == null)
29
		         continue;
30
			if (operands[i] instanceof AreaEval) {
31
				AreaEval ap = (AreaEval) operands[i];
32
				Object[] values = ap.getValues();
33
				for (int j=0, jSize=values.length; j<jSize; j++) {
34
				    if (values[j]==null) 
35
				        continue;
36
					if (values[j] instanceof NumericValueEval) { 
37
						d += ((NumericValueEval) values[j]).getNumberValue();
38
					}
39
					else if (values[j] instanceof RefEval) {
40
					    RefEval re = (RefEval) values[j];
41
					    ValueEval ve = re.getInnerValueEval();
42
						if (ve!=null && ve instanceof NumericValueEval) { 
43
							d += ((NumericValueEval) ve).getNumberValue();
44
						}
45
					}
46
				}
47
			}
48
			else if (operands[i] instanceof NumericValueEval) {
49
				NumericValueEval np = (NumericValueEval) operands[i];
50
				d += np.getNumberValue();
51
			}
52
			else if (operands[i] instanceof RefEval) {
53
			    RefEval re = (RefEval) operands[i];
54
			    ValueEval ve = re.getInnerValueEval();
55
			    if (ve instanceof NumericValueEval) {
56
			        NumericValueEval ne = (NumericValueEval) ve;
57
			        d += ne.getNumberValue();
58
			    }
59
			}
60
		}
61
62
		if (retval == null) {
63
		    retval = (Double.isNaN(d)) 
64
		    		? (ValueEval) ErrorEval.ERROR_502 
65
		            : new NumberEval(d);
66
		}
67
		return retval;	}
68
}
(-)org/apache/poi/hssf/record/formula/functions/Sumif.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Sumif extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Sumproduct.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Sumproduct extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Sumsq.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Sumsq extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Sumx2my2.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Sumx2my2 extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Sumx2py2.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Sumx2py2 extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Sumxmy2.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Sumxmy2 extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Syd.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Syd extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/T.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class T extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Tan.java (+45 lines)
Added Link Here
1
/*
2
 * Created on May 6, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author amolweb &lt; amolweb at ya hoo dot com &gt;
11
 *
12
 */
13
public class Tan extends DefaultFunctionImpl {
14
15
	/* (non-Javadoc)
16
	 * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
17
	 */
18
	public Eval evaluate(Eval[] operands) {
19
	    return super.evaluate(operands);
20
//		double d;
21
//		if (operands[0] instanceof IntPtg) {
22
//		    IntPtg np = (IntPtg) operands[0];
23
//			d = Math.tan(np.getValue());
24
//		}
25
//		else if (operands[0] instanceof NumberPtg) {
26
//			NumberPtg np = (NumberPtg) operands[0];
27
//			d = Math.tan(np.getValue());
28
//		}
29
//		else if (operands[0] instanceof AreaPtg) {
30
//			d=Double.NaN; // TODO: Fix this: check with excel, Oo does weird things with Area refs 
31
//		}
32
//		else if (operands[0] instanceof BoolPtg) {
33
//			BoolPtg bp = (BoolPtg) operands[0];
34
//			d=bp.getValue() ? Math.tan(1) : Math.tan(0);  
35
//		}
36
//		else if (operands[0] instanceof StringPtg) {
37
//			d=Math.tan(0);  
38
//		}
39
//		else {
40
//			d=Math.tan(0); 
41
//		}
42
//		return new NumberPtg(d);
43
	}
44
45
}
(-)org/apache/poi/hssf/record/formula/functions/Tanh.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Tanh extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Tdist.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Tdist extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Terminate.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Terminate extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Text.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Text extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Textbox.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Textbox extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Textref.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Textref extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Time.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Time extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Timevalue.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Timevalue extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Tinv.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Tinv extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Today.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Today extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Transpose.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Transpose extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Trend.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Trend extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Trim.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Trim extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Trimmean.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Trimmean extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/True.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class True extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Trunc.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Trunc extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Ttest.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Ttest extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Type.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Type extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Unregister.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Unregister extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Upper.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Upper extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Usdollar.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Usdollar extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Value.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Value extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Var.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Var extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Vara.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Vara extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Varp.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Varp extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Varpa.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Varpa extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Vdb.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Vdb extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Viewget.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Viewget extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Vlookup.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Vlookup extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Volatile.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Volatile extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Weekday.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Weekday extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Weibull.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Weibull extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Windows.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Windows extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Windowtitle.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Windowtitle extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Year.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Year extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/record/formula/functions/Ztest.java (+23 lines)
Added Link Here
1
/*
2
 * Created on May 9, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.record.formula.functions;
6
7
import org.apache.poi.hssf.record.formula.eval.Eval;
8
9
/**
10
 * @author 
11
 *
12
 */
13
public class Ztest extends DefaultFunctionImpl {
14
15
    
16
   /* (non-Javadoc)
17
    * @see org.apache.poi.hssf.record.formula.functions.Function#evaluate(org.apache.poi.hssf.record.formula.Ptg[])
18
    */
19
   public Eval evaluate(Eval[] operands) {
20
       return super.evaluate(operands);
21
   }
22
23
}
(-)org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java (+480 lines)
Added Link Here
1
/*
2
 * Created on May 5, 2005
3
 *
4
 */
5
package org.apache.poi.hssf.usermodel;
6
import java.io.FileInputStream;
7
import java.lang.reflect.Constructor;
8
import java.util.HashMap;
9
import java.util.Map;
10
import java.util.Stack;
11
12
import org.apache.poi.hssf.model.FormulaParser;
13
import org.apache.poi.hssf.record.formula.AddPtg;
14
import org.apache.poi.hssf.record.formula.Area3DPtg;
15
import org.apache.poi.hssf.record.formula.AreaPtg;
16
import org.apache.poi.hssf.record.formula.AttrPtg;
17
import org.apache.poi.hssf.record.formula.BoolPtg;
18
import org.apache.poi.hssf.record.formula.ConcatPtg;
19
import org.apache.poi.hssf.record.formula.ControlPtg;
20
import org.apache.poi.hssf.record.formula.DividePtg;
21
import org.apache.poi.hssf.record.formula.EqualPtg;
22
import org.apache.poi.hssf.record.formula.FuncPtg;
23
import org.apache.poi.hssf.record.formula.FuncVarPtg;
24
import org.apache.poi.hssf.record.formula.GreaterEqualPtg;
25
import org.apache.poi.hssf.record.formula.GreaterThanPtg;
26
import org.apache.poi.hssf.record.formula.IntPtg;
27
import org.apache.poi.hssf.record.formula.LessEqualPtg;
28
import org.apache.poi.hssf.record.formula.LessThanPtg;
29
import org.apache.poi.hssf.record.formula.MemErrPtg;
30
import org.apache.poi.hssf.record.formula.MissingArgPtg;
31
import org.apache.poi.hssf.record.formula.MultiplyPtg;
32
import org.apache.poi.hssf.record.formula.NamePtg;
33
import org.apache.poi.hssf.record.formula.NameXPtg;
34
import org.apache.poi.hssf.record.formula.NotEqualPtg;
35
import org.apache.poi.hssf.record.formula.NumberPtg;
36
import org.apache.poi.hssf.record.formula.OperationPtg;
37
import org.apache.poi.hssf.record.formula.ParenthesisPtg;
38
import org.apache.poi.hssf.record.formula.PowerPtg;
39
import org.apache.poi.hssf.record.formula.Ptg;
40
import org.apache.poi.hssf.record.formula.Ref3DPtg;
41
import org.apache.poi.hssf.record.formula.ReferencePtg;
42
import org.apache.poi.hssf.record.formula.StringPtg;
43
import org.apache.poi.hssf.record.formula.SubtractPtg;
44
import org.apache.poi.hssf.record.formula.UnaryMinusPtg;
45
import org.apache.poi.hssf.record.formula.UnaryPlusPtg;
46
import org.apache.poi.hssf.record.formula.UnionPtg;
47
import org.apache.poi.hssf.record.formula.UnknownPtg;
48
import org.apache.poi.hssf.record.formula.eval.AddEval;
49
import org.apache.poi.hssf.record.formula.eval.Area2DEval;
50
import org.apache.poi.hssf.record.formula.eval.Area3DEval;
51
import org.apache.poi.hssf.record.formula.eval.AreaEval;
52
import org.apache.poi.hssf.record.formula.eval.BoolEval;
53
import org.apache.poi.hssf.record.formula.eval.ConcatEval;
54
import org.apache.poi.hssf.record.formula.eval.DivideEval;
55
import org.apache.poi.hssf.record.formula.eval.EqualEval;
56
import org.apache.poi.hssf.record.formula.eval.ErrorEval;
57
import org.apache.poi.hssf.record.formula.eval.Eval;
58
import org.apache.poi.hssf.record.formula.eval.FuncVarEval;
59
import org.apache.poi.hssf.record.formula.eval.GreaterEqualEval;
60
import org.apache.poi.hssf.record.formula.eval.GreaterThanEval;
61
import org.apache.poi.hssf.record.formula.eval.LessEqualEval;
62
import org.apache.poi.hssf.record.formula.eval.LessThanEval;
63
import org.apache.poi.hssf.record.formula.eval.MultiplyEval;
64
import org.apache.poi.hssf.record.formula.eval.NotEqualEval;
65
import org.apache.poi.hssf.record.formula.eval.NumberEval;
66
import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
67
import org.apache.poi.hssf.record.formula.eval.OperationEval;
68
import org.apache.poi.hssf.record.formula.eval.PowerEval;
69
import org.apache.poi.hssf.record.formula.eval.Ref2DEval;
70
import org.apache.poi.hssf.record.formula.eval.Ref3DEval;
71
import org.apache.poi.hssf.record.formula.eval.RefEval;
72
import org.apache.poi.hssf.record.formula.eval.StringEval;
73
import org.apache.poi.hssf.record.formula.eval.StringValueEval;
74
import org.apache.poi.hssf.record.formula.eval.SubtractEval;
75
import org.apache.poi.hssf.record.formula.eval.UnaryMinusEval;
76
import org.apache.poi.hssf.record.formula.eval.UnaryPlusEval;
77
import org.apache.poi.hssf.record.formula.eval.ValueEval;
78
79
/**
80
 * @author amolweb &lt; amolweb at ya hoo dot com &gt;
81
 *
82
 * Limitations:
83
 * Unfortunately, cyclic references will cause stackoverflow exception
84
 */
85
public class HSSFFormulaEvaluator {
86
    
87
    // params to lookup the right constructor using reflection
88
    private static final Class[] OPERATION_CONTRUCTOR_CLASS_ARRAY = new Class[]{Ptg.class};
89
    private static final Class[] VALUE_CONTRUCTOR_CLASS_ARRAY = new Class[]{Ptg.class};
90
    private static final Class[] AREA_CONSTRUCTOR_CLASS_ARRAY = new Class[]{Ptg.class, ValueEval[].class};
91
    private static final Class[] AREA3D_CONSTRUCTOR_CLASS_ARRAY = new Class[]{Ptg.class, ValueEval[].class};
92
    private static final Class[] REFERENCE_CONSTRUCTOR_CLASS_ARRAY = new Class[]{Ptg.class, ValueEval.class};
93
    private static final Class[] REF3D_CONSTRUCTOR_CLASS_ARRAY = new Class[]{Ptg.class, ValueEval.class};
94
    
95
    // Maps for mapping *Eval to *Ptg
96
    private static final Map VALUE_EVALS_MAP = new HashMap();
97
    private static final Map OPERATION_EVALS_MAP = new HashMap();    
98
    
99
    
100
    /*
101
     * If you dont like this map, join the club :)
102
     * I did this becoz it was desired to keep the FormulaEvaluator
103
     * separate from FormulaParser and related classes in the CVS-HEAD.
104
     * So now we need some mapping between the Ptg tokens that
105
     * the FormulaParser returns and the *Eval classes taht
106
     * are used by the FormulaEvaluator - hence the following :)
107
     */
108
static {
109
    VALUE_EVALS_MAP.put(BoolPtg.class, BoolEval.class);
110
    VALUE_EVALS_MAP.put(IntPtg.class, NumberEval.class);
111
    VALUE_EVALS_MAP.put(NumberPtg.class, NumberEval.class);
112
    VALUE_EVALS_MAP.put(StringPtg.class, StringEval.class);
113
    
114
    OPERATION_EVALS_MAP.put(AddPtg.class, AddEval.class);
115
    OPERATION_EVALS_MAP.put(ConcatPtg.class, ConcatEval.class);
116
    OPERATION_EVALS_MAP.put(DividePtg.class, DivideEval.class);
117
    OPERATION_EVALS_MAP.put(EqualPtg.class, EqualEval.class);
118
    //OPERATION_EVALS_MAP.put(ExpPtg.class, ExpEval.class); // TODO: check this
119
    OPERATION_EVALS_MAP.put(FuncPtg.class, FuncVarEval.class); // TODO: check this
120
    OPERATION_EVALS_MAP.put(FuncVarPtg.class, FuncVarEval.class);
121
    OPERATION_EVALS_MAP.put(GreaterEqualPtg.class, GreaterEqualEval.class);
122
    OPERATION_EVALS_MAP.put(GreaterThanPtg.class, GreaterThanEval.class);
123
    OPERATION_EVALS_MAP.put(LessEqualPtg.class, LessEqualEval.class);
124
    OPERATION_EVALS_MAP.put(LessThanPtg.class, LessThanEval.class);
125
    OPERATION_EVALS_MAP.put(MultiplyPtg.class, MultiplyEval.class);
126
    OPERATION_EVALS_MAP.put(NotEqualPtg.class, NotEqualEval.class);
127
    OPERATION_EVALS_MAP.put(PowerPtg.class, PowerEval.class);
128
    OPERATION_EVALS_MAP.put(SubtractPtg.class, SubtractEval.class);
129
    OPERATION_EVALS_MAP.put(UnaryMinusPtg.class, UnaryMinusEval.class);
130
    OPERATION_EVALS_MAP.put(UnaryPlusPtg.class, UnaryPlusEval.class);
131
132
133
}
134
    
135
	
136
    /**
137
     * debug method
138
     * @param formula
139
     * @param sheet
140
     * @param workbook
141
     */
142
	static void inspectPtgs(String formula, HSSFSheet sheet, HSSFWorkbook workbook) {
143
		FormulaParser fp = new FormulaParser(formula, workbook.getWorkbook());
144
		fp.parse();
145
		Ptg[] ptgs = fp.getRPNPtg();
146
    	System.out.println("<ptg-group>");
147
    	for (int i=0, iSize=ptgs.length; i<iSize; i++) {
148
    		System.out.println("<ptg>");
149
    		System.out.println(ptgs[i]);
150
    		if (ptgs[i] instanceof OperationPtg) {
151
    			System.out.println("numoperands: " + ((OperationPtg) ptgs[i]).getNumberOfOperands());
152
    		}
153
    		System.out.println("</ptg>");
154
		}
155
	}
156
	
157
	/**
158
	 * returns the string value resulting from teh evaluation of the formula
159
	 * @param formula
160
	 * @param sheet
161
	 * @param workbook
162
	 * @return
163
	 */
164
	public static String evaluateToString(String formula, HSSFSheet sheet, HSSFWorkbook workbook) {
165
    	String retval = null;
166
    	Eval value = evaluate(formula, sheet, workbook);
167
    	if (value instanceof NumericValueEval) {
168
    	    NumericValueEval ne = (NumericValueEval) value;
169
    		retval = String.valueOf(ne.getNumberValue());
170
    	}
171
    	else if (value instanceof StringValueEval) {
172
    	    StringValueEval se = (StringValueEval) value;
173
    		retval = se.getStringValue();
174
    	}
175
    	else {
176
    		retval = value.getClass().getName();
177
    	}
178
    	return retval;
179
	}
180
181
	/**
182
	 * evaluates a formula!!! :)
183
	 * @param formula
184
	 * @param sheet
185
	 * @param workbook
186
	 * @return
187
	 */
188
	private static Eval evaluate(String formula, HSSFSheet sheet, HSSFWorkbook workbook) {
189
		FormulaParser parser = new FormulaParser(formula, workbook.getWorkbook());
190
		parser.parse();
191
		Ptg[] ptgs = parser.getRPNPtg();
192
		// -- parsing over --
193
		
194
    	Stack stack = new Stack();
195
    	for (int i=0, iSize=ptgs.length; i<iSize; i++) {
196
			if (ptgs[i] instanceof ControlPtg) {continue;}
197
			if (ptgs[i] instanceof MemErrPtg) {continue;}
198
			if (ptgs[i] instanceof MissingArgPtg) {continue;}
199
			if (ptgs[i] instanceof NamePtg) {continue;}
200
			if (ptgs[i] instanceof NameXPtg) {continue;}
201
			if (ptgs[i] instanceof UnknownPtg) {continue;}
202
203
			
204
    		if (ptgs[i] instanceof OperationPtg) {
205
    			OperationPtg optg = (OperationPtg) ptgs[i];
206
207
    			if (optg instanceof ParenthesisPtg) {continue;}
208
    			if (optg instanceof AttrPtg) {continue;}
209
    			if (optg instanceof UnionPtg) {continue;}
210
    			
211
    			OperationEval operation = (OperationEval) getOperationEvalForPtg(optg);
212
    			
213
    			int numops = operation.getNumberOfOperands();
214
    			Eval[] ops = new Eval[numops];
215
    			for (int j=numops-1; j>=0; j--) { // storing the ops in reverse order since they are popping ;)
216
    				Eval p = (Eval) stack.pop();
217
    				ops[j] = p;
218
    			}
219
    			Eval opresult = operation.evaluate(ops);
220
    			stack.push(opresult);
221
    		}
222
    		else if (ptgs[i] instanceof ReferencePtg) {
223
    			ReferencePtg ptg = (ReferencePtg) ptgs[i];
224
    			short colnum = ptg.getColumn();
225
    			short rownum = ptg.getRow();
226
    			HSSFRow row = sheet.getRow(rownum);
227
    			HSSFCell cell = (row!=null) ? row.getCell(colnum) : null;
228
    			pushRef2DEval(ptg, stack, cell, sheet, workbook);
229
    		}
230
    		else if (ptgs[i] instanceof Ref3DPtg) {
231
    		    Ref3DPtg ptg = (Ref3DPtg) ptgs[i];
232
    			short colnum = ptg.getColumn();
233
    			short rownum = ptg.getRow();
234
    			HSSFSheet xsheet = workbook.getSheetAt(ptg.getExternSheetIndex());
235
    			HSSFRow row = sheet.getRow(rownum);
236
    			HSSFCell cell = (row!=null) ? row.getCell(colnum) : null;
237
    			pushRef3DEval(ptg, stack, cell, sheet, workbook);
238
    		}
239
    		else if (ptgs[i] instanceof AreaPtg) {
240
				AreaPtg ap = (AreaPtg) ptgs[i];
241
				short row0 = ap.getFirstRow();
242
				short col0 = ap.getFirstColumn();
243
				short row1 = ap.getLastRow();
244
				short col1 = ap.getLastColumn();
245
				ValueEval[] values = new ValueEval[(row1-row0+1)*(col1-col0+1)];
246
				for (short x=row0; sheet!=null && x<row1+1; x++) {
247
					HSSFRow row = sheet.getRow(x);
248
					for (short y=col0; row!=null && y<col1+1; y++) {
249
						values[(x-row0)*(col1-col0+1)+(y-col0)] = getEvalForCell(row.getCell(y), sheet, workbook);
250
					}
251
				}
252
				AreaEval ae = new Area2DEval(ap, values);
253
				stack.push(ae);
254
    		}
255
    		else if (ptgs[i] instanceof Area3DPtg) {
256
				Area3DPtg a3dp = (Area3DPtg) ptgs[i];
257
				short row0 = a3dp.getFirstRow();
258
				short col0 = a3dp.getFirstColumn();
259
				short row1 = a3dp.getLastRow();
260
				short col1 = a3dp.getLastColumn();
261
				HSSFSheet xsheet = workbook.getSheetAt(a3dp.getExternSheetIndex());
262
				ValueEval[] values = new ValueEval[(row1-row0+1)*(col1-col0+1)];
263
				for (short x=row0; sheet!=null && x<row1+1; x++) {
264
					HSSFRow row = sheet.getRow(x);
265
					for (short y=col0; row!=null && y<col1+1; y++) {
266
						values[(x-row0)*(col1-col0+1)+(y-col0)] = getEvalForCell(row.getCell(y), sheet, workbook);
267
					}
268
				}
269
				AreaEval ae = new Area3DEval(a3dp, values);
270
				stack.push(ae);
271
    		}
272
    		else {
273
    		    Eval ptgEval = getEvalForPtg(ptgs[i]);
274
    			stack.push(ptgEval);
275
    		}
276
    	}
277
    	Eval value = ((Eval) stack.pop());
278
    	if (value instanceof RefEval) {
279
    	    RefEval rv = (RefEval) value;
280
    	    value = rv.getInnerValueEval();
281
    	}
282
    	return value;
283
	}
284
	
285
	protected static Eval getOperationEvalForPtg(OperationPtg ptg) {
286
	    Eval retval = null;
287
	    
288
	    Class clazz = (Class) OPERATION_EVALS_MAP.get(ptg.getClass());
289
	    try {
290
		    Constructor constructor = clazz.getConstructor(OPERATION_CONTRUCTOR_CLASS_ARRAY);
291
		    retval = (OperationEval) constructor.newInstance(new Ptg[]{ptg});
292
	    }
293
	    catch (Exception e) {throw new RuntimeException("Fatal Error: ", e);}
294
	    return retval;
295
	}
296
	
297
	
298
	/**
299
	 * returns an appropriate Eval impl instance for the Ptg.
300
	 * The Ptg must be one of: 
301
	 * Area3DPtg, AreaPtg, ReferencePtg, Ref3DPtg, IntPtg, 
302
	 * NumberPtg, StringPtg, BoolPtg
303
	 * <br/>
304
	 * special Note: OperationPtg subtypes cannot be passed here!
305
	 * @param ptg
306
	 * @return
307
	 */
308
	protected static Eval getEvalForPtg(Ptg ptg) {
309
	    Eval retval = null;
310
	    
311
	    Class clazz = (Class) VALUE_EVALS_MAP.get(ptg.getClass());
312
        try {
313
            if (ptg instanceof Area3DPtg) {
314
                Constructor constructor = clazz.getConstructor(AREA3D_CONSTRUCTOR_CLASS_ARRAY);
315
                retval = (OperationEval) constructor.newInstance(new Ptg[]{ptg});
316
            }
317
            else if (ptg instanceof AreaPtg) {
318
                Constructor constructor = clazz.getConstructor(AREA3D_CONSTRUCTOR_CLASS_ARRAY);
319
                retval = (OperationEval) constructor.newInstance(new Ptg[]{ptg});
320
            }
321
            else if (ptg instanceof ReferencePtg) {
322
                Constructor constructor = clazz.getConstructor(REFERENCE_CONSTRUCTOR_CLASS_ARRAY);
323
                retval = (OperationEval) constructor.newInstance(new Ptg[]{ptg});
324
            }
325
            else if (ptg instanceof Ref3DPtg) {
326
                Constructor constructor = clazz.getConstructor(REF3D_CONSTRUCTOR_CLASS_ARRAY);
327
                retval = (OperationEval) constructor.newInstance(new Ptg[]{ptg});
328
            }
329
            else {
330
                if (ptg instanceof IntPtg
331
                 || ptg instanceof NumberPtg
332
                 || ptg instanceof StringPtg
333
                 || ptg instanceof BoolPtg
334
                 ) {
335
                    Constructor constructor = clazz.getConstructor(VALUE_CONTRUCTOR_CLASS_ARRAY);
336
            	    retval = (ValueEval) constructor.newInstance(new Ptg[]{ptg});
337
                }
338
            }
339
        } catch (Exception e) {
340
            throw new RuntimeException("Fatal Error: ", e);
341
        }
342
        return retval;
343
344
	}
345
	
346
	/**
347
	 * Given a cell, find its type and from that create an appropriate ValueEval impl instance
348
	 * and return that. Since the cell could be an external reference, we need the sheet that
349
	 * this belongs to.
350
	 * @param cell
351
	 * @param sheet
352
	 * @param workbook
353
	 * @return
354
	 */
355
	protected static ValueEval getEvalForCell(HSSFCell cell, HSSFSheet sheet, HSSFWorkbook workbook) {
356
		ValueEval retval = null;
357
		if (cell != null) {
358
			switch (cell.getCellType()) {
359
			case HSSFCell.CELL_TYPE_NUMERIC:
360
				retval = new NumberEval(cell.getNumericCellValue());
361
				break;
362
			case HSSFCell.CELL_TYPE_STRING:
363
				retval = new StringEval(cell.getStringCellValue());
364
                break;
365
			case HSSFCell.CELL_TYPE_FORMULA:
366
				retval = (ValueEval) evaluate(cell.getCellFormula(), sheet, workbook);
367
				break;
368
			case HSSFCell.CELL_TYPE_BOOLEAN:
369
				retval = new BoolEval(cell.getBooleanCellValue());
370
				break;
371
			case HSSFCell.CELL_TYPE_BLANK:
372
			    retval = new StringEval("");
373
				break;
374
			case HSSFCell.CELL_TYPE_ERROR:
375
				retval = ErrorEval.ERROR_UNKNOWN; // TODO: think about this...
376
				break;
377
			}
378
		}
379
		return retval;
380
	}
381
	
382
	/**
383
	 * create a Ref2DEval for ReferencePtg and push it on the stack.
384
	 * @param ptg
385
	 * @param stack
386
	 * @param cell
387
	 * @param sheet
388
	 * @param workbook
389
	 */
390
	protected static void pushRef2DEval(ReferencePtg ptg, Stack stack, HSSFCell cell, HSSFSheet sheet, HSSFWorkbook workbook) {
391
	    if (cell!=null)
392
	    switch (cell.getCellType()) {
393
		case HSSFCell.CELL_TYPE_NUMERIC:
394
			stack.push(new Ref2DEval(ptg, new NumberEval(cell.getNumericCellValue())));
395
			break;
396
		case HSSFCell.CELL_TYPE_STRING:
397
			stack.push(new Ref2DEval(ptg, new StringEval(cell.getStringCellValue())));
398
			break;
399
		case HSSFCell.CELL_TYPE_FORMULA:
400
			stack.push(evaluate(cell.getCellFormula(), sheet, workbook));
401
			break;
402
		case HSSFCell.CELL_TYPE_BOOLEAN:
403
			stack.push(new Ref2DEval(ptg, new BoolEval(cell.getBooleanCellValue())));
404
			break;
405
		case HSSFCell.CELL_TYPE_BLANK:
406
			stack.push(new Ref2DEval(ptg, new StringEval("")));
407
			break;
408
		case HSSFCell.CELL_TYPE_ERROR:
409
			stack.push(new Ref2DEval(ptg, ErrorEval.ERROR_UNKNOWN)); // TODO: think about this...
410
			break;
411
		}
412
	    else {
413
	        stack.push(new Ref2DEval(ptg, new StringEval("")));
414
	    }
415
	}
416
417
	/**
418
	 * create a Ref3DEval for Ref3DPtg and push it on the stack.
419
	 * @param ptg
420
	 * @param stack
421
	 * @param cell
422
	 * @param sheet
423
	 * @param workbook
424
	 */
425
	protected static void pushRef3DEval(Ref3DPtg ptg, Stack stack, HSSFCell cell, HSSFSheet sheet, HSSFWorkbook workbook) {
426
		if (cell!=null)
427
	    switch (cell.getCellType()) {
428
		case HSSFCell.CELL_TYPE_NUMERIC:
429
			stack.push(new Ref3DEval(ptg, new NumberEval(cell.getNumericCellValue())));
430
			break;
431
		case HSSFCell.CELL_TYPE_STRING:
432
			stack.push(new Ref3DEval(ptg, new StringEval(cell.getStringCellValue())));
433
			break;
434
		case HSSFCell.CELL_TYPE_FORMULA:
435
			stack.push(evaluate(cell.getCellFormula(), sheet, workbook));
436
			break;
437
		case HSSFCell.CELL_TYPE_BOOLEAN:
438
			stack.push(new Ref3DEval(ptg, new BoolEval(cell.getBooleanCellValue())));
439
			break;
440
		case HSSFCell.CELL_TYPE_BLANK:
441
			stack.push(new Ref3DEval(ptg, new StringEval("")));
442
			break;
443
		case HSSFCell.CELL_TYPE_ERROR:
444
			stack.push(new Ref3DEval(ptg, ErrorEval.ERROR_UNKNOWN)); // TODO: think about this...
445
			break;
446
		}
447
		else {
448
		    stack.push(new Ref3DEval(ptg, new StringEval("")));
449
		}
450
	}
451
452
	
453
	
454
	/**
455
	 * Manual testing... needs a c:/temp/test1.xls file to be present.
456
	 * @param args
457
	 * @throws Exception
458
	 */
459
    public static void main(String[] args) throws Exception {
460
    	String FILE_NAME = "c:/temp/test1.xls";
461
    	
462
    	FileInputStream fis = new FileInputStream(FILE_NAME);
463
    	HSSFWorkbook wb = new HSSFWorkbook(fis);
464
    	fis.close();
465
    	HSSFSheet sheet = wb.getSheetAt(0);
466
    	
467
    	for (int rn=1, rnSize=4; rn<=rnSize; rn++) {
468
        	HSSFRow row = sheet.getRow(rn);
469
    	    for (int cn=5, cnSize=7; cn<=cnSize; cn++) {
470
    	    	HSSFCell     	cell = row.getCell((short) cn);
471
    	    	String formula = cell.getCellFormula();
472
    	    	System.out.println("-----------------------------------------------------");
473
    	    	//inspectPtgs(formula, sheet, wb);
474
    	    	System.out.println("["+rn+","+cn+"]: "+evaluateToString(formula, sheet, wb));
475
    	    	System.out.println("-----------------------------------------------------");
476
    	    }
477
    	}
478
    }
479
    
480
}

Return to bug 34828