How to Get Custom Bullets from Presentations Using Aspose.Slides for C++?

Using aspose slides for cpp.
Both No bullets and custom bullets both come as Not defined .
using API:

paragraphFormat->get_Bullet()->get_Type()

Is there a way to differentiate custom bullets?

Thanks

@pankajku

To differentiate custom bullets in Aspose.Slides for C++, you can utilize the ParagraphFormat properties to set custom bullet styles. While the context provided examples in C# and Java, the approach remains similar across different languages, including C++.

Here’s a general outline of how you can set custom bullets:

  1. Create a Presentation: Start by creating a new presentation instance.
  2. Add a Shape: Add an auto shape to the slide where you want to include the bullet points.
  3. Access the Text Frame: Get the text frame of the shape to manipulate the paragraphs.
  4. Add Paragraphs with Custom Bullets: For each paragraph, set the bullet type and customize it as needed.

Here’s a simplified example in C++:

#include <Aspose.Slides.h>
using namespace Aspose::Slides;

int main() {
    // Create a presentation instance
    SharedPtr<Presentation> presentation = MakeObject<Presentation>();

    // Add a shape to the first slide
    SharedPtr<IAutoShape> shape = presentation->get_Slides()->idx_get(0)->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 200, 200, 400, 200);
    
    // Access the text frame of the shape
    SharedPtr<ITextFrame> textFrame = shape->get_TextFrame();
    
    // Remove the default paragraph
    textFrame->get_Paragraphs()->RemoveAt(0);

    // Create a paragraph with a custom bullet
    SharedPtr<Paragraph> paragraph = MakeObject<Paragraph>();
    paragraph->set_Text(u"Custom Bullet Item");
    paragraph->get_ParagraphFormat()->get_Bullet()->set_Type(BulletType::Symbol);
    paragraph->get_ParagraphFormat()->get_Bullet()->set_Char(8226); // Unicode for bullet character
    paragraph->get_ParagraphFormat()->set_Indent(25);
    
    // Add the paragraph to the text frame
    textFrame->get_Paragraphs()->Add(paragraph);

    // Save the presentation
    presentation->Save(u"CustomBulletsPresentation.pptx", SaveFormat::Pptx);
    
    return 0;
}

In this example, a custom bullet is set using a specific character (in this case, a bullet character). You can adjust the bullet type and character as needed to create different styles.

For more detailed examples, you can refer to the C# and Java examples provided in the Aspose documentation, which illustrate how to set custom bullets and numbered lists effectively.

If you have further questions or need more specific examples, feel free to ask!

Can you provide sample code to extract custom bullet type?

This API paragraphFormat->get_Bullet()->get_Type() returns Not defined for custom bullets.

@pankajku,
In PowerPoint presentations, many shape and text properties can be inherited from parent objects when those properties are not explicitly set. Please try using the following API:
paragraphFormat->GetEffective()->get_Bullet()->get_Type()

More examples:
Shape Effective Properties|Aspose.Slides Documentation

Hi,
in powerpoint, we have a type of bullets called: Custom

bulletType = paragraphFormat->GetEffective()->get_Bullet()->get_Type()
bulletType is correctly fetched for bullets of type symbol and numbered.

However, for custom styled bullets, this api returns undefined.

Can you provide a fix for this?

@pankajku,
Unfortunately, I cannot answer your questions yet. Could you please share a sample presentation file?

text1 copy 10.pptx.zip (28.3 KB)

I have attached the zip of the sample presentation which uses custom bullets.

@pankajku,
Thank you for the sample presentation file. Custom bullets defined by PowerPoint are bullets configured using a font symbol (type Symbol) or an image (type Picture). They differ from predefined bullet styles only in that they are not listed among the predefined styles.

Unfortunately, custom bullets cannot be distinguished from predefined ones, as the presentation document does not contain any additional information that identifies them as custom.