Synch up.

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352474 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew C. Oliver 2002-04-23 23:56:46 +00:00
parent 532added9f
commit 756c1f0a55
9 changed files with 108 additions and 20 deletions

View File

@ -60,14 +60,15 @@
*/ */
package org.apache.poi.hssf.record.formula; package org.apache.poi.hssf.record.formula;
import java.util.List;
/** /**
* *
* @author andy * @author andy
*/ */
public class AddPtg public class AddPtg
extends Ptg extends OperationPtg
implements OperationPtg
{ {
public final static int SIZE = 1; public final static int SIZE = 1;
public final static byte sid = 0x03; public final static byte sid = 0x03;
@ -147,4 +148,10 @@ public class AddPtg
public int getStringLength() { public int getStringLength() {
return 1; return 1;
} }
public void manipulate(List source, List results, int pos) {
standardBinaryManipulation(source,results,pos);
}
} }

View File

@ -63,6 +63,8 @@ package org.apache.poi.hssf.record.formula;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.BitField; import org.apache.poi.util.BitField;
import java.util.List;
/** /**
* "Special Attributes" * "Special Attributes"
* This seems to be a Misc Stuff and Junk record. One function it serves is * This seems to be a Misc Stuff and Junk record. One function it serves is
@ -71,8 +73,7 @@ import org.apache.poi.util.BitField;
*/ */
public class AttrPtg public class AttrPtg
extends Ptg extends OperationPtg
implements OperationPtg
{ {
public final static short sid = 0x19; public final static short sid = 0x19;
private final static int SIZE = 4; private final static int SIZE = 4;
@ -205,4 +206,9 @@ public class AttrPtg
{ {
return -1; return -1;
} }
public void manipulate(List source, List results, int pos) {
}
} }

View File

@ -60,14 +60,15 @@
*/ */
package org.apache.poi.hssf.record.formula; package org.apache.poi.hssf.record.formula;
import java.util.List;
/** /**
* *
* @author andy * @author andy
*/ */
public class DividePtg public class DividePtg
extends Ptg extends OperationPtg
implements OperationPtg
{ {
public final static int SIZE = 1; public final static int SIZE = 1;
public final static byte sid = 0x06; public final static byte sid = 0x06;
@ -118,4 +119,8 @@ public class DividePtg
buffer.append(operands[ 1 ].toFormulaString()); buffer.append(operands[ 1 ].toFormulaString());
return buffer.toString(); return buffer.toString();
} }
public void manipulate(List source, List results, int pos) {
}
} }

View File

@ -60,17 +60,20 @@
*/ */
package org.apache.poi.hssf.record.formula; package org.apache.poi.hssf.record.formula;
import java.util.List;
/** /**
* *
* @author andy * @author andy
*/ */
public class MultiplyPtg public class MultiplyPtg
extends Ptg extends OperationPtg
implements OperationPtg
{ {
public final static int SIZE = 1; public final static int SIZE = 1;
public final static byte sid = 0x05; public final static byte sid = 0x05;
private final static String MULTIPLY="*";
/** Creates new AddPtg */ /** Creates new AddPtg */
@ -83,6 +86,11 @@ public class MultiplyPtg
// doesn't need anything // doesn't need anything
} }
protected MultiplyPtg(String formula, int offset) {
}
public void writeBytes(byte [] array, int offset) public void writeBytes(byte [] array, int offset)
{ {
@ -104,6 +112,11 @@ public class MultiplyPtg
return 2; return 2;
} }
public int getStringLength() {
return 1;
}
public String toFormulaString() public String toFormulaString()
{ {
return "*"; return "*";
@ -118,4 +131,28 @@ public class MultiplyPtg
buffer.append(operands[ 1 ].toFormulaString()); buffer.append(operands[ 1 ].toFormulaString());
return buffer.toString(); return buffer.toString();
} }
public void manipulate(List source, List results, int pos) {
standardBinaryManipulation(source, results, pos);
}
public int getPrecedence() {
return 3;
}
public static boolean isNextStringToken(String formula, int pos) {
boolean retval = false;
while (pos < formula.length() && Character.isWhitespace(formula.charAt(pos))) {
pos++;
}
if (pos < formula.length()) {
if (formula.charAt(pos) == MULTIPLY.toCharArray()[0]) {
retval = true;
}
}
return retval;
}
} }

View File

