private void setParameterRVA(Node n, int expectedClass, int formulaType) { Ptg p = (Ptg) n.getValue(); if (expectedClass == Ptg.CLASS_REF) { // pg 15, table 1 if (p.getDefaultOperandClass() == Ptg.CLASS_REF) { setClass(n, Ptg.CLASS_REF); } if (p.getDefaultOperandClass() == Ptg.CLASS_VALUE) { if (formulaType == FORMULA_TYPE_CELL || formulaType == FORMULA_TYPE_SHARED) { setClass(n, Ptg.CLASS_VALUE); } else { setClass(n, Ptg.CLASS_ARRAY); } } if (p.getDefaultOperandClass() == Ptg.CLASS_ARRAY) { setClass(n, Ptg.CLASS_ARRAY); } } else if (expectedClass == Ptg.CLASS_VALUE) { // pg 15, table 2 if (formulaType == FORMULA_TYPE_NAMEDRANGE) { setClass(n, Ptg.CLASS_ARRAY); } else { setClass(n, Ptg.CLASS_VALUE); } } else { // Array class, pg 16. if (p.getDefaultOperandClass() == Ptg.CLASS_VALUE && (formulaType == FORMULA_TYPE_CELL || formulaType == FORMULA_TYPE_SHARED)) { setClass(n, Ptg.CLASS_VALUE); } else { setClass(n, Ptg.CLASS_ARRAY); } } }
private void setClass(Node n, byte theClass) { Ptg p = (Ptg) n.getValue(); if (p instanceof AbstractFunctionPtg || !(p instanceof OperationPtg)) { p.setClass(theClass); } else { for (int i = 0; i < n.getNumChildren(); i++) { setClass(n.getChild(i), theClass); } } }
/** * Adds the size of all the ptgs after the provided index (inclusive). * * <p>Initially used to count a goto * * @param index * @return int */ private int getPtgSize(int index) { int count = 0; Iterator ptgIterator = tokens.listIterator(index); while (ptgIterator.hasNext()) { Ptg ptg = (Ptg) ptgIterator.next(); count += ptg.getSize(); } return count; }
private int getPtgSize(int start, int end) { int count = 0; int index = start; Iterator ptgIterator = tokens.listIterator(index); while (ptgIterator.hasNext() && index <= end) { Ptg ptg = (Ptg) ptgIterator.next(); count += ptg.getSize(); index++; } return count; }
private void setRootLevelRVA(Node n, int formulaType) { // Pg 16, excelfileformat.pdf @ openoffice.org Ptg p = (Ptg) n.getValue(); if (formulaType == FormulaParser.FORMULA_TYPE_NAMEDRANGE) { if (p.getDefaultOperandClass() == Ptg.CLASS_REF) { setClass(n, Ptg.CLASS_REF); } else { setClass(n, Ptg.CLASS_ARRAY); } } else { setClass(n, Ptg.CLASS_VALUE); } }