TabStopCollection Class |
Namespace: Aspose.Words
The TabStopCollection type exposes the following members.
| Name | Description | |
|---|---|---|
| Count |
Gets the number of tab stops in the collection.
| |
| ItemDouble |
Gets a tab stop at the specified position.
| |
| ItemInt32 |
Gets a tab stop at the given index.
|
| Name | Description | |
|---|---|---|
| Add(TabStop) |
Adds or replaces a tab stop in the collection.
| |
| Add(Double, TabAlignment, TabLeader) |
Adds or replaces a tab stop in the collection.
| |
| After |
Gets a first tab stop to the right of the specified position.
| |
| Before |
Gets a first tab stop to the left of the specified position.
| |
| Clear |
Deletes all tab stop positions.
| |
| Equals(Object) |
Determines whether the specified object is equal in value to the current object.
(Overrides ObjectEquals(Object).) | |
| Equals(TabStopCollection) |
Determines whether the specified TabStopCollection is equal in value to the current TabStopCollection.
| |
| GetHashCode |
Serves as a hash function for this type.
(Overrides ObjectGetHashCode.) | |
| GetIndexByPosition |
Gets the index of a tab stop with the specified position in points.
| |
| GetPositionByIndex |
Gets the position (in points) of the tab stop at the specified index.
| |
| GetType | (Inherited from Object.) | |
| RemoveByIndex |
Removes a tab stop at the specified index from the collection.
| |
| RemoveByPosition |
Removes a tab stop at the specified position from the collection.
| |
| ToString | (Inherited from Object.) |
In Microsoft Word documents, a tab stop can be defined in the properties of a paragraph style or directly in the properties of a paragraph. A style can be based on another style. Therefore, the complete set of tab stops for a given object is a combination of tab stops defined directly on this object and tab stops inherited from the parent styles.
In Aspose.Words, when you obtain a TabStops collection for a paragraph or a style, it contains only the custom tab stops defined directly for this paragraph or style. The collection does not include tab stops defined in the parent styles or default tab stops.
Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Access the collection of tab stops and add some tab stops to it TabStopCollection tabStops = builder.ParagraphFormat.TabStops; // 72 points is one "inch" on the Microsoft Word tab stop ruler tabStops.Add(new TabStop(72.0)); tabStops.Add(new TabStop(432.0, TabAlignment.Right, TabLeader.Dashes)); Assert.AreEqual(2, tabStops.Count); Assert.IsFalse(tabStops[0].IsClear); Assert.IsFalse(tabStops[0].Equals(tabStops[1])); builder.Writeln("Start\tTab 1\tTab 2"); // Get the collection of paragraphs that we've created ParagraphCollection paragraphs = doc.FirstSection.Body.Paragraphs; Assert.AreEqual(2, paragraphs.Count); // Each paragraph gets its own TabStopCollection which gets values from the DocumentBuilder's collection Assert.AreEqual(paragraphs[0].ParagraphFormat.TabStops, paragraphs[1].ParagraphFormat.TabStops); Assert.AreNotSame(paragraphs[0].ParagraphFormat.TabStops, paragraphs[1].ParagraphFormat.TabStops); Assert.AreNotEqual(paragraphs[0].ParagraphFormat.TabStops.GetHashCode(), paragraphs[1].ParagraphFormat.TabStops.GetHashCode()); // A TabStopCollection can point us to TabStops before and after certain positions Assert.AreEqual(72.0, tabStops.Before(100.0).Position); Assert.AreEqual(432.0, tabStops.After(100.0).Position); doc.Save(ArtifactsDir + "TabStopCollection.TabStops.docx");