use of org.apache.poi.hssf.record.UncalcedRecord in project poi by apache.
the class InternalSheet method visitContainedRecords.
public void visitContainedRecords(RecordVisitor rv, int offset) {
PositionTrackingVisitor ptv = new PositionTrackingVisitor(rv, offset);
boolean haveSerializedIndex = false;
for (int k = 0; k < _records.size(); k++) {
RecordBase record = _records.get(k);
if (record instanceof RecordAggregate) {
RecordAggregate agg = (RecordAggregate) record;
agg.visitContainedRecords(ptv);
} else {
ptv.visitRecord((Record) record);
}
// If the BOF record was just serialized then add the IndexRecord
if (record instanceof BOFRecord) {
if (!haveSerializedIndex) {
haveSerializedIndex = true;
// and one shouldn't go in after that!
if (_isUncalced) {
ptv.visitRecord(new UncalcedRecord());
}
//remove this guard. So be safe it is left here.
if (_rowsAggregate != null) {
// find forward distance to first RowRecord
int initRecsSize = getSizeOfInitialSheetRecords(k);
int currentPos = ptv.getPosition();
ptv.visitRecord(_rowsAggregate.createIndexRecord(currentPos, initRecsSize));
}
}
}
}
}
use of org.apache.poi.hssf.record.UncalcedRecord in project poi by apache.
the class TestSheet method testUncalcSize_bug45066.
/**
* Prior to bug 45066, POI would get the estimated sheet size wrong
* when an <tt>UncalcedRecord</tt> was present.<p/>
*/
@Test
public void testUncalcSize_bug45066() {
List<Record> records = new ArrayList<Record>();
records.add(BOFRecord.createSheetBOF());
records.add(new UncalcedRecord());
records.add(new DimensionsRecord());
records.add(createWindow2Record());
records.add(EOFRecord.instance);
InternalSheet sheet = createSheet(records);
// The original bug was due to different logic for collecting records for sizing and
// serialization. The code has since been refactored into a single method for visiting
// all contained records. Now this test is much less interesting
SizeCheckingRecordVisitor scrv = new SizeCheckingRecordVisitor();
sheet.visitContainedRecords(scrv, 0);
assertEquals(90, scrv.getTotalSize());
}
Aggregations