public class FieldAutoNumLgl extends Field
To learn more, visit the Working with Fields documentation article.
Remarks:
Inserts an automatic number in legal format.
Examples:
Shows how to organize a document using AUTONUMLGL fields.
public void fieldAutoNumLgl() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
final String FILLER_TEXT = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. " +
"\nUt enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. ";
// AUTONUMLGL fields display a number that increments at each AUTONUMLGL field within its current heading level.
// These fields maintain a separate count for each heading level,
// and each field also displays the AUTONUMLGL field counts for all heading levels below its own.
// Changing the count for any heading level resets the counts for all levels above that level to 1.
// This allows us to organize our document in the form of an outline list.
// This is the first AUTONUMLGL field at a heading level of 1, displaying "1." in the document.
insertNumberedClause(builder, "\tHeading 1", FILLER_TEXT, StyleIdentifier.HEADING_1);
// This is the second AUTONUMLGL field at a heading level of 1, so it will display "2.".
insertNumberedClause(builder, "\tHeading 2", FILLER_TEXT, StyleIdentifier.HEADING_1);
// This is the first AUTONUMLGL field at a heading level of 2,
// and the AUTONUMLGL count for the heading level below it is "2", so it will display "2.1.".
insertNumberedClause(builder, "\tHeading 3", FILLER_TEXT, StyleIdentifier.HEADING_2);
// This is the first AUTONUMLGL field at a heading level of 3.
// Working in the same way as the field above, it will display "2.1.1.".
insertNumberedClause(builder, "\tHeading 4", FILLER_TEXT, StyleIdentifier.HEADING_3);
// This field is at a heading level of 2, and its respective AUTONUMLGL count is at 2, so the field will display "2.2.".
insertNumberedClause(builder, "\tHeading 5", FILLER_TEXT, StyleIdentifier.HEADING_2);
// Incrementing the AUTONUMLGL count for a heading level below this one
// has reset the count for this level so that this field will display "2.2.1.".
insertNumberedClause(builder, "\tHeading 6", FILLER_TEXT, StyleIdentifier.HEADING_3);
for (Field field : doc.getRange().getFields()) {
if (field.getType() == FieldType.FIELD_AUTO_NUM_LEGAL) {
// The separator character, which appears in the field result immediately after the number,
// is a full stop by default. If we leave this property null,
// our last AUTONUMLGL field will display "2.2.1." in the document.
Assert.assertNull(((FieldAutoNumLgl) field).getSeparatorCharacter());
// Setting a custom separator character and removing the trailing period
// will change that field's appearance from "2.2.1." to "2:2:1".
// We will apply this to all the fields that we have created.
((FieldAutoNumLgl) field).setSeparatorCharacter(":");
((FieldAutoNumLgl) field).setRemoveTrailingPeriod(true);
Assert.assertEquals(field.getFieldCode(), " AUTONUMLGL \\s : \\e");
}
}
doc.save(getArtifactsDir() + "Field.AUTONUMLGL.docx");
}
/// <summary>
/// Uses a document builder to insert a clause numbered by an AUTONUMLGL field.
/// </summary>
private static void insertNumberedClause(DocumentBuilder builder, String heading, String contents, int headingStyle) throws Exception {
builder.insertField(FieldType.FIELD_AUTO_NUM_LEGAL, true);
builder.getCurrentParagraph().getParagraphFormat().setStyleIdentifier(headingStyle);
builder.writeln(heading);
// This text will belong to the auto num legal field above it.
// It will collapse when we click the arrow next to the corresponding AUTONUMLGL field in Microsoft Word.
builder.getCurrentParagraph().getParagraphFormat().setStyleIdentifier(StyleIdentifier.BODY_TEXT);
builder.writeln(contents);
}
| Modifier and Type | Method and Description |
|---|---|
boolean |
getRemoveTrailingPeriod()
Gets whether to display the number without a trailing period.
|
java.lang.String |
getSeparatorCharacter()
Gets the separator character to be used.
|
int |
getSwitchType(java.lang.String switchName) |
void |
setRemoveTrailingPeriod(boolean value)
Sets whether to display the number without a trailing period.
|
void |
setSeparatorCharacter(java.lang.String value)
Sets the separator character to be used.
|
getDisplayResult, getEnd, getFieldCode, getFieldCode, getFormat, getLocaleId, getResult, getSeparator, getStart, getType, isDirty, isDirty, isLocked, isLocked, needStoreOldResultNodes, remove, setLocaleId, setResult, unlink, update, updatepublic boolean getRemoveTrailingPeriod()
Examples:
Shows how to organize a document using AUTONUMLGL fields.
public void fieldAutoNumLgl() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
final String FILLER_TEXT = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. " +
"\nUt enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. ";
// AUTONUMLGL fields display a number that increments at each AUTONUMLGL field within its current heading level.
// These fields maintain a separate count for each heading level,
// and each field also displays the AUTONUMLGL field counts for all heading levels below its own.
// Changing the count for any heading level resets the counts for all levels above that level to 1.
// This allows us to organize our document in the form of an outline list.
// This is the first AUTONUMLGL field at a heading level of 1, displaying "1." in the document.
insertNumberedClause(builder, "\tHeading 1", FILLER_TEXT, StyleIdentifier.HEADING_1);
// This is the second AUTONUMLGL field at a heading level of 1, so it will display "2.".
insertNumberedClause(builder, "\tHeading 2", FILLER_TEXT, StyleIdentifier.HEADING_1);
// This is the first AUTONUMLGL field at a heading level of 2,
// and the AUTONUMLGL count for the heading level below it is "2", so it will display "2.1.".
insertNumberedClause(builder, "\tHeading 3", FILLER_TEXT, StyleIdentifier.HEADING_2);
// This is the first AUTONUMLGL field at a heading level of 3.
// Working in the same way as the field above, it will display "2.1.1.".
insertNumberedClause(builder, "\tHeading 4", FILLER_TEXT, StyleIdentifier.HEADING_3);
// This field is at a heading level of 2, and its respective AUTONUMLGL count is at 2, so the field will display "2.2.".
insertNumberedClause(builder, "\tHeading 5", FILLER_TEXT, StyleIdentifier.HEADING_2);
// Incrementing the AUTONUMLGL count for a heading level below this one
// has reset the count for this level so that this field will display "2.2.1.".
insertNumberedClause(builder, "\tHeading 6", FILLER_TEXT, StyleIdentifier.HEADING_3);
for (Field field : doc.getRange().getFields()) {
if (field.getType() == FieldType.FIELD_AUTO_NUM_LEGAL) {
// The separator character, which appears in the field result immediately after the number,
// is a full stop by default. If we leave this property null,
// our last AUTONUMLGL field will display "2.2.1." in the document.
Assert.assertNull(((FieldAutoNumLgl) field).getSeparatorCharacter());
// Setting a custom separator character and removing the trailing period
// will change that field's appearance from "2.2.1." to "2:2:1".
// We will apply this to all the fields that we have created.
((FieldAutoNumLgl) field).setSeparatorCharacter(":");
((FieldAutoNumLgl) field).setRemoveTrailingPeriod(true);
Assert.assertEquals(field.getFieldCode(), " AUTONUMLGL \\s : \\e");
}
}
doc.save(getArtifactsDir() + "Field.AUTONUMLGL.docx");
}
/// <summary>
/// Uses a document builder to insert a clause numbered by an AUTONUMLGL field.
/// </summary>
private static void insertNumberedClause(DocumentBuilder builder, String heading, String contents, int headingStyle) throws Exception {
builder.insertField(FieldType.FIELD_AUTO_NUM_LEGAL, true);
builder.getCurrentParagraph().getParagraphFormat().setStyleIdentifier(headingStyle);
builder.writeln(heading);
// This text will belong to the auto num legal field above it.
// It will collapse when we click the arrow next to the corresponding AUTONUMLGL field in Microsoft Word.
builder.getCurrentParagraph().getParagraphFormat().setStyleIdentifier(StyleIdentifier.BODY_TEXT);
builder.writeln(contents);
}
public void setRemoveTrailingPeriod(boolean value)
throws java.lang.Exception
Examples:
Shows how to organize a document using AUTONUMLGL fields.
public void fieldAutoNumLgl() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
final String FILLER_TEXT = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. " +
"\nUt enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. ";
// AUTONUMLGL fields display a number that increments at each AUTONUMLGL field within its current heading level.
// These fields maintain a separate count for each heading level,
// and each field also displays the AUTONUMLGL field counts for all heading levels below its own.
// Changing the count for any heading level resets the counts for all levels above that level to 1.
// This allows us to organize our document in the form of an outline list.
// This is the first AUTONUMLGL field at a heading level of 1, displaying "1." in the document.
insertNumberedClause(builder, "\tHeading 1", FILLER_TEXT, StyleIdentifier.HEADING_1);
// This is the second AUTONUMLGL field at a heading level of 1, so it will display "2.".
insertNumberedClause(builder, "\tHeading 2", FILLER_TEXT, StyleIdentifier.HEADING_1);
// This is the first AUTONUMLGL field at a heading level of 2,
// and the AUTONUMLGL count for the heading level below it is "2", so it will display "2.1.".
insertNumberedClause(builder, "\tHeading 3", FILLER_TEXT, StyleIdentifier.HEADING_2);
// This is the first AUTONUMLGL field at a heading level of 3.
// Working in the same way as the field above, it will display "2.1.1.".
insertNumberedClause(builder, "\tHeading 4", FILLER_TEXT, StyleIdentifier.HEADING_3);
// This field is at a heading level of 2, and its respective AUTONUMLGL count is at 2, so the field will display "2.2.".
insertNumberedClause(builder, "\tHeading 5", FILLER_TEXT, StyleIdentifier.HEADING_2);
// Incrementing the AUTONUMLGL count for a heading level below this one
// has reset the count for this level so that this field will display "2.2.1.".
insertNumberedClause(builder, "\tHeading 6", FILLER_TEXT, StyleIdentifier.HEADING_3);
for (Field field : doc.getRange().getFields()) {
if (field.getType() == FieldType.FIELD_AUTO_NUM_LEGAL) {
// The separator character, which appears in the field result immediately after the number,
// is a full stop by default. If we leave this property null,
// our last AUTONUMLGL field will display "2.2.1." in the document.
Assert.assertNull(((FieldAutoNumLgl) field).getSeparatorCharacter());
// Setting a custom separator character and removing the trailing period
// will change that field's appearance from "2.2.1." to "2:2:1".
// We will apply this to all the fields that we have created.
((FieldAutoNumLgl) field).setSeparatorCharacter(":");
((FieldAutoNumLgl) field).setRemoveTrailingPeriod(true);
Assert.assertEquals(field.getFieldCode(), " AUTONUMLGL \\s : \\e");
}
}
doc.save(getArtifactsDir() + "Field.AUTONUMLGL.docx");
}
/// <summary>
/// Uses a document builder to insert a clause numbered by an AUTONUMLGL field.
/// </summary>
private static void insertNumberedClause(DocumentBuilder builder, String heading, String contents, int headingStyle) throws Exception {
builder.insertField(FieldType.FIELD_AUTO_NUM_LEGAL, true);
builder.getCurrentParagraph().getParagraphFormat().setStyleIdentifier(headingStyle);
builder.writeln(heading);
// This text will belong to the auto num legal field above it.
// It will collapse when we click the arrow next to the corresponding AUTONUMLGL field in Microsoft Word.
builder.getCurrentParagraph().getParagraphFormat().setStyleIdentifier(StyleIdentifier.BODY_TEXT);
builder.writeln(contents);
}
value - Whether to display the number without a trailing period.java.lang.Exceptionpublic java.lang.String getSeparatorCharacter()
Examples:
Shows how to organize a document using AUTONUMLGL fields.
public void fieldAutoNumLgl() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
final String FILLER_TEXT = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. " +
"\nUt enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. ";
// AUTONUMLGL fields display a number that increments at each AUTONUMLGL field within its current heading level.
// These fields maintain a separate count for each heading level,
// and each field also displays the AUTONUMLGL field counts for all heading levels below its own.
// Changing the count for any heading level resets the counts for all levels above that level to 1.
// This allows us to organize our document in the form of an outline list.
// This is the first AUTONUMLGL field at a heading level of 1, displaying "1." in the document.
insertNumberedClause(builder, "\tHeading 1", FILLER_TEXT, StyleIdentifier.HEADING_1);
// This is the second AUTONUMLGL field at a heading level of 1, so it will display "2.".
insertNumberedClause(builder, "\tHeading 2", FILLER_TEXT, StyleIdentifier.HEADING_1);
// This is the first AUTONUMLGL field at a heading level of 2,
// and the AUTONUMLGL count for the heading level below it is "2", so it will display "2.1.".
insertNumberedClause(builder, "\tHeading 3", FILLER_TEXT, StyleIdentifier.HEADING_2);
// This is the first AUTONUMLGL field at a heading level of 3.
// Working in the same way as the field above, it will display "2.1.1.".
insertNumberedClause(builder, "\tHeading 4", FILLER_TEXT, StyleIdentifier.HEADING_3);
// This field is at a heading level of 2, and its respective AUTONUMLGL count is at 2, so the field will display "2.2.".
insertNumberedClause(builder, "\tHeading 5", FILLER_TEXT, StyleIdentifier.HEADING_2);
// Incrementing the AUTONUMLGL count for a heading level below this one
// has reset the count for this level so that this field will display "2.2.1.".
insertNumberedClause(builder, "\tHeading 6", FILLER_TEXT, StyleIdentifier.HEADING_3);
for (Field field : doc.getRange().getFields()) {
if (field.getType() == FieldType.FIELD_AUTO_NUM_LEGAL) {
// The separator character, which appears in the field result immediately after the number,
// is a full stop by default. If we leave this property null,
// our last AUTONUMLGL field will display "2.2.1." in the document.
Assert.assertNull(((FieldAutoNumLgl) field).getSeparatorCharacter());
// Setting a custom separator character and removing the trailing period
// will change that field's appearance from "2.2.1." to "2:2:1".
// We will apply this to all the fields that we have created.
((FieldAutoNumLgl) field).setSeparatorCharacter(":");
((FieldAutoNumLgl) field).setRemoveTrailingPeriod(true);
Assert.assertEquals(field.getFieldCode(), " AUTONUMLGL \\s : \\e");
}
}
doc.save(getArtifactsDir() + "Field.AUTONUMLGL.docx");
}
/// <summary>
/// Uses a document builder to insert a clause numbered by an AUTONUMLGL field.
/// </summary>
private static void insertNumberedClause(DocumentBuilder builder, String heading, String contents, int headingStyle) throws Exception {
builder.insertField(FieldType.FIELD_AUTO_NUM_LEGAL, true);
builder.getCurrentParagraph().getParagraphFormat().setStyleIdentifier(headingStyle);
builder.writeln(heading);
// This text will belong to the auto num legal field above it.
// It will collapse when we click the arrow next to the corresponding AUTONUMLGL field in Microsoft Word.
builder.getCurrentParagraph().getParagraphFormat().setStyleIdentifier(StyleIdentifier.BODY_TEXT);
builder.writeln(contents);
}
public void setSeparatorCharacter(java.lang.String value)
throws java.lang.Exception
Examples:
Shows how to organize a document using AUTONUMLGL fields.
public void fieldAutoNumLgl() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
final String FILLER_TEXT = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. " +
"\nUt enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. ";
// AUTONUMLGL fields display a number that increments at each AUTONUMLGL field within its current heading level.
// These fields maintain a separate count for each heading level,
// and each field also displays the AUTONUMLGL field counts for all heading levels below its own.
// Changing the count for any heading level resets the counts for all levels above that level to 1.
// This allows us to organize our document in the form of an outline list.
// This is the first AUTONUMLGL field at a heading level of 1, displaying "1." in the document.
insertNumberedClause(builder, "\tHeading 1", FILLER_TEXT, StyleIdentifier.HEADING_1);
// This is the second AUTONUMLGL field at a heading level of 1, so it will display "2.".
insertNumberedClause(builder, "\tHeading 2", FILLER_TEXT, StyleIdentifier.HEADING_1);
// This is the first AUTONUMLGL field at a heading level of 2,
// and the AUTONUMLGL count for the heading level below it is "2", so it will display "2.1.".
insertNumberedClause(builder, "\tHeading 3", FILLER_TEXT, StyleIdentifier.HEADING_2);
// This is the first AUTONUMLGL field at a heading level of 3.
// Working in the same way as the field above, it will display "2.1.1.".
insertNumberedClause(builder, "\tHeading 4", FILLER_TEXT, StyleIdentifier.HEADING_3);
// This field is at a heading level of 2, and its respective AUTONUMLGL count is at 2, so the field will display "2.2.".
insertNumberedClause(builder, "\tHeading 5", FILLER_TEXT, StyleIdentifier.HEADING_2);
// Incrementing the AUTONUMLGL count for a heading level below this one
// has reset the count for this level so that this field will display "2.2.1.".
insertNumberedClause(builder, "\tHeading 6", FILLER_TEXT, StyleIdentifier.HEADING_3);
for (Field field : doc.getRange().getFields()) {
if (field.getType() == FieldType.FIELD_AUTO_NUM_LEGAL) {
// The separator character, which appears in the field result immediately after the number,
// is a full stop by default. If we leave this property null,
// our last AUTONUMLGL field will display "2.2.1." in the document.
Assert.assertNull(((FieldAutoNumLgl) field).getSeparatorCharacter());
// Setting a custom separator character and removing the trailing period
// will change that field's appearance from "2.2.1." to "2:2:1".
// We will apply this to all the fields that we have created.
((FieldAutoNumLgl) field).setSeparatorCharacter(":");
((FieldAutoNumLgl) field).setRemoveTrailingPeriod(true);
Assert.assertEquals(field.getFieldCode(), " AUTONUMLGL \\s : \\e");
}
}
doc.save(getArtifactsDir() + "Field.AUTONUMLGL.docx");
}
/// <summary>
/// Uses a document builder to insert a clause numbered by an AUTONUMLGL field.
/// </summary>
private static void insertNumberedClause(DocumentBuilder builder, String heading, String contents, int headingStyle) throws Exception {
builder.insertField(FieldType.FIELD_AUTO_NUM_LEGAL, true);
builder.getCurrentParagraph().getParagraphFormat().setStyleIdentifier(headingStyle);
builder.writeln(heading);
// This text will belong to the auto num legal field above it.
// It will collapse when we click the arrow next to the corresponding AUTONUMLGL field in Microsoft Word.
builder.getCurrentParagraph().getParagraphFormat().setStyleIdentifier(StyleIdentifier.BODY_TEXT);
builder.writeln(contents);
}
value - The separator character to be used.java.lang.Exceptionpublic int getSwitchType(java.lang.String switchName)