SmartArt verwalten

Text aus SmartArt abrufen

Jetzt wurde die TextFrame-Eigenschaft zum ISmartArtShape-Interface und zur SmartArtShape-Klasse hinzugefügt. Diese Eigenschaft ermöglicht es Ihnen, gesamten Text aus SmartArt abzurufen, wenn sie nicht nur Knotentext hat. Der folgende Beispielcode hilft Ihnen, Text aus einem SmartArt-Knoten abzurufen.

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 templatePath = u"../templates/SmartArt.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Traverse through every shape inside first slide
//foreach(IShape shape in pres.Slides[0].Shapes)
for (int x = 0; x<pres->get_Slides()->idx_get(0)->get_Shapes()->get_Count(); x++)
{
SharedPtr<IShape> shape = pres->get_Slides()->idx_get(0)->get_Shapes()->idx_get(x);
if (System::ObjectExt::Is<Aspose::Slides::SmartArt::SmartArt>(shape))
{
System::SharedPtr<Aspose::Slides::SmartArt::SmartArt> smart = System::DynamicCast_noexcept<Aspose::Slides::SmartArt::SmartArt>(shape);
// Traverse through all nodes inside SmartArt
for (int i = 0; i < smart->get_AllNodes()->get_Count(); i++)
{
// Accessing SmartArt node at index i
System::SharedPtr<Aspose::Slides::SmartArt::SmartArtNode> node = System::DynamicCast_noexcept<Aspose::Slides::SmartArt::SmartArtNode>(smart->get_AllNodes()->idx_get(i));
int iNodeShapeCount = node->get_Shapes()->get_Count();
for(int j=0; j < iNodeShapeCount;j++)
{
System::SharedPtr<Aspose::Slides::SmartArt::SmartArtShape> nodeShape=System::DynamicCast_noexcept<Aspose::Slides::SmartArt::SmartArtShape>(node->get_Shapes()->idx_get(j));
//auto nodeShape = System::DynamicCast_noexcept<Aspose::Slides::SmartArt::SmartArtShape>(node->get_Shapes()->idx_get(j));
if (nodeShape->get_TextFrame() != NULL)
{
// Printing the SmartArt nodeShape parameters
System::Console::WriteLine(u"NodeShape Text is: {0}", nodeShape->get_TextFrame()->get_Text());
}
}
}
}
}

Layouttyp von SmartArt ändern

Um den Layouttyp von SmartArt zu ändern, befolgen Sie bitte die folgenden Schritte:

  • Erstellen Sie eine Instanz der Presentation Klasse.
  • Erhalten Sie die Referenz zu einer Folie, indem Sie ihren Index verwenden.
  • Fügen Sie SmartArt BasicBlockList hinzu.
  • Ändern Sie den LayoutType in BasicProcess.
  • Schreiben Sie die Präsentation als PPTX-Datei. Im folgenden Beispiel haben wir einen Connector zwischen zwei Formen hinzugefügt.
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/ChangeSmartArtLayout_out.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Add SmartArt BasicProcess
System::SharedPtr<Aspose::Slides::SmartArt::ISmartArt> smart = pres->get_Slides()->idx_get(0)->get_Shapes()->AddSmartArt(10, 10, 400, 300, SmartArtLayoutType::BasicBlockList);
// Change LayoutType to BasicProcess
smart->set_Layout(SmartArtLayoutType::BasicProcess);
// Save Presentation
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);

Versteckte Eigenschaften von SmartArt überprüfen

Bitte beachten Sie, dass die Methode com.aspose.slides.ISmartArtNode.isHidden() true zurückgibt, wenn dieser Knoten ein versteckter Knoten im Datenmodell ist. Um die versteckte Eigenschaft eines beliebigen Knotens von SmartArt zu überprüfen, befolgen Sie bitte die folgenden Schritte:

  • Erstellen Sie eine Instanz der Presentation Klasse.
  • Fügen Sie SmartArt RadialCycle hinzu.
  • Fügen Sie einen Knoten zu SmartArt hinzu.
  • Überprüfen Sie die isHidden-Eigenschaft.
  • Schreiben Sie die Präsentation als PPTX-Datei.

