com.aspose.words

Class ListTemplate

  • java.lang.Object
    • com.aspose.words.ListTemplate
public class ListTemplate 
extends java.lang.Object

Utility class containing constants. Specifies one of the predefined list formats available in Microsoft Word.

A list template value is used as a parameter into the ListCollection.add(int) method.

Aspose.Words list templates correspond to the 21 list templates available in the Bullets and Numbering dialog box in Microsoft Word 2003.

Example:

Shows how to create a document that contains all outline headings list templates.
Document doc = new Document();
    DocumentBuilder builder = new DocumentBuilder(doc);

    List list = doc.getLists().add(ListTemplate.OUTLINE_HEADINGS_ARTICLE_SECTION);
    addOutlineHeadingParagraphs(builder, list, "Aspose.Words Outline - \"Article Section\"");

    list = doc.getLists().add(ListTemplate.OUTLINE_HEADINGS_LEGAL);
    addOutlineHeadingParagraphs(builder, list, "Aspose.Words Outline - \"Legal\"");

    builder.insertBreak(BreakType.PAGE_BREAK);

    list = doc.getLists().add(ListTemplate.OUTLINE_HEADINGS_NUMBERS);
    addOutlineHeadingParagraphs(builder, list, "Aspose.Words Outline - \"Numbers\"");

    list = doc.getLists().add(ListTemplate.OUTLINE_HEADINGS_CHAPTER);
    addOutlineHeadingParagraphs(builder, list, "Aspose.Words Outline - \"Chapters\"");

    doc.save(getArtifactsDir() + "Lists.OutlineHeadingTemplates.docx");

private static void addOutlineHeadingParagraphs(final DocumentBuilder builder, final List list, final String title) {
    builder.getParagraphFormat().clearFormatting();
    builder.writeln(title);

    for (int i = 0; i < 9; i++) {
        builder.getListFormat().setList(list);
        builder.getListFormat().setListLevelNumber(i);

        String styleName = "Heading " + (i + 1);
        builder.getParagraphFormat().setStyleName(styleName);
        builder.writeln(styleName);
    }

    builder.getListFormat().removeNumbers();
}

Example:

Shows how to restart numbering in a list by copying a list.
Document doc = new Document();

// A list allows us to organize and decorate sets of paragraphs with prefix symbols and indents.
// We can create nested lists by increasing the indent level. 
// We can begin and end a list by using a document builder's "ListFormat" property. 
// Each paragraph that we add between a list's start and the end will become an item in the list.
// Create a list from a Microsoft Word template, and customize its first list level.
List list1 = doc.getLists().add(ListTemplate.NUMBER_ARABIC_PARENTHESIS);
list1.getListLevels().get(0).getFont().setColor(Color.RED);
list1.getListLevels().get(0).setAlignment(ListLevelAlignment.RIGHT);

// Apply our list to some paragraphs.
DocumentBuilder builder = new DocumentBuilder(doc);

builder.writeln("List 1 starts below:");
builder.getListFormat().setList(list1);
builder.writeln("Item 1");
builder.writeln("Item 2");
builder.getListFormat().removeNumbers();

// We can add a copy of an existing list to the document's list collection
// to create a similar list without making changes to the original.
List list2 = doc.getLists().addCopy(list1);
list2.getListLevels().get(0).getFont().setColor(Color.BLUE);
list2.getListLevels().get(0).setStartAt(10);

// Apply the second list to new paragraphs.
builder.writeln("List 2 starts below:");
builder.getListFormat().setList(list2);
builder.writeln("Item 1");
builder.writeln("Item 2");
builder.getListFormat().removeNumbers();

doc.save(getArtifactsDir() + "Lists.RestartNumberingUsingListCopy.docx");

Example:

Shows how to work with list levels.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Assert.assertFalse(builder.getListFormat().isListItem());

// A list allows us to organize and decorate sets of paragraphs with prefix symbols and indents.
// We can create nested lists by increasing the indent level. 
// We can begin and end a list by using a document builder's "ListFormat" property. 
// Each paragraph that we add between a list's start and the end will become an item in the list.
// Below are two types of lists that we can create using a document builder.
// 1 -  A numbered list:
// Numbered lists create a logical order for their paragraphs by numbering each item.
builder.getListFormat().setList(doc.getLists().add(ListTemplate.NUMBER_DEFAULT));

Assert.assertTrue(builder.getListFormat().isListItem());

