ForEach

Inheritance: java.lang.Object

public class ForEach

Represents a group of methods intended to iterate over different Presentation model objects. These methods can be useful if you need to iterate and change some Presentation’ elements formatting or content, e.g. change each portion formatting.


Presentation pres = new Presentation("pres.pptx");
 try {
     ForEach.portion(pres, (portion, para, slide, index) ->
         portion.getPortionFormat().setLatinFont(new FontData("Times New Roman")));

     pres.save("pres-out.pptx", SaveFormat.Pptx);
 } finally {
     if (pres != null) pres.dispose();
 }

Constructors

Constructor Description
ForEach()

Methods

Method Description
slide(Presentation pres, ForEach.ForEachSlideCallback forEachSlide) Iterate each #slide(Presentation,ForEachSlideCallback).slide(Presentation,ForEachSlideCallback) in the Presentation.
masterSlide(Presentation pres, ForEach.ForEachMasterSlideCallback forEachMasterSlide) Iterate each #masterSlide(Presentation,ForEachMasterSlideCallback).masterSlide(Presentation,ForEachMasterSlideCallback) in the Presentation.
layoutSlide(Presentation pres, ForEach.ForEachLayoutSlideCallback forEachLayoutSlide) Iterate each #layoutSlide(Presentation,ForEachLayoutSlideCallback).layoutSlide(Presentation,ForEachLayoutSlideCallback) in the Presentation.
shape(Presentation pres, ForEach.ForEachShapeCallback forEachShape) Iterate each Shape in the Presentation.
shape(BaseSlide baseSlide, ForEach.ForEachShapeCallback forEachShape) Iterate each Shape in the BaseSlide.
paragraph(Presentation pres, ForEach.ForEachParagraphCallback forEachParagraph) Iterate each #paragraph(Presentation,ForEachParagraphCallback).paragraph(Presentation,ForEachParagraphCallback) in the Presentation.
portion(Presentation pres, ForEach.ForEachPortionCallback forEachPortion) Iterate each #portion(Presentation,ForEachPortionCallback).portion(Presentation,ForEachPortionCallback) in the Presentation.

ForEach()

public ForEach()

slide(Presentation pres, ForEach.ForEachSlideCallback forEachSlide)

public static void slide(Presentation pres, ForEach.ForEachSlideCallback forEachSlide)

Iterate each #slide(Presentation,ForEachSlideCallback).slide(Presentation,ForEachSlideCallback) in the Presentation.


Presentation pres = new Presentation("pres.pptx");
 try {
     ForEach.slide(pres, (slide, index) ->
         slide.setName(String.format("Slide #%d", index)));
 } finally {
     if (pres != null) pres.dispose();
 }

Parameters:

Parameter Type Description
pres Presentation Presentation to iterate slides
forEachSlide ForEachSlideCallback Callback that will be invoked for each slide

masterSlide(Presentation pres, ForEach.ForEachMasterSlideCallback forEachMasterSlide)

public static void masterSlide(Presentation pres, ForEach.ForEachMasterSlideCallback forEachMasterSlide)

Iterate each #masterSlide(Presentation,ForEachMasterSlideCallback).masterSlide(Presentation,ForEachMasterSlideCallback) in the Presentation.


Presentation pres = new Presentation("pres.pptx");
 try {
     ForEach.masterSlide(pres, (slide, index) ->
         slide.setName(String.format("Master Slide #%d", index)));
 } finally {
     if (pres != null) pres.dispose();
 }

Parameters:

Parameter Type Description
pres Presentation Presentation to iterate master slides
forEachMasterSlide ForEachMasterSlideCallback Callback that will be invoked for each master slide

layoutSlide(Presentation pres, ForEach.ForEachLayoutSlideCallback forEachLayoutSlide)

public static void layoutSlide(Presentation pres, ForEach.ForEachLayoutSlideCallback forEachLayoutSlide)

Iterate each #layoutSlide(Presentation,ForEachLayoutSlideCallback).layoutSlide(Presentation,ForEachLayoutSlideCallback) in the Presentation.


Presentation pres = new Presentation("pres.pptx");
 try {
     ForEach.layoutSlide(pres, (layoutSlide, index) ->
         layoutSlide.setName(String.format("Layout Slide #%d", index)));
 } finally {
     if (pres != null) pres.dispose();
 }

Parameters:

Parameter Type Description
pres Presentation Presentation to iterate layout slides
forEachLayoutSlide ForEachLayoutSlideCallback Callback that will be invoked for each layout slide

