public override IEnumerable <RenderElement> GetRenderElementReverseIter()
        {
            if (_lineCollection != null)
            {
                if ((_layerFlags & FLOWLAYER_HAS_MULTILINE) != 0)
                {
                    List <EditableTextLine> lines = (List <EditableTextLine>)_lineCollection;
                    int j = lines.Count;
                    for (int i = lines.Count; i > -1; --i)
                    {
                        EditableTextLine             ln     = lines[i];
                        LinkedListNode <EditableRun> veNode = ln.Last;
                        while (veNode != null)
                        {
                            yield return(veNode.Value);

                            veNode = veNode.Previous;
                        }
                    }
                }
                else
                {
                    EditableTextLine             ln     = (EditableTextLine)_lineCollection;
                    LinkedListNode <EditableRun> veNode = ln.Last;
                    while (veNode != null)
                    {
                        yield return(veNode.Value);

                        veNode = veNode.Previous;
                    }
                }
            }
        }
 void AddLineBreakBefore(EditableRun beforeTextRun)
 {
     if (beforeTextRun == null)
     {
         this.EndWithLineBreak = true;
         EditableFlowLayer.InsertNewLine(_currentLineNumber + 1);
     }
     else
     {
         List <EditableRun> tempTextRuns = new List <EditableRun>();
         if (beforeTextRun != null)
         {
             foreach (EditableRun t in GetVisualElementForward(beforeTextRun))
             {
                 tempTextRuns.Add(t);
             }
         }
         this.EndWithLineBreak = true;
         EditableTextLine newTextline = EditableFlowLayer.InsertNewLine(_currentLineNumber + 1);
         //
         this.LocalSuspendLineReArrange();
         newTextline.LocalSuspendLineReArrange();
         int j = tempTextRuns.Count;
         for (int i = 0; i < j; ++i)
         {
             EditableRun t = tempTextRuns[i];
             this.Remove(t);
             newTextline.AddLast(t);
         }
         this.LocalResumeLineReArrange();
         newTextline.LocalResumeLineReArrange();
     }
 }
        void AddLineBreakAfter(EditableRun afterTextRun)
        {
            if (afterTextRun == null)
            {
                //add line break on the last end

                this.EndWithLineBreak = true;
                EditableTextLine newline = EditableFlowLayer.InsertNewLine(_currentLineNumber + 1);
                //
                if (EditableFlowLayer.LineCount - 1 != newline.LineNumber)
                {
                    newline.EndWithLineBreak = true;
                }
            }
            else if (afterTextRun.NextTextRun == null)
            {
                this.EndWithLineBreak = true;
                EditableTextLine newline = EditableFlowLayer.InsertNewLine(_currentLineNumber + 1);
                //
                if (EditableFlowLayer.LineCount - 1 != newline.LineNumber)
                {
                    newline.EndWithLineBreak = true;
                }
            }
            else
            {
                List <EditableRun> tempTextRuns = new List <EditableRun>(this.RunCount);
                if (afterTextRun != null)
                {
                    foreach (EditableRun t in GetVisualElementForward(afterTextRun.NextTextRun))
                    {
                        tempTextRuns.Add(t);
                    }
                }

                this.EndWithLineBreak = true;
                this.LocalSuspendLineReArrange();
                EditableTextLine newTextline = EditableFlowLayer.InsertNewLine(_currentLineNumber + 1);
                //
                int j = tempTextRuns.Count;
                newTextline.LocalSuspendLineReArrange(); int cx = 0;
                for (int i = 0; i < j; ++i)
                {
                    EditableRun t = tempTextRuns[i];
                    this.Remove(t);
                    newTextline.AddLast(t);
                    RenderElement.DirectSetLocation(t, cx, 0);
                    cx += t.Width;
                }

                newTextline.LocalResumeLineReArrange();
                this.LocalResumeLineReArrange();
            }
        }
        public void AddBefore(EditableRun beforeVisualElement, EditableRun visualElement)
        {
            EditableTextLine targetLine = beforeVisualElement.OwnerEditableLine;

            if (targetLine != null)
            {
                targetLine.AddBefore(beforeVisualElement, visualElement);
            }
            else
            {
                throw new NotSupportedException();
            }
        }
        public void AddAfter(EditableRun afterVisualElement, EditableRun visualElement)
        {
            EditableTextLine targetLine = afterVisualElement.OwnerEditableLine;

            if (targetLine != null)
            {
                targetLine.AddAfter(afterVisualElement, visualElement);
            }
            else
            {
                throw new NotSupportedException();
            }
        }
