A built in function in a formula. These functions take a variable
number of arguments, such as a range (eg. SUM etc)
| Method from jxl.biff.formula.VariableArgFunction Detail: |
public void adjustRelativeCellReferences(int colAdjust,
int rowAdjust) {
ParseItem[] operands = getOperands();
for (int i = 0 ; i < operands.length ; i++)
{
operands[i].adjustRelativeCellReferences(colAdjust, rowAdjust);
}
}
Adjusts all the relative cell references in this formula by the
amount specified. Used when copying formulas |
void columnInserted(int sheetIndex,
int col,
boolean currentSheet) {
ParseItem[] operands = getOperands();
for (int i = 0 ; i < operands.length ; i++)
{
operands[i].columnInserted(sheetIndex, col, currentSheet);
}
}
Called when a column is inserted on the specified sheet. Tells
the formula parser to update all of its cell references beyond this
column |
void columnRemoved(int sheetIndex,
int col,
boolean currentSheet) {
ParseItem[] operands = getOperands();
for (int i = 0 ; i < operands.length ; i++)
{
operands[i].columnRemoved(sheetIndex, col, currentSheet);
}
}
Called when a column is inserted on the specified sheet. Tells
the formula parser to update all of its cell references beyond this
column |
byte[] getBytes() {
handleSpecialCases();
// Get the data for the operands - in the correct order
ParseItem[] operands = getOperands();
byte[] data = new byte[0];
for (int i = 0 ; i < operands.length ; i++)
{
byte[] opdata = operands[i].getBytes();
// Grow the array
byte[] newdata = new byte[data.length + opdata.length];
System.arraycopy(data, 0, newdata, 0, data.length);
System.arraycopy(opdata, 0, newdata, data.length, opdata.length);
data = newdata;
}
// Add on the operator byte
byte[] newdata = new byte[data.length + 4];
System.arraycopy(data, 0, newdata, 0, data.length);
newdata[data.length] = !useAlternateCode() ?
Token.FUNCTIONVARARG.getCode() : Token.FUNCTIONVARARG.getCode2() ;
newdata[data.length+1] = (byte) arguments;
IntegerHelper.getTwoBytes(function.getCode(), newdata, data.length+2);
return newdata;
}
Gets the token representation of this item in RPN |
Function getFunction() {
return function;
}
Gets the underlying function |
public void getOperands(Stack s) {
// parameters are in the correct order, god damn them
ParseItem[] items = new ParseItem[arguments];
for (int i = arguments - 1; i >= 0 ; i--)
{
ParseItem pi = (ParseItem) s.pop();
items[i] = pi;
}
for (int i = 0 ; i < arguments; i++)
{
add(items[i]);
}
}
Gets the operands for this operator from the stack |
int getPrecedence() {
return 3;
}
Gets the precedence for this operator. Operator precedents run from
1 to 5, one being the highest, 5 being the lowest |
public void getString(StringBuffer buf) {
buf.append(function.getName(settings));
buf.append('(");
if (arguments > 0)
{
ParseItem[] operands = getOperands();
if (readFromSheet)
{
// arguments are in the same order they were specified
operands[0].getString(buf);
for (int i = 1; i < arguments; i++)
{
buf.append(',");
operands[i].getString(buf);
}
}
else
{
// arguments are stored in the reverse order to which they
// were specified, so iterate through them backwards
operands[arguments - 1].getString(buf);
for (int i = arguments - 2; i >= 0 ; i--)
{
buf.append(',");
operands[i].getString(buf);
}
}
}
buf.append(')");
}
|
void handleImportedCellReferences() {
ParseItem[] operands = getOperands();
for (int i = 0 ; i < operands.length ; i++)
{
operands[i].handleImportedCellReferences();
}
}
If this formula was on an imported sheet, check that
cell references to another sheet are warned appropriately
Does nothing, as operators don't have cell references |
public int read(byte[] data,
int pos) throws FormulaException {
arguments = data[pos];
int index = IntegerHelper.getInt(data[pos+1], data[pos+2]);
function = Function.getFunction(index);
if (function == Function.UNKNOWN)
{
throw new FormulaException(FormulaException.UNRECOGNIZED_FUNCTION,
index);
}
return 3;
}
Reads the ptg data from the array starting at the specified position |
void rowInserted(int sheetIndex,
int row,
boolean currentSheet) {
ParseItem[] operands = getOperands();
for (int i = 0 ; i < operands.length ; i++)
{
operands[i].rowInserted(sheetIndex, row, currentSheet);
}
}
Called when a column is inserted on the specified sheet. Tells
the formula parser to update all of its cell references beyond this
column |
void rowRemoved(int sheetIndex,
int row,
boolean currentSheet) {
ParseItem[] operands = getOperands();
for (int i = 0 ; i < operands.length ; i++)
{
operands[i].rowRemoved(sheetIndex, row, currentSheet);
}
}
Called when a column is inserted on the specified sheet. Tells
the formula parser to update all of its cell references beyond this
column |