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
 */