Esempio n. 6
0
        public TextLineReader(EditableTextFlowLayer flowlayer)
        {
#if DEBUG
            this.dbug_MyId = dbugTotalId;
            dbugTotalId++;
#endif

            _textFlowLayer    = flowlayer;
            flowlayer.Reflow += new EventHandler(flowlayer_Reflow);
            _currentLine      = flowlayer.GetTextLine(0);
            if (_currentLine.FirstRun != null)
            {
                _currentTextRun = _currentLine.FirstRun;
            }
        }
Esempio n. 7
0
        public void MoveToLine(int lineNumber)
        {
            _currentLine  = _textFlowLayer.GetTextLine(lineNumber);
            _currentLineY = _currentLine.Top;

            //if current line is a blank line
            //not first run => currentTextRun= null
            _currentTextRun = (EditableRun)_currentLine.FirstRun;

            _rCharOffset  = 0;
            _rPixelOffset = 0;

            caret_char_index = 0;
            _caretXPos       = 0;
        }
Esempio n. 8
0
 public VisualPointInfo FindTextRunOnPosition(int x, int y)
 {
     if (y < 0)
     {
         return(null);
     }
     else
     {
         int j = _textLineWriter.LineCount;
         if (j > 0)
         {
             EditableTextLine textLine = _textLineWriter.GetTextLineAtPos(y);
             if (textLine != null)
             {
                 return(textLine.GetTextPointInfoFromCaretPoint(x));
             }
         }
         return(null);
     }
 }
 public override void Clear()
 {
     if ((_layerFlags & FLOWLAYER_HAS_MULTILINE) != 0)
     {
         List <EditableTextLine> lines = (List <EditableTextLine>)_lineCollection;
         for (int i = lines.Count - 1; i > -1; --i)
         {
             EditableTextLine line = lines[i];
             line.EditableFlowLayer = null;
             line.Clear();
         }
         lines.Clear();
         _lineCollection        = new EditableTextLine(this);
         FlowLayerHasMultiLines = false;
     }
     else
     {
         ((EditableTextLine)_lineCollection).Clear();
     }
 }
        internal void Remove(int lineId)
        {
#if DEBUG
            if (lineId < 0)
            {
                throw new NotSupportedException();
            }
#endif
            if ((_layerFlags & FLOWLAYER_HAS_MULTILINE) == 0)
            {
                return;
            }
            List <EditableTextLine> lines = (List <EditableTextLine>)_lineCollection;
            if (lines.Count < 2)
            {
                return;
            }

            EditableTextLine removedLine = lines[lineId];
            int cy = removedLine.Top;

            //
            lines.RemoveAt(lineId);
            removedLine.EditableFlowLayer = null;


            int j = lines.Count;
            for (int i = lineId; i < j; ++i)
            {
                EditableTextLine line = lines[i];
                line.SetTop(cy);
                line.SetLineNumber(i);
                cy += line.ActualLineHeight;
            }

            if (lines.Count == 1)
            {
                _lineCollection        = lines[0];
                FlowLayerHasMultiLines = false;
            }
        }
