SmartArtシェイプを管理する
SmartArtシェイプを作成する
Aspose.Slides for C++は、スライドにカスタムSmartArtシェイプをゼロから追加する機能を提供します。Aspose.Slides for C++は、SmartArtシェイプを最も簡単に作成するためのシンプルなAPIを提供しています。スライドにSmartArtシェイプを作成するには、以下の手順に従ってください。
- Presentation クラスのインスタンスを作成します。
- インデックスを使用してスライドの参照を取得します。
- LayoutTypeを設定してSmartArtシェイプを追加します。
- 修正されたプレゼンテーションを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()); | |
} | |
} | |
特定のLayoutTypeを持つSmartArtシェイプにアクセスする
以下のサンプルコードは、特定のLayoutTypeを持つSmartArtシェイプにアクセスするのに役立ちます。SmartArtシェイプのLayoutTypeは読み取り専用であり、SmartArtシェイプが追加されたときにのみ設定されるため、変更できませんのでご注意ください。
Presentation
クラスのインスタンスを作成し、SmartArtシェイプを含むプレゼンテーションをロードします。- インデックスを使用して最初のスライドの参照を取得します。
- 最初のスライド内のすべてのシェイプをトラバースします。
- シェイプがSmartArtタイプかどうかを確認し、SmartArtの場合は選択したシェイプをSmartArtに型変換します。
- 特定のLayoutTypeを持つ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()); | |
// Checking SmartArt Layout | |
if (smart->get_Layout() == SmartArtLayoutType::BasicBlockList) | |
{ | |
System::Console::WriteLine(u"Do some thing here...."); | |
} | |
} | |
} | |
SmartArtシェイプスタイルを変更する
以下のサンプルコードは、特定のLayoutTypeを持つSmartArtシェイプにアクセスするのに役立ちます。
Presentation
クラスのインスタンスを作成し、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
クラスのインスタンスを作成し、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); | |