use of org.apache.poi.hssf.record.UnknownRecord 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);
}
use of org.apache.poi.hssf.record.UnknownRecord in project poi by apache.
the class TestRowBlocksReader method testAbnormalPivotTableRecords_bug46280.
@Test
public void testAbnormalPivotTableRecords_bug46280() {
int SXVIEW_SID = ViewDefinitionRecord.sid;
Record[] inRecs = { new RowRecord(0), new NumberRecord(), // normally MSODRAWING(0x00EC) would come here before SXVIEW
new UnknownRecord(SXVIEW_SID, "dummydata (SXVIEW: View Definition)".getBytes(LocaleUtil.CHARSET_1252)), new WindowTwoRecord() };
RecordStream rs = new RecordStream(Arrays.asList(inRecs), 0);
RowBlocksReader rbr = new RowBlocksReader(rs);
if (rs.peekNextClass() == WindowTwoRecord.class) {
// Should have stopped at the SXVIEW record
fail("Identified bug 46280b");
}
RecordStream rbStream = rbr.getPlainRecordStream();
assertEquals(inRecs[0], rbStream.getNext());
assertEquals(inRecs[1], rbStream.getNext());
assertFalse(rbStream.hasNext());
assertTrue(rs.hasNext());
assertEquals(inRecs[2], rs.getNext());
assertEquals(inRecs[3], rs.getNext());
}
use of org.apache.poi.hssf.record.UnknownRecord in project poi by apache.
the class HSSFWorkbook method insertChartRecord.
/** Test only. Do not use */
public void insertChartRecord() {
int loc = workbook.findFirstRecordLocBySid(SSTRecord.sid);
byte[] data = { (byte) 0x0F, (byte) 0x00, (byte) 0x00, (byte) 0xF0, (byte) 0x52, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x06, (byte) 0xF0, (byte) 0x18, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x08, (byte) 0x00, (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x03, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x33, (byte) 0x00, (byte) 0x0B, (byte) 0xF0, (byte) 0x12, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0xBF, (byte) 0x00, (byte) 0x08, (byte) 0x00, (byte) 0x08, (byte) 0x00, (byte) 0x81, (byte) 0x01, (byte) 0x09, (byte) 0x00, (byte) 0x00, (byte) 0x08, (byte) 0xC0, (byte) 0x01, (byte) 0x40, (byte) 0x00, (byte) 0x00, (byte) 0x08, (byte) 0x40, (byte) 0x00, (byte) 0x1E, (byte) 0xF1, (byte) 0x10, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0D, (byte) 0x00, (byte) 0x00, (byte) 0x08, (byte) 0x0C, (byte) 0x00, (byte) 0x00, (byte) 0x08, (byte) 0x17, (byte) 0x00, (byte) 0x00, (byte) 0x08, (byte) 0xF7, (byte) 0x00, (byte) 0x00, (byte) 0x10 };
UnknownRecord r = new UnknownRecord((short) 0x00EB, data);
workbook.getRecords().add(loc, r);
}
Aggregations