Search in sources :

Example 11 with POIFSFileSystem

use of org.apache.poi.poifs.filesystem.POIFSFileSystem in project poi by apache.

the class HSLFSlideShowImpl method write.

/**
     * Writes out the slideshow file the is represented by an instance
     * of this class.
     * If you require all streams to be written out (eg Marcos, embeded
     * documents), then set <code>preserveNodes</code> set to <code>true</code>
     *
     * @param newFile       The File to write to.
     * @param preserveNodes Should all OLE2 streams be written back out, or only the common ones?
     * @throws IOException If there is an unexpected IOException from writing to the File
     */
public void write(File newFile, boolean preserveNodes) throws IOException {
    // Get a new FileSystem to write into
    POIFSFileSystem outFS = POIFSFileSystem.create(newFile);
    try {
        // Write into the new FileSystem
        write(outFS, preserveNodes);
        // Send the POIFSFileSystem object out to the underlying stream
        outFS.writeFilesystem();
    } finally {
        outFS.close();
    }
}
Also used : POIFSFileSystem(org.apache.poi.poifs.filesystem.POIFSFileSystem) NPOIFSFileSystem(org.apache.poi.poifs.filesystem.NPOIFSFileSystem)

Example 12 with POIFSFileSystem

use of org.apache.poi.poifs.filesystem.POIFSFileSystem in project poi by apache.

the class TestPOIDocumentScratchpad method testWriteReadProperties.

@Test
public void testWriteReadProperties() throws IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    // Write them out
    NPOIFSFileSystem outFS = new NPOIFSFileSystem();
    doc.writeProperties(outFS);
    outFS.writeFilesystem(baos);
    // Create a new version
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    POIFSFileSystem inFS = new POIFSFileSystem(bais);
    // Check they're still there
    POIDocument ppt = new HPSFPropertiesOnlyDocument(inFS);
    ppt.readProperties();
    // Delegate test
    testReadPropertiesHelper(ppt);
    ppt.close();
    inFS.close();
}
Also used : NPOIFSFileSystem(org.apache.poi.poifs.filesystem.NPOIFSFileSystem) ByteArrayInputStream(java.io.ByteArrayInputStream) POIFSFileSystem(org.apache.poi.poifs.filesystem.POIFSFileSystem) NPOIFSFileSystem(org.apache.poi.poifs.filesystem.NPOIFSFileSystem) HPSFPropertiesOnlyDocument(org.apache.poi.hpsf.HPSFPropertiesOnlyDocument) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Example 13 with POIFSFileSystem

use of org.apache.poi.poifs.filesystem.POIFSFileSystem in project poi by apache.

the class TestHDGFCore method DISABLEDtestAIOOB.

/**
     * Tests that we can open a problematic file that triggers
     *  an ArrayIndexOutOfBoundsException when processing the
     *  chunk commands.
     * @throws Exception
     */
public void DISABLEDtestAIOOB() throws Exception {
    fs = new POIFSFileSystem(_dgTests.openResourceAsStream("44501.vsd"));
    hdgf = new HDGFDiagram(fs);
    assertNotNull(hdgf);
}
Also used : POIFSFileSystem(org.apache.poi.poifs.filesystem.POIFSFileSystem)

Example 14 with POIFSFileSystem

use of org.apache.poi.poifs.filesystem.POIFSFileSystem in project poi by apache.

the class TestStreamBugs method setUp.

@Before
public void setUp() throws IOException {
    ptrFactory = new PointerFactory(11);
    chunkFactory = new ChunkFactory(11);
    InputStream is = POIDataSamples.getDiagramInstance().openResourceAsStream("44594.vsd");
    filesystem = new POIFSFileSystem(is);
    is.close();
    // Grab the document stream
    InputStream is2 = filesystem.createDocumentInputStream("VisioDocument");
    contents = IOUtils.toByteArray(is2);
    is2.close();
}
Also used : InputStream(java.io.InputStream) POIFSFileSystem(org.apache.poi.poifs.filesystem.POIFSFileSystem) PointerFactory(org.apache.poi.hdgf.pointers.PointerFactory) ChunkFactory(org.apache.poi.hdgf.chunks.ChunkFactory) Before(org.junit.Before)

Example 15 with POIFSFileSystem

use of org.apache.poi.poifs.filesystem.POIFSFileSystem in project poi by apache.

the class TestStreamComplex method setUp.

@Before
public void setUp() throws IOException {
    ptrFactory = new PointerFactory(11);
    chunkFactory = new ChunkFactory(11);
    InputStream is = POIDataSamples.getDiagramInstance().openResourceAsStream("Test_Visio-Some_Random_Text.vsd");
    POIFSFileSystem filesystem = new POIFSFileSystem(is);
    is.close();
    // Grab the document stream
    InputStream is2 = filesystem.createDocumentInputStream("VisioDocument");
    contents = IOUtils.toByteArray(is2);
    is2.close();
    filesystem.close();
}
Also used : InputStream(java.io.InputStream) POIFSFileSystem(org.apache.poi.poifs.filesystem.POIFSFileSystem) PointerFactory(org.apache.poi.hdgf.pointers.PointerFactory) ChunkFactory(org.apache.poi.hdgf.chunks.ChunkFactory) Before(org.junit.Before)

Aggregations

POIFSFileSystem (org.apache.poi.poifs.filesystem.POIFSFileSystem)121 Test (org.junit.Test)58 NPOIFSFileSystem (org.apache.poi.poifs.filesystem.NPOIFSFileSystem)38 InputStream (java.io.InputStream)36 ByteArrayInputStream (java.io.ByteArrayInputStream)33 ByteArrayOutputStream (java.io.ByteArrayOutputStream)33 FileInputStream (java.io.FileInputStream)31 File (java.io.File)25 OPOIFSFileSystem (org.apache.poi.poifs.filesystem.OPOIFSFileSystem)15 FileOutputStream (java.io.FileOutputStream)14 OutputStream (java.io.OutputStream)14 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)13 DirectoryNode (org.apache.poi.poifs.filesystem.DirectoryNode)13 TempFile (org.apache.poi.util.TempFile)13 IOException (java.io.IOException)12 MutablePropertySet (org.apache.poi.hpsf.MutablePropertySet)7 MutableSection (org.apache.poi.hpsf.MutableSection)7 HashMap (java.util.HashMap)6 DocumentEntry (org.apache.poi.poifs.filesystem.DocumentEntry)6 NDocumentOutputStream (org.apache.poi.poifs.filesystem.NDocumentOutputStream)6