// By setting the "ListLevelNumber" property, we can increase the list level
// to begin a self-contained sub-list at the current list item.
// The Microsoft Word list template called "NumberDefault" uses numbers to create list levels for the first list level.
// Deeper list levels use letters and lowercase Roman numerals. 
for (int i = 0; i < 9; i++) {
    builder.getListFormat().setListLevelNumber(i);
    builder.writeln("Level " + i);
}

// 2 -  A bulleted list:
// This list will apply an indent and a bullet symbol ("�") before each paragraph.
// Deeper levels of this list will use different symbols, such as "�" and "?".
builder.getListFormat().setList(doc.getLists().add(ListTemplate.BULLET_DEFAULT));

for (int i = 0; i < 9; i++) {
    builder.getListFormat().setListLevelNumber(i);
    builder.writeln("Level " + i);
}

// We can disable list formatting to not format any subsequent paragraphs as lists by un-setting the "List" flag.
builder.getListFormat().setList(null);

Assert.assertFalse(builder.getListFormat().isListItem());

doc.save(getArtifactsDir() + "Lists.SpecifyListLevel.docx");

Field Summary
static final intBULLET_DEFAULT = 0

Default bulleted list with 9 levels. Bullet of the first level is a disc, bullet of the second level is a circle, bullet of the third level is a square. Then formatting repeats for the remaining levels.

Each level is indented to the right by 0.25" relative to the previous level.

Corresponds to the 1st bulleted list template in the Bullets and Numbering dialog box in Microsoft Word.

static final intBULLET_DISK = 0

Same as BulletDefault.

Corresponds to the 1st bulleted list template in the Bullets and Numbering dialog box in Microsoft Word.

static final intBULLET_CIRCLE = 1

The bullet of the first level is a circle. The remaining levels are same as in BulletDefault.

Corresponds to the 2nd bulleted list template in the Bullets and Numbering dialog box in Microsoft Word.

static final intBULLET_SQUARE = 2

The bullet of the first level is a square. The remaining levels are same as in BulletDefault.

Corresponds to the 3rd bulleted list template in the Bullets and Numbering dialog box in Microsoft Word.

static final intBULLET_DIAMONDS = 3

The bullet of the first level is a 4-diamond Wingding character. The remaining levels are same as in BulletDefault.

Corresponds to the 5th bulleted list template in the Bullets and Numbering dialog box in Microsoft Word.

static final intBULLET_ARROW_HEAD = 4

The bullet of the first level is an arrow head Wingding character. The remaining levels are same as in BulletDefault.

Corresponds to the 6th bulleted list template in the Bullets and Numbering dialog box in Microsoft Word.

static final intBULLET_TICK = 5

The bullet of the first level is a tick Wingding character. The remaining levels are same as in BulletDefault.

Corresponds to the 7th bulleted list template in the Bullets and Numbering dialog box in Microsoft Word.

static final intNUMBER_DEFAULT = 6

Default numbered list with 9 levels. Arabic numbering (1., 2., 3., ...) for the first level, lowercase letter numbering (a., b., c., ...) for the second level, lowercase roman numbering (i., ii., iii., ...) for the third level. Then formatting repeats for the remaining levels.

Each level is indented to the right by 0.25" relative to the previous level.

Corresponds to the 1st numbered list template in the Bullets and Numbering dialog box in Microsoft Word.

static final intNUMBER_ARABIC_DOT = 6

Same as NumberDefault.

Corresponds to the 1st numbered list template in the Bullets and Numbering dialog box in Microsoft Word.

static final intNUMBER_ARABIC_PARENTHESIS = 7

The number of the first level is "1)". The remaining levels are same as in NumberDefault.

Corresponds to the 2nd numbered list template in the Bullets and Numbering dialog box in Microsoft Word.

static final intNUMBER_UPPERCASE_ROMAN_DOT = 8

The number of the first level is "I.". The remaining levels are same as in NumberDefault.

Corresponds to the 3rd numbered list template in the Bullets and Numbering dialog box in Microsoft Word.

static final intNUMBER_UPPERCASE_LETTER_DOT = 9

The number of the first level is "A.". The remaining levels are same as in NumberDefault.

Corresponds to the 4th numbered list template in the Bullets and Numbering dialog box in Microsoft Word.

static final intNUMBER_LOWERCASE_LETTER_PARENTHESIS = 10

The number of the first level is "a)". The remaining levels are same as in NumberDefault.

