You can find detailed information at: Create SmartArt in PowerPoint Presentations using C++
Last active
October 5, 2021 17:20
-
-
Save aspose-com-gists/0306bb6e0ef50710e2a4afb0e7261b10 to your computer and use it in GitHub Desktop.
Create SmartArt in PowerPoint Presentations using C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// File path | |
const String sourceFilePath = u"OutputDirectory\\CreateSmartArt_out.pptx"; | |
// Load the Presentation file | |
SharedPtr<Presentation> presentation = MakeObject<Presentation>(sourceFilePath); | |
// Loop through the shapes | |
for (auto shape : presentation->get_Slides()->idx_get(0)->get_Shapes()) | |
{ | |
// Check if shape is of SmartArt type | |
if (System::ObjectExt::Is<Aspose::Slides::SmartArt::SmartArt>(shape)) | |
{ | |
// Typecast shape to SmartArt | |
auto smartArt = System::DynamicCast_noexcept<ISmartArt>(shape); | |
Console::WriteLine(String::Format(u"Shape Name: {0}", smartArt->get_Name())); | |
// Checking SmartArt Layout | |
/*if (smartArt->get_Layout() == SmartArtLayoutType::BasicBlockList) | |
{ | |
Console::WriteLine(u"Do some thing here...."); | |
}*/ | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// File paths | |
const String sourceFilePath = u"OutputDirectory\\CreateSmartArt_out.pptx"; | |
const String outputFilePath = u"OutputDirectory\\ChangeSmartArt_out.pptx"; | |
// Load the Presentation file | |
SharedPtr<Presentation> presentation = MakeObject<Presentation>(sourceFilePath); | |
// Loop through the shapes | |
for (auto shape : presentation->get_Slides()->idx_get(0)->get_Shapes()) | |
{ | |
// Check if shape is of SmartArt type | |
if (System::ObjectExt::Is<Aspose::Slides::SmartArt::SmartArt>(shape)) | |
{ | |
// Typecast shape to SmartArt | |
auto smartArt = System::DynamicCast_noexcept<ISmartArt>(shape); | |
// Check SmartArt style | |
if (smartArt->get_QuickStyle() == SmartArtQuickStyleType::SimpleFill) { | |
// Change SmartArt Style | |
smartArt->set_QuickStyle(SmartArtQuickStyleType::Cartoon); | |
} | |
// Check SmartArt color type | |
if (smartArt->get_ColorStyle() == SmartArtColorType::ColoredFillAccent1) { | |
// Change SmartArt color type | |
smartArt->set_ColorStyle(SmartArtColorType::ColorfulAccentColors); | |
} | |
} | |
} | |
// Save Presentation | |
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// File path | |
const String outputFilePath = u"OutputDirectory\\CreateSmartArt_out.pptx"; | |
// Load the Presentation file | |
SharedPtr<Presentation> presentation = MakeObject<Presentation>(); | |
// Retrieve the first slide | |
SharedPtr<ISlide> slide = presentation->get_Slides()->idx_get(0); | |
// Add SmartArt | |
auto smartArt = slide->get_Shapes()->AddSmartArt(0, 0, 400, 400, Aspose::Slides::SmartArt::SmartArtLayoutType::BasicBlockList); | |
smartArt->get_AllNodes()->idx_get(0)->get_TextFrame()->set_Text(u"First Block"); | |
smartArt->get_AllNodes()->idx_get(1)->get_TextFrame()->set_Text(u"Second Block"); | |
// Save Presentation | |
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment