Examples of AttrPtg


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

    assertEquals(9, asts.length);
   
    IntPtg op1 = (IntPtg) asts[0];
    IntPtg op2 = (IntPtg) asts[1];
    EqualPtg eq = (EqualPtg) asts[2];   
    AttrPtg ifPtg = (AttrPtg) asts[3];
    IntPtg res1 = (IntPtg) asts[4];
       
    AttrPtg ptgGoto= (AttrPtg) asts[5];   
    assertEquals("Goto 1 Length", (short)10, ptgGoto.getData());
   
    IntPtg res2 = (IntPtg) asts[6];   
    AttrPtg ptgGoto2 = (AttrPtg) asts[7];   
    assertEquals("Goto 2 Length", (short)3, ptgGoto2.getData());
   
    assertEquals("If FALSE offset", (short)7, ifPtg.getData());
   
    FuncVarPtg funcPtg = (FuncVarPtg)asts[8];
   
View Full Code Here

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

    fp.parse();
    Ptg[] asts = fp.getRPNPtg();
    assertEquals("11 Ptgs expected", 11, asts.length);

    assertTrue("IF Attr set correctly", (asts[3] instanceof AttrPtg));
    AttrPtg ifFunc = (AttrPtg)asts[3];
    assertTrue("It is not an if", ifFunc.isOptimizedIf());
   
    assertTrue("Average Function set correctly", (asts[5] instanceof FuncVarPtg));
   
             
  }
View Full Code Here

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

    fp.parse();
    Ptg[] asts = fp.getRPNPtg();
    assertEquals("7 Ptgs expected", 7, asts.length);

    assertTrue("IF Attr set correctly", (asts[3] instanceof AttrPtg));
    AttrPtg ifFunc = (AttrPtg)asts[3];
    assertTrue("It is not an if", ifFunc.isOptimizedIf());
   
    assertTrue("Single Value is not an IntPtg", (asts[4] instanceof IntPtg));
    IntPtg intPtg = (IntPtg)asts[4];
    assertEquals("Result", (short)10, intPtg.getValue());
   
View Full Code Here

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

  private static void confirmAttrData(Ptg[] ptgs, int i, int expectedData) {
    Ptg ptg = ptgs[i];
    if (!(ptg instanceof AttrPtg)) {
      throw new AssertionFailedError("Token[" + i + "] was not AttrPtg as expected");
    }
    AttrPtg attrPtg = (AttrPtg) ptg;
    assertEquals(expectedData, attrPtg.getData());
  }
View Full Code Here

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

  public void testYN() {
    Ptg[] ptgs = parseFormula("IF(TRUE,\"Y\",\"N\")");
    assertEquals(7, ptgs.length);

    BoolPtg flag  = (BoolPtg) ptgs[0];
    AttrPtg funif = (AttrPtg) ptgs[1];
    StringPtg y = (StringPtg) ptgs[2];
    AttrPtg goto1 = (AttrPtg) ptgs[3];
    StringPtg n = (StringPtg) ptgs[4];


    assertEquals(true, flag.getValue());
    assertEquals("Y", y.getValue());
    assertEquals("N", n.getValue());
    assertEquals("IF", funif.toFormulaString());
    assertTrue("Goto ptg exists", goto1.isGoto());
  }
View Full Code Here

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

  public void testNestedFunctionIf() {
    Ptg[] ptgs = parseFormula("IF(A1=B1,AVERAGE(A1:B1),AVERAGE(A2:B2))");
    assertEquals(11, ptgs.length);

    assertTrue("IF Attr set correctly", (ptgs[3] instanceof AttrPtg));
    AttrPtg ifFunc = (AttrPtg)ptgs[3];
    assertTrue("It is not an if", ifFunc.isOptimizedIf());

    assertTrue("Average Function set correctly", (ptgs[5] instanceof FuncVarPtg));
  }
View Full Code Here

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

  public void testIfSingleCondition(){
    Ptg[] ptgs = parseFormula("IF(1=1,10)");
    assertEquals(7, ptgs.length);

    assertTrue("IF Attr set correctly", (ptgs[3] instanceof AttrPtg));
    AttrPtg ifFunc = (AttrPtg)ptgs[3];
    assertTrue("It is not an if", ifFunc.isOptimizedIf());

    assertTrue("Single Value is not an IntPtg", (ptgs[4] instanceof IntPtg));
    IntPtg intPtg = (IntPtg)ptgs[4];
    assertEquals("Result", (short)10, intPtg.getValue());
View Full Code Here

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

    token.setClass(transformClass(token.getPtgClass(), desiredOperandClass, callerForceArrayFlag));
  }

  private static boolean isSingleArgSum(Ptg token) {
    if (token instanceof AttrPtg) {
      AttrPtg attrPtg = (AttrPtg) token;
      return attrPtg.isSum();
    }
    return false;
  }
View Full Code Here

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

   
    // placeholder for first skip attr
    int skipAfterTrueParamIndex = temp.createPlaceholder();
    int trueParamSize = temp.sumTokenSizes(ifAttrIndex+1, skipAfterTrueParamIndex);

    AttrPtg attrIf = new AttrPtg();
    attrIf.setOptimizedIf(true);
    AttrPtg attrSkipAfterTrue = new AttrPtg();
    attrSkipAfterTrue.setGoto(true);
   
    if (getChildren().length > 2) {
      // false param present
     
      // false parameter
      getChildren()[2].collectPtgs(temp);
     
      int skipAfterFalseParamIndex = temp.createPlaceholder();

      AttrPtg attrSkipAfterFalse = new AttrPtg();
      attrSkipAfterFalse.setGoto(true);

      int falseParamSize =  temp.sumTokenSizes(skipAfterTrueParamIndex+1, skipAfterFalseParamIndex);
     
      attrIf.setData((short)(trueParamSize + 4)); // distance to start of false parameter. +4 for skip after true
      attrSkipAfterTrue.setData((short)(falseParamSize + 4 + 4 - 1)); // 1 less than distance to end of if FuncVar(size=4). +4 for attr skip before
      attrSkipAfterFalse.setData((short)(4 - 1)); // 1 less than distance to end of if FuncVar(size=4).

      temp.setPlaceholder(ifAttrIndex, attrIf);
      temp.setPlaceholder(skipAfterTrueParamIndex, attrSkipAfterTrue);
      temp.setPlaceholder(skipAfterFalseParamIndex, attrSkipAfterFalse);
    } else {
View Full Code Here

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

  public void testSpaceAtStartOfFormula() {
    // Simulating cell formula of "= 4" (note space)
    // The same Ptg array can be observed if an excel file is saved with that exact formula

    AttrPtg spacePtg = AttrPtg.createSpace(AttrPtg.SpaceType.SPACE_BEFORE, 1);
    Ptg[] ptgs = { spacePtg, new IntPtg(4), };
    String formulaString;
    try {
      formulaString = toFormulaString(ptgs);
    } catch (IllegalStateException e) {
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.