acoliver    02/04/29 17:19:49

  Modified:    src/java/org/apache/poi/hssf/record/formula
                        FormulaParser.java FunctionPtg.java IntPtg.java
  Log:
  Aviks patches for numbers mostly.
  
  Revision  Changes    Path
  1.11      +17 -10    
jakarta-poi/src/java/org/apache/poi/hssf/record/formula/FormulaParser.java
  
  Index: FormulaParser.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/formula/FormulaParser.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- FormulaParser.java        29 Apr 2002 00:33:28 -0000      1.10
  +++ FormulaParser.java        30 Apr 2002 00:19:49 -0000      1.11
  @@ -247,16 +247,14 @@
               tokens.add(new FunctionPtg(name,(byte)numArgs));
           } else if (Look == ':') { // this is a AreaReference
               String first = name;
  -            GetChar();
  +            Match(':');
               String second = GetName();
  -                tokens.add(new AreaPtg(first+":"+second));
  -            //String second = ;
  +            tokens.add(new AreaPtg(first+":"+second));
           } else {
               //this can be either a cell ref or a named range !!
  -            
               boolean cellRef = true ; //we should probably do it with reg exp??
               if (cellRef) {
  -                tokens.add(new ReferencePtg(name)); //TODO we need to pass in Name 
somewhere??
  +                tokens.add(new ReferencePtg(name)); 
               }else {
                   //handle after named range is integrated!!
               }
  @@ -270,7 +268,7 @@
               numArgs++; 
               Expression();
           }
  -        while (Look == ',') {
  +        while (Look == ',') { //TODO handle EmptyArgs
               Match(',');
               Expression();
               numArgs++;
  @@ -289,10 +287,17 @@
           } else if (IsAlpha(Look)){
               Ident();
           }else{
  -
  -            IntPtg p = new IntPtg();
  -            p.setValue(Short.parseShort(GetNum()));
  -            tokens.add(p);
  +            String number = GetNum();
  +            if (Look=='.') { 
  +                Match('.');
  +                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 @@
           
           wb.write(out);
           out.close();
  +        
  +        System.out.println(file.getCanonicalPath());
           } catch (java.io.IOException ioe) {
               ioe.printStackTrace();
           }
  
  
  
  1.4       +1 -8      
jakarta-poi/src/java/org/apache/poi/hssf/record/formula/FunctionPtg.java
  
  Index: FunctionPtg.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/formula/FunctionPtg.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FunctionPtg.java  29 Apr 2002 01:25:28 -0000      1.3
  +++ FunctionPtg.java  30 Apr 2002 00:19:49 -0000      1.4
  @@ -1,16 +1,9 @@
  -/*
  - * DummyFunctionPtg.java
  - *
  - * 
  - */
  -
  -
   package org.apache.poi.hssf.record.formula;
   
   import java.util.List;
   /**
    * This class provides functions with variable arguments.  
  - * @author  aviks
  + * @author  Avik Sengupta
    * @author Andrew C. Oliver (acoliver at apache dot org)
    * @version 
    */
  
  
  
  1.5       +4 -0      
jakarta-poi/src/java/org/apache/poi/hssf/record/formula/IntPtg.java
  
  Index: IntPtg.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/formula/IntPtg.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- IntPtg.java       28 Apr 2002 16:33:57 -0000      1.4
  +++ IntPtg.java       30 Apr 2002 00:19:49 -0000      1.5
  @@ -95,6 +95,10 @@
           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)
       {
  
  
  


Reply via email to