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))));
}
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();
}
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);
}
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());
}
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);
}
Aggregations