<< Click to display table of contents >> TCustomRichView.OnSaveItemToFile |
Allows you to change how document items are saved in text, RTF, DocX, HTML or Markdown file or stream.
type
TRVSaveItemToFileEvent = procedure (Sender: TCustomRichView;
const Path: TRVUnicodeString;
RVData: TCustomRVData; ItemNo: Integer;
SaveFormat: TRVSaveFormat; var 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:
These events are easier to use than this event.
Input parameters:
Path – path to the 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).
DoDefault – True.
Output parameters:
Set values of DoDefault and OutStr according to the table below.
Output value of DoDefault |
For text items |
For non-text items |
---|---|---|
True |
For text files: default saving, value of OutStr is ignored. For HTML, RTF, DocX, Markdown: value of OutStr will be processed afterward (for example, '<' will be changed to '<' 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
Notes about Markdown:
Regardless of DoDefault value, space characters in OutStr can be encoded (changed to ' ' or a line break). To prevent it, use #01 instead of space characters (#01 will be changed to spaces before saving).
Example: saving pictures as '[PIC]'
procedure TMyForm.MyRichViewSaveItemToFile(
Sender: TCustomRichView; const Path: TRVUnicodeString;
RVData: TCustomRVData; ItemNo: Integer;
SaveFormat: TRVSaveFormat;
var OutStr: TRVUnicodeString; var DoDefault: Boolean);
begin
if (RVData.GetItemStyle(ItemNo)=rvsPicture) then
begin
case SaveFormat of
rvsfMarkdown:
OutStr := '\[PIC\]';
else
OutStr := '[PIC]';
end;
DoDefault := False;
end;
end;