Example usage for org.apache.poi.ss.formula.ptg ParenthesisPtg instance

List of usage examples for org.apache.poi.ss.formula.ptg ParenthesisPtg instance

Introduction

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

Prototype

ControlPtg instance

To view the source code for org.apache.poi.ss.formula.ptg ParenthesisPtg instance.

Click Source Link

Usage

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  .j  av a 2s.c  o  m*/
 *            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//  w w  w  .j a  v  a 2s. 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;
        }
    }
}