Aspose::Words::Range class

Range class

Represents a contiguous area in a document. To learn more, visit the Working with Ranges documentation article.

class Range : public System::Object

Methods

MethodDescription
Delete()Deletes all characters of the range.
get_Bookmarks()Returns a Bookmarks collection that represents all bookmarks in the range.
get_Fields()Returns a Fields collection that represents all fields in the range.
get_FormFields()Returns a FormFields collection that represents all form fields in the range.
get_Revisions()Gets a collection of revisions (tracked changes) that exist in this range.
get_StructuredDocumentTags()Returns a StructuredDocumentTags collection that represents all structured document tags in the range.
get_Text()Gets the text of the range.
GetType() const override
Is(const System::TypeInfo&) const override
NormalizeFieldTypes()Changes field type values FieldType of FieldStart, FieldSeparator, FieldEnd in this range so that they correspond to the field types contained in the field codes.
Replace(const System::String&, const System::String&)Replaces all occurrences of a specified character string pattern with a replacement string.
Replace(const System::SharedPtr<System::Text::RegularExpressions::Regex>&, const System::String&)Replaces all occurrences of a character pattern specified by a regular expression with another string.
Replace(const System::String&, const System::String&, const System::SharedPtr<Aspose::Words::Replacing::FindReplaceOptions>&)Replaces all occurrences of a specified character string pattern with a replacement string.
Replace(const System::SharedPtr<System::Text::RegularExpressions::Regex>&, const System::String&, const System::SharedPtr<Aspose::Words::Replacing::FindReplaceOptions>&)Replaces all occurrences of a character pattern specified by a regular expression with another string.
ToDocument()Constructs a new fully formed document that contains the range.
static Type()
UnlinkFields()Unlinks fields in this range.
UpdateFields()Updates the values of document fields in this range.

Remarks

The document is represented by a tree of nodes and the nodes provide operations to work with the tree, but some operations are easier to perform if the document is treated as a contiguous sequence of text.

Range is a “facade” interface that provide methods that treat the document or portions of the document as “flat” text regardless of the fact that the document nodes are stored in a tree-like object model.

Range does not contain any text or nodes, it is merely a view or “window” over a fragment of a document.

Examples

Shows how to get the text contents of all the nodes that a range covers.

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

builder->Write(u"Hello world!");

ASSERT_EQ(u"Hello world!", doc->get_Range()->get_Text().Trim());

See Also