Aspose::Words::Replacing::FindReplaceOptions::get_IgnoreFields method

FindReplaceOptions::get_IgnoreFields method

Gets or sets a boolean value indicating either to ignore text inside fields. The default value is false.

bool Aspose::Words::Replacing::FindReplaceOptions::get_IgnoreFields() const

Remarks

This option affects whole field (all nodes between FieldStart and FieldEnd).

To ignore only field codes, please use corresponding option IgnoreFieldCodes.

Examples

Shows how to ignore text inside fields.

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

builder->Writeln(u"Hello world!");
builder->InsertField(u"QUOTE", u"Hello again!");

// We can use a "FindReplaceOptions" object to modify the find-and-replace process.
auto options = MakeObject<FindReplaceOptions>();

// Set the "IgnoreFields" flag to "true" to get the find-and-replace
// operation to ignore text inside fields.
// Set the "IgnoreFields" flag to "false" to get the find-and-replace
// operation to also search for text inside fields.
options->set_IgnoreFields(ignoreTextInsideFields);

doc->get_Range()->Replace(u"Hello", u"Greetings", options);

ASSERT_EQ(ignoreTextInsideFields ? String(u"Greetings world!\r\u0013QUOTE\u0014Hello again!\u0015")
                                 : String(u"Greetings world!\r\u0013QUOTE\u0014Greetings again!\u0015"),
          doc->GetText().Trim());

See Also