Aspose::Words::ListFormat Class Reference

Detailed Description

Allows to control what list formatting is applied to a paragraph.

A paragraph in a Microsoft Word document can be bulleted or numbered. When a paragraph is bulleted or numbered, it is said that list formatting is applied to the paragraph.

You do not create objects of the ListFormat class directly. You access ListFormat as a property of another object that can have list formatting associated with it. At the moment the objects that can have list formatting are: Paragraph, Style and DocumentBuilder.

ListFormat of a Paragraph specifies what list formatting and list level is applied to that particular paragraph.

ListFormat of a Style (applicable to paragraph styles only) allows to specify what list formatting and list level is applied to all paragraphs of that particular style.

ListFormat of a DocumentBuilder provides access to the list formatting at the current cursor position inside the DocumentBuilder.

The list formatting itself is stored inside a List object that is stored separately from the paragraphs. The list objects are stored inside a ListCollection collection. There is a single ListCollection collection per Document.

The paragraphs do not physically belong to a list. The paragraphs just reference a particular list object via the List property and a particular level in the list via the ListLevelNumber property. By setting these two properties you control what bullets and numbering is applied to a paragraph.

Examples

Shows how to specify list level number when building a list using DocumentBuilder.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Create a numbered list based on one of the Microsoft Word list templates and
// apply it to the current paragraph in the document builder
builder->get_ListFormat()->set_List(doc->get_Lists()->Add(Aspose::Words::Lists::ListTemplate::NumberArabicDot));
// Insert text at each of the 9 indent levels
for (int i = 0; i < 9; i++)
{
builder->get_ListFormat()->set_ListLevelNumber(i);
builder->Writeln(String(u"Level ") + i);
}
// Create a bulleted list based on one of the Microsoft Word list templates
// and apply it to the current paragraph in the document builder
builder->get_ListFormat()->set_List(doc->get_Lists()->Add(Aspose::Words::Lists::ListTemplate::BulletDiamonds));
for (int i = 0; i < 9; i++)
{
builder->get_ListFormat()->set_ListLevelNumber(i);
builder->Writeln(String(u"Level ") + i);
}
// This is a way to stop list formatting
builder->get_ListFormat()->set_List(nullptr);
doc->Save(ArtifactsDir + u"Lists.SpecifyListLevel.docx");

#include <Aspose.Words.Cpp/Model/Text/ListFormat.h>

+ Inheritance diagram for Aspose::Words::ListFormat:

Public Member Functions

void ApplyBulletDefault ()
 Starts a new default bulleted list and applies it to the paragraph. More...
 
void ApplyNumberDefault ()
 Starts a new default numbered list and applies it to the paragraph. More...
 
bool get_IsListItem ()
 True when the paragraph has bulleted or numbered formatting applied to it. More...
 
SharedPtr< Listget_List ()
 Gets or sets the list this paragraph is a member of. More...
 
SharedPtr< ListLevelget_ListLevel ()
 Returns the list level formatting plus any formatting overrides applied to the current paragraph. More...
 
int32_t get_ListLevelNumber ()
 Gets or sets the list level number (0 to 8) for the paragraph. More...
 
virtual const TypeInfoGetType () const override
 
virtual bool Is (const TypeInfo &target) const override
 
void ListIndent ()
 Increases the list level of the current paragraph by one level. More...
 
void ListOutdent ()
 Decreases the list level of the current paragraph by one level. More...
 
void RemoveNumbers ()
 Removes numbers or bullets from the current paragraph and sets list level to zero. More...
 
void set_List (SharedPtr< List > value)
 Setter for get_List. More...
 
void set_ListLevelNumber (int32_t value)
 Setter for get_ListLevelNumber. More...
 
- Public Member Functions inherited from Object
ASPOSECPP_SHARED_API Object ()
 
ASPOSECPP_SHARED_API Object (Object const &x)
 
virtual ASPOSECPP_SHARED_API ~Object ()
 
virtual ASPOSECPP_SHARED_API bool Equals (ptr obj)
 
Detail::SmartPtrCounter * GetCounter ()
 
virtual ASPOSECPP_SHARED_API int GetHashCode () const
 
ASPOSECPP_SHARED_API void Lock ()
 
