Nevron Open Vision Documentation
Rich Text Editor / Document Model / Range Elements
In This Topic
    Range Elements
    In This Topic

    All text elements except table column derive from the NRangeTextElement class. This class provides a system for indexing text content inside text root elements (document, header and footer). This indexing allows you to identify text elements that correspond to a particular text position, by assigning a unique index to each character, image, formatting instruction, etc. inside a particular root element. This allows you to think about all text content as if it is a simple string. 

     Range

    Each range text element has a property called Range which allow you to get the range of positions spanned by a particular text element. For example consider the following code:

    Range
    Copy Code
    NSection section = new NSection();
    
    NParagraph paragraph = new NParagraph();
    
    NTextInline lowerCaps1 = new NTextInline("lower case text ");
    NTextInline upperCaps = new NTextInline("UPPER CASE TEXT");
    NTextInline lowerCaps2 = new NTextInline(" lower case text");
    
    paragraph.Inlines.Add(lowerCaps1);
    paragraph.Inlines.Add(upperCaps);
    paragraph.Inlines.Add(lowerCaps2);
    
    section.Blocks.Add(paragraph);
    
    m_RichText.Content.Sections.Clear();
    m_RichText.Content.Sections.Add(section);
    
    m_RichText.Content.Selection.SelectRange(upperCaps.Range);
    

    Note that the last line of code selects the range spanned by the inline containing upper caps. This results in the following text output:

    In this particular example the value of the Range property of the upper caps inline is [16, 30]. This is because the inline element before it contains 16 characters and the upper caps inline itself is 15 chars long.

    Blocks elements have ranges that encompass the content of all their descendant inline elements - for example the Range property of the paragraph defined in the above example is [0, 47]. This is how it's calculated:

    - lowerCaps1 - [0, 15]

    - upperCaps - [16, 30]

    - lowerCaps2 - [31, 46]

    - paragraph end [47, 47]

    Intrinsic inline elements such as paragraph end participate in the range indexing.