ShapeCollection

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

Properties ShapeCollection คลาสเก็บรูปทรงทั้งหมดบนสไลด์ เข้าถึงได้ผ่าน Slide::shapes().

Properties: Aspose::Slides::Foss

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

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


Properties

PropertiesProperties
size()จำนวนรูปทรงในคอลเลกชัน.
operator[](size_t index)เข้าถึงรูปทรงโดยใช้ดัชนีเริ่มจากศูนย์.
to_array()คืนค่ารูปทรงทั้งหมดเป็นอาร์เรย์.
to_array(int start, int count)คืนค่าช่วงย่อยของรูปทรง.
reorder(int old_index, int new_index)ย้ายรูปทรงไปยังตำแหน่ง z-order ใหม่.
index_of(const IShape& shape)คืนค่าดัชนีเริ่มจากศูนย์ของรูปทรง.
remove(IShape& shape)ลบรูปทรงออกจากคอลเลกชัน.
remove_at(int index)ลบรูปทรงที่ตำแหน่งดัชนีที่กำหนด.
clear()ลบรูปทรงทั้งหมด.
begin() / end()การสนับสนุน iterator สำหรับ range-based 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);

ดูเพิ่มเติม

 ภาษาไทย