Aspose::Words::TabStopCollection Class Reference

Detailed Description

A collection of TabStop objects that represent custom tabs for a paragraph or a style.

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.

See also
Aspose::Words::ParagraphFormat
Aspose::Words::TabStop
Aspose::Words::Document::get_DefaultTabStop
Examples

Shows how to work with a document's collection of tab stops.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<TabStopCollection> tabStops = builder->get_ParagraphFormat()->get_TabStops();
// 72 points is one "inch" on the Microsoft Word tab stop ruler.
tabStops->Add(MakeObject<TabStop>(72.0));
tabStops->Add(MakeObject<TabStop>(432.0, TabAlignment::Right, TabLeader::Dashes));
ASSERT_EQ(2, tabStops->get_Count());
ASSERT_FALSE(tabStops->idx_get(0)->get_IsClear());
ASSERT_FALSE(System::ObjectExt::Equals(tabStops->idx_get(0), tabStops->idx_get(1)));
// Every "tab" character takes the builder's cursor to the location of the next tab stop.
builder->Writeln(u"Start\tTab 1\tTab 2");
SharedPtr<ParagraphCollection> paragraphs = doc->get_FirstSection()->get_Body()->get_Paragraphs();
ASSERT_EQ(2, paragraphs->get_Count());
// Each paragraph gets its tab stop collection, which clones its values from the document builder's tab stop collection.
ASPOSE_ASSERT_EQ(paragraphs->idx_get(0)->get_ParagraphFormat()->get_TabStops(), paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops());
ASPOSE_ASSERT_NS(paragraphs->idx_get(0)->get_ParagraphFormat()->get_TabStops(), paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops());
// A tab stop collection can point us to TabStops before and after certain positions.
ASPOSE_ASSERT_EQ(72.0, tabStops->Before(100.0)->get_Position());
ASPOSE_ASSERT_EQ(432.0, tabStops->After(100.0)->get_Position());
// We can clear a paragraph's tab stop collection to revert to the default tabbing behavior.
paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops()->Clear();
ASSERT_EQ(0, paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops()->get_Count());
doc->Save(ArtifactsDir + u"TabStopCollection.TabStopCollection.docx");

#include <Aspose.Words.Cpp/TabStopCollection.h>

+ Inheritance diagram for Aspose::Words::TabStopCollection:

Public Member Functions

void Add (const SharedPtr< TabStop > &tabStop)
 Adds or replaces a tab stop in the collection. More...
 
void Add (double position, TabAlignment alignment, TabLeader leader)
 Adds or replaces a tab stop in the collection. More...
 
SharedPtr< TabStopAfter (double position)
 Gets a first tab stop to the right of the specified position. More...
 
SharedPtr< TabStopBefore (double position)
 Gets a first tab stop to the left of the specified position. More...
 
void Clear ()
 Deletes all tab stop positions. More...
 
bool Equals (const SharedPtr< TabStopCollection > &rhs)
 Determines whether the specified TabStopCollection is equal in value to the current TabStopCollection. More...
 
bool Equals (SharedPtr< Object > obj) override
 Determines whether the specified object is equal in value to the current object. More...
 
int32_t get_Count ()
 Gets the number of tab stops in the collection. More...
 
int32_t GetHashCode () const override
 Serves as a hash function for this type. More...
 
int32_t GetIndexByPosition (double position)
 Gets the index of a tab stop with the specified position in points. More...
 
double GetPositionByIndex (int32_t index)
 Gets the position (in points) of the tab stop at the specified index. More...
 
virtual const TypeInfoGetType () const override
 
SharedPtr< TabStopidx_get (double position)
 Gets a tab stop at the specified position. More...
 
SharedPtr< TabStopidx_get (int32_t index)
 Gets a tab stop at the given index. More...
 
virtual bool Is (const TypeInfo &target) const override
 
void RemoveByIndex (int32_t index)
 Removes a tab stop at the specified index from the collection. More...
 
