スマートアートの管理
スマートアートからテキストを取得
現在、ISmartArtShapeインターフェースおよびSmartArtShapeクラスにTextFrameプロパティが追加されました。このプロパティを使用すると、ノードのテキストだけでなく、スマートアートからすべてのテキストを取得できます。以下のサンプルコードは、スマートアートノードからテキストを取得するのに役立ちます。
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()); | |
} | |
} | |
} | |
} | |
} |
スマートアートのレイアウトタイプを変更
スマートアートのレイアウトタイプを変更するには、以下の手順に従ってください:
- Presentationクラスのインスタンスを作成します。
- インデックスを使用してスライドの参照を取得します。
- SmartArt BasicBlockListを追加します。
- LayoutTypeをBasicProcessに変更します。
- プレゼンテーションをPPTXファイルとして保存します。 下記の例では、2つのシェイプ間にコネクタを追加しました。
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); | |
スマートアートの隠れたプロパティを確認
メソッドcom.aspose.slides.ISmartArtNode.isHidden()は、このノードがデータモデル内の隠れたノードである場合にtrueを返すことに注意してください。スマートアートの任意のノードの隠れたプロパティを確認するには、以下の手順に従ってください:
- Presentationクラスのインスタンスを作成します。
- SmartArt RadialCycleを追加します。
- スマートアートにノードを追加します。
- isHiddenプロパティを確認します。
- プレゼンテーションをPPTXファイルとして保存します。
下記の例では、2つのシェイプ間にコネクタを追加しました。
組織図タイプの取得または設定
メソッドcom.aspose.slides.ISmartArtNode.getOrganizationChartLayout(), setOrganizationChartLayout(int)は、現在のノードに関連する組織図タイプを取得または設定することを可能にします。組織図タイプを取得または設定するには、以下の手順に従ってください:
- Presentationクラスのインスタンスを作成します。
- スライドにスマートアートを追加します。
- 組織図タイプを取得または設定します。
- プレゼンテーションをPPTXファイルとして保存します。 下記の例では、2つのシェイプ間にコネクタを追加しました。
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); | |
スマートアートの状態の取得または設定
いくつかのスマートアート図は反転をサポートしていません。たとえば、垂直バレットリスト、垂直プロセス、降順プロセス、ファネル、ギア、バランス、円関係、六角形クラスター、逆リスト、スタック型ベン図などです。スマートアートの向きを変更するには、以下の手順に従ってください:
- Presentationクラスのインスタンスを作成します。
- スライドにスマートアートを追加します。
- スマートアート図の状態を取得または設定します。
- プレゼンテーションをPPTXファイルとして保存します。 下記の例では、2つのシェイプ間にコネクタを追加しました。
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); | |
ピクチャ組織図の作成
Aspose.Slides for C++は、簡単にピクチャ組織図を作成するためのシンプルなAPIを提供します。スライドにチャートを作成するには:
- Presentationクラスのインスタンスを作成します。
- インデックスからスライドの参照を取得します。
- デフォルトデータと共に、目的のタイプ(ChartType.PictureOrganizationChart)を持つチャートを追加します。
- 修正されたプレゼンテーションをPPTXファイルに保存します。
以下のコードを使用してチャートを作成します。
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);