Search in sources :

Example 6 with NPOIFSFileSystem

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

the class DrawingDump method main.

public static void main(String[] args) throws IOException {
    OutputStreamWriter osw = new OutputStreamWriter(System.out, Charset.defaultCharset());
    PrintWriter pw = new PrintWriter(osw);
    NPOIFSFileSystem fs = new NPOIFSFileSystem(new File(args[0]));
    HSSFWorkbook wb = new HSSFWorkbook(fs);
    try {
        pw.println("Drawing group:");
        wb.dumpDrawingGroupRecords(true);
        int i = 1;
        for (Sheet sheet : wb) {
            pw.println("Sheet " + i + "(" + sheet.getSheetName() + "):");
            ((HSSFSheet) sheet).dumpDrawingRecords(true, pw);
        }
    } finally {
        wb.close();
        fs.close();
    }
}
Also used : NPOIFSFileSystem(org.apache.poi.poifs.filesystem.NPOIFSFileSystem) OutputStreamWriter(java.io.OutputStreamWriter) HSSFSheet(org.apache.poi.hssf.usermodel.HSSFSheet) File(java.io.File) Sheet(org.apache.poi.ss.usermodel.Sheet) HSSFSheet(org.apache.poi.hssf.usermodel.HSSFSheet) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook) PrintWriter(java.io.PrintWriter)

Example 7 with NPOIFSFileSystem

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

the class TestXSLFSlideShowFactory method createProtected.

private static File createProtected(String basefile, String password) throws IOException, GeneralSecurityException {
    NPOIFSFileSystem fs = new NPOIFSFileSystem();
    EncryptionInfo info = new EncryptionInfo(EncryptionMode.agile);
    Encryptor enc = info.getEncryptor();
    enc.confirmPassword(password);
    InputStream fis = _slTests.openResourceAsStream(basefile);
    OutputStream os = enc.getDataStream(fs);
    IOUtils.copy(fis, os);
    os.close();
    fis.close();
    File tf = TempFile.createTempFile("test-xslf-slidefactory", ".pptx");
    FileOutputStream fos = new FileOutputStream(tf);
    fs.writeFilesystem(fos);
    fos.close();
    fs.close();
    return tf;
}
Also used : NPOIFSFileSystem(org.apache.poi.poifs.filesystem.NPOIFSFileSystem) EncryptionInfo(org.apache.poi.poifs.crypt.EncryptionInfo) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) Encryptor(org.apache.poi.poifs.crypt.Encryptor) TempFile(org.apache.poi.util.TempFile) File(java.io.File)

Example 8 with NPOIFSFileSystem

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

the class SlideShowDumper method main.

/**
   *  right now this function takes one parameter: a ppt file, and outputs
   *  a dump of what it contains
   */
public static void main(String[] args) throws IOException {
    if (args.length == 0) {
        System.err.println("Useage: SlideShowDumper [-escher|-basicescher] <filename>");
        return;
    }
    String filename = args[0];
    if (args.length > 1) {
        filename = args[1];
    }
    NPOIFSFileSystem poifs = new NPOIFSFileSystem(new File(filename));
    SlideShowDumper foo = new SlideShowDumper(poifs, System.out);
    poifs.close();
    if (args.length > 1) {
        if (args[0].equalsIgnoreCase("-escher")) {
            foo.setDDFEscher(true);
        } else {
            foo.setBasicEscher(true);
        }
    }
    foo.printDump();
}
Also used : NPOIFSFileSystem(org.apache.poi.poifs.filesystem.NPOIFSFileSystem) File(java.io.File)

Example 9 with NPOIFSFileSystem

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

the class HSMFDump method main.

public static void main(String[] args) throws Exception {
    for (String file : args) {
        NPOIFSFileSystem fs = new NPOIFSFileSystem(new File(file), true);
        HSMFDump dump = new HSMFDump(fs);
        dump.dump();
        fs.close();
    }
}
Also used : NPOIFSFileSystem(org.apache.poi.poifs.filesystem.NPOIFSFileSystem) File(java.io.File)

Example 10 with NPOIFSFileSystem

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

the class TestPOIDocumentScratchpad method testWriteProperties.

@Test
public void testWriteProperties() throws IOException {
    // Just check we can write them back out into a filesystem
    NPOIFSFileSystem outFS = new NPOIFSFileSystem();
    doc.writeProperties(outFS);
    // Should now hold them
    assertNotNull(outFS.createDocumentInputStream("\005SummaryInformation"));
    assertNotNull(outFS.createDocumentInputStream("\005DocumentSummaryInformation"));
    outFS.close();
}
Also used : NPOIFSFileSystem(org.apache.poi.poifs.filesystem.NPOIFSFileSystem) Test(org.junit.Test)

Aggregations

NPOIFSFileSystem (org.apache.poi.poifs.filesystem.NPOIFSFileSystem)101 Test (org.junit.Test)57 File (java.io.File)35 InputStream (java.io.InputStream)26 ByteArrayInputStream (java.io.ByteArrayInputStream)19 ByteArrayOutputStream (java.io.ByteArrayOutputStream)14 MAPIMessage (org.apache.poi.hsmf.MAPIMessage)14 FileOutputStream (java.io.FileOutputStream)12 TempFile (org.apache.poi.util.TempFile)12 FileInputStream (java.io.FileInputStream)11 OPOIFSFileSystem (org.apache.poi.poifs.filesystem.OPOIFSFileSystem)10 POIFSFileSystem (org.apache.poi.poifs.filesystem.POIFSFileSystem)10 DocumentSummaryInformation (org.apache.poi.hpsf.DocumentSummaryInformation)9 DirectoryNode (org.apache.poi.poifs.filesystem.DirectoryNode)9 IOException (java.io.IOException)8 OutputStream (java.io.OutputStream)8 SummaryInformation (org.apache.poi.hpsf.SummaryInformation)7 TikaInputStream (org.apache.tika.io.TikaInputStream)6 AgileDecryptor (org.apache.poi.poifs.crypt.agile.AgileDecryptor)5 DirectoryEntry (org.apache.poi.poifs.filesystem.DirectoryEntry)5