Esempio n. 11
0
        internal EditableTextLine SplitToNewLine(EditableRun startVisualElement)
        {
            LinkedListNode <EditableRun> curNode        = GetLineLinkedNode(startVisualElement);
            EditableTextLine             newSplitedLine = EditableFlowLayer.InsertNewLine(_currentLineNumber + 1);

            newSplitedLine.LocalSuspendLineReArrange();
            while (curNode != null)
            {
                LinkedListNode <EditableRun> tobeRemovedNode = curNode;
                curNode = curNode.Next;
                if (tobeRemovedNode.List != null)
                {
                    EditableRun tmpv = tobeRemovedNode.Value;
                    _runs.Remove(tobeRemovedNode);
                    newSplitedLine.AddLast(tmpv);
                }
                else
                {
                }
            }
            newSplitedLine.LocalResumeLineReArrange();
            return(newSplitedLine);
        }
Esempio n. 12
0
        void JoinWithNextLine()
        {
            if (!IsLastLine)
            {
                EditableTextLine lowerLine = EditableFlowLayer.GetTextLine(_currentLineNumber + 1);
                this.LocalSuspendLineReArrange();
                int         cx          = 0;
                EditableRun lastTextRun = (EditableRun)this.LastRun;
                if (lastTextRun != null)
                {
                    cx = lastTextRun.Right;
                }

                foreach (EditableRun r in lowerLine._runs)
                {
                    this.AddLast(r);
                    EditableRun.DirectSetLocation(r, cx, 0);
                    cx += r.Width;
                }
                this.LocalResumeLineReArrange();
                this.EndWithLineBreak = lowerLine.EndWithLineBreak;
                EditableFlowLayer.Remove(lowerLine._currentLineNumber);
            }
        }
Esempio n. 13
0
 public void JoinWithNextLine()
 {
     EditableTextLine.InnerDoJoinWithNextLine(this.CurrentLine);
     EnsureCurrentTextRun();
 }
Esempio n. 14
0
 //
 internal void SetInternalLinkedNode(LinkedListNode <EditableRun> linkedNode, EditableTextLine ownerTextLine)
 {
     _ownerTextLine = ownerTextLine;
     _editableRunInternalLinkedNode = linkedNode;
     EditableRun.SetParentLink(this, ownerTextLine);
 }
Esempio n. 15
0
 public static void InnerCopyLineContent(EditableTextLine line, StringBuilder stBuilder)
 {
     line.CopyLineContent(stBuilder);
 }
