Page 1 of 1

Steaming with Table Cells

Posted: Sat Mar 11, 2006 6:58 pm
by jwkerns
Could I get an example of SaveRTFToStream() from a table cell

Ex
Cells[iRow,0].SaveRTFToStream(....)

Also, is there a demo or some example code makeing use of streaming with the table ?


John

Posted: Sun Mar 12, 2006 12:59 pm
by Michel
There are some code snippets (and discussion) here: www.trichview.com/forums/viewtopic.php?t=236
HTH,
Michel

Not RTF

Posted: Sun Mar 12, 2006 1:25 pm
by jwkerns
Thanks for the reponse. I've already read this post.
It's on streaming with RVF not RTF which has quite a few more arguments that wasn't sure how to fill in. Also I tried streaming from a cell back to a TRichView which appears to work. Then I stream from that TRichView back to my database which does not save the style. In RVF that is, not RTF. The question remains can a cell be used the same as a RichView when streaming out. I able to stream in without losing anything so why not stream out. There needs to be better documentation or demos on this.

Posted: Mon Mar 13, 2006 8:52 am
by Sergey Tkachenko
RTF

Saving:
Cell.GetRVData.SaveRTFToStream(Stream, '', False, clNone, nil, nil, nil, nil, nil, nil, 0.0);

Loading:
Cell.GetRVData.Clear;
Cell.GetRVData.LoadRTFFromStream(Stream);
This is not an editing operation, it should not be used in editor (only when generating a new document, or inserting a new table with data).
Call rv.Format when finished.

RVF
As it was discussed in the topic mentioned above, cells cannot save RVF containing styles (without a workaround).

Actually, these methods were planned as private, what's why they have so many unclear parameters.
But it's very unlikely that they will be changed, so you can use them safely.

Posted: Mon Mar 13, 2006 12:30 pm
by jwkerns
Thanks for the response.

Let me make sure I'm clear. Because this is what I'm trying to do.
I'm going to load a series of saved richviews to a database. Then load these back into a table with cells assigned to another richview. I want the user to be able to make changes for whatever: bold, Italic, Color etc.. and then save these changes back to the database from the cells. If I understand you correctly this cannot be done using either RVF or RTF? Even if I funnel the cell back to a RichView and then save that back to the database?

John

Posted: Mon Mar 13, 2006 3:58 pm
by Sergey Tkachenko
No problems with RTF.
Using Cell.SaveRTFToStream produces exactly the same output as saving from the main editor, so you can use RTF in your application.

If you want to use RVF for this task, it slightly more difficult.
You need to do it in several steps:
1) Save RVF from cell to Stream
2) Load this RVF in a hidden TRichView linked to the same RVStyle as the editor containing this table.
3) Saving from this hidden TRichView to database.
Even with using these 3 steps, saving in RVF may be faster than in RTF.

Posted: Mon Mar 13, 2006 6:44 pm
by jwkerns
Thanks for the Response.
I will try the rft then.
I tried exactly what you suggested for the RVF and it does not appear to work. Is this a suggestion or have you verified it will work. If you have it working could I see a code sample. Thanks.

Posted: Tue Mar 14, 2006 4:13 pm
by Sergey Tkachenko
http://www.trichview.com/support/files/copyfromcell.zip

May be it looks a bit complicated, but the file/stream saving methods of cells were not planned initially as public methods.
You can simply copy the main procedures from this project to yours.