Search in sources :

Example 1 with RowRecord

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

the class InternalSheet method recalcRowGutter.

private void recalcRowGutter() {
    int maxLevel = 0;
    Iterator<RowRecord> iterator = _rowsAggregate.getIterator();
    while (iterator.hasNext()) {
        RowRecord rowRecord = iterator.next();
        maxLevel = Math.max(rowRecord.getOutlineLevel(), maxLevel);
    }
    // Grab the guts record, adding if needed
    GutsRecord guts = getGutsRecord();
    // Set the levels onto it
    guts.setRowLevelMax((short) (maxLevel + 1));
    guts.setLeftRowGutter((short) (29 + (12 * (maxLevel))));
}
Also used : RowRecord(org.apache.poi.hssf.record.RowRecord) GutsRecord(org.apache.poi.hssf.record.GutsRecord)

Example 2 with RowRecord

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

the class InternalSheet method groupRowRange.

public void groupRowRange(int fromRow, int toRow, boolean indent) {
    for (int rowNum = fromRow; rowNum <= toRow; rowNum++) {
        RowRecord row = getRow(rowNum);
        if (row == null) {
            row = RowRecordsAggregate.createRow(rowNum);
            addRow(row);
        }
        int level = row.getOutlineLevel();
        if (indent)
            level++;
        else
            level--;
        level = Math.max(0, level);
        level = Math.min(7, level);
        row.setOutlineLevel((short) (level));
    }
    recalcRowGutter();
}
Also used : RowRecord(org.apache.poi.hssf.record.RowRecord)

Example 3 with RowRecord

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

the class TestSheet method testCloneMulBlank_bug46776.

@Test
public void testCloneMulBlank_bug46776() {
    Record[] recs = { InternalSheet.createBOF(), new DimensionsRecord(), new RowRecord(1), new MulBlankRecord(1, 3, new short[] { 0x0F, 0x0F, 0x0F }), new RowRecord(2), createWindow2Record(), EOFRecord.instance };
    InternalSheet sheet = createSheet(Arrays.asList(recs));
    InternalSheet sheet2;
    try {
        sheet2 = sheet.cloneSheet();
    } catch (RuntimeException e) {
        if (e.getMessage().equals("The class org.apache.poi.hssf.record.MulBlankRecord needs to define a clone method")) {
            throw new AssertionFailedError("Identified bug 46776");
        }
        throw e;
    }
    RecordCollector rc = new RecordCollector();
    sheet2.visitContainedRecords(rc, 0);
    Record[] clonedRecs = rc.getRecords();
    // +2 for INDEX and DBCELL
    assertEquals(recs.length + 2, clonedRecs.length);
}
Also used : MulBlankRecord(org.apache.poi.hssf.record.MulBlankRecord) RecordCollector(org.apache.poi.hssf.usermodel.RecordInspector.RecordCollector) RowRecord(org.apache.poi.hssf.record.RowRecord) DimensionsRecord(org.apache.poi.hssf.record.DimensionsRecord) StringRecord(org.apache.poi.hssf.record.StringRecord) GutsRecord(org.apache.poi.hssf.record.GutsRecord) MergeCellsRecord(org.apache.poi.hssf.record.MergeCellsRecord) DrawingRecord(org.apache.poi.hssf.record.DrawingRecord) NoteRecord(org.apache.poi.hssf.record.NoteRecord) Record(org.apache.poi.hssf.record.Record) ObjRecord(org.apache.poi.hssf.record.ObjRecord) EOFRecord(org.apache.poi.hssf.record.EOFRecord) RowRecord(org.apache.poi.hssf.record.RowRecord) ColumnInfoRecord(org.apache.poi.hssf.record.ColumnInfoRecord) WindowTwoRecord(org.apache.poi.hssf.record.WindowTwoRecord) EscherDggRecord(org.apache.poi.ddf.EscherDggRecord) TextObjectRecord(org.apache.poi.hssf.record.TextObjectRecord) IndexRecord(org.apache.poi.hssf.record.IndexRecord) BOFRecord(org.apache.poi.hssf.record.BOFRecord) NumberRecord(org.apache.poi.hssf.record.NumberRecord) MulBlankRecord(org.apache.poi.hssf.record.MulBlankRecord) UncalcedRecord(org.apache.poi.hssf.record.UncalcedRecord) DimensionsRecord(org.apache.poi.hssf.record.DimensionsRecord) BlankRecord(org.apache.poi.hssf.record.BlankRecord) FormulaRecord(org.apache.poi.hssf.record.FormulaRecord) AssertionFailedError(junit.framework.AssertionFailedError) Test(org.junit.Test)

Example 4 with RowRecord

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

the class TestSheet method testSheetDimensions.

