Package com.extentech.formats.XLS.formulas

Examples of com.extentech.formats.XLS.formulas.Ptg


        if(host!=null)host.registerIndirectFunction();
      }
      // Cache Relative Ptgs for quickness of access
      ArrayList<Ptg> ptgs= new ArrayList();
      for (int idx = 0; idx < expression.size(); idx++) {
        Ptg ptg = (Ptg) expression.get( idx );
        if (ptg instanceof PtgRefN){
          ptgs.add(ptg);
        }else if (ptg instanceof PtgAreaN){
          ptgs.add(ptg);
        }
View Full Code Here


     */
    // NOTE: now these ptgs are not reference-tracked; see ExpressionParser and PtgRefN,PtgAreaN for reference-tracking these entities
    public static Stack convertStack (Stack in, Formula f){
      Stack out = new Stack();
      for (int idx = 0; idx < in.size(); idx++) {
        Ptg ptg = (Ptg) in.get( idx );
        // convert the Ptg if necessary, otherwise clone it
        if (ptg instanceof PtgRefN){
          ptg = ((PtgRefN)ptg).convertToPtgRef(f);
        }else if (ptg instanceof PtgAreaN){
          ptg = ((PtgAreaN)ptg).convertToPtgArea(f);
        } else {
          ptg = (Ptg) ptg.clone();
            ptg.setParentRec( f );
        }
       
        out.add( ptg );
      }
      return out;
View Full Code Here

    byte[] expbytes = new byte[0];
      byte[] arraybytes= null;
      Stack expression= f.getExpression();
    for (int i = 0; i< expression.size();i++){
      Object o = expression.elementAt(i);
      Ptg ptg = (Ptg) o;
      byte[] b;
      if (o instanceof PtgArray){
        PtgArray pa = (PtgArray)o;
        b = pa.getPreRecord();
        arraybytes = ByteTools.append(pa.getPostRecord(), arraybytes);
        hasArray = true;
      }else{
        b = ptg.getRecord();
      }
      expbytes = ByteTools.append(b, expbytes);
     }
    if (hasArray){
      expbytes= ByteTools.append(arraybytes, expbytes);
View Full Code Here

     Iterator itx = expr.iterator();

     int[] rc= refcell.getIntLocation();
     if(refPos == -1){
       while(itx.hasNext()){
         Ptg prex = (Ptg)itx.next();
         if (prex instanceof PtgRefN){
           ((PtgRefN) prex).setFormulaRow(rc[0]);
           ((PtgRefN) prex).setFormulaCol(rc[1]);
         }
       }
View Full Code Here

           
            // get the firstCond bytes
            tmp = new byte[0];
            for (int i = 0; i< firstCond.size();i++){
                Object o = firstCond.elementAt(i);
                Ptg ptg = (Ptg) o;
                tmp = ByteTools.append(ptg.getRecord(), tmp);
            }
            // get the length and add in.
            short sz = (short)tmp.length;
            recbytes = ByteTools.append(ByteTools.shortToLEBytes(sz), recbytes);
            // add garbage
            recbytes = ByteTools.append(garbageByteOne, recbytes);
            recbytes = ByteTools.append(tmp, recbytes);
           
            // get the secondCond bytes
            tmp = new byte[0];
            for (int i = 0; i< secondCond.size();i++){
                Object o = secondCond.elementAt(i);
                Ptg ptg = (Ptg) o;
                tmp = ByteTools.append(ptg.getRecord(), tmp);
            }
            // get the length and add in.
            sz = (short)tmp.length;
            recbytes = ByteTools.append(ByteTools.shortToLEBytes(sz), recbytes);
            // add garbage
            recbytes = ByteTools.append(garbageByteTwo, recbytes);
            recbytes = ByteTools.append(tmp, recbytes);
           
            tmp = new byte[1];
            if (cRangeList != null) {
                tmp[0] = (byte)cRangeList.size();;
                recbytes = ByteTools.append(tmp, recbytes);
                for(int i=0;i<cRangeList.size();i++) {
                    tmp = ((PtgArea)cRangeList.get(i)).getRecord();
                    byte[] tmp2 = new byte[8];
                    tmp[0] = 0;
                    System.arraycopy(tmp, 0, tmp2, 0, tmp2.length);
                    recbytes = ByteTools.append(tmp2, recbytes);
                }
                // there is a trailing zero, not sure why...
                if (cRangeList.size()>0) {
                    tmp = new byte[1];
                    tmp[0] = 0;
                    recbytes = ByteTools.append(tmp, recbytes);
                }
            } else if (ooxmlranges!=null && ooxmlranges.length>0) {
                tmp[0] = (byte)ooxmlranges.length;
                recbytes = ByteTools.append(tmp, recbytes);
                for(int i=0;i<ooxmlranges.length;i++) {
          Ptg/*Ref*/ p= PtgRef.createPtgRefFromString(this.getSheet().getSheetName() + "!" + ooxmlranges[i], this);
          tmp= p.getRecord();
                    /* replace with above PtgArea pa= new PtgArea();
                    try {
                        pa.setParentRec(this);
                        pa.setLocation(this.getSheet().getSheetName() + "!" + ooxmlranges[i]);
                    } catch (Exception e) {
View Full Code Here

        throws FormulaNotFoundException{
        List dx = form.getPtgsByLocation(formulaLoc);
    Iterator lx=dx.iterator();
    while(lx.hasNext()){
          try{
            Ptg thisptg = (Ptg)lx.next();
        ReferenceTracker.updateAddressPerPolicy(thisptg, newaddr);     
        form.setCachedValue(null); // flag to recalculate
        return true;
      }catch(Exception e){
        Logger.logInfo("updating Formula reference failed:" + e.toString());
View Full Code Here

    throws FormulaNotFoundException{
    List dx = form.getPtgsByLocation(formulaLoc);
    Iterator lx=dx.iterator();
    boolean b=false;
    while(lx.hasNext()){
        Ptg ptg = (Ptg)lx.next();
          if (ptg == null)return false;
          int[] formulaaddr = ExcelTools.getRangeRowCol(formulaLoc);
          String handleaddr = handle.getCellAddress();
          int[] celladdr = ExcelTools.getRowColFromString(handleaddr);
         
View Full Code Here

    Iterator x = cfmt.getRules().iterator();
    while (x.hasNext()) {
      Cf cx1 = ((Cf) x.next());
      // create a ptgref for this Cell
      Ptg pref = new PtgRef(this.getCellAddress(), this.mycell, false);

      if (cx1.evaluate(pref)) {
        // TODO: evaluate and combine multiple rules...
        // currently returns on first true format
        int ret = cfmt.getCfxe();
View Full Code Here

     * @return boolean true if evaluation of criteria passes
     * @param Ptg refcell - the Ptg location to obtain cell value from
     * @see com.extentech.formats.XLS.Cf#evaluate(com.extentech.formats.XLS.formulas.Ptg)
     */
    public boolean evaluate(CellHandle refcell) {
    Ptg/*Ref*/ pr = PtgRef.createPtgRefFromString(refcell.getCellAddress(), null);
        return currentCf.evaluate(pr);
    }
View Full Code Here

TOP

Related Classes of com.extentech.formats.XLS.formulas.Ptg

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.