virtual ASPOSECPP_SHARED_API ptr MemberwiseClone () const
 
Objectoperator= (Object const &x)
 
bool ReferenceEquals (String const &str, std::nullptr_t)
 
bool ReferenceEquals (String const &str1, String const &str2)
 
int RemovedSharedRefs (int count)
 
virtual ASPOSECPP_SHARED_API void SetTemplateWeakPtr (unsigned int argument)
 
int SharedCount () const
 
ObjectSharedRefAdded ()
 
int SharedRefRemovedSafe ()
 
virtual ASPOSECPP_SHARED_API String ToString () const
 
ASPOSECPP_SHARED_API void Unlock ()
 
Detail::SmartPtrCounter * WeakRefAdded ()
 
void WeakRefRemoved ()
 

Static Public Member Functions

static const TypeInfoType ()
 
- Static Public Member Functions inherited from Object
bool Equals (double const &objA, double const &objB)
 
bool Equals (float const &objA, float const &objB)
 
static std::enable_if<!IsSmartPtr< T1 >::value &&!IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 
static std::enable_if< IsSmartPtr< T1 >::value &&IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 
static bool ReferenceEquals (ptr const &objA, ptr const &objB)
 
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, std::nullptr_t)
 
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, T const &objB)
 
static const TypeInfoType ()
 

Additional Inherited Members

- Public Types inherited from Object
typedef SmartPtr< Objectptr
 
typedef System::Details::SharedMembersType shared_members_type
 

Member Function Documentation

◆ ApplyBulletDefault()

void Aspose::Words::ListFormat::ApplyBulletDefault ( )

Starts a new default bulleted list and applies it to the paragraph.

This is a shortcut method that creates a new list using the default bulleted template, applies it to the paragraph and selects the 1st list level.

See also
Aspose::Words::ListFormat::get_List
Aspose::Words::ListFormat::RemoveNumbers
Aspose::Words::ListFormat::get_ListLevelNumber
Examples

Shows how to apply default bulleted or numbered list formatting to paragraphs when using DocumentBuilder.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Aspose.Words allows:");
builder->Writeln();
// Start a numbered list with default formatting
builder->get_ListFormat()->ApplyNumberDefault();
builder->Writeln(u"Opening documents from different formats:");
ASSERT_EQ(0, builder->get_ListFormat()->get_ListLevelNumber());
// Go to second list level, add more text
builder->get_ListFormat()->ListIndent();
ASSERT_EQ(1, builder->get_ListFormat()->get_ListLevelNumber());
builder->Writeln(u"DOC");
builder->Writeln(u"PDF");
builder->Writeln(u"HTML");
// Outdent to the first list level
builder->get_ListFormat()->ListOutdent();
ASSERT_EQ(0, builder->get_ListFormat()->get_ListLevelNumber());
builder->Writeln(u"Processing documents");
builder->Writeln(u"Saving documents in different formats:");
// Indent the list level again
builder->get_ListFormat()->ListIndent();
builder->Writeln(u"DOC");
builder->Writeln(u"PDF");
builder->Writeln(u"HTML");
builder->Writeln(u"MHTML");
builder->Writeln(u"Plain text");
// Outdent the list level again
builder->get_ListFormat()->ListOutdent();
builder->Writeln(u"Doing many other things!");
// End the numbered list
builder->get_ListFormat()->RemoveNumbers();
builder->Writeln();
builder->Writeln(u"Aspose.Words main advantages are:");
builder->Writeln();
// Start a bulleted list with default formatting
builder->get_ListFormat()->ApplyBulletDefault();
builder->Writeln(u"Great performance");
builder->Writeln(u"High reliability");
builder->Writeln(u"Quality code and working");
builder->Writeln(u"Wide variety of features");
builder->Writeln(u"Easy to understand API");
// End the bulleted list
builder->get_ListFormat()->RemoveNumbers();
doc->Save(ArtifactsDir + u"Lists.ApplyDefaultBulletsAndNumbers.docx");

◆ ApplyNumberDefault()

void Aspose::Words::ListFormat::ApplyNumberDefault ( )

Starts a new default numbered list and applies it to the paragraph.

This is a shortcut method that creates a new list using the default numbered template, applies it to the paragraph and selects the 1st list level.

