search/mag_sel search/close
Aspose::Words::Fields::FieldListNum Class Reference

Implements the LISTNUM field.

Examples

Shows how to number paragraphs with LISTNUM fields.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// LISTNUM fields display a number that increments at each LISTNUM field.
// These fields also have a variety of options that allow us to use them to emulate numbered lists.
auto field = System::DynamicCast<FieldListNum>(builder->InsertField(FieldType::FieldListNum, true));
// Lists start counting at 1 by default, but we can set this number to a different value, such as 0.
// This field will display "0)".
field->set_StartingNumber(u"0");
builder->Writeln(u"Paragraph 1");
ASSERT_EQ(u" LISTNUM \\s 0", field->GetFieldCode());
// LISTNUM fields maintain separate counts for each list level.
// Inserting a LISTNUM field in the same paragraph as another LISTNUM field
// increases the list level instead of the count.
// The next field will continue the count we started above and display a value of "1" at list level 1.
builder->InsertField(FieldType::FieldListNum, true);
// This field will start a count at list level 2. It will display a value of "1".
builder->InsertField(FieldType::FieldListNum, true);
// This field will start a count at list level 3. It will display a value of "1".
// Different list levels have different formatting,
// so these fields combined will display a value of "1)a)i)".
builder->InsertField(FieldType::FieldListNum, true);
builder->Writeln(u"Paragraph 2");
// The next LISTNUM field that we insert will continue the count at the list level
// that the previous LISTNUM field was on.
// We can use the "ListLevel" property to jump to a different list level.
// If this LISTNUM field stayed on list level 3, it would display "ii)",
// but, since we have moved it to list level 2, it carries on the count at that level and displays "b)".
field = System::DynamicCast<FieldListNum>(builder->InsertField(FieldType::FieldListNum, true));
field->set_ListLevel(u"2");
builder->Writeln(u"Paragraph 3");
ASSERT_EQ(u" LISTNUM \\l 2", field->GetFieldCode());
// We can set the ListName property to get the field to emulate a different AUTONUM field type.
// "NumberDefault" emulates AUTONUM, "OutlineDefault" emulates AUTONUMOUT,
// and "LegalDefault" emulates AUTONUMLGL fields.
// The "OutlineDefault" list name with 1 as the starting number will result in displaying "I.".
field = System::DynamicCast<FieldListNum>(builder->InsertField(FieldType::FieldListNum, true));
field->set_StartingNumber(u"1");
field->set_ListName(u"OutlineDefault");
builder->Writeln(u"Paragraph 4");
ASSERT_TRUE(field->get_HasListName());
ASSERT_EQ(u" LISTNUM OutlineDefault \\s 1", field->GetFieldCode());
// The ListName does not carry over from the previous field, so we will need to set it for each new field.
// This field continues the count with the different list name and displays "II.".
field = System::DynamicCast<FieldListNum>(builder->InsertField(FieldType::FieldListNum, true));
field->set_ListName(u"OutlineDefault");
builder->Writeln(u"Paragraph 5");
doc->UpdateFields();
doc->Save(ArtifactsDir + u"Field.LISTNUM.docx");

#include <Aspose.Words.Cpp/Fields/FieldListNum.h>

+ Inheritance diagram for Aspose::Words::Fields::FieldListNum:

Public Member Functions

bool get_HasListName ()
 Returns a value indicating whether the name of an abstract numbering definition is provided by the field's code. More...
 
String get_ListLevel ()
 Gets or sets the level in the list, overriding the default behavior of the field. More...
 
String get_ListName ()
 Gets or sets the name of the abstract numbering definition used for the numbering. More...
 
String get_StartingNumber ()
 Gets or sets the starting value for this field. More...
 
FieldSwitchType GetSwitchType (String switchName) override
 
virtual const TypeInfoGetType () const override
 
virtual bool Is (const TypeInfo &target) const override
 
void set_ListLevel (String value)
 Setter for get_ListLevel. More...
 
void set_ListName (String value)
 Setter for get_ListName. More...
 
