Free Support Forum - aspose.com

Bullet style can not mix with other number style- like uppercase roman

Hi Support,

It seems like when the first level number style is bullet, the nested list level can not apply other number style, like uppercase roman, uppercase letter. But if the first level number style is number, then nested levels can mix with bullet and number styles.

I wonder it is a intention desgin or a defect. Please reference the below code section:

Thanks.

DocumentBuilder builder = new DocumentBuilder();
builder.writeln();
builder.getParagraphFormat().clearFormatting();

Style style = builder.getDocument().getStyles().get(“Normal”);
if (style != null)
{
builder.getParagraphFormat().setStyle(style);
}
builder.clearRunAttrs();

//it can not mix with other number style
builder.getListFormat().applyBulletDefault();

//it can mix with different number style
//builder.getListFormat().applyNumberDefault();
builder.write(“111”);
builder.clearRunAttrs();
builder.writeln();
builder.write(“2222”);

builder.clearRunAttrs();
builder.writeln();

builder.getListFormat().listIndent();
builder.getListFormat().getListLevel().setRestartAfterLevel(builder.getListFormat().getListLevelNumber()-1);
builder.getListFormat().getListLevel().setNumberStyle(NumberStyle.UPPERCASE_ROMAN);

builder.write(“aaa”);
builder.clearRunAttrs();
builder.writeln();
builder.write(“bbb”);
builder.clearRunAttrs();
builder.writeln();

builder.getListFormat().listIndent();
builder.getListFormat().getListLevel().setRestartAfterLevel(builder.getListFormat().getListLevelNumber()-1);
builder.getListFormat().getListLevel().setNumberStyle(NumberStyle.UPPERCASE_LETTER);
builder.write(“xxx”);
builder.clearRunAttrs();
builder.writeln();
builder.write(“yyy”);
builder.clearRunAttrs();
builder.writeln();

builder.getListFormat().listOutdent();

builder.getListFormat().listOutdent();
builder.write(“3333”);
builder.clearRunAttrs();

builder.getDocument().save(“c:\test.doc”);

Hi

Thanks for your request. Please see the following link to learn how to create and customized lists.

http://www.aspose.com/documentation/java-components/aspose.words-for-java/com/aspose/words/listlevel.html#NumberFormat

Also, please see the following code:

// Create new document and Documentbuilder.

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

// Create new list and configure the first 3 levels of the list.

com.aspose.words.List list = doc.getLists().add(ListTemplate.NUMBER_DEFAULT);

// Configure the first level.

list.getListLevels().get(0).getFont().setName("Symbol");

list.getListLevels().get(0).setNumberStyle(NumberStyle.BULLET);

list.getListLevels().get(0).setNumberFormat("\u00B7"); // This is a bullet.

// Configure the second level.

list.getListLevels().get(1).setNumberStyle(NumberStyle.ARABIC);

list.getListLevels().get(1).setNumberFormat("\u0001."); // This is a number of the second level.

// Configure the third level.

list.getListLevels().get(2).setNumberStyle(NumberStyle.LOWERCASE_LETTER);

list.getListLevels().get(2).setNumberFormat("\u0002."); // This is a number of the third level.

// insert content into the document using DocumentBuilder.

builder.getListFormat().setList(list);

builder.writeln("test");

builder.writeln("test");

// Move to the next level.

builder.getListFormat().listIndent();

builder.writeln("test");

builder.writeln("test");

// Move to the next level.

builder.getListFormat().listIndent();

builder.writeln("test");

builder.writeln("test");

// Move to the previous level.

builder.getListFormat().listOutdent();

builder.writeln("test");

builder.writeln("test");

// Move to the previous level.

builder.getListFormat().listOutdent();

builder.writeln("test");

builder.writeln("test");

// Save output.

doc.save("C:\\Temp\\out.docx");

Hope this helps.

Best regards,

  1. For you code, if change one line from:
    com.aspose.words.List list = doc.getLists().add(ListTemplate.NUMBER_DEFAULT);
    to:
    com.aspose.words.List list = doc.getLists().add(ListTemplate.BULLET_DEFAULT);

    the generated document has errors for the third list level.

    2. For my code, if change from:
    //it can not mix with other number style
    builder.getListFormat().applyBulletDefault();
    to:
    //it can mix with different number style
    builder.getListFormat().applyNumberDefault();

    The generated document is my expectation.

    So, please explain why for above two points, also, please answer my first question.

    Thank you.

Hi

Thanks for your request. I do not think this is a defect, I think this is some restriction in using bulleted lists. Probably numbered lists are more common than bulleted. So there are more customization options for these lists.

Best regards,