Page 1 of 1
RichViewEdit.LoadRVFFromStream Fails (returns false)
Posted: Thu Feb 23, 2006 9:05 pm
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?
Posted: Fri Feb 24, 2006 2:33 pm
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).
Michel
Posted: Fri Feb 24, 2006 3:03 pm
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.
Posted: Fri Feb 24, 2006 5:09 pm
by Michel
Right you are, I haven't noticed, sorry!
Re: RichViewEdit.LoadRVFFromStream Fails (returns false)
Posted: Fri Feb 24, 2006 5:42 pm
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
Posted: Fri Feb 24, 2006 7:50 pm
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
Posted: Sat Feb 25, 2006 12:01 am
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.
Posted: Sat Feb 25, 2006 8:53 am
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.
Posted: Sun Feb 26, 2006 9:51 am
by Sergey Tkachenko
Yes, TStringStream cannot be used to store RVF data, because it "normalizes" line breaks and damages binary data.