Hi, I have problem iterate throw master slides, first metod getMasters() return just first master slide not all of them, second how I can iterate throw shapes on master slide and get text but not text that generate office automatic, I need just text that is put on presentation by her creator. This is test:
public void test() {
PresentationEx presentation = new PresentationEx(
“/home/emisia/Desktop/master-slide-test.pptx”);
MasterSlideEx slide;
ShapesEx shps;
for (int index = 0; index < presentation.getMasters().getCount(); index++) {
// Accessing Slides
slide = presentation.getMasters().get_Item(index);
// Accessing all shapes in slide
shps = slide.getShapes();
ShapeEx shape;
// Traversing through all shapes
for (int shpCount = 0; shpCount < shps.getCount(); shpCount++) {
shape = shps.get_Item(shpCount);
if (shape.getPlaceholder() != null) {
if (!(shape instanceof PictureFrameEx)) {
// Getting AutoShape from group shapes set
AutoShapeEx aShape = (AutoShapeEx) shape;
if (aShape.getTextFrame() != null) {
// Accessing the text frame of shape
TextFrameEx tfText = aShape.getTextFrame();
System.out.println(tfText.getText());
}// End Text Frame IF
}// End AutoShape Check
} else if (shape instanceof AutoShapeEx) {
// Getting AutoShape from group shapes set
AutoShapeEx aShp = (AutoShapeEx) shape;
if (aShp.getTextFrame() != null) {
// Accessing the text frame of shape
TextFrameEx tfText = aShp.getTextFrame();
System.out.println(tfText.getText());
}// End Text Frame IF
}// End AutoShape Check
// If shape is a group shape
else if (shape instanceof GroupShapeEx) {
// Type casting shape to group shape
GroupShapeEx gShape = (GroupShapeEx) shape;
// Traversing through all shapes in group shape
for (int iCount = 0; iCount < gShape.getShapes().getCount(); iCount++) {
if (gShape.getShapes().get_Item(iCount) instanceof AutoShapeEx) {
// Getting AutoShape from group shapes set
AutoShapeEx aShp = (AutoShapeEx) gShape.getShapes()
.get_Item(iCount);
if (aShp.getTextFrame() != null) {
TextFrameEx tfText = aShp.getTextFrame();
System.out.println(tfText.getText());
}// End Text Frame IF
}
}
}
// If shape is instance of Table
else if (shape instanceof TableEx) {
TableEx tTable = (TableEx) shape;
for (int iCol = 0; iCol < tTable.getColumns().size()-1; iCol++) {
for (int iRow = 0; iRow < tTable.getRows().size()-1; iRow++) {
TextFrameEx tfText = tTable.get_Item(iCol, iRow)
.getTextFrame();
if (tfText != null)
System.out.println(tfText.getText());
}// End Row Loop
}// End Col Loop
}// End Group Shape IF
}// End Shape Loop
}// End Slide Traversal
}
Thanks