Aspose::Words::Lists::List Class Reference

Detailed Description

Represents formatting of a list.

A list in a Microsoft Word document is a set of list formatting properties. Each list can have up to 9 levels and formatting properties, such as number style, start value, indent, tab position etc are defined separately for each level.

A List object always belongs to the ListCollection collection.

To create a new list, use the Add methods of the ListCollection collection.

To modify formatting of a list, use ListLevel objects found in the ListLevels collection.

To apply or remove list formatting from a paragraph, use ListFormat.

See also
Aspose::Words::Lists::ListCollection
Aspose::Words::Lists::ListLevel
Aspose::Words::Lists::ListFormat
Examples

Shows how to work with list levels.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
ASSERT_FALSE(builder->get_ListFormat()->get_IsListItem());
// A list allows us to organize and decorate sets of paragraphs with prefix symbols and indents.
// We can create nested lists by increasing the indent level.
// We can begin and end a list by using a document builder's "ListFormat" property.
// Each paragraph that we add between a list's start and the end will become an item in the list.
// Below are two types of lists that we can create using a document builder.
// 1 - A numbered list:
// Numbered lists create a logical order for their paragraphs by numbering each item.
builder->get_ListFormat()->set_List(doc->get_Lists()->Add(ListTemplate::NumberDefault));
ASSERT_TRUE(builder->get_ListFormat()->get_IsListItem());
// By setting the "ListLevelNumber" property, we can increase the list level
// to begin a self-contained sub-list at the current list item.
// The Microsoft Word list template called "NumberDefault" uses numbers to create list levels for the first list level.
// Deeper list levels use letters and lowercase Roman numerals.
for (int i = 0; i < 9; i++)
{
builder->get_ListFormat()->set_ListLevelNumber(i);
builder->Writeln(String(u"Level ") + i);
}
// 2 - A bulleted list:
// This list will apply an indent and a bullet symbol ("•") before each paragraph.
// Deeper levels of this list will use different symbols, such as "■" and "○".
builder->get_ListFormat()->set_List(doc->get_Lists()->Add(ListTemplate::BulletDefault));
for (int i = 0; i < 9; i++)
{
builder->get_ListFormat()->set_ListLevelNumber(i);
builder->Writeln(String(u"Level ") + i);
}
// We can disable list formatting to not format any subsequent paragraphs as lists by un-setting the "List" flag.
builder->get_ListFormat()->set_List(nullptr);
ASSERT_FALSE(builder->get_ListFormat()->get_IsListItem());
doc->Save(ArtifactsDir + u"Lists.SpecifyListLevel.docx");

Shows how to apply custom list formatting to paragraphs when using DocumentBuilder.

auto doc = MakeObject<Document>();
// A list allows us to organize and decorate sets of paragraphs with prefix symbols and indents.
// We can create nested lists by increasing the indent level.
// We can begin and end a list by using a document builder's "ListFormat" property.
// Each paragraph that we add between a list's start and the end will become an item in the list.
// Create a list from a Microsoft Word template, and customize the first two of its list levels.
SharedPtr<List> list = doc->get_Lists()->Add(ListTemplate::NumberDefault);
SharedPtr<ListLevel> listLevel = list->get_ListLevels()->idx_get(0);
listLevel->get_Font()->set_Color(System::Drawing::Color::get_Red());
listLevel->get_Font()->set_Size(24);
listLevel->set_NumberStyle(NumberStyle::OrdinalText);
listLevel->set_StartAt(21);
listLevel->set_NumberFormat(u"\x0000");
listLevel->set_NumberPosition(-36);
listLevel->set_TextPosition(144);
listLevel->set_TabPosition(144);
listLevel = list->get_ListLevels()->idx_get(1);
listLevel->set_Alignment(ListLevelAlignment::Right);
listLevel->set_NumberStyle(NumberStyle::Bullet);
listLevel->get_Font()->set_Name(u"Wingdings");
listLevel->get_Font()->set_Color(System::Drawing::Color::get_Blue());
listLevel->get_Font()->set_Size(24);
// This NumberFormat value will create star-shaped bullet list symbols.
listLevel->set_NumberFormat(u"\xf0af");
listLevel->set_TrailingCharacter(ListTrailingCharacter::Space);
listLevel->set_NumberPosition(144);
// Create paragraphs and apply both list levels of our custom list formatting to them.
auto builder = MakeObject<DocumentBuilder>(doc);
builder->get_ListFormat()->set_List(list);
builder->Writeln(u"The quick brown fox...");
builder->Writeln(u"The quick brown fox...");
builder->get_ListFormat()->ListIndent();
builder->Writeln(u"jumped over the lazy dog.");
builder->Writeln(u"jumped over the lazy dog.");
builder->get_ListFormat()->ListOutdent();
builder->Writeln(u"The quick brown fox...");
builder->get_ListFormat()->RemoveNumbers();
builder->get_Document()->Save(ArtifactsDir + u"Lists.CreateCustomList.docx");