Esempio n. 16
0
        internal void Remove(VisualSelectionRange selectionRange)
        {
            EditableVisualPointInfo startPoint = selectionRange.StartPoint;
            EditableVisualPointInfo endPoint   = selectionRange.EndPoint;

            if (startPoint.TextRun != null)
            {
                if (startPoint.TextRun == endPoint.TextRun)
                {
                    EditableRun removedRun = (EditableRun)startPoint.TextRun;
                    EditableRun.InnerRemove(removedRun,
                                            startPoint.RunLocalSelectedIndex,
                                            endPoint.LineCharIndex - startPoint.LineCharIndex, false);
                    if (removedRun.CharacterCount == 0)
                    {
                        if (startPoint.LineId == _currentLineNumber)
                        {
                            this.Remove(removedRun);
                        }
                        else
                        {
                            EditableTextLine line = EditableFlowLayer.GetTextLine(startPoint.LineId);
                            line.Remove(removedRun);
                        }
                    }
                }
                else
                {
                    EditableVisualPointInfo newStartPoint = null;
                    EditableVisualPointInfo newStopPoint  = null;
                    EditableTextLine        startLine     = null;
                    EditableTextLine        stopLine      = null;
                    if (startPoint.LineId == _currentLineNumber)
                    {
                        startLine = this;
                    }
                    else
                    {
                        startLine = EditableFlowLayer.GetTextLine(startPoint.LineId);
                    }
                    newStartPoint = startLine.Split(startPoint);
                    if (endPoint.LineId == _currentLineNumber)
                    {
                        stopLine = this;
                    }
                    else
                    {
                        stopLine = EditableFlowLayer.GetTextLine(endPoint.LineId);
                    }

                    newStopPoint = stopLine.Split(endPoint);
                    if (startLine == stopLine)
                    {
                        if (newStartPoint.TextRun != null)
                        {
                            LinkedList <EditableRun> tobeRemoveRuns = new LinkedList <EditableRun>();
                            if (newStartPoint.LineCharIndex == 0)
                            {
                                foreach (EditableRun t in EditableFlowLayer.TextRunForward(
                                             (EditableRun)newStartPoint.TextRun,
                                             (EditableRun)newStopPoint.TextRun))
                                {
                                    tobeRemoveRuns.AddLast(t);
                                }
                            }
                            else
                            {
                                foreach (EditableRun t in EditableFlowLayer.TextRunForward(
                                             newStartPoint.TextRun.NextTextRun,
                                             (EditableRun)newStopPoint.TextRun))
                                {
                                    tobeRemoveRuns.AddLast(t);
                                }
                            }
                            startLine.LocalSuspendLineReArrange();
                            foreach (EditableRun t in tobeRemoveRuns)
                            {
                                startLine.Remove(t);
                            }
                            startLine.LocalResumeLineReArrange();
                        }
                        else
                        {
                            //this may be the blank line
                            startLine.Clear();
#if DEBUG
                            //TODO: review here again
                            //System.Diagnostics.Debug.WriteLine("EditableTextLine_adv1");
#endif
                        }
                    }
                    else
                    {
                        int startLineId = newStartPoint.LineId;
                        int stopLineId  = newStopPoint.LineId;
                        if (newStopPoint.LineCharIndex > 0)
                        {
                            stopLine.RemoveLeft((EditableRun)newStopPoint.TextRun);
                        }
                        for (int i = stopLineId - 1; i > startLineId; i--)
                        {
                            EditableTextLine line = EditableFlowLayer.GetTextLine(i);
                            line.Clear();
                            line.JoinWithNextLine();
                        }
                        if (newStartPoint.LineCharIndex == 0)
                        {
                            startLine.RemoveRight((EditableRun)newStartPoint.TextRun);
                        }
                        else
                        {
                            EditableRun nextRun = ((EditableRun)newStartPoint.TextRun).NextTextRun;
                            if (nextRun != null && !nextRun.IsLineBreak)
                            {
                                startLine.RemoveRight(nextRun);
                            }
                        }
                        startLine.JoinWithNextLine();
                    }
                }
            }
            else
            {
                VisualPointInfo  newStartPoint = null;
                VisualPointInfo  newStopPoint  = null;
                EditableTextLine startLine     = null;
                EditableTextLine stopLine      = null;
                if (startPoint.LineId == _currentLineNumber)
                {
                    startLine = this;
                }
                else
                {
                    startLine = EditableFlowLayer.GetTextLine(startPoint.LineId);
                }
                newStartPoint = startLine.Split(startPoint);
                if (endPoint.LineId == _currentLineNumber)
                {
                    stopLine = this;
                }
                else
                {
                    stopLine = EditableFlowLayer.GetTextLine(endPoint.LineId);
                }
                newStopPoint = stopLine.Split(endPoint);
                if (startLine == stopLine)
                {
                    if (newStartPoint.TextRun != null)
                    {
                        LinkedList <EditableRun> tobeRemoveRuns = new LinkedList <EditableRun>();
                        if (newStartPoint.LineCharIndex == -1)
                        {
                            foreach (EditableRun t in EditableFlowLayer.TextRunForward(
                                         (EditableRun)newStartPoint.TextRun,
                                         (EditableRun)newStopPoint.TextRun))
                            {
                                tobeRemoveRuns.AddLast(t);
                            }
                        }
                        else
                        {
                            foreach (EditableRun t in EditableFlowLayer.TextRunForward(
                                         newStartPoint.TextRun.NextTextRun,
                                         (EditableRun)newStopPoint.TextRun))
                            {
                                tobeRemoveRuns.AddLast(t);
                            }
                        }
                        foreach (EditableRun t in tobeRemoveRuns)
                        {
                            startLine.Remove(t);
                        }
                    }
                    else
                    {
                        throw new NotSupportedException();
                    }
                }
                else
                {
                    int startLineId = newStartPoint.LineId;
                    int stopLineId  = newStopPoint.LineId;
                    if (newStopPoint.LineCharIndex > -1)
                    {
                        stopLine.RemoveLeft((EditableRun)newStopPoint.TextRun);
                    }
                    for (int i = stopLineId - 1; i > startLineId; i--)
                    {
                        EditableTextLine line = EditableFlowLayer.GetTextLine(i);
                        line.Clear();
                        line.JoinWithNextLine();
                    }
                    if (newStartPoint.LineCharIndex == -1)
                    {
                        //TODO: review here again
                        //at this point newStartPoint.TextRun should always null
                        if (newStartPoint.TextRun != null)
                        {
                            startLine.RemoveRight((EditableRun)newStartPoint.TextRun);
                        }
                    }
                    else
                    {
                        //at this point newStartPoint.TextRun should always null
                        //TODO newStartPoint.TextRun == null???
                        if (newStartPoint.TextRun != null)
                        {
                            EditableRun nextRun = newStartPoint.TextRun.NextTextRun;
                            if (nextRun != null && !nextRun.IsLineBreak)
                            {
                                startLine.RemoveRight(nextRun);
                            }
                        }
                    }
                    startLine.JoinWithNextLine();
                }
            }
        }