@Test
public void testSheetDimensions() throws IOException {
    InternalSheet sheet = InternalSheet.createSheet();
    DimensionsRecord dimensions = (DimensionsRecord) sheet.findFirstRecordBySid(DimensionsRecord.sid);
    assertEquals(0, dimensions.getFirstCol());
    assertEquals(0, dimensions.getFirstRow());
    // plus pne
    assertEquals(1, dimensions.getLastCol());
    // plus pne
    assertEquals(1, dimensions.getLastRow());
    RowRecord rr = new RowRecord(0);
    sheet.addRow(rr);
    assertEquals(0, dimensions.getFirstCol());
    assertEquals(0, dimensions.getFirstRow());
    assertEquals(1, dimensions.getLastCol());
    assertEquals(1, dimensions.getLastRow());
    CellValueRecordInterface cvr;
    cvr = new BlankRecord();
    cvr.setColumn((short) 0);
    cvr.setRow(0);
    sheet.addValueRecord(0, cvr);
    assertEquals(0, dimensions.getFirstCol());
    assertEquals(0, dimensions.getFirstRow());
    assertEquals(1, dimensions.getLastCol());
    assertEquals(1, dimensions.getLastRow());
    cvr = new BlankRecord();
    cvr.setColumn((short) 1);
    cvr.setRow(0);
    sheet.addValueRecord(0, cvr);
    assertEquals(0, dimensions.getFirstCol());
    assertEquals(0, dimensions.getFirstRow());
    //YK:  failed until Bugzilla 53414 was fixed
    assertEquals(2, dimensions.getLastCol());
    assertEquals(1, dimensions.getLastRow());
}
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) DimensionsRecord(org.apache.poi.hssf.record.DimensionsRecord) Test(org.junit.Test)

Example 5 with RowRecord

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

the class TestRowRecordsAggregate method testUnknownContinue_bug46280.

/**
	 * This problem was noted as the overt symptom of bug 46280.  The logic for skipping {@link
	 * UnknownRecord}s in the constructor {@link RowRecordsAggregate} did not allow for the
	 * possibility of tailing {@link ContinueRecord}s.<br/>
	 * The functionality change being tested here is actually not critical to the overall fix
	 * for bug 46280, since the fix involved making sure the that offending <i>PivotTable</i>
	 * records do not get into {@link RowRecordsAggregate}.<br/>
	 * This fix in {@link RowRecordsAggregate} was implemented anyway since any {@link
	 * UnknownRecord} has the potential of being 'continued'.
	 */
@Test
public void testUnknownContinue_bug46280() {
    Record[] inRecs = { new RowRecord(0), new NumberRecord(), new UnknownRecord(0x5555, "dummydata".getBytes(LocaleUtil.CHARSET_1252)), new ContinueRecord("moredummydata".getBytes(LocaleUtil.CHARSET_1252)) };
    RecordStream rs = new RecordStream(Arrays.asList(inRecs), 0);
    RowRecordsAggregate rra;
    try {
        rra = new RowRecordsAggregate(rs, SharedValueManager.createEmpty());
    } catch (RuntimeException e) {
        if (e.getMessage().startsWith("Unexpected record type")) {
            fail("Identified bug 46280a");
        }
        throw e;
    }
    RecordCollector rv = new RecordCollector();
    rra.visitContainedRecords(rv);
    Record[] outRecs = rv.getRecords();
    assertEquals(5, outRecs.length);
}
Also used : RecordStream(org.apache.poi.hssf.model.RecordStream) RecordCollector(org.apache.poi.hssf.usermodel.RecordInspector.RecordCollector) RowRecord(org.apache.poi.hssf.record.RowRecord) UnknownRecord(org.apache.poi.hssf.record.UnknownRecord) ContinueRecord(org.apache.poi.hssf.record.ContinueRecord) Record(org.apache.poi.hssf.record.Record) NumberRecord(org.apache.poi.hssf.record.NumberRecord) UnknownRecord(org.apache.poi.hssf.record.UnknownRecord) ArrayRecord(org.apache.poi.hssf.record.ArrayRecord) ContinueRecord(org.apache.poi.hssf.record.ContinueRecord) TableRecord(org.apache.poi.hssf.record.TableRecord) RowRecord(org.apache.poi.hssf.record.RowRecord) SharedFormulaRecord(org.apache.poi.hssf.record.SharedFormulaRecord) FormulaRecord(org.apache.poi.hssf.record.FormulaRecord) NumberRecord(org.apache.poi.hssf.record.NumberRecord) Test(org.junit.Test)

Aggregations

RowRecord (org.apache.poi.hssf.record.RowRecord)17 Test (org.junit.Test)11 BlankRecord (org.apache.poi.hssf.record.BlankRecord)7 DimensionsRecord (org.apache.poi.hssf.record.DimensionsRecord)7 MulBlankRecord (org.apache.poi.hssf.record.MulBlankRecord)7 Record (org.apache.poi.hssf.record.Record)7 GutsRecord (org.apache.poi.hssf.record.GutsRecord)6 NumberRecord (org.apache.poi.hssf.record.NumberRecord)6 WindowTwoRecord (org.apache.poi.hssf.record.WindowTwoRecord)6 BOFRecord (org.apache.poi.hssf.record.BOFRecord)5 DrawingRecord (org.apache.poi.hssf.record.DrawingRecord)5 FormulaRecord (org.apache.poi.hssf.record.FormulaRecord)5 NoteRecord (org.apache.poi.hssf.record.NoteRecord)5 StringRecord (org.apache.poi.hssf.record.StringRecord)5 AssertionFailedError (junit.framework.AssertionFailedError)4 EscherDggRecord (org.apache.poi.ddf.EscherDggRecord)4 CellValueRecordInterface (org.apache.poi.hssf.record.CellValueRecordInterface)4 ColumnInfoRecord (org.apache.poi.hssf.record.ColumnInfoRecord)4 EOFRecord (org.apache.poi.hssf.record.EOFRecord)4 IndexRecord (org.apache.poi.hssf.record.IndexRecord)4