Example usage for org.apache.poi.ss.formula NameIdentifier NameIdentifier

List of usage examples for org.apache.poi.ss.formula NameIdentifier NameIdentifier

Introduction

In this page you can find the example usage for org.apache.poi.ss.formula NameIdentifier NameIdentifier.

Prototype

public NameIdentifier(String name, boolean isQuoted) 

Source Link

Usage

From source file:org.tiefaces.components.websheet.utility.ShiftFormulaUtility.java

License:MIT License

/**
 * Fixup ref relative row one to one./* ww  w  .j a v  a2 s .c  o  m*/
 *
 * @param ptg
 *            the ptg
 * @param newRow
 *            the new row
 * @return the object
 */
protected static Object fixupRefRelativeRowOneToOne(final Object ptg, final Row newRow) {
    if (ptg instanceof RefPtgBase) {
        if (ptg instanceof Ref3DPxg) {
            Ref3DPxg ref3dPxg = (Ref3DPxg) ptg;
            Ref3DPxg new3dpxg = new Ref3DPxg(ref3dPxg.getExternalWorkbookNumber(),
                    new SheetIdentifier(null, new NameIdentifier(ref3dPxg.getSheetName(), false)),
                    new CellReference(newRow.getRowNum(), ref3dPxg.getColumn()));
            new3dpxg.setClass(ref3dPxg.getPtgClass());
            new3dpxg.setColRelative(ref3dPxg.isColRelative());
            new3dpxg.setRowRelative(ref3dPxg.isRowRelative());
            new3dpxg.setLastSheetName(ref3dPxg.getLastSheetName());
            return new3dpxg;
        } else {
            RefPtgBase refPtgBase = (RefPtgBase) ptg;
            return new RefPtg(newRow.getRowNum(), refPtgBase.getColumn(), refPtgBase.isRowRelative(),
                    refPtgBase.isColRelative());

        }
    } else {
        if (ptg instanceof Area3DPxg) {
            Area3DPxg area3dPxg = (Area3DPxg) ptg;
            Area3DPxg new3dpxg = new Area3DPxg(area3dPxg.getExternalWorkbookNumber(),
                    new SheetIdentifier(null, new NameIdentifier(area3dPxg.getSheetName(), false)),
                    area3dPxg.format2DRefAsString());
            new3dpxg.setClass(area3dPxg.getPtgClass());
            new3dpxg.setFirstColRelative(area3dPxg.isFirstColRelative());
            new3dpxg.setLastColRelative(area3dPxg.isLastColRelative());
            int shiftRow = newRow.getRowNum() - area3dPxg.getFirstRow();
            new3dpxg.setFirstRow(area3dPxg.getFirstRow() + shiftRow);
            new3dpxg.setLastRow(area3dPxg.getLastRow() + shiftRow);
            new3dpxg.setFirstRowRelative(area3dPxg.isFirstRowRelative());
            new3dpxg.setLastRowRelative(area3dPxg.isLastRowRelative());
            new3dpxg.setLastSheetName(area3dPxg.getLastSheetName());
            return new3dpxg;
        } else {
            AreaPtgBase areaPtgBase = (AreaPtgBase) ptg;
            int shiftRow = newRow.getRowNum() - areaPtgBase.getFirstRow();
            return new AreaPtg(areaPtgBase.getFirstRow() + shiftRow, areaPtgBase.getLastRow() + shiftRow,
                    areaPtgBase.getFirstColumn(), areaPtgBase.getLastColumn(), areaPtgBase.isFirstRowRelative(),
                    areaPtgBase.isLastRowRelative(), areaPtgBase.isFirstColRelative(),
                    areaPtgBase.isLastColRelative());
        }
    }

}

From source file:org.tiefaces.components.websheet.utility.ShiftFormulaUtility.java

License:MIT License

/**
 * Builds the dynamic row for ref ptg base.
 *
 * @param ptg//  ww  w .  ja  va 2 s .com
 *            the ptg
 * @param originalOperandClass
 *            the original operand class
 * @param rowList
 *            the row list
 * @param newPtg
 *            the new ptg
 * @param includeParenthesis
 *            the include parenthesis
 */