See also
Aspose::Words::ListFormat::get_List
Aspose::Words::ListFormat::RemoveNumbers
Aspose::Words::ListFormat::get_ListLevelNumber
Examples

Shows how to apply default bulleted or numbered list formatting to paragraphs when using DocumentBuilder.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Aspose.Words allows:");
builder->Writeln();
// Start a numbered list with default formatting
builder->get_ListFormat()->ApplyNumberDefault();
builder->Writeln(u"Opening documents from different formats:");
ASSERT_EQ(0, builder->get_ListFormat()->get_ListLevelNumber());
// Go to second list level, add more text
builder->get_ListFormat()->ListIndent();
ASSERT_EQ(1, builder->get_ListFormat()->get_ListLevelNumber());
builder->Writeln(u"DOC");
builder->Writeln(u"PDF");
builder->Writeln(u"HTML");
// Outdent to the first list level
builder->get_ListFormat()->ListOutdent();
ASSERT_EQ(0, builder->get_ListFormat()->get_ListLevelNumber());
builder->Writeln(u"Processing documents");
builder->Writeln(u"Saving documents in different formats:");
// Indent the list level again
builder->get_ListFormat()->ListIndent();
builder->Writeln(u"DOC");
builder->Writeln(u"PDF");
builder->Writeln(u"HTML");
builder->Writeln(u"MHTML");
builder->Writeln(u"Plain text");
// Outdent the list level again
builder->get_ListFormat()->ListOutdent();
builder->Writeln(u"Doing many other things!");
// End the numbered list
builder->get_ListFormat()->RemoveNumbers();
builder->Writeln();
builder->Writeln(u"Aspose.Words main advantages are:");
builder->Writeln();
// Start a bulleted list with default formatting
builder->get_ListFormat()->ApplyBulletDefault();
builder->Writeln(u"Great performance");
builder->Writeln(u"High reliability");
builder->Writeln(u"Quality code and working");
builder->Writeln(u"Wide variety of features");
builder->Writeln(u"Easy to understand API");
// End the bulleted list
builder->get_ListFormat()->RemoveNumbers();
doc->Save(ArtifactsDir + u"Lists.ApplyDefaultBulletsAndNumbers.docx");

◆ get_IsListItem()

bool Aspose::Words::ListFormat::get_IsListItem ( )

True when the paragraph has bulleted or numbered formatting applied to it.

Examples

Shows how to output all paragraphs in a document that are bulleted or numbered.

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(Aspose::Words::NodeType::Paragraph, true);
for (auto para : System::IterateOver(paras->LINQ_OfType<SharedPtr<Paragraph>>()->LINQ_Where([](SharedPtr<Paragraph> p) { return p->get_ListFormat()->get_IsListItem(); })))
{
System::Console::WriteLine(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()));
System::Console::WriteLine(String::Format(u"\t\"{0}\"",para->GetText().Trim()));
}

◆ get_List()

System::SharedPtr<Aspose::Words::Lists::List> Aspose::Words::ListFormat::get_List ( )

Gets or sets the list this paragraph is a member of.

The list that is being assigned to this property must belong to the current document.

The list that is being assigned to this property must not be a list style definition.

Setting this property to null removes bullets and numbering from the paragraph and sets the list level number to zero. Setting this property to null is equivalent to calling RemoveNumbers.

See also
Aspose::Words::ListFormat::get_ListLevelNumber
Aspose::Words::ListFormat::RemoveNumbers
Examples

Shows how to specify list level number when building a list using DocumentBuilder.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Create a numbered list based on one of the Microsoft Word list templates and
// apply it to the current paragraph in the document builder
builder->get_ListFormat()->set_List(doc->get_Lists()->Add(Aspose::Words::Lists::ListTemplate::NumberArabicDot));
// Insert text at each of the 9 indent levels
for (int i = 0; i < 9; i++)
{
builder->get_ListFormat()->set_ListLevelNumber(i);
builder->Writeln(String(u"Level ") + i);
}
// Create a bulleted list based on one of the Microsoft Word list templates
// and apply it to the current paragraph in the document builder
builder->get_ListFormat()->set_List(doc->get_Lists()->Add(Aspose::Words::Lists::ListTemplate::BulletDiamonds));
for (int i = 0; i < 9; i++)
{
builder->get_ListFormat()->set_ListLevelNumber(i);
builder->Writeln(String(u"Level ") + i);
}
// This is a way to stop list formatting
builder->get_ListFormat()->set_List(nullptr);
doc->Save(ArtifactsDir + u"Lists.SpecifyListLevel.docx");