void RemoveByPosition (double position)
 Removes a tab stop at the specified position from the collection. More...
 

Static Public Member Functions

static const TypeInfoType ()
 
- Static Public Member Functions inherited from InternableComplexAttr
static const TypeInfoType ()
 

Member Function Documentation

◆ Add() [1/2]

void Aspose::Words::TabStopCollection::Add ( const System::SharedPtr< Aspose::Words::TabStop > &  tabStop)

Adds or replaces a tab stop in the collection.

If a tab stop already exists at the specified position, it is replaced.

Parameters
tabStopA tab stop object to add.
Examples

Shows how to add custom tab stops to a document.

auto doc = MakeObject<Document>();
auto paragraph = System::DynamicCast<Paragraph>(doc->GetChild(NodeType::Paragraph, 0, true));
// Below are two ways of adding tab stops to a paragraph's collection of tab stops via the "ParagraphFormat" property.
// 1 - Create a "TabStop" object, and then add it to the collection:
auto tabStop = MakeObject<TabStop>(ConvertUtil::InchToPoint(3), TabAlignment::Left, TabLeader::Dashes);
paragraph->get_ParagraphFormat()->get_TabStops()->Add(tabStop);
// 2 - Pass the values for properties of a new tab stop to the "Add" method:
paragraph->get_ParagraphFormat()->get_TabStops()->Add(ConvertUtil::MillimeterToPoint(100), TabAlignment::Left, TabLeader::Dashes);
// Add tab stops at 5 cm to all paragraphs.
for (const auto& para : System::IterateOver(doc->GetChildNodes(NodeType::Paragraph, true)->LINQ_OfType<SharedPtr<Paragraph>>()))
{
para->get_ParagraphFormat()->get_TabStops()->Add(ConvertUtil::MillimeterToPoint(50), TabAlignment::Left, TabLeader::Dashes);
}
// Every "tab" character takes the builder's cursor to the location of the next tab stop.
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Start\tTab 1\tTab 2\tTab 3\tTab 4");
doc->Save(ArtifactsDir + u"TabStopCollection.AddTabStops.docx");

◆ Add() [2/2]

void Aspose::Words::TabStopCollection::Add ( double  position,
Aspose::Words::TabAlignment  alignment,
Aspose::Words::TabLeader  leader 
)

Adds or replaces a tab stop in the collection.

If a tab stop already exists at the specified position, it is replaced.

Parameters
positionA position (in points) where to add the tab stop.
alignmentA TabAlignment value that specifies the alignment of text at the tab stop.
leaderA TabLeader value that specifies the type of the leader line displayed under the tab character.
Examples

Shows how to add custom tab stops to a document.

auto doc = MakeObject<Document>();
auto paragraph = System::DynamicCast<Paragraph>(doc->GetChild(NodeType::Paragraph, 0, true));
// Below are two ways of adding tab stops to a paragraph's collection of tab stops via the "ParagraphFormat" property.
// 1 - Create a "TabStop" object, and then add it to the collection:
auto tabStop = MakeObject<TabStop>(ConvertUtil::InchToPoint(3), TabAlignment::Left, TabLeader::Dashes);
paragraph->get_ParagraphFormat()->get_TabStops()->Add(tabStop);
// 2 - Pass the values for properties of a new tab stop to the "Add" method:
paragraph->get_ParagraphFormat()->get_TabStops()->Add(ConvertUtil::MillimeterToPoint(100), TabAlignment::Left, TabLeader::Dashes);
// Add tab stops at 5 cm to all paragraphs.
for (const auto& para : System::IterateOver(doc->GetChildNodes(NodeType::Paragraph, true)->LINQ_OfType<SharedPtr<Paragraph>>()))
{
para->get_ParagraphFormat()->get_TabStops()->Add(ConvertUtil::MillimeterToPoint(50), TabAlignment::Left, TabLeader::Dashes);
}
// Every "tab" character takes the builder's cursor to the location of the next tab stop.
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Start\tTab 1\tTab 2\tTab 3\tTab 4");
doc->Save(ArtifactsDir + u"TabStopCollection.AddTabStops.docx");

