Paragraph style numbering

Hi support,

I’ve created a paragraph style, and had associated a numbering format like " style1.getListFormat().getListLevel().setNumberFormat("\u0000"); " , and then created another paragraph style with the number format : “\u0000.\u0001”. I’ve used those styles in a document generated with java, and found that the 2nd style numbering isn’t related to the 1st style numbering, and 2nd style numbering increments the first index, not the second one, as expected. Shouldn’t Aspose.Words handle this numbering process, or should I do specifications like the relation between those styles, the way that they should count etc ?

Thank you,
Milan Cutlac

Hi
Thanks for your request. I think that you can use DocumentBuilder to create multilevel list. For example see the following code:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.getListFormat().applyNumberDefault();
builder.getListFormat().getListLevel().setNumberFormat("\u0000");
builder.writeln("Item1");
builder.writeln("Item2");
builder.getListFormat().listIndent();
builder.getListFormat().getListLevel().setNumberFormat("\u0000.\u0001");
builder.writeln("Item2.1");
builder.writeln("Item2.2");
builder.getListFormat().listOutdent();
builder.writeln("Item3");
doc.save("out.doc");

Best regards.

Hi Alexey,

I knew the topic about multilevel list, but in Word you can specify the numbering for a style, so this is what I’m pointing to.
My code is trying to obtain that, but I’m doing something wrong, or Aspose doesn’t know how to deal correctly with style numbering.

Any suggestions ?

Thank you,
Milan Cutlac

Hi
Thanks for your request. Could you please provide me your code?
Best regards.

Hi,

I’ve attached a test that should put level1 and level2 numberings on four paragraphs that have two styles. In my output, it can be seened the numbering like this : 1; 2; 1.0; 2.0 and not 1; 2; 2.1; 2.2 as expected. I’m using Word 2003.
The numberings for level 2 and greater, in Word 2007, are not displayed at all, but I saw there is a topic on this that can be eloquent about, related to a multilevel list that seems to lose its numberings on 2007’s Word.

Thank you for looking into this,
Milan

Hi
Thank you for additional information. I modified your code and now it works fine. See the following code:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Create a paragraph style and specify some formatting for it.
Style style1 = doc.getStyles().add(StyleType.PARAGRAPH, "MyStyle1");
style1.getFont().setSize(18);
style1.getFont().setName("Verdana");
style1.getParagraphFormat().setSpaceAfter(12);
style1.getListFormat().setList(doc.getLists().add(ListTemplate.NUMBER_ARABIC_DOT));
style1.getListFormat().getListLevel().setNumberStyle(NumberStyle.ARABIC);
style1.getListFormat().getListLevel().setNumberFormat("\u0000");
// Apply the paragraph style to the current paragraph in the document and add some text.
builder.getParagraphFormat().setStyle(style1);
builder.writeln("Hello World1: MyStyle1");
builder.writeln("Hello World2: MyStyle1");
List lst = builder.getListFormat().getList();
// Create a paragraph style and specify some formatting for it.
Style style2 = doc.getStyles().add(StyleType.PARAGRAPH, "MyStyle2");
style2.getFont().setSize(15);
style2.getFont().setName("Arial");
style2.getListFormat().setListLevelNumber(1);
style2.getListFormat().setList(lst);
style2.getListFormat().getListLevel().setNumberStyle(NumberStyle.ARABIC);
style2.getListFormat().getListLevel().setNumberFormat("\u0000.\u0001");
// Apply the paragraph style to the current paragraph in the document and add some text.
builder.getParagraphFormat().setStyle(style2);
builder.writeln("Hello World1: MyStyle2");
builder.writeln("Hello World2: MyStyle2");
// Change to a paragraph style that has no list formatting.
builder.getParagraphFormat().setStyle(doc.getStyles().get("Normal"));
doc.save("out.doc");

Hope this helps.
Best regards.

Your modification helped for this particular case, but it didn’t resolved the link between the numberings in a full manner. Thus, if you will supply with some paragraphs with MyStyle1 and then some paragraphs with MyStyle2, in our test, you will note that the output has the following numbering :
1.
2.
2.1
2.2
3
3.3
3.4
, and not
1.
2.
2.1
2.2
3
3.1
3.2

Milan

Hi
Thanks for your request. Just missed one line in code:

// Create a paragraph style and specify some formatting for it.
Style style2 = doc.getStyles().add(StyleType.PARAGRAPH, "MyStyle2");
style2.getFont().setSize(15);
style2.getFont().setName("Arial");
style2.getListFormat().setList(lst);
style2.getListFormat().setListLevelNumber(1);
style2.getListFormat().getListLevel().isRestartAfterHigher(true);
style2.getListFormat().getListLevel().setNumberStyle(NumberStyle.ARABIC);
style2.getListFormat().getListLevel().setNumberFormat("\u0000.\u0001");

Best regards.

Thank you, it worked. I’ve insisted on this to get the best approach.
Best regards,
Milan