Slide Section
With Aspose.Slides for C++, you can organize a PowerPoint Presentation into sections. You get to create sections that contain specific slides.
You may want to create sections and use them to organize or divide slides in a presentation into logical parts in these situations:
- When you are working on a large presentation with other people or a team—and you need to assign certain slides to a colleague or some team members.
- When you are dealing with a presentation that contains many slides—and you are struggling to manage or edit its contents at once.
Ideally, you should create a section that houses similar slides—the slides have something in common or they can exist in a group based on a rule—and give the section a name that describes the slides inside it.
Creating Sections in Presentations
To add a section that will house slides in a presentation, Aspose.Slides for C++ provides the AddSection method that allows you to specify the name of the section you intend to create and the slide from which the section starts.
This sample code shows you to create a section in a presentation in C++:
auto pres = System::MakeObject<Presentation>();
auto defaultSlide = pres->get_Slides()->idx_get(0);
auto newSlide1 = pres->get_Slides()->AddEmptySlide(pres->get_LayoutSlides()->idx_get(0));
auto newSlide2 = pres->get_Slides()->AddEmptySlide(pres->get_LayoutSlides()->idx_get(0));
auto newSlide3 = pres->get_Slides()->AddEmptySlide(pres->get_LayoutSlides()->idx_get(0));
auto newSlide4 = pres->get_Slides()->AddEmptySlide(pres->get_LayoutSlides()->idx_get(0));
auto section1 = pres->get_Sections()->AddSection(u"Section 1", newSlide1);
auto section2 = pres->get_Sections()->AddSection(u"Section 2", newSlide3);
// section1 will be ended at newSlide2 and after it section2 will start
pres->Save(u"pres-sections.pptx", SaveFormat::Pptx);
pres->get_Sections()->ReorderSectionWithSlides(section2, 0);
pres->Save(u"pres-sections-moved.pptx", SaveFormat::Pptx);
pres->get_Sections()->RemoveSectionWithSlides(section2);
pres->get_Sections()->AppendEmptySection(u"Last empty section");
pres->Save(u"pres-section-with-empty.pptx", SaveFormat::Pptx);
Changing the Names of Sections
After you create a section in a PowerPoint presentation, you may decide to change its name.
This sample code shows you how to change the name of a section in a presentation in C++ using Aspose.Slides:
auto pres = System::MakeObject<Presentation>(u"pres.pptx");
auto section = pres->get_Sections()->idx_get(0);
section->set_Name(u"My section");