Search in sources :

Example 1 with HDGFDiagram

use of org.apache.poi.hdgf.HDGFDiagram 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)

Example 2 with HDGFDiagram

use of org.apache.poi.hdgf.HDGFDiagram in project poi by apache.

the class TestVisioExtractor method testCreation.

/**
	 * Test the 3 different ways of creating one
	 */
@Test
public void testCreation() throws IOException {
    VisioTextExtractor extractor1 = openExtractor(defFilename);
    assertNotNull(extractor1);
    assertNotNull(extractor1.getAllText());
    assertEquals(defTextChunks, extractor1.getAllText().length);
    extractor1.close();
    InputStream is2 = _dgTests.openResourceAsStream(defFilename);
    POIFSFileSystem poifs2 = new POIFSFileSystem(is2);
    is2.close();
    VisioTextExtractor extractor2 = new VisioTextExtractor(poifs2);
    assertNotNull(extractor2);
    assertNotNull(extractor2.getAllText());
    assertEquals(defTextChunks, extractor2.getAllText().length);
    extractor2.close();
    poifs2.close();
    InputStream is3 = _dgTests.openResourceAsStream(defFilename);
    POIFSFileSystem poifs3 = new POIFSFileSystem(is3);
    is3.close();
    HDGFDiagram hdgf3 = new HDGFDiagram(poifs3);
    VisioTextExtractor extractor3 = new VisioTextExtractor(hdgf3);
    assertNotNull(extractor3);
    assertNotNull(extractor3.getAllText());
    assertEquals(defTextChunks, extractor3.getAllText().length);
    extractor3.close();
    hdgf3.close();
    poifs3.close();
}
Also used : HDGFDiagram(org.apache.poi.hdgf.HDGFDiagram) InputStream(java.io.InputStream) POIFSFileSystem(org.apache.poi.poifs.filesystem.POIFSFileSystem) Test(org.junit.Test)

Example 3 with HDGFDiagram

use of org.apache.poi.hdgf.HDGFDiagram in project poi by apache.

the class VSDDumper method main.

public static void main(String[] args) throws Exception {
    if (args.length == 0) {
        System.err.println("Use:");
        System.err.println("  VSDDumper <filename>");
        System.exit(1);
    }
    NPOIFSFileSystem poifs = new NPOIFSFileSystem(new File(args[0]));
    try {
        HDGFDiagram hdgf = new HDGFDiagram(poifs);
        PrintStream ps = System.out;
        ps.println("Opened " + args[0]);
        VSDDumper vd = new VSDDumper(ps, hdgf);
        vd.dumpFile();
    } finally {
        poifs.close();
    }
}
Also used : PrintStream(java.io.PrintStream) NPOIFSFileSystem(org.apache.poi.poifs.filesystem.NPOIFSFileSystem) HDGFDiagram(org.apache.poi.hdgf.HDGFDiagram) File(java.io.File)

Aggregations

HDGFDiagram (org.apache.poi.hdgf.HDGFDiagram)3 InputStream (java.io.InputStream)2 POIFSFileSystem (org.apache.poi.poifs.filesystem.POIFSFileSystem)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 PrintStream (java.io.PrintStream)1 Stream (org.apache.poi.hdgf.streams.Stream)1 TrailerStream (org.apache.poi.hdgf.streams.TrailerStream)1 NPOIFSFileSystem (org.apache.poi.poifs.filesystem.NPOIFSFileSystem)1 Test (org.junit.Test)1