On Saving Ole Container in RTF Blob, Text Remains

General TRichView support forum. Please post your questions here
Post Reply
fchintc
Posts: 47
Joined: Thu Oct 25, 2007 2:49 pm

On Saving Ole Container in RTF Blob, Text Remains

Post by fchintc »

I inserted an Ole Container that links to MS Equation Editor within a DBRichViewEdit that points to a BLOB field containing an RTF.

Image

After I save it using the following code,

Code: Select all

function SaveBlob(rv: TCustomRichView; tbl: TDataSet; const FieldName: String): Boolean;
var
   Stream: TStream;
begin
   Stream := tbl.CreateBlobStream(tbl.fieldbyname(fieldname), bmWrite);
   try
      Result := rv.SaveRTFToStream(Stream, False);
   finally
      Stream.Free;
   end;
end;
the DBRichViewEdit shows

Image

What am I missing?

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

Post by Sergey Tkachenko »

Controls are not saved in RTF or HTML. OnSaveComponentToFile event occurs instead (I believe you use event code from one of demo projects that inserts the class name). In this event you can provide code representing this control (but if cause, you need to know RTF/HTML to process it).
Saving TOleContainer in RTF is discussed here:
http://www.trichview.com/forums/viewtopic.php?t=118
fchintc
Posts: 47
Joined: Thu Oct 25, 2007 2:49 pm

Post by fchintc »

Sergey Tkachenko wrote:Controls are not saved in RTF or HTML. OnSaveComponentToFile event occurs instead (I believe you use event code from one of demo projects that inserts the class name). In this event you can provide code representing this control (but if cause, you need to know RTF/HTML to process it).
Saving TOleContainer in RTF is discussed here:
http://www.trichview.com/forums/viewtopic.php?t=118
I have looked at the above topic but it is confusing to me. How do I use it? When I place it within an existing PAS file, a bunch of errors about missing declarations pop up. If I am not mistaken, the code refers to saving to a file. I need code to save to a blob and also to retrieve it back for display/edit.

I am using the following OnSaveComponentToFile Event code:-

Code: Select all

procedure TfrmInstruct.rchContentSaveComponentToFile(Sender: TCustomRichView;
   Path: String; SaveMe: TPersistent; SaveFormat: TRVSaveFormat;
   var OutStr: String);
begin
  case SaveFormat of
   rvsfText:
      begin
        OutStr := '('+SaveMe.ClassName+')';
      end;
   rvsfHTML:
       begin
         if SaveMe is TButton then begin
           OutStr := '<INPUT type="button" value="'+TButton(SaveMe).Caption+'" '+
                     'onClick="alert(''Just a demo'')">';
           exit;
         end;
         if SaveMe is TEdit then begin
           OutStr := '<INPUT type="text" value="'+TEdit(SaveMe).Text+'">';
           exit;
         end;
       end;
   rvsfRTF:
      begin
        OutStr := '\plain\b ('+SaveMe.ClassName+')';
      end;
   end;
end;
Please advise.

Frederick
fchintc
Posts: 47
Joined: Thu Oct 25, 2007 2:49 pm

Post by fchintc »

Sergey Tkachenko wrote:Controls are not saved in RTF or HTML.
Just for clarification of the above statement. Are you saying that controls are saved using the RVF format?

Currently, my data source is in RTF format from BLOB fields in Microsoft Access. Will there be a huge effort to import and convert them to RVF format?

Frederick
Post Reply