use of org.apache.poi.hssf.record.aggregates.ConditionalFormattingTable in project poi by apache.
the class InternalSheet method getConditionalFormattingTable.
public ConditionalFormattingTable getConditionalFormattingTable() {
if (condFormatting == null) {
condFormatting = new ConditionalFormattingTable();
RecordOrderer.addNewSheetRecord(_records, condFormatting);
}
return condFormatting;
}
use of org.apache.poi.hssf.record.aggregates.ConditionalFormattingTable in project poi by apache.
the class TestSheet method testShiftFormulasAddCondFormat_bug46547.
/**
* Prior to the fix for bug 46547, shifting formulas would have the side-effect
* of creating a {@link ConditionalFormattingTable}. There was no impairment to
* functionality since empty record aggregates are equivalent to missing record
* aggregates. However, since this unnecessary creation helped expose bug 46547b,
* and since there is a slight performance hit the fix was made to avoid it.
*/
@Test
public void testShiftFormulasAddCondFormat_bug46547() {
// Create a sheet with data validity (similar to bugzilla attachment id=23131).
InternalSheet sheet = InternalSheet.createSheet();
List<RecordBase> sheetRecs = sheet.getRecords();
assertEquals(23, sheetRecs.size());
FormulaShifter shifter = FormulaShifter.createForRowShift(0, "", 0, 0, 1, SpreadsheetVersion.EXCEL97);
sheet.updateFormulasAfterCellShift(shifter, 0);
if (sheetRecs.size() == 24 && sheetRecs.get(22) instanceof ConditionalFormattingTable) {
throw new AssertionFailedError("Identified bug 46547a");
}
assertEquals(23, sheetRecs.size());
}
use of org.apache.poi.hssf.record.aggregates.ConditionalFormattingTable in project poi by apache.
the class TestSheet method testAddCondFormatAfterDataValidation_bug46547.
/**
* Bug 46547 happened when attempting to add conditional formatting to a sheet
* which already had data validity constraints.
*/
@Test
public void testAddCondFormatAfterDataValidation_bug46547() {
// Create a sheet with data validity (similar to bugzilla attachment id=23131).
InternalSheet sheet = InternalSheet.createSheet();
sheet.getOrCreateDataValidityTable();
ConditionalFormattingTable cft;
// attempt to add conditional formatting
try {
// lazy getter
cft = sheet.getConditionalFormattingTable();
} catch (ClassCastException e) {
throw new AssertionFailedError("Identified bug 46547b");
}
assertNotNull(cft);
}
Aggregations