Search in sources :

Example 1 with CFRule12Record

use of org.apache.poi.hssf.record.CFRule12Record in project poi by apache.

the class CFRecordsAggregate method updateFormulasAfterCellShift.

/**
     * @return <code>false</code> if this whole {@link CFHeaderRecord} / {@link CFRuleRecord}s should be deleted
     */
public boolean updateFormulasAfterCellShift(FormulaShifter shifter, int currentExternSheetIx) {
    CellRangeAddress[] cellRanges = header.getCellRanges();
    boolean changed = false;
    List<CellRangeAddress> temp = new ArrayList<CellRangeAddress>();
    for (CellRangeAddress craOld : cellRanges) {
        CellRangeAddress craNew = shiftRange(shifter, craOld, currentExternSheetIx);
        if (craNew == null) {
            changed = true;
            continue;
        }
        temp.add(craNew);
        if (craNew != craOld) {
            changed = true;
        }
    }
    if (changed) {
        int nRanges = temp.size();
        if (nRanges == 0) {
            return false;
        }
        CellRangeAddress[] newRanges = new CellRangeAddress[nRanges];
        temp.toArray(newRanges);
        header.setCellRanges(newRanges);
    }
    for (CFRuleBase rule : rules) {
        Ptg[] ptgs;
        ptgs = rule.getParsedExpression1();
        if (ptgs != null && shifter.adjustFormula(ptgs, currentExternSheetIx)) {
            rule.setParsedExpression1(ptgs);
        }
        ptgs = rule.getParsedExpression2();
        if (ptgs != null && shifter.adjustFormula(ptgs, currentExternSheetIx)) {
            rule.setParsedExpression2(ptgs);
        }
        if (rule instanceof CFRule12Record) {
            CFRule12Record rule12 = (CFRule12Record) rule;
            ptgs = rule12.getParsedExpressionScale();
            if (ptgs != null && shifter.adjustFormula(ptgs, currentExternSheetIx)) {
                rule12.setParsedExpressionScale(ptgs);
            }
        }
    }
    return true;
}
Also used : CFRuleBase(org.apache.poi.hssf.record.CFRuleBase) Ptg(org.apache.poi.ss.formula.ptg.Ptg) AreaErrPtg(org.apache.poi.ss.formula.ptg.AreaErrPtg) AreaPtg(org.apache.poi.ss.formula.ptg.AreaPtg) CFRule12Record(org.apache.poi.hssf.record.CFRule12Record) ArrayList(java.util.ArrayList) CellRangeAddress(org.apache.poi.ss.util.CellRangeAddress)

Example 2 with CFRule12Record

use of org.apache.poi.hssf.record.CFRule12Record in project poi by apache.

the class HSSFConditionalFormattingRule method getColorScaleFormatting.

private HSSFColorScaleFormatting getColorScaleFormatting(boolean create) {
    CFRule12Record cfRule12Record = getCFRule12Record(create);
    if (cfRule12Record == null)
        return null;
    ColorGradientFormatting colorFormatting = cfRule12Record.getColorGradientFormatting();
    if (colorFormatting == null) {
        if (!create)
            return null;
        cfRule12Record.createColorGradientFormatting();
    }
    return new HSSFColorScaleFormatting(cfRule12Record, sheet);
}
Also used : ColorGradientFormatting(org.apache.poi.hssf.record.cf.ColorGradientFormatting) CFRule12Record(org.apache.poi.hssf.record.CFRule12Record)

Example 3 with CFRule12Record

use of org.apache.poi.hssf.record.CFRule12Record in project poi by apache.

the class HSSFConditionalFormattingRule method getDataBarFormatting.

private HSSFDataBarFormatting getDataBarFormatting(boolean create) {
    CFRule12Record cfRule12Record = getCFRule12Record(create);
    if (cfRule12Record == null)
        return null;
    DataBarFormatting databarFormatting = cfRule12Record.getDataBarFormatting();
    if (databarFormatting == null) {
        if (!create)
            return null;
        cfRule12Record.createDataBarFormatting();
    }
    return new HSSFDataBarFormatting(cfRule12Record, sheet);
}
Also used : CFRule12Record(org.apache.poi.hssf.record.CFRule12Record) DataBarFormatting(org.apache.poi.hssf.record.cf.DataBarFormatting)

Example 4 with CFRule12Record

use of org.apache.poi.hssf.record.CFRule12Record in project poi by apache.

the class HSSFConditionalFormattingRule method getMultiStateFormatting.

private HSSFIconMultiStateFormatting getMultiStateFormatting(boolean create) {
    CFRule12Record cfRule12Record = getCFRule12Record(create);
    if (cfRule12Record == null)
        return null;
    IconMultiStateFormatting iconFormatting = cfRule12Record.getMultiStateFormatting();
    if (iconFormatting == null) {
        if (!create)
            return null;
        cfRule12Record.createMultiStateFormatting();
    }
    return new HSSFIconMultiStateFormatting(cfRule12Record, sheet);
}
Also used : CFRule12Record(org.apache.poi.hssf.record.CFRule12Record) IconMultiStateFormatting(org.apache.poi.hssf.record.cf.IconMultiStateFormatting)

Aggregations

CFRule12Record (org.apache.poi.hssf.record.CFRule12Record)4 ArrayList (java.util.ArrayList)1 CFRuleBase (org.apache.poi.hssf.record.CFRuleBase)1 ColorGradientFormatting (org.apache.poi.hssf.record.cf.ColorGradientFormatting)1 DataBarFormatting (org.apache.poi.hssf.record.cf.DataBarFormatting)1 IconMultiStateFormatting (org.apache.poi.hssf.record.cf.IconMultiStateFormatting)1 AreaErrPtg (org.apache.poi.ss.formula.ptg.AreaErrPtg)1 AreaPtg (org.apache.poi.ss.formula.ptg.AreaPtg)1 Ptg (org.apache.poi.ss.formula.ptg.Ptg)1 CellRangeAddress (org.apache.poi.ss.util.CellRangeAddress)1