Administrar Forma de SmartArt
Crear Forma de SmartArt
Aspose.Slides para C++ ahora facilita agregar formas de SmartArt personalizadas en sus diapositivas desde cero. Aspose.Slides para C++ ha proporcionado la API más simple para crear formas de SmartArt de la manera más fácil. Para crear una forma de SmartArt en una diapositiva, por favor siga los pasos a continuación:
- Cree una instancia de la clase Presentation.
- Obtenga la referencia de una diapositiva utilizando su índice.
- Agregue una forma de SmartArt estableciendo su LayoutType.
- Escriba la presentación modificada como un archivo PPTX.
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/SimpleSmartArt_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); | |
// Save Presentation | |
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx); | |
Acceder a la Forma de SmartArt en la Diapositiva
El siguiente código se utilizará para acceder a las formas de SmartArt agregadas en la diapositiva de la presentación. En el código de ejemplo, recorreremos cada forma dentro de la diapositiva y verificaremos si es una forma de SmartArt. Si la forma es del tipo SmartArt, la convertiremos en una instancia 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 | |
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); | |
System::Console::WriteLine(u"Smart Art Name = " + smart->get_Name()); | |
} | |
} | |
Acceder a la Forma de SmartArt con un Tipo de Diseño Particular
El siguiente código de muestra ayudará a acceder a la forma de SmartArt con un LayoutType particular. Tenga en cuenta que no puede cambiar el LayoutType del SmartArt ya que es de solo lectura y se establece solo cuando se agrega la forma de SmartArt.
- Cree una instancia de la clase
Presentation
y cargue la presentación con la forma de SmartArt. - Obtenga la referencia de la primera diapositiva utilizando su índice.
- Recorra cada forma dentro de la primera diapositiva.
- Verifique si la forma es del tipo SmartArt y convierta la forma seleccionada a SmartArt si es SmartArt.
- Verifique la forma de SmartArt con el LayoutType particular y realice lo que se requiere realizar posteriormente.
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 | |
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); | |
System::Console::WriteLine(u"Smart Art Name = " + smart->get_Name()); | |
// Checking SmartArt Layout | |
if (smart->get_Layout() == SmartArtLayoutType::BasicBlockList) | |
{ | |
System::Console::WriteLine(u"Do some thing here...."); | |
} | |
} | |
} | |
Cambiar el Estilo de la Forma de SmartArt
El siguiente código de muestra ayudará a acceder a la forma de SmartArt con un LayoutType particular.
- Cree una instancia de la clase
Presentation
y cargue la presentación con la forma de SmartArt. - Obtenga la referencia de la primera diapositiva utilizando su índice.
- Recorra cada forma dentro de la primera diapositiva.
- Verifique si la forma es del tipo SmartArt y convierta la forma seleccionada a SmartArt si es SmartArt.
- Encuentre la forma de SmartArt con un estilo particular.
- Establezca el nuevo estilo para la forma de SmartArt.
- Guarde la presentación.
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/ChangeSmartArtStyle_out.pptx"; | |
// Load the desired the presentation | |
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath); | |
// Traverse through every shape inside first slide | |
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); | |
// Checking SmartArt style | |
if (smart->get_QuickStyle() == SmartArtQuickStyleType::SimpleFill) | |
{ | |
// Changing SmartArt Style | |
smart->set_QuickStyle(SmartArtQuickStyleType::Cartoon); | |
} | |
} | |
} | |
// Save Presentation | |
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx); | |
Cambiar el Estilo de Color de la Forma de SmartArt
En este ejemplo, aprenderemos a cambiar el estilo de color para cualquier forma de SmartArt. En el siguiente código de muestra accederemos a la forma de SmartArt con un estilo de color particular y cambiaremos su estilo.
- Cree una instancia de la clase
Presentation
y cargue la presentación con la forma de SmartArt. - Obtenga la referencia de la primera diapositiva utilizando su índice.
- Recorra cada forma dentro de la primera diapositiva.
- Verifique si la forma es del tipo SmartArt y convierta la forma seleccionada a SmartArt si es SmartArt.
- Encuentre la forma de SmartArt con un estilo de color particular.
- Establezca el nuevo estilo de color para la forma de SmartArt.
- Guarde la presentación.
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/ChangeSmartArtShapeColorStyle.pptx"; | |
// Load the desired the presentation | |
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath); | |
// Traverse through every shape inside first slide | |
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); | |
if (smart->get_ColorStyle() == SmartArtColorType::ColoredFillAccent1) | |
{ | |
// Changing SmartArt color type | |
smart->set_ColorStyle(SmartArtColorType::ColorfulAccentColors); | |
} | |
} | |
} | |
// Save Presentation | |
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx); | |