ShapeCollection — Aspose.Slides FOSS for C++ API Reference

The ShapeCollection class holds all shapes on a slide. Accessed via Slide::shapes().

Namespace: Aspose::Slides::Foss

#include <Aspose/Slides/Foss/shape_collection.h>
class ShapeCollection

Header: include/Aspose/Slides/Foss/shape_collection.h


Methods

MethodDescription
size()Number of shapes in the collection.
operator[](size_t index)Access shape by zero-based index.
to_array()Returns all shapes as an array.
to_array(int start, int count)Returns a sub-range of shapes.
reorder(int old_index, int new_index)Move a shape to a new z-order position.
index_of(const IShape& shape)Returns zero-based index of a shape.
remove(IShape& shape)Remove a shape from the collection.
remove_at(int index)Remove the shape at the given index.
clear()Remove all shapes.
begin() / end()Iterator support for range-based for loops.

Usage Examples

Iterate Over Shapes

#include <Aspose/Slides/Foss/presentation.h>
using namespace Aspose::Slides::Foss;

Presentation prs("deck.pptx");
auto& shapes = prs.slides()[0].shapes();
for (size_t i = 0; i < shapes.size(); ++i) {
    auto& shape = shapes[i];
    std::cout << "Shape at (" << shape.x() << ", " << shape.y() << ")" << std::endl;
}

Remove All Shapes

prs.slides()[0].shapes().clear();
prs.save("empty.pptx", SaveFormat::Pptx);

See Also