Unplanned
Last Updated: 30 Mar 2016 12:57 by ADMIN
ADMIN
Dimitar
Created on: 20 Nov 2015 14:55
Category: RichTextEditor
Type: Bug Report
0
FIX. RadRichTextEditor - the text is indented when it is pasted from a docm document.
Workaround:
void radRichTextEditor1_CommandExecuting(object sender, CommandExecutingEventArgs e)
{
    if (e.Command is PasteCommand)
    {
        e.Cancel = true;
        PasteNewText();
    }
}

public void PasteNewText()
{
    DocumentFragment clipboardDocument = null;
    string clipboardText = null;
    bool clipboardContainsData = false;

    if (ClipboardEx.ContainsDocument(null))
    {
        clipboardDocument = ClipboardEx.GetDocument();
        clipboardContainsData = true;
    }
    else if (ClipboardEx.ContainsText(null))
    {
        clipboardText = ClipboardEx.GetText(null);
        clipboardContainsData = true;
    }

    if (!clipboardContainsData)
    {
        return;
    }

    if (clipboardDocument != null)
    {
        RadDocument doc = new RadDocument();
        RadDocumentEditor editor = new RadDocumentEditor(doc);
        editor.InsertFragment(clipboardDocument);
         
        TxtFormatProvider provider = new TxtFormatProvider();
        string plainText = provider.Export(doc);

        this.radRichTextEditor1.RichTextBoxElement.ActiveDocumentEditor.Insert(plainText);
    }
    else if (!string.IsNullOrEmpty(clipboardText))
    {
        this.radRichTextEditor1.RichTextBoxElement.ActiveDocumentEditor.Insert(clipboardText);
    }
}
0 comments