Package org.apache.poi.hslf.usermodel

Examples of org.apache.poi.hslf.usermodel.SlideShow


    /**
     * A simple bar chart demo
     */
    public static void main(String[] args) throws Exception {
        SlideShow ppt = new SlideShow();

        //bar chart data. The first value is the bar color, the second is the width
        Object[] def = new Object[]{
            Color.yellow, new Integer(40),
            Color.green, new Integer(60),
            Color.gray, new Integer(30),
            Color.red, new Integer(80),
        };

        Slide slide = ppt.createSlide();

        ShapeGroup group = new ShapeGroup();
        //define position of the drawing in the slide
        Rectangle bounds = new java.awt.Rectangle(200, 100, 350, 300);
        group.setAnchor(bounds);
        group.setCoordinates(new java.awt.Rectangle(0, 0, 100, 100));
        slide.addShape(group);
        Graphics2D graphics = new PPGraphics2D(group);

        //draw a simple bar graph
        int x = 10, y = 10;
        graphics.setFont(new Font("Arial", Font.BOLD, 10));
        for (int i = 0, idx = 1; i < def.length; i+=2, idx++) {
            graphics.setColor(Color.black);
            int width = ((Integer)def[i+1]).intValue();
            graphics.drawString("Q" + idx, x-5, y+10);
            graphics.drawString(width + "%", x + width+3, y + 10);
            graphics.setColor((Color)def[i]);
            graphics.fill(new Rectangle(x, y, width, 10));
            y += 15;
        }
        graphics.setColor(Color.black);
        graphics.setFont(new Font("Arial", Font.BOLD, 14));
        graphics.draw(group.getCoordinates());
        graphics.drawString("Performance", x + 30, y + 10);

        FileOutputStream out = new FileOutputStream("hslf-graphics.ppt");
        ppt.write(out);
        out.close();
    }
View Full Code Here


*/
public class BulletsDemo {

    public static void main(String[] args) throws Exception {

        SlideShow ppt = new SlideShow();

        Slide slide = ppt.createSlide();

        TextBox shape = new TextBox();
        RichTextRun rt = shape.getTextRun().getRichTextRuns()[0];
        shape.setText(
                "January\r" +
                "February\r" +
                "March\r" +
                "April");
        rt.setFontSize(42);
        rt.setBullet(true);
        rt.setBulletOffset(0)//bullet offset
        rt.setTextOffset(50);   //text offset (should be greater than bullet offset)
        rt.setBulletChar('\u263A'); //bullet character
        slide.addShape(shape);

        shape.setAnchor(new java.awt.Rectangle(50, 50, 500, 300))//position of the text box in the slide
        slide.addShape(shape);

        FileOutputStream out = new FileOutputStream("bullets.ppt");
        ppt.write(out);
        out.close();
   }
View Full Code Here

            {"Purchase History File - # of PO\u2019s\r(12/01/04 - 05/31/06)", "12,852"},
            {"Purchase History File - # of PO Lines\r(12/01/04 - 05/31/06)", "53,523" },
            {"Total PO History Spend", "$10,172,038"}
        };

        SlideShow ppt = new SlideShow();

        Slide slide = ppt.createSlide();

        //six rows, two columns
        Table table1 = new Table(6, 2);
        for (int i = 0; i < txt1.length; i++) {
            for (int j = 0; j < txt1[i].length; j++) {
                TableCell cell = table1.getCell(i, j);
                cell.setText(txt1[i][j]);
                RichTextRun rt = cell.getTextRun().getRichTextRuns()[0];
                rt.setFontName("Arial");
                rt.setFontSize(10);
                if(i == 0){
                    cell.getFill().setForegroundColor(new Color(227, 227, 227));
                } else {
                    rt.setBold(true);
                }
                cell.setVerticalAlignment(TextBox.AnchorMiddle);
                cell.setHorizontalAlignment(TextBox.AlignCenter);
            }
        }

        Line border1 = table1.createBorder();
        border1.setLineColor(Color.black);
        border1.setLineWidth(1.0);
        table1.setAllBorders(border1);

        table1.setColumnWidth(0, 300);
        table1.setColumnWidth(1, 150);

        slide.addShape(table1);
        int pgWidth = ppt.getPageSize().width;
        table1.moveTo((pgWidth - table1.getAnchor().width)/2, 100);

        //test data for the second taable
        String[][] txt2 = {
            {"Data Source"},
            {"CAS Internal Metrics - Item Master Summary\r" +
             "CAS Internal Metrics - Vendor Summary\r" +
             "CAS Internal Metrics - PO History Summary"}
        };

        //two rows, one column
        Table table2 = new Table(2, 1);
        for (int i = 0; i < txt2.length; i++) {
            for (int j = 0; j < txt2[i].length; j++) {
                TableCell cell = table2.getCell(i, j);
                cell.setText(txt2[i][j]);
                RichTextRun rt = cell.getTextRun().getRichTextRuns()[0];
                rt.setFontSize(10);
                rt.setFontName("Arial");
                if(i == 0){
                    cell.getFill().setForegroundColor(new Color(0, 51, 102));
                    rt.setFontColor(Color.white);
                    rt.setBold(true);
                    rt.setFontSize(14);
                    cell.setHorizontalAlignment(TextBox.AlignCenter);
                } else {
                    rt.setBullet(true);
                    rt.setFontSize(12);
                    cell.setHorizontalAlignment(TextBox.AlignLeft);
                }
                cell.setVerticalAlignment(TextBox.AnchorMiddle);
            }
        }
        table2.setColumnWidth(0, 300);
        table2.setRowHeight(0, 30);
        table2.setRowHeight(1, 70);

        Line border2 = table2.createBorder();
        table2.setOutsideBorders(border2);

        slide.addShape(table2);
        table2.moveTo(200, 400);

        FileOutputStream out = new FileOutputStream("hslf-table.ppt");
        ppt.write(out);
        out.close();

    }