Esempio n. 17
0
        internal EditableVisualPointInfo[] Split(VisualSelectionRange selectionRange)
        {
            selectionRange.SwapIfUnOrder();
            EditableVisualPointInfo startPoint = selectionRange.StartPoint;
            EditableVisualPointInfo endPoint   = selectionRange.EndPoint;

            if (startPoint.TextRun == endPoint.TextRun)
            {
                EditableRun             toBeCutTextRun         = startPoint.TextRun;
                EditableRun             preCutTextRun          = (EditableRun)toBeCutTextRun.LeftCopy(startPoint.RunLocalSelectedIndex);
                EditableRun             middleCutTextRun       = (EditableRun)toBeCutTextRun.Copy(startPoint.RunLocalSelectedIndex, endPoint.LineCharIndex - startPoint.LineCharIndex);
                EditableRun             postCutTextRun         = (EditableRun)toBeCutTextRun.Copy(endPoint.RunLocalSelectedIndex);
                EditableVisualPointInfo newStartRangePointInfo = null;
                EditableVisualPointInfo newEndRangePointInfo   = null;
                EditableTextLine        line = this;
                if (startPoint.LineId != _currentLineNumber)
                {
                    line = EditableFlowLayer.GetTextLine(startPoint.LineId);
                }
                line.LocalSuspendLineReArrange();
                if (preCutTextRun != null)
                {
                    line.AddBefore(toBeCutTextRun, preCutTextRun);
                    newStartRangePointInfo = CreateTextPointInfo(
                        startPoint.LineId, startPoint.LineCharIndex, startPoint.X,
                        preCutTextRun, startPoint.TextRunCharOffset, startPoint.TextRunPixelOffset);
                }
                else
                {
                    EditableRun prevTxtRun = GetPrevTextRun((EditableRun)startPoint.TextRun);
                    if (prevTxtRun != null)
                    {
                        newStartRangePointInfo = CreateTextPointInfo(
                            startPoint.LineId, startPoint.LineCharIndex, startPoint.X, prevTxtRun, startPoint.TextRunCharOffset - preCutTextRun.CharacterCount,
                            startPoint.TextRunPixelOffset - prevTxtRun.Width);
                    }
                    else
                    {
                        newStartRangePointInfo = CreateTextPointInfo(
                            startPoint.LineId,
                            startPoint.LineCharIndex,
                            0,
                            null,
                            0, 0);
                    }
                }

                if (postCutTextRun != null)
                {
                    line.AddAfter(toBeCutTextRun, postCutTextRun);
                    newEndRangePointInfo =
                        CreateTextPointInfo(
                            endPoint.LineId,
                            endPoint.LineCharIndex,
                            endPoint.X,
                            middleCutTextRun,
                            startPoint.TextRunCharOffset + middleCutTextRun.CharacterCount,
                            startPoint.TextRunPixelOffset + middleCutTextRun.Width);
                }
                else
                {
                    EditableRun nextTxtRun = GetNextTextRun((EditableRun)endPoint.TextRun);
                    if (nextTxtRun != null)
                    {
                        newEndRangePointInfo = CreateTextPointInfo(
                            endPoint.LineId,
                            endPoint.LineCharIndex,
                            endPoint.X,
                            nextTxtRun,
                            endPoint.TextRunPixelOffset + endPoint.TextRun.CharacterCount,
                            endPoint.TextRunPixelOffset + endPoint.TextRun.Width);
                    }
                    else
                    {
                        newEndRangePointInfo = CreateTextPointInfo(
                            endPoint.LineId,
                            endPoint.LineCharIndex,
                            endPoint.X,
                            middleCutTextRun,
                            endPoint.TextRunCharOffset,
                            endPoint.TextRunPixelOffset);
                    }
                }

                if (middleCutTextRun != null)
                {
                    line.AddAfter(toBeCutTextRun, middleCutTextRun);
                }
                else
                {
                    throw new NotSupportedException();
                }
                line.Remove(toBeCutTextRun);
                line.LocalResumeLineReArrange();
                return(new EditableVisualPointInfo[] { newStartRangePointInfo, newEndRangePointInfo });
            }
            else
            {
                EditableTextLine workingLine = this;
                if (startPoint.LineId != _currentLineNumber)
                {
                    workingLine = EditableFlowLayer.GetTextLine(startPoint.LineId);
                }
                EditableVisualPointInfo newStartPoint = workingLine.Split(startPoint);
                workingLine = this;
                if (endPoint.LineId != _currentLineNumber)
                {
                    workingLine = EditableFlowLayer.GetTextLine(endPoint.LineId);
                }
                EditableVisualPointInfo newEndPoint = workingLine.Split(endPoint);
                return(new EditableVisualPointInfo[] { newStartPoint, newEndPoint });
            }
        }