void set_StartingNumber (String value)
 Setter for get_StartingNumber. More...
 
- Public Member Functions inherited from Field
String get_DisplayResult ()
 Gets the text that represents the displayed field result. More...
 
SharedPtr< FieldEndget_End () const
 Gets the node that represents the field end. More...
 
SharedPtr< FieldEndget_FieldEnd () const
 Gets the node that represents the field end. More...
 
SharedPtr< FieldStartget_FieldStart () const
 Gets the node that represents the start of the field. More...
 
SharedPtr< FieldFormatget_Format ()
 Gets a FieldFormat object that provides typed access to field's formatting. More...
 
bool get_IsDirty ()
 Gets or sets whether the current result of the field is no longer correct (stale) due to other modifications made to the document. More...
 
bool get_IsLocked ()
 Gets or sets whether the field is locked (should not recalculate its result). More...
 
int32_t get_LocaleId ()
 Gets or sets the LCID of the field. More...
 
String get_Result ()
 Gets or sets text that is between the field separator and field end. More...
 
SharedPtr< FieldSeparatorget_Separator ()
 Gets the node that represents the field separator. Can be null. More...
 
SharedPtr< FieldStartget_Start () const
 Gets the node that represents the start of the field. More...
 
virtual FieldType get_Type ()
 Gets the Microsoft Word field type. More...
 
String GetFieldCode ()
 Returns text between field start and field separator (or field end if there is no separator). Both field code and field result of child fields are included. More...
 
String GetFieldCode (bool includeChildFieldCodes)
 Returns text between field start and field separator (or field end if there is no separator). More...
 
SharedPtr< NodeRemove ()
 Removes the field from the document. Returns a node right after the field. If the field's end is the last child of its parent node, returns its parent paragraph. If the field is already removed, returns null. More...
 
void set_IsDirty (bool value)
 Setter for get_IsDirty. More...
 
void set_IsLocked (bool value)
 Setter for get_IsLocked. More...
 
void set_LocaleId (int32_t value)
 Setter for get_LocaleId. More...
 
void set_Result (String value)
 Setter for get_Result. More...
 
bool Unlink ()
 Performs the field unlink. More...
 
void Update ()
 Performs the field update. Throws if the field is being updated already. More...
 
void Update (bool ignoreMergeFormat)
 Performs a field update. Throws if the field is being updated already. More...
 

Static Public Member Functions

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

Member Function Documentation

◆ get_HasListName()

bool Aspose::Words::Fields::FieldListNum::get_HasListName ( )

Returns a value indicating whether the name of an abstract numbering definition is provided by the field's code.

Examples