shape(Presentation pres, ForEach.ForEachShapeCallback forEachShape)

public static void shape(Presentation pres, ForEach.ForEachShapeCallback forEachShape)

Iterate each Shape in the Presentation.


Presentation pres = new Presentation("pres.pptx");
 try {
     ForEach.shape(pres, (shape, slide, index) ->
         System.out.println(String.format("%s, index: %d", shape.getName(), index)));
 } finally {
     if (pres != null) pres.dispose();
 }

Parameters:

Parameter Type Description
pres Presentation Presentation to iterate layout shapes
forEachShape ForEachShapeCallback Callback that will be invoked for each shape

Shapes will be iterated in all type of slides - #slide(Presentation,ForEachSlideCallback).slide(Presentation,ForEachSlideCallback), #masterSlide(Presentation,ForEachMasterSlideCallback).masterSlide(Presentation,ForEachMasterSlideCallback) and #layoutSlide(Presentation,ForEachLayoutSlideCallback).layoutSlide(Presentation,ForEachLayoutSlideCallback) |

shape(BaseSlide baseSlide, ForEach.ForEachShapeCallback forEachShape)

public static void shape(BaseSlide baseSlide, ForEach.ForEachShapeCallback forEachShape)

Iterate each Shape in the BaseSlide.


Presentation pres = new Presentation("pres.pptx");
 try {
     ForEach.slide(pres, (slide, index) ->
         ForEach.shape(slide, (shape, baseSlide, shapeIndex) ->
                 System.out.println(String.format("%s, index: %d", shape.getName(), shapeIndex))));
 } finally {
     if (pres != null) pres.dispose();
 }

Parameters:

Parameter Type Description
baseSlide BaseSlide Slide to iterate layout shapes
forEachShape ForEachShapeCallback Callback that will be invoked for each shape

BaseSlide is the base type for #slide(Presentation,ForEachSlideCallback).slide(Presentation,ForEachSlideCallback), #masterSlide(Presentation,ForEachMasterSlideCallback).masterSlide(Presentation,ForEachMasterSlideCallback) and #layoutSlide(Presentation,ForEachLayoutSlideCallback).layoutSlide(Presentation,ForEachLayoutSlideCallback) |

paragraph(Presentation pres, ForEach.ForEachParagraphCallback forEachParagraph)

public static void paragraph(Presentation pres, ForEach.ForEachParagraphCallback forEachParagraph)

Iterate each #paragraph(Presentation,ForEachParagraphCallback).paragraph(Presentation,ForEachParagraphCallback) in the Presentation.


Presentation pres = new Presentation("pres.pptx");
 try {
     ForEach.paragraph(pres, (para, slide, index) ->
         System.out.println(String.format("%s, index: %d", para.getText(), index)));
 } finally {
     if (pres != null) pres.dispose();
 }

Parameters:

Parameter Type Description
pres Presentation Presentation to iterate paragraphs
forEachParagraph ForEachParagraphCallback Callback that will be invoked for each paragraph

Shapes will be iterated in all type of slides - #slide(Presentation,ForEachSlideCallback).slide(Presentation,ForEachSlideCallback), #masterSlide(Presentation,ForEachMasterSlideCallback).masterSlide(Presentation,ForEachMasterSlideCallback) and #layoutSlide(Presentation,ForEachLayoutSlideCallback).layoutSlide(Presentation,ForEachLayoutSlideCallback) |

portion(Presentation pres, ForEach.ForEachPortionCallback forEachPortion)

public static void portion(Presentation pres, ForEach.ForEachPortionCallback forEachPortion)

Iterate each #portion(Presentation,ForEachPortionCallback).portion(Presentation,ForEachPortionCallback) in the Presentation.


Presentation pres = new Presentation("pres.pptx");
 try {
     ForEach.portion(pres, (portion, para, slide, index) ->
         System.out.println(String.format("%s, index: %d", portion.getText(), index)));
 } finally {
     if (pres != null) pres.dispose();
 }

Parameters:

Parameter Type Description
pres Presentation Presentation to iterate portions
forEachPortion ForEachPortionCallback Callback that will be invoked for each portion

Portions will be iterated in all type of slides - #slide(Presentation,ForEachSlideCallback).slide(Presentation,ForEachSlideCallback), #masterSlide(Presentation,ForEachMasterSlideCallback).masterSlide(Presentation,ForEachMasterSlideCallback) and #layoutSlide(Presentation,ForEachLayoutSlideCallback).layoutSlide(Presentation,ForEachLayoutSlideCallback) |