Shows how to restart numbering in a list by copying a list.

auto doc = MakeObject<Document>();
// A list allows us to organize and decorate sets of paragraphs with prefix symbols and indents.
// We can create nested lists by increasing the indent level.
// We can begin and end a list by using a document builder's "ListFormat" property.
// Each paragraph that we add between a list's start and the end will become an item in the list.
// Create a list from a Microsoft Word template, and customize its first list level.
SharedPtr<List> list1 = doc->get_Lists()->Add(ListTemplate::NumberArabicParenthesis);
list1->get_ListLevels()->idx_get(0)->get_Font()->set_Color(System::Drawing::Color::get_Red());
list1->get_ListLevels()->idx_get(0)->set_Alignment(ListLevelAlignment::Right);
// Apply our list to some paragraphs.
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"List 1 starts below:");
builder->get_ListFormat()->set_List(list1);
builder->Writeln(u"Item 1");
builder->Writeln(u"Item 2");
builder->get_ListFormat()->RemoveNumbers();
// We can add a copy of an existing list to the document's list collection
// to create a similar list without making changes to the original.
SharedPtr<List> list2 = doc->get_Lists()->AddCopy(list1);
list2->get_ListLevels()->idx_get(0)->get_Font()->set_Color(System::Drawing::Color::get_Blue());
list2->get_ListLevels()->idx_get(0)->set_StartAt(10);
// Apply the second list to new paragraphs.
builder->Writeln(u"List 2 starts below:");
builder->get_ListFormat()->set_List(list2);
builder->Writeln(u"Item 1");
builder->Writeln(u"Item 2");
builder->get_ListFormat()->RemoveNumbers();
doc->Save(ArtifactsDir + u"Lists.RestartNumberingUsingListCopy.docx");

#include <Aspose.Words.Cpp/Lists/List.h>

+ Inheritance diagram for Aspose::Words::Lists::List:

Public Member Functions

int32_t CompareTo (SharedPtr< List > other) override
 Compares the specified list to the current list. More...
 
bool Equals (SharedPtr< List > list)
 Compares with the specified list. More...
 
bool Equals (SharedPtr< Object > obj) override
 
SharedPtr< DocumentBaseget_Document () const
 Gets the owner document. More...
 
bool get_IsListStyleDefinition ()
 Returns true if this list is a definition of a list style. More...
 
bool get_IsListStyleReference ()
 Returns true if this list is a reference to a list style. More...
 
bool get_IsMultiLevel ()
 Returns true when the list contains 9 levels; false when 1 level. More...
 
bool get_IsRestartAtEachSection ()
 Specifies whether list should be restarted at each section. Default value is false. More...
 
int32_t get_ListId () const
 Gets the unique identifier of the list. More...
 
SharedPtr< ListLevelCollectionget_ListLevels ()
 Gets the collection of list levels for this list. More...
 