Corresponds to the 5th numbered list template in the Bullets and Numbering dialog box in Microsoft Word.

static final intNUMBER_LOWERCASE_LETTER_DOT = 11

The number of the first level is "a.". The remaining levels are same as in NumberDefault.

Corresponds to the 6th numbered list template in the Bullets and Numbering dialog box in Microsoft Word.

static final intNUMBER_LOWERCASE_ROMAN_DOT = 12

The number of the first level is "i.". The remaining levels are same as in NumberDefault.

Corresponds to the 7th numbered list template in the Bullets and Numbering dialog box in Microsoft Word.

static final intOUTLINE_NUMBERS = 13

An outline list with levels numbered "1), a), i), (1), (a), (i), 1., a., i.".

Corresponds to the 1st outline list template in the Bullets and Numbering dialog box in Microsoft Word.

static final intOUTLINE_LEGAL = 14

An outline list with levels are numbered "1., 1.1., 1.1.1, ...".

Corresponds to the 2nd outline list template in the Bullets and Numbering dialog box in Microsoft Word.

static final intOUTLINE_BULLETS = 15

An outline lists with various bullets for different levels.

Corresponds to the 3rd outline list template in the Bullets and Numbering dialog box in Microsoft Word.

static final intOUTLINE_HEADINGS_ARTICLE_SECTION = 16

An outline list with levels linked to Heading styles.

Corresponds to the 4th outline list template in the Bullets and Numbering dialog box in Microsoft Word.

static final intOUTLINE_HEADINGS_LEGAL = 17

An outline list with levels linked to Heading styles.

Corresponds to the 5th outline list template in the Bullets and Numbering dialog box in Microsoft Word.

static final intOUTLINE_HEADINGS_NUMBERS = 18

An outline list with levels linked to Heading styles.

Corresponds to the 6th outline list template in the Bullets and Numbering dialog box in Microsoft Word.

static final intOUTLINE_HEADINGS_CHAPTER = 19

An outline list with levels linked to Heading styles.

