You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Yegor Kozlov <ye...@dinom.ru> on 2008/03/31 11:20:10 UTC

Re: Regarding hslf slide

Deletion of shapes in HSLF is not officially supported. However, you can use the following low-level code to delete shapes:

        FileInputStream is = new FileInputStream(new File(cwd, "template.ppt"));
        SlideShow ppt = new SlideShow(is);
        is.close();

        Slide slide = ppt.getSlides()[0];

        PPDrawing ppdrawing = slide.getSheetContainer().getPPDrawing();
        EscherContainerRecord dg = (EscherContainerRecord) ppdrawing.getEscherRecords()[0];
        EscherContainerRecord spgr = null;
        for (Iterator it = dg.getChildRecords().iterator(); it.hasNext();) {
            EscherRecord rec = (EscherRecord) it.next();
            if (rec.getRecordId() == EscherContainerRecord.SPGR_CONTAINER) {
                spgr = (EscherContainerRecord) rec;
                break;
            }
        }
        List ch = spgr.getChildRecords();

        Shape[] shape = slide.getShapes();
        for (int i = 0; i < shape.length; i++) {

            Shape placeholder = shape[i];
            //do something with the placeholder
            
            //remove the placeholder
            boolean ok = ch.remove(placeholder.getSpContainer());
            System.out.println("removed: " + ok);
        }

 Wait for a while if you can. I'm going to add Slide.deleteShape(Shape shape)
 which will be based on the code above. It should be committed soon.
 
Regards,
Yegor

> Hi

> I am trying to implement Apache POI hslf with my java project. The requirements are:

> I will be provided with a template PPT. It will contain some empty
> text boxes or placeholders, of which I have to replace with my Text, images, and other controls.
>  The details of the things to be placed on the final output will be provided as an XML file.

> Is there any way to delete these placeholding stuff and add my
> images or other controls on its place.

> Specifically is there any way in HSLF to delete a control(TextBox,
> Picture etc.) from a PPT. If yes please provide the details.
>  

> Looking forward for your reply,

> Thanks And Regards,
> Shibu

>   


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org