Shows how to start a numbered list, add a bulleted list inside it, then return to the numbered list.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Create an outline list for the headings
SharedPtr<List> outlineList = doc->get_Lists()->Add(Aspose::Words::Lists::ListTemplate::OutlineNumbers);
builder->get_ListFormat()->set_List(outlineList);
builder->get_ParagraphFormat()->set_StyleIdentifier(Aspose::Words::StyleIdentifier::Heading1);
builder->Writeln(u"This is my Chapter 1");
// Create a numbered list
SharedPtr<List> numberedList = doc->get_Lists()->Add(Aspose::Words::Lists::ListTemplate::NumberDefault);
builder->get_ListFormat()->set_List(numberedList);
builder->get_ParagraphFormat()->set_StyleIdentifier(Aspose::Words::StyleIdentifier::Normal);
builder->Writeln(u"Numbered list item 1.");
// Every paragraph that comprises a list will have this flag
ASSERT_TRUE(builder->get_CurrentParagraph()->get_IsListItem());
ASSERT_TRUE(builder->get_ParagraphFormat()->get_IsListItem());
// Create a bulleted list
SharedPtr<List> bulletedList = doc->get_Lists()->Add(Aspose::Words::Lists::ListTemplate::BulletDefault);
builder->get_ListFormat()->set_List(bulletedList);
builder->get_ParagraphFormat()->set_LeftIndent(72);
builder->Writeln(u"Bulleted list item 1.");
builder->Writeln(u"Bulleted list item 2.");
builder->get_ParagraphFormat()->ClearFormatting();
// Revert to the numbered list
builder->get_ListFormat()->set_List(numberedList);
builder->Writeln(u"Numbered list item 2.");
builder->Writeln(u"Numbered list item 3.");
// Revert to the outline list
builder->get_ListFormat()->set_List(outlineList);
builder->get_ParagraphFormat()->set_StyleIdentifier(Aspose::Words::StyleIdentifier::Heading1);
builder->Writeln(u"This is my Chapter 2");
builder->get_ParagraphFormat()->ClearFormatting();
builder->get_Document()->Save(ArtifactsDir + u"Lists.NestedLists.docx");

◆ get_ListLevel()

System::SharedPtr<Aspose::Words::Lists::ListLevel> Aspose::Words::ListFormat::get_ListLevel ( )

Returns the list level formatting plus any formatting overrides applied to the current paragraph.

Examples

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

auto doc = MakeObject<Document>();
// Create a list based on one of the Microsoft Word list templates
SharedPtr<List> list = doc->get_Lists()->Add(Aspose::Words::Lists::ListTemplate::NumberDefault);
// Completely customize one list level
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(Aspose::Words::NumberStyle::OrdinalText);
listLevel->set_StartAt(21);
listLevel->set_NumberFormat(u"\x0000");
listLevel->set_NumberPosition(-36);
listLevel->set_TextPosition(144);
listLevel->set_TabPosition(144);
// Customize another list level
listLevel = list->get_ListLevels()->idx_get(1);
listLevel->set_NumberStyle(Aspose::Words::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);
listLevel->set_NumberFormat(u"\xf0af");
// A bullet that looks like a star
listLevel->set_TrailingCharacter(Aspose::Words::Lists::ListTrailingCharacter::Space);
listLevel->set_NumberPosition(144);
// Now add some text that uses the list that we created
// It does not matter when to customize the list - before or after adding the paragraphs
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_ListLevelNumber()

int32_t Aspose::Words::ListFormat::get_ListLevelNumber ( )

Gets or sets the list level number (0 to 8) for the paragraph.

In Word documents, lists may consist of 1 or 9 levels, numbered 0 to 8.

Has effect only when the List property is set to reference a valid list.

See also
Aspose::Words::ListFormat::get_List
Examples

