### Create Pareto Chart in PowerPoint (C++) Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md Illustrates how to create a Pareto chart in a PowerPoint presentation using C++. The example includes setting up the chart, defining categories and values, and configuring legend and title properties. ```cpp //Create a PPT document intrusive_ptr ppt = new Presentation(); //Add Pareto chart intrusive_ptr rect1 = new RectangleF(50, 50, 500, 400); intrusive_ptr chart = ppt->GetSlides()->GetItem(0)->GetShapes()->AppendChart(ChartType::Pareto, rect1, false); chart->GetChartData()->GetItem(0, 1)->SetText(L"series 1"); //Set category text for (int i = 0; i < categories.size(); i++) { chart->GetChartData()->GetItem(i + 1, 0)->SetText(categories[i].c_str()); } //Fill data for chart for (int i = 0; i < values.size(); i++) { chart->GetChartData()->GetItem(i + 1, 1)->SetNumberValue(values[i]); } chart->GetSeries()->SetSeriesLabel(chart->GetChartData()->GetItem(0, 1, 0, 1)); chart->GetCategories()->SetCategoryLabels(chart->GetChartData()->GetItem(1, 0, categories.size(), 0)); chart->GetSeries()->GetItem(0)->SetValues(chart->GetChartData()->GetItem(1, 1, values.size(), 1)); chart->GetPrimaryCategoryAxis()->SetIsBinningByCategory(true); chart->GetSeries()->GetItem(1)->GetLine()->GetFillFormat()->SetFillType(FillFormatType::Solid); chart->GetSeries()->GetItem(1)->GetLine()->GetFillFormat()->GetSolidFillColor()->SetKnownColor(KnownColors::Red); chart->GetChartTitle()->GetTextProperties()->SetText(L"Pareto"); chart->SetHasLegend(true); chart->GetChartLegend()->SetPosition(ChartLegendPositionType::Bottom); ``` -------------------------------- ### Create Map Chart in PowerPoint (C++) Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md Provides a C++ example for creating a Map chart in a PowerPoint presentation. It demonstrates how to add the chart, set series data, and define country and value mappings. ```cpp //Create a PPT document intrusive_ptr ppt = new Presentation(); //Add line markers chart intrusive_ptr rect1 = new RectangleF(50, 50, 450, 450); intrusive_ptr chart = ppt->GetSlides()->GetItem(0)->GetShapes()->AppendChart(ChartType::Map, rect1, false); chart->GetChartData()->GetItem(0, 1)->SetText(L"series"); //Define some data. std::vector countries = { L"China", L"Russia", L"France", L"Mexico", L"United States", L"India", L"Australia" }; for (int i = 0; i < countries.size(); i++) { chart->GetChartData()->GetItem(i + 1, 0)->SetText(countries[i].c_str()); } std::vector values = { 32, 20, 23, 17, 18, 6, 11 }; for (int i = 0; i < values.size(); i++) { chart->GetChartData()->GetItem(i + 1, 1)->SetNumberValue(values[i]); } chart->GetSeries()->SetSeriesLabel(chart->GetChartData()->GetItem(0, 1, 0, 1)); chart->GetCategories()->SetCategoryLabels(chart->GetChartData()->GetItem(1, 0, 7, 0)); chart->GetSeries()->GetItem(0)->SetValues(chart->GetChartData()->GetItem(1, 1, 7, 1)); ``` -------------------------------- ### Get Target Slide from Hyperlink Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md This example shows how to retrieve the target slide associated with a hyperlink. It checks if a shape has a hyperlink action of type 'GotoSlide' and then retrieves the target slide object. ```cpp //Create a PPT document intrusive_ptr ppt = new Presentation(); //Get the second slide intrusive_ptr slide = ppt->GetSlides()->GetItem(1); //Get the first shape of the second slide intrusive_ptr shape = Object::Dynamic_cast(slide->GetShapes()->GetItem(0)); //Get the linked slide index if (shape->GetClick()->GetActionType() == HyperlinkActionType::GotoSlide) { intrusive_ptr targetSlide = shape->GetClick()->GetTargetSlide(); } ``` -------------------------------- ### Spire.Presentation C++ Hello World Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md Creates a simple 'Hello World' presentation using Spire.Presentation in C++. It demonstrates how to create a presentation, add a shape, format its appearance, append text, and set text properties like font and fill. ```cpp //Create a PPT document intrusive_ptr presentation = new Presentation(); //Add a new shape to the PPT document intrusive_ptr rec = new RectangleF(presentation->GetSlideSize()->GetSize()->GetWidth() / 2 - 250, 80, 500, 150); intrusive_ptr shape = presentation->GetSlides()->GetItem(0)->GetShapes()->AppendShape(ShapeType::Rectangle, rec); shape->GetShapeStyle()->GetLineColor()->SetColor(Color::GetWhite()); shape->GetFill()->SetFillType(FillFormatType::None); //Add text to the shape shape->AppendTextFrame(L"Hello World!"); //Set the font and fill style of the text intrusive_ptr textRange = shape->GetTextFrame()->GetTextRange(); textRange->GetFill()->SetFillType(FillFormatType::Solid); textRange->GetFill()->GetSolidColor()->SetColor(Color::GetCadetBlue()); textRange->SetFontHeight(66); textRange->SetLatinFont(new TextFont(L"Lucida Sans Unicode")); ``` -------------------------------- ### Set Starting Slide Number Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md This C++ code snippet shows how to set the starting slide number for a PowerPoint presentation using the Spire.Presentation library. It configures the presentation to begin numbering slides from a specified number. ```cpp //Create PPT document intrusive_ptr presentation = new Presentation(); //Set 5 as the starting number presentation->SetFirstSlideNumber(5); ``` -------------------------------- ### Create and Format Table in PowerPoint Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md Demonstrates how to create a new table in a PowerPoint presentation, define its dimensions, add sample text to cells, set font styles, align text, and apply a preset style. ```cpp //Create a PPT document intrusive_ptr presentation = new Presentation(); //Define table dimensions std::vector widths = { 100, 100, 150, 100, 100 }; std::vector heights = { 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15 }; //Add new table to PPT intrusive_ptr table = presentation->GetSlides()->GetItem(0)->GetShapes()->AppendTable(presentation->GetSlideSize()->GetSize()->GetWidth() / 2 - 275, 90, widths, heights); //Add data to table for (int i = 0; i < 13; i++) { for (int j = 0; j < 5; j++) { //Fill the table with data table->GetItem(j, i)->GetTextFrame()->SetText(L"Sample Text"); //Set the Font table->GetItem(j, i)->GetTextFrame()->GetParagraphs()->GetItem(0)->GetTextRanges()->GetItem(0)->SetLatinFont(new TextFont(L"Arial Narrow")); } } //Set the alignment of the first row to Center for (int i = 0; i < 5; i++) { table->GetItem(i, 0)->GetTextFrame()->GetParagraphs()->GetItem(0)->SetAlignment(TextAlignmentType::Center); } //Set the style of table table->SetStylePreset(TableStylePreset::LightStyle3Accent1); ``` -------------------------------- ### Set Slide Transitions with Sound Mode and Speed Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md Illustrates setting slide transitions with different types (Push, Fade) and configuring sound mode (StartSound) and speed (Slow) for the transitions in C++ using Spire.Presentation. ```cpp //Set the first slide transition as push and sound mode presentation->GetSlides()->GetItem(0)->GetSlideShowTransition()->SetType(TransitionType::Push); presentation->GetSlides()->GetItem(0)->GetSlideShowTransition()->SetSoundMode(TransitionSoundMode::StartSound); //Set the second slide transition as circle and set the speed presentation->GetSlides()->GetItem(1)->GetSlideShowTransition()->SetType(TransitionType::Fade); presentation->GetSlides()->GetItem(1)->GetSlideShowTransition()->SetSpeed(TransitionSpeed::Slow); ``` -------------------------------- ### Get Section Index Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md Illustrates how to retrieve the index of a specific section within a PowerPoint presentation. ```cpp //Create a PPT document intrusive_ptr ppt = new Presentation(); intrusive_ptr
section = ppt->GetSectionList()->GetItem(0); int index = ppt->GetSectionList()->IndexOf(section); ``` -------------------------------- ### Create Presentation with Custom Slide Size Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md Illustrates how to create a new presentation and set a custom slide size using Spire.Presentation for C++. ```cpp //Create a new PPT document Presentation* newPresentation = new Presentation(); //Remove the default slide newPresentation->GetSlides()->RemoveAt(0); //Define a new size SizeF* size = new SizeF(200.0, 200.0); //Set PPT slide size newPresentation->GetSlideSize()->SetSize(size); //Insert the slide of original PPT newPresentation->GetSlides()->Insert(0, slide); ``` -------------------------------- ### Get and Set Slide Titles Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md This C++ code snippet demonstrates how to retrieve and modify the titles of slides within a PowerPoint presentation using Spire.Presentation. It shows how to get the current title of a slide and how to set a new title for another slide. ```cpp //Get the first slide intrusive_ptr slide = ppt->GetSlides()->GetItem(0); //Get the title of the first slide std::wstring slideTitle = slide->GetTitle(); //Set the title of the second slide ppt->GetSlides()->GetItem(1)->SetTitle(L"Second Slide"); ``` -------------------------------- ### Convert ODP to XPS Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md Shows how to convert an OpenDocument Presentation (ODP) file to XPS format using Spire.Presentation for C++. ```cpp wstring inputFile = DATAPATH"toPdf.odp"; wstring outputFile = OUTPUTPATH"OdpToXps.xps"; //Create a PPT document intrusive_ptr ppt = new Presentation(); //Load the file from disk. ppt->LoadFromFile(inputFile.c_str()); //Save to file. ppt->SaveToFile(outputFile.c_str(), FileFormat::XPS); ``` -------------------------------- ### Get Text Frame Properties from Shape Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md This C++ code snippet shows how to retrieve and display various text frame properties from a shape in a Spire.Presentation document. It accesses the ITextFrameProperties interface to get anchoring type, autofit type, vertical text type, and margins. ```cpp intrusive_ptr shape = Object::Dynamic_cast(presentation->GetSlides()->GetItem(0)->GetShapes()->GetItem(0)); intrusive_ptr textFrameFormat = shape->GetTextFrame(); wstring anchoringTypeStr = textTypeToString(textFrameFormat->GetAnchoringType()); wstring autofitTypeStr = textFitToString(textFrameFormat->GetAutofitType()); wstring verticalTextTypeStr = vertTextToString(textFrameFormat->GetVerticalTextType()); float marginLeft = textFrameFormat->GetMarginLeft(); float marginTop = textFrameFormat->GetMarginTop(); float marginRight = textFrameFormat->GetMarginRight(); float marginBottom = textFrameFormat->GetMarginBottom(); ``` -------------------------------- ### Get Text Style Effective Data from Presentation Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md Retrieves and accesses various text style properties, including paragraph indentation, alignment, line spacing, and text range font details, from a presentation's shape. It iterates through paragraphs and text ranges to get specific style information. ```cpp //Get the first slide intrusive_ptr slide = presentation->GetSlides()->GetItem(0); //Get a shape intrusive_ptr shape = Object::Dynamic_cast(presentation->GetSlides()->GetItem(0)->GetShapes()->GetItem(0)); for (int p = 0; p < shape->GetTextFrame()->GetParagraphs()->GetCount(); p++) { auto paragraph = shape->GetTextFrame()->GetParagraphs()->GetItem(p); //Get the paragraph style paragraph->GetIndent(); paragraph->GetAlignment(); paragraph->GetFontAlignment(); paragraph->GetHangingPunctuation(); paragraph->GetLineSpacing(); paragraph->GetSpaceBefore(); paragraph->GetSpaceAfter(); for (int r = 0; r < paragraph->GetTextRanges()->GetCount(); r++) { auto textRange = paragraph->GetTextRanges()->GetItem(r); //Get the text range style textRange->GetFontHeight(); textRange->GetLanguage(); textRange->GetLatinFont()->GetFontName(); } } ``` -------------------------------- ### Set Slide Size, Orientation, and Background Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md Shows how to set the size, orientation, and background image for slides in a PowerPoint presentation. ```cpp //Create a PPT document intrusive_ptr ppt = new Presentation(); //Set the size of slides ppt->GetSlideSize()->SetSize(new SizeF(600, 600)); ppt->GetSlideSize()->SetOrientation(SlideOrienation::Portrait); ppt->GetSlideSize()->SetType(SlideSizeType::Custom); //Set background image intrusive_ptr rect = new RectangleF(0, 0, ppt->GetSlideSize()->GetSize()->GetWidth(), ppt->GetSlideSize()->GetSize()->GetHeight()); ppt->GetSlides()->GetItem(0)->GetShapes()->AppendEmbedImage(ShapeType::Rectangle, ImageFile.c_str(), rect); ppt->GetSlides()->GetItem(0)->GetShapes()->GetItem(0)->GetLine()->GetFillFormat()->GetSolidFillColor()->SetColor(Color::GetFloralWhite()); ``` -------------------------------- ### C++ Precompiled Header for Spire.Presentation Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md Defines library linking and path constants for Spire.Presentation in C++. It includes the necessary library file and defines data and output paths. ```cpp #pragma once #pragma comment(lib,"../lib/Spire.Presentation.Cpp.lib") #define DATAPATH L"Data\" #define OUTPUTPATH L"Output\" ``` -------------------------------- ### Set and Get Alternative Text for Shapes Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md Demonstrates how to set and retrieve alternative text (title and description) for shapes in a presentation. This is useful for accessibility purposes. ```cpp //Set the alternative text (title and description) slide->GetShapes()->GetItem(0)->SetAlternativeTitle(L"Rectangle"); slide->GetShapes()->GetItem(0)->SetAlternativeText(L"This is a Rectangle"); //Get the alternative text (title and description) wstring title = slide->GetShapes()->GetItem(0)->GetAlternativeTitle(); wstring description = slide->GetShapes()->GetItem(0)->GetAlternativeText(); ``` -------------------------------- ### Access SmartArt Nodes Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md Demonstrates how to load a PowerPoint file, iterate through shapes, find SmartArt elements, and access all nodes within the SmartArt, including their text, level, and position. ```cpp //Create PPT document intrusive_ptr presentation = new Presentation(); //Load the PPT presentation->LoadFromFile(inputFile.c_str()); intrusive_ptr node; for (int s = 0; s < presentation->GetSlides()->GetItem(0)->GetShapes()->GetCount(); s++) { intrusive_ptr shape = presentation->GetSlides()->GetItem(0)->GetShapes()->GetItem(s); //Get the SmartArt intrusive_ptr sa = Object::Dynamic_cast(shape); if (sa != nullptr) { intrusive_ptr nodes = sa->GetNodes(); //Traverse through all nodes inside SmartArt for (int i = 0; i < nodes->GetCount(); i++) { //Access SmartArt node at index i node = nodes->GetItem(i); std::wstring text = node->GetTextFrame()->GetText(); //Get the SmartArt node parameters //Node text, level and position } } } ``` -------------------------------- ### Get Built-in Properties Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md Retrieves various built-in document properties from a PowerPoint presentation, such as application, author, company, keywords, comments, category, title, and subject. ```cpp //Create PPT document intrusive_ptr presentation = new Presentation(); //Load the PPT document from disk presentation->LoadFromFile(inputFile.c_str()); //Get the builtin properties wstring application = presentation->GetDocumentProperty()->GetApplication(); wstring author = presentation->GetDocumentProperty()->GetAuthor(); wstring company = presentation->GetDocumentProperty()->GetCompany(); wstring keywords = presentation->GetDocumentProperty()->GetKeywords(); wstring comments = presentation->GetDocumentProperty()->GetComments(); wstring category = presentation->GetDocumentProperty()->GetCategory(); wstring title = presentation->GetDocumentProperty()->GetTitle(); wstring subject = presentation->GetDocumentProperty()->GetSubject(); ``` -------------------------------- ### Add Line with Two Points Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md Shows how to add lines to a presentation slide by defining the start and end points using `PointF` objects in C++ with Spire.Presentation, and setting their colors. ```cpp using namespace Spire::Presentation; intrusive_ptr ppt = new Presentation(); //Get the first slide intrusive_ptr slide = ppt->GetSlides()->GetItem(0); //Add line with two points intrusive_ptr line = slide->GetShapes()->AppendShape(ShapeType::Line, new PointF(50, 50), new PointF(150, 150)); line->GetShapeStyle()->GetLineColor()->SetColor(Color::GetRed()); line = slide->GetShapes()->AppendShape(ShapeType::Line, new PointF(150, 150), new PointF(250, 50)); line->GetShapeStyle()->GetLineColor()->SetColor(Color::GetBlue()); ``` -------------------------------- ### Create Slide Masters and Apply to Slides Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md This code demonstrates how to create slide masters with different background images and apply them to specific slides within a presentation. It involves setting slide size, adding slides, appending masters, setting background fills with images, and applying layouts to slides. ```cpp //Create an instance of presentation document intrusive_ptr ppt = new Presentation(); ppt->GetSlideSize()->SetType(SlideSizeType::Screen16x9); //Add slides for (int i = 0; i < 4; i++) { ppt->GetSlides()->Append(); } //Get the first default slide master intrusive_ptr first_master = ppt->GetMasters()->GetItem(0); //Append another slide master ppt->GetMasters()->AppendSlide(first_master); intrusive_ptr second_master = ppt->GetMasters()->GetItem(1); //Set different background image for the two slide masters //The first slide master intrusive_ptr rect = new RectangleF(0, 0, ppt->GetSlideSize()->GetSize()->GetWidth(), ppt->GetSlideSize()->GetSize()->GetHeight()); first_master->GetSlideBackground()->GetFill()->SetFillType(FillFormatType::Picture); intrusive_ptr image1 = first_master->GetShapes()->AppendEmbedImage(ShapeType::Rectangle, pic1.c_str(), rect); first_master->GetSlideBackground()->GetFill()->GetPictureFill()->GetPicture()->SetEmbedImage(image1->GetPictureFill()->GetPicture()->GetEmbedImage()); //The second slide master second_master->GetSlideBackground()->GetFill()->SetFillType(FillFormatType::Picture); intrusive_ptr image2 = second_master->GetShapes()->AppendEmbedImage(ShapeType::Rectangle, pic2.c_str(), rect); second_master->GetSlideBackground()->GetFill()->GetPictureFill()->GetPicture()->SetEmbedImage(image2->GetPictureFill()->GetPicture()->GetEmbedImage()); //Apply the first master with layout to the first slide ppt->GetSlides()->GetItem(0)->SetLayout(first_master->GetLayouts()->GetItem(1)); //Apply the second master with layout to other slides for (int i = 1; i < ppt->GetSlides()->GetCount(); i++) { ppt->GetSlides()->GetItem(i)->SetLayout(second_master->GetLayouts()->GetItem(8)); } ``` -------------------------------- ### Manage Animation Duration and Delay Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md Provides C++ code to manage the duration and delay time of animation effects in a PowerPoint presentation. It shows how to get and set these timing properties for existing animations. ```cpp //Create an instance of presentation document intrusive_ptr presentation = new Presentation(); //Get the first slide intrusive_ptr slide = presentation->GetSlides()->GetItem(0); intrusive_ptr animations = slide->GetTimeline()->GetMainSequence(); //Get duration time of animation float durationTime = animations->GetItem(0)->GetTiming()->GetDuration(); //Set new duration time of animation animations->GetItem(0)->GetTiming()->SetDuration(0.8f); //Get delay time of animation float delayTime = animations->GetItem(0)->GetTiming()->GetTriggerDelayTime(); //Set new delay time of animation animations->GetItem(0)->GetTiming()->SetTriggerDelayTime(0.6f); ``` -------------------------------- ### Set Table Borders in C++ Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md Demonstrates how to create a new PowerPoint presentation, add a table, and set various border types, widths, and colors for the table cells using Spire.Presentation in C++. ```cpp //Create a PPT document intrusive_ptr presentation = new Presentation(); //Set the table width and height for each table cell. vector tableWidth = { 100, 100, 100, 100, 100 }; vector tableHeight = { 20, 20 }; //Traverse all the border type of the table. for (int i = 1; i <= 2048; i *= 2) { //Add a table to the presentation slide with the setting width and height intrusive_ptr itable = presentation->GetSlides()->Append()->GetShapes()->AppendTable(100, 100, tableWidth, tableHeight); //Add some text to the table cell. itable->GetTableRows()->GetItem(0)->GetItem(0)->GetTextFrame()->SetText(L"Row"); itable->GetTableRows()->GetItem(1)->GetItem(0)->GetTextFrame()->SetText(L"Column"); //Set the border type, border width and the border color for the table. itable->SetTableBorder(static_cast(i), 1.5, Color::GetRed()); } ``` -------------------------------- ### Load and Save DPS and DPT Files Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md Shows how to load and save files in DPS (PowerPoint Show) and DPT (PowerPoint Template) formats using Spire.Presentation for C++. ```cpp //Create a PPT document intrusive_ptr ppt = new Presentation(); //Load the file from disk. ppt->LoadFromFile(inputFile.c_str(), FileFormat::Dps); //Save to file. ppt->SaveToFile(outputFile.c_str(), FileFormat::Dps); ``` -------------------------------- ### Clone Slide in Presentation (C++) Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md Demonstrates how to clone a slide within a presentation document using Spire.Presentation for C++. It involves creating a presentation instance, getting a slide, and inserting it at a specified index. ```cpp //Create an instance of presentation document intrusive_ptr ppt = new Presentation(); //Get a list of slides and choose the first slide to be cloned intrusive_ptr slide = ppt->GetSlides()->GetItem(0); //Insert the desired slide to the specified index in the same presentation int index = 1; ppt->GetSlides()->Insert(index, slide); ``` -------------------------------- ### Load Presentation from Stream Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md Demonstrates loading a PowerPoint presentation from a stream into a Presentation object. ```cpp //Create a PPT document intrusive_ptr ppt = new Presentation(); //Load the file from disk. intrusive_ptr stream = new Stream(inputFile.c_str()); ppt->LoadFromStream(stream, FileFormat::Pptx2013); ``` -------------------------------- ### Get Shapes by Placeholder Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md This C++ code retrieves shapes associated with a specific placeholder in a PowerPoint slide. It iterates through the shapes and checks if they are linked to the given placeholder, processing auto shapes with text frames. ```cpp intrusive_ptr ppt = new Presentation(); intrusive_ptr placeholder = ppt->GetSlides()->GetItem(1)->GetShapes()->GetItem(0)->GetPlaceholder(); //Get Shapes by Placeholder std::vector> shapes = ppt->GetSlides()->GetItem(1)->GetPlaceholderShapes(placeholder); //Iterate over all the shapes for (int i = 0; i < shapes.size(); i++) { //If shape is IAutoShape if (Object::CheckType(shapes[i])) { intrusive_ptr autoShape = Object::Dynamic_cast(shapes[i]); if (autoShape->GetTextFrame() != nullptr) { // Process text frame } } } ``` -------------------------------- ### Create and Configure SmartArt Shape Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md Creates a new SmartArt shape with a specified layout, sets its style and color, removes existing nodes, and adds new nodes with text and formatting. ```cpp intrusive_ptr sa = presentation->GetSlides()->GetItem(0)->GetShapes()->AppendSmartArt(200, 60, 300, 300, SmartArtLayoutType::Gear); //Set type and color of smartart sa->SetStyle(SmartArtStyleType::SubtleEffect); sa->SetColorStyle(SmartArtColorType::GradientLoopAccent3); //Remove all shapes int i = sa->GetNodes()->GetCount(); while (i > 0) { sa->GetNodes()->RemoveNode(0); i--; } //Add two custom shapes with text intrusive_ptr node = sa->GetNodes()->AddNode(); sa->GetNodes()->GetItem(0)->GetTextFrame()->SetText(L"aa"); node = sa->GetNodes()->AddNode(); node->GetTextFrame()->SetText(L"bb"); node->GetTextFrame()->GetTextRange()->GetFill()->SetFillType(FillFormatType::Solid); node->GetTextFrame()->GetTextRange()->GetFill()->GetSolidColor()->SetKnownColor(KnownColors::Black); ``` -------------------------------- ### Get Slide Layout Names Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md This C++ code snippet shows how to retrieve the names of the slide layouts used in a PowerPoint presentation with the Spire.Presentation library. It iterates through each slide and extracts the name of its associated layout. ```cpp using namespace Spire::Presentation; //Create a PPT document intrusive_ptr presentation = new Presentation(); //Loop through the slides of PPT document for (int i = 0; i < presentation->GetSlides()->GetCount(); i++) { //Get the name of slide layout std::wstring name = presentation->GetSlides()->GetItem(i)->GetLayout()->GetName(); } ``` -------------------------------- ### Insert Audio into Presentation Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md This C++ code demonstrates how to create a new presentation and insert an audio file into the first slide at a specified rectangular position. ```cpp //Create a PPT document intrusive_ptr presentation = new Presentation(); //Insert audio into the document intrusive_ptr audioRect = new RectangleF(220, 240, 80, 80); wstring inputFile_music = DATAPATH"Music.wav"; presentation->GetSlides()->GetItem(0)->GetShapes()->AppendAudioMedia(inputFile_music.c_str(), audioRect); ``` -------------------------------- ### Append Slide with Master Layout Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md Demonstrates how to append a new slide to a presentation using a specific master layout. It involves getting master slides, layouts, appending shapes, and setting text properties. ```cpp //Get the master intrusive_ptr master = presentation->GetMasters()->GetItem(0); //Get master layout slides intrusive_ptr masterLayouts = master->GetLayouts(); intrusive_ptr layoutSlide = masterLayouts->GetItem(1); //Append a rectangle to the layout slide intrusive_ptr shape = layoutSlide->GetShapes()->AppendShape(ShapeType::Rectangle, new RectangleF(10, 50, 100, 80)); //Add a text into the shape and set the style shape->GetFill()->SetFillType(FillFormatType::None); shape->AppendTextFrame(L"Layout slide 1"); shape->GetTextFrame()->GetParagraphs()->GetItem(0)->GetTextRanges()->GetItem(0)->SetLatinFont(new TextFont(L"Arial Black")); shape->GetTextFrame()->GetParagraphs()->GetItem(0)->GetTextRanges()->GetItem(0)->GetFill()->SetFillType(FillFormatType::Solid); shape->GetTextFrame()->GetParagraphs()->GetItem(0)->GetTextRanges()->GetItem(0)->GetFill()->GetSolidColor()->SetColor(Color::GetCadetBlue()); //Append new slide with master layout presentation->GetSlides()->Append(presentation->GetSlides()->GetItem(0), master->GetLayouts()->GetItem(1)); //Another way to append new slide with master layout presentation->GetSlides()->Insert(2, presentation->GetSlides()->GetItem(1), master->GetLayouts()->GetItem(1)); ``` -------------------------------- ### Set Header and Footer in Presentation Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md Illustrates how to set footer text, control footer visibility, and display slide numbers and dates in a PowerPoint presentation using Spire.Presentation for C++. ```cpp //Create a PPT document intrusive_ptr ppt = new Presentation(); //Add footer ppt->SetFooterText(L"Demo of Spire.Presentation"); //Set the footer visible ppt->SetFooterVisible(true); //Set the page number visible ppt->SetSlideNumberVisible(true); //Set the date visible ppt->SetDateTimeVisible(true); ``` -------------------------------- ### Get Table Cell Border Color Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md Retrieves the Alpha, Red, Green, and Blue components of the left, top, right, and bottom borders of a table cell. It also retrieves the display color components of the cell. ```cpp intrusive_ptr ppt = new Presentation(); //Get the table in the first slide intrusive_ptr table = Object::Dynamic_cast(ppt->GetSlides()->GetItem(0)->GetShapes()->GetItem(0)); //Get borders' color of the first cell table->GetItem(0, 0)->GetBorderLeftDisplayColor()->GetA(); table->GetItem(0, 0)->GetBorderLeftDisplayColor()->GetR(); table->GetItem(0, 0)->GetBorderLeftDisplayColor()->GetG(); table->GetItem(0, 0)->GetBorderLeftDisplayColor()->GetB(); table->GetItem(0, 0)->GetBorderTopDisplayColor()->GetA(); table->GetItem(0, 0)->GetBorderTopDisplayColor()->GetR(); table->GetItem(0, 0)->GetBorderTopDisplayColor()->GetG(); table->GetItem(0, 0)->GetBorderTopDisplayColor()->GetB(); table->GetItem(0, 0)->GetBorderRightDisplayColor()->GetA(); table->GetItem(0, 0)->GetBorderRightDisplayColor()->GetR(); table->GetItem(0, 0)->GetBorderRightDisplayColor()->GetG(); table->GetItem(0, 0)->GetBorderRightDisplayColor()->GetB(); table->GetItem(0, 0)->GetBorderBottomDisplayColor()->GetA(); table->GetItem(0, 0)->GetBorderBottomDisplayColor()->GetR(); table->GetItem(0, 0)->GetBorderBottomDisplayColor()->GetG(); table->GetItem(0, 0)->GetBorderBottomDisplayColor()->GetB(); //Get display color of the first cell table->GetItem(0, 0)->GetDisplayColor()->GetA(); table->GetItem(0, 0)->GetDisplayColor()->GetR(); table->GetItem(0, 0)->GetDisplayColor()->GetG(); table->GetItem(0, 0)->GetDisplayColor()->GetB(); ``` -------------------------------- ### Set Slide Transition Effects Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md Shows how to apply specific transition effects, such as a 'Cut' transition with a 'FromBlack' effect, to a slide in a presentation using Spire.Presentation in C++. ```cpp // Set effects presentation->GetSlides()->GetItem(0)->GetSlideShowTransition()->SetType(TransitionType::Cut); (Object::Dynamic_cast(presentation->GetSlides()->GetItem(0)->GetSlideShowTransition()->GetValue()))->SetFromBlack(true); ``` -------------------------------- ### Get Slide Comments from Presentation (C++) Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md Shows how to retrieve comments associated with authors in a PowerPoint presentation using Spire.Presentation for C++. The code iterates through comment authors and their respective comment lists to access comment details. ```cpp // Loop through comments for (int i = 0; i < ppt->GetCommentAuthors()->GetCount(); i++) { intrusive_ptr commentAuthor = ppt->GetCommentAuthors()->GetItem(i); for (int j = 0; j < commentAuthor->GetCommentsList()->GetCount(); j++) { // Get comment information intrusive_ptr comment = commentAuthor->GetCommentsList()->GetItem(j); } } ``` -------------------------------- ### Add and Get Speaker Notes in PowerPoint Slides (C++) Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md Demonstrates how to add and retrieve speaker notes for a slide in a PowerPoint presentation using Spire.Presentation for C++. It handles cases where notes might not exist by adding them first. ```cpp using namespace std; using namespace Spire::Presentation; intrusive_ptr presentation = new Presentation(); //Get the first slide and in the PowerPoint document. intrusive_ptr slide = presentation->GetSlides()->GetItem(0); //Get the NotesSlide in the first slide, if there is no notes, we need to add it firstly. intrusive_ptr ns = slide->GetNotesSlide(); if (ns == nullptr) { ns = slide->AddNotesSlide(); } //Add the text string as the notes. ns->GetNotesTextFrame()->SetText(L"Speak notes added by Spire.Presentation"); //Get the speaker notes wstring speakerNotes = ns->GetNotesTextFrame()->GetText(); ``` -------------------------------- ### Create Pie Chart with Auto-Varying Colors Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md Provides an example of creating a pie chart and setting its title, data, and series labels. It also demonstrates how to control the auto-varying color feature and set the distance for a pie slice. ```cpp // Create a PPT document intrusive_ptr ppt = new Presentation(); intrusive_ptr rect1 = new RectangleF(40, 100, 550, 320); // Add a pie chart intrusive_ptr chart = ppt->GetSlides()->GetItem(0)->GetShapes()->AppendChart(ChartType::Pie, rect1, false); chart->GetChartTitle()->GetTextProperties()->SetText(L"Sales by Quarter"); chart->GetChartTitle()->GetTextProperties()->SetIsCentered(true); chart->GetChartTitle()->SetHeight(30); chart->SetHasTitle(true); // Attach the data to chart chart->GetSeries()->SetSeriesLabel(chart->GetChartData()->GetItem(L"B1", L"B1")); chart->GetCategories()->SetCategoryLabels(chart->GetChartData()->GetItem(L"A2", L"A5")); chart->GetSeries()->GetItem(0)->SetValues(chart->GetChartData()->GetItem(L"B2", L"B5")); // Set whether auto vary color, default value is true chart->GetSeries()->GetItem(0)->SetIsVaryColor(false); chart->GetSeries()->GetItem(0)->SetDistance(15); ``` -------------------------------- ### Obtain Sound Effects from Presentation Timeline Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md This C++ code shows how to access the timeline of a presentation's slide, retrieve audio elements from the main sequence, and get properties like sound name, volume, and mute status. ```cpp using namespace std; using namespace Spire::Presentation; //Create an instance of presentation document intrusive_ptr ppt = new Presentation(); //Get the first slide intrusive_ptr slide = ppt->GetSlides()->GetItem(0); //Get the audio in a time node intrusive_ptr audio = slide->GetTimeline()->GetMainSequence()->GetItem(0)->GetTimeNodeAudios().front(); //Get the properties of the audio, such as sound name, volume or detect if it's mute audio->GetSoundName(); audio->GetVolume(); audio->GetIsMute(); ``` -------------------------------- ### Set Chart Legend Position and Size Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md This C++ code illustrates how to position and resize the legend of a chart within a presentation. It involves getting the chart object, accessing its legend, and then setting the Left, Top, Width, and Height properties. ```cpp //Create a PPT document intrusive_ptr ppt = new Presentation(); //Get the chart. intrusive_ptr chart = Object::Dynamic_cast(ppt->GetSlides()->GetItem(0)->GetShapes()->GetItem(0)); //Set the legend positon chart->GetChartLegend()->SetLeft(20); chart->GetChartLegend()->SetTop(20); //Set the legend size chart->GetChartLegend()->SetWidth(250); chart->GetChartLegend()->SetHeight(30); ``` -------------------------------- ### Set SmartArt Node Outline Properties Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md This snippet demonstrates how to iterate through SmartArt nodes in a presentation and set their outline properties, including fill type, style, color, and width. ```cpp using namespace Spire::Presentation; // Get SmartArt from the first slide intrusive_ptr smartArt = Object::Dynamic_cast(ppt->GetSlides()->GetItem(0)->GetShapes()->GetItem(0)); int count = smartArt->GetNodes()->GetCount(); intrusive_ptr node; // Loop through all nodes for (int i = 0; i < count; i++) { node = smartArt->GetNodes()->GetItem(i); // Set the fill format type node->GetLine()->SetFillType(FillFormatType::Solid); // Set the line style node->GetLine()->SetStyle(TextLineStyle::ThinThin); // Set the line color node->GetLine()->GetSolidFillColor()->SetColor(Color::GetRed()); // Set the line width node->GetLine()->SetWidth(2); } ``` -------------------------------- ### Convert PowerPoint Slide to Specific Size Image Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md Converts the first slide of a PowerPoint presentation to an image with a specified size (600x400 pixels). The code loads the presentation, gets the first slide, saves it as an image with dimensions, and then saves the image stream. ```cpp //Create a PPT document intrusive_ptr ppt = new Presentation(); //Load the file from disk. ppt->LoadFromFile(inputFile.c_str()); //Save the first slide to Image and set the image size to 600x400 intrusive_ptr stream = ppt->GetSlides()->GetItem(0)->SaveAsImage(600, 400); stream->Save(outputFile.c_str()); ``` -------------------------------- ### Format Chart Data Labels Source: https://github.com/eiceblue/spire.presentation-for-c/blob/main/C++ Examples/ppt_c.md Shows how to format chart data labels by adding new labels, setting their position, text, font, and color. Multiple data labels with different configurations are demonstrated. ```cpp //Get the chart. intrusive_ptr chart = Object::Dynamic_cast(ppt->GetSlides()->GetItem(0)->GetShapes()->GetItem(0)); //Get the chart series intrusive_ptr sers = chart->GetSeries(); //Initialize four instances of series label and set parameters of each label intrusive_ptr cd1 = sers->GetItem(0)->GetDataLabels()->Add(); cd1->SetPercentageVisible(true); cd1->GetTextFrame()->SetText(L"Custom Datalabel1"); cd1->GetTextFrame()->GetTextRange()->SetFontHeight(12); cd1->GetTextFrame()->GetTextRange()->SetLatinFont(new TextFont(L"Lucida Sans Unicode")); cd1->GetTextFrame()->GetTextRange()->GetFill()->SetFillType(FillFormatType::Solid); cd1->GetTextFrame()->GetTextRange()->GetFill()->GetSolidColor()->SetKnownColor(KnownColors::Green); intrusive_ptr cd2 = sers->GetItem(0)->GetDataLabels()->Add(); cd2->SetPosition(ChartDataLabelPosition::InsideEnd); cd2->SetPercentageVisible(true); cd2->GetTextFrame()->SetText(L"Custom Datalabel2"); cd2->GetTextFrame()->GetTextRange()->SetFontHeight(10); cd2->GetTextFrame()->GetTextRange()->SetLatinFont(new TextFont(L"Arial")); cd2->GetTextFrame()->GetTextRange()->GetFill()->SetFillType(FillFormatType::Solid); cd2->GetTextFrame()->GetTextRange()->GetFill()->GetSolidColor()->SetKnownColor(KnownColors::OrangeRed); intrusive_ptr cd3 = sers->GetItem(0)->GetDataLabels()->Add(); cd3->SetPosition(ChartDataLabelPosition::Center); cd3->SetPercentageVisible(true); cd3->GetTextFrame()->SetText(L"Custom Datalabel3"); cd3->GetTextFrame()->GetTextRange()->SetFontHeight(14); cd3->GetTextFrame()->GetTextRange()->SetLatinFont(new TextFont(L"Calibri")); cd3->GetTextFrame()->GetTextRange()->GetFill()->SetFillType(FillFormatType::Solid); cd3->GetTextFrame()->GetTextRange()->GetFill()->GetSolidColor()->SetKnownColor(KnownColors::Blue); intrusive_ptr cd4 = sers->GetItem(0)->GetDataLabels()->Add(); cd4->SetPosition(ChartDataLabelPosition::InsideBase); cd4->SetPercentageVisible(true); cd4->GetTextFrame()->SetText(L"Custom Datalabel4"); cd4->GetTextFrame()->GetTextRange()->SetFontHeight(12); cd4->GetTextFrame()->GetTextRange()->SetLatinFont(new TextFont(L"Lucida Sans Unicode")); cd4->GetTextFrame()->GetTextRange()->GetFill()->SetFillType(FillFormatType::Solid); cd4->GetTextFrame()->GetTextRange()->GetFill()->GetSolidColor()->SetKnownColor(KnownColors::OliveDrab); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.