Aspose::Words::Fields::FieldStyleRef class
Contents
[
Hide
]FieldStyleRef class
Implements the STYLEREF field. To learn more, visit the Working with Fields documentation article.
class FieldStyleRef : public Aspose::Words::Fields::Field,
public Aspose::Words::Fields::IFieldCodeTokenInfoProvider
Methods
Method | Description |
---|---|
get_DisplayResult() | Gets the text that represents the displayed field result. |
get_End() const | Gets the node that represents the field end. |
get_FieldEnd() const | Gets the node that represents the field end. |
get_FieldStart() const | Gets the node that represents the start of the field. |
get_Format() | Gets a FieldFormat object that provides typed access to field’s formatting. |
get_InsertParagraphNumber() | Gets or sets whether to insert the paragraph number of the referenced paragraph exactly as it appears in the document. |
get_InsertParagraphNumberInFullContext() | Gets or sets whether to insert the paragraph number of the referenced paragraph in full context. |
get_InsertParagraphNumberInRelativeContext() | Gets or sets whether to insert the paragraph number of the referenced paragraph in relative context. |
get_InsertRelativePosition() | Gets or sets whether to insert the relative position of the referenced paragraph. |
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. |
get_IsLocked() | Gets or sets whether the field is locked (should not recalculate its result). |
get_LocaleId() | Gets or sets the LCID of the field. |
get_Result() | Gets or sets text that is between the field separator and field end. |
get_SearchFromBottom() | Gets or sets whether to search from the bottom of the current page, rather from the top. |
get_Separator() | Gets the node that represents the field separator. Can be null. |
get_Start() const | Gets the node that represents the start of the field. |
get_StyleName() | Gets or sets the name of the style by which the text to search for is formatted. |
get_SuppressNonDelimiters() | Gets or sets whether to suppress non-delimiter characters. |
virtual get_Type() const | Gets the Microsoft Word field type. |
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. |
GetFieldCode(bool) | Returns text between field start and field separator (or field end if there is no separator). |
GetType() const override | |
Is(const System::TypeInfo&) const override | |
Remove() | 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. |
set_InsertParagraphNumber(bool) | Setter for Aspose::Words::Fields::FieldStyleRef::get_InsertParagraphNumber. |
set_InsertParagraphNumberInFullContext(bool) | Setter for Aspose::Words::Fields::FieldStyleRef::get_InsertParagraphNumberInFullContext. |
set_InsertParagraphNumberInRelativeContext(bool) | Setter for Aspose::Words::Fields::FieldStyleRef::get_InsertParagraphNumberInRelativeContext. |
set_InsertRelativePosition(bool) | Setter for Aspose::Words::Fields::FieldStyleRef::get_InsertRelativePosition. |
set_IsDirty(bool) | Setter for Aspose::Words::Fields::Field::get_IsDirty. |
set_IsLocked(bool) | Setter for Aspose::Words::Fields::Field::get_IsLocked. |
set_LocaleId(int32_t) | Setter for Aspose::Words::Fields::Field::get_LocaleId. |
set_Result(const System::String&) | Setter for Aspose::Words::Fields::Field::get_Result. |
set_SearchFromBottom(bool) | Setter for Aspose::Words::Fields::FieldStyleRef::get_SearchFromBottom. |
set_StyleName(const System::String&) | Setter for Aspose::Words::Fields::FieldStyleRef::get_StyleName. |
set_SuppressNonDelimiters(bool) | Setter for Aspose::Words::Fields::FieldStyleRef::get_SuppressNonDelimiters. |
static Type() | |
Unlink() | Performs the field unlink. |
Update() | Performs the field update. Throws if the field is being updated already. |
Update(bool) | Performs a field update. Throws if the field is being updated already. |
Examples
Shows how to use STYLEREF fields.
auto doc = System::MakeObject<Aspose::Words::Document>();
auto builder = System::MakeObject<Aspose::Words::DocumentBuilder>(doc);
// Create a list based using a Microsoft Word list template.
System::SharedPtr<Aspose::Words::Lists::List> list = doc->get_Lists()->Add(Aspose::Words::Lists::ListTemplate::NumberDefault);
// This generated list will display "1.a )".
// Space before the bracket is a non-delimiter character, which we can suppress.
list->get_ListLevels()->idx_get(0)->set_NumberFormat(u"\x0000" u".");
list->get_ListLevels()->idx_get(1)->set_NumberFormat(u"\x0001" u" )");
// Add text and apply paragraph styles that STYLEREF fields will reference.
builder->get_ListFormat()->set_List(list);
builder->get_ListFormat()->ListIndent();
builder->get_ParagraphFormat()->set_Style(doc->get_Styles()->idx_get(u"List Paragraph"));
builder->Writeln(u"Item 1");
builder->get_ParagraphFormat()->set_Style(doc->get_Styles()->idx_get(u"Quote"));
builder->Writeln(u"Item 2");
builder->get_ParagraphFormat()->set_Style(doc->get_Styles()->idx_get(u"List Paragraph"));
builder->Writeln(u"Item 3");
builder->get_ListFormat()->RemoveNumbers();
builder->get_ParagraphFormat()->set_Style(doc->get_Styles()->idx_get(u"Normal"));
// Place a STYLEREF field in the header and display the first "List Paragraph"-styled text in the document.
builder->MoveToHeaderFooter(Aspose::Words::HeaderFooterType::HeaderPrimary);
auto field = System::ExplicitCast<Aspose::Words::Fields::FieldStyleRef>(builder->InsertField(Aspose::Words::Fields::FieldType::FieldStyleRef, true));
field->set_StyleName(u"List Paragraph");
// Place a STYLEREF field in the footer, and have it display the last text.
builder->MoveToHeaderFooter(Aspose::Words::HeaderFooterType::FooterPrimary);
field = System::ExplicitCast<Aspose::Words::Fields::FieldStyleRef>(builder->InsertField(Aspose::Words::Fields::FieldType::FieldStyleRef, true));
field->set_StyleName(u"List Paragraph");
field->set_SearchFromBottom(true);
builder->MoveToDocumentEnd();
// We can also use STYLEREF fields to reference the list numbers of lists.
builder->Write(u"\nParagraph number: ");
field = System::ExplicitCast<Aspose::Words::Fields::FieldStyleRef>(builder->InsertField(Aspose::Words::Fields::FieldType::FieldStyleRef, true));
field->set_StyleName(u"Quote");
field->set_InsertParagraphNumber(true);
builder->Write(u"\nParagraph number, relative context: ");
field = System::ExplicitCast<Aspose::Words::Fields::FieldStyleRef>(builder->InsertField(Aspose::Words::Fields::FieldType::FieldStyleRef, true));
field->set_StyleName(u"Quote");
field->set_InsertParagraphNumberInRelativeContext(true);
builder->Write(u"\nParagraph number, full context: ");
field = System::ExplicitCast<Aspose::Words::Fields::FieldStyleRef>(builder->InsertField(Aspose::Words::Fields::FieldType::FieldStyleRef, true));
field->set_StyleName(u"Quote");
field->set_InsertParagraphNumberInFullContext(true);
builder->Write(u"\nParagraph number, full context, non-delimiter chars suppressed: ");
field = System::ExplicitCast<Aspose::Words::Fields::FieldStyleRef>(builder->InsertField(Aspose::Words::Fields::FieldType::FieldStyleRef, true));
field->set_StyleName(u"Quote");
field->set_InsertParagraphNumberInFullContext(true);
field->set_SuppressNonDelimiters(true);
doc->UpdatePageLayout();
doc->UpdateFields();
doc->Save(get_ArtifactsDir() + u"Field.STYLEREF.docx");
See Also
- Class Field
- Namespace Aspose::Words::Fields
- Library Aspose.Words for C++