SharedPtr< Styleget_Style ()
 Gets the list style that this list references or defines. More...
 
int32_t GetHashCode () const override
 Calculates hash code for this list object. More...
 
virtual const TypeInfoGetType () const override
 
virtual bool Is (const TypeInfo &target) const override
 
void set_IsRestartAtEachSection (bool value)
 Setter for get_IsRestartAtEachSection. More...
 

Static Public Member Functions

static const TypeInfoType ()
 

Member Function Documentation

◆ CompareTo()

int32_t Aspose::Words::Lists::List::CompareTo ( System::SharedPtr< Aspose::Words::Lists::List other)
override

Compares the specified list to the current list.

◆ Equals() [1/2]

bool Aspose::Words::Lists::List::Equals ( System::SharedPtr< Aspose::Words::Lists::List list)

Compares with the specified list.

◆ Equals() [2/2]

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

◆ get_Document()

System::SharedPtr<Aspose::Words::DocumentBase> Aspose::Words::Lists::List::get_Document ( ) const

Gets the owner document.

A list always has a parent document and is valid only in the context of that document.

Examples

Shows how to verify owner document properties of lists.

auto doc = MakeObject<Document>();
SharedPtr<ListCollection> lists = doc->get_Lists();
ASPOSE_ASSERT_EQ(doc, lists->get_Document());
SharedPtr<List> list = lists->Add(ListTemplate::BulletDefault);
ASPOSE_ASSERT_EQ(doc, list->get_Document());
std::cout << (String(u"Current list count: ") + lists->get_Count()) << std::endl;
std::cout << (String(u"Is the first document list: ") + (System::ObjectExt::Equals(lists->idx_get(0), list))) << std::endl;
std::cout << (String(u"ListId: ") + list->get_ListId()) << std::endl;
std::cout << (String(u"List is the same by ListId: ") + (System::ObjectExt::Equals(lists->GetListByListId(1), list))) << std::endl;

◆ get_IsListStyleDefinition()

bool Aspose::Words::Lists::List::get_IsListStyleDefinition ( )

Returns true if this list is a definition of a list style.

When this property is true, the Style property returns the list style that this list defines.

By modifying properties of a list that defines a list style, you modify the properties of the list style.

A list that is a definition of a list style cannot be applied directly to paragraphs to make them numbered.

See also
Aspose::Words::Lists::List::get_Style
Aspose::Words::Lists::List::get_IsListStyleReference
Examples

Shows how to create a list style and use it in a document.

auto doc = MakeObject<Document>();
// A list allows us to organize and decorate sets of paragraphs with prefix symbols and indents.
// We can create nested lists by increasing the indent level.
// We can begin and end a list by using a document builder's "ListFormat" property.
// Each paragraph that we add between a list's start and the end will become an item in the list.
// We can contain an entire List object within a style.
SharedPtr<Style> listStyle = doc->get_Styles()->Add(StyleType::List, u"MyListStyle");
SharedPtr<List> list1 = listStyle->get_List();
ASSERT_TRUE(list1->get_IsListStyleDefinition());
ASSERT_FALSE(list1->get_IsListStyleReference());
ASSERT_TRUE(list1->get_IsMultiLevel());
ASPOSE_ASSERT_EQ(listStyle, list1->get_Style());
// Change the appearance of all list levels in our list.
for (const auto& level : list1->get_ListLevels())
{
level->get_Font()->set_Name(u"Verdana");
level->get_Font()->set_Color(System::Drawing::Color::get_Blue());
level->get_Font()->set_Bold(true);
}
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Using list style first time:");
// Create another list from a list within a style.
SharedPtr<List> list2 = doc->get_Lists()->Add(listStyle);
ASSERT_FALSE(list2->get_IsListStyleDefinition());
ASSERT_TRUE(list2->get_IsListStyleReference());
ASPOSE_ASSERT_EQ(listStyle, list2->get_Style());
// Add some list items that our list will format.
builder->get_ListFormat()->set_List(list2);
builder->Writeln(u"Item 1");
builder->Writeln(u"Item 2");
builder->get_ListFormat()->RemoveNumbers();
builder->Writeln(u"Using list style second time:");
// Create and apply another list based on the list style.
SharedPtr<List> list3 = doc->get_Lists()->Add(listStyle);
builder->get_ListFormat()->set_List(list3);
builder->Writeln(u"Item 1");
builder->Writeln(u"Item 2");
builder->get_ListFormat()->RemoveNumbers();
builder->get_Document()->Save(ArtifactsDir + u"Lists.CreateAndUseListStyle.docx");