Corresponds to the 7th outline list template in the Bullets and Numbering dialog box in Microsoft Word.

 

    • Field Detail

      • BULLET_DEFAULT = 0

        public static final int BULLET_DEFAULT

        Default bulleted list with 9 levels. Bullet of the first level is a disc, bullet of the second level is a circle, bullet of the third level is a square. Then formatting repeats for the remaining levels.

        Each level is indented to the right by 0.25" relative to the previous level.

        Corresponds to the 1st bulleted list template in the Bullets and Numbering dialog box in Microsoft Word.

      • BULLET_DISK = 0

        public static final int BULLET_DISK

        Same as BulletDefault.

        Corresponds to the 1st bulleted list template in the Bullets and Numbering dialog box in Microsoft Word.

      • BULLET_CIRCLE = 1

        public static final int BULLET_CIRCLE

        The bullet of the first level is a circle. The remaining levels are same as in BulletDefault.

        Corresponds to the 2nd bulleted list template in the Bullets and Numbering dialog box in Microsoft Word.

      • BULLET_SQUARE = 2

        public static final int BULLET_SQUARE

        The bullet of the first level is a square. The remaining levels are same as in BulletDefault.

        Corresponds to the 3rd bulleted list template in the Bullets and Numbering dialog box in Microsoft Word.

      • BULLET_DIAMONDS = 3

        public static final int BULLET_DIAMONDS

        The bullet of the first level is a 4-diamond Wingding character. The remaining levels are same as in BulletDefault.

        Corresponds to the 5th bulleted list template in the Bullets and Numbering dialog box in Microsoft Word.

      • BULLET_ARROW_HEAD = 4

        public static final int BULLET_ARROW_HEAD

        The bullet of the first level is an arrow head Wingding character. The remaining levels are same as in BulletDefault.

        Corresponds to the 6th bulleted list template in the Bullets and Numbering dialog box in Microsoft Word.

      • BULLET_TICK = 5

        public static final int BULLET_TICK

        The bullet of the first level is a tick Wingding character. The remaining levels are same as in BulletDefault.

        Corresponds to the 7th bulleted list template in the Bullets and Numbering dialog box in Microsoft Word.

      • NUMBER_DEFAULT = 6

        public static final int NUMBER_DEFAULT

        Default numbered list with 9 levels. Arabic numbering (1., 2., 3., ...) for the first level, lowercase letter numbering (a., b., c., ...) for the second level, lowercase roman numbering (i., ii., iii., ...) for the third level. Then formatting repeats for the remaining levels.

        Each level is indented to the right by 0.25" relative to the previous level.

        Corresponds to the 1st numbered list template in the Bullets and Numbering dialog box in Microsoft Word.

      • NUMBER_ARABIC_DOT = 6

        public static final int NUMBER_ARABIC_DOT

        Same as NumberDefault.

        Corresponds to the 1st numbered list template in the Bullets and Numbering dialog box in Microsoft Word.

      • NUMBER_ARABIC_PARENTHESIS = 7

        public static final int NUMBER_ARABIC_PARENTHESIS

        The number of the first level is "1)". The remaining levels are same as in NumberDefault.

        Corresponds to the 2nd numbered list template in the Bullets and Numbering dialog box in Microsoft Word.

      • NUMBER_UPPERCASE_ROMAN_DOT = 8

        public static final int NUMBER_UPPERCASE_ROMAN_DOT

        The number of the first level is "I.". The remaining levels are same as in NumberDefault.

        Corresponds to the 3rd numbered list template in the Bullets and Numbering dialog box in Microsoft Word.

      • NUMBER_UPPERCASE_LETTER_DOT = 9

        public static final int NUMBER_UPPERCASE_LETTER_DOT

        The number of the first level is "A.". The remaining levels are same as in NumberDefault.

        Corresponds to the 4th numbered list template in the Bullets and Numbering dialog box in Microsoft Word.

      • NUMBER_LOWERCASE_LETTER_PARENTHESIS = 10

        public static final int NUMBER_LOWERCASE_LETTER_PARENTHESIS

        The number of the first level is "a)". The remaining levels are same as in NumberDefault.

        Corresponds to the 5th numbered list template in the Bullets and Numbering dialog box in Microsoft Word.

      • NUMBER_LOWERCASE_LETTER_DOT = 11

        public static final int NUMBER_LOWERCASE_LETTER_DOT

        The number of the first level is "a.". The remaining levels are same as in NumberDefault.

        Corresponds to the 6th numbered list template in the Bullets and Numbering dialog box in Microsoft Word.

      • NUMBER_LOWERCASE_ROMAN_DOT = 12

        public static final int NUMBER_LOWERCASE_ROMAN_DOT

        The number of the first level is "i.". The remaining levels are same as in NumberDefault.

        Corresponds to the 7th numbered list template in the Bullets and Numbering dialog box in Microsoft Word.

      • OUTLINE_NUMBERS = 13

        public static final int OUTLINE_NUMBERS

        An outline list with levels numbered "1), a), i), (1), (a), (i), 1., a., i.".

        Corresponds to the 1st outline list template in the Bullets and Numbering dialog box in Microsoft Word.

      • OUTLINE_LEGAL = 14

        public static final int OUTLINE_LEGAL

        An outline list with levels are numbered "1., 1.1., 1.1.1, ...".

        Corresponds to the 2nd outline list template in the Bullets and Numbering dialog box in Microsoft Word.

      • OUTLINE_BULLETS = 15

        public static final int OUTLINE_BULLETS

        An outline lists with various bullets for different levels.

        Corresponds to the 3rd outline list template in the Bullets and Numbering dialog box in Microsoft Word.

      • OUTLINE_HEADINGS_ARTICLE_SECTION = 16

        public static final int OUTLINE_HEADINGS_ARTICLE_SECTION

        An outline list with levels linked to Heading styles.

        Corresponds to the 4th outline list template in the Bullets and Numbering dialog box in Microsoft Word.

      • OUTLINE_HEADINGS_LEGAL = 17

        public static final int OUTLINE_HEADINGS_LEGAL

        An outline list with levels linked to Heading styles.

        Corresponds to the 5th outline list template in the Bullets and Numbering dialog box in Microsoft Word.

      • OUTLINE_HEADINGS_NUMBERS = 18

        public static final int OUTLINE_HEADINGS_NUMBERS

        An outline list with levels linked to Heading styles.

        Corresponds to the 6th outline list template in the Bullets and Numbering dialog box in Microsoft Word.

      • OUTLINE_HEADINGS_CHAPTER = 19

        public static final int OUTLINE_HEADINGS_CHAPTER

        An outline list with levels linked to Heading styles.

        Corresponds to the 7th outline list template in the Bullets and Numbering dialog box in Microsoft Word.