Example usage for org.apache.poi.hslf.record Document getDocumentAtom

List of usage examples for org.apache.poi.hslf.record Document getDocumentAtom

Introduction

In this page you can find the example usage for org.apache.poi.hslf.record Document getDocumentAtom.

Prototype

public DocumentAtom getDocumentAtom() 

Source Link

Document

Returns the DocumentAtom of this Document

Usage

From source file:br.pucrio.telemidia.ncl30.ppt2ncl.tests.Animations.java

License:Open Source License

public static void main(String[] args) {
    SlideShow ppt;//from w w w.j  av a2  s  .  c om
    try {
        ppt = new SlideShow(new HSLFSlideShow("exemplos/A01introducao.ppt"));
        Slide[] slide = ppt.getSlides();
        Document doc = ppt.getDocumentRecord();
        DocumentAtom docAtom = doc.getDocumentAtom();
        docAtom.getRecordType();

        for (int i = 0; i < slide.length; i++) {
            // extract all pictures contained in the presentation
            PictureData[] pdata = slide[i].getSlideShow().getPictureData();
            for (int j = 0; j < pdata.length; j++) {
                PictureData pict = pdata[j];

                // picture data
                byte[] data = pict.getData();

                int type = pict.getType();
                String ext;
                switch (type) {
                case Picture.JPEG:
                    ext = ".jpg";
                    break;
                case Picture.PNG:
                    ext = ".png";
                    break;
                case Picture.WMF:
                    ext = ".wmf";
                    break;
                case Picture.EMF:
                    ext = ".emf";
                    break;
                case Picture.PICT:
                    ext = ".pict";
                    break;
                default:
                    continue;
                }
                FileOutputStream out;
                try {
                    out = new FileOutputStream("exemplos/tests/pict_" + i + ext);
                    out.write(data);
                    out.close();
                } catch (FileNotFoundException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

}