◆ After()

System::SharedPtr<Aspose::Words::TabStop> Aspose::Words::TabStopCollection::After ( double  position)

Gets a first tab stop to the right of the specified position.

Skips tab stops with Alignment set to TabAlignment.Bar.

Parameters
positionThe reference position (in points).
Returns
A tab stop object or null if a suitable tab stop was not found.
Examples

Shows how to work with a document's collection of tab stops.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<TabStopCollection> tabStops = builder->get_ParagraphFormat()->get_TabStops();
// 72 points is one "inch" on the Microsoft Word tab stop ruler.
tabStops->Add(MakeObject<TabStop>(72.0));
tabStops->Add(MakeObject<TabStop>(432.0, TabAlignment::Right, TabLeader::Dashes));
ASSERT_EQ(2, tabStops->get_Count());
ASSERT_FALSE(tabStops->idx_get(0)->get_IsClear());
ASSERT_FALSE(System::ObjectExt::Equals(tabStops->idx_get(0), tabStops->idx_get(1)));
// Every "tab" character takes the builder's cursor to the location of the next tab stop.
builder->Writeln(u"Start\tTab 1\tTab 2");
SharedPtr<ParagraphCollection> paragraphs = doc->get_FirstSection()->get_Body()->get_Paragraphs();
ASSERT_EQ(2, paragraphs->get_Count());
// Each paragraph gets its tab stop collection, which clones its values from the document builder's tab stop collection.
ASPOSE_ASSERT_EQ(paragraphs->idx_get(0)->get_ParagraphFormat()->get_TabStops(), paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops());
ASPOSE_ASSERT_NS(paragraphs->idx_get(0)->get_ParagraphFormat()->get_TabStops(), paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops());
// A tab stop collection can point us to TabStops before and after certain positions.
ASPOSE_ASSERT_EQ(72.0, tabStops->Before(100.0)->get_Position());
ASPOSE_ASSERT_EQ(432.0, tabStops->After(100.0)->get_Position());
// We can clear a paragraph's tab stop collection to revert to the default tabbing behavior.
paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops()->Clear();
ASSERT_EQ(0, paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops()->get_Count());
doc->Save(ArtifactsDir + u"TabStopCollection.TabStopCollection.docx");

◆ Before()

System::SharedPtr<Aspose::Words::TabStop> Aspose::Words::TabStopCollection::Before ( double  position)

Gets a first tab stop to the left of the specified position.

Skips tab stops with Alignment set to TabAlignment.Bar.

Parameters
positionThe reference position (in points).
Returns
A tab stop object or null if a suitable tab stop was not found.
Examples

Shows how to work with a document's collection of tab stops.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<TabStopCollection> tabStops = builder->get_ParagraphFormat()->get_TabStops();
// 72 points is one "inch" on the Microsoft Word tab stop ruler.
tabStops->Add(MakeObject<TabStop>(72.0));
tabStops->Add(MakeObject<TabStop>(432.0, TabAlignment::Right, TabLeader::Dashes));
ASSERT_EQ(2, tabStops->get_Count());
ASSERT_FALSE(tabStops->idx_get(0)->get_IsClear());
ASSERT_FALSE(System::ObjectExt::Equals(tabStops->idx_get(0), tabStops->idx_get(1)));
// Every "tab" character takes the builder's cursor to the location of the next tab stop.
builder->Writeln(u"Start\tTab 1\tTab 2");
SharedPtr<ParagraphCollection> paragraphs = doc->get_FirstSection()->get_Body()->get_Paragraphs();
ASSERT_EQ(2, paragraphs->get_Count());
// Each paragraph gets its tab stop collection, which clones its values from the document builder's tab stop collection.
ASPOSE_ASSERT_EQ(paragraphs->idx_get(0)->get_ParagraphFormat()->get_TabStops(), paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops());
ASPOSE_ASSERT_NS(paragraphs->idx_get(0)->get_ParagraphFormat()->get_TabStops(), paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops());
// A tab stop collection can point us to TabStops before and after certain positions.
ASPOSE_ASSERT_EQ(72.0, tabStops->Before(100.0)->get_Position());
ASPOSE_ASSERT_EQ(432.0, tabStops->After(100.0)->get_Position());
// We can clear a paragraph's tab stop collection to revert to the default tabbing behavior.
paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops()->Clear();
ASSERT_EQ(0, paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops()->get_Count());
doc->Save(ArtifactsDir + u"TabStopCollection.TabStopCollection.docx");

