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

ConstructorDescription
ForEach()

Methods

MethodDescription
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(Presentation pres, boolean includeNotes, 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 in the Presentation.
paragraph(Presentation pres, boolean includeNotes, ForEach.ForEachParagraphCallback forEachParagraph)Iterate each Paragraph in the Presentation.
portion(Presentation pres, ForEach.ForEachPortionCallback forEachPortion)Iterate each Portion in the Presentation.
portion(Presentation pres, boolean includeNotes, ForEach.ForEachPortionCallback forEachPortion)Iterate each Portion 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:

ParameterTypeDescription
presPresentationPresentation to iterate slides
forEachSlideForEachSlideCallbackCallback 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:

ParameterTypeDescription
presPresentationPresentation to iterate master slides
forEachMasterSlideForEachMasterSlideCallbackCallback 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:

ParameterTypeDescription
presPresentationPresentation to iterate layout slides
forEachLayoutSlideForEachLayoutSlideCallbackCallback 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:

ParameterTypeDescription
presPresentationPresentation to iterate layout shapes
forEachShapeForEachShapeCallbackCallback 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(Presentation pres, boolean includeNotes, ForEach.ForEachShapeCallback forEachShape)

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

Iterate each Shape in the Presentation.


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

Parameters:

ParameterTypeDescription
presPresentationPresentation to iterate layout shapes
includeNotesbooleanFlag that indicates whether NotesSlides should be included in processing.
forEachShapeForEachShapeCallbackCallback 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), #layoutSlide(Presentation,ForEachLayoutSlideCallback).layoutSlide(Presentation,ForEachLayoutSlideCallback) and NotesSlide if needed. |

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:

ParameterTypeDescription
baseSlideBaseSlideSlide to iterate layout shapes
forEachShapeForEachShapeCallbackCallback 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 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:

ParameterTypeDescription
presPresentationPresentation to iterate paragraphs
forEachParagraphForEachParagraphCallbackCallback 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) |

paragraph(Presentation pres, boolean includeNotes, ForEach.ForEachParagraphCallback forEachParagraph)

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

Iterate each Paragraph in the Presentation.


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

Parameters:

ParameterTypeDescription
presPresentationPresentation to iterate paragraphs
includeNotesbooleanFlag that indicates whether NotesSlides should be included in processing.
forEachParagraphForEachParagraphCallbackCallback 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), #layoutSlide(Presentation,ForEachLayoutSlideCallback).layoutSlide(Presentation,ForEachLayoutSlideCallback) and NotesSlide |

portion(Presentation pres, ForEach.ForEachPortionCallback forEachPortion)

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

Iterate each Portion 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:

ParameterTypeDescription
presPresentationPresentation to iterate portions
forEachPortionForEachPortionCallbackCallback 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) |

portion(Presentation pres, boolean includeNotes, ForEach.ForEachPortionCallback forEachPortion)

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

Iterate each Portion in the Presentation.


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

Parameters:

ParameterTypeDescription
presPresentationPresentation to iterate portions
includeNotesbooleanFlag that indicates whether NotesSlides should be included in processing.
forEachPortionForEachPortionCallbackCallback 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), #layoutSlide(Presentation,ForEachLayoutSlideCallback).layoutSlide(Presentation,ForEachLayoutSlideCallback) and NotesSlide |