Search in sources :

Example 6 with RecordInputStream

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

the class TestSheetPropertiesRecord method testLoad.

public void testLoad() {
    RecordInputStream in = TestcaseRecordInputStream.create(0x1044, data);
    SheetPropertiesRecord record = new SheetPropertiesRecord(in);
    if (in.remaining() == 1) {
        throw new AssertionFailedError("Identified bug 44693c");
    }
    assertEquals(0, in.remaining());
    assertEquals(10, record.getFlags());
    assertEquals(false, record.isChartTypeManuallyFormatted());
    assertEquals(true, record.isPlotVisibleOnly());
    assertEquals(false, record.isDoNotSizeWithWindow());
    assertEquals(true, record.isDefaultPlotDimensions());
    assertEquals(false, record.isAutoPlotArea());
    assertEquals(0, record.getEmpty());
    assertEquals(8, record.getRecordSize());
}
Also used : AssertionFailedError(junit.framework.AssertionFailedError) RecordInputStream(org.apache.poi.hssf.record.RecordInputStream) TestcaseRecordInputStream(org.apache.poi.hssf.record.TestcaseRecordInputStream)

Example 7 with RecordInputStream

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

the class TestExtendedPivotTableViewFieldsRecord method testSubNameNotPresent_bug46693.

public void testSubNameNotPresent_bug46693() {
    // This data came from attachment 23347 of bug 46693 at offset 0xAA43
    byte[] data = HexRead.readFromString(// BIFF header
    "00 01 14 00" + "1E 14 00 0A FF FF FF FF 00 00 FF FF 00 00 00 00 00 00 00 00");
    RecordInputStream in = TestcaseRecordInputStream.create(data);
    ExtendedPivotTableViewFieldsRecord rec;
    try {
        rec = new ExtendedPivotTableViewFieldsRecord(in);
    } catch (RecordFormatException e) {
        if (e.getMessage().equals("Expected to find a ContinueRecord in order to read remaining 65535 of 65535 chars")) {
            throw new AssertionFailedError("Identified bug 46693a");
        }
        throw e;
    }
    assertEquals(data.length, rec.getRecordSize());
}
Also used : RecordFormatException(org.apache.poi.hssf.record.RecordFormatException) ExtendedPivotTableViewFieldsRecord(org.apache.poi.hssf.record.pivottable.ExtendedPivotTableViewFieldsRecord) AssertionFailedError(junit.framework.AssertionFailedError) RecordInputStream(org.apache.poi.hssf.record.RecordInputStream) TestcaseRecordInputStream(org.apache.poi.hssf.record.TestcaseRecordInputStream)

Example 8 with RecordInputStream

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

the class TestExtendedPivotTableViewFieldsRecord method testOlderFormat_bug46918.

public void testOlderFormat_bug46918() {
    // There are 10 SXVDEX records in the file (not uploaded) that originated bugzilla 46918
    // They all had the following hex encoding:
    byte[] data = HexRead.readFromString("00 01 0A 00 1E 14 00 0A FF FF FF FF 00 00");
    RecordInputStream in = TestcaseRecordInputStream.create(data);
    ExtendedPivotTableViewFieldsRecord rec;
    try {
        rec = new ExtendedPivotTableViewFieldsRecord(in);
    } catch (RecordFormatException e) {
        if (e.getMessage().equals("Not enough data (0) to read requested (2) bytes")) {
            throw new AssertionFailedError("Identified bug 46918");
        }
        throw e;
    }
    byte[] expReserData = HexRead.readFromString("1E 14 00 0A FF FF FF FF 00 00" + "FF FF 00 00 00 00 00 00 00 00");
    TestcaseRecordInputStream.confirmRecordEncoding(ExtendedPivotTableViewFieldsRecord.sid, expReserData, rec.serialize());
}
Also used : RecordFormatException(org.apache.poi.hssf.record.RecordFormatException) ExtendedPivotTableViewFieldsRecord(org.apache.poi.hssf.record.pivottable.ExtendedPivotTableViewFieldsRecord) AssertionFailedError(junit.framework.AssertionFailedError) RecordInputStream(org.apache.poi.hssf.record.RecordInputStream) TestcaseRecordInputStream(org.apache.poi.hssf.record.TestcaseRecordInputStream)

Example 9 with RecordInputStream

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

the class TestChartFormatRecord method testLoad.

/**
	 * The correct size of a {@link ChartFormatRecord} is 20 bytes (not including header).
	 */
public void testLoad() {
    RecordInputStream in = TestcaseRecordInputStream.create(data);
    ChartFormatRecord record = new ChartFormatRecord(in);
    if (in.remaining() == 2) {
        throw new AssertionFailedError("Identified bug 44693d");
    }
    assertEquals(0, in.remaining());
    assertEquals(24, record.getRecordSize());
    byte[] data2 = record.serialize();
    assertArrayEquals(data, data2);
}
Also used : AssertionFailedError(junit.framework.AssertionFailedError) RecordInputStream(org.apache.poi.hssf.record.RecordInputStream) TestcaseRecordInputStream(org.apache.poi.hssf.record.TestcaseRecordInputStream)

Example 10 with RecordInputStream

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

the class TestPageItemRecord method confirmSerialize.

private static PageItemRecord confirmSerialize(String hexDump) {
    byte[] data = HexRead.readFromString(hexDump);
    RecordInputStream in = TestcaseRecordInputStream.create(PageItemRecord.sid, data);
    PageItemRecord rec = new PageItemRecord(in);
    assertEquals(0, in.remaining());
    assertEquals(4 + data.length, rec.getRecordSize());
    byte[] data2 = rec.serialize();
    TestcaseRecordInputStream.confirmRecordEncoding(PageItemRecord.sid, data, data2);
    return rec;
}
Also used : PageItemRecord(org.apache.poi.hssf.record.pivottable.PageItemRecord) RecordInputStream(org.apache.poi.hssf.record.RecordInputStream) TestcaseRecordInputStream(org.apache.poi.hssf.record.TestcaseRecordInputStream)

Aggregations

RecordInputStream (org.apache.poi.hssf.record.RecordInputStream)13 TestcaseRecordInputStream (org.apache.poi.hssf.record.TestcaseRecordInputStream)9 AssertionFailedError (junit.framework.AssertionFailedError)7 RecordFormatException (org.apache.poi.hssf.record.RecordFormatException)3 ExtendedPivotTableViewFieldsRecord (org.apache.poi.hssf.record.pivottable.ExtendedPivotTableViewFieldsRecord)3 ViewFieldsRecord (org.apache.poi.hssf.record.pivottable.ViewFieldsRecord)3 PageItemRecord (org.apache.poi.hssf.record.pivottable.PageItemRecord)2 NPOIFSFileSystem (org.apache.poi.poifs.filesystem.NPOIFSFileSystem)2 BufferedInputStream (java.io.BufferedInputStream)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 ArrayRecord (org.apache.poi.hssf.record.ArrayRecord)1 AutoFilterInfoRecord (org.apache.poi.hssf.record.AutoFilterInfoRecord)1 BOFRecord (org.apache.poi.hssf.record.BOFRecord)1 BackupRecord (org.apache.poi.hssf.record.BackupRecord)1 BlankRecord (org.apache.poi.hssf.record.BlankRecord)1 BookBoolRecord (org.apache.poi.hssf.record.BookBoolRecord)1