◆ get_IsListStyleReference()

bool Aspose::Words::Lists::List::get_IsListStyleReference ( )

Returns true if this list is a reference to a list style.

Note, modifying properties of a list that is a reference to list style has no effect. The list formatting specified in the list style itself always takes precedence.

See also
Aspose::Words::Lists::List::get_Style
Aspose::Words::Lists::List::get_IsListStyleDefinition
Examples

Shows how to create a list style and use it in a document.

auto doc = MakeObject<Document>();
// A list allows us to organize and decorate sets of paragraphs with prefix symbols and indents.
// We can create nested lists by increasing the indent level.
// We can begin and end a list by using a document builder's "ListFormat" property.
// Each paragraph that we add between a list's start and the end will become an item in the list.
// We can contain an entire List object within a style.
SharedPtr<Style> listStyle = doc->get_Styles()->Add(StyleType::List, u"MyListStyle");
SharedPtr<List> list1 = listStyle->get_List();
ASSERT_TRUE(list1->get_IsListStyleDefinition());
ASSERT_FALSE(list1->get_IsListStyleReference());
ASSERT_TRUE(list1->get_IsMultiLevel());
ASPOSE_ASSERT_EQ(listStyle, list1->get_Style());
// Change the appearance of all list levels in our list.
for (const auto& level : list1->get_ListLevels())
{
level->get_Font()->set_Name(u"Verdana");
level->get_Font()->set_Color(System::Drawing::Color::get_Blue());
level->get_Font()->set_Bold(true);
}
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Using list style first time:");
// Create another list from a list within a style.
SharedPtr<List> list2 = doc->get_Lists()->Add(listStyle);
ASSERT_FALSE(list2->get_IsListStyleDefinition());
ASSERT_TRUE(list2->get_IsListStyleReference());
ASPOSE_ASSERT_EQ(listStyle, list2->get_Style());
// Add some list items that our list will format.
builder->get_ListFormat()->set_List(list2);
builder->Writeln(u"Item 1");
builder->Writeln(u"Item 2");
builder->get_ListFormat()->RemoveNumbers();
builder->Writeln(u"Using list style second time:");
// Create and apply another list based on the list style.
SharedPtr<List> list3 = doc->get_Lists()->Add(listStyle);
builder->get_ListFormat()->set_List(list3);
builder->Writeln(u"Item 1");
builder->Writeln(u"Item 2");
builder->get_ListFormat()->RemoveNumbers();
builder->get_Document()->Save(ArtifactsDir + u"Lists.CreateAndUseListStyle.docx");

◆ get_IsMultiLevel()

bool Aspose::Words::Lists::List::get_IsMultiLevel ( )

Returns true when the list contains 9 levels; false when 1 level.

The lists that you create with Aspose.Words are always multi-level lists and contain 9 levels.

Microsoft Word 2003 and later always create multi-level lists with 9 levels. But in some documents, created with earlier versions of Microsoft Word you might encounter lists that have 1 level only.

Examples

Shows how to create a list style and use it in a document.