Shows how to number paragraphs with LISTNUM fields.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// LISTNUM fields display a number that increments at each LISTNUM field.
// These fields also have a variety of options that allow us to use them to emulate numbered lists.
auto field = System::DynamicCast<FieldListNum>(builder->InsertField(FieldType::FieldListNum, true));
// Lists start counting at 1 by default, but we can set this number to a different value, such as 0.
// This field will display "0)".
field->set_StartingNumber(u"0");
builder->Writeln(u"Paragraph 1");
ASSERT_EQ(u" LISTNUM \\s 0", field->GetFieldCode());
// LISTNUM fields maintain separate counts for each list level.
// Inserting a LISTNUM field in the same paragraph as another LISTNUM field
// increases the list level instead of the count.
// The next field will continue the count we started above and display a value of "1" at list level 1.
builder->InsertField(FieldType::FieldListNum, true);
// This field will start a count at list level 2. It will display a value of "1".
builder->InsertField(FieldType::FieldListNum, true);
// This field will start a count at list level 3. It will display a value of "1".
// Different list levels have different formatting,
// so these fields combined will display a value of "1)a)i)".
builder->InsertField(FieldType::FieldListNum, true);
builder->Writeln(u"Paragraph 2");
// The next LISTNUM field that we insert will continue the count at the list level
// that the previous LISTNUM field was on.
// We can use the "ListLevel" property to jump to a different list level.
// If this LISTNUM field stayed on list level 3, it would display "ii)",
// but, since we have moved it to list level 2, it carries on the count at that level and displays "b)".
field = System::DynamicCast<FieldListNum>(builder->InsertField(FieldType::FieldListNum, true));
field->set_ListLevel(u"2");
builder->Writeln(u"Paragraph 3");
ASSERT_EQ(u" LISTNUM \\l 2", field->GetFieldCode());
// We can set the ListName property to get the field to emulate a different AUTONUM field type.
// "NumberDefault" emulates AUTONUM, "OutlineDefault" emulates AUTONUMOUT,
// and "LegalDefault" emulates AUTONUMLGL fields.
// The "OutlineDefault" list name with 1 as the starting number will result in displaying "I.".
field = System::DynamicCast<FieldListNum>(builder->InsertField(FieldType::FieldListNum, true));
field->set_StartingNumber(u"1");
field->set_ListName(u"OutlineDefault");
builder->Writeln(u"Paragraph 4");
ASSERT_TRUE(field->get_HasListName());
ASSERT_EQ(u" LISTNUM OutlineDefault \\s 1", field->GetFieldCode());
// The ListName does not carry over from the previous field, so we will need to set it for each new field.
// This field continues the count with the different list name and displays "II.".
field = System::DynamicCast<FieldListNum>(builder->InsertField(FieldType::FieldListNum, true));
field->set_ListName(u"OutlineDefault");
builder->Writeln(u"Paragraph 5");
doc->UpdateFields();
doc->Save(ArtifactsDir + u"Field.LISTNUM.docx");

◆ get_ListLevel()

System::String Aspose::Words::Fields::FieldListNum::get_ListLevel ( )

Gets or sets the level in the list, overriding the default behavior of the field.

Examples

Shows how to number paragraphs with LISTNUM fields.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// LISTNUM fields display a number that increments at each LISTNUM field.
// These fields also have a variety of options that allow us to use them to emulate numbered lists.
auto field = System::DynamicCast<FieldListNum>(builder->InsertField(FieldType::FieldListNum, true));
// Lists start counting at 1 by default, but we can set this number to a different value, such as 0.
// This field will display "0)".
field->set_StartingNumber(u"0");
builder->Writeln(u"Paragraph 1");
ASSERT_EQ(u" LISTNUM \\s 0", field->GetFieldCode());
// LISTNUM fields maintain separate counts for each list level.
// Inserting a LISTNUM field in the same paragraph as another LISTNUM field
// increases the list level instead of the count.
// The next field will continue the count we started above and display a value of "1" at list level 1.
builder->InsertField(FieldType::FieldListNum, true);
// This field will start a count at list level 2. It will display a value of "1".
builder->InsertField(FieldType::FieldListNum, true);
// This field will start a count at list level 3. It will display a value of "1".
// Different list levels have different formatting,
// so these fields combined will display a value of "1)a)i)".
builder->InsertField(FieldType::FieldListNum, true);
builder->Writeln(u"Paragraph 2");
// The next LISTNUM field that we insert will continue the count at the list level
// that the previous LISTNUM field was on.
// We can use the "ListLevel" property to jump to a different list level.
// If this LISTNUM field stayed on list level 3, it would display "ii)",
// but, since we have moved it to list level 2, it carries on the count at that level and displays "b)".
field = System::DynamicCast<FieldListNum>(builder->InsertField(FieldType::FieldListNum, true));
field->set_ListLevel(u"2");
builder->Writeln(u"Paragraph 3");
ASSERT_EQ(u" LISTNUM \\l 2", field->GetFieldCode());
// We can set the ListName property to get the field to emulate a different AUTONUM field type.
// "NumberDefault" emulates AUTONUM, "OutlineDefault" emulates AUTONUMOUT,
// and "LegalDefault" emulates AUTONUMLGL fields.
// The "OutlineDefault" list name with 1 as the starting number will result in displaying "I.".
field = System::DynamicCast<FieldListNum>(builder->InsertField(FieldType::FieldListNum, true));
field->set_StartingNumber(u"1");
field->set_ListName(u"OutlineDefault");
builder->Writeln(u"Paragraph 4");
ASSERT_TRUE(field->get_HasListName());
ASSERT_EQ(u" LISTNUM OutlineDefault \\s 1", field->GetFieldCode());
// The ListName does not carry over from the previous field, so we will need to set it for each new field.
// This field continues the count with the different list name and displays "II.".
field = System::DynamicCast<FieldListNum>(builder->InsertField(FieldType::FieldListNum, true));
field->set_ListName(u"OutlineDefault");
builder->Writeln(u"Paragraph 5");
doc->UpdateFields();
doc->Save(ArtifactsDir + u"Field.LISTNUM.docx");

