Cell Streaming does not save Styles
Cell Streaming does not save Styles
Hello,
I am trying to stream a cell's contents (with all styles) into a stream to later insert it into a different TDBRichViewEdit control with a different TRVStyle. No matter how I go about it, all I seem to be getting in the stream (I am saving it to a file to see what's there) is the text of the cell with Style indices, but not the Styles themselves. Since I'm using a different pair of RV/Style controls as targets where I end up inserting/appending/whatever the stream, the Style information gets lost.
The relevant portion of the code I am trying to use is:
TMemoryStream *MS = new TMemoryStream;
TRVTableCellData *Cell = Table->Cells[0][0];
Cell->SaveRVFToStream(MS, false, clNone, NULL, NULL);
Alternative (B) (to the last line above):
TCustomRVData *CRVD = Cell->GetRVData();
CRVD->SaveRVFToStream(...);
Or (C):
TRVTableInplaceRVData *CED = (TRVTableInplaceRVData *)Cell->Edit();
CED->SaveRVFToStream(...);
Or even (D):
TCustomRichViewEdit *CEDRV = (TCustomRichViewEdit *)CED->GetParentControl();
CEDRV->SaveRVFToStream(MS, false);
I have also tried SaveRVFToStreamEx(MS, rvfss_Full, clNone, NULL, NULL) for the first 3 (RVData) variants.
In all cases, I am getting the exact same output that looks like this:
-8 1 3
0 1 0 0 0 0
abc
22 1 -1 1 0 0
def
0 1 -1 1 0 0
ghi
23 1 -1 1 0 0
jkl
What I seem to be missing is the actual Styles #22 and #23 for "def" and "jkl".
The source TDBRichViewEdit is already in the "Allow adding styles dynamically" mode (which happens to be the default). The only non-default setting I can think of is: rvoTagsArePChars is true. I'm using version 1.9.
Is there something I'm doing wrong? Is there a (known) limitation related to Cell streaming? If so, is there a workaround?
Thank you in advance,
Michel
I am trying to stream a cell's contents (with all styles) into a stream to later insert it into a different TDBRichViewEdit control with a different TRVStyle. No matter how I go about it, all I seem to be getting in the stream (I am saving it to a file to see what's there) is the text of the cell with Style indices, but not the Styles themselves. Since I'm using a different pair of RV/Style controls as targets where I end up inserting/appending/whatever the stream, the Style information gets lost.
The relevant portion of the code I am trying to use is:
TMemoryStream *MS = new TMemoryStream;
TRVTableCellData *Cell = Table->Cells[0][0];
Cell->SaveRVFToStream(MS, false, clNone, NULL, NULL);
Alternative (B) (to the last line above):
TCustomRVData *CRVD = Cell->GetRVData();
CRVD->SaveRVFToStream(...);
Or (C):
TRVTableInplaceRVData *CED = (TRVTableInplaceRVData *)Cell->Edit();
CED->SaveRVFToStream(...);
Or even (D):
TCustomRichViewEdit *CEDRV = (TCustomRichViewEdit *)CED->GetParentControl();
CEDRV->SaveRVFToStream(MS, false);
I have also tried SaveRVFToStreamEx(MS, rvfss_Full, clNone, NULL, NULL) for the first 3 (RVData) variants.
In all cases, I am getting the exact same output that looks like this:
-8 1 3
0 1 0 0 0 0
abc
22 1 -1 1 0 0
def
0 1 -1 1 0 0
ghi
23 1 -1 1 0 0
jkl
What I seem to be missing is the actual Styles #22 and #23 for "def" and "jkl".
The source TDBRichViewEdit is already in the "Allow adding styles dynamically" mode (which happens to be the default). The only non-default setting I can think of is: rvoTagsArePChars is true. I'm using version 1.9.
Is there something I'm doing wrong? Is there a (known) limitation related to Cell streaming? If so, is there a workaround?
Thank you in advance,
Michel
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Table cells really do not support saving and loading styles.
So the first code does not saved styles.
This code will work:
So the first code does not saved styles.
This code will work:
Code: Select all
Cell->Edit();
RichViewEdit1->TopLevelEditor->SaveRVFToStream(...);
Hi Sergey,
Thank you for a very prompt response! However, it doesn't quite work.
Firstly, RichViewEdit->TopLevelEditor returns the exact same thing I was already getting in step (D) as CED->GetParentControl(), so I have essentially already tried what you suggested. I did of course try your alternative and it produced the exact same results.
While playing with this some more, I noticed the following peculiarity.
The above produces a 100000-byte file regardless of the real size of what has been streamed (which is less). I doubt this problem is in any way related to my cell streaming troubles though. Just thought I'd mention it.
Is there anything else I can try with Cell+Style streaming?
Thank you,
Michel
Thank you for a very prompt response! However, it doesn't quite work.
Firstly, RichViewEdit->TopLevelEditor returns the exact same thing I was already getting in step (D) as CED->GetParentControl(), so I have essentially already tried what you suggested. I did of course try your alternative and it produced the exact same results.
While playing with this some more, I noticed the following peculiarity.
Code: Select all
TMemoryStream *MS = new TMemoryStream;
MS->Size = 100000;
<Any RVEdit or RVData>->SaveRVFToStream(MS, ...);
MS->SaveToFile("Check.bin");
Is there anything else I can try with Cell+Style streaming?
Thank you,
Michel
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Workarounds Accepted!
Hi Sergey,
Thank you very much!
Thank you once again!
Michel
Thank you very much!
Actually, this is what I have come up with on my side. I was simply hoping there was a better way.Workarounds:
- to select cell and save selection as RVF
And this appears to be that better way I was looking for! In a little test project I did, it worked just fine. By this I mean that it saved cell text with styles, so I don't know why you wrote "to save without styles".- to save without styles, load in a hidden TRichView linked to the same RVStyle, then save this TRichView.
Thank you once again!
Michel
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact: