Aspose::Words::Fields::FieldSymbol class

FieldSymbol class

Implements a SYMBOL field. To learn more, visit the Working with Fields documentation article.

class FieldSymbol : public Aspose::Words::Fields::Field,
                    public Aspose::Words::Fields::IFieldCodeTokenInfoProvider

Methods

MethodDescription
get_CharacterCode()Gets or sets the character’s code point value in decimal or hexadecimal.
get_DisplayResult()Gets the text that represents the displayed field result.
get_DontAffectsLineSpacing()Gets or sets whether the character retrieved by the field affects the line spacing of the paragraph.
get_End() constGets the node that represents the field end.
get_FieldEnd() constGets the node that represents the field end.
get_FieldStart() constGets the node that represents the start of the field.
get_FontName()Gets or sets the name of the font of the character retrieved by the field.
get_FontSize()Gets or sets the size in points of the font of the character retrieved by the field.
get_Format()Gets a FieldFormat object that provides typed access to field’s formatting.
get_IsAnsi()Gets or sets whether the character code is interpreted as the value of an ANSI character.
get_IsDirty()Gets 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_IsShiftJis()Gets or sets whether the character code is interpreted as the value of a SHIFT-JIS character.
get_IsUnicode()Gets or sets whether the character code is interpreted as the value of a Unicode character.
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_Separator()Gets the node that represents the field separator. Can be null.
get_Start() constGets the node that represents the start of the field.
virtual get_Type() constGets 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_CharacterCode(const System::String&)Setter for Aspose::Words::Fields::FieldSymbol::get_CharacterCode.
set_DontAffectsLineSpacing(bool)Setter for Aspose::Words::Fields::FieldSymbol::get_DontAffectsLineSpacing.
set_FontName(const System::String&)Setter for Aspose::Words::Fields::FieldSymbol::get_FontName.
set_FontSize(const System::String&)Setter for Aspose::Words::Fields::FieldSymbol::get_FontSize.
set_IsAnsi(bool)Setter for Aspose::Words::Fields::FieldSymbol::get_IsAnsi.
set_IsDirty(bool)Sets whether the current result of the field is no longer correct (stale) due to other modifications made to the document.
set_IsLocked(bool)Setter for Aspose::Words::Fields::Field::get_IsLocked.
set_IsShiftJis(bool)Setter for Aspose::Words::Fields::FieldSymbol::get_IsShiftJis.
set_IsUnicode(bool)Setter for Aspose::Words::Fields::FieldSymbol::get_IsUnicode.
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.
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 the SYMBOL field.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);

// Below are three ways to use a SYMBOL field to display a single character.
// 1 -  Add a SYMBOL field which displays the © (Copyright) symbol, specified by an ANSI character code:
auto field = System::ExplicitCast<FieldSymbol>(builder->InsertField(FieldType::FieldSymbol, true));

// The ANSI character code "U+00A9", or "169" in integer form, is reserved for the copyright symbol.
field->set_CharacterCode(System::Convert::ToString(0x00a9));
field->set_IsAnsi(true);

ASSERT_EQ(u" SYMBOL  169 \\a", field->GetFieldCode());

builder->Writeln(u" Line 1");

// 2 -  Add a SYMBOL field which displays the ∞ (Infinity) symbol, and modify its appearance:
field = System::ExplicitCast<FieldSymbol>(builder->InsertField(FieldType::FieldSymbol, true));

// In Unicode, the infinity symbol occupies the "221E" code.
field->set_CharacterCode(System::Convert::ToString(0x221E));
field->set_IsUnicode(true);

// Change the font of our symbol after using the Windows Character Map
// to ensure that the font can represent that symbol.
field->set_FontName(u"Calibri");
field->set_FontSize(u"24");

// We can set this flag for tall symbols to make them not push down the rest of the text on their line.
field->set_DontAffectsLineSpacing(true);

ASSERT_EQ(u" SYMBOL  8734 \\u \\f Calibri \\s 24 \\h", field->GetFieldCode());

builder->Writeln(u"Line 2");

// 3 -  Add a SYMBOL field which displays the あ character,
// with a font that supports Shift-JIS (Windows-932) codepage:
field = System::ExplicitCast<FieldSymbol>(builder->InsertField(FieldType::FieldSymbol, true));
field->set_FontName(u"MS Gothic");
field->set_CharacterCode(System::Convert::ToString(0x82A0));
field->set_IsShiftJis(true);

ASSERT_EQ(u" SYMBOL  33440 \\f \"MS Gothic\" \\j", field->GetFieldCode());

builder->Write(u"Line 3");

doc->Save(ArtifactsDir + u"Field.SYMBOL.docx");

See Also