Search in sources :

Example 1 with TrailerStream

use of org.apache.poi.hdgf.streams.TrailerStream in project poi by apache.

the class TestHDGFCore method testTrailer.

public void testTrailer() throws Exception {
    hdgf = new HDGFDiagram(fs);
    assertNotNull(hdgf);
    assertNotNull(hdgf.getTrailerStream());
    // Check it has what we'd expect
    TrailerStream trailer = hdgf.getTrailerStream();
    assertEquals(0x8a94, trailer.getPointer().getOffset());
    assertNotNull(trailer.getPointedToStreams());
    assertEquals(20, trailer.getPointedToStreams().length);
    assertEquals(20, hdgf.getTopLevelStreams().length);
    // 9th one should have children
    assertNotNull(trailer.getPointedToStreams()[8]);
    assertNotNull(trailer.getPointedToStreams()[8].getPointer());
    PointerContainingStream ps8 = (PointerContainingStream) trailer.getPointedToStreams()[8];
    assertNotNull(ps8.getPointedToStreams());
    assertEquals(8, ps8.getPointedToStreams().length);
}
Also used : TrailerStream(org.apache.poi.hdgf.streams.TrailerStream) PointerContainingStream(org.apache.poi.hdgf.streams.PointerContainingStream)

Example 2 with TrailerStream

use of org.apache.poi.hdgf.streams.TrailerStream in project poi by apache.

the class HDGFFileHandler method handleFile.

@Override
public void handleFile(InputStream stream, String path) throws IOException {
    POIFSFileSystem poifs = new POIFSFileSystem(stream);
    HDGFDiagram diagram = new HDGFDiagram(poifs);
    Stream[] topLevelStreams = diagram.getTopLevelStreams();
    assertNotNull(topLevelStreams);
    for (Stream str : topLevelStreams) {
        assertTrue(str.getPointer().getLength() >= 0);
    }
    TrailerStream trailerStream = diagram.getTrailerStream();
    assertNotNull(trailerStream);
    assertTrue(trailerStream.getPointer().getLength() >= 0);
    diagram.close();
    poifs.close();
// writing is not yet implemented... handlePOIDocument(diagram);
}
Also used : TrailerStream(org.apache.poi.hdgf.streams.TrailerStream) HDGFDiagram(org.apache.poi.hdgf.HDGFDiagram) POIFSFileSystem(org.apache.poi.poifs.filesystem.POIFSFileSystem) FileInputStream(java.io.FileInputStream) Stream(org.apache.poi.hdgf.streams.Stream) TrailerStream(org.apache.poi.hdgf.streams.TrailerStream) InputStream(java.io.InputStream)

Aggregations

TrailerStream (org.apache.poi.hdgf.streams.TrailerStream)2 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 HDGFDiagram (org.apache.poi.hdgf.HDGFDiagram)1 PointerContainingStream (org.apache.poi.hdgf.streams.PointerContainingStream)1 Stream (org.apache.poi.hdgf.streams.Stream)1 POIFSFileSystem (org.apache.poi.poifs.filesystem.POIFSFileSystem)1