Search in sources :

Example 1 with GutsRecord

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

the class InternalSheet method groupColumnRange.

/**
     * Creates an outline group for the specified columns.
     * @param fromColumn    group from this column (inclusive)
     * @param toColumn      group to this column (inclusive)
     * @param indent        if true the group will be indented by one level,
     *                      if false indenting will be removed by one level.
     */
public void groupColumnRange(int fromColumn, int toColumn, boolean indent) {
    // Set the level for each column
    _columnInfos.groupColumnRange(fromColumn, toColumn, indent);
    // Determine the maximum overall level
    int maxLevel = _columnInfos.getMaxOutlineLevel();
    GutsRecord guts = getGutsRecord();
    guts.setColLevelMax((short) (maxLevel + 1));
    if (maxLevel == 0) {
        guts.setTopColGutter((short) 0);
    } else {
        guts.setTopColGutter((short) (29 + (12 * (maxLevel - 1))));
    }
}
Also used : GutsRecord(org.apache.poi.hssf.record.GutsRecord)

Example 2 with GutsRecord

use of org.apache.poi.hssf.record.GutsRecord 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 3 with GutsRecord

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

the class InternalSheet method createGuts.

/**
     * creates the Guts record and sets leftrow/topcol guttter and rowlevelmax/collevelmax to 0
      */
private static GutsRecord createGuts() {
    GutsRecord retval = new GutsRecord();
    retval.setLeftRowGutter((short) 0);
    retval.setTopColGutter((short) 0);
    retval.setRowLevelMax((short) 0);
    retval.setColLevelMax((short) 0);
    return retval;
}
Also used : GutsRecord(org.apache.poi.hssf.record.GutsRecord)

Example 4 with GutsRecord

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

the class InternalSheet method getGutsRecord.

private GutsRecord getGutsRecord() {
    if (_gutsRecord == null) {
        GutsRecord result = createGuts();
        RecordOrderer.addNewSheetRecord(_records, result);
        _gutsRecord = result;
    }
    return _gutsRecord;
}
Also used : GutsRecord(org.apache.poi.hssf.record.GutsRecord)

Example 5 with GutsRecord

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

the class TestSheet method testGutsRecord_bug45640.

/**
	 * Checks for bug introduced around r682282-r683880 that caused a second GUTS records
	 * which in turn got the dimensions record out of alignment
	 */
@Test
public void testGutsRecord_bug45640() {
    InternalSheet sheet = InternalSheet.createSheet();
    sheet.addRow(new RowRecord(0));
    sheet.addRow(new RowRecord(1));
    sheet.groupRowRange(0, 1, true);
    sheet.toString();
    List<RecordBase> recs = sheet.getRecords();
    int count = 0;
    for (int i = 0; i < recs.size(); i++) {
        if (recs.get(i) instanceof GutsRecord) {
            count++;
        }
    }
    if (count == 2) {
        throw new AssertionFailedError("Identified bug 45640");
    }
    assertEquals(1, count);
}
Also used : RowRecord(org.apache.poi.hssf.record.RowRecord) RecordBase(org.apache.poi.hssf.record.RecordBase) GutsRecord(org.apache.poi.hssf.record.GutsRecord) AssertionFailedError(junit.framework.AssertionFailedError) Test(org.junit.Test)

Aggregations

GutsRecord (org.apache.poi.hssf.record.GutsRecord)5 RowRecord (org.apache.poi.hssf.record.RowRecord)2 AssertionFailedError (junit.framework.AssertionFailedError)1 RecordBase (org.apache.poi.hssf.record.RecordBase)1 Test (org.junit.Test)1