Gruppe

Gruppenform hinzufügen

Aspose.Slides unterstützt die Arbeit mit Gruppenformen auf Folien. Diese Funktion hilft Entwicklern, reichhaltigere Präsentationen zu unterstützen. Aspose.Slides für C++ unterstützt das Hinzufügen oder Zugreifen auf Gruppenformen. Es ist möglich, Formen zu einer hinzugefügten Gruppenform hinzuzufügen, um sie zu bevölkern, oder auf eine beliebige Eigenschaft der Gruppenform zuzugreifen. Um eine Gruppenform zu einer Folie mit Aspose.Slides für C++ hinzuzufügen:

  1. Erstellen Sie eine Instanz der Presentation Klasse.
  2. Erhalten Sie die Referenz einer Folie, indem Sie ihren Index verwenden.
  3. Fügen Sie der Folie eine Gruppenform hinzu.
  4. Fügen Sie die Formen zur hinzugefügten Gruppenform hinzu.
  5. Speichern Sie die modifizierte Präsentation als PPTX-Datei.

Das folgende Beispiel fügt einer Folie eine Gruppenform hinzu.

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);

Auf Eigenschaft AltText zugreifen

Dieses Thema zeigt einfache Schritte, komplett mit Codebeispielen, zum Hinzufügen einer Gruppenform und zum Zugreifen auf die AltText-Eigenschaft von Gruppenformen auf Folien. Um auf den AltText einer Gruppenform in einer Folie mit Aspose.Slides für C++ zuzugreifen:

  1. Instanziieren Sie die Presentation Klasse, die eine PPTX-Datei darstellt.
  2. Erhalten Sie die Referenz einer Folie, indem Sie ihren Index verwenden.
  3. Zugriff auf die Formsammlung der Folien.
  4. Zugriff auf die Gruppenform.
  5. Zugriff auf die AltText-Eigenschaft.

Das folgende Beispiel greift auf den alternativen Text der Gruppenform zu.

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);
}
}
}