rvico TRichView Reference | TRichView

TCustomRichView.OnSaveItemToFile

Top  Previous  Next

Allows you to change how document items are saved in text, RTF, DocX or HTML file or stream.

type

  TRVSaveItemToFileEvent = procedure (Sender: TCustomRichView;

    const Path: String; RVData: TCustomRVData; ItemNo: Integer;

    SaveFormat: TRVSaveFormatvar OutStr:TRVUnicodeString;

    var DoDefault: Boolean) of object;

(introduced  in v1.8; changed in v18)

This is a "low level" event allowing to change saving of items completely.

There are events offering a subset of functionality of this event:

OnHTMLSaveImage,

OnSaveImage2,

OnSaveComponentToFile.

These events are easier to use than this event.

 

Input parameters:

Path – path to output file;

RVData, ItemNo – item to save. RVData document containing item that is being saved; it can be Sender.RVData, table cell, or RVData of cell inplace-editor. ItemNo index of this item inside RVData.

SaveFormat identifies file format, one of rvsfText, rvsfHTML, rvsfRTF, rvsfDocX.

OutStr:

for non-text items: empty string;

for text items: text that needs to be saved (it can be a part of the item's text when saving selected fragment).

DoDefaultTrue.

 

Output parameters:

Set values of DoDefault and OutStr according to the table below.

Output value of DoDefault

For Unicode text items

For non-text items

True

For text files: default saving, value of OutStr is ignored.

For HTML, RTF, DocX: value of OutStr will be processed afterward (for example, '<' will be  changed to '&lt;' for HTML).

Default saving, value of OutStr is ignored.

False

OutStr will be inserted in the file without further processing (no control codes will be replaced).

If you do not want to change saving of some item, leave DoDefault to True.

You cannot override some special processing for paragraph markers when saving to HTML and RTF.

Notes about DocX:

this event is not called for tables

this event allows changing saving of numbering sequences only partially

 

Example: saving pictures as '[PIC]'

procedure TMyForm.MyRichViewSaveItemToFile(

  Sender: TCustomRichView; const Path: String;

  RVData: TCustomRVData; ItemNo: Integer;

  SaveFormat: TRVSaveFormat; 

  var OutStr: TRVUnicodeStringvar DoDefault: Boolean);

begin

  if (RVData.GetItemStyle(ItemNo)=rvsPicturethen

  begin

    OutStr := '[PIC]';

    DoDefault := False;        

  end;

end;


TRichView © trichview.com