ShapeCollection
概述
ShapeCollection 是 Aspose.Slides FOSS for C++ 中的一个类。
管理幻灯片上的形状集合。以两种模式运行: - 简单模式 (默认):仅在内存中管理形状。 - 基于XML的模式 (在 init_internal 之后):形状从幻灯片的 spTree XML 加载并持久化,采用惰性缓存。
该类在 C++ 程序中提供了 49 个用于操作 ShapeCollection 对象的方法。可用的方法包括:ShapeCollection、Table、add_auto_shape、add_auto_shape_impl、add_connector、add_connector_impl、add_picture_frame、add_picture_frame_impl、add_table、add_table_impl、as_i_collection、as_i_enumerable,以及另外 25 个方法。安装 Aspose.Slides FOSS for C++ 包后,所有公共成员对任何 C++ 应用程序均可访问。属性:ShapeCollection、Table。
属性
| 名称 | 类型 | 访问 | 描述 |
|---|---|---|---|
ShapeCollection | ShapeCollection | 读取 | 获取形状集合。 |
Table | Table | 读取 | 获取表。 |
方法
| 签名 | 描述 |
|---|---|
ShapeCollection() → ShapeCollection | 属性提供对集合本身的访问 |
Table() → Table | 属性提供对集合关联的 Table shape 的访问 |
Table() → Table | |
ShapeCollection() | |
ShapeCollection() | |
init_internal(slide_part: Internal::pptx::SlidePart, parent_slide: IBaseSlide) | 从幻灯片部件初始化,进入 XML 支持模式。 |
parent_group() → IGroupShape | 返回父组形状,如果是顶层则返回 nullptr。 |
as_i_collection() → IShapeCollection | 将此集合返回为通用集合接口。 |
as_i_enumerable() → IShapeCollection | 将此集合返回为通用可枚举接口。 |
size() → std::size_t | 返回形状的数量。 |
to_array() → std::vector<Shape*> | 返回所有形状的非拥有指针。 |
to_array(start_index: std::size_t, count: std::size_t) → std::vector<Shape*> | 返回所有形状的非拥有指针。 |
reorder(new_index: std::size_t, shape: Shape) | 将形状移动到指定位置(z 顺序)。 |
reorder(index: std::size_t, shapes: std::span<Shape*>) | 将形状移动到指定位置(z-order)。 |
add_auto_shape(type: ShapeType, x: double, y: double, width: double, height: double) → AutoShape | 向集合中添加一个 AutoShape。 |
add_auto_shape(type: ShapeType, x: double, y: double, width: double, height: double, create_from_template: bool) → AutoShape | 向集合中添加一个 AutoShape。 |
insert_auto_shape(index: std::size_t, type: ShapeType, x: double, y: double, width: double, height: double) → AutoShape | 在指定索引处插入一个 AutoShape。 |
insert_auto_shape(index: std::size_t, type: ShapeType, x: double, y: double, width: double, height: double, create_from_template: bool) → AutoShape | 在指定索引处插入一个AutoShape。 |
add_connector(type: ShapeType, x: double, y: double, width: double, height: double) → Connector | 向集合中添加一个 Connector。 |
add_connector(type: ShapeType, x: double, y: double, width: double, height: double, create_from_template: bool) → Connector | 向集合中添加一个 Connector。 |
insert_connector(index: std::size_t, type: ShapeType, x: double, y: double, width: double, height: double) → Connector | 在指定索引处插入一个 Connector。 |
insert_connector(index: std::size_t, type: ShapeType, x: double, y: double, width: double, height: double, create_from_template: bool) → Connector | 在指定索引处插入一个连接器。 |
index_of(shape: Shape) → std::ptrdiff_t | 返回形状的零基索引,如果未找到则返回 -1。 |
add_picture_frame(type: ShapeType, x: double, y: double, width: double, height: double, image: PPImage) → PictureFrame | 向集合中添加一个 PictureFrame。 |
insert_picture_frame(index: std::size_t, type: ShapeType, x: double, y: double, width: double, height: double, image: PPImage) → PictureFrame | 在指定索引处插入一个 PictureFrame。 |
add_table(x: double, y: double, column_widths: std::span<const double>, row_heights: std::span<const double>) → Table | 向集合中添加一个 Table。 |
insert_table(index: std::size_t, x: double, y: double, column_widths: std::span<const double>, row_heights: std::span<const double>) → Table | 在指定索引处插入一个表格。 |
remove(shape: Shape) | 通过引用从集合中移除形状。 |
remove_at(index: std::size_t) | 在给定索引处移除形状。 |
clear() | 移除所有形状。 |
table_count() → std::size_t | 返回集合中表的数量。 |
table_at(index: std::size_t) → Table | 返回给定索引处的表。 |
table_at(index: std::size_t) → Table | 返回给定索引处的表。 |
begin() → iterator | 返回指向第一个形状的迭代器 |
end() → iterator | 返回指向最后一个形状之后的迭代器 |
begin() → const_iterator | |
end() → const_iterator | |
get_sp_tree() → pugi::xml_node | 从幻灯片 XML 获取 spTree 元素。 |
load_shapes() | 从 XML 加载所有形状,填充内部缓存。如果缓存已有效,则不执行任何操作。 |
invalidate_cache() | 使形状缓存失效,在下次访问时强制重新加载。 |
save_to_part() | 将更改保存到幻灯片部分。 |
next_shape_id() → int | 在 spTree 中查找下一个可用的形状 ID。 |
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) | 为新的 AutoShape 元素构建 XML 内容。 |
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) | 为新的连接器 (cxnSp) 元素构建 XML 内容。 |
add_auto_shape_impl(index: std::optional<std::size_t>, type: ShapeType, x: double, y: double, w: double, h: double, create_from_template: bool) → AutoShape | 针对 add_auto_shape 和 insert_auto_shape 的核心实现。 |
add_connector_impl(index: std::optional<std::size_t>, type: ShapeType, x: double, y: double, w: double, h: double, create_from_template: bool) → Connector | 针对 add_connector 和 insert_connector 的核心实现。 |
add_picture_frame_impl(index: std::optional<std::size_t>, type: ShapeType, x: double, y: double, w: double, h: double, image: PPImage) → PictureFrame | 针对 add_picture_frame 和 insert_picture_frame 的核心实现。 |
add_table_impl(index: std::optional<std::size_t>, x: double, y: double, column_widths: std::span<const double>, row_heights: std::span<const double>) → Table | 核心实现用于 add_table 和 insert_table。 |
reorder_single(new_index: std::size_t, shape: Shape) | 在 XML 和缓存中将单个形状重新排序到新位置。 |