Page 1 of 1

InsertRVFFromStream loads the content underlined

Posted: Thu Apr 09, 2015 8:46 pm
by pruettm
I have a program that allows a user to type in some content and save the content into the database. I then load that content with some other data into a separate RichView and display it back to the user. The data is loading underlined with inserting it into a separate RichView despite the original content not being underlined.

Is there a way to prevent this behavior?

Thank you.

Posted: Fri Apr 10, 2015 6:37 am
by Sergey Tkachenko
O assu

Possible reasons:
1) RVF is stored without styles.
Solution: Make sure that rvfoSaveTextStyles and rvfoSaveParaStyles are included in RVFOptions of the source editor.

2) RVF is stored with styles, but they are not loaded.
Solution: Make sure that RVFTextStylesReadMode=RVFParaStylesReadMode=rvf_sInsertMerge for the target editor.

3) RVF is loaded correctly, but later some other operation changes styles in the target editor's RVStyle.
Solution: The fist thing to check: make sure that each TRichViewEdit is linked with it's own TRVStyle (no TRVStyles are shared between different editors)

4) StyleTemplates are applied to the loaded content, and the target editor's styletemplate defines underlined text. It may happen if UserStyleTemplates=True for the target editor.

Posted: Fri Apr 10, 2015 9:02 pm
by pruettm
Sergey Tkachenko wrote:1) RVF is stored without styles.
Solution: Make sure that rvfoSaveTextStyles and rvfoSaveParaStyles are included in RVFOptions of the source editor.
They are.
Sergey Tkachenko wrote:2) RVF is stored with styles, but they are not loaded.
Solution: Make sure that RVFTextStylesReadMode=RVFParaStylesReadMode=rvf_sInsertMerge for the target editor.
Both are set to rvf_sInsertMerge, and I tried setting the StyleTemplateInsertMode of the target SRichViewEdit to rvstimUseSourceFormatting. I am still seeing the erroneous result.
Sergey Tkachenko wrote:3) RVF is loaded correctly, but later some other operation changes styles in the target editor's RVStyle.
Solution: The fist thing to check: make sure that each TRichViewEdit is linked with it's own TRVStyle (no TRVStyles are shared between different editors)
This is already being done.
Sergey Tkachenko wrote:4) StyleTemplates are applied to the loaded content, and the target editor's styletemplate defines underlined text. It may happen if UserStyleTemplates=True for the target editor.
UserStyleTemplates is set to false.

I have confirmed that the RVF content is formatted correctly from the stream, but once the content is completely entered, the content that was inserted from the stream is not in the format I expected.

Posted: Sun Apr 12, 2015 6:15 pm
by Sergey Tkachenko
I run out of ideas. Please create a simple demo reproducing the problem and send to richviewgmailcom

Posted: Mon Apr 13, 2015 3:43 pm
by pruettm
I have sent you an example.

Thank you.

Posted: Fri Apr 17, 2015 1:31 pm
by pruettm
Just a quick update, I did try and load the streamed content into a hidden RichviewEdit before loading that content into the primary target SRichviewEdit, but the results were still the same.

Posted: Fri Apr 17, 2015 2:03 pm
by pruettm
Sorry for the triple post, but I think I have some more information.

Just before inserting the questionable RVF content from stream. I am doing another insert of different content from stream. The difference is that this content is being inserted into a table via the TRVtableItemInfo.InsertRVFFromStream.

Prior to that insert, I tried saving the content into hidden richview form for formatting purposes. That block of code looks like this:

the dummy values are unassigned, and the table object is a 3 row, 1 col table.

veLoadSave.Clear();
rveLoadSave.Format();
FNoteMemoryStream.Position := 0;
rveLoadSave.LoadRVFFromStream(FNoteMemoryStream);
ms := TMemoryStream.Create();
try
ms.Clear();
rveLoadSave.SaveRVFToStream(ms, False);
ms.Position := 0;
table.Cells[2, 0].InsertRVFFromStream(ms, 0, Dummy1, Dummy2, Dummy3, False, nil);
FNoteMemoryStream.Clear();
table.MergeCells(1, 0, 1, 2, True);
finally
ms.Free();
end;

Posted: Fri Apr 17, 2015 2:04 pm
by pruettm
If I comment that code out, the insert that occurs after that appears normal.

Posted: Mon Apr 20, 2015 7:59 pm
by Sergey Tkachenko
Sorry for the delay.

1) In your project, RVStyle1 was assigned not only with RichViewEdit1.Style, but also with all SRV.ExternalRVStyle* properties.
Do not assign the same RVStyle to several editors (unless you restrict styles to some predefined set), and do not assign the same RVStyle to different editors in SRV.
When I cleared SRV.ExternalRVStyle* properties, a text was formatted as expected.

2) Cell.InsertRVFromStream does not support loading text and paragraph styles.
Workaround:
- create hidden trichview, link it to the same RVStyle as the editor containing the table
- load RVF in this hidden trichview
- save RVF from trichview, excluding rvfoSaveTextStyles and rvfoSaveParaStyles from RVFOptions
- load this RVF in cell.
You can find an example in Demos\RVDemos\Assorted\Fields\MailMerge2.*