Shows how to apply default bulleted or numbered list formatting to paragraphs when using DocumentBuilder.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Aspose.Words allows:");
builder->Writeln();
// Start a numbered list with default formatting
builder->get_ListFormat()->ApplyNumberDefault();
builder->Writeln(u"Opening documents from different formats:");
ASSERT_EQ(0, builder->get_ListFormat()->get_ListLevelNumber());
// Go to second list level, add more text
builder->get_ListFormat()->ListIndent();
ASSERT_EQ(1, builder->get_ListFormat()->get_ListLevelNumber());
builder->Writeln(u"DOC");
builder->Writeln(u"PDF");
builder->Writeln(u"HTML");
// Outdent to the first list level
builder->get_ListFormat()->ListOutdent();
ASSERT_EQ(0, builder->get_ListFormat()->get_ListLevelNumber());
builder->Writeln(u"Processing documents");
builder->Writeln(u"Saving documents in different formats:");
// Indent the list level again
builder->get_ListFormat()->ListIndent();
builder->Writeln(u"DOC");
builder->Writeln(u"PDF");
builder->Writeln(u"HTML");
builder->Writeln(u"MHTML");
builder->Writeln(u"Plain text");
// Outdent the list level again
builder->get_ListFormat()->ListOutdent();
builder->Writeln(u"Doing many other things!");
// End the numbered list
builder->get_ListFormat()->RemoveNumbers();
builder->Writeln();
builder->Writeln(u"Aspose.Words main advantages are:");
builder->Writeln();
// Start a bulleted list with default formatting
builder->get_ListFormat()->ApplyBulletDefault();
builder->Writeln(u"Great performance");
builder->Writeln(u"High reliability");
builder->Writeln(u"Quality code and working");
builder->Writeln(u"Wide variety of features");
builder->Writeln(u"Easy to understand API");
// End the bulleted list
builder->get_ListFormat()->RemoveNumbers();
doc->Save(ArtifactsDir + u"Lists.ApplyDefaultBulletsAndNumbers.docx");

Shows how to specify list level number when building a list using DocumentBuilder.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Create a numbered list based on one of the Microsoft Word list templates and
// apply it to the current paragraph in the document builder
builder->get_ListFormat()->set_List(doc->get_Lists()->Add(Aspose::Words::Lists::ListTemplate::NumberArabicDot));
// Insert text at each of the 9 indent levels
for (int i = 0; i < 9; i++)
{
builder->get_ListFormat()->set_ListLevelNumber(i);
builder->Writeln(String(u"Level ") + i);
}
// Create a bulleted list based on one of the Microsoft Word list templates
// and apply it to the current paragraph in the document builder
builder->get_ListFormat()->set_List(doc->get_Lists()->Add(Aspose::Words::Lists::ListTemplate::BulletDiamonds));
for (int i = 0; i < 9; i++)
{
builder->get_ListFormat()->set_ListLevelNumber(i);
builder->Writeln(String(u"Level ") + i);
}
// This is a way to stop list formatting
builder->get_ListFormat()->set_List(nullptr);
doc->Save(ArtifactsDir + u"Lists.SpecifyListLevel.docx");

◆ GetType()

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

Reimplemented from System::Object.

◆ Is()

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

Reimplemented from System::Object.

◆ ListIndent()

void Aspose::Words::ListFormat::ListIndent ( )

Increases the list level of the current paragraph by one level.

This method changes the list level and applies formatting properties of the new level.

In Word documents, lists may consist of up to nine levels. List formatting for each level specifies what bullet or number is used, left indent, space between the bullet and text etc.

Examples

