java.lang.Objectcom.aspose.words.TabStop
public class TabStop
Normally, a tab stop specifies a position where a tab stop exists. But because
tab stops can be inherited from parent styles, it might be needed for the child object
to define explicitly that there is no tab stop at a given position. To clear
an inherited tab stop at a given position, create a TabStop object and set
For more information see Example:TabAlignment.Clear
.
Document doc = new Document(getMyDir() + "Document.TableOfContents.doc");
// Iterate through all paragraphs in the document
for (Paragraph para : (Iterable<Paragraph>) doc.getChildNodes(NodeType.PARAGRAPH, true))
{
// Check if this paragraph is formatted using the TOC result based styles. This is any style between TOC and TOC9.
if (para.getParagraphFormat().getStyle().getStyleIdentifier() >= StyleIdentifier.TOC_1 && para.getParagraphFormat().getStyle().getStyleIdentifier() <= StyleIdentifier.TOC_9)
{
// Get the first tab used in this paragraph, this should be the tab used to align the page numbers.
TabStop tab = para.getParagraphFormat().getTabStops().get(0);
// Remove the old tab from the collection.
para.getParagraphFormat().getTabStops().removeByPosition(tab.getPosition());
// Insert a new tab using the same properties but at a modified position.
// We could also change the separators used (dots) by passing a different Leader type
para.getParagraphFormat().getTabStops().add(tab.getPosition() - 50, tab.getAlignment(), tab.getLeader());
}
}
doc.save(getMyDir() + "Document.TableOfContentsTabStops Out.doc");
Constructor Summary |
---|
TabStop(double position)
Initializes a new instance of this class. |
TabStop(double position, int alignment, int leader)
Initializes a new instance of this class. |
Property Getters/Setters Summary | ||
---|---|---|
int | getAlignment() | |
void | setAlignment(int value) | |
Gets or sets the alignment of text at this tab stop. The value of the property is TabAlignment integer constant. | ||
boolean | isClear() | |
Returns true if this tab stop clears any existing tab stops in this position. | ||
int | getLeader() | |
void | setLeader(int value) | |
Gets or sets the type of the leader line displayed under the tab character. The value of the property is TabLeader integer constant. | ||
double | getPosition() | |
Gets the position of the tab stop in points. |
Constructor Detail |
---|
public TabStop(double position)
public TabStop(double position, int alignment, int leader)
position
- The position of the tab stop in points.alignment
- A leader
- A Property Getters/Setters Detail |
---|
getAlignment/setAlignment | |
public int getAlignment() / public void setAlignment(int value) |
Example:
Shows how to modify the position of the right tab stop in TOC related paragraphs.Document doc = new Document(getMyDir() + "Document.TableOfContents.doc"); // Iterate through all paragraphs in the document for (Paragraph para : (Iterable<Paragraph>) doc.getChildNodes(NodeType.PARAGRAPH, true)) { // Check if this paragraph is formatted using the TOC result based styles. This is any style between TOC and TOC9. if (para.getParagraphFormat().getStyle().getStyleIdentifier() >= StyleIdentifier.TOC_1 && para.getParagraphFormat().getStyle().getStyleIdentifier() <= StyleIdentifier.TOC_9) { // Get the first tab used in this paragraph, this should be the tab used to align the page numbers. TabStop tab = para.getParagraphFormat().getTabStops().get(0); // Remove the old tab from the collection. para.getParagraphFormat().getTabStops().removeByPosition(tab.getPosition()); // Insert a new tab using the same properties but at a modified position. // We could also change the separators used (dots) by passing a different Leader type para.getParagraphFormat().getTabStops().add(tab.getPosition() - 50, tab.getAlignment(), tab.getLeader()); } } doc.save(getMyDir() + "Document.TableOfContentsTabStops Out.doc");
isClear | |
public boolean isClear() |
getLeader/setLeader | |
public int getLeader() / public void setLeader(int value) |
Example:
Shows how to modify the position of the right tab stop in TOC related paragraphs.Document doc = new Document(getMyDir() + "Document.TableOfContents.doc"); // Iterate through all paragraphs in the document for (Paragraph para : (Iterable<Paragraph>) doc.getChildNodes(NodeType.PARAGRAPH, true)) { // Check if this paragraph is formatted using the TOC result based styles. This is any style between TOC and TOC9. if (para.getParagraphFormat().getStyle().getStyleIdentifier() >= StyleIdentifier.TOC_1 && para.getParagraphFormat().getStyle().getStyleIdentifier() <= StyleIdentifier.TOC_9) { // Get the first tab used in this paragraph, this should be the tab used to align the page numbers. TabStop tab = para.getParagraphFormat().getTabStops().get(0); // Remove the old tab from the collection. para.getParagraphFormat().getTabStops().removeByPosition(tab.getPosition()); // Insert a new tab using the same properties but at a modified position. // We could also change the separators used (dots) by passing a different Leader type para.getParagraphFormat().getTabStops().add(tab.getPosition() - 50, tab.getAlignment(), tab.getLeader()); } } doc.save(getMyDir() + "Document.TableOfContentsTabStops Out.doc");
getPosition | |
public double getPosition() |
Example:
Shows how to modify the position of the right tab stop in TOC related paragraphs.Document doc = new Document(getMyDir() + "Document.TableOfContents.doc"); // Iterate through all paragraphs in the document for (Paragraph para : (Iterable<Paragraph>) doc.getChildNodes(NodeType.PARAGRAPH, true)) { // Check if this paragraph is formatted using the TOC result based styles. This is any style between TOC and TOC9. if (para.getParagraphFormat().getStyle().getStyleIdentifier() >= StyleIdentifier.TOC_1 && para.getParagraphFormat().getStyle().getStyleIdentifier() <= StyleIdentifier.TOC_9) { // Get the first tab used in this paragraph, this should be the tab used to align the page numbers. TabStop tab = para.getParagraphFormat().getTabStops().get(0); // Remove the old tab from the collection. para.getParagraphFormat().getTabStops().removeByPosition(tab.getPosition()); // Insert a new tab using the same properties but at a modified position. // We could also change the separators used (dots) by passing a different Leader type para.getParagraphFormat().getTabStops().add(tab.getPosition() - 50, tab.getAlignment(), tab.getLeader()); } } doc.save(getMyDir() + "Document.TableOfContentsTabStops Out.doc");