◆ Clear()

void Aspose::Words::TabStopCollection::Clear ( )

Deletes all tab stop positions.

Examples

Shows how to work with a document's collection of tab stops.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<TabStopCollection> tabStops = builder->get_ParagraphFormat()->get_TabStops();
// 72 points is one "inch" on the Microsoft Word tab stop ruler.
tabStops->Add(MakeObject<TabStop>(72.0));
tabStops->Add(MakeObject<TabStop>(432.0, TabAlignment::Right, TabLeader::Dashes));
ASSERT_EQ(2, tabStops->get_Count());
ASSERT_FALSE(tabStops->idx_get(0)->get_IsClear());
ASSERT_FALSE(System::ObjectExt::Equals(tabStops->idx_get(0), tabStops->idx_get(1)));
// Every "tab" character takes the builder's cursor to the location of the next tab stop.
builder->Writeln(u"Start\tTab 1\tTab 2");
SharedPtr<ParagraphCollection> paragraphs = doc->get_FirstSection()->get_Body()->get_Paragraphs();
ASSERT_EQ(2, paragraphs->get_Count());
// Each paragraph gets its tab stop collection, which clones its values from the document builder's tab stop collection.
ASPOSE_ASSERT_EQ(paragraphs->idx_get(0)->get_ParagraphFormat()->get_TabStops(), paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops());
ASPOSE_ASSERT_NS(paragraphs->idx_get(0)->get_ParagraphFormat()->get_TabStops(), paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops());
// A tab stop collection can point us to TabStops before and after certain positions.
ASPOSE_ASSERT_EQ(72.0, tabStops->Before(100.0)->get_Position());
ASPOSE_ASSERT_EQ(432.0, tabStops->After(100.0)->get_Position());
// We can clear a paragraph's tab stop collection to revert to the default tabbing behavior.
paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops()->Clear();
ASSERT_EQ(0, paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops()->get_Count());
doc->Save(ArtifactsDir + u"TabStopCollection.TabStopCollection.docx");

◆ Equals() [1/2]

bool Aspose::Words::TabStopCollection::Equals ( const System::SharedPtr< Aspose::Words::TabStopCollection > &  rhs)

Determines whether the specified TabStopCollection is equal in value to the current TabStopCollection.

Examples

Shows how to work with a document's collection of tab stops.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<TabStopCollection> tabStops = builder->get_ParagraphFormat()->get_TabStops();
// 72 points is one "inch" on the Microsoft Word tab stop ruler.
tabStops->Add(MakeObject<TabStop>(72.0));
tabStops->Add(MakeObject<TabStop>(432.0, TabAlignment::Right, TabLeader::Dashes));
ASSERT_EQ(2, tabStops->get_Count());
ASSERT_FALSE(tabStops->idx_get(0)->get_IsClear());
ASSERT_FALSE(System::ObjectExt::Equals(tabStops->idx_get(0), tabStops->idx_get(1)));
// Every "tab" character takes the builder's cursor to the location of the next tab stop.
builder->Writeln(u"Start\tTab 1\tTab 2");
SharedPtr<ParagraphCollection> paragraphs = doc->get_FirstSection()->get_Body()->get_Paragraphs();
ASSERT_EQ(2, paragraphs->get_Count());
// Each paragraph gets its tab stop collection, which clones its values from the document builder's tab stop collection.
ASPOSE_ASSERT_EQ(paragraphs->idx_get(0)->get_ParagraphFormat()->get_TabStops(), paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops());
ASPOSE_ASSERT_NS(paragraphs->idx_get(0)->get_ParagraphFormat()->get_TabStops(), paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops());
// A tab stop collection can point us to TabStops before and after certain positions.
ASPOSE_ASSERT_EQ(72.0, tabStops->Before(100.0)->get_Position());
ASPOSE_ASSERT_EQ(432.0, tabStops->After(100.0)->get_Position());
// We can clear a paragraph's tab stop collection to revert to the default tabbing behavior.
paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops()->Clear();
ASSERT_EQ(0, paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops()->get_Count());
doc->Save(ArtifactsDir + u"TabStopCollection.TabStopCollection.docx");

