Page 1 of 1

Problem with SaveRVFToStream and LoadRVFFromStream Functions

Posted: Mon Dec 19, 2016 6:04 am
by colivero
Forgive my English; I start with the LoadRVFFromStream function, I try to load the information stored in database (Firebird 2.5) from a blob field of sub_type 0, using the following form:

st: = TMemoryStream.Create;
FDQuery1.Close;
FDQuery1.SQL.Clear;
FDQuery1.Open ('Select * from tests');
// TSQLBlobStream (FDQuery1.FieldByName ('text')). SaveToStream (st);
// TBlobField (FDQuery1.FieldByName ('text').) SaveToStream (st);
st: = FDQuery1.CreateBlobStream (FDQuery1.FieldByName ('text'), bmRead);
St.Position: = 0;
// st.Seek (0,0);
RichViewEdit1.LoadRVFFromStream (st);
St.Free;

Which does not happen, that is, it does not load anything.
Or this way

st := TStream.Create;
FDQuery1.Close;
FDQuery1.SQL.Clear;
FDQuery1.Open('Select * from pruebas');
// TSQLBlobStream(FDQuery1.FieldByName('texto')).SaveToStream(st);
// TBlobField(FDQuery1.FieldByName('texto')).SaveToStream(st);
st := FDQuery1.CreateBlobStream(FDQuery1.FieldByName('texto'),bmRead);
st.Position := 0;
// st.Seek(0,0);
RichViewEdit1.LoadRVFFromStream(st);
st.Free;

I throw the following error. Raised exception class EStreamError with message 'TStream.Seek not implemented'

I have reviewed the examples they recommend from this forum and it does not work. What am I doing wrong?

As for the function SaveRVFToStream, it does not generate error in fact in the database stores the information but I do not know how to check this, I simply store it in bold but when trying to load it I do not know if it stores well.

The control I'm using the RichViewEdit

Posted: Mon Dec 19, 2016 9:24 am
by Sergey Tkachenko
May be it is loaded, but not displayed?
Call RichViewEdit1.Format after LoadRVFFromStream.
Does LoadRVFFromStream return True of False?
If False, what's the value of RVFWarnings after loading?

Posted: Wed Dec 21, 2016 9:43 am
by colivero
I added the RichView1.Format line after the LoadRVFFromStream, but it only brings me the content without the format.

Posted: Wed Dec 21, 2016 9:54 am
by Sergey Tkachenko
Sorry, I do not understand what you mean. Do you see text with incorrect font and paragraph properties?

Posted: Wed Dec 21, 2016 10:14 am
by colivero
colivero wrote:I added the RichView1.Format line after the LoadRVFFromStream, but it only brings me the content without the format.
Return True (LoadRVFFromStream)

Posted: Wed Dec 21, 2016 10:23 am
by colivero
Exactly, that's why I say I do not know if I'm doing something wrong, or the save code is doing it right.

Posted: Wed Dec 21, 2016 10:32 am
by Sergey Tkachenko
May be RVF was saved without information about text and paragraph styles, or they are ignored on reading.

Make sure that rvfoSaveTextStyles and rvfoSaveParaStyles are included in RVFOptions of the editor that saves data, and RVFParaStylesReadMode = RVFTextStylesReadMode = rvf_sInsertMerge for the editor that loads data.
The simplest way to set the proper property values is right clicking on the editor at designtime, choosing "Settings" in the context menu, then setting "Allow adding styles dynamically" in the dialog.
Also, make sure that each editor is linked to its own TRVStyle component.

If your RVF was saved without text and paragraph styles, it's not possible to restore them, you need to recreate the document with the proper property settings.

Posted: Wed Dec 21, 2016 10:48 am
by colivero
All that is ready, the properties and configuration are as you suggest, I wonder if it will be the field type in the database.

Posted: Wed Dec 21, 2016 10:53 am
by Sergey Tkachenko
Can you create a simple project reproducing the problem and send it to me to richviewgmailcom?

If not, please save the content of this database field as send to me

Code: Select all

var Stream: TMemoryStream;
 FileStream: TFileStream;

Stream := TMemoryStream.Create;
(Table.FiedByName(FieldName) as TBlobField).SaveToStream(Stream);
Stream.Position := 0;
FileStream := TFileStream.Create(FileName, fmCreate);
FileStream.CopyFrom(Stream, 0);
FileStream.Free;
Stream.Free;

Posted: Wed Dec 21, 2016 11:18 am
by colivero
I sent you the project and the file. The project was developed in delphi xe10 seatle

Posted: Fri Dec 30, 2016 5:24 pm
by colivero
???

Posted: Sat Dec 31, 2016 9:52 am
by Sergey Tkachenko
Sorry for the delay.
I was not able to run the application. Which version of FireBird do you use? I tried 2.5 embedded.

I can see your rvffile.
It contains a plain text string of Arial 10 font.
Do you see something different when load from your database?

Posted: Mon Jan 02, 2017 12:18 pm
by colivero
Firebird 2.5.5

Only the text that I typed without formatting

Posted: Mon Jan 02, 2017 12:39 pm
by Sergey Tkachenko
I found the problem.
Exclude rvfoUseStyleNames from RVFOptions.
In this mode, names of text and paragraph styles are stored instead of their indexes.
This mode requires you to maintain unique names of text, paragraph and list styles.

Posted: Mon Jan 02, 2017 12:56 pm
by colivero
Thank you, sometimes you blind yourself. Works correctly.