InsertRVFFromStream loads the content underlined

General TRichView support forum. Please post your questions here
Post Reply
pruettm
Posts: 23
Joined: Wed Nov 30, 2011 9:08 pm

InsertRVFFromStream loads the content underlined

Post 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.
Sergey Tkachenko
Site Admin
Posts: 17555
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
pruettm
Posts: 23
Joined: Wed Nov 30, 2011 9:08 pm

Post 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.
Sergey Tkachenko
Site Admin
Posts: 17555
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I run out of ideas. Please create a simple demo reproducing the problem and send to richviewgmailcom
pruettm
Posts: 23
Joined: Wed Nov 30, 2011 9:08 pm

Post by pruettm »

I have sent you an example.

Thank you.
pruettm
Posts: 23
Joined: Wed Nov 30, 2011 9:08 pm

Post 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.
pruettm
Posts: 23
Joined: Wed Nov 30, 2011 9:08 pm

Post 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;
pruettm
Posts: 23
Joined: Wed Nov 30, 2011 9:08 pm

Post by pruettm »

If I comment that code out, the insert that occurs after that appears normal.
Sergey Tkachenko
Site Admin
Posts: 17555
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.*
Post Reply