Examples of Ptg


Examples of org.apache.poi.hssf.record.formula.Ptg

   * abnormally-set 'shared formula' flags.
   * (see TestValueRecordsAggregate.testSpuriousSharedFormulaFlag()).<p/>
   */
  private static void handleMissingSharedFormulaRecord(FormulaRecord formula) {
    // make sure 'unshared' formula is actually available
    Ptg firstToken = formula.getParsedExpression()[0];
    if (firstToken instanceof ExpPtg) {
      throw new RecordFormatException(
          "SharedFormulaRecord not found for FormulaRecord with (isSharedFormula=true)");
    }
    // could log an info message here since this is a fairly unusual occurrence.
View Full Code Here

Examples of org.apache.poi.ss.formula.ptg.Ptg

    Stack<ValueEval> stack = new Stack<ValueEval>();
    for (int i = 0, iSize = ptgs.length; i < iSize; i++) {

      // since we don't know how to handle these yet :(
      Ptg ptg = ptgs[i];
      if (ptg instanceof AttrPtg) {
        AttrPtg attrPtg = (AttrPtg) ptg;
        if (attrPtg.isSum()) {
          // Excel prefers to encode 'SUM()' as a tAttr token, but this evaluator
          // expects the equivalent function token
          ptg = FuncVarPtg.SUM;
        }
        if (attrPtg.isOptimizedChoose()) {
          ValueEval arg0 = stack.pop();
          int[] jumpTable = attrPtg.getJumpTable();
          int dist;
          int nChoices = jumpTable.length;
          try {
            int switchIndex = Choose.evaluateFirstArg(arg0, ec.getRowIndex(), ec.getColumnIndex());
            if (switchIndex<1 || switchIndex > nChoices) {
              stack.push(ErrorEval.VALUE_INVALID);
              dist = attrPtg.getChooseFuncOffset() + 4; // +4 for tFuncFar(CHOOSE)
            } else {
              dist = jumpTable[switchIndex-1];
            }
          } catch (EvaluationException e) {
            stack.push(e.getErrorEval());
            dist = attrPtg.getChooseFuncOffset() + 4; // +4 for tFuncFar(CHOOSE)
          }
          // Encoded dist for tAttrChoose includes size of jump table, but
          // countTokensToBeSkipped() does not (it counts whole tokens).
          dist -= nChoices*2+2; // subtract jump table size
          i+= countTokensToBeSkipped(ptgs, i, dist);
          continue;
        }
        if (attrPtg.isOptimizedIf()) {
          ValueEval arg0 = stack.pop();
          boolean evaluatedPredicate;
          try {
            evaluatedPredicate = IfFunc.evaluateFirstArg(arg0, ec.getRowIndex(), ec.getColumnIndex());
          } catch (EvaluationException e) {
            stack.push(e.getErrorEval());
            int dist = attrPtg.getData();
            i+= countTokensToBeSkipped(ptgs, i, dist);
            attrPtg = (AttrPtg) ptgs[i];
            dist = attrPtg.getData()+1;
            i+= countTokensToBeSkipped(ptgs, i, dist);
            continue;
          }
          if (evaluatedPredicate) {
            // nothing to skip - true param folows
          } else {
            int dist = attrPtg.getData();
            i+= countTokensToBeSkipped(ptgs, i, dist);
            Ptg nextPtg = ptgs[i+1];
            if (ptgs[i] instanceof AttrPtg && nextPtg instanceof FuncVarPtg) {
              // this is an if statement without a false param (as opposed to MissingArgPtg as the false param)
              i++;
              stack.push(BoolEval.FALSE);
            }
View Full Code Here

Examples of org.zkoss.poi.ss.formula.ptg.Ptg

    final int ptglen = srcPtgs.length;
    final Ptg[] dstPtgs = new Ptg[ptglen];
   
    final SpreadsheetVersion ver = ((Book)dstSheet.getWorkbook()).getSpreadsheetVersion();
    for(int j = 0; j < ptglen; ++j) {
      final Ptg srcPtg = srcPtgs[j];
      final Ptg dstPtg = offsetPtg(srcPtg, dstCell, offRow, offCol, ver);
      dstPtgs[j] = dstPtg;
    }
    return dstPtgs;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.