Shows how to apply default bulleted or numbered list formatting to paragraphs when using DocumentBuilder.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Aspose.Words allows:");
builder->Writeln();
// Start a numbered list with default formatting
builder->get_ListFormat()->ApplyNumberDefault();
builder->Writeln(u"Opening documents from different formats:");
ASSERT_EQ(0, builder->get_ListFormat()->get_ListLevelNumber());
// Go to second list level, add more text
builder->get_ListFormat()->ListIndent();
ASSERT_EQ(1, builder->get_ListFormat()->get_ListLevelNumber());
builder->Writeln(u"DOC");
builder->Writeln(u"PDF");
builder->Writeln(u"HTML");
// Outdent to the first list level
builder->get_ListFormat()->ListOutdent();
ASSERT_EQ(0, builder->get_ListFormat()->get_ListLevelNumber());
builder->Writeln(u"Processing documents");
builder->Writeln(u"Saving documents in different formats:");
// Indent the list level again
builder->get_ListFormat()->ListIndent();
builder->Writeln(u"DOC");
builder->Writeln(u"PDF");
builder->Writeln(u"HTML");
builder->Writeln(u"MHTML");
builder->Writeln(u"Plain text");
// Outdent the list level again
builder->get_ListFormat()->ListOutdent();
builder->Writeln(u"Doing many other things!");
// End the numbered list
builder->get_ListFormat()->RemoveNumbers();
builder->Writeln();
builder->Writeln(u"Aspose.Words main advantages are:");
builder->Writeln();
// Start a bulleted list with default formatting
builder->get_ListFormat()->ApplyBulletDefault();
builder->Writeln(u"Great performance");
builder->Writeln(u"High reliability");
builder->Writeln(u"Quality code and working");
builder->Writeln(u"Wide variety of features");
builder->Writeln(u"Easy to understand API");
// End the bulleted list
builder->get_ListFormat()->RemoveNumbers();
doc->Save(ArtifactsDir + u"Lists.ApplyDefaultBulletsAndNumbers.docx");

◆ ListOutdent()

void Aspose::Words::ListFormat::ListOutdent ( )

Decreases the list level of the current paragraph by one level.

This method changes the list level and applies formatting properties of the new level.

In Word documents, lists may consist of up to nine levels. List formatting for each level specifies what bullet or number is used, left indent, space between the bullet and text etc.

Examples

Shows how to apply default bulleted or numbered list formatting to paragraphs when using DocumentBuilder.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Aspose.Words allows:");
builder->Writeln();
// Start a numbered list with default formatting
builder->get_ListFormat()->ApplyNumberDefault();
builder->Writeln(u"Opening documents from different formats:");
ASSERT_EQ(0, builder->get_ListFormat()->get_ListLevelNumber());
// Go to second list level, add more text
builder->get_ListFormat()->ListIndent();
ASSERT_EQ(1, builder->get_ListFormat()->get_ListLevelNumber());
builder->Writeln(u"DOC");
builder->Writeln(u"PDF");
builder->Writeln(u"HTML");
// Outdent to the first list level
builder->get_ListFormat()->ListOutdent();
ASSERT_EQ(0, builder->get_ListFormat()->get_ListLevelNumber());
builder->Writeln(u"Processing documents");
builder->Writeln(u"Saving documents in different formats:");
// Indent the list level again
builder->get_ListFormat()->ListIndent();
builder->Writeln(u"DOC");
builder->Writeln(u"PDF");
builder->Writeln(u"HTML");
builder->Writeln(u"MHTML");
builder->Writeln(u"Plain text");
// Outdent the list level again
builder->get_ListFormat()->ListOutdent();
builder->Writeln(u"Doing many other things!");
// End the numbered list
builder->get_ListFormat()->RemoveNumbers();
builder->Writeln();
builder->Writeln(u"Aspose.Words main advantages are:");
builder->Writeln();
// Start a bulleted list with default formatting
builder->get_ListFormat()->ApplyBulletDefault();
builder->Writeln(u"Great performance");
builder->Writeln(u"High reliability");
builder->Writeln(u"Quality code and working");
builder->Writeln(u"Wide variety of features");
builder->Writeln(u"Easy to understand API");
// End the bulleted list
builder->get_ListFormat()->RemoveNumbers();
doc->Save(ArtifactsDir + u"Lists.ApplyDefaultBulletsAndNumbers.docx");

◆ RemoveNumbers()

void Aspose::Words::ListFormat::RemoveNumbers ( )

Removes numbers or bullets from the current paragraph and sets list level to zero.

Calling this method is equivalent to setting the List property to null.

Examples