private static void buildDynamicRowForRefPtgBase(final Object ptg, final byte originalOperandClass,
        final List<SerialRow> rowList, final Ptg[] newPtg, final boolean includeParenthesis) {
    RefPtgBase refPtg = (RefPtgBase) ptg;
    int unitSize = 1;
    if (includeParenthesis) {
        unitSize = 2;
    }
    for (int i = 0; i < rowList.size(); i++) {
        Row row = rowList.get(i).getRow();
        if (refPtg instanceof Ref3DPxg) {
            Ref3DPxg ref3dPxg = (Ref3DPxg) refPtg;
            Ref3DPxg new3dpxg = new Ref3DPxg(ref3dPxg.getExternalWorkbookNumber(),
                    new SheetIdentifier(null, new NameIdentifier(ref3dPxg.getSheetName(), false)),
                    new CellReference(row.getRowNum(), ref3dPxg.getColumn()));
            new3dpxg.setClass(originalOperandClass);
            new3dpxg.setColRelative(ref3dPxg.isColRelative());
            new3dpxg.setRowRelative(ref3dPxg.isRowRelative());
            new3dpxg.setLastSheetName(ref3dPxg.getLastSheetName());
            newPtg[i * unitSize] = new3dpxg;
        } else {
            RefPtgBase refPtgBase = refPtg;
            newPtg[i * unitSize] = new RefPtg(row.getRowNum(), refPtgBase.getColumn(),
                    refPtgBase.isRowRelative(), refPtgBase.isColRelative());
        }
        if ((unitSize == 2) && (i < (rowList.size() - 1))) {
            newPtg[i * unitSize + 1] = ParenthesisPtg.instance;
        }
    }
}

From source file:org.tiefaces.components.websheet.utility.ShiftFormulaUtility.java

License:MIT License

/**
 * Builds the dynamic row for area ptg base.
 *
 * @param ptg//from   w ww  .  j  a  v a 2 s  .co  m
 *            the ptg
 * @param originalOperandClass
 *            the original operand class
 * @param rowList
 *            the row list
 * @param newPtg
 *            the new ptg
 */
private static void buildDynamicRowForAreaPtgBase(final Object ptg, final byte originalOperandClass,
        final List<SerialRow> rowList, final Ptg[] newPtg) {
    AreaPtgBase areaPtg = (AreaPtgBase) ptg;
    int originFirstRow = areaPtg.getFirstRow();
    int originLastRow = areaPtg.getLastRow();
    int unitSize = 2;
    for (int i = 0; i < rowList.size(); i++) {
        Row row = rowList.get(i).getRow();
        int shiftRow = row.getRowNum() - originFirstRow;
        if (ptg instanceof Area3DPxg) {
            Area3DPxg area3dPxg = (Area3DPxg) ptg;
            Area3DPxg new3dpxg = new Area3DPxg(area3dPxg.getExternalWorkbookNumber(),
                    new SheetIdentifier(null, new NameIdentifier(area3dPxg.getSheetName(), false)),
                    area3dPxg.format2DRefAsString());
            new3dpxg.setClass(originalOperandClass);
            new3dpxg.setFirstColRelative(area3dPxg.isFirstColRelative());
            new3dpxg.setLastColRelative(area3dPxg.isLastColRelative());
            new3dpxg.setFirstRow(originFirstRow + shiftRow);
            new3dpxg.setLastRow(originLastRow + shiftRow);
            new3dpxg.setFirstRowRelative(area3dPxg.isFirstRowRelative());
            new3dpxg.setLastRowRelative(area3dPxg.isLastRowRelative());
            new3dpxg.setLastSheetName(area3dPxg.getLastSheetName());
            newPtg[i * unitSize] = new3dpxg;
        } else {
            AreaPtgBase areaPtgBase = (AreaPtgBase) ptg;
            newPtg[i * unitSize] = new AreaPtg(originFirstRow + shiftRow, originLastRow + shiftRow,
                    areaPtgBase.getFirstColumn(), areaPtgBase.getLastColumn(), areaPtgBase.isFirstRowRelative(),
                    areaPtgBase.isLastRowRelative(), areaPtgBase.isFirstColRelative(),
                    areaPtgBase.isLastColRelative());

        }
        if (i < (rowList.size() - 1)) {
            newPtg[i * unitSize + 1] = ParenthesisPtg.instance;
        }
    }
}