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;
}
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);
}
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);
}
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);
}
Aggregations