Esempio n. 18
0
 public static void InnerDoJoinWithNextLine(EditableTextLine line)
 {
     line.JoinWithNextLine();
 }
Esempio n. 19
0
        public void Copy(VisualSelectionRange selectionRange, List <EditableRun> output)
        {
            EditableVisualPointInfo startPoint = selectionRange.StartPoint;
            EditableVisualPointInfo endPoint   = selectionRange.EndPoint;

            if (startPoint.TextRun != null)
            {
                if (startPoint.TextRun == endPoint.TextRun)
                {
                    EditableRun elem =
                        startPoint.TextRun.Copy(
                            startPoint.RunLocalSelectedIndex,
                            endPoint.LineCharIndex - startPoint.LineCharIndex);
                    if (elem != null)
                    {
                        output.Add(elem);
                    }
                }
                else
                {
                    EditableTextLine startLine = null;
                    EditableTextLine stopLine  = null;
                    if (startPoint.LineId == _currentLineNumber)
                    {
                        startLine = this;
                    }
                    else
                    {
                        startLine = EditableFlowLayer.GetTextLine(startPoint.LineId);
                    }
                    if (endPoint.LineId == _currentLineNumber)
                    {
                        stopLine = this;
                    }
                    else
                    {
                        stopLine = EditableFlowLayer.GetTextLine(endPoint.LineId);
                    }
                    if (startLine == stopLine)
                    {
                        EditableRun postCutTextRun = startPoint.TextRun.Copy(startPoint.RunLocalSelectedIndex);
                        if (postCutTextRun != null)
                        {
                            output.Add(postCutTextRun);
                        }
                        if (startPoint.TextRun.NextTextRun != endPoint.TextRun)
                        {
                            foreach (EditableRun t in EditableFlowLayer.TextRunForward(startPoint.TextRun.NextTextRun, endPoint.TextRun.PrevTextRun))
                            {
                                output.Add(t.Clone());
                            }
                        }

                        EditableRun preCutTextRun = endPoint.TextRun.LeftCopy(endPoint.RunLocalSelectedIndex);
                        if (preCutTextRun != null)
                        {
                            output.Add(preCutTextRun);
                        }
                    }
                    else
                    {
                        int startLineId = startPoint.LineId;
                        int stopLineId  = endPoint.LineId;
                        startLine.RightCopy(startPoint, output);
                        for (int i = startLineId + 1; i < stopLineId; i++)
                        {
                            output.Add(new EditableTextRun(this.Root, '\n', this.CurrentTextSpanStyle));
                            EditableTextLine line = EditableFlowLayer.GetTextLine(i);
                            line.Copy(output);
                        }
                        if (endPoint.LineCharIndex > -1)
                        {
                            output.Add(new EditableTextRun(this.Root, '\n', this.CurrentTextSpanStyle));
                            stopLine.LeftCopy(endPoint, output);
                        }
                    }
                }
            }
            else
            {
                EditableTextLine startLine = null;
                EditableTextLine stopLine  = null;
                if (startPoint.LineId == _currentLineNumber)
                {
                    startLine = this;
                }
                else
                {
                    startLine = EditableFlowLayer.GetTextLine(startPoint.LineId);
                }

                if (endPoint.LineId == _currentLineNumber)
                {
                    stopLine = this;
                }
                else
                {
                    stopLine = EditableFlowLayer.GetTextLine(endPoint.LineId);
                }


                if (startLine == stopLine)
                {
                    if (startPoint.LineCharIndex == -1)
                    {
                        foreach (EditableRun t in EditableFlowLayer.TextRunForward(startPoint.TextRun, endPoint.TextRun.PrevTextRun))
                        {
                            output.Add(t.Clone());
                        }
                        EditableRun postCutTextRun = endPoint.TextRun.Copy(endPoint.RunLocalSelectedIndex + 1);
                        if (postCutTextRun != null)
                        {
                            output.Add(postCutTextRun);
                        }
                    }
                    else
                    {
                        EditableRun postCutTextRun = startPoint.TextRun.Copy(startPoint.RunLocalSelectedIndex + 1);
                        if (postCutTextRun != null)
                        {
                            output.Add(postCutTextRun);
                        }

                        foreach (EditableRun t in EditableFlowLayer.TextRunForward(startPoint.TextRun.NextTextRun, endPoint.TextRun.PrevTextRun))
                        {
                            output.Add(t.Clone());
                        }

                        EditableRun preCutTextRun = endPoint.TextRun.LeftCopy(startPoint.RunLocalSelectedIndex);
                        if (preCutTextRun != null)
                        {
                            output.Add(preCutTextRun);
                        }
                    }
                }
                else
                {
                    int startLineId = startPoint.LineId;
                    int stopLineId  = endPoint.LineId;
                    startLine.RightCopy(startPoint, output);
                    for (int i = startLineId + 1; i < stopLineId; i++)
                    {
                        output.Add(new EditableTextRun(this.Root, '\n', this.CurrentTextSpanStyle));
                        EditableTextLine line = EditableFlowLayer.GetTextLine(i);
                        line.Copy(output);
                    }
                    stopLine.LeftCopy(endPoint, output);
                }
            }
        }