SmartArt
Contents
[
Hide
]
This article demonstrates how to add SmartArt graphics, access them, remove them, and change layouts using Aspose.Slides for C++.
Add SmartArt
Insert a SmartArt graphic using one of the built-in layouts.
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/Presentation.h>
#include <DOM/SmartArt/ISmartArt.h>
#include <DOM/SmartArt/SmartArtLayoutType.h>
#include <system/smart_ptr.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::SmartArt;
using namespace System;
static void AddSmartArt()
{
auto presentation = MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto smartArt = slide->get_Shapes()->AddSmartArt(50.0f, 50.0f, 400.0f, 300.0f, SmartArtLayoutType::BasicProcess);
presentation->Dispose();
}
Access SmartArt
Retrieve the first SmartArt object on a slide.
#include <DOM/IShape.h>
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/Presentation.h>
#include <DOM/SmartArt/ISmartArt.h>
#include <DOM/SmartArt/SmartArtLayoutType.h>
#include <system/object_ext.h>
#include <system/smart_ptr.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::SmartArt;
using namespace System;
static void AccessSmartArt()
{
auto presentation = MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto smartArt = slide->get_Shapes()->AddSmartArt(50.0f, 50.0f, 400.0f, 300.0f, SmartArtLayoutType::BasicProcess);
auto firstSmartArt = SharedPtr<ISmartArt>();
for (auto&& shape : slide->get_Shapes())
{
if (ObjectExt::Is<ISmartArt>(shape))
{
firstSmartArt = ExplicitCast<ISmartArt>(shape);
break;
}
}
presentation->Dispose();
}
Remove SmartArt
Delete a SmartArt shape from the slide.
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/Presentation.h>
#include <DOM/SmartArt/ISmartArt.h>
#include <DOM/SmartArt/SmartArtLayoutType.h>
#include <system/smart_ptr.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::SmartArt;
using namespace System;
static void RemoveSmartArt()
{
auto presentation = MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto smartArt = slide->get_Shapes()->AddSmartArt(50.0f, 50.0f, 400.0f, 300.0f, SmartArtLayoutType::BasicProcess);
slide->get_Shapes()->Remove(smartArt);
presentation->Dispose();
}
Change SmartArt Layout
Update the layout type of an existing SmartArt graphic.
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/Presentation.h>
#include <DOM/SmartArt/ISmartArt.h>
#include <DOM/SmartArt/SmartArtLayoutType.h>
#include <system/smart_ptr.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::SmartArt;
using namespace System;
static void ChangeSmartArtLayout()
{
auto presentation = MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto smartArt = slide->get_Shapes()->AddSmartArt(50.0f, 50.0f, 400.0f, 300.0f, SmartArtLayoutType::BasicBlockList);
smartArt->set_Layout(SmartArtLayoutType::VerticalPictureList);
presentation->Dispose();
}