ShapeCollection — Aspose.Slides FOSS for C++ API Reference
Properties ShapeCollection 类保存幻灯片上的所有形状。通过 Slide::shapes().
Properties: Aspose::Slides::Foss
#include <Aspose/Slides/Foss/shape_collection.h>class ShapeCollectionProperties: include/Aspose/Slides/Foss/shape_collection.h
Properties
| Properties | Properties |
|---|---|
size() | 集合中形状的数量。. |
operator[](size_t index) | 通过从零开始的索引访问形状。. |
to_array() | 以数组形式返回所有形状。. |
to_array(int start, int count) | 返回形状的子范围。. |
reorder(int old_index, int new_index) | 将形状移动到新的 Z 顺序位置。. |
index_of(const IShape& shape) | 返回形状的从零开始的索引。. |
remove(IShape& shape) | 从集合中移除形状。. |
remove_at(int index) | 移除给定索引处的形状。. |
clear() | 移除所有形状。. |
begin() / end() | 对基于范围的迭代器支持 for 循环。. |
使用示例
遍历形状
#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;
}删除所有形状
prs.slides()[0].shapes().clear();
prs.save("empty.pptx", SaveFormat::PPTX);