auto doc = MakeObject<Document>();
// A list allows us to organize and decorate sets of paragraphs with prefix symbols and indents.
// We can create nested lists by increasing the indent level.
// We can begin and end a list by using a document builder's "ListFormat" property.
// Each paragraph that we add between a list's start and the end will become an item in the list.
// We can contain an entire List object within a style.
SharedPtr<Style> listStyle = doc->get_Styles()->Add(StyleType::List, u"MyListStyle");
SharedPtr<List> list1 = listStyle->get_List();
ASSERT_TRUE(list1->get_IsListStyleDefinition());
ASSERT_FALSE(list1->get_IsListStyleReference());
ASSERT_TRUE(list1->get_IsMultiLevel());
ASPOSE_ASSERT_EQ(listStyle, list1->get_Style());
// Change the appearance of all list levels in our list.
for (const auto& level : list1->get_ListLevels())
{
level->get_Font()->set_Name(u"Verdana");
level->get_Font()->set_Color(System::Drawing::Color::get_Blue());
level->get_Font()->set_Bold(true);
}
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Using list style first time:");
// Create another list from a list within a style.
SharedPtr<List> list2 = doc->get_Lists()->Add(listStyle);
ASSERT_FALSE(list2->get_IsListStyleDefinition());
ASSERT_TRUE(list2->get_IsListStyleReference());
ASPOSE_ASSERT_EQ(listStyle, list2->get_Style());
// Add some list items that our list will format.
builder->get_ListFormat()->set_List(list2);
builder->Writeln(u"Item 1");
builder->Writeln(u"Item 2");
builder->get_ListFormat()->RemoveNumbers();
builder->Writeln(u"Using list style second time:");
// Create and apply another list based on the list style.
SharedPtr<List> list3 = doc->get_Lists()->Add(listStyle);
builder->get_ListFormat()->set_List(list3);
builder->Writeln(u"Item 1");
builder->Writeln(u"Item 2");
builder->get_ListFormat()->RemoveNumbers();
builder->get_Document()->Save(ArtifactsDir + u"Lists.CreateAndUseListStyle.docx");

◆ get_IsRestartAtEachSection()

bool Aspose::Words::Lists::List::get_IsRestartAtEachSection ( )

Specifies whether list should be restarted at each section. Default value is false.

This option is supported only in RTF, DOC and DOCX document formats.

This option will be written to DOCX only if OoxmlCompliance is higher then Ecma376_2006.

Examples

Shows how to configure a list to restart numbering at each section.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
doc->get_Lists()->Add(ListTemplate::NumberDefault);
SharedPtr<Aspose::Words::Lists::List> list = doc->get_Lists()->idx_get(0);
list->set_IsRestartAtEachSection(restartListAtEachSection);
// The "IsRestartAtEachSection" property will only be applicable when
// the document's OOXML compliance level is to a standard that is newer than "OoxmlComplianceCore.Ecma376".
auto options = MakeObject<OoxmlSaveOptions>();
options->set_Compliance(OoxmlCompliance::Iso29500_2008_Transitional);
builder->get_ListFormat()->set_List(list);
builder->Writeln(u"List item 1");
builder->Writeln(u"List item 2");
builder->InsertBreak(BreakType::SectionBreakNewPage);
builder->Writeln(u"List item 3");
builder->Writeln(u"List item 4");
doc->Save(ArtifactsDir + u"OoxmlSaveOptions.RestartingDocumentList.docx", options);
doc = MakeObject<Document>(ArtifactsDir + u"OoxmlSaveOptions.RestartingDocumentList.docx");
ASPOSE_ASSERT_EQ(restartListAtEachSection, doc->get_Lists()->idx_get(0)->get_IsRestartAtEachSection());

◆ get_ListId()

int32_t Aspose::Words::Lists::List::get_ListId ( ) const

Gets the unique identifier of the list.

You do not normally need to use this property. But if you use it, you normally do so in conjunction with the GetListByListId() method to find a list by its identifier.

Examples

