Aspose::Words::Lists::ListLabel Class Reference

Detailed Description

Defines properties specific to a list label.

Examples

Shows how to extract the list labels of all paragraphs that are list items.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
doc->UpdateListLabels();
SharedPtr<NodeCollection> paras = doc->GetChildNodes(NodeType::Paragraph, true);
// Find if we have the paragraph list. In our document, our list uses plain Arabic numbers,
// which start at three and ends at six.
for (auto paragraph : System::IterateOver(
paras->LINQ_OfType<SharedPtr<Paragraph>>()->LINQ_Where([](SharedPtr<Paragraph> p) { return p->get_ListFormat()->get_IsListItem(); })))
{
std::cout << "List item paragraph #" << paras->IndexOf(paragraph) << std::endl;
// This is the text we get when getting when we output this node to text format.
// This text output will omit list labels. Trim any paragraph formatting characters.
String paragraphText = paragraph->ToString(SaveFormat::Text).Trim();
std::cout << "\tExported Text: " << paragraphText << std::endl;
SharedPtr<ListLabel> label = paragraph->get_ListLabel();
// This gets the position of the paragraph in the current level of the list. If we have a list with multiple levels,
// this will tell us what position it is on that level.
std::cout << "\tNumerical Id: " << label->get_LabelValue() << std::endl;
// Combine them together to include the list label with the text in the output.
std::cout << "\tList label combined with text: " << label->get_LabelString() << " " << paragraphText << std::endl;
}

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

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

Public Member Functions

SharedPtr< Fontget_Font ()
 Gets the list label font. More...
 
String get_LabelString ()
 Gets a string representation of list label. More...
 
int32_t get_LabelValue ()
 Gets a numeric value for this label. More...
 
virtual const TypeInfoGetType () const override
 
virtual bool Is (const TypeInfo &target) const override
 

Static Public Member Functions

static const TypeInfoType ()
 

Member Function Documentation

◆ get_Font()

System::SharedPtr<Aspose::Words::Font> Aspose::Words::Lists::ListLabel::get_Font ( )

Gets the list label font.

◆ get_LabelString()

System::String Aspose::Words::Lists::ListLabel::get_LabelString ( )

Gets a string representation of list label.

Examples

Shows how to extract the list labels of all paragraphs that are list items.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
doc->UpdateListLabels();
SharedPtr<NodeCollection> paras = doc->GetChildNodes(NodeType::Paragraph, true);
// Find if we have the paragraph list. In our document, our list uses plain Arabic numbers,
// which start at three and ends at six.
for (auto paragraph : System::IterateOver(
paras->LINQ_OfType<SharedPtr<Paragraph>>()->LINQ_Where([](SharedPtr<Paragraph> p) { return p->get_ListFormat()->get_IsListItem(); })))
{
std::cout << "List item paragraph #" << paras->IndexOf(paragraph) << std::endl;
// This is the text we get when getting when we output this node to text format.
// This text output will omit list labels. Trim any paragraph formatting characters.
String paragraphText = paragraph->ToString(SaveFormat::Text).Trim();
std::cout << "\tExported Text: " << paragraphText << std::endl;
SharedPtr<ListLabel> label = paragraph->get_ListLabel();
// This gets the position of the paragraph in the current level of the list. If we have a list with multiple levels,
// this will tell us what position it is on that level.
std::cout << "\tNumerical Id: " << label->get_LabelValue() << std::endl;
// Combine them together to include the list label with the text in the output.
std::cout << "\tList label combined with text: " << label->get_LabelString() << " " << paragraphText << std::endl;
}

◆ get_LabelValue()

int32_t Aspose::Words::Lists::ListLabel::get_LabelValue ( )

Gets a numeric value for this label.

Examples

Shows how to extract the list labels of all paragraphs that are list items.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
doc->UpdateListLabels();
SharedPtr<NodeCollection> paras = doc->GetChildNodes(NodeType::Paragraph, true);
// Find if we have the paragraph list. In our document, our list uses plain Arabic numbers,
// which start at three and ends at six.
for (auto paragraph : System::IterateOver(
paras->LINQ_OfType<SharedPtr<Paragraph>>()->LINQ_Where([](SharedPtr<Paragraph> p) { return p->get_ListFormat()->get_IsListItem(); })))
{
std::cout << "List item paragraph #" << paras->IndexOf(paragraph) << std::endl;
// This is the text we get when getting when we output this node to text format.
// This text output will omit list labels. Trim any paragraph formatting characters.
String paragraphText = paragraph->ToString(SaveFormat::Text).Trim();
std::cout << "\tExported Text: " << paragraphText << std::endl;
SharedPtr<ListLabel> label = paragraph->get_ListLabel();
// This gets the position of the paragraph in the current level of the list. If we have a list with multiple levels,
// this will tell us what position it is on that level.
std::cout << "\tNumerical Id: " << label->get_LabelValue() << std::endl;
// Combine them together to include the list label with the text in the output.
std::cout << "\tList label combined with text: " << label->get_LabelString() << " " << paragraphText << std::endl;
}

◆ GetType()

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

◆ Is()

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

◆ Type()

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