rvico TRichView Reference | TRichView

TCustomRichView.OnReadMergeField

Top  Previous  Next

Occurs when reading merge fields from RTF file.

type

 

  TRVReadMergeFieldEvent = 

    procedure (Sender: TCustomRichView; 

      const FieldName, Extras: TRVUnicodeString

      DocFormat: TRVLoadFormat;

     var StyleNo: Integer; var ItemTag: TRVTag

     var ItemName: TRVUnicodeStringof object;

 

property OnReadMergeField: TRVReadMergeFieldEvent;

(introduced in version 18)

Input parameters:

FieldName – merge field name.

Extras – reserved, always empty.

DocFormat – format of loaded document. It is always equals to rvlfRTF.

StyleNo:

if the item is a picture, it is either rvsPicture or rvsHotPicture. You can change it, but it must still be rvsPicture or rvsHotPicture (or another item type inherited from TRVGraphicItemInfo)

if the item is a text, it is an index of style of this text. You can modify it to point to another text style.

ItemName:

if the item is a picture, it is initially equal to '' (empty string) . You can set it to value which will be assigned to name of this item.

if the item is a text, it is initially a text to display. You can modify it.

 

Output parameters:

StyleNo – style that will be used for the loaded item. See comments for input parameters.

ItemName – value that will be assigned to item text. See comments for input parameters.

ItemTag – value that will be assigned to tag of this item. You can store FieldName here. However, please note that targets of hyperlinks are also stored here; so, if you choose to store hyperlink targets and field names in tags, you need to encode them somehow.

 

If this event is not assigned, merge fields are not loaded (their content is loaded as a normal text and pictures).

Example:

Loading text merge fields as field names inside {}.

procedure TMyForm.MyRichViewReadMergeField(Sender: TCustomRichView; 

  const FieldName, Extras: TRVUnicodeString; DocFormat: TRVLoadFormat;

  var StyleNo: Integer; var ItemTag: TRVTag

  var ItemName: TRVUnicodeString);

begin

  if StyleNo >= 0 then
    ItemName := '{' + FieldName + '}';

end;

 


TRichView © trichview.com