If you copy a hyperlink from Outlook (or any Office app I expect) and paste it into a RichTextEditor box then try to modify the text... the control will crash.
To duplicate this bug:
1. Create a hyperlink in Outlook to \\server\folder1\folder2\folder3\somefile.txt
2. Copy the hyperlink and paste it into a RichTextEditor box.
3. Place your caret after the \ before somefile.txt
4. Press backspace until the control crashes (takes less than 20)
The control will start to act very weird with overlapping text before it finally crashes with the following error:
-----------------
Index was out of range. Must be non-negative and less than the seize of the collection.
at System.ThrowHelper.ThrowArgumentOutOfRangeException()
at System.Collections.Generic.List`1.get_Item(Int32 index)
at Telerik.WinControls.RichTextEditor.UI.TextBlock.DrawRunGDI(Run run, RunLayoutInfo runInfo, Single fontSizeScale, PointF location, NativeTextRenderer renderer)
at Telerik.WinControls.RichTextEditor.UI.TextBlock.DrawGdi(Single angle, Graphics nativeGraphics, Single fontSizeScale)
at Telerik.WinControls.RichTextEditor.UI.TextBlock.PaintElement(IGraphics graphics, Single angle, SizeF scale)
...
-----------------
I've tried setting AutoInsertHyperlinks to false but it still crashes. Any ideas?
Thanks!
To duplicate this bug:
1. Create a hyperlink in Outlook to \\server\folder1\folder2\folder3\somefile.txt
2. Copy the hyperlink and paste it into a RichTextEditor box.
3. Place your caret after the \ before somefile.txt
4. Press backspace until the control crashes (takes less than 20)
The control will start to act very weird with overlapping text before it finally crashes with the following error:
-----------------
Index was out of range. Must be non-negative and less than the seize of the collection.
at System.ThrowHelper.ThrowArgumentOutOfRangeException()
at System.Collections.Generic.List`1.get_Item(Int32 index)
at Telerik.WinControls.RichTextEditor.UI.TextBlock.DrawRunGDI(Run run, RunLayoutInfo runInfo, Single fontSizeScale, PointF location, NativeTextRenderer renderer)
at Telerik.WinControls.RichTextEditor.UI.TextBlock.DrawGdi(Single angle, Graphics nativeGraphics, Single fontSizeScale)
at Telerik.WinControls.RichTextEditor.UI.TextBlock.PaintElement(IGraphics graphics, Single angle, SizeF scale)
...
-----------------
I've tried setting AutoInsertHyperlinks to false but it still crashes. Any ideas?
Thanks!
6 Answers, 1 is accepted
0
Hello Michael,
We are aware of this issue and it is already logged it in our feedback portal. You can add your vote and subscribe for status updates here: http://feedback.telerik.com/Project/154/Feedback/Details/147332-fix-richtexteditor-pasting-link-copied-from-outlook-causes-exception.
It appears that Outlook produces different RTF contents when using its different Copy commands. In some cases the RTF string produced by Outlook contains empty spans which is not a valid element in our implementation. To handle that case, you can subscribe to the CommandExecuting event to capture the Paste command before it was executed, strip the empty spans, and then modify the clipboard contents with a valid RTF string. The following code snippet demonstrates how to implement this:
I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us.
Regards,
Stefan
Telerik
We are aware of this issue and it is already logged it in our feedback portal. You can add your vote and subscribe for status updates here: http://feedback.telerik.com/Project/154/Feedback/Details/147332-fix-richtexteditor-pasting-link-copied-from-outlook-causes-exception.
It appears that Outlook produces different RTF contents when using its different Copy commands. In some cases the RTF string produced by Outlook contains empty spans which is not a valid element in our implementation. To handle that case, you can subscribe to the CommandExecuting event to capture the Paste command before it was executed, strip the empty spans, and then modify the clipboard contents with a valid RTF string. The following code snippet demonstrates how to implement this:
Private
Sub
radRichTextEditor1_CommandExecuting(sender
As
Object
, e
As
CommandExecutingEventArgs)
Handles
radRichTextEditor1.CommandExecuting
If
Not
(
TypeOf
e.Command
Is
PasteCommand)
Then
Return
End
If
Dim
docString
As
String
=
Nothing
Dim
docObj
As
Object
= Clipboard.GetData(
"Rich Text Format"
)
If
docObj IsNot
Nothing
AndAlso
docObj.[
GetType
]() =
GetType
(
String
)
Then
docString =
DirectCast
(docObj,
String
)
End
If
Dim
document
As
RadDocument =
Nothing
Using stream
As
New
MemoryStream()
Dim
writer
As
New
StreamWriter(stream)
writer.Write(docString)
writer.Flush()
stream.Seek(0, SeekOrigin.Begin)
Try
document =
New
RtfFormatProvider().Import(stream)
Catch
ex
As
Exception
System.Diagnostics.Debug.WriteLine(
"Error reading document from clipboard:"
& vbLf + ex.ToString())
End
Try
End
Using
If
document IsNot
Nothing
Then
Dim
emptySpans
As
New
List(Of Span)()
For
Each
span
As
var
In
document.EnumerateChildrenOfType(Of Span)()
If
[
String
].IsNullOrEmpty(span.Text)
Then
emptySpans.Add(span)
End
If
Next
If
emptySpans.Count = 0
Then
Return
End
If
For
Each
span
As
var
In
emptySpans
span.Parent.Children.Remove(span)
Next
Dim
modifiedRtf
As
String
=
New
RtfFormatProvider().Export(document)
Clipboard.SetData(
"Rich Text Format"
, modifiedRtf)
End
If
End
Sub
I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us.
Regards,
Stefan
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Michael
Top achievements
Rank 1
answered on 12 Jan 2015, 04:48 PM
Thank you for the speedy response. Might we expect a fixed integrated into the actual control for the next release? Thanks!
0
Hello Michael,
We will do our best to address it in the Q1 2015 release, however, our plans are packed and I do not want to engage with promises. Still, we will try to look into it.
I hope that you find this information useful.
Regards,
Stefan
Telerik
We will do our best to address it in the Q1 2015 release, however, our plans are packed and I do not want to engage with promises. Still, we will try to look into it.
I hope that you find this information useful.
Regards,
Stefan
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Michael
Top achievements
Rank 1
answered on 25 Feb 2015, 07:45 PM
Stefan, this is still broken in the 2015 Q1 version of the control.
0
Hello Michael,
I confirm that the issue is still present. It turns out that your case is a bit different from the one described on the feedback portal and for this reason it was left unresolved. I have reopened the feedback item and updated its description. The issue will be resolved in the service pack which is expected in the beginning of April. For the time being, you can workaround the issue by subscribing to the CommandExecuted event and handling it the following way:
If there is anything else I can help you with, just let me know.
Regards,
Ivan Todorov
Telerik
I confirm that the issue is still present. It turns out that your case is a bit different from the one described on the feedback portal and for this reason it was left unresolved. I have reopened the feedback item and updated its description. The issue will be resolved in the service pack which is expected in the beginning of April. For the time being, you can workaround the issue by subscribing to the CommandExecuted event and handling it the following way:
void
radRichTextEditor1_CommandExecuted(
object
sender, CommandExecutedEventArgs e)
{
if
(e.Command
is
DeleteCommand)
{
this
.radRichTextEditor1.RichTextBoxElement.InvalidateMeasure(
true
);
this
.radRichTextEditor1.RichTextBoxElement.UpdateLayout();
}
}
If there is anything else I can help you with, just let me know.
Regards,
Ivan Todorov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Michael
Top achievements
Rank 1
answered on 27 Feb 2015, 04:05 PM
Thank you Ivan. Your work around seems to be working.