Copy() public method

public Copy ( LinkedList output ) : void
output LinkedList
return void
        public LinkedList <EditableRun> CopySelectedTextRuns(VisualSelectionRange selectionRange)
        {
            LinkedList <EditableRun> output = new LinkedList <EditableRun>();

            currentLine.Copy(selectionRange, output);
            return(output);
        }
 public void CopySelectedTextRuns(VisualSelectionRange selectionRange, List <EditableRun> output)
 {
     currentLine.Copy(selectionRange, output);
 }
Example #3
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);
                }
            }
        }