Shows how to output all paragraphs in a document that are list items.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->get_ListFormat()->ApplyNumberDefault();
builder->Writeln(u"Numbered list item 1");
builder->Writeln(u"Numbered list item 2");
builder->Writeln(u"Numbered list item 3");
builder->get_ListFormat()->RemoveNumbers();
builder->get_ListFormat()->ApplyBulletDefault();
builder->Writeln(u"Bulleted list item 1");
builder->Writeln(u"Bulleted list item 2");
builder->Writeln(u"Bulleted list item 3");
builder->get_ListFormat()->RemoveNumbers();
SharedPtr<NodeCollection> paras = doc->GetChildNodes(NodeType::Paragraph, true);
for (auto para : System::IterateOver(
paras->LINQ_OfType<SharedPtr<Paragraph>>()->LINQ_Where([](SharedPtr<Paragraph> p) { return p->get_ListFormat()->get_IsListItem(); })))
{
std::cout << String::Format(u"This paragraph belongs to list ID# {0}, number style \"{1}\"", para->get_ListFormat()->get_List()->get_ListId(),
para->get_ListFormat()->get_ListLevel()->get_NumberStyle())
<< std::endl;
std::cout << "\t\"" << para->GetText().Trim() << "\"" << std::endl;
}

Shows how to verify owner document properties of lists.

auto doc = MakeObject<Document>();
SharedPtr<ListCollection> lists = doc->get_Lists();
ASPOSE_ASSERT_EQ(doc, lists->get_Document());
SharedPtr<List> list = lists->Add(ListTemplate::BulletDefault);
ASPOSE_ASSERT_EQ(doc, list->get_Document());
std::cout << (String(u"Current list count: ") + lists->get_Count()) << std::endl;
std::cout << (String(u"Is the first document list: ") + (System::ObjectExt::Equals(lists->idx_get(0), list))) << std::endl;
std::cout << (String(u"ListId: ") + list->get_ListId()) << std::endl;
std::cout << (String(u"List is the same by ListId: ") + (System::ObjectExt::Equals(lists->GetListByListId(1), list))) << std::endl;

◆ get_ListLevels()

System::SharedPtr<Aspose::Words::Lists::ListLevelCollection> Aspose::Words::Lists::List::get_ListLevels ( )

Gets the collection of list levels for this list.

Use this property to access and modify formatting individual to each level of the list.

Examples

Shows how to apply custom list formatting to paragraphs when using DocumentBuilder.

auto doc = MakeObject<Document>();
// A list allows us to organize and decorate sets of paragraphs with prefix symbols and indents.
// We can create nested lists by increasing the indent level.
// We can begin and end a list by using a document builder's "ListFormat" property.
// Each paragraph that we add between a list's start and the end will become an item in the list.
// Create a list from a Microsoft Word template, and customize the first two of its list levels.
SharedPtr<List> list = doc->get_Lists()->Add(ListTemplate::NumberDefault);
SharedPtr<ListLevel> listLevel = list->get_ListLevels()->idx_get(0);
listLevel->get_Font()->set_Color(System::Drawing::Color::get_Red());
listLevel->get_Font()->set_Size(24);
listLevel->set_NumberStyle(NumberStyle::OrdinalText);
listLevel->set_StartAt(21);
listLevel->set_NumberFormat(u"\x0000");
listLevel->set_NumberPosition(-36);
listLevel->set_TextPosition(144);
listLevel->set_TabPosition(144);
listLevel = list->get_ListLevels()->idx_get(1);
listLevel->set_Alignment(ListLevelAlignment::Right);
listLevel->set_NumberStyle(NumberStyle::Bullet);
listLevel->get_Font()->set_Name(u"Wingdings");
listLevel->get_Font()->set_Color(System::Drawing::Color::get_Blue());
listLevel->get_Font()->set_Size(24);
// This NumberFormat value will create star-shaped bullet list symbols.
listLevel->set_NumberFormat(u"\xf0af");
listLevel->set_TrailingCharacter(ListTrailingCharacter::Space);
listLevel->set_NumberPosition(144);
// Create paragraphs and apply both list levels of our custom list formatting to them.
auto builder = MakeObject<DocumentBuilder>(doc);
builder->get_ListFormat()->set_List(list);
builder->Writeln(u"The quick brown fox...");
builder->Writeln(u"The quick brown fox...");
builder->get_ListFormat()->ListIndent();
builder->Writeln(u"jumped over the lazy dog.");
builder->Writeln(u"jumped over the lazy dog.");
builder->get_ListFormat()->ListOutdent();
builder->Writeln(u"The quick brown fox...");
builder->get_ListFormat()->RemoveNumbers();
builder->get_Document()->Save(ArtifactsDir + u"Lists.CreateCustomList.docx");

