[How to] How to save OLE objects in RTF

Demos, code samples. Only questions related to the existing topics are allowed here.
Post Reply
Sergey Tkachenko
Site Admin
Posts: 17524
Joined: Sat Aug 27, 2005 10:28 am
Contact:

[How to] How to save OLE objects in RTF

Post by Sergey Tkachenko »

Saving TOLEContainers from TRichView to RTF file:
http://www.trichview.com/forums/viewtopic.php?t=108
Sergey Tkachenko
Site Admin
Posts: 17524
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I created a unit based on the code from the topic above.
http://www.trichview.com/support/files/ ... rtortf.zip

It contains the function

Code: Select all

function GetOleContainerRTFString(OleContainer: TOleContainer;
  Image: TMetafile = nil): String;
This function returns RTF representation of OleContainer for assigning to OutStr parameter of TRichView.OnSaveComponentToFile event:

Code: Select all

procedure TForm1.RichViewEdit1SaveComponentToFile(Sender: TCustomRichView;
  Path: String; SaveMe: TPersistent; SaveFormat: TRVSaveFormat;
  var OutStr: TRVUnicodeString);
begin
  case SaveFormat of
   ...
   rvsfRTF:
      begin
        if SaveMe is TOleContainer then
          OutStr := GetOleContainerRTFString(TOleContainer(SaveMe))
        ...
      end;
  end;
end;
The second parameter (Image) is optional. If assigned, this metafile will be used as an image representing this OleContainer. If not assigned, the function makes this image itself.

Update:
2018-Apr-20: for compatibility with TRichView 17.3 (for older versions, change the type of OutStr parameter to String
gary
Posts: 163
Joined: Wed Aug 31, 2005 1:36 pm

Post by gary »

Is there a same function for export ole to html?
Sergey Tkachenko
Site Admin
Posts: 17524
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I am not sure if it is possible at all.
HTML can include ActiveX controls, not OLE.

ActiveX is a programming code, while OLE object is data (such as a picture).
Post Reply