java.lang.Objectcom.aspose.words.ListLevelCollection
public class ListLevelCollection
Example: Example:
Document doc = new Document();
// Create a list based on one of the Microsoft Word list templates.
List list = doc.getLists().add(ListTemplate.NUMBER_DEFAULT);
// Completely customize one list level.
ListLevel level1 = list.getListLevels().get(0);
level1.getFont().setColor(Color.RED);
level1.getFont().setSize(24);
level1.setNumberStyle(NumberStyle.ORDINAL_TEXT);
level1.setStartAt(21);
level1.setNumberFormat("\u0000");
level1.setNumberPosition(-36);
level1.setTextPosition(144);
level1.setTabPosition(144);
// Completely customize yet another list level.
ListLevel level2 = list.getListLevels().get(1);
level2.setAlignment(ListLevelAlignment.RIGHT);
level2.setNumberStyle(NumberStyle.BULLET);
level2.getFont().setName("Wingdings");
level2.getFont().setColor(Color.BLUE);
level2.getFont().setSize(24);
level2.setNumberFormat("\uf0af"); // A bullet that looks like some sort of a star.
level2.setTrailingCharacter(ListTrailingCharacter.SPACE);
level2.setNumberPosition(144);
// Now add some text that uses the list that we created.
// It does not matter when to customize the list - before or after adding the paragraphs.
DocumentBuilder builder = new DocumentBuilder(doc);
builder.getListFormat().setList(list);
builder.writeln("The quick brown fox...");
builder.writeln("The quick brown fox...");
builder.getListFormat().listIndent();
builder.writeln("jumped over the lazy dog.");
builder.writeln("jumped over the lazy dog.");
builder.getListFormat().listOutdent();
builder.writeln("The quick brown fox...");
builder.getListFormat().removeNumbers();
builder.getDocument().save(getMyDir() + "Lists.CreateCustomList Out.doc");
Document doc = new Document();
// Create a new list style.
// List formatting associated with this list style is default numbered.
Style listStyle = doc.getStyles().add(StyleType.LIST, "MyListStyle");
// This list defines the formatting of the list style.
// Note this list can not be used directly to apply formatting to paragraphs (see below).
List list1 = listStyle.getList();
// Check some basic rules about the list that defines a list style.
System.out.println("IsListStyle: " + list1.isListStyleDefinition()); // Will be true
System.out.println("IsListStyleReference: " + list1.isListStyleReference()); // Will be false
System.out.println("IsMultiLevel: " + list1.isMultiLevel()); // Will be true
System.out.println("List style has been set: " + (listStyle == list1.getStyle())); // Are equal
// Modify formatting of the list style to our liking.
for (int i = 0; i < list1.getListLevels().getCount(); i++)
{
ListLevel level = list1.getListLevels().get(i);
level.getFont().setName("Verdana");
level.getFont().setColor(Color.BLUE);
level.getFont().setBold(true);
}
// Add some text to our document and use the list style.
DocumentBuilder builder = new DocumentBuilder(doc);
builder.writeln("Using list style first time:");
// This creates a list based on the list style.
List list2 = doc.getLists().add(listStyle);
// Check some basic rules about the list that references a list style.
System.out.println("IsListStyleDefinition: " + list2.isListStyleDefinition()); // Will be false
System.out.println("IsListStyleReference: " + list2.isListStyleReference()); // Will be true
System.out.println("List Style has been set: " + (listStyle == list2.getStyle())); // Are equal
// Apply the list that references the list style.
builder.getListFormat().setList(list2);
builder.writeln("Item 1");
builder.writeln("Item 2");
builder.getListFormat().removeNumbers();
builder.writeln("Using list style second time:");
// Create and apply another list based on the list style.
List list3 = doc.getLists().add(listStyle);
builder.getListFormat().setList(list3);
builder.writeln("Item 1");
builder.writeln("Item 2");
builder.getListFormat().removeNumbers();
builder.getDocument().save(getMyDir() + "Lists.CreateAndUseListStyle Out.doc");
Property Getters/Setters Summary | ||
---|---|---|
int | getCount() | |
Gets the number of levels in this list. | ||
ListLevel | get(int index) | |
void | set(int index, ListLevel value) | |
Gets a list level by index. |
Property Getters/Setters Detail |
---|
getCount | |
public int getCount() |
There could be 1 or 9 levels in a list.
Example:
Shows how to create a list style and use it in a document.Document doc = new Document(); // Create a new list style. // List formatting associated with this list style is default numbered. Style listStyle = doc.getStyles().add(StyleType.LIST, "MyListStyle"); // This list defines the formatting of the list style. // Note this list can not be used directly to apply formatting to paragraphs (see below). List list1 = listStyle.getList(); // Check some basic rules about the list that defines a list style. System.out.println("IsListStyle: " + list1.isListStyleDefinition()); // Will be true System.out.println("IsListStyleReference: " + list1.isListStyleReference()); // Will be false System.out.println("IsMultiLevel: " + list1.isMultiLevel()); // Will be true System.out.println("List style has been set: " + (listStyle == list1.getStyle())); // Are equal // Modify formatting of the list style to our liking. for (int i = 0; i < list1.getListLevels().getCount(); i++) { ListLevel level = list1.getListLevels().get(i); level.getFont().setName("Verdana"); level.getFont().setColor(Color.BLUE); level.getFont().setBold(true); } // Add some text to our document and use the list style. DocumentBuilder builder = new DocumentBuilder(doc); builder.writeln("Using list style first time:"); // This creates a list based on the list style. List list2 = doc.getLists().add(listStyle); // Check some basic rules about the list that references a list style. System.out.println("IsListStyleDefinition: " + list2.isListStyleDefinition()); // Will be false System.out.println("IsListStyleReference: " + list2.isListStyleReference()); // Will be true System.out.println("List Style has been set: " + (listStyle == list2.getStyle())); // Are equal // Apply the list that references the list style. builder.getListFormat().setList(list2); builder.writeln("Item 1"); builder.writeln("Item 2"); builder.getListFormat().removeNumbers(); builder.writeln("Using list style second time:"); // Create and apply another list based on the list style. List list3 = doc.getLists().add(listStyle); builder.getListFormat().setList(list3); builder.writeln("Item 1"); builder.writeln("Item 2"); builder.getListFormat().removeNumbers(); builder.getDocument().save(getMyDir() + "Lists.CreateAndUseListStyle Out.doc");
get/set | |
public ListLevel get(int index) / public void set(int index, ListLevel value) |
Example:
Shows how to create a list style and use it in a document.Document doc = new Document(); // Create a new list style. // List formatting associated with this list style is default numbered. Style listStyle = doc.getStyles().add(StyleType.LIST, "MyListStyle"); // This list defines the formatting of the list style. // Note this list can not be used directly to apply formatting to paragraphs (see below). List list1 = listStyle.getList(); // Check some basic rules about the list that defines a list style. System.out.println("IsListStyle: " + list1.isListStyleDefinition()); // Will be true System.out.println("IsListStyleReference: " + list1.isListStyleReference()); // Will be false System.out.println("IsMultiLevel: " + list1.isMultiLevel()); // Will be true System.out.println("List style has been set: " + (listStyle == list1.getStyle())); // Are equal // Modify formatting of the list style to our liking. for (int i = 0; i < list1.getListLevels().getCount(); i++) { ListLevel level = list1.getListLevels().get(i); level.getFont().setName("Verdana"); level.getFont().setColor(Color.BLUE); level.getFont().setBold(true); } // Add some text to our document and use the list style. DocumentBuilder builder = new DocumentBuilder(doc); builder.writeln("Using list style first time:"); // This creates a list based on the list style. List list2 = doc.getLists().add(listStyle); // Check some basic rules about the list that references a list style. System.out.println("IsListStyleDefinition: " + list2.isListStyleDefinition()); // Will be false System.out.println("IsListStyleReference: " + list2.isListStyleReference()); // Will be true System.out.println("List Style has been set: " + (listStyle == list2.getStyle())); // Are equal // Apply the list that references the list style. builder.getListFormat().setList(list2); builder.writeln("Item 1"); builder.writeln("Item 2"); builder.getListFormat().removeNumbers(); builder.writeln("Using list style second time:"); // Create and apply another list based on the list style. List list3 = doc.getLists().add(listStyle); builder.getListFormat().setList(list3); builder.writeln("Item 1"); builder.writeln("Item 2"); builder.getListFormat().removeNumbers(); builder.getDocument().save(getMyDir() + "Lists.CreateAndUseListStyle Out.doc");
Example:
Shows how to apply custom list formatting to paragraphs when using DocumentBuilder.Document doc = new Document(); // Create a list based on one of the Microsoft Word list templates. List list = doc.getLists().add(ListTemplate.NUMBER_DEFAULT); // Completely customize one list level. ListLevel level1 = list.getListLevels().get(0); level1.getFont().setColor(Color.RED); level1.getFont().setSize(24); level1.setNumberStyle(NumberStyle.ORDINAL_TEXT); level1.setStartAt(21); level1.setNumberFormat("\u0000"); level1.setNumberPosition(-36); level1.setTextPosition(144); level1.setTabPosition(144); // Completely customize yet another list level. ListLevel level2 = list.getListLevels().get(1); level2.setAlignment(ListLevelAlignment.RIGHT); level2.setNumberStyle(NumberStyle.BULLET); level2.getFont().setName("Wingdings"); level2.getFont().setColor(Color.BLUE); level2.getFont().setSize(24); level2.setNumberFormat("\uf0af"); // A bullet that looks like some sort of a star. level2.setTrailingCharacter(ListTrailingCharacter.SPACE); level2.setNumberPosition(144); // Now add some text that uses the list that we created. // It does not matter when to customize the list - before or after adding the paragraphs. DocumentBuilder builder = new DocumentBuilder(doc); builder.getListFormat().setList(list); builder.writeln("The quick brown fox..."); builder.writeln("The quick brown fox..."); builder.getListFormat().listIndent(); builder.writeln("jumped over the lazy dog."); builder.writeln("jumped over the lazy dog."); builder.getListFormat().listOutdent(); builder.writeln("The quick brown fox..."); builder.getListFormat().removeNumbers(); builder.getDocument().save(getMyDir() + "Lists.CreateCustomList Out.doc");