◆ get_Style()

System::SharedPtr<Aspose::Words::Style> Aspose::Words::Lists::List::get_Style ( )

Gets the list style that this list references or defines.

If this list is not associated with a list style, the property will return null.

A list could be a reference to a list style, in this case IsListStyleReference will be true.

A list could be a definition of a list style, in this case IsListStyleDefinition will be true. Such a list cannot be applied to paragraphs in the document directly.

Examples

Shows how to create a list style and use it in a document.

auto doc = MakeObject<Document>();
// A list allows us to organize and decorate sets of paragraphs with prefix symbols and indents.
// We can create nested lists by increasing the indent level.
// We can begin and end a list by using a document builder's "ListFormat" property.
// Each paragraph that we add between a list's start and the end will become an item in the list.
// We can contain an entire List object within a style.
SharedPtr<Style> listStyle = doc->get_Styles()->Add(StyleType::List, u"MyListStyle");
SharedPtr<List> list1 = listStyle->get_List();
ASSERT_TRUE(list1->get_IsListStyleDefinition());
ASSERT_FALSE(list1->get_IsListStyleReference());
ASSERT_TRUE(list1->get_IsMultiLevel());
ASPOSE_ASSERT_EQ(listStyle, list1->get_Style());
// Change the appearance of all list levels in our list.
for (const auto& level : list1->get_ListLevels())
{
level->get_Font()->set_Name(u"Verdana");
level->get_Font()->set_Color(System::Drawing::Color::get_Blue());
level->get_Font()->set_Bold(true);
}
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Using list style first time:");
// Create another list from a list within a style.
SharedPtr<List> list2 = doc->get_Lists()->Add(listStyle);
ASSERT_FALSE(list2->get_IsListStyleDefinition());
ASSERT_TRUE(list2->get_IsListStyleReference());
ASPOSE_ASSERT_EQ(listStyle, list2->get_Style());
// Add some list items that our list will format.
builder->get_ListFormat()->set_List(list2);
builder->Writeln(u"Item 1");
builder->Writeln(u"Item 2");
builder->get_ListFormat()->RemoveNumbers();
builder->Writeln(u"Using list style second time:");
// Create and apply another list based on the list style.
SharedPtr<List> list3 = doc->get_Lists()->Add(listStyle);
builder->get_ListFormat()->set_List(list3);
builder->Writeln(u"Item 1");
builder->Writeln(u"Item 2");
builder->get_ListFormat()->RemoveNumbers();
builder->get_Document()->Save(ArtifactsDir + u"Lists.CreateAndUseListStyle.docx");

◆ GetHashCode()

int32_t Aspose::Words::Lists::List::GetHashCode ( ) const
overridevirtual

Calculates hash code for this list object.

Reimplemented from System::Object.

◆ GetType()

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

Reimplemented from System::Object.

◆ Is()

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

Reimplemented from System::Object.

◆ set_IsRestartAtEachSection()

void Aspose::Words::Lists::List::set_IsRestartAtEachSection ( bool  value)

◆ Type()

static const System::TypeInfo& Aspose::Words::Lists::List::Type ( )
static