use of org.apache.poi.hssf.record.BlankRecord in project poi by apache.
the class TestValueRecordsAggregate method testMultipleBlanks.
/**
* Tests various manipulations of blank cells, to make sure that {@link MulBlankRecord}s
* are use appropriately
*/
@Test
public void testMultipleBlanks() {
BlankRecord brA2 = newBlankRecord(0, 1);
BlankRecord brB2 = newBlankRecord(1, 1);
BlankRecord brC2 = newBlankRecord(2, 1);
BlankRecord brD2 = newBlankRecord(3, 1);
BlankRecord brE2 = newBlankRecord(4, 1);
BlankRecord brB3 = newBlankRecord(1, 2);
BlankRecord brC3 = newBlankRecord(2, 2);
valueRecord.insertCell(brA2);
valueRecord.insertCell(brB2);
valueRecord.insertCell(brD2);
confirmMulBlank(3, 1, 1);
valueRecord.insertCell(brC3);
confirmMulBlank(4, 1, 2);
valueRecord.insertCell(brB3);
valueRecord.insertCell(brE2);
confirmMulBlank(6, 3, 0);
valueRecord.insertCell(brC2);
confirmMulBlank(7, 2, 0);
valueRecord.removeCell(brA2);
confirmMulBlank(6, 2, 0);
valueRecord.removeCell(brC2);
confirmMulBlank(5, 2, 1);
valueRecord.removeCell(brC3);
confirmMulBlank(4, 1, 2);
}
use of org.apache.poi.hssf.record.BlankRecord in project poi by apache.
the class TestValueRecordsAggregate method testRemoveCell.
@Test
public void testRemoveCell() {
BlankRecord blankRecord1 = newBlankRecord();
valueRecord.insertCell(blankRecord1);
BlankRecord blankRecord2 = newBlankRecord();
valueRecord.removeCell(blankRecord2);
assertEquals(0, getValueRecords().size());
// removing an already empty cell just falls through
valueRecord.removeCell(blankRecord2);
}
use of org.apache.poi.hssf.record.BlankRecord in project poi by apache.
the class TestValueRecordsAggregate method testInsertCell.
@Test
public void testInsertCell() {
assertEquals(0, getValueRecords().size());
BlankRecord blankRecord = newBlankRecord();
valueRecord.insertCell(blankRecord);
assertEquals(1, getValueRecords().size());
}
use of org.apache.poi.hssf.record.BlankRecord in project poi by apache.
the class ValueRecordsAggregate method countBlanks.
/**
* @return the number of <em>consecutive</em> {@link BlankRecord}s in the specified row
* starting from startIx.
*/
private static int countBlanks(CellValueRecordInterface[] rowCellValues, int startIx) {
int i = startIx;
while (i < rowCellValues.length) {
CellValueRecordInterface cvr = rowCellValues[i];
if (!(cvr instanceof BlankRecord)) {
break;
}
i++;
}
return i - startIx;
}
use of org.apache.poi.hssf.record.BlankRecord in project poi by apache.
the class TestSheet method testRowValueAggregatesOrder_bug45145.
/**
* Prior to bug 45145 <tt>RowRecordsAggregate</tt> and <tt>ValueRecordsAggregate</tt> could
* sometimes occur in reverse order. This test reproduces one of those situations and makes
* sure that RRA comes before VRA.<br/>
*
* The code here represents a normal POI use case where a spreadsheet is created from scratch.
*/
@Test
public void testRowValueAggregatesOrder_bug45145() {
InternalSheet sheet = InternalSheet.createSheet();
RowRecord rr = new RowRecord(5);
sheet.addRow(rr);
CellValueRecordInterface cvr = new BlankRecord();
cvr.setColumn((short) 0);
cvr.setRow(5);
sheet.addValueRecord(5, cvr);
int dbCellRecordPos = getDbCellRecordPos(sheet);
if (dbCellRecordPos == 252) {
// DBCELL record pos is calculated wrong if VRA comes before RRA
throw new AssertionFailedError("Identified bug 45145");
}
// if (false) {
// // make sure that RRA and VRA are in the right place
// // (Aug 2008) since the VRA is now part of the RRA, there is much less chance that
// // they could get out of order. Still, one could write serialize the sheet here,
// // and read back with EventRecordFactory to make sure...
// }
assertEquals(242, dbCellRecordPos);
}
Aggregations