View Full Code Here

     * Returns the picture data for this picture.
     *
     * @return the picture data for this picture.
     */
    public PictureData getPictureData(){
        SlideShow ppt = getSheet().getSlideShow();
        PictureData[] pict = ppt.getPictureData();
        Document doc = ppt.getDocumentRecord();
        EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
        EscherContainerRecord bstore = (EscherContainerRecord)Shape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);

        List lst = bstore.getChildRecords();
        int idx = getPictureIndex();
View Full Code Here

     * Returns unique identifier for the OLE object.
     *
     * @return the unique identifier for the OLE object
     */
    public ObjectData getObjectData(){
        SlideShow ppt = getSheet().getSlideShow();
        ObjectData[] ole = ppt.getEmbeddedObjects();

        //persist reference
        int ref = getExEmbed().getExOleObjAtom().getObjStgDataRef();
        for (int i = 0; i < ole.length; i++) {
            if(ole[i].getExOleObjStg().getPersistId() == ref) return ole[i];
View Full Code Here

     * </p>
     * @return
     */
    public ExEmbed getExEmbed(){
        if(_exEmbed == null){
            SlideShow ppt = getSheet().getSlideShow();

            ExObjList lst = ppt.getDocumentRecord().getExObjList();
            if(lst == null){
                logger.log(POILogger.WARN, "ExObjList not found");
                return null;
            }

View Full Code Here

     * @param run  <code>TextRun</code> to lookup hyperlinks in
     * @return found hyperlinks or <code>null</code> if not found
     */
    protected static Hyperlink[] find(TextRun run){
        ArrayList lst = new ArrayList();
        SlideShow ppt = run.getSheet().getSlideShow();
        //document-level container which stores info about all links in a presentation
        ExObjList exobj = ppt.getDocumentRecord().getExObjList();
        if (exobj == null) {
            return null;
        }
        Record[] records = run._records;
        if(records != null) find(records, exobj, lst);
View Full Code Here

     * @param shape  <code>Shape</code> to lookup hyperlink in
     * @return found hyperlink or <code>null</code>
     */
    protected static Hyperlink find(Shape shape){
        ArrayList lst = new ArrayList();
        SlideShow ppt = shape.getSheet().getSlideShow();
        //document-level container which stores info about all links in a presentation
        ExObjList exobj = ppt.getDocumentRecord().getExObjList();
        if (exobj == null) {
            return null;
        }

        EscherContainerRecord spContainer = shape.getSpContainer();
View Full Code Here

    public PictureData getPictureData(){
        EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);
        EscherSimpleProperty p = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__PATTERNTEXTURE);
        if (p == null) return null;

        SlideShow ppt = shape.getSheet().getSlideShow();
        PictureData[] pict = ppt.getPictureData();
        Document doc = ppt.getDocumentRecord();

        EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
        EscherContainerRecord bstore = (EscherContainerRecord)Shape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);

        java.util.List lst = bstore.getChildRecords();
View Full Code Here

        if (args.length < 1) {
            System.err.println("Usage:");
            System.err.println("\tImageExtractor <file>");
            return;
        }
        SlideShow ppt = new SlideShow(new HSLFSlideShow(args[0]));

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

            // picture data
            byte[] data = pict.getData();
View Full Code Here

TOP

Related Classes of org.apache.poi.hslf.usermodel.SlideShow

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.