إدارة شكل SmartArt

إنشاء شكل SmartArt

تتيح Aspose.Slides لـ C++ الآن إضافة أشكال SmartArt مخصصة في الشرائح من الصفر. تقدم Aspose.Slides لـ C++ أبسط واجهة برمجة تطبيقات لإنشاء أشكال SmartArt بطريقة سهلة. لإنشاء شكل SmartArt في شريحة، يرجى اتباع الخطوات أدناه:

  • إنشاء مثيل من Presentation class.
  • الحصول على مرجع الشريحة باستخدام الفهرس الخاص بها.
  • إضافة شكل SmartArt عن طريق تعيين LayoutType الخاص به.
  • كتابة العرض التقديمي المعدل كملف 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);

الوصول إلى شكل SmartArt في الشريحة

سيتم استخدام الكود التالي للوصول إلى أشكال SmartArt المضافة في شريحة العرض التقديمي. في عينة الكود، سنتنقل عبر كل شكل داخل الشريحة ونتحقق مما إذا كان شكل SmartArt. إذا كان الشكل من نوع SmartArt، فسنقوم بتحويله إلى مثيل 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());
}
}

الوصول إلى شكل SmartArt بنوع تخطيط معين

ستساعد عينة الكود التالية في الوصول إلى شكل SmartArt بنوع LayoutType معين. يرجى ملاحظة أنه لا يمكنك تغيير LayoutType الخاص بـ SmartArt لأنه للقراءة فقط ويتم تعيينه فقط عند إضافة شكل SmartArt.

  • إنشاء مثيل من Presentation class وتحميل العرض التقديمي مع شكل SmartArt.
  • الحصول على مرجع الشريحة الأولى باستخدام الفهرس الخاص بها.
  • التنقل عبر كل شكل داخل الشريحة الأولى.
  • التحقق مما إذا كان الشكل من نوع SmartArt وتحويل الشكل المحدد إلى SmartArt إذا كان من نوع SmartArt.
  • التحقق من شكل SmartArt بنوع LayoutType معين وتنفيذ ما هو مطلوب بعد ذلك.
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....");
}
}
}

تغيير نمط شكل SmartArt

ستساعد عينة الكود التالية في الوصول إلى شكل SmartArt بنوع LayoutType معين.

  • إنشاء مثيل من Presentation class وتحميل العرض التقديمي مع شكل SmartArt.
  • الحصول على مرجع الشريحة الأولى باستخدام الفهرس الخاص بها.
  • التنقل عبر كل شكل داخل الشريحة الأولى.
  • التحقق مما إذا كان الشكل من نوع SmartArt وتحويل الشكل المحدد إلى SmartArt إذا كان من نوع SmartArt.
  • العثور على شكل SmartArt بنمط معين.
  • تعيين النمط الجديد لشكل 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";
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);

تغيير نمط لون شكل SmartArt

في هذا المثال، سنتعلم كيفية تغيير نمط اللون لأي شكل SmartArt. في عينة الكود التالية، سنقوم بالوصول إلى شكل SmartArt بنمط لون معين وسنقوم بتغيير نمطه.

  • إنشاء مثيل من Presentation class وتحميل العرض التقديمي مع شكل SmartArt.
  • الحصول على مرجع الشريحة الأولى باستخدام الفهرس الخاص بها.
  • التنقل عبر كل شكل داخل الشريحة الأولى.
  • التحقق مما إذا كان الشكل من نوع SmartArt وتحويل الشكل المحدد إلى SmartArt إذا كان من نوع SmartArt.
  • العثور على شكل SmartArt بنمط لون معين.
  • تعيين نمط اللون الجديد لشكل 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";
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);