RichViewEdit.LoadRVFFromStream Fails (returns false)

General TRichView support forum. Please post your questions here
Post Reply
mgkrebbs
Posts: 10
Joined: Thu Feb 23, 2006 8:45 pm

RichViewEdit.LoadRVFFromStream Fails (returns false)

Post by mgkrebbs »

Hi all,
I'm evaluating this software and have come accross an issue:
RichViewEdit.LoadRVFFromStream Fails (returns false)

I basically loaded the RichViewActions Demo into a project, completely unchanged. I added a procedure called StartUp tha happens after formCreate but before formShow
I also made sure that the RichViewEdit1's rvfoSaveTextStyles, rvfoSaveParaStyles are true
Here's the code:

procedure TFormRVF_FieldEdit.Startup(Sender: TObject;var zCurrent:WideString);
var zStream:TStringStream;
begin
if zCurrent<>'' then
begin
zResult_RVF:=zCurrent;
zStream:=TStringStream.Create(zCurrent);
zStream.Position := 0;
RichViewEdit1.Clear;
if not RichViewEdit1.LoadRVFFromStream(zStream) then
ShowMessage('load failed');//it always fails
RichViewEdit1.Format;
zStream.Free;
end;

Anything, I need to add, or is there some setting in the RichViewActions Demo theat would prevent loadinf rvf from a stream?
Michel
Posts: 92
Joined: Fri Oct 14, 2005 2:56 pm
Contact:

Post by Michel »

Well, I think your stream is utterly empty when you try to load from it, so the failure feels like normal behavior. Opening a zero-size file would likely produce similar results (in just about anything other than Notepad). :wink:
Michel
mgkrebbs
Posts: 10
Joined: Thu Feb 23, 2006 8:45 pm

Post by mgkrebbs »

No, the stream is not empty. On the line :
zStream:=TStringStream.Create(zCurrent);
-it is loading the value of zCurrent parameter into the StringStream, In the debugger I checked to make sure that the stream is not empty. It isn't, so that's not the problem.
Michel
Posts: 92
Joined: Fri Oct 14, 2005 2:56 pm
Contact:

Post by Michel »

Right you are, I haven't noticed, sorry!
Yernar Shambayev
Posts: 57
Joined: Wed Aug 31, 2005 6:46 pm

Re: RichViewEdit.LoadRVFFromStream Fails (returns false)

Post by Yernar Shambayev »

mgkrebbs wrote:Hi all,
if zCurrent<>'' then
begin
zResult_RVF:=zCurrent;
zStream:=TStringStream.Create(zCurrent);
zStream.Position := 0;
RichViewEdit1.Clear;
if not RichViewEdit1.LoadRVFFromStream(zStream) then
ShowMessage('load failed');//it always fails
RichViewEdit1.Format;
zStream.Free;
end;
What is zCurrent?
Does it start with "-8 1", etc. ?

See RVF Specification in help
mgkrebbs
Posts: 10
Joined: Thu Feb 23, 2006 8:45 pm

Post by mgkrebbs »

Good question.
I created the file in the exact same RichView Edit, so I don't know why the load from stream fails. Loading it from file works, and the stream's text looks exactly like the file does when I view it in Notepad.

Here's the value of zCurrent from the debugger:

'-8 1 3'#$D#$A'-7 0 -1 0 0 0 0 536870911'#$D#$A'-9 2 0 0 2 0 1'#$D#$A'RVStyle1'#$D#$A'î'#2#0#0'-9 2 0 0 2 0 2'#$D#$A'RVStyle1'#$D#$A'K'#0#0#0'-9 2 0 0 2 0 4'#$D#$A'RVStyle1'#$D#$A'—'#8#0#0'-9 2 0 0 2 0 3'#$D#$A#$D#$A'!'#0#0#0#0#0#0#0#$19#0#0#0#5#0#0#0#5#0#0#0#5#0#0#0#5#0#0#0#0#0#0#0#0#0#0#0#0'0 1 0 0 0 0'#$D#$A'This is a '#$D#$A'1 1 -1 1 0 0'#$D#$A'test.'#$D#$A'0 1 -1 1 0 0'#$D#$A' '#$D#$A'2 1 -1 1 0 0'#$D#$A'Should be underlined.'#$D#$A'0 1 -1 1 0 0'#$D#$A' '#$D#$A'3 1 -1 1 0 0'#$D#$A'This sentence only is in Times New Roman.'#$D#$A'0 1 -1 1 0 0'#$D#$A' This in Arial. '#$D#$A'4 1 -1 1 0 0'#$D#$A'This is 12-point.'#$D#$A'0 1 -1 1 0 0'#$D#$A' Please visit '#$D#$A'5 1 -1 1 0 "http://www.msn.com"'#$D#$A'MSN'#$D#$A'0 1 -1 1 0 0'#$D#$A' to read some stuff.'#$D#$A'-11 0 0 0 0 0 0 0 1 0'#$D#$A'0 1 -1 1 0 0'#$D#$A'Bullet 1'#$D#$A'-11 0 0 0 0 0 0 0 1 0'#$D#$A'0 1 -1 1 0 0'#$D#$A'Bullet 2'#$D#$A'-11 0 0 0 0 0 1 0 1 0'#$D#$A'0 1 -1 1 0 0'#$D#$A'Item 1'#$D#$A'-11 0 0 0 0 0 1 0 1 0'#$D#$A'0 1 -1 1 0 0'#$D#$A'Item 2'#$D#$A'0 2 1 0 0 0'#$D#$A'This paragraph has been indented.'#$D#$A'It sure has.'#$D#$A'0 1 0 0 0 0'#$D#$A'OK, back to normal.'#$D#$A'7 1 0 0 0 0'#$D#$A'Strikeout!!!!!'#$D#$A'0 1 0 0 0 0'#$D#$A#$D#$A
mgkrebbs
Posts: 10
Joined: Thu Feb 23, 2006 8:45 pm

Post by mgkrebbs »

I figured out the the problem is in passing it through a TStringStream or a WideString. I loaded it directly to and from a TMemoryStream , and it works fine. If I figure out which one it was, I'll post here. Thanks to everyone for your suggestions.
Yernar Shambayev
Posts: 57
Joined: Wed Aug 31, 2005 6:46 pm

Post by Yernar Shambayev »

mgkrebbs wrote:I figured out the the problem is in passing it through a TStringStream or a WideString. I loaded it directly to and from a TMemoryStream , and it works fine. If I figure out which one it was, I'll post here. Thanks to everyone for your suggestions.
That's right.
RVF is a binary format, not text format, so using TMemoryStream (not TStringStream) will be correct.
Sergey Tkachenko
Site Admin
Posts: 17316
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Yes, TStringStream cannot be used to store RVF data, because it "normalizes" line breaks and damages binary data.
Post Reply