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 specify list level number when building a list using DocumentBuilder.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Create a numbered list based on one of the Microsoft Word list templates and
// apply it to the current paragraph in the document builder
builder.getListFormat().setList(doc.getLists().add(ListTemplate.NUMBER_ARABIC_DOT));

// Insert text at each of the 9 indent levels
for (int i = 0; i < 9; i++) {
    builder.getListFormat().setListLevelNumber(i);
    builder.writeln("Level " + i);
}

// Create a bulleted list based on one of the Microsoft Word list templates
// and apply it to the current paragraph in the document builder
builder.getListFormat().setList(doc.getLists().add(ListTemplate.BULLET_DIAMONDS));

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

// This is a way to stop list formatting
builder.getListFormat().setList(null);

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

Example:

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

// Create a list based on a template
List list1 = doc.getLists().add(ListTemplate.NUMBER_ARABIC_PARENTHESIS);
// Modify the formatting of the list
list1.getListLevels().get(0).getFont().setColor(Color.RED);
list1.getListLevels().get(0).setAlignment(ListLevelAlignment.RIGHT);

builder.writeln("List 1 starts below:");
// Use the first list in the document for a while
builder.getListFormat().setList(list1);
builder.writeln("Item 1");
builder.writeln("Item 2");
builder.getListFormat().removeNumbers();

// Now I want to reuse the first list, but need to restart numbering
// This should be done by creating a copy of the original list formatting
List list2 = doc.getLists().addCopy(list1);

// We can modify the new list in any way. Including setting new start number
list2.getListLevels().get(0).setStartAt(10);

// Use the second list in the document
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 create a document that demonstrates all outline headings list templates.
public void outlineHeadingTemplates() throws Exception {
    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 " + Integer.toString((i + 1));
        builder.getParagraphFormat().setStyleName(styleName);
        builder.writeln(styleName);
    }

    builder.getListFormat().removeNumbers();
}

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, lowecase 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, lowecase 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.