ShapeCollection

ShapeCollection

Overview

ShapeCollection is a class in Aspose.Slides FOSS for C++.

Manages the collection of shapes on a slide. Operates in two modes: - Simple mode (default): shapes are managed in-memory only. - XML-backed mode (after init_internal): shapes are loaded from and persisted to the slide’s spTree XML, with lazy caching.

Properties

NameTypeAccessDescription
ShapeCollectionShapeCollectionReadProperty gives access to the collection itself
TableTableReadProperty provides access to the Table shape associated with the collection

Methods

SignatureDescription
ShapeCollection()ShapeCollectionProperty gives access to the collection itself
Table()TableProperty provides access to the Table shape associated with the collection
Table()Table
init_internal(slide_part: Internal::pptx::SlidePart, parent_slide: IBaseSlide)Initialize from a slide part, entering XML-backed mode.
size()std::size_tReturns the number of shapes.
to_array()std::vector<Shape*>Returns all shapes as non-owning pointers.
to_array(start_index: std::size_t, count: std::size_t)std::vector<Shape*>Returns all shapes as non-owning pointers.
reorder(new_index: std::size_t, shape: Shape)Moves a shape to the specified position (z-order).
reorder(index: std::size_t, shapes: std::span<Shape*>)Moves a shape to the specified position (z-order).
index_of(shape: Shape)std::ptrdiff_tReturns the zero-based index of a shape, or -1 if not found.
remove(shape: Shape)Removes a shape from the collection by reference.
remove_at(index: std::size_t)Removes the shape at the given index.
clear()Removes all shapes.
begin()iteratorReturns an iterator to the first shape
end()iteratorReturns an iterator past the last shape
begin()const_iterator
end()const_iterator
get_sp_tree()pugi::xml_nodeGet the spTree element from the slide XML.
load_shapes()Load all shapes from the XML, populating the internal cache. No-op if the cache is already valid.
invalidate_cache()Invalidate the shapes cache, forcing a reload on next access.
save_to_part()Save changes to the slide part.
next_shape_id()intFind the next available shape ID in the spTree.
build_auto_shape_xml(sp: pugi::xml_node, shape_id: int, name: std::string_view, type: ShapeType, x: double, y: double, w: double, h: double, create_from_template: bool)Build XML content for a new AutoShape element.
build_connector_xml(cxn_sp: pugi::xml_node, shape_id: int, name: std::string_view, type: ShapeType, x: double, y: double, w: double, h: double, create_from_template: bool)Build XML content for a new connector (cxnSp) element.
reorder_single(new_index: std::size_t, shape: Shape)Reorder a single shape to a new position in XML and cache.

See Also