public class FieldTC extends Field
To learn more, visit the Working with Fields documentation article.
Remarks:
Defines the text and page number for a table of contents (including a table of figures) entry, which is used by a TOC field.
Examples:
Shows how to insert a TOC field, and filter which TC fields end up as entries.
public void fieldTocEntryIdentifier() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a TOC field, which will compile all TC fields into a table of contents.
FieldToc fieldToc = (FieldToc) builder.insertField(FieldType.FIELD_TOC, true);
// Configure the field only to pick up TC entries of the "A" type, and an entry-level between 1 and 3.
fieldToc.setEntryIdentifier("A");
fieldToc.setEntryLevelRange("1-3");
Assert.assertEquals(" TOC \\f A \\l 1-3", fieldToc.getFieldCode());
// These two entries will appear in the table.
builder.insertBreak(BreakType.PAGE_BREAK);
insertTocEntry(builder, "TC field 1", "A", "1");
insertTocEntry(builder, "TC field 2", "A", "2");
Assert.assertEquals(" TC \"TC field 1\" \\n \\f A \\l 1", doc.getRange().getFields().get(1).getFieldCode());
// This entry will be omitted from the table because it has a different type from "A".
insertTocEntry(builder, "TC field 3", "B", "1");
// This entry will be omitted from the table because it has an entry-level outside of the 1-3 range.
insertTocEntry(builder, "TC field 4", "A", "5");
doc.updateFields();
doc.save(getArtifactsDir() + "Field.TC.docx");
}
/// <summary>
/// Use a document builder to insert a TC field.
/// </summary>
public void insertTocEntry(final DocumentBuilder builder, final String text, final String typeIdentifier, final String entryLevel) throws Exception {
FieldTC fieldTc = (FieldTC) builder.insertField(FieldType.FIELD_TOC_ENTRY, true);
fieldTc.setOmitPageNumber(true);
fieldTc.setText(text);
fieldTc.setTypeIdentifier(typeIdentifier);
fieldTc.setEntryLevel(entryLevel);
}
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getDocumentOutlineTitle() |
java.lang.String |
getEntryLevel()
Gets the level of the entry.
|
int |
getLevel() |
boolean |
getOmitPageNumber()
Gets whether page number in TOC should be omitted for this field.
|
int |
getPageNumber() |
Paragraph |
getParagraph() |
int |
getSequenceValue(java.lang.String sequenceIdentifier) |
int |
getSwitchType(java.lang.String switchName) |
java.lang.String |
getText()
Gets the text of the entry.
|
java.lang.String |
getTypeIdentifier()
Gets a type identifier for this field (which is typically a letter).
|
boolean |
hasBookmark() |
boolean |
isInFieldCode() |
boolean |
isLinkedStyleTocEntry() |
void |
setEntryLevel(java.lang.String value)
Sets the level of the entry.
|
void |
setOmitPageNumber(boolean value)
Sets whether page number in TOC should be omitted for this field.
|
void |
setText(java.lang.String value)
Sets the text of the entry.
|
void |
setTypeIdentifier(java.lang.String value)
Sets a type identifier for this field (which is typically a letter).
|
getDisplayResult, getEnd, getFieldCode, getFieldCode, getFormat, getLocaleId, getResult, getSeparator, getStart, getType, isDirty, isDirty, isLocked, isLocked, needStoreOldResultNodes, remove, setLocaleId, setResult, unlink, update, updatepublic int getSwitchType(java.lang.String switchName)
public java.lang.String getText()
Examples:
Shows how to insert a TOC field, and filter which TC fields end up as entries.
public void fieldTocEntryIdentifier() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a TOC field, which will compile all TC fields into a table of contents.
FieldToc fieldToc = (FieldToc) builder.insertField(FieldType.FIELD_TOC, true);
// Configure the field only to pick up TC entries of the "A" type, and an entry-level between 1 and 3.
fieldToc.setEntryIdentifier("A");
fieldToc.setEntryLevelRange("1-3");
Assert.assertEquals(" TOC \\f A \\l 1-3", fieldToc.getFieldCode());
// These two entries will appear in the table.
builder.insertBreak(BreakType.PAGE_BREAK);
insertTocEntry(builder, "TC field 1", "A", "1");
insertTocEntry(builder, "TC field 2", "A", "2");
Assert.assertEquals(" TC \"TC field 1\" \\n \\f A \\l 1", doc.getRange().getFields().get(1).getFieldCode());
// This entry will be omitted from the table because it has a different type from "A".
insertTocEntry(builder, "TC field 3", "B", "1");
// This entry will be omitted from the table because it has an entry-level outside of the 1-3 range.
insertTocEntry(builder, "TC field 4", "A", "5");
doc.updateFields();
doc.save(getArtifactsDir() + "Field.TC.docx");
}
/// <summary>
/// Use a document builder to insert a TC field.
/// </summary>
public void insertTocEntry(final DocumentBuilder builder, final String text, final String typeIdentifier, final String entryLevel) throws Exception {
FieldTC fieldTc = (FieldTC) builder.insertField(FieldType.FIELD_TOC_ENTRY, true);
fieldTc.setOmitPageNumber(true);
fieldTc.setText(text);
fieldTc.setTypeIdentifier(typeIdentifier);
fieldTc.setEntryLevel(entryLevel);
}
public void setText(java.lang.String value)
throws java.lang.Exception
Examples:
Shows how to insert a TOC field, and filter which TC fields end up as entries.
public void fieldTocEntryIdentifier() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a TOC field, which will compile all TC fields into a table of contents.
FieldToc fieldToc = (FieldToc) builder.insertField(FieldType.FIELD_TOC, true);
// Configure the field only to pick up TC entries of the "A" type, and an entry-level between 1 and 3.
fieldToc.setEntryIdentifier("A");
fieldToc.setEntryLevelRange("1-3");
Assert.assertEquals(" TOC \\f A \\l 1-3", fieldToc.getFieldCode());
// These two entries will appear in the table.
builder.insertBreak(BreakType.PAGE_BREAK);
insertTocEntry(builder, "TC field 1", "A", "1");
insertTocEntry(builder, "TC field 2", "A", "2");
Assert.assertEquals(" TC \"TC field 1\" \\n \\f A \\l 1", doc.getRange().getFields().get(1).getFieldCode());
// This entry will be omitted from the table because it has a different type from "A".
insertTocEntry(builder, "TC field 3", "B", "1");
// This entry will be omitted from the table because it has an entry-level outside of the 1-3 range.
insertTocEntry(builder, "TC field 4", "A", "5");
doc.updateFields();
doc.save(getArtifactsDir() + "Field.TC.docx");
}
/// <summary>
/// Use a document builder to insert a TC field.
/// </summary>
public void insertTocEntry(final DocumentBuilder builder, final String text, final String typeIdentifier, final String entryLevel) throws Exception {
FieldTC fieldTc = (FieldTC) builder.insertField(FieldType.FIELD_TOC_ENTRY, true);
fieldTc.setOmitPageNumber(true);
fieldTc.setText(text);
fieldTc.setTypeIdentifier(typeIdentifier);
fieldTc.setEntryLevel(entryLevel);
}
value - The text of the entry.java.lang.Exceptionpublic java.lang.String getTypeIdentifier()
Examples:
Shows how to insert a TOC field, and filter which TC fields end up as entries.
public void fieldTocEntryIdentifier() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a TOC field, which will compile all TC fields into a table of contents.
FieldToc fieldToc = (FieldToc) builder.insertField(FieldType.FIELD_TOC, true);
// Configure the field only to pick up TC entries of the "A" type, and an entry-level between 1 and 3.
fieldToc.setEntryIdentifier("A");
fieldToc.setEntryLevelRange("1-3");
Assert.assertEquals(" TOC \\f A \\l 1-3", fieldToc.getFieldCode());
// These two entries will appear in the table.
builder.insertBreak(BreakType.PAGE_BREAK);
insertTocEntry(builder, "TC field 1", "A", "1");
insertTocEntry(builder, "TC field 2", "A", "2");
Assert.assertEquals(" TC \"TC field 1\" \\n \\f A \\l 1", doc.getRange().getFields().get(1).getFieldCode());
// This entry will be omitted from the table because it has a different type from "A".
insertTocEntry(builder, "TC field 3", "B", "1");
// This entry will be omitted from the table because it has an entry-level outside of the 1-3 range.
insertTocEntry(builder, "TC field 4", "A", "5");
doc.updateFields();
doc.save(getArtifactsDir() + "Field.TC.docx");
}
/// <summary>
/// Use a document builder to insert a TC field.
/// </summary>
public void insertTocEntry(final DocumentBuilder builder, final String text, final String typeIdentifier, final String entryLevel) throws Exception {
FieldTC fieldTc = (FieldTC) builder.insertField(FieldType.FIELD_TOC_ENTRY, true);
fieldTc.setOmitPageNumber(true);
fieldTc.setText(text);
fieldTc.setTypeIdentifier(typeIdentifier);
fieldTc.setEntryLevel(entryLevel);
}
public void setTypeIdentifier(java.lang.String value)
throws java.lang.Exception
Examples:
Shows how to insert a TOC field, and filter which TC fields end up as entries.
public void fieldTocEntryIdentifier() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a TOC field, which will compile all TC fields into a table of contents.
FieldToc fieldToc = (FieldToc) builder.insertField(FieldType.FIELD_TOC, true);
// Configure the field only to pick up TC entries of the "A" type, and an entry-level between 1 and 3.
fieldToc.setEntryIdentifier("A");
fieldToc.setEntryLevelRange("1-3");
Assert.assertEquals(" TOC \\f A \\l 1-3", fieldToc.getFieldCode());
// These two entries will appear in the table.
builder.insertBreak(BreakType.PAGE_BREAK);
insertTocEntry(builder, "TC field 1", "A", "1");
insertTocEntry(builder, "TC field 2", "A", "2");
Assert.assertEquals(" TC \"TC field 1\" \\n \\f A \\l 1", doc.getRange().getFields().get(1).getFieldCode());
// This entry will be omitted from the table because it has a different type from "A".
insertTocEntry(builder, "TC field 3", "B", "1");
// This entry will be omitted from the table because it has an entry-level outside of the 1-3 range.
insertTocEntry(builder, "TC field 4", "A", "5");
doc.updateFields();
doc.save(getArtifactsDir() + "Field.TC.docx");
}
/// <summary>
/// Use a document builder to insert a TC field.
/// </summary>
public void insertTocEntry(final DocumentBuilder builder, final String text, final String typeIdentifier, final String entryLevel) throws Exception {
FieldTC fieldTc = (FieldTC) builder.insertField(FieldType.FIELD_TOC_ENTRY, true);
fieldTc.setOmitPageNumber(true);
fieldTc.setText(text);
fieldTc.setTypeIdentifier(typeIdentifier);
fieldTc.setEntryLevel(entryLevel);
}
value - A type identifier for this field (which is typically a letter).java.lang.Exceptionpublic java.lang.String getEntryLevel()
Examples:
Shows how to insert a TOC field, and filter which TC fields end up as entries.
public void fieldTocEntryIdentifier() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a TOC field, which will compile all TC fields into a table of contents.
FieldToc fieldToc = (FieldToc) builder.insertField(FieldType.FIELD_TOC, true);
// Configure the field only to pick up TC entries of the "A" type, and an entry-level between 1 and 3.
fieldToc.setEntryIdentifier("A");
fieldToc.setEntryLevelRange("1-3");
Assert.assertEquals(" TOC \\f A \\l 1-3", fieldToc.getFieldCode());
// These two entries will appear in the table.
builder.insertBreak(BreakType.PAGE_BREAK);
insertTocEntry(builder, "TC field 1", "A", "1");
insertTocEntry(builder, "TC field 2", "A", "2");
Assert.assertEquals(" TC \"TC field 1\" \\n \\f A \\l 1", doc.getRange().getFields().get(1).getFieldCode());
// This entry will be omitted from the table because it has a different type from "A".
insertTocEntry(builder, "TC field 3", "B", "1");
// This entry will be omitted from the table because it has an entry-level outside of the 1-3 range.
insertTocEntry(builder, "TC field 4", "A", "5");
doc.updateFields();
doc.save(getArtifactsDir() + "Field.TC.docx");
}
/// <summary>
/// Use a document builder to insert a TC field.
/// </summary>
public void insertTocEntry(final DocumentBuilder builder, final String text, final String typeIdentifier, final String entryLevel) throws Exception {
FieldTC fieldTc = (FieldTC) builder.insertField(FieldType.FIELD_TOC_ENTRY, true);
fieldTc.setOmitPageNumber(true);
fieldTc.setText(text);
fieldTc.setTypeIdentifier(typeIdentifier);
fieldTc.setEntryLevel(entryLevel);
}
public void setEntryLevel(java.lang.String value)
throws java.lang.Exception
Examples:
Shows how to insert a TOC field, and filter which TC fields end up as entries.
public void fieldTocEntryIdentifier() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a TOC field, which will compile all TC fields into a table of contents.
FieldToc fieldToc = (FieldToc) builder.insertField(FieldType.FIELD_TOC, true);
// Configure the field only to pick up TC entries of the "A" type, and an entry-level between 1 and 3.
fieldToc.setEntryIdentifier("A");
fieldToc.setEntryLevelRange("1-3");
Assert.assertEquals(" TOC \\f A \\l 1-3", fieldToc.getFieldCode());
// These two entries will appear in the table.
builder.insertBreak(BreakType.PAGE_BREAK);
insertTocEntry(builder, "TC field 1", "A", "1");
insertTocEntry(builder, "TC field 2", "A", "2");
Assert.assertEquals(" TC \"TC field 1\" \\n \\f A \\l 1", doc.getRange().getFields().get(1).getFieldCode());
// This entry will be omitted from the table because it has a different type from "A".
insertTocEntry(builder, "TC field 3", "B", "1");
// This entry will be omitted from the table because it has an entry-level outside of the 1-3 range.
insertTocEntry(builder, "TC field 4", "A", "5");
doc.updateFields();
doc.save(getArtifactsDir() + "Field.TC.docx");
}
/// <summary>
/// Use a document builder to insert a TC field.
/// </summary>
public void insertTocEntry(final DocumentBuilder builder, final String text, final String typeIdentifier, final String entryLevel) throws Exception {
FieldTC fieldTc = (FieldTC) builder.insertField(FieldType.FIELD_TOC_ENTRY, true);
fieldTc.setOmitPageNumber(true);
fieldTc.setText(text);
fieldTc.setTypeIdentifier(typeIdentifier);
fieldTc.setEntryLevel(entryLevel);
}
value - The level of the entry.java.lang.Exceptionpublic boolean getOmitPageNumber()
Examples:
Shows how to insert a TOC field, and filter which TC fields end up as entries.
public void fieldTocEntryIdentifier() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a TOC field, which will compile all TC fields into a table of contents.
FieldToc fieldToc = (FieldToc) builder.insertField(FieldType.FIELD_TOC, true);
// Configure the field only to pick up TC entries of the "A" type, and an entry-level between 1 and 3.
fieldToc.setEntryIdentifier("A");
fieldToc.setEntryLevelRange("1-3");
Assert.assertEquals(" TOC \\f A \\l 1-3", fieldToc.getFieldCode());
// These two entries will appear in the table.
builder.insertBreak(BreakType.PAGE_BREAK);
insertTocEntry(builder, "TC field 1", "A", "1");
insertTocEntry(builder, "TC field 2", "A", "2");
Assert.assertEquals(" TC \"TC field 1\" \\n \\f A \\l 1", doc.getRange().getFields().get(1).getFieldCode());
// This entry will be omitted from the table because it has a different type from "A".
insertTocEntry(builder, "TC field 3", "B", "1");
// This entry will be omitted from the table because it has an entry-level outside of the 1-3 range.
insertTocEntry(builder, "TC field 4", "A", "5");
doc.updateFields();
doc.save(getArtifactsDir() + "Field.TC.docx");
}
/// <summary>
/// Use a document builder to insert a TC field.
/// </summary>
public void insertTocEntry(final DocumentBuilder builder, final String text, final String typeIdentifier, final String entryLevel) throws Exception {
FieldTC fieldTc = (FieldTC) builder.insertField(FieldType.FIELD_TOC_ENTRY, true);
fieldTc.setOmitPageNumber(true);
fieldTc.setText(text);
fieldTc.setTypeIdentifier(typeIdentifier);
fieldTc.setEntryLevel(entryLevel);
}
public void setOmitPageNumber(boolean value)
throws java.lang.Exception
Examples:
Shows how to insert a TOC field, and filter which TC fields end up as entries.
public void fieldTocEntryIdentifier() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a TOC field, which will compile all TC fields into a table of contents.
FieldToc fieldToc = (FieldToc) builder.insertField(FieldType.FIELD_TOC, true);
// Configure the field only to pick up TC entries of the "A" type, and an entry-level between 1 and 3.
fieldToc.setEntryIdentifier("A");
fieldToc.setEntryLevelRange("1-3");
Assert.assertEquals(" TOC \\f A \\l 1-3", fieldToc.getFieldCode());
// These two entries will appear in the table.
builder.insertBreak(BreakType.PAGE_BREAK);
insertTocEntry(builder, "TC field 1", "A", "1");
insertTocEntry(builder, "TC field 2", "A", "2");
Assert.assertEquals(" TC \"TC field 1\" \\n \\f A \\l 1", doc.getRange().getFields().get(1).getFieldCode());
// This entry will be omitted from the table because it has a different type from "A".
insertTocEntry(builder, "TC field 3", "B", "1");
// This entry will be omitted from the table because it has an entry-level outside of the 1-3 range.
insertTocEntry(builder, "TC field 4", "A", "5");
doc.updateFields();
doc.save(getArtifactsDir() + "Field.TC.docx");
}
/// <summary>
/// Use a document builder to insert a TC field.
/// </summary>
public void insertTocEntry(final DocumentBuilder builder, final String text, final String typeIdentifier, final String entryLevel) throws Exception {
FieldTC fieldTc = (FieldTC) builder.insertField(FieldType.FIELD_TOC_ENTRY, true);
fieldTc.setOmitPageNumber(true);
fieldTc.setText(text);
fieldTc.setTypeIdentifier(typeIdentifier);
fieldTc.setEntryLevel(entryLevel);
}
value - Whether page number in TOC should be omitted for this field.java.lang.Exceptionpublic Paragraph getParagraph()
public int getLevel()
public java.lang.String getDocumentOutlineTitle()
public boolean isInFieldCode()
public boolean hasBookmark()
public boolean isLinkedStyleTocEntry()
public int getSequenceValue(java.lang.String sequenceIdentifier)
public int getPageNumber()