Problem with SaveRVFToStream and LoadRVFFromStream Functions

General TRichView support forum. Please post your questions here
Post Reply
colivero
Posts: 9
Joined: Mon Dec 19, 2016 5:28 am

Problem with SaveRVFToStream and LoadRVFFromStream Functions

Post 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
Sergey Tkachenko
Site Admin
Posts: 17253
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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?
colivero
Posts: 9
Joined: Mon Dec 19, 2016 5:28 am

Post by colivero »

I added the RichView1.Format line after the LoadRVFFromStream, but it only brings me the content without the format.
Sergey Tkachenko
Site Admin
Posts: 17253
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Sorry, I do not understand what you mean. Do you see text with incorrect font and paragraph properties?
colivero
Posts: 9
Joined: Mon Dec 19, 2016 5:28 am

Post 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)
colivero
Posts: 9
Joined: Mon Dec 19, 2016 5:28 am

Post 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.
Sergey Tkachenko
Site Admin
Posts: 17253
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
colivero
Posts: 9
Joined: Mon Dec 19, 2016 5:28 am

Post 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.
Sergey Tkachenko
Site Admin
Posts: 17253
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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;
colivero
Posts: 9
Joined: Mon Dec 19, 2016 5:28 am

Post by colivero »

I sent you the project and the file. The project was developed in delphi xe10 seatle
colivero
Posts: 9
Joined: Mon Dec 19, 2016 5:28 am

Post by colivero »

???
Sergey Tkachenko
Site Admin
Posts: 17253
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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?
colivero
Posts: 9
Joined: Mon Dec 19, 2016 5:28 am

Post by colivero »

Firebird 2.5.5

Only the text that I typed without formatting
Sergey Tkachenko
Site Admin
Posts: 17253
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
colivero
Posts: 9
Joined: Mon Dec 19, 2016 5:28 am

Post by colivero »

Thank you, sometimes you blind yourself. Works correctly.
Post Reply