Class ContentRange
Spans a set of content in a document. Used when performing operations on the document content.
Inheritance
Implements
Inherited Members
Namespace: Sdl.DesktopEditor.EditorApi
Assembly: Sdl.DesktopEditor.EditorApi.dll
Syntax
public class ContentRange : ICloneable
Constructors
ContentRange()
Create a range with uninitialized (invalid) from and upto positions.
Declaration
public ContentRange()
ContentRange(ContentRange)
Clone another range
Declaration
protected ContentRange(ContentRange other)
Parameters
| Type | Name | Description |
|---|---|---|
| ContentRange | other |
ContentRange(IAbstractContentNode, IAbstractContentNode)
Create from and upto positions from nodes, using offset 0 for both nodes.
Declaration
public ContentRange(IAbstractContentNode from, IAbstractContentNode upto)
Parameters
| Type | Name | Description |
|---|---|---|
| IAbstractContentNode | from | |
| IAbstractContentNode | upto |
ContentRange(IContentSelection)
Create a range spanning the same content as a selection.
Declaration
public ContentRange(IContentSelection selection)
Parameters
| Type | Name | Description |
|---|---|---|
| IContentSelection | selection |
ContentRange(Position)
Sets the from and upto positions to clones fo the specified position.
Declaration
public ContentRange(Position location)
Parameters
| Type | Name | Description |
|---|---|---|
| Position | location |
ContentRange(Position, Position)
Clone the specified from and upto positions.
Declaration
public ContentRange(Position from, Position upto)
Parameters
| Type | Name | Description |
|---|---|---|
| Position | from | |
| Position | upto |
Properties
First
The first of the from and upto positions.
Declaration
public virtual Position First { get; }
Property Value
| Type | Description |
|---|---|
| Position |
From
The from location
Declaration
public virtual Position From { get; set; }
Property Value
| Type | Description |
|---|---|
| Position |
IsEmpty
True if from and upto are valid and are the same nodes.
Declaration
public virtual bool IsEmpty { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
IsReversed
True if the upto position appears before the from position and the range is valid.
Declaration
public virtual bool IsReversed { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
IsValid
True if from and upto are valid and have the same root node.
Declaration
public virtual bool IsValid { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Last
The last of the from and upto positions
Declaration
public virtual Position Last { get; }
Property Value
| Type | Description |
|---|---|
| Position |
Upto
The upto location.
Declaration
public virtual Position Upto { get; set; }
Property Value
| Type | Description |
|---|---|
| Position |
Methods
Clone()
Create a clone of the object. The position objects are cloned, but the fields they reference are not (obviously).
Declaration
public virtual object Clone()
Returns
| Type | Description |
|---|---|
| System.Object |
Contains(Position)
true if the position is inside the range
Declaration
public virtual bool Contains(Position position)
Parameters
| Type | Name | Description |
|---|---|---|
| Position | position |
Returns
| Type | Description |
|---|---|
| System.Boolean |
GetIntersection(ContentRange)
Returns the normalized range that represents the intersection between
this range and the other, or null if they don't overlap.
Declaration
public virtual ContentRange GetIntersection(ContentRange other)
Parameters
| Type | Name | Description |
|---|---|---|
| ContentRange | other |
Returns
| Type | Description |
|---|---|
| ContentRange |
Normalize()
swaps from and upto if the range is reversed
Declaration
public virtual void Normalize()
Overlaps(ContentRange)
true if there is an overlap between this and the other range
Declaration
public virtual bool Overlaps(ContentRange other)
Parameters
| Type | Name | Description |
|---|---|---|
| ContentRange | other |
Returns
| Type | Description |
|---|---|
| System.Boolean |
ReduceRanges(List<ContentRange>, ContentRange.ReductionAllowedTest)
Helper function to reduce a set of same-parent ranges to the smallest set of same-parent ranges necessary to span the content from the first to the last range.
Declaration
public static List<ContentRange> ReduceRanges(List<ContentRange> rangesToReduce, ContentRange.ReductionAllowedTest additionalCondition)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.List<ContentRange> | rangesToReduce | Set of same-parent ranges to be processed |
| ContentRange.ReductionAllowedTest | additionalCondition | Additional condition that will be evaluated to determine if
the range can be reduced. Can be |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.List<ContentRange> | The smallest set of same-parent ranges necessary to span all content in the input ranges (and anything between them) |
Remarks
This method is used as a helper in the implementation of IFrameworkDocument.GetMarkupDataRanges in the EditorApi.
The input range should be sorted so that all ranges appear in the correct order. The output ranges will also be sorted in this order.
NOTE: The input ranges may get modified in the process.
Reverse()
swaps from and upto
Declaration
public virtual void Reverse()
SetFromSelection(IContentSelection)
Clone the from and upto locations from the selection.
Declaration
public virtual void SetFromSelection(IContentSelection selection)
Parameters
| Type | Name | Description |
|---|---|---|
| IContentSelection | selection |