Hello.
I am using custom field extends on CodeBasedField. This field fetch some data form database or prompt window on request. Sometimes its simple string, some time its rft string. I face with problem on handling rft strings. Here is how its looks like in "Code" mode:
Here is how I handle result value of field:
protected override DocumentFragment GetResultFragment()
{
var text = "";
/*
text = fetch string handle here
*/
if (!text.StartsWith(@"{\rtf"))
{
var document = new RtfFormatProvider().Import(text);
return new DocumentFragment(document);
}
return CreateFragmentFromText(text);
}
And if 'text' is rtf the "Result" mode is this:
You can see that extra line breaking there.
I am sure that my rtf have no extra line breaking or paragraphs. As well as "SpacingAfter" parameter for paragraph is 0.
The reason of it is how code handle Paragraphs.
Here is some code from Telerik lib:
How fragment created from document:
How Fragment inserted in RadDocument:
The code inserts "line break" after Paragraph if its single in fragment and if "IsLastParagraphClosed" is true. I cant change value of "IsLastParagraphClosed" because its setter is internal.
Same problem if my rtf has more then one Paragraph. In that case it use another flow in InsertFragmentInternal method but the result is same - extra line breaking after Field.
I found workaround to skip this line breaking, create fragment not from RadDocument but from Selection:
protected override DocumentFragment GetResultFragment()
{
var text = "";
/*
text = fetch string handle here
*/
if (!text.StartsWith(@"{\rtf"))
{
var document = new RtfFormatProvider().Import(text);
document.Selection.SelectAll();
return new DocumentFragment(document.Selection);
}
return CreateFragmentFromText(text);
}
But in this case its not reproduce full text formatting (e.g. TextAlingment) for my rtf.
Please help me to find proper workaround or fix this issue.