Administrar SmartArt

Obtener texto de SmartArt

Ahora se ha añadido la propiedad TextFrame a la interfaz ISmartArtShape y a la clase SmartArtShape, respectivamente. Esta propiedad te permite obtener todo el texto de SmartArt si no tiene solo texto de nodos. El siguiente código de muestra te ayudará a obtener texto del nodo de SmartArt.

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());
}
}
}
}
}

Cambiar el tipo de diseño de cualquier SmartArt

Para cambiar el tipo de diseño de SmartArt, sigue los pasos a continuación:

  • Crea una instancia de la clase Presentation.
  • Obtén la referencia de una diapositiva utilizando su índice.
  • Añade SmartArt BasicBlockList.
  • Cambia LayoutType a BasicProcess.
  • Escribe la presentación como un archivo PPTX. En el ejemplo que se da a continuación, hemos añadido un conector entre dos formas.
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);

Comprobar la propiedad oculta de SmartArt

Ten en cuenta que el método com.aspose.slides.ISmartArtNode.isHidden() devuelve verdadero si este nodo es un nodo oculto en el modelo de datos. Para comprobar la propiedad oculta de cualquier nodo de SmartArt, sigue los pasos a continuación:

  • Crea una instancia de la clase Presentation.
  • Añade SmartArt RadialCycle.
  • Añade un nodo en SmartArt.
  • Comprueba la propiedad isHidden.
  • Escribe la presentación como un archivo PPTX.

En el ejemplo que se da a continuación, hemos añadido un conector entre dos formas.

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);

Obtener o establecer el tipo de diagrama organizacional

Los métodos com.aspose.slides.ISmartArtNode.getOrganizationChartLayout(), setOrganizationChartLayout(int) permiten obtener o establecer el tipo de diagrama organizacional asociado con el nodo actual. Para obtener o establecer el tipo de diagrama organizacional, sigue los pasos a continuación:

  • Crea una instancia de la clase Presentation.
  • Añade SmartArt en la diapositiva.
  • Obtén o establece el tipo de diagrama organizacional.
  • Escribe la presentación como un archivo PPTX. En el ejemplo que se da a continuación, hemos añadido un conector entre dos formas.
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);

Obtener o establecer el estado de SmartArt

Algunos diagramas de SmartArt no admiten la inversión, por ejemplo; Lista de viñetas vertical, Proceso vertical, Proceso descendente, Embudo, Engranaje, Balance, Relación circular, Agrupación hexagonal, Lista invertida, Diagrama de Venn apilado. Para cambiar la orientación de SmartArt, sigue los pasos a continuación:

  • Crea una instancia de la clase Presentation.
  • Añade SmartArt en la diapositiva.
  • Obtén o establece el estado del diagrama de SmartArt.
  • Escribe la presentación como un archivo PPTX. En el ejemplo que se da a continuación, hemos añadido un conector entre dos formas.
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);

Crear un diagrama organizacional de imagen

Aspose.Slides para C++ proporciona una API simple para crear y diagramas organizacionales de imagen de manera sencilla. Para crear un diagrama en una diapositiva:

  1. Crea una instancia de la clase Presentation.
  2. Obtén la referencia de una diapositiva por su índice.
  3. Añade un diagrama con datos predeterminados junto con el tipo deseado (ChartType.PictureOrganizationChart).
  4. Escribe la presentación modificada en un archivo PPTX.

El siguiente código se utiliza para crear un diagrama.

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);