use of org.apache.poi.poifs.filesystem.POIFSFileSystem in project poi by apache.
the class POIFSFileHandler method handlePOIDocument.
protected void handlePOIDocument(POIDocument doc) throws Exception {
ByteArrayOutputStream out = new ByteArrayOutputStream();
doc.write(out);
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
POIFSFileSystem fs = new POIFSFileSystem(in);
handlePOIFSFileSystem(fs);
fs.close();
}
use of org.apache.poi.poifs.filesystem.POIFSFileSystem in project poi by apache.
the class POIFSFileHandler method handleFile.
@Override
public void handleFile(InputStream stream, String path) throws Exception {
POIFSFileSystem fs = new POIFSFileSystem(stream);
try {
handlePOIFSFileSystem(fs);
handleHPSFProperties(fs);
} finally {
fs.close();
}
}
use of org.apache.poi.poifs.filesystem.POIFSFileSystem in project poi by apache.
the class HPBFFileHandler method handleFile.
@Override
public void handleFile(InputStream stream, String path) throws Exception {
HPBFDocument pub = new HPBFDocument(new POIFSFileSystem(stream));
assertNotNull(pub.getEscherDelayStm());
assertNotNull(pub.getMainContents());
assertNotNull(pub.getQuillContents());
// writing is not yet implemented... handlePOIDocument(pub);
pub.close();
}
use of org.apache.poi.poifs.filesystem.POIFSFileSystem in project poi by apache.
the class HWPFDocumentCore method verifyAndBuildPOIFS.
/**
* Takes an InputStream, verifies that it's not RTF or PDF, builds a
* POIFSFileSystem from it, and returns that.
*/
public static POIFSFileSystem verifyAndBuildPOIFS(InputStream istream) throws IOException {
// Open a PushbackInputStream, so we can peek at the first few bytes
PushbackInputStream pis = new PushbackInputStream(istream, 6);
byte[] first6 = IOUtils.toByteArray(pis, 6);
// Does it start with {\rtf ? If so, it's really RTF
if (first6[0] == '{' && first6[1] == '\\' && first6[2] == 'r' && first6[3] == 't' && first6[4] == 'f') {
throw new IllegalArgumentException("The document is really a RTF file");
} else if (first6[0] == '%' && first6[1] == 'P' && first6[2] == 'D' && first6[3] == 'F') {
throw new IllegalArgumentException("The document is really a PDF file");
}
// OK, so it's neither RTF nor PDF
// Open a POIFSFileSystem on the (pushed back) stream
pis.unread(first6);
return new POIFSFileSystem(pis);
}
use of org.apache.poi.poifs.filesystem.POIFSFileSystem in project poi by apache.
the class TestCurrentUserAtom method readEnc.
@Test(expected = EncryptedPowerPointFileException.class)
public void readEnc() throws Exception {
POIFSFileSystem fs = new POIFSFileSystem(_slTests.getFile(encFile));
try {
new CurrentUserAtom(fs.getRoot());
// not yet failed
assertTrue(true);
new HSLFSlideShowImpl(fs).close();
} finally {
fs.close();
}
}
Aggregations