Hi,
I have a potx template with some layouts created in MS Powerpoint 2010 by
me with text, table and image placeholders.
I'm trying to execute this code:
---
import org.apache.poi.xslf.usermodel.*;
import java.io.*;
import java.awt.geom.*;
import java.awt.*;
import java.util.*;
public class Powerpoint{
public static void main(String[] args) throws Exception{
XMLSlideShow pptx = new XMLSlideShow(new
FileInputStream("layout_v0.potx"));
XSLFSlideMaster master = pptx.getSlideMasters()[0];
XSLFSlideLayout[] layouts = master.getSlideLayouts();
Iterator layout_it = new ArrayList(Arrays.asList(layouts)).iterator();
while(layout_it.hasNext()){
XSLFSlideLayout layout = (XSLFSlideLayout) layout_it.next();
XSLFSlide slide = pptx.createSlide(layout);
XSLFShape[] shapes = slide.getShapes();
Iterator shapes_it = new ArrayList(Arrays.asList(shapes)).iterator();
while(shapes_it.hasNext()){
XSLFShape shape = (XSLFShape) shapes_it.next();
System.out.println(shape.getShapeName());
if (shape instanceof XSLFConnectorShape){
System.out.println("CONNECTORSHAPE");
} else if (shape instanceof XSLFTextShape){
System.out.println("TEXTSHAPE");
} else if (shape instanceof XSLFPictureShape){
System.out.println("PICTURESHAPE");
}
}
}
return;
}
}
---
And the result is:
$ java Powerpoint
Title 1
TEXTSHAPE
Subtitle 2
TEXTSHAPE
Text Placeholder 20
TEXTSHAPE
Text Placeholder 22
TEXTSHAPE
Picture Placeholder 24
TEXTSHAPE
Table Placeholder 26
TEXTSHAPE
Obviously Picture Placeholder 24 and Table Placeholder 26 shouldn't be
Textshapes.
Am I doing anything wrong or Powerpoint saves this in a wrong format?
Thanks in advance.
-
- *Pablo Rivera*
- Software Engineer
-
- [email protected]
- T:(+34) 902 10 83 84
-
-
- www.mediasq.com