Free Support Forum - aspose.com

BulletFormat type is NotDefined for some bullets (SOLVED)

EDIT: I found the solution (see reply). I’m leaving the thread here in case anyone else has the same issue (I could not find anything on the topic here).

I am trying to find out which text is part of a bullet list and which text is not. Currently I do something like this:

for(ISlide slide : pres.getSlides()){
    for( ITextFrame shape :  SlideUtil.getAllTextBoxes(slide)) {
        for(IParagraph para : shape.getParagraphs()) {
            IBulletFormat bullet = para.getParagraphFormat().getBullet();
            System.out.println(String.format("type: %d, depth: %d [%s]", bullet.getType(), para.getParagraphFormat().getDepth(), para.getText()));
        }
    }
}

I would assume I could detect bullets based on para.getParagraphFormat().getBullet().getType() but for some reason this gives me -1 for text without bullets and also -1 for text with the default bullet list style.

For example, this slide (screenshot):
https://imgur.com/a/rfvmDtj

Gives the output:

type: -1, depth: 0 [Slide 1]
type: -1, depth: 0 [Symbol1]
type: -1, depth: 0 [Symbol2]
type: -1, depth: 1 [Symbol3]
type: -1, depth: 0 []
type: -1, depth: 0 [No bullet]
type: 2, depth: 0 [Number1]
type: 2, depth: 0 [Number2]
type: 2, depth: 1 [Number3]
type: 0, depth: 0 []

As you can see, the slide title (“Slide 1”) and first bullets (“Symbol1”) can not be distinguished by using bullet type, as both are -1. However, it’s clear that one is a bullet is one is not. It does work for the numbered bullets further down the slide.

Is this the way to do it or is there another way to detect bullets?
I am using Aspose Slides for Java 18.7.

Thank your for your time,
Reinout

I found the solution. I was doing it wrong.
For anyone that finds this thread later, the solution is to create the ParagraphFormatEffectiveData object like so:

para.createParagraphFormatEffective().getBullet().getType()

I assume it has to do with the inheritance of properties from parent objects and ParagraphFormatEffectiveData cascades the properties and represents the final calculated properties of the paragraph, whereas getParagraphFormat does not take inherited properties into account.

@peanutman,

It is pleasant to hear that you have been able to resolve the issue on your end. Please share if I may help you any further in this regard.