ShapeCollection

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。

属性

名称类型访问描述
ShapeCollectionShapeCollection读取获取形状集合。
TableTable读取获取表。

方法

签名描述
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 和缓存中将单个形状重新排序到新位置。

另请参阅

 中文