Group
Add Group Shape
Aspose.Slides support working with group shapes on slides. This feature helps developers support richer presentations. Aspose.Slides for C++ supports adding or accessing group shapes. It is possible to add shapes to an added group shape to populate it or access any property of group shape. To add a group shape to a slide using Aspose.Slides for C++:
- Create an instance of the Presentation class.
- Obtain the reference of a slide by using its Index
- Add a group shape to the slide.
- Add the shapes to the added group shape.
- Save the modified presentation as a PPTX file.
The example below adds a group shape to a slide.
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); | |
Access AltText Property
This topic shows simple steps, complete with code examples, for adding a group shape and accessing AltText property of group shapes on slides. To access AltText of a group shape in a slide using Aspose.Slides for C++:
- Instantiate
Presentation
class that represents a PPTX file. - Obtain the reference of a slide by using its Index.
- Accessing the shape collection of slides.
- Accessing the group shape.
- Accessing the AltText property.
The example below accesses the alternative text of group shape.
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); | |
} | |
} | |
} |