java.lang.Objectcom.aspose.words.ListLevel
public class ListLevel
You do not create objects of this class. List level objects are created automatically
when a list is created. You access Use the properties of Example:
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 the first two of its list levels.
List list = doc.getLists().add(ListTemplate.NUMBER_DEFAULT);
ListLevel listLevel = list.getListLevels().get(0);
listLevel.getFont().setColor(Color.RED);
listLevel.getFont().setSize(24.0);
listLevel.setNumberStyle(NumberStyle.ORDINAL_TEXT);
listLevel.setStartAt(21);
listLevel.setNumberFormat("\u0000");
listLevel.setNumberPosition(-36);
listLevel.setTextPosition(144.0);
listLevel.setTabPosition(144.0);
listLevel = list.getListLevels().get(1);
listLevel.setAlignment(ListLevelAlignment.RIGHT);
listLevel.setNumberStyle(NumberStyle.BULLET);
listLevel.getFont().setName("Wingdings");
listLevel.getFont().setColor(Color.BLUE);
listLevel.getFont().setSize(24.0);
// This NumberFormat value will create star-shaped bullet list symbols.
listLevel.setNumberFormat("\uf0af");
listLevel.setTrailingCharacter(ListTrailingCharacter.SPACE);
listLevel.setNumberPosition(144.0);
// Create paragraphs and apply both list levels of our custom list formatting to them.
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(getArtifactsDir() + "Lists.CreateCustomList.docx");
Property Getters/Setters Summary | ||
---|---|---|
int | getAlignment() | |
void | setAlignment(int value) | |
Gets or sets the justification of the actual number of the list item. The value of the property is ListLevelAlignment integer constant. | ||
java.lang.String | getCustomNumberStyleFormat() | |
Gets the custom number style format for this list level. For example: "a, ç, ĝ, ...". | ||
Font | getFont() | |
Specifies character formatting used for the list label. | ||
ImageData | getImageData() | |
Returns image data of the picture bullet shape for the current list level. | ||
boolean | isLegal() | |
void | isLegal(boolean value) | |
True if the level turns all inherited numbers to Arabic, false if it preserves their number style. | ||
Style | getLinkedStyle() | |
void | setLinkedStyle(Style value) | |
Gets or sets the paragraph style that is linked to this list level. | ||
java.lang.String | getNumberFormat() | |
void | setNumberFormat(java.lang.String value) | |
Returns or sets the number format for the list level. | ||
double | getNumberPosition() | |
void | setNumberPosition(double value) | |
Returns or sets the position (in points) of the number or bullet for the list level. | ||
int | getNumberStyle() | |
void | setNumberStyle(int value) | |
Returns or sets the number style for this list level. The value of the property is NumberStyle integer constant. | ||
int | getRestartAfterLevel() | |
void | setRestartAfterLevel(int value) | |
Sets or returns the list level that must appear before the specified list level restarts numbering. | ||
int | getStartAt() | |
void | setStartAt(int value) | |
Returns or sets the starting number for this list level. | ||
double | getTabPosition() | |
void | setTabPosition(double value) | |
Returns or sets the tab position (in points) for the list level. | ||
double | getTextPosition() | |
void | setTextPosition(double value) | |
Returns or sets the position (in points) for the second line of wrapping text for the list level. | ||
int | getTrailingCharacter() | |
void | setTrailingCharacter(int value) | |
Returns or sets the character inserted after the number for the list level. The value of the property is ListTrailingCharacter integer constant. |
Method Summary | ||
---|---|---|
void | createPictureBullet() | |
Creates picture bullet shape for the current list level. | ||
void | deletePictureBullet() | |
Deletes picture bullet for the current list level. | ||
boolean | equals(ListLevel level) | |
Compares with the specified ListLevel. | ||
static java.lang.String | getEffectiveValue(int index, int numberStyle, java.lang.String customNumberStyleFormat) | |
Reports the string representation of the |
||
int | hashCode() | |
Calculates hash code for this object. |
Property Getters/Setters Detail |
---|
getAlignment/setAlignment | |
public int getAlignment() / public void setAlignment(int value) |
The list label is justified relative to the
Example:
Shows how to apply custom list formatting to paragraphs when using DocumentBuilder.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 the first two of its list levels. List list = doc.getLists().add(ListTemplate.NUMBER_DEFAULT); ListLevel listLevel = list.getListLevels().get(0); listLevel.getFont().setColor(Color.RED); listLevel.getFont().setSize(24.0); listLevel.setNumberStyle(NumberStyle.ORDINAL_TEXT); listLevel.setStartAt(21); listLevel.setNumberFormat("\u0000"); listLevel.setNumberPosition(-36); listLevel.setTextPosition(144.0); listLevel.setTabPosition(144.0); listLevel = list.getListLevels().get(1); listLevel.setAlignment(ListLevelAlignment.RIGHT); listLevel.setNumberStyle(NumberStyle.BULLET); listLevel.getFont().setName("Wingdings"); listLevel.getFont().setColor(Color.BLUE); listLevel.getFont().setSize(24.0); // This NumberFormat value will create star-shaped bullet list symbols. listLevel.setNumberFormat("\uf0af"); listLevel.setTrailingCharacter(ListTrailingCharacter.SPACE); listLevel.setNumberPosition(144.0); // Create paragraphs and apply both list levels of our custom list formatting to them. 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(getArtifactsDir() + "Lists.CreateCustomList.docx");
getCustomNumberStyleFormat | |
public java.lang.String getCustomNumberStyleFormat() |
getFont | |
public Font getFont() |
Example:
Shows how to apply custom list formatting to paragraphs when using DocumentBuilder.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 the first two of its list levels. List list = doc.getLists().add(ListTemplate.NUMBER_DEFAULT); ListLevel listLevel = list.getListLevels().get(0); listLevel.getFont().setColor(Color.RED); listLevel.getFont().setSize(24.0); listLevel.setNumberStyle(NumberStyle.ORDINAL_TEXT); listLevel.setStartAt(21); listLevel.setNumberFormat("\u0000"); listLevel.setNumberPosition(-36); listLevel.setTextPosition(144.0); listLevel.setTabPosition(144.0); listLevel = list.getListLevels().get(1); listLevel.setAlignment(ListLevelAlignment.RIGHT); listLevel.setNumberStyle(NumberStyle.BULLET); listLevel.getFont().setName("Wingdings"); listLevel.getFont().setColor(Color.BLUE); listLevel.getFont().setSize(24.0); // This NumberFormat value will create star-shaped bullet list symbols. listLevel.setNumberFormat("\uf0af"); listLevel.setTrailingCharacter(ListTrailingCharacter.SPACE); listLevel.setNumberPosition(144.0); // Create paragraphs and apply both list levels of our custom list formatting to them. 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(getArtifactsDir() + "Lists.CreateCustomList.docx");
getImageData | |
public ImageData getImageData() |
isLegal/isLegal | |
public boolean isLegal() / public void isLegal(boolean value) |
Example:
Shows advances ways of customizing list labels.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // 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. List list = doc.getLists().add(ListTemplate.NUMBER_DEFAULT); // Level 1 labels will be formatted according to the "Heading 1" paragraph style and will have a prefix. // These will look like "Appendix A", "Appendix B"... list.getListLevels().get(0).setNumberFormat("Appendix \u0000"); list.getListLevels().get(0).setNumberStyle(NumberStyle.UPPERCASE_LETTER); list.getListLevels().get(0).setLinkedStyle(doc.getStyles().get("Heading 1")); // Level 2 labels will display the current numbers of the first and the second list levels and have leading zeroes. // If the first list level is at 1, then the list labels from these will look like "Section (1.01)", "Section (1.02)"... list.getListLevels().get(1).setNumberFormat("Section (\u0000.\u0001)"); list.getListLevels().get(1).setNumberStyle(NumberStyle.LEADING_ZERO); // Note that the higher-level uses UppercaseLetter numbering. // We can set the "IsLegal" property to use Arabic numbers for the higher list levels. list.getListLevels().get(1).isLegal(true); list.getListLevels().get(1).setRestartAfterLevel(0); // Level 3 labels will be upper case Roman numerals with a prefix and a suffix and will restart at each List level 1 item. // These list labels will look like "-I-", "-II-"... list.getListLevels().get(2).setNumberFormat("-\u0002-"); list.getListLevels().get(2).setNumberStyle(NumberStyle.UPPERCASE_ROMAN); list.getListLevels().get(2).setRestartAfterLevel(1); // Make labels of all list levels bold. for (ListLevel level : list.getListLevels()) level.getFont().setBold(true); // Apply list formatting to the current paragraph. builder.getListFormat().setList(list); // Create list items that will display all three of our list levels. for (int n = 0; n < 2; n++) { for (int i = 0; i < 3; i++) { builder.getListFormat().setListLevelNumber(i); builder.writeln("Level " + i); } } builder.getListFormat().removeNumbers(); doc.save(getArtifactsDir() + "Lists.CreateListRestartAfterHigher.docx");
getLinkedStyle/setLinkedStyle | |
public Style getLinkedStyle() / public void setLinkedStyle(Style value) |
This property is null when the list level is not linked to a paragraph style. This property can be set to null.
Example:
Shows advances ways of customizing list labels.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // 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. List list = doc.getLists().add(ListTemplate.NUMBER_DEFAULT); // Level 1 labels will be formatted according to the "Heading 1" paragraph style and will have a prefix. // These will look like "Appendix A", "Appendix B"... list.getListLevels().get(0).setNumberFormat("Appendix \u0000"); list.getListLevels().get(0).setNumberStyle(NumberStyle.UPPERCASE_LETTER); list.getListLevels().get(0).setLinkedStyle(doc.getStyles().get("Heading 1")); // Level 2 labels will display the current numbers of the first and the second list levels and have leading zeroes. // If the first list level is at 1, then the list labels from these will look like "Section (1.01)", "Section (1.02)"... list.getListLevels().get(1).setNumberFormat("Section (\u0000.\u0001)"); list.getListLevels().get(1).setNumberStyle(NumberStyle.LEADING_ZERO); // Note that the higher-level uses UppercaseLetter numbering. // We can set the "IsLegal" property to use Arabic numbers for the higher list levels. list.getListLevels().get(1).isLegal(true); list.getListLevels().get(1).setRestartAfterLevel(0); // Level 3 labels will be upper case Roman numerals with a prefix and a suffix and will restart at each List level 1 item. // These list labels will look like "-I-", "-II-"... list.getListLevels().get(2).setNumberFormat("-\u0002-"); list.getListLevels().get(2).setNumberStyle(NumberStyle.UPPERCASE_ROMAN); list.getListLevels().get(2).setRestartAfterLevel(1); // Make labels of all list levels bold. for (ListLevel level : list.getListLevels()) level.getFont().setBold(true); // Apply list formatting to the current paragraph. builder.getListFormat().setList(list); // Create list items that will display all three of our list levels. for (int n = 0; n < 2; n++) { for (int i = 0; i < 3; i++) { builder.getListFormat().setListLevelNumber(i); builder.writeln("Level " + i); } } builder.getListFormat().removeNumbers(); doc.save(getArtifactsDir() + "Lists.CreateListRestartAfterHigher.docx");
getNumberFormat/setNumberFormat | |
public java.lang.String getNumberFormat() / public void setNumberFormat(java.lang.String value) |
Among normal text characters, the string can contain placeholder characters \x0000 to \x0008 representing the numbers from the corresponding list levels.
For example, the string "\x0000.\x0001)" will generate a list label that looks something like "1.5)". The number "1" is the current number from the 1st list level, the number "5" is the current number from the 2nd list level.
Null is not allowed, but an empty string meaning no number is valid.
Example:
Shows how to apply custom list formatting to paragraphs when using DocumentBuilder.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 the first two of its list levels. List list = doc.getLists().add(ListTemplate.NUMBER_DEFAULT); ListLevel listLevel = list.getListLevels().get(0); listLevel.getFont().setColor(Color.RED); listLevel.getFont().setSize(24.0); listLevel.setNumberStyle(NumberStyle.ORDINAL_TEXT); listLevel.setStartAt(21); listLevel.setNumberFormat("\u0000"); listLevel.setNumberPosition(-36); listLevel.setTextPosition(144.0); listLevel.setTabPosition(144.0); listLevel = list.getListLevels().get(1); listLevel.setAlignment(ListLevelAlignment.RIGHT); listLevel.setNumberStyle(NumberStyle.BULLET); listLevel.getFont().setName("Wingdings"); listLevel.getFont().setColor(Color.BLUE); listLevel.getFont().setSize(24.0); // This NumberFormat value will create star-shaped bullet list symbols. listLevel.setNumberFormat("\uf0af"); listLevel.setTrailingCharacter(ListTrailingCharacter.SPACE); listLevel.setNumberPosition(144.0); // Create paragraphs and apply both list levels of our custom list formatting to them. 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(getArtifactsDir() + "Lists.CreateCustomList.docx");
Example:
Shows advances ways of customizing list labels.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // 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. List list = doc.getLists().add(ListTemplate.NUMBER_DEFAULT); // Level 1 labels will be formatted according to the "Heading 1" paragraph style and will have a prefix. // These will look like "Appendix A", "Appendix B"... list.getListLevels().get(0).setNumberFormat("Appendix \u0000"); list.getListLevels().get(0).setNumberStyle(NumberStyle.UPPERCASE_LETTER); list.getListLevels().get(0).setLinkedStyle(doc.getStyles().get("Heading 1")); // Level 2 labels will display the current numbers of the first and the second list levels and have leading zeroes. // If the first list level is at 1, then the list labels from these will look like "Section (1.01)", "Section (1.02)"... list.getListLevels().get(1).setNumberFormat("Section (\u0000.\u0001)"); list.getListLevels().get(1).setNumberStyle(NumberStyle.LEADING_ZERO); // Note that the higher-level uses UppercaseLetter numbering. // We can set the "IsLegal" property to use Arabic numbers for the higher list levels. list.getListLevels().get(1).isLegal(true); list.getListLevels().get(1).setRestartAfterLevel(0); // Level 3 labels will be upper case Roman numerals with a prefix and a suffix and will restart at each List level 1 item. // These list labels will look like "-I-", "-II-"... list.getListLevels().get(2).setNumberFormat("-\u0002-"); list.getListLevels().get(2).setNumberStyle(NumberStyle.UPPERCASE_ROMAN); list.getListLevels().get(2).setRestartAfterLevel(1); // Make labels of all list levels bold. for (ListLevel level : list.getListLevels()) level.getFont().setBold(true); // Apply list formatting to the current paragraph. builder.getListFormat().setList(list); // Create list items that will display all three of our list levels. for (int n = 0; n < 2; n++) { for (int i = 0; i < 3; i++) { builder.getListFormat().setListLevelNumber(i); builder.writeln("Level " + i); } } builder.getListFormat().removeNumbers(); doc.save(getArtifactsDir() + "Lists.CreateListRestartAfterHigher.docx");
getNumberPosition/setNumberPosition | |
public double getNumberPosition() / public void setNumberPosition(double value) |
Example:
Shows how to apply custom list formatting to paragraphs when using DocumentBuilder.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 the first two of its list levels. List list = doc.getLists().add(ListTemplate.NUMBER_DEFAULT); ListLevel listLevel = list.getListLevels().get(0); listLevel.getFont().setColor(Color.RED); listLevel.getFont().setSize(24.0); listLevel.setNumberStyle(NumberStyle.ORDINAL_TEXT); listLevel.setStartAt(21); listLevel.setNumberFormat("\u0000"); listLevel.setNumberPosition(-36); listLevel.setTextPosition(144.0); listLevel.setTabPosition(144.0); listLevel = list.getListLevels().get(1); listLevel.setAlignment(ListLevelAlignment.RIGHT); listLevel.setNumberStyle(NumberStyle.BULLET); listLevel.getFont().setName("Wingdings"); listLevel.getFont().setColor(Color.BLUE); listLevel.getFont().setSize(24.0); // This NumberFormat value will create star-shaped bullet list symbols. listLevel.setNumberFormat("\uf0af"); listLevel.setTrailingCharacter(ListTrailingCharacter.SPACE); listLevel.setNumberPosition(144.0); // Create paragraphs and apply both list levels of our custom list formatting to them. 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(getArtifactsDir() + "Lists.CreateCustomList.docx");
getNumberStyle/setNumberStyle | |
public int getNumberStyle() / public void setNumberStyle(int value) |
Example:
Shows how to apply custom list formatting to paragraphs when using DocumentBuilder.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 the first two of its list levels. List list = doc.getLists().add(ListTemplate.NUMBER_DEFAULT); ListLevel listLevel = list.getListLevels().get(0); listLevel.getFont().setColor(Color.RED); listLevel.getFont().setSize(24.0); listLevel.setNumberStyle(NumberStyle.ORDINAL_TEXT); listLevel.setStartAt(21); listLevel.setNumberFormat("\u0000"); listLevel.setNumberPosition(-36); listLevel.setTextPosition(144.0); listLevel.setTabPosition(144.0); listLevel = list.getListLevels().get(1); listLevel.setAlignment(ListLevelAlignment.RIGHT); listLevel.setNumberStyle(NumberStyle.BULLET); listLevel.getFont().setName("Wingdings"); listLevel.getFont().setColor(Color.BLUE); listLevel.getFont().setSize(24.0); // This NumberFormat value will create star-shaped bullet list symbols. listLevel.setNumberFormat("\uf0af"); listLevel.setTrailingCharacter(ListTrailingCharacter.SPACE); listLevel.setNumberPosition(144.0); // Create paragraphs and apply both list levels of our custom list formatting to them. 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(getArtifactsDir() + "Lists.CreateCustomList.docx");
Example:
Shows advances ways of customizing list labels.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // 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. List list = doc.getLists().add(ListTemplate.NUMBER_DEFAULT); // Level 1 labels will be formatted according to the "Heading 1" paragraph style and will have a prefix. // These will look like "Appendix A", "Appendix B"... list.getListLevels().get(0).setNumberFormat("Appendix \u0000"); list.getListLevels().get(0).setNumberStyle(NumberStyle.UPPERCASE_LETTER); list.getListLevels().get(0).setLinkedStyle(doc.getStyles().get("Heading 1")); // Level 2 labels will display the current numbers of the first and the second list levels and have leading zeroes. // If the first list level is at 1, then the list labels from these will look like "Section (1.01)", "Section (1.02)"... list.getListLevels().get(1).setNumberFormat("Section (\u0000.\u0001)"); list.getListLevels().get(1).setNumberStyle(NumberStyle.LEADING_ZERO); // Note that the higher-level uses UppercaseLetter numbering. // We can set the "IsLegal" property to use Arabic numbers for the higher list levels. list.getListLevels().get(1).isLegal(true); list.getListLevels().get(1).setRestartAfterLevel(0); // Level 3 labels will be upper case Roman numerals with a prefix and a suffix and will restart at each List level 1 item. // These list labels will look like "-I-", "-II-"... list.getListLevels().get(2).setNumberFormat("-\u0002-"); list.getListLevels().get(2).setNumberStyle(NumberStyle.UPPERCASE_ROMAN); list.getListLevels().get(2).setRestartAfterLevel(1); // Make labels of all list levels bold. for (ListLevel level : list.getListLevels()) level.getFont().setBold(true); // Apply list formatting to the current paragraph. builder.getListFormat().setList(list); // Create list items that will display all three of our list levels. for (int n = 0; n < 2; n++) { for (int i = 0; i < 3; i++) { builder.getListFormat().setListLevelNumber(i); builder.writeln("Level " + i); } } builder.getListFormat().removeNumbers(); doc.save(getArtifactsDir() + "Lists.CreateListRestartAfterHigher.docx");
getRestartAfterLevel/setRestartAfterLevel | |
public int getRestartAfterLevel() / public void setRestartAfterLevel(int value) |
The value of -1 means the numbering will continue.
Example:
Shows advances ways of customizing list labels.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // 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. List list = doc.getLists().add(ListTemplate.NUMBER_DEFAULT); // Level 1 labels will be formatted according to the "Heading 1" paragraph style and will have a prefix. // These will look like "Appendix A", "Appendix B"... list.getListLevels().get(0).setNumberFormat("Appendix \u0000"); list.getListLevels().get(0).setNumberStyle(NumberStyle.UPPERCASE_LETTER); list.getListLevels().get(0).setLinkedStyle(doc.getStyles().get("Heading 1")); // Level 2 labels will display the current numbers of the first and the second list levels and have leading zeroes. // If the first list level is at 1, then the list labels from these will look like "Section (1.01)", "Section (1.02)"... list.getListLevels().get(1).setNumberFormat("Section (\u0000.\u0001)"); list.getListLevels().get(1).setNumberStyle(NumberStyle.LEADING_ZERO); // Note that the higher-level uses UppercaseLetter numbering. // We can set the "IsLegal" property to use Arabic numbers for the higher list levels. list.getListLevels().get(1).isLegal(true); list.getListLevels().get(1).setRestartAfterLevel(0); // Level 3 labels will be upper case Roman numerals with a prefix and a suffix and will restart at each List level 1 item. // These list labels will look like "-I-", "-II-"... list.getListLevels().get(2).setNumberFormat("-\u0002-"); list.getListLevels().get(2).setNumberStyle(NumberStyle.UPPERCASE_ROMAN); list.getListLevels().get(2).setRestartAfterLevel(1); // Make labels of all list levels bold. for (ListLevel level : list.getListLevels()) level.getFont().setBold(true); // Apply list formatting to the current paragraph. builder.getListFormat().setList(list); // Create list items that will display all three of our list levels. for (int n = 0; n < 2; n++) { for (int i = 0; i < 3; i++) { builder.getListFormat().setListLevelNumber(i); builder.writeln("Level " + i); } } builder.getListFormat().removeNumbers(); doc.save(getArtifactsDir() + "Lists.CreateListRestartAfterHigher.docx");
getStartAt/setStartAt | |
public int getStartAt() / public void setStartAt(int value) |
Default value is 1.
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 apply custom list formatting to paragraphs when using DocumentBuilder.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 the first two of its list levels. List list = doc.getLists().add(ListTemplate.NUMBER_DEFAULT); ListLevel listLevel = list.getListLevels().get(0); listLevel.getFont().setColor(Color.RED); listLevel.getFont().setSize(24.0); listLevel.setNumberStyle(NumberStyle.ORDINAL_TEXT); listLevel.setStartAt(21); listLevel.setNumberFormat("\u0000"); listLevel.setNumberPosition(-36); listLevel.setTextPosition(144.0); listLevel.setTabPosition(144.0); listLevel = list.getListLevels().get(1); listLevel.setAlignment(ListLevelAlignment.RIGHT); listLevel.setNumberStyle(NumberStyle.BULLET); listLevel.getFont().setName("Wingdings"); listLevel.getFont().setColor(Color.BLUE); listLevel.getFont().setSize(24.0); // This NumberFormat value will create star-shaped bullet list symbols. listLevel.setNumberFormat("\uf0af"); listLevel.setTrailingCharacter(ListTrailingCharacter.SPACE); listLevel.setNumberPosition(144.0); // Create paragraphs and apply both list levels of our custom list formatting to them. 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(getArtifactsDir() + "Lists.CreateCustomList.docx");
getTabPosition/setTabPosition | |
public double getTabPosition() / public void setTabPosition(double value) |
Has effect only when
Example:
Shows how to apply custom list formatting to paragraphs when using DocumentBuilder.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 the first two of its list levels. List list = doc.getLists().add(ListTemplate.NUMBER_DEFAULT); ListLevel listLevel = list.getListLevels().get(0); listLevel.getFont().setColor(Color.RED); listLevel.getFont().setSize(24.0); listLevel.setNumberStyle(NumberStyle.ORDINAL_TEXT); listLevel.setStartAt(21); listLevel.setNumberFormat("\u0000"); listLevel.setNumberPosition(-36); listLevel.setTextPosition(144.0); listLevel.setTabPosition(144.0); listLevel = list.getListLevels().get(1); listLevel.setAlignment(ListLevelAlignment.RIGHT); listLevel.setNumberStyle(NumberStyle.BULLET); listLevel.getFont().setName("Wingdings"); listLevel.getFont().setColor(Color.BLUE); listLevel.getFont().setSize(24.0); // This NumberFormat value will create star-shaped bullet list symbols. listLevel.setNumberFormat("\uf0af"); listLevel.setTrailingCharacter(ListTrailingCharacter.SPACE); listLevel.setNumberPosition(144.0); // Create paragraphs and apply both list levels of our custom list formatting to them. 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(getArtifactsDir() + "Lists.CreateCustomList.docx");
getTextPosition/setTextPosition | |
public double getTextPosition() / public void setTextPosition(double value) |
Example:
Shows how to apply custom list formatting to paragraphs when using DocumentBuilder.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 the first two of its list levels. List list = doc.getLists().add(ListTemplate.NUMBER_DEFAULT); ListLevel listLevel = list.getListLevels().get(0); listLevel.getFont().setColor(Color.RED); listLevel.getFont().setSize(24.0); listLevel.setNumberStyle(NumberStyle.ORDINAL_TEXT); listLevel.setStartAt(21); listLevel.setNumberFormat("\u0000"); listLevel.setNumberPosition(-36); listLevel.setTextPosition(144.0); listLevel.setTabPosition(144.0); listLevel = list.getListLevels().get(1); listLevel.setAlignment(ListLevelAlignment.RIGHT); listLevel.setNumberStyle(NumberStyle.BULLET); listLevel.getFont().setName("Wingdings"); listLevel.getFont().setColor(Color.BLUE); listLevel.getFont().setSize(24.0); // This NumberFormat value will create star-shaped bullet list symbols. listLevel.setNumberFormat("\uf0af"); listLevel.setTrailingCharacter(ListTrailingCharacter.SPACE); listLevel.setNumberPosition(144.0); // Create paragraphs and apply both list levels of our custom list formatting to them. 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(getArtifactsDir() + "Lists.CreateCustomList.docx");
getTrailingCharacter/setTrailingCharacter | |
public int getTrailingCharacter() / public void setTrailingCharacter(int value) |
Example:
Shows how to apply custom list formatting to paragraphs when using DocumentBuilder.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 the first two of its list levels. List list = doc.getLists().add(ListTemplate.NUMBER_DEFAULT); ListLevel listLevel = list.getListLevels().get(0); listLevel.getFont().setColor(Color.RED); listLevel.getFont().setSize(24.0); listLevel.setNumberStyle(NumberStyle.ORDINAL_TEXT); listLevel.setStartAt(21); listLevel.setNumberFormat("\u0000"); listLevel.setNumberPosition(-36); listLevel.setTextPosition(144.0); listLevel.setTabPosition(144.0); listLevel = list.getListLevels().get(1); listLevel.setAlignment(ListLevelAlignment.RIGHT); listLevel.setNumberStyle(NumberStyle.BULLET); listLevel.getFont().setName("Wingdings"); listLevel.getFont().setColor(Color.BLUE); listLevel.getFont().setSize(24.0); // This NumberFormat value will create star-shaped bullet list symbols. listLevel.setNumberFormat("\uf0af"); listLevel.setTrailingCharacter(ListTrailingCharacter.SPACE); listLevel.setNumberPosition(144.0); // Create paragraphs and apply both list levels of our custom list formatting to them. 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(getArtifactsDir() + "Lists.CreateCustomList.docx");
Method Detail |
---|
createPictureBullet | |
public void createPictureBullet() throws java.lang.Exception |
Example:
Shows how to set a custom image icon for list item labels.Document doc = new Document(); List list = doc.getLists().add(ListTemplate.BULLET_CIRCLE); // Create a picture bullet for the current list level, and set an image from a local file system // as the icon that the bullets for this list level will display. list.getListLevels().get(0).createPictureBullet(); list.getListLevels().get(0).getImageData().setImage(getImageDir() + "Logo icon.ico"); Assert.assertTrue(list.getListLevels().get(0).getImageData().hasImage()); DocumentBuilder builder = new DocumentBuilder(doc); builder.getListFormat().setList(list); builder.writeln("Hello world!"); builder.write("Hello again!"); doc.save(getArtifactsDir() + "Lists.CreatePictureBullet.docx"); list.getListLevels().get(0).deletePictureBullet(); Assert.assertNull(list.getListLevels().get(0).getImageData());
deletePictureBullet | |
public void deletePictureBullet() |
Example:
Shows how to set a custom image icon for list item labels.Document doc = new Document(); List list = doc.getLists().add(ListTemplate.BULLET_CIRCLE); // Create a picture bullet for the current list level, and set an image from a local file system // as the icon that the bullets for this list level will display. list.getListLevels().get(0).createPictureBullet(); list.getListLevels().get(0).getImageData().setImage(getImageDir() + "Logo icon.ico"); Assert.assertTrue(list.getListLevels().get(0).getImageData().hasImage()); DocumentBuilder builder = new DocumentBuilder(doc); builder.getListFormat().setList(list); builder.writeln("Hello world!"); builder.write("Hello again!"); doc.save(getArtifactsDir() + "Lists.CreatePictureBullet.docx"); list.getListLevels().get(0).deletePictureBullet(); Assert.assertNull(list.getListLevels().get(0).getImageData());
equals | |
public boolean equals(ListLevel level) |
getEffectiveValue | |
public static java.lang.String getEffectiveValue(int index, int numberStyle, java.lang.String customNumberStyleFormat) |
index
- The index of the list item (must be in the range from 1 to 32767).numberStyle
- A customNumberStyleFormat
-
The optional format string used when hashCode | |
public int hashCode() |