@ -60,20 +60,31 @@
*/ */
package org.apache.poi.hssf.record.formula; package org.apache.poi.hssf.record.formula;
import java.util.List;
/** /**
* defines a Ptg that is an operation instead of an operand * defines a Ptg that is an operation instead of an operand
* @author andy * @author andy
*/ */
public interface OperationPtg public abstract class OperationPtg extends Ptg
{ {
public final static int TYPE_UNARY = 0; public final static int TYPE_UNARY = 0;
public final static int TYPE_BINARY = 1; public final static int TYPE_BINARY = 1;
public final static int TYPE_FUNCTION = 2; public final static int TYPE_FUNCTION = 2;
public int getType(); public abstract int getType();
public int getNumberOfOperands(); public abstract int getNumberOfOperands();
/**
* manipulate the list, moving the arguments for this function to the source list
* followed by the operator.
*/
public abstract void manipulate(List source, List results, int pos);
public String toFormulaString(Ptg [] operands); public abstract String toFormulaString(Ptg [] operands);
protected void standardBinaryManipulation(List source,List results, int pos) {
}
} }

View File

@ -55,16 +55,18 @@
package org.apache.poi.hssf.record.formula; package org.apache.poi.hssf.record.formula;
import java.util.List;
/** /**
* Dummy class, we want it only for for the parsing process * Dummy class, we want it only for for the parsing process
* does not actually get into the file -- note by andy...there is a parenthesis PTG * does not actually get into the file -- note by andy...there is a parenthesis PTG
* that can be written and is sometimes! * that can be written and is sometimes!
* *
* Avik Sengupta <lists@aviksengupta.com> * Avik Sengupta <lists@aviksengupta.com>
* Andrew C. Oliver (acoliver at apache dot org)
*/ */
public class ParenthesisPtg public class ParenthesisPtg
extends Ptg extends OperationPtg
implements OperationPtg
{ {
@ -99,5 +101,9 @@ public class ParenthesisPtg
{ {
return "("; return "(";
} }
public void manipulate(List source, List results, int pos) {
}
} }

View File

@ -60,14 +60,15 @@
*/ */
package org.apache.poi.hssf.record.formula; package org.apache.poi.hssf.record.formula;
import java.util.List;
/** /**
* *
* @author andy * @author andy
*/ */
public class PowerPtg public class PowerPtg
extends Ptg extends OperationPtg
implements OperationPtg
{ {
public final static int SIZE = 1; public final static int SIZE = 1;
public final static byte sid = 0x07; public final static byte sid = 0x07;
@ -118,4 +119,8 @@ public class PowerPtg
buffer.append(operands[ 0 ].toFormulaString()); buffer.append(operands[ 0 ].toFormulaString());
return buffer.toString(); return buffer.toString();
} }
public void manipulate(List source, List results, int pos) {
}
} }

View File

@ -60,14 +60,15 @@
*/ */
package org.apache.poi.hssf.record.formula; package org.apache.poi.hssf.record.formula;
import java.util.List;
/** /**
* *
* @author andy * @author andy
*/ */
public class SubtractPtg public class SubtractPtg
extends Ptg extends OperationPtg
implements OperationPtg
{ {
public final static int SIZE = 1; public final static int SIZE = 1;
public final static byte sid = 0x04; public final static byte sid = 0x04;
@ -118,4 +119,9 @@ public class SubtractPtg
buffer.append(operands[ 1 ].toFormulaString()); buffer.append(operands[ 1 ].toFormulaString());
return buffer.toString(); return buffer.toString();
} }
public void manipulate(List source, List results, int pos) {
}
} }

View File

@ -63,14 +63,15 @@ package org.apache.poi.hssf.record.formula;
import org.apache.poi.util.BitField; import org.apache.poi.util.BitField;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import java.util.List;
/** /**
* An excel function with variable number of value arguments. * An excel function with variable number of value arguments.
* @author andy * @author andy
*/ */
public class ValueVariableFunctionPtg public class ValueVariableFunctionPtg
extends Ptg extends OperationPtg
implements OperationPtg
{ {
public final static short sid = 0x42; public final static short sid = 0x42;
private final static short SIZE = 4; private final static short SIZE = 4;
@ -127,4 +128,8 @@ public class ValueVariableFunctionPtg
{ {
return toFormulaString(); return toFormulaString();
} }
public void manipulate(List source, List results, int pos) {
}
} }