◆ get_ListName()

System::String Aspose::Words::Fields::FieldListNum::get_ListName ( )

Gets or sets the name of the abstract numbering definition used for the numbering.

Examples

Shows how to number paragraphs with LISTNUM fields.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// LISTNUM fields display a number that increments at each LISTNUM field.
// These fields also have a variety of options that allow us to use them to emulate numbered lists.
auto field = System::DynamicCast<FieldListNum>(builder->InsertField(FieldType::FieldListNum, true));
// Lists start counting at 1 by default, but we can set this number to a different value, such as 0.
// This field will display "0)".
field->set_StartingNumber(u"0");
builder->Writeln(u"Paragraph 1");
ASSERT_EQ(u" LISTNUM \\s 0", field->GetFieldCode());
// LISTNUM fields maintain separate counts for each list level.
// Inserting a LISTNUM field in the same paragraph as another LISTNUM field
// increases the list level instead of the count.
// The next field will continue the count we started above and display a value of "1" at list level 1.
builder->InsertField(FieldType::FieldListNum, true);
// This field will start a count at list level 2. It will display a value of "1".
builder->InsertField(FieldType::FieldListNum, true);
// This field will start a count at list level 3. It will display a value of "1".
// Different list levels have different formatting,
// so these fields combined will display a value of "1)a)i)".
builder->InsertField(FieldType::FieldListNum, true);
builder->Writeln(u"Paragraph 2");
// The next LISTNUM field that we insert will continue the count at the list level
// that the previous LISTNUM field was on.
// We can use the "ListLevel" property to jump to a different list level.
// If this LISTNUM field stayed on list level 3, it would display "ii)",
// but, since we have moved it to list level 2, it carries on the count at that level and displays "b)".
field = System::DynamicCast<FieldListNum>(builder->InsertField(FieldType::FieldListNum, true));
field->set_ListLevel(u"2");
builder->Writeln(u"Paragraph 3");
ASSERT_EQ(u" LISTNUM \\l 2", field->GetFieldCode());
// We can set the ListName property to get the field to emulate a different AUTONUM field type.
// "NumberDefault" emulates AUTONUM, "OutlineDefault" emulates AUTONUMOUT,
// and "LegalDefault" emulates AUTONUMLGL fields.
// The "OutlineDefault" list name with 1 as the starting number will result in displaying "I.".
field = System::DynamicCast<FieldListNum>(builder->InsertField(FieldType::FieldListNum, true));
field->set_StartingNumber(u"1");
field->set_ListName(u"OutlineDefault");
builder->Writeln(u"Paragraph 4");
ASSERT_TRUE(field->get_HasListName());
ASSERT_EQ(u" LISTNUM OutlineDefault \\s 1", field->GetFieldCode());
// The ListName does not carry over from the previous field, so we will need to set it for each new field.
// This field continues the count with the different list name and displays "II.".
field = System::DynamicCast<FieldListNum>(builder->InsertField(FieldType::FieldListNum, true));
field->set_ListName(u"OutlineDefault");
builder->Writeln(u"Paragraph 5");
doc->UpdateFields();
doc->Save(ArtifactsDir + u"Field.LISTNUM.docx");

