public class ForEach
extends java.lang.Object
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(); }
Modifier and Type | Class and Description |
---|---|
static interface |
ForEach.ForEachLayoutSlideCallback |
static interface |
ForEach.ForEachMasterSlideCallback |
static interface |
ForEach.ForEachParagraphCallback |
static interface |
ForEach.ForEachPortionCallback |
static interface |
ForEach.ForEachShapeCallback |
static interface |
ForEach.ForEachSlideCallback |
Constructor and Description |
---|
ForEach() |
public static void slide(Presentation pres, ForEach.ForEachSlideCallback forEachSlide)
Iterate each 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(); }
pres
- Presentation to iterate slidesforEachSlide
- Callback that will be invoked for each slidepublic static void masterSlide(Presentation pres, ForEach.ForEachMasterSlideCallback forEachMasterSlide)
Iterate each 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(); }
pres
- Presentation to iterate master slidesforEachMasterSlide
- Callback that will be invoked for each master slidepublic static void layoutSlide(Presentation pres, ForEach.ForEachLayoutSlideCallback forEachLayoutSlide)
Iterate each 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(); }
pres
- Presentation to iterate layout slidesforEachLayoutSlide
- Callback that will be invoked for each layout slidepublic 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(); }
pres
- Presentation to iterate layout shapesforEachShape
- Callback that will be invoked for each shape
slide(Presentation,ForEachSlideCallback)
, masterSlide(Presentation,ForEachMasterSlideCallback)
and layoutSlide(Presentation,ForEachLayoutSlideCallback)
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(); }
baseSlide
- Slide to iterate layout shapesforEachShape
- Callback that will be invoked for each shape
BaseSlide
is the base type for slide(Presentation,ForEachSlideCallback)
, masterSlide(Presentation,ForEachMasterSlideCallback)
and layoutSlide(Presentation,ForEachLayoutSlideCallback)
public static void paragraph(Presentation pres, ForEach.ForEachParagraphCallback forEachParagraph)
Iterate each 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(); }
pres
- Presentation to iterate paragraphsforEachParagraph
- Callback that will be invoked for each paragraph
slide(Presentation,ForEachSlideCallback)
, masterSlide(Presentation,ForEachMasterSlideCallback)
and layoutSlide(Presentation,ForEachLayoutSlideCallback)
public static void portion(Presentation pres, ForEach.ForEachPortionCallback forEachPortion)
Iterate each 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(); }
pres
- Presentation to iterate portionsforEachPortion
- Callback that will be invoked for each portion
slide(Presentation,ForEachSlideCallback)
, masterSlide(Presentation,ForEachMasterSlideCallback)
and layoutSlide(Presentation,ForEachLayoutSlideCallback)