Im folgenden Beispiel haben wir einen Connector zwischen zwei Formen hinzugefügt.

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/CheckSmartArtHiddenProperty_out.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Add SmartArt BasicProcess
System::SharedPtr<Aspose::Slides::SmartArt::ISmartArt> smart = pres->get_Slides()->idx_get(0)->get_Shapes()->AddSmartArt(10, 10, 400, 300, SmartArtLayoutType::RadialCycle);
// Adding SmartArt node
System::SharedPtr<Aspose::Slides::SmartArt::ISmartArtNode> NewNode = smart->get_AllNodes()->AddNode();
// Check isHidden property
bool hidden = NewNode->get_IsHidden(); // Returns true
if (hidden)
{
// Do some actions or notifications
}
// Save Presentation
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);

Organigrammtyp abrufen oder festlegen

Die Methoden com.aspose.slides.ISmartArtNode.getOrganizationChartLayout(), setOrganizationChartLayout(int) ermöglichen das Abrufen oder Festlegen des mit dem aktuellen Knoten verknüpften Organigrammtyps. Um den Organigrammtyp abzurufen oder festzulegen, befolgen Sie bitte die folgenden Schritte:

  • Erstellen Sie eine Instanz der Presentation Klasse.
  • Fügen Sie SmartArt auf die Folie hinzu.
  • Holen Sie sich den Organigrammtyp oder setzen Sie ihn.
  • Schreiben Sie die Präsentation als PPTX-Datei. Im folgenden Beispiel haben wir einen Connector zwischen zwei Formen hinzugefügt.
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 templatePath = u"../templates/SmartArt.pptx";
const String outPath = u"../out/OrganizeChartLayoutType_out.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Add SmartArt BasicProcess
System::SharedPtr<Aspose::Slides::SmartArt::ISmartArt> smart = pres->get_Slides()->idx_get(0)->get_Shapes()->AddSmartArt(10, 10, 400, 300, SmartArtLayoutType::OrganizationChart);
// Accessing SmartArt node at index 0
System::SharedPtr<Aspose::Slides::SmartArt::ISmartArtNode> node0 = smart->get_AllNodes()->idx_get(0);
// Get or Set the organization chart type
node0->set_OrganizationChartLayout(OrganizationChartLayoutType::LeftHanging);
// Save Presentation
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);

Zustand von SmartArt abrufen oder festlegen

Einige SmartArt-Diagramme unterstützen keine Umkehrung, z.B.; vertikale Aufzählungsliste, vertikaler Prozess, absteigender Prozess, Trichter, Zahnrad, Gleichgewicht, Kreisbeziehung, Sechseck-Cluster, umgekehrte Liste, gestapelte Venn. Um die Ausrichtung von SmartArt zu ändern, befolgen Sie bitte die folgenden Schritte:

  • Erstellen Sie eine Instanz der Presentation Klasse.
  • Fügen Sie SmartArt auf die Folie hinzu.
  • Holen Sie sich den Zustand des SmartArt-Diagramms oder setzen Sie ihn.
  • Schreiben Sie die Präsentation als PPTX-Datei. Im folgenden Beispiel haben wir einen Connector zwischen zwei Formen hinzugefügt.
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/ChangeSmartArtLayout_out.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Add SmartArt BasicProcess
System::SharedPtr<Aspose::Slides::SmartArt::ISmartArt> smart = pres->get_Slides()->idx_get(0)->get_Shapes()->AddSmartArt(10, 10, 400, 300, SmartArtLayoutType::BasicBlockList);
// Change LayoutType to BasicProcess
smart->set_Layout(SmartArtLayoutType::BasicProcess);
// Save Presentation
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);

Bild-Organigramm erstellen

Aspose.Slides für C++ bietet eine einfache API zum Erstellen von Bild-Organigrammen auf einfache Weise. Um ein Diagramm auf einer Folie zu erstellen:

  1. Erstellen Sie eine Instanz der Presentation Klasse.
  2. Erhalten Sie die Referenz einer Folie anhand ihres Indexes.
  3. Fügen Sie ein Diagramm mit Standarddaten sowie dem gewünschten Typ hinzu (ChartType.PictureOrganizationChart).
  4. Schreiben Sie die modifizierte Präsentation in eine PPTX-Datei.

Der folgende Code wird verwendet, um ein Diagramm zu erstellen.

auto pres = System::MakeObject<Presentation>(u"test.pptx");
auto smartArt = pres->get_Slides()->idx_get(0)->get_Shapes()->AddSmartArt(0.0f, 0.0f, 400.0f, 400.0f, SmartArtLayoutType::PictureOrganizationChart);
pres->Save(u"OrganizationChart.pptx", SaveFormat::Pptx);