◆ get_StartingNumber()

System::String Aspose::Words::Fields::FieldListNum::get_StartingNumber ( )

Gets or sets the starting value for this field.

Examples

Shows how to number paragraphs with LISTNUM fields.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// LISTNUM fields display a number that increments at each LISTNUM field.
// These fields also have a variety of options that allow us to use them to emulate numbered lists.
auto field = System::DynamicCast<FieldListNum>(builder->InsertField(FieldType::FieldListNum, true));
// Lists start counting at 1 by default, but we can set this number to a different value, such as 0.
// This field will display "0)".
field->set_StartingNumber(u"0");
builder->Writeln(u"Paragraph 1");
ASSERT_EQ(u" LISTNUM \\s 0", field->GetFieldCode());
// LISTNUM fields maintain separate counts for each list level.
// Inserting a LISTNUM field in the same paragraph as another LISTNUM field
// increases the list level instead of the count.
// The next field will continue the count we started above and display a value of "1" at list level 1.
builder->InsertField(FieldType::FieldListNum, true);
// This field will start a count at list level 2. It will display a value of "1".
builder->InsertField(FieldType::FieldListNum, true);
// This field will start a count at list level 3. It will display a value of "1".
// Different list levels have different formatting,
// so these fields combined will display a value of "1)a)i)".
builder->InsertField(FieldType::FieldListNum, true);
builder->Writeln(u"Paragraph 2");
// The next LISTNUM field that we insert will continue the count at the list level
// that the previous LISTNUM field was on.
// We can use the "ListLevel" property to jump to a different list level.
// If this LISTNUM field stayed on list level 3, it would display "ii)",
// but, since we have moved it to list level 2, it carries on the count at that level and displays "b)".
field = System::DynamicCast<FieldListNum>(builder->InsertField(FieldType::FieldListNum, true));
field->set_ListLevel(u"2");
builder->Writeln(u"Paragraph 3");
ASSERT_EQ(u" LISTNUM \\l 2", field->GetFieldCode());
// We can set the ListName property to get the field to emulate a different AUTONUM field type.
// "NumberDefault" emulates AUTONUM, "OutlineDefault" emulates AUTONUMOUT,
// and "LegalDefault" emulates AUTONUMLGL fields.
// The "OutlineDefault" list name with 1 as the starting number will result in displaying "I.".
field = System::DynamicCast<FieldListNum>(builder->InsertField(FieldType::FieldListNum, true));
field->set_StartingNumber(u"1");
field->set_ListName(u"OutlineDefault");
builder->Writeln(u"Paragraph 4");
ASSERT_TRUE(field->get_HasListName());
ASSERT_EQ(u" LISTNUM OutlineDefault \\s 1", field->GetFieldCode());
// The ListName does not carry over from the previous field, so we will need to set it for each new field.
// This field continues the count with the different list name and displays "II.".
field = System::DynamicCast<FieldListNum>(builder->InsertField(FieldType::FieldListNum, true));
field->set_ListName(u"OutlineDefault");
builder->Writeln(u"Paragraph 5");
doc->UpdateFields();
doc->Save(ArtifactsDir + u"Field.LISTNUM.docx");

◆ GetSwitchType()

Aspose::Words::Fields::FieldSwitchType Aspose::Words::Fields::FieldListNum::GetSwitchType ( System::String  switchName)
override

◆ GetType()

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

Reimplemented from Aspose::Words::Fields::Field.

◆ Is()

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

Reimplemented from Aspose::Words::Fields::Field.

◆ set_ListLevel()

void Aspose::Words::Fields::FieldListNum::set_ListLevel ( System::String  value)

◆ set_ListName()

void Aspose::Words::Fields::FieldListNum::set_ListName ( System::String  value)

◆ set_StartingNumber()

void Aspose::Words::Fields::FieldListNum::set_StartingNumber ( System::String  value)

◆ Type()

static const System::TypeInfo& Aspose::Words::Fields::FieldListNum::Type ( )
static