Группа

Добавление группы фигур

Aspose.Slides поддерживает работу с группами фигур на слайдах. Эта функция помогает разработчикам создавать более насыщенные презентации. Aspose.Slides для C++ поддерживает добавление или доступ к группам фигур. Можно добавлять фигуры в добавленную группу фигур, чтобы заполнить ее, или получать доступ к любому свойству группы фигур. Чтобы добавить группу фигур на слайд с использованием Aspose.Slides для C++:

  1. Создайте экземпляр класса Presentation.
  2. Получите ссылку на слайд, используя его индекс.
  3. Добавьте группу фигур на слайд.
  4. Добавьте фигуры в добавленную группу фигур.
  5. Сохраните измененную презентацию в виде файла PPTX.

Пример ниже добавляет группу фигур на слайд.

For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-C
// The path to the documents directory.
const String outPath = u"../out/CreateGroupShape_out.pptx";
const String templatePath = u"../templates/Source Frame.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Accessing shapes collection for selected slide
SharedPtr<IShapeCollection> slideShapes = slide->get_Shapes();
// Adding a group shape to the slide
SharedPtr<IGroupShape> groupShape = slideShapes->AddGroupShape();
// Adding shapes inside added group shape
groupShape->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 300, 100, 100, 100);
groupShape->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 500, 100, 100, 100);
groupShape->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 300, 300, 100, 100);
groupShape->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 500, 300, 100, 100);
// Adding group shape frame
groupShape->set_Frame( MakeObject<ShapeFrame>(100, 300, 500, 40, NullableBool::False, NullableBool::False, 0));
//Write the PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);

Доступ к свойству AltText

Эта тема показывает простые шаги, сопровождаемые примерами кода, для добавления группы фигур и доступа к свойству AltText групп фигур на слайдах. Чтобы получить доступ к AltText группы фигур на слайде с использованием Aspose.Slides для C++:

  1. Создайте экземпляр класса Presentation, который представляет файл PPTX.
  2. Получите ссылку на слайд, используя его индекс.
  3. Доступ к коллекции фигур слайдов.
  4. Доступ к группе фигур.
  5. Доступ к свойству AltText.

Пример ниже получает альтернативный текст группы фигур.

For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-C
// The path to the documents directory.
//const String outPath = u"../out/EmbeddedVideoFrame_out.pptx";
const String templatePath = u"../templates/AltText.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
for (int i = 0; i < slide->get_Shapes()->get_Count(); i++)
{
// Accessing the shape collection of slides
System::SharedPtr<IShape> shape = slide->get_Shapes()->idx_get(i);
if (System::ObjectExt::Is<GroupShape>(shape))
{
// Accessing the group shape.
SharedPtr<GroupShape> grphShape = DynamicCast<Aspose::Slides::GroupShape>(shape);
for (int j = 0; j < grphShape->get_Shapes()->get_Count(); j++)
{
SharedPtr<IShape> shape2 = grphShape->get_Shapes()->idx_get(j);
String st = shape2->get_AlternativeText();
// Accessing the AltText property
System::Console::WriteLine(u"Shape Name : " + st);
}
}
}