Shows how to apply default bulleted or numbered list formatting to paragraphs when using DocumentBuilder.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Aspose.Words allows:");
builder->Writeln();
// Start a numbered list with default formatting
builder->get_ListFormat()->ApplyNumberDefault();
builder->Writeln(u"Opening documents from different formats:");
ASSERT_EQ(0, builder->get_ListFormat()->get_ListLevelNumber());
// Go to second list level, add more text
builder->get_ListFormat()->ListIndent();
ASSERT_EQ(1, builder->get_ListFormat()->get_ListLevelNumber());
builder->Writeln(u"DOC");
builder->Writeln(u"PDF");
builder->Writeln(u"HTML");
// Outdent to the first list level
builder->get_ListFormat()->ListOutdent();
ASSERT_EQ(0, builder->get_ListFormat()->get_ListLevelNumber());
builder->Writeln(u"Processing documents");
builder->Writeln(u"Saving documents in different formats:");
// Indent the list level again
builder->get_ListFormat()->ListIndent();
builder->Writeln(u"DOC");
builder->Writeln(u"PDF");
builder->Writeln(u"HTML");
builder->Writeln(u"MHTML");
builder->Writeln(u"Plain text");
// Outdent the list level again
builder->get_ListFormat()->ListOutdent();
builder->Writeln(u"Doing many other things!");
// End the numbered list
builder->get_ListFormat()->RemoveNumbers();
builder->Writeln();
builder->Writeln(u"Aspose.Words main advantages are:");
builder->Writeln();
// Start a bulleted list with default formatting
builder->get_ListFormat()->ApplyBulletDefault();
builder->Writeln(u"Great performance");
builder->Writeln(u"High reliability");
builder->Writeln(u"Quality code and working");
builder->Writeln(u"Wide variety of features");
builder->Writeln(u"Easy to understand API");
// End the bulleted list
builder->get_ListFormat()->RemoveNumbers();
doc->Save(ArtifactsDir + u"Lists.ApplyDefaultBulletsAndNumbers.docx");

Shows how to remove bullets and numbering from all paragraphs in the main text of a section.

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();
SharedPtr<NodeCollection> paras = doc->GetChildNodes(Aspose::Words::NodeType::Paragraph, true);
ASSERT_EQ(3, paras->LINQ_Count([](SharedPtr<Node> n) { return System::DynamicCast<Paragraph>(n)->get_ListFormat()->get_IsListItem(); }));
for (auto paragraph : System::IterateOver<Paragraph>(paras))
{
paragraph->get_ListFormat()->RemoveNumbers();
}
ASSERT_EQ(0, paras->LINQ_Count([](SharedPtr<Node> n) { return System::DynamicCast<Paragraph>(n)->get_ListFormat()->get_IsListItem(); }));

◆ set_List()

void Aspose::Words::ListFormat::set_List ( System::SharedPtr< Aspose::Words::Lists::List value)

◆ set_ListLevelNumber()

void Aspose::Words::ListFormat::set_ListLevelNumber ( int32_t  value)

◆ Type()

static const System::TypeInfo& Aspose::Words::ListFormat::Type ( )
static
String
@ BulletDiamonds
The bullet of the first level is a 4-diamond Wingding character. The remaining levels are same as in ...
@ NumberDefault
Default numbered list with 9 levels. Arabic numbering (1., 2., 3., ...) for the first level,...
static ASPOSECPP_SHARED_API void WriteLine()
std::enable_if_t<!Details::IsIterable< Enumerable >::value, Details::EnumeratorAdapter< Enumerable, T > > IterateOver(System::SmartPtr< Enumerable > enumerable)
@ Heading1
The Heading 1 style.
@ Right
This list label is aligned to the right of the number position.
@ OutlineNumbers
An outline list with levels numbered "1), a), i), (1), (a), (i), 1., a., i.". Corresponds to the 1st ...
@ Space
A space character is placed between the list label and text of the paragraph.
static ASPOSECPP_SHARED_API Color get_Blue()
static ASPOSECPP_SHARED_API Color get_Red()
@ Bullet
Bullet (check the character code in the text)
@ Normal
The Normal style.
@ Paragraph
A paragraph of text. A Paragraph node is a container for inline level elements Run,...
@ OrdinalText
Ordinal (text) (First, Second, Third, ...)
@ BulletDefault
Default bulleted list with 9 levels. Bullet of the first level is a disc, bullet of the second level ...
@ NumberArabicDot
Same as NumberDefault. Corresponds to the 1st numbered list template in the Bullets and Numbering dia...