Search in sources :

Example 1 with AreaErrPtg

use of org.apache.poi.ss.formula.ptg.AreaErrPtg in project poi by apache.

the class CFRecordsAggregate method shiftRange.

private static CellRangeAddress shiftRange(FormulaShifter shifter, CellRangeAddress cra, int currentExternSheetIx) {
    // FormulaShifter works well in terms of Ptgs - so convert CellRangeAddress to AreaPtg (and back) here
    AreaPtg aptg = new AreaPtg(cra.getFirstRow(), cra.getLastRow(), cra.getFirstColumn(), cra.getLastColumn(), false, false, false, false);
    Ptg[] ptgs = { aptg };
    if (!shifter.adjustFormula(ptgs, currentExternSheetIx)) {
        return cra;
    }
    Ptg ptg0 = ptgs[0];
    if (ptg0 instanceof AreaPtg) {
        AreaPtg bptg = (AreaPtg) ptg0;
        return new CellRangeAddress(bptg.getFirstRow(), bptg.getLastRow(), bptg.getFirstColumn(), bptg.getLastColumn());
    }
    if (ptg0 instanceof AreaErrPtg) {
        return null;
    }
    throw new IllegalStateException("Unexpected shifted ptg class (" + ptg0.getClass().getName() + ")");
}
Also used : Ptg(org.apache.poi.ss.formula.ptg.Ptg) AreaErrPtg(org.apache.poi.ss.formula.ptg.AreaErrPtg) AreaPtg(org.apache.poi.ss.formula.ptg.AreaPtg) AreaErrPtg(org.apache.poi.ss.formula.ptg.AreaErrPtg) CellRangeAddress(org.apache.poi.ss.util.CellRangeAddress) AreaPtg(org.apache.poi.ss.formula.ptg.AreaPtg)

Example 2 with AreaErrPtg

use of org.apache.poi.ss.formula.ptg.AreaErrPtg in project poi by apache.

the class XSSFRowShifter method shiftRange.

private static CellRangeAddress shiftRange(FormulaShifter shifter, CellRangeAddress cra, int currentExternSheetIx) {
    // FormulaShifter works well in terms of Ptgs - so convert CellRangeAddress to AreaPtg (and back) here
    AreaPtg aptg = new AreaPtg(cra.getFirstRow(), cra.getLastRow(), cra.getFirstColumn(), cra.getLastColumn(), false, false, false, false);
    Ptg[] ptgs = { aptg };
    if (!shifter.adjustFormula(ptgs, currentExternSheetIx)) {
        return cra;
    }
    Ptg ptg0 = ptgs[0];
    if (ptg0 instanceof AreaPtg) {
        AreaPtg bptg = (AreaPtg) ptg0;
        return new CellRangeAddress(bptg.getFirstRow(), bptg.getLastRow(), bptg.getFirstColumn(), bptg.getLastColumn());
    }
    if (ptg0 instanceof AreaErrPtg) {
        return null;
    }
    throw new IllegalStateException("Unexpected shifted ptg class (" + ptg0.getClass().getName() + ")");
}
Also used : Ptg(org.apache.poi.ss.formula.ptg.Ptg) AreaErrPtg(org.apache.poi.ss.formula.ptg.AreaErrPtg) AreaPtg(org.apache.poi.ss.formula.ptg.AreaPtg) AreaErrPtg(org.apache.poi.ss.formula.ptg.AreaErrPtg) CellRangeAddress(org.apache.poi.ss.util.CellRangeAddress) AreaPtg(org.apache.poi.ss.formula.ptg.AreaPtg)

Aggregations

AreaErrPtg (org.apache.poi.ss.formula.ptg.AreaErrPtg)2 AreaPtg (org.apache.poi.ss.formula.ptg.AreaPtg)2 Ptg (org.apache.poi.ss.formula.ptg.Ptg)2 CellRangeAddress (org.apache.poi.ss.util.CellRangeAddress)2