Search in sources :

Example 11 with BlankRecord

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);
}
Also used : MulBlankRecord(org.apache.poi.hssf.record.MulBlankRecord) BlankRecord(org.apache.poi.hssf.record.BlankRecord) Test(org.junit.Test)

Example 12 with BlankRecord

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);
}
Also used : MulBlankRecord(org.apache.poi.hssf.record.MulBlankRecord) BlankRecord(org.apache.poi.hssf.record.BlankRecord) Test(org.junit.Test)

Example 13 with BlankRecord

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());
}
Also used : MulBlankRecord(org.apache.poi.hssf.record.MulBlankRecord) BlankRecord(org.apache.poi.hssf.record.BlankRecord) Test(org.junit.Test)

Example 14 with BlankRecord

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;
}
Also used : MulBlankRecord(org.apache.poi.hssf.record.MulBlankRecord) BlankRecord(org.apache.poi.hssf.record.BlankRecord) CellValueRecordInterface(org.apache.poi.hssf.record.CellValueRecordInterface)

Example 15 with BlankRecord

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);
}
Also used : MulBlankRecord(org.apache.poi.hssf.record.MulBlankRecord) BlankRecord(org.apache.poi.hssf.record.BlankRecord) CellValueRecordInterface(org.apache.poi.hssf.record.CellValueRecordInterface) RowRecord(org.apache.poi.hssf.record.RowRecord) AssertionFailedError(junit.framework.AssertionFailedError) Test(org.junit.Test)

Aggregations

BlankRecord (org.apache.poi.hssf.record.BlankRecord)15 MulBlankRecord (org.apache.poi.hssf.record.MulBlankRecord)12 Test (org.junit.Test)7 FormulaRecord (org.apache.poi.hssf.record.FormulaRecord)4 RowRecord (org.apache.poi.hssf.record.RowRecord)4 CellValueRecordInterface (org.apache.poi.hssf.record.CellValueRecordInterface)3 LabelSSTRecord (org.apache.poi.hssf.record.LabelSSTRecord)3 NumberRecord (org.apache.poi.hssf.record.NumberRecord)3 Record (org.apache.poi.hssf.record.Record)3 SharedFormulaRecord (org.apache.poi.hssf.record.SharedFormulaRecord)3 WindowTwoRecord (org.apache.poi.hssf.record.WindowTwoRecord)3 AssertionFailedError (junit.framework.AssertionFailedError)2 LastCellOfRowDummyRecord (org.apache.poi.hssf.eventusermodel.dummyrecord.LastCellOfRowDummyRecord)2 MissingCellDummyRecord (org.apache.poi.hssf.eventusermodel.dummyrecord.MissingCellDummyRecord)2 BOFRecord (org.apache.poi.hssf.record.BOFRecord)2 BoolErrRecord (org.apache.poi.hssf.record.BoolErrRecord)2 DimensionsRecord (org.apache.poi.hssf.record.DimensionsRecord)2 StringRecord (org.apache.poi.hssf.record.StringRecord)2 ArrayList (java.util.ArrayList)1 MissingRowDummyRecord (org.apache.poi.hssf.eventusermodel.dummyrecord.MissingRowDummyRecord)1