Aviks patches for numbers mostly.

PR:
Obtained from:
Submitted by:
Reviewed by:


git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352562 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew C. Oliver 2002-04-30 00:19:49 +00:00
parent d83491053b
commit b8802bb429
3 changed files with 22 additions and 18 deletions

View File

@ -247,16 +247,14 @@ public class FormulaParser {
tokens.add(new FunctionPtg(name,(byte)numArgs)); tokens.add(new FunctionPtg(name,(byte)numArgs));
} else if (Look == ':') { // this is a AreaReference } else if (Look == ':') { // this is a AreaReference
String first = name; String first = name;
GetChar(); Match(':');
String second = GetName(); String second = GetName();
tokens.add(new AreaPtg(first+":"+second)); tokens.add(new AreaPtg(first+":"+second));
//String second = ;
} else { } else {
//this can be either a cell ref or a named range !! //this can be either a cell ref or a named range !!
boolean cellRef = true ; //we should probably do it with reg exp?? boolean cellRef = true ; //we should probably do it with reg exp??
if (cellRef) { if (cellRef) {
tokens.add(new ReferencePtg(name)); //TODO we need to pass in Name somewhere?? tokens.add(new ReferencePtg(name));
}else { }else {
//handle after named range is integrated!! //handle after named range is integrated!!
} }
@ -270,7 +268,7 @@ public class FormulaParser {
numArgs++; numArgs++;
Expression(); Expression();
} }
while (Look == ',') { while (Look == ',') { //TODO handle EmptyArgs
Match(','); Match(',');
Expression(); Expression();
numArgs++; numArgs++;
@ -289,10 +287,17 @@ public class FormulaParser {
} else if (IsAlpha(Look)){ } else if (IsAlpha(Look)){
Ident(); Ident();
}else{ }else{
String number = GetNum();
IntPtg p = new IntPtg(); if (Look=='.') {
p.setValue(Short.parseShort(GetNum())); Match('.');
tokens.add(p); String decimalPart = null;
if (IsDigit(Look)) number = number +"."+ GetNum(); //this also takes care of someone entering "1234."
tokens.add(new NumberPtg(number));
} else {
//IntPtg p = new IntPtg(GetNum()); // removing since a ptg should be able to create itself from parser results.
//p.setValue(Short.parseShort(GetNum()));
tokens.add(new IntPtg(number)); //TODO:what if the number is too big to be a short? ..add factory to return Int or Number!
}
} }
} }
@ -489,6 +494,8 @@ end;
wb.write(out); wb.write(out);
out.close(); out.close();
System.out.println(file.getCanonicalPath());
} catch (java.io.IOException ioe) { } catch (java.io.IOException ioe) {
ioe.printStackTrace(); ioe.printStackTrace();
} }

View File

@ -1,16 +1,9 @@
/*
* DummyFunctionPtg.java
*
*
*/
package org.apache.poi.hssf.record.formula; package org.apache.poi.hssf.record.formula;
import java.util.List; import java.util.List;
/** /**
* This class provides functions with variable arguments. * This class provides functions with variable arguments.
* @author aviks * @author Avik Sengupta
* @author Andrew C. Oliver (acoliver at apache dot org) * @author Andrew C. Oliver (acoliver at apache dot org)
* @version * @version
*/ */

View File

@ -95,6 +95,10 @@ public class IntPtg
field_1_value = Short.parseShort(val); field_1_value = Short.parseShort(val);
} }
// IntPtg should be able to create itself, shouldnt have to call setValue
protected IntPtg(String formulaToken) {
setValue(Short.parseShort(formulaToken));
}
public void setValue(short value) public void setValue(short value)
{ {