◆ Equals() [2/2]

bool Aspose::Words::TabStopCollection::Equals ( System::SharedPtr< System::Object obj)
override

Determines whether the specified object is equal in value to the current object.

Examples

Shows how to work with a document's collection of tab stops.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<TabStopCollection> tabStops = builder->get_ParagraphFormat()->get_TabStops();
// 72 points is one "inch" on the Microsoft Word tab stop ruler.
tabStops->Add(MakeObject<TabStop>(72.0));
tabStops->Add(MakeObject<TabStop>(432.0, TabAlignment::Right, TabLeader::Dashes));
ASSERT_EQ(2, tabStops->get_Count());
ASSERT_FALSE(tabStops->idx_get(0)->get_IsClear());
ASSERT_FALSE(System::ObjectExt::Equals(tabStops->idx_get(0), tabStops->idx_get(1)));
// Every "tab" character takes the builder's cursor to the location of the next tab stop.
builder->Writeln(u"Start\tTab 1\tTab 2");
SharedPtr<ParagraphCollection> paragraphs = doc->get_FirstSection()->get_Body()->get_Paragraphs();
ASSERT_EQ(2, paragraphs->get_Count());
// Each paragraph gets its tab stop collection, which clones its values from the document builder's tab stop collection.
ASPOSE_ASSERT_EQ(paragraphs->idx_get(0)->get_ParagraphFormat()->get_TabStops(), paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops());
ASPOSE_ASSERT_NS(paragraphs->idx_get(0)->get_ParagraphFormat()->get_TabStops(), paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops());
// A tab stop collection can point us to TabStops before and after certain positions.
ASPOSE_ASSERT_EQ(72.0, tabStops->Before(100.0)->get_Position());
ASPOSE_ASSERT_EQ(432.0, tabStops->After(100.0)->get_Position());
// We can clear a paragraph's tab stop collection to revert to the default tabbing behavior.
paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops()->Clear();
ASSERT_EQ(0, paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops()->get_Count());
doc->Save(ArtifactsDir + u"TabStopCollection.TabStopCollection.docx");

◆ get_Count()

int32_t Aspose::Words::TabStopCollection::get_Count ( )

Gets the number of tab stops in the collection.

Examples

Shows how to work with a document's collection of tab stops.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<TabStopCollection> tabStops = builder->get_ParagraphFormat()->get_TabStops();
// 72 points is one "inch" on the Microsoft Word tab stop ruler.
tabStops->Add(MakeObject<TabStop>(72.0));
tabStops->Add(MakeObject<TabStop>(432.0, TabAlignment::Right, TabLeader::Dashes));
ASSERT_EQ(2, tabStops->get_Count());
ASSERT_FALSE(tabStops->idx_get(0)->get_IsClear());
ASSERT_FALSE(System::ObjectExt::Equals(tabStops->idx_get(0), tabStops->idx_get(1)));
// Every "tab" character takes the builder's cursor to the location of the next tab stop.
builder->Writeln(u"Start\tTab 1\tTab 2");
SharedPtr<ParagraphCollection> paragraphs = doc->get_FirstSection()->get_Body()->get_Paragraphs();
ASSERT_EQ(2, paragraphs->get_Count());
// Each paragraph gets its tab stop collection, which clones its values from the document builder's tab stop collection.
ASPOSE_ASSERT_EQ(paragraphs->idx_get(0)->get_ParagraphFormat()->get_TabStops(), paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops());
ASPOSE_ASSERT_NS(paragraphs->idx_get(0)->get_ParagraphFormat()->get_TabStops(), paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops());
// A tab stop collection can point us to TabStops before and after certain positions.
ASPOSE_ASSERT_EQ(72.0, tabStops->Before(100.0)->get_Position());
ASPOSE_ASSERT_EQ(432.0, tabStops->After(100.0)->get_Position());
// We can clear a paragraph's tab stop collection to revert to the default tabbing behavior.
paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops()->Clear();
ASSERT_EQ(0, paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops()->get_Count());
doc->Save(ArtifactsDir + u"TabStopCollection.TabStopCollection.docx");

◆ GetHashCode()

int32_t Aspose::Words::TabStopCollection::GetHashCode ( ) const
overridevirtual

Serves as a hash function for this type.

Examples

Shows how to work with a document's collection of tab stops.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<TabStopCollection> tabStops = builder->get_ParagraphFormat()->get_TabStops();
// 72 points is one "inch" on the Microsoft Word tab stop ruler.
tabStops->Add(MakeObject<TabStop>(72.0));
tabStops->Add(MakeObject<TabStop>(432.0, TabAlignment::Right, TabLeader::Dashes));
ASSERT_EQ(2, tabStops->get_Count());
ASSERT_FALSE(tabStops->idx_get(0)->get_IsClear());
ASSERT_FALSE(System::ObjectExt::Equals(tabStops->idx_get(0), tabStops->idx_get(1)));
// Every "tab" character takes the builder's cursor to the location of the next tab stop.
builder->Writeln(u"Start\tTab 1\tTab 2");
SharedPtr<ParagraphCollection> paragraphs = doc->get_FirstSection()->get_Body()->get_Paragraphs();
ASSERT_EQ(2, paragraphs->get_Count());
// Each paragraph gets its tab stop collection, which clones its values from the document builder's tab stop collection.
ASPOSE_ASSERT_EQ(paragraphs->idx_get(0)->get_ParagraphFormat()->get_TabStops(), paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops());
ASPOSE_ASSERT_NS(paragraphs->idx_get(0)->get_ParagraphFormat()->get_TabStops(), paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops());
// A tab stop collection can point us to TabStops before and after certain positions.
ASPOSE_ASSERT_EQ(72.0, tabStops->Before(100.0)->get_Position());
ASPOSE_ASSERT_EQ(432.0, tabStops->After(100.0)->get_Position());
// We can clear a paragraph's tab stop collection to revert to the default tabbing behavior.
paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops()->Clear();
ASSERT_EQ(0, paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops()->get_Count());
doc->Save(ArtifactsDir + u"TabStopCollection.TabStopCollection.docx");

Reimplemented from System::Object.

◆ GetIndexByPosition()

int32_t Aspose::Words::TabStopCollection::GetIndexByPosition ( double  position)

Gets the index of a tab stop with the specified position in points.

Examples

Shows how to look up a position to see if a tab stop exists there and obtain its index.

auto doc = MakeObject<Document>();
SharedPtr<TabStopCollection> tabStops = doc->get_FirstSection()->get_Body()->get_Paragraphs()->idx_get(0)->get_ParagraphFormat()->get_TabStops();
// Add a tab stop at a position of 30mm.
// A result of "0" returned by "GetIndexByPosition" confirms that a tab stop
// at 30mm exists in this collection, and it is at index 0.
ASSERT_EQ(0, tabStops->GetIndexByPosition(ConvertUtil::MillimeterToPoint(30)));
// A "-1" returned by "GetIndexByPosition" confirms that
// there is no tab stop in this collection with a position of 60mm.
ASSERT_EQ(-1, tabStops->GetIndexByPosition(ConvertUtil::MillimeterToPoint(60)));

◆ GetPositionByIndex()

double Aspose::Words::TabStopCollection::GetPositionByIndex ( int32_t  index)

Gets the position (in points) of the tab stop at the specified index.

Parameters
indexAn index into the collection of tab stops.
Returns
The position of the tab stop.
Examples

Shows how to find a tab, stop by its index and verify its position.

auto doc = MakeObject<Document>();
SharedPtr<TabStopCollection> tabStops = doc->get_FirstSection()->get_Body()->get_Paragraphs()->idx_get(0)->get_ParagraphFormat()->get_TabStops();
// Verify the position of the second tab stop in the collection.
ASSERT_NEAR(ConvertUtil::MillimeterToPoint(60), tabStops->GetPositionByIndex(1), 0.1);

◆ GetType()

virtual const System::TypeInfo& Aspose::Words::TabStopCollection::GetType ( ) const
overridevirtual

◆ idx_get() [1/2]

System::SharedPtr<Aspose::Words::TabStop> Aspose::Words::TabStopCollection::idx_get ( double  position)

Gets a tab stop at the specified position.

Parameters
positionThe position (in points) of the tab stop.
Examples

Shows how to work with a document's collection of tab stops.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<TabStopCollection> tabStops = builder->get_ParagraphFormat()->get_TabStops();
// 72 points is one "inch" on the Microsoft Word tab stop ruler.
tabStops->Add(MakeObject<TabStop>(72.0));
tabStops->Add(MakeObject<TabStop>(432.0, TabAlignment::Right, TabLeader::Dashes));
ASSERT_EQ(2, tabStops->get_Count());
ASSERT_FALSE(tabStops->idx_get(0)->get_IsClear());
ASSERT_FALSE(System::ObjectExt::Equals(tabStops->idx_get(0), tabStops->idx_get(1)));
// Every "tab" character takes the builder's cursor to the location of the next tab stop.
builder->Writeln(u"Start\tTab 1\tTab 2");
SharedPtr<ParagraphCollection> paragraphs = doc->get_FirstSection()->get_Body()->get_Paragraphs();
ASSERT_EQ(2, paragraphs->get_Count());
// Each paragraph gets its tab stop collection, which clones its values from the document builder's tab stop collection.
ASPOSE_ASSERT_EQ(paragraphs->idx_get(0)->get_ParagraphFormat()->get_TabStops(), paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops());
ASPOSE_ASSERT_NS(paragraphs->idx_get(0)->get_ParagraphFormat()->get_TabStops(), paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops());
// A tab stop collection can point us to TabStops before and after certain positions.
ASPOSE_ASSERT_EQ(72.0, tabStops->Before(100.0)->get_Position());
ASPOSE_ASSERT_EQ(432.0, tabStops->After(100.0)->get_Position());
// We can clear a paragraph's tab stop collection to revert to the default tabbing behavior.
paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops()->Clear();
ASSERT_EQ(0, paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops()->get_Count());
doc->Save(ArtifactsDir + u"TabStopCollection.TabStopCollection.docx");

◆ idx_get() [2/2]

System::SharedPtr<Aspose::Words::TabStop> Aspose::Words::TabStopCollection::idx_get ( int32_t  index)

Gets a tab stop at the given index.

Parameters
indexAn index into the collection of tab stops.
Examples

Shows how to work with a document's collection of tab stops.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<TabStopCollection> tabStops = builder->get_ParagraphFormat()->get_TabStops();
// 72 points is one "inch" on the Microsoft Word tab stop ruler.
tabStops->Add(MakeObject<TabStop>(72.0));
tabStops->Add(MakeObject<TabStop>(432.0, TabAlignment::Right, TabLeader::Dashes));
ASSERT_EQ(2, tabStops->get_Count());
ASSERT_FALSE(tabStops->idx_get(0)->get_IsClear());
ASSERT_FALSE(System::ObjectExt::Equals(tabStops->idx_get(0), tabStops->idx_get(1)));
// Every "tab" character takes the builder's cursor to the location of the next tab stop.
builder->Writeln(u"Start\tTab 1\tTab 2");
SharedPtr<ParagraphCollection> paragraphs = doc->get_FirstSection()->get_Body()->get_Paragraphs();
ASSERT_EQ(2, paragraphs->get_Count());
// Each paragraph gets its tab stop collection, which clones its values from the document builder's tab stop collection.
ASPOSE_ASSERT_EQ(paragraphs->idx_get(0)->get_ParagraphFormat()->get_TabStops(), paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops());
ASPOSE_ASSERT_NS(paragraphs->idx_get(0)->get_ParagraphFormat()->get_TabStops(), paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops());
// A tab stop collection can point us to TabStops before and after certain positions.
ASPOSE_ASSERT_EQ(72.0, tabStops->Before(100.0)->get_Position());
ASPOSE_ASSERT_EQ(432.0, tabStops->After(100.0)->get_Position());
// We can clear a paragraph's tab stop collection to revert to the default tabbing behavior.
paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops()->Clear();
ASSERT_EQ(0, paragraphs->idx_get(1)->get_ParagraphFormat()->get_TabStops()->get_Count());
doc->Save(ArtifactsDir + u"TabStopCollection.TabStopCollection.docx");

◆ Is()

virtual bool Aspose::Words::TabStopCollection::Is ( const System::TypeInfo target) const
overridevirtual

◆ RemoveByIndex()

void Aspose::Words::TabStopCollection::RemoveByIndex ( int32_t  index)

Removes a tab stop at the specified index from the collection.

Parameters
indexAn index into the collection of tab stops.
Examples

Shows how to select a tab stop in a document by its index and remove it.

auto doc = MakeObject<Document>();
SharedPtr<TabStopCollection> tabStops = doc->get_FirstSection()->get_Body()->get_Paragraphs()->idx_get(0)->get_ParagraphFormat()->get_TabStops();
ASSERT_EQ(2, tabStops->get_Count());
// Remove the first tab stop.
tabStops->RemoveByIndex(0);
ASSERT_EQ(1, tabStops->get_Count());
doc->Save(ArtifactsDir + u"TabStopCollection.RemoveByIndex.docx");

◆ RemoveByPosition()

void Aspose::Words::TabStopCollection::RemoveByPosition ( double  position)

Removes a tab stop at the specified position from the collection.

Parameters
positionThe position (in points) of the tab stop to remove.
Examples

Shows how to modify the position of the right tab stop in TOC related paragraphs.

auto doc = MakeObject<Document>(MyDir + u"Table of contents.docx");
// Iterate through all paragraphs with TOC result-based styles; this is any style between TOC and TOC9.
for (const auto& para : System::IterateOver(doc->GetChildNodes(NodeType::Paragraph, true)->LINQ_OfType<SharedPtr<Paragraph>>()))
{
if (para->get_ParagraphFormat()->get_Style()->get_StyleIdentifier() >= StyleIdentifier::Toc1 &&
para->get_ParagraphFormat()->get_Style()->get_StyleIdentifier() <= StyleIdentifier::Toc9)
{
// Get the first tab used in this paragraph, this should be the tab used to align the page numbers.
SharedPtr<TabStop> tab = para->get_ParagraphFormat()->get_TabStops()->idx_get(0);
// Replace the first default tab, stop with a custom tab stop.
para->get_ParagraphFormat()->get_TabStops()->RemoveByPosition(tab->get_Position());
para->get_ParagraphFormat()->get_TabStops()->Add(tab->get_Position() - 50, tab->get_Alignment(), tab->get_Leader());
}
}
doc->Save(ArtifactsDir + u"Styles.ChangeTocsTabStops.docx");

◆ Type()

static const System::TypeInfo& Aspose::Words::TabStopCollection::Type ( )
static