diff --git a/src/java/org/apache/poi/hssf/model/FormulaParser.java b/src/java/org/apache/poi/hssf/model/FormulaParser.java index 32e6cd4af..6d7ff6f70 100644 --- a/src/java/org/apache/poi/hssf/model/FormulaParser.java +++ b/src/java/org/apache/poi/hssf/model/FormulaParser.java @@ -797,7 +797,9 @@ end; } return (String) stack.pop(); //TODO: catch stack underflow and throw parse exception. } - + /** Create a tree representation of the RPN token array + *used to run the class(RVA) change algo + */ private Node createTree() { java.util.Stack stack = new java.util.Stack(); int numPtgs = tokens.size(); @@ -837,7 +839,8 @@ end; return buf.toString(); } -} +} + /** Private helper class, used to create a tree representation of the formula*/ class Node { private Ptg value=null; private Node[] children=new Node[0]; diff --git a/src/java/org/apache/poi/hssf/record/formula/AbstractFunctionPtg.java b/src/java/org/apache/poi/hssf/record/formula/AbstractFunctionPtg.java index 4c0e9f066..da08a6dc3 100644 --- a/src/java/org/apache/poi/hssf/record/formula/AbstractFunctionPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/AbstractFunctionPtg.java @@ -69,7 +69,7 @@ public abstract class AbstractFunctionPtg extends OperationPtg { //constant used allow a ptgAttr to be mapped properly for its functionPtg public static final String ATTR_NAME = "specialflag"; - private final static int SIZE = 4; + private static BinaryTree map = produceHash(); protected static Object[][] functionData = produceFunctionData(); @@ -129,14 +129,13 @@ public abstract class AbstractFunctionPtg extends OperationPtg { } public abstract void writeBytes(byte[] array, int offset); + public abstract int getSize(); - public int getSize() { - return SIZE; - } + - private String lookupName(short index) { + protected String lookupName(short index) { return ((String)map.get(new Integer(index))); } diff --git a/src/java/org/apache/poi/hssf/record/formula/FuncPtg.java b/src/java/org/apache/poi/hssf/record/formula/FuncPtg.java index 1b22e3604..1c230c95a 100644 --- a/src/java/org/apache/poi/hssf/record/formula/FuncPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/FuncPtg.java @@ -2,13 +2,14 @@ package org.apache.poi.hssf.record.formula; import org.apache.poi.util.LittleEndian; /** - * + * @author aviks * @author Jason Height (jheight at chariot dot net dot au) * @author Danny Mui (dmui at apache dot org) (Leftover handling) */ public class FuncPtg extends AbstractFunctionPtg{ public final static byte sid = 0x21; + public final static int SIZE = 3; private int numParams=0; /** @@ -17,8 +18,8 @@ public class FuncPtg extends AbstractFunctionPtg{ *
* If the leftovers are removed, a prompt "Warning: Data may have been lost occurs in Excel"
*/
- protected byte[] leftOvers = null;
-
+ //protected byte[] leftOvers = null;
+
private FuncPtg() {
//Required for clone methods
}
@@ -31,12 +32,12 @@ public class FuncPtg extends AbstractFunctionPtg{
//field_1_num_args = data[ offset + 0 ];
field_2_fnc_index = LittleEndian.getShort(data,offset + 0 );
-
+ /*
if (data.length - offset > 2) { //save left overs if there are any
leftOvers = new byte[2];
System.arraycopy(data, offset+1, leftOvers, 0, leftOvers.length);
}
-
+ */
try {
numParams = ( (Integer)functionData[field_2_fnc_index][2]).intValue();
} catch (NullPointerException npe) {
@@ -49,9 +50,9 @@ public class FuncPtg extends AbstractFunctionPtg{
array[offset+0]= (byte) (sid + ptgClass);
//array[offset+1]=field_1_num_args;
LittleEndian.putShort(array,offset+1,field_2_fnc_index);
- if (leftOvers != null) {
+ /**if (leftOvers != null) {
System.arraycopy(leftOvers, 0, array, offset+2, leftOvers.length);
- }
+ }**/
}
public int getNumberOfOperands() {
@@ -60,8 +61,23 @@ public class FuncPtg extends AbstractFunctionPtg{
public Object clone() {
FuncPtg ptg = new FuncPtg();
- ptg.field_1_num_args = field_1_num_args;
+ //ptg.field_1_num_args = field_1_num_args;
ptg.field_2_fnc_index = field_2_fnc_index;
return ptg;
}
+
+ public int getSize() {
+ return SIZE;
+ }
+
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ buffer
+ .append("