RVRTF.pas
上传用户:daoqigc
上传日期:2021-04-20
资源大小:2795k
文件大小:213k
源码类别:

RichEdit

开发平台:

Delphi

  1. {*******************************************************}
  2. {                                                       }
  3. {       RichView                                        }
  4. {       TRVRTFReader: Rich Text Format (RTF) parser.    }
  5. {                                                       }
  6. {       Copyright (c) Sergey Tkachenko                  }
  7. {       svt@trichview.com                               }
  8. {       http://www.trichview.com                        }
  9. {                                                       }
  10. {*******************************************************}
  11. unit  RVRTF;
  12. interface
  13. {$I RV_Defs.inc}
  14. uses Windows, Classes, Graphics,  StdCtrls,  SysUtils,
  15.      {$IFDEF RICHVIEW}
  16.      RVFuncs, CRVData,
  17.      {$ENDIF}
  18.      RVClasses, Forms,
  19.      {$IFNDEF RVDONOTUSEJPEGIMAGE}
  20.      Jpeg,
  21.      {$ENDIF}
  22.      {$IFDEF RVUSEWORDDOC}
  23.      MSWordDoc,
  24.      {$ENDIF}
  25.      RVRTFErr;
  26. type
  27.    TRVRTFHighlightConvert = (rtf_hl_Ignore, rtf_hl_FixedColors, rtf_hl_ColorTable);
  28.    TRVRTFTabAlign = (rtf_tab_Left, rtf_tab_Right, rtf_tab_Center, rtf_tab_Decimal);
  29.    TRVRTFTabLeader = (rtf_tl_None, rtf_tl_Dot, rtf_tl_MiddleDot, rtf_tl_Hyphen,
  30.      rtf_tl_Underline, rtf_tl_EqualSign);
  31.    TRVRTFReader = class;
  32.    TRVRTFPosition = (rtf_ts_ContinuePara, rtf_ts_NewLine, rtf_ts_NewPara);
  33.    TRVRTFNewTextEvent = procedure (Sender: TRVRTFReader; const Text: String;
  34.      Position: TRVRTFPosition) of object;
  35.    TRVRTFHeaderFooterType = (rtf_hf_MainText, rtf_hf_Header, rtf_hf_Footer);
  36.    TRVRTFHeaderFooterEvent = procedure (Sender: TRVRTFReader;
  37.      HFType: TRVRTFHeaderFooterType; Starting: Boolean;
  38.      var Supported: Boolean) of object;
  39.    TRVRTFImportPictureEvent = procedure (Sender: TRVRTFReader;
  40.      const Location: String; var Graphic: TGraphic; var Invalid: Boolean) of object;
  41.    {$IFDEF RICHVIEWCBDEF3}
  42.    TRVRTFNewUnicodeTextEvent = procedure (Sender: TRVRTFReader;
  43.      const Text: WideString; Position: TRVRTFPosition) of object;
  44.    {$ENDIF}
  45.    TRVRTFProgressStage = (
  46.     rvprtfprStarting,
  47.     rvprtfprRunning,
  48.     rvprtfprEnding);
  49.     TRVRTFProgressEvent = procedure (Sender: TRVRTFReader;
  50.       Stage: TRVRTFProgressStage; PercentDone: Byte) of object;
  51.    {------------------------------------------------------------------------------}
  52.     TRVRTFParaListType = (
  53.                  rtf_pn_Default,
  54.                  // both for old and new style
  55.                  rtf_pn_Decimal, rtf_pn_LowerLetter, rtf_pn_UpperLetter,
  56.                  rtf_pn_LowerRoman, rtf_pn_UpperRoman,
  57.                  // for new style
  58.                  rtf_pn_Bullet
  59.                  );
  60.     TRVRTFPictureType = (rtf_pict_EMF, rtf_pict_PNG, rtf_pict_JPEG,
  61.                          rtf_pict_MacPict, rtf_pict_PmMetafile,
  62.                          rtf_pict_WMF, rtf_pict_DIB, rtf_pict_DDB);
  63.     TRVRTFPicture = class
  64.       private
  65.         FType: TRVRTFPictureType;
  66.         FMetafileMapMode: Integer; // MM_ constant
  67.         FPicW, FPicH, FPicWGoalTw, FPicHGoalTw, FPicScaleX, FPicScaleY: Integer;
  68.         FWBMWidthBytes, FWBMBitsPixel, FWBMPlanes: Integer;
  69.         FMetafileWithBitmap: Boolean;
  70.         FShpPict: Boolean;
  71.       public
  72.         FData: TMemoryStream;
  73.         SuggestedWidth, SuggestedHeight: Integer;
  74.         constructor Create;
  75.         destructor Destroy; override;
  76.         property PicW: Integer read FPicW;
  77.         property PicH: Integer read FPicH;
  78.         property PicWGoalTw: Integer read FPicWGoalTw;
  79.         property PicHGoalTw: Integer read FPicHGoalTw;
  80.         property PicScaleX: Integer read FPicScaleX;
  81.         property PicScaleY: Integer read FPicScaleY;
  82.         property PicType: TRVRTFPictureType read FType;
  83.         property MetafileWithBitmap: Boolean read FMetafileWithBitmap;
  84.         property ShpPict: Boolean read FShpPict;
  85.     end;
  86.     TRVRTFObjectType = (rtf_obj_Emb, rtf_obj_Link, rtf_obj_AutLink, rtf_obj_Sub,
  87.       rtf_obj_Pub, rtf_obj_ICEmb, rtf_obj_HTML, rtf_obj_OCX);
  88.     TRVRTFObject = class
  89.       private
  90.         FType: TRVRTFObjectType;
  91.         FData: TMemoryStream;
  92.         FWidthTw, FHeightTw: Integer;
  93.       public
  94.         constructor Create;
  95.         destructor Destroy; override;
  96.         property ObjType: TRVRTFObjectType read FType;
  97.         property Data: TMemoryStream read FData;
  98.         property WidthTw: Integer read FWidthTw;
  99.         property HeightTw: Integer read FHeightTw;
  100.     end;
  101.    TRVRTFTableEventKind = (rvf_tbl_TableStart, rvf_tbl_TableEnd,
  102.                            rvf_tbl_RowEnd, rvf_tbl_CellEnd);
  103.    TRVRTFTableEvent = procedure (Sender: TRVRTFReader;
  104.      WhatHappens: TRVRTFTableEventKind) of object;
  105.    TRVRTFNewPictureEvent = procedure (Sender: TRVRTFReader; RTFPicture: TRVRTFPicture;
  106.      Graphic: TGraphic; Position: TRVRTFPosition; const FileName: String;
  107.      var Inserted: Boolean) of object;
  108.    TRVRTFNewObjectEvent = procedure (Sender: TRVRTFReader; RTFObject: TRVRTFObject;
  109.      Position: TRVRTFPosition; var Inserted: Boolean) of object;
  110.    {-------------------- character properties -----------------------}
  111.    TRVRTFAlignment = (rtf_al_Left, rtf_al_Right, rtf_al_Center, rtf_al_Justify);
  112.    TRVRTFVAlign = (rtf_val_Top, rtf_val_Bottom, rtf_val_Center);
  113.    TRVRTFSScriptType = (rtf_ss_Normal, rtf_ss_Subscript, rtf_ss_Superscript);
  114.    TRVRTFFontStyleEx = (rtf_fs_AllCaps {$IFDEF RVTEXTFOOTNOTES},rtf_fs_Footnote{$ENDIF});
  115.    TRVRTFFontStylesEx = set of TRVRTFFontStyleEx;
  116.    TRVRTFCharProperties = class
  117.      private
  118.        FHidden: Boolean;
  119.        FSize: Integer;
  120.        FColor, FBackColor: TColor;
  121.        FFontIndex: Integer;
  122.        FStyle: TFontStyles;
  123.        FStyleEx: TRVRTFFontStylesEx;
  124.        FCharScaleX: Integer;
  125.        FSScriptType: TRVRTFSScriptType;
  126.        FCharSpacingTw: Integer;
  127.        FLanguage: Cardinal;
  128.        FFontName: String;
  129.        {$IFDEF RVTEXTFOOTNOTES}
  130.        FFootNote: String;
  131.        {$ENDIF}
  132.      public
  133.        constructor Create;
  134.        procedure Reset (DefLanguage: Cardinal; DefFontIndex: Integer);
  135.        procedure Assign(Source: TRVRTFCharProperties);
  136.        property Size     : Integer     read FSize;
  137.        property Color    : TColor      read FColor;
  138.        property BackColor: TColor      read FBackColor;
  139.        property FontIndex: Integer     read FFontIndex;
  140.        property Style    : TFontStyles read FStyle;
  141.        property StyleEx  : TRVRTFFontStylesEx read FStyleEx;
  142.        property CharScaleX: Integer    read FCharScaleX;
  143.        property SScriptType: TRVRTFSScriptType read FSScriptType;
  144.        property CharSpacingTw: Integer read FCharSpacingTw;
  145.        property Hidden: Boolean        read FHidden;
  146.        property FontName: String       read FFontName;
  147.        property Language: Cardinal     read FLanguage;
  148.        {$IFDEF RVTEXTFOOTNOTES}
  149.        property FootNote: String       read FFootnote;
  150.        {$ENDIF}
  151.    end;
  152.    {-------------------- paragraph properties -----------------------}
  153.    TRVRTFBorderType = (rtf_brdr_None,
  154.                    rtf_brdr_SingleThickness, rtf_brdr_DoubleThickness,
  155.                    rtf_brdr_Shadow, rtf_brdr_Double, rtf_brdr_Dot,
  156.                    rtf_brdr_Dash, rtf_brdr_Hairline,
  157.                    rtf_brdr_DashSmall, rtf_brdr_DotDash,
  158.                    rtf_brdr_DotDotDash, rtf_brdr_Triple,
  159.                    rtf_brdr_ThickThinSmall, rtf_brdr_ThinThickSmall,
  160.                    rtf_brdr_ThinThickThinSmall,
  161.                    rtf_brdr_ThickThinMed, rtf_brdr_ThinThickMed,
  162.                    rtf_brdr_ThinThickThinMed,
  163.                    rtf_brdr_ThickThinLarge, rtf_brdr_ThinThickLarge,
  164.                    rtf_brdr_ThinThickThinLarge,
  165.                    rtf_brdr_Wavy, rtf_brdr_DoubleWavy,
  166.                    rtf_brdr_Striped, rtf_brdr_Emboss,
  167.                    rtf_brdr_Engrave,
  168.                    rtf_brdr_Inset, rtf_brdr_Outset);
  169.    TRVRTFSide = (rtf_side_Left, rtf_side_Top, rtf_side_Right, rtf_side_Bottom);
  170.    TRVRTFBorderSide = class
  171.      private
  172.         FBorderType: TRVRTFBorderType;
  173.         FWidthTw: Integer;
  174.         FColor: TColor;
  175.         FSpaceTw: Integer; // Space between borders and the paragraph
  176.      public
  177.         procedure Assign(Source: TRVRTFBorderSide);
  178.         property BorderType: TRVRTFBorderType read FBorderType;
  179.         procedure Reset;
  180.         property WidthTw   : Integer      read FWidthTw;
  181.         property Color     : TColor       read FColor;
  182.         property SpaceTw   : Integer      read FSpaceTw;
  183.    end;
  184.    TRVRTFParaBorder = class
  185.      private
  186.        FSides: array [TRVRTFSide] of TRVRTFBorderSide;
  187.        function GetSides(Index: TRVRTFSide): TRVRTFBorderSide;
  188.      public
  189.        procedure Assign(Source: TRVRTFParaBorder);
  190.        destructor Destroy; override;
  191.        procedure Reset;
  192.        property Sides[Index:TRVRTFSide]:TRVRTFBorderSide read GetSides;
  193.    end;
  194.    TRVRTFMarkerProp = (rtfmp_FontIndex, rtfmp_Size, rtfmp_Color,
  195.      rtfmp_Bold, rtfmp_Italic, rtfmp_Underline, rtfmp_StrikeOut);
  196.    TRVRTFMarkerProps = set of TRVRTFMarkerProp;
  197.    TRVRTFCustomMarkerProperties = class
  198.      private
  199.        FListType: TRVRTFParaListType;
  200.        FFontIndex, FIndentTw, FSpaceTw, FStart: Integer;
  201.        FFontStyle: TFontStyles;
  202.        FColor: TColor;
  203.        FAlignment: TRVRTFAlignment;
  204.        FFixedProperties: TRVRTFMarkerProps;
  205.        procedure ChangeFontStyle(fs: TFontStyle; Val: Integer);
  206.      public
  207.        FFontSize: Integer;
  208.        constructor Create;
  209.        procedure Reset; dynamic;
  210.        procedure Assign(Source: TRVRTFCustomMarkerProperties; FromDefaults: Boolean);
  211.        procedure UpdateFrom(CharProps: TRVRTFCharProperties);
  212.        property ListType: TRVRTFParaListType read FListType;
  213.        property FontIndex: Integer           read FFontIndex;
  214.        property FontSize: Integer            read FFontSize;
  215.        property IndentTw: Integer            read FIndentTw;
  216.        property SpaceTw: Integer             read FSpaceTw;
  217.        property Start: Integer               read FStart;
  218.        property FontStyle: TFontStyles       read FFontStyle;
  219.        property Color    : TColor            read FColor;
  220.        property Alignment: TRVRTFAlignment   read FAlignment;
  221.    end;
  222.    TRVRTFMarkerProperties = class (TRVRTFCustomMarkerProperties)
  223.      private
  224.        FLevel: Integer;
  225.        FHanging: Boolean;
  226.        FTextAfter, FTextBefore: String;
  227.      public
  228.        procedure Reset; override;
  229.        procedure Assign(Source: TRVRTFMarkerProperties; FromDefaults: Boolean);
  230.        property Level: Integer               read FLevel;
  231.        property TextAfter: String            read FTextAfter;
  232.        property TextBefore: String           read FTextBefore;
  233.        property Hanging: Boolean             read FHanging;
  234.    end;
  235.    TRVRTFLevelFollow97 = (rtf_lf_Tab, rtf_lf_Space, rtf_lf_None);
  236.    TRVRTFListLevel97 = class (TRVRTFCustomMarkerProperties)
  237.      private
  238.        FOldStyle, FLegal, FNoRestart: Boolean;
  239.        FText,FNumbers: String;
  240.        {$IFDEF RICHVIEWCBDEF3}
  241.        FTextW: WideString;
  242.        {$ELSE}
  243.        FTextW: String;
  244.        {$ENDIF}
  245.        FFollow: TRVRTFLevelFollow97;
  246.        FLeftIndentTw, FFirstIndentTw, FTabPosTw: Integer;
  247.      public
  248.        FFontSizeDefined: Boolean;
  249.        FIndentsUpdated: Boolean;
  250.        procedure Reset; override;
  251.        procedure Assign(Source: TRVRTFListLevel97);
  252.        property OldStyle: Boolean           read FOldStyle;
  253.        property Legal: Boolean              read FLegal;
  254.        property NoRestart: Boolean          read FNoRestart;
  255.        property Text: String                read FText;
  256.        property TextW: {$IFDEF RICHVIEWCBDEF3}WideString{$ELSE}String{$ENDIF} read FTextW;
  257.        property Numbers: String             read FNumbers;
  258.        property Follow: TRVRTFLevelFollow97 read FFollow;
  259.        property LeftIndentTw: Integer       read FLeftIndentTw;
  260.        property FirstIndentTw: Integer      read FFirstIndentTw;
  261.        property TabPosTw: Integer           read FTabPosTw;
  262.    end;
  263.    TRVRTFList97 = class (TRVList)
  264.      private
  265.        FId, FTemplateId: Integer;
  266.        FSimple: Boolean;
  267.        FName: String;
  268.        function Get(Index: Integer): TRVRTFListLevel97;
  269.        procedure Put(Index: Integer; const Value: TRVRTFListLevel97);
  270.      protected
  271.        function GetLastLevel: TRVRTFListLevel97;
  272.        procedure AddNew;
  273.      public
  274.        property Items[Index: Integer]: TRVRTFListLevel97 read Get write Put; default;
  275.        property Id: Integer         read FId;
  276.        property TemplateId: Integer read FTemplateId;
  277.        property Simple: Boolean     read FSimple;
  278.        property Name: String        read FName;
  279.    end;
  280.    TRVRTFListTable97 = class (TRVList)
  281.      private
  282.        function Get(Index: Integer): TRVRTFList97;
  283.        procedure Put(Index: Integer; const Value: TRVRTFList97);
  284.      protected
  285.        function GetLastList: TRVRTFList97;
  286.        function FindList(ID: Integer): Integer;
  287.        procedure AddNew;
  288.      public
  289.        property Items[Index: Integer]: TRVRTFList97 read Get write Put; default;
  290.    end;
  291.    TRVRTFListOverrideLevel97 = class
  292.      private
  293.        FUseStart: Boolean;
  294.        FStart: Integer;
  295.      public
  296.        constructor Create;
  297.        property Start: Integer    read FStart;
  298.        property UseStart: Boolean read FUseStart;
  299.    end;
  300.    TRVRTFListOverride97 = class (TRVList)
  301.      private
  302.        FListIndex, FNumber, FOverrideCount: Integer;
  303.        function Get(Index: Integer): TRVRTFListOverrideLevel97;
  304.        procedure Put(Index: Integer; const Value: TRVRTFListOverrideLevel97);
  305.      public
  306.        function GetLastLevel: TRVRTFListOverrideLevel97;
  307.        procedure AddNew;
  308.        property ListIndex: Integer read FListIndex;
  309.        property Number: Integer    read FNumber;
  310.        property OverrideCount: Integer read FOverrideCount;
  311.        property Items[Index: Integer]: TRVRTFListOverrideLevel97 read Get write Put; default;
  312.    end;
  313.    TRVRTFListOverrideTable97 = class (TRVList)
  314.      private
  315.        function Get(Index: Integer): TRVRTFListOverride97;
  316.        procedure Put(Index: Integer; const Value: TRVRTFListOverride97);
  317.      protected
  318.        function GetLastListOverride: TRVRTFListOverride97;
  319.        function FindListOverride(Number: Integer): Integer;
  320.        procedure AddNew;
  321.      public
  322.        property Items[Index: Integer]: TRVRTFListOverride97 read Get write Put; default;
  323.    end;
  324.    {$IFNDEF RVDONOTUSETABS}
  325.    TRVRTFTab = class
  326.      private
  327.        FPositionTW: Integer;
  328.        FAlign: TRVRTFTabAlign;
  329.        FLeader: TRVRTFTabLeader;
  330.        FIsListTab: Boolean;
  331.      public
  332.        procedure Assign(Source: TRVRTFTab);
  333.        property PositionTW: Integer read FPositionTW;
  334.        property Align: TRVRTFTabAlign read FAlign;
  335.        property Leader: TRVRTFTabLeader read FLeader;
  336.        property IsListTab: Boolean read FIsListTab;
  337.    end;
  338.    TRVRTFTabList = class (TRVList)
  339.      private
  340.        function Get(Index: Integer): TRVRTFTab;
  341.        procedure Put(Index: Integer; const Value: TRVRTFTab);
  342.      protected
  343.        procedure AddNew;
  344.        function GetLastTab: TRVRTFTab;
  345.      public
  346.        procedure Assign(Source: TRVRTFTabList);
  347.        property Items[Index: Integer]: TRVRTFTab read Get write Put; default;
  348.    end;
  349.    {$ENDIF}
  350.    TRVRTFParaProperties = class
  351.      private
  352.        FLeftIndentTw, FRightIndentTw, FFirstIndentTw:  Integer;
  353.        FSpaceBeforeTw, FSpaceAfterTw: Integer;
  354.        FAlignment:  TRVRTFAlignment;
  355.        FBorder: TRVRTFParaBorder;
  356.        FMarkerProps: TRVRTFMarkerProperties;
  357.        FCurBorderSide: TRVRTFSide;
  358.        FLineSpacing: Integer;
  359.        FLineSpacingMulti: Boolean;
  360.        FColor: TColor;
  361.        FNestingLevel: Integer;
  362.        FInTable: Boolean;
  363.        Shading: Integer;
  364.        ForeColor: TColor;
  365.        FListOverrideIndex, FListLevel: Integer;
  366.        FKeepLinesTogether, FKeepWithNext: Boolean;
  367.        NoTableEv, NoResetLev: Boolean;
  368.        {$IFNDEF RVDONOTUSETABS}
  369.        FTabs: TRVRTFTabList;
  370.        FTabsReady: Boolean;
  371.        function GetTabs: TRVRTFTabList;
  372.        {$ENDIF}
  373.        function GetBorder: TRVRTFParaBorder;
  374.        function GetMarkerProps: TRVRTFMarkerProperties;
  375.        procedure Finalize;
  376.      public
  377.        constructor Create;
  378.        destructor Destroy; override;
  379.        procedure Reset;
  380.        procedure Assign(Source: TRVRTFParaProperties);
  381.        function HasBorder: Boolean;
  382.        function HasMarker: Boolean;
  383.        {$IFNDEF RVDONOTUSETABS}
  384.        function HasTabs: Boolean;
  385.        property Tabs: TRVRTFTabList            read GetTabs;
  386.        {$ENDIF}
  387.        property LeftIndentTw : Integer         read FLeftIndentTw;
  388.        property RightIndentTw: Integer         read FRightIndentTw;
  389.        property FirstIndentTw: Integer         read FFirstIndentTw;
  390.        property SpaceBeforeTw: Integer         read FSpaceBeforeTw;
  391.        property SpaceAfterTw : Integer         read FSpaceAfterTw;
  392.        property Alignment    : TRVRTFAlignment read FAlignment;
  393.        property Border       : TRVRTFParaBorder read GetBorder;
  394.        property MarkerProps  : TRVRTFMarkerProperties read GetMarkerProps;
  395.        property Color        : TColor          read FColor;
  396.        property LineSpacing  : Integer         read FLineSpacing;
  397.        property LineSpacingMulti: Boolean      read FLineSpacingMulti;
  398.        property NestingLevel : Integer         read FNestingLevel;
  399.        property InTable      : Boolean         read FInTable;
  400.        property ListOverrideIndex: Integer     read FListOverrideIndex;
  401.        property ListLevel    : Integer         read FListLevel;
  402.        property KeepLinesTogether: Boolean     read FKeepLinesTogether;
  403.        property KeepWithNext: Boolean          read FKeepWithNext;
  404.     end;
  405.    {-------------------- table cell properties --------------------}
  406.    TRVRTFCellMerge = (rtf_cm_None, rtf_cm_First, rtf_cm_Merged);
  407.    TRVRTFCellProperties = class
  408.      private
  409.        FHMerge, FVMerge: TRVRTFCellMerge;
  410.        InvertWidth: Boolean;
  411.        FBestWidth: Integer;
  412.        FColor: TColor;
  413.        FVAlign: TRVRTFVAlign;
  414.        FBorder: TRVRTFParaBorder;
  415.        FCurBorderSide: TRVRTFSide;
  416.        FRightBoundaryTw: Integer;
  417.        ForeColor: TColor;
  418.        Shading: Integer;
  419.        procedure Finalize;
  420.      public
  421.        {$IFDEF RICHVIEW}
  422.        BestHeight: Integer;
  423.        {$ENDIF}
  424.        constructor Create;
  425.        destructor Destroy; override;
  426.        procedure Reset;
  427.        procedure Assign(Source: TRVRTFCellProperties);
  428.        property HMerge         : TRVRTFCellMerge read FHMerge;
  429.        property VMerge         : TRVRTFCellMerge read FVMerge;
  430.        property BestWidth      : Integer         read FBestWidth; // positive: twips; negative: 50th of %; 0: undefined
  431.        property Color          : TColor          read FColor;
  432.        property VAlign         : TRVRTFVAlign    read FVAlign;
  433.        property Border         : TRVRTFParaBorder read FBorder;
  434.        property RightBoundaryTw: Integer         read FRightBoundaryTw;
  435.    end;
  436.    TRVRTFCellPropsList = class (TRVList)
  437.       private
  438.         function Get(Index: Integer): TRVRTFCellProperties;
  439.         procedure Put(Index: Integer; const Value: TRVRTFCellProperties);
  440.       public
  441.         procedure AddNew;
  442.         procedure AssignItems(Source: TRVRTFCellPropsList);
  443.         property Items[Index: Integer]: TRVRTFCellProperties read Get write Put; default;
  444.    end;
  445.    {-------------------- table row properties ---------------------}
  446.    TRVRTFRowProperties = class
  447.      private
  448.        InvertWidth, FHeading: Boolean;
  449.        FGapHTw, FLeftTw, FHeightTw: Integer;
  450.        FBestWidth: Integer;
  451.        FBorder: TRVRTFParaBorder;
  452.        FCurBorderSide: TRVRTFSide;
  453.        FCellProps: TRVRTFCellPropsList;
  454.        NewCellProps, AssumedLastCell: Boolean;
  455.        function GetPaddingTw(Index: TRVRTFSide): Integer;
  456.        function GetSpacingTw(Index: TRVRTFSide): Integer;
  457.        function GetUsePadding(Index: TRVRTFSide): Boolean;
  458.        function GetUseSpacing(Index: TRVRTFSide): Boolean;
  459.        function GetLastCellProp: TRVRTFCellProperties;
  460.        procedure Finalize;
  461.      public
  462.        {$IFDEF RICHVIEW}
  463.        RichViewSpecial: Boolean;
  464.        {$ENDIF}
  465.        FPaddingTw, FSpacingTw: array[TRVRTFSide] of Integer;
  466.        FUsePadding, FUseSpacing: array[TRVRTFSide] of Boolean;       
  467.        constructor Create;
  468.        destructor Destroy; override;
  469.        procedure Reset;
  470.        procedure Assign(Source: TRVRTFRowProperties);
  471.        property CellProps      : TRVRTFCellPropsList read FCellProps;
  472.        property GapHTw         : Integer         read FGapHTw;
  473.        property LeftTw         : Integer         read FLeftTw;
  474.        property HeightTw       : Integer         read FHeightTw;
  475.        property BestWidth      : Integer         read FBestWidth; // positive: twips; negative: 50-th of %; 0: undefined
  476.        property PaddingTw  [Index:TRVRTFSide]: Integer read GetPaddingTw;
  477.        property SpacingTw  [Index:TRVRTFSide]: Integer read GetSpacingTw;
  478.        property UsePadding [Index:TRVRTFSide]: Boolean read GetUsePadding;
  479.        property UseSpacing [Index:TRVRTFSide]: Boolean read GetUseSpacing;
  480.        property Border         : TRVRTFParaBorder read FBorder;
  481.        property Heading        : Boolean         read FHeading;
  482.    end;
  483.    {-------------------- section properties -----------------------}
  484.    TRVRTFSectionBreakType = (rtf_sbk_None, rtf_sbk_Column, rtf_sbk_Even, rtf_sbk_Odd, rtf_sbk_Page);
  485.    TRVRTFPageNumberFormat = (rtf_pg_Decimal,
  486.                              rtf_pg_UpperRoman, rtf_pg_LowerRoman,
  487.                              rtf_pg_UpperLetter, rtf_pg_LowerLetter);
  488.    TRVRTFSectionProperties = class
  489.      private
  490.        FColumnCount: Integer;
  491.        FSectionBreakType: TRVRTFSectionBreakType;
  492.        FPageNumberXTw, FPageNumberYTw: Integer;
  493.        FPageNumberFormat: TRVRTFPageNumberFormat;
  494.        FHeaderYTw, FFooterYTw: Integer;
  495.        FDefMarkerPropsList: TRVList;
  496.        procedure InitListDefaults;
  497.      public
  498.        constructor Create;
  499.        procedure Reset;
  500.        destructor Destroy; override;
  501.        procedure Assign(Source: TRVRTFSectionProperties);
  502.        property ColumnCount     : Integer                read FColumnCount;
  503.        property SectionBreakType: TRVRTFSectionBreakType read FSectionBreakType;
  504.        property PageNumberXTw   : Integer                read FPageNumberXTw;
  505.        property PageNumberYTw   : Integer                read FPageNumberYTw;
  506.        property PageNumberFormat: TRVRTFPageNumberFormat read FPageNumberFormat;
  507.        property HeaderYTw       : Integer                read FHeaderYTw;
  508.        property FooterYTw       : Integer                read FFooterYTw;
  509.    end;
  510.    {-------------------- document properties -----------------------}
  511.     TRVRTFDocProperties = class
  512.       private
  513.         FPaperWidthTw, FPaperHeightTw: Integer;
  514.         FLeftMarginTw, FTopMarginTw, FRightMarginTw, FBottomMarginTw: Integer;
  515.         FPageNumberStart: Integer;
  516.         FFacingPages: Boolean;
  517.         FLandscape: Boolean;
  518.       public
  519.         constructor Create;
  520.         procedure Reset;
  521.         procedure Assign(Source: TRVRTFDocProperties);
  522.         property PaperWidthTw   : Integer read FPaperWidthTw;
  523.         property PaperHeightTw  : Integer read FPaperHeightTw;
  524.         property LeftMarginTw   : Integer read FLeftMarginTw;
  525.         property TopMarginTw    : Integer read FTopMarginTw;
  526.         property RightMarginTw  : Integer read FRightMarginTw;
  527.         property BottomMarginTw : Integer read FBottomMarginTw;
  528.         property PageNumberStart: Integer read FPageNumberStart;
  529.         property FacingPages    : Boolean read FFacingPages;
  530.         property Landscape      : Boolean read FLandscape;
  531.     end;
  532. //----------------------------------------------------------------------
  533.     TRTFrds = ( rdsNorm, rdsSkip,  rdsFontTable, rdsStyleSheet, rdsColorTable,
  534.                 rdsStyleSheetEntry, rdsPict, rdsShpPict, rdsObject, rdsObjData,
  535.                 rdsField, rdsFldInst, rdsPN, rdsPNTextAfter, rdsPNTextBefore,
  536.                 rdsPNSecLvl, rdsListTable, rdsList, rdsListLevel,
  537.                 rdsListName, rdsListLevelText, rdsListLevelNumbers,
  538.                 rdsLOTable, rdsLO, rdsLOLevel);       // Rtf Destination State
  539. //----------------------------------------------------------------------
  540.     TRTFris = ( risNorm, risBin, risHex );// Rtf Internal State
  541. //----------------------------------------------------------------------
  542. // What types of properties are there?
  543.     TRTFIPROP = (ipropBold, ipropItalic, ipropUnderline, ipropStrike,
  544.               ipropCharScaleX, ipropCharSpacing, ipropSScript, ipropAllCaps,
  545.               ipropFontSize, ipropTextColor, ipropTextBackColor, ipropHighlight,
  546.               ipropLanguage, ipropDefLanguage,
  547.               ipropSL, ipropSLMult,
  548.               ipropLeftInd,
  549.               ipropRightInd, ipropFirstInd, ipropCols, ipropPgnX,
  550.               ipropPgnY, ipropHeaderY, ipropFooterY, ipropXaPage, ipropYaPage, ipropXaLeft,
  551.               ipropXaRight, ipropYaTop, ipropYaBottom, ipropPgnStart,
  552.               ipropSbk, ipropPgnFormat, ipropFacingp, ipropLandscape,
  553.               ipropJust, ipropPard, ipropPlain, ipropSectd,
  554.               ipropF, ipropDefF, ipropSpaceBefore, ipropSpaceAfter,
  555.               {$IFDEF RVTEXTFOOTNOTES}
  556.               ipropfootnote,
  557.               {$ENDIF}
  558.               ipropParaBorderType, ipropParaBorderSide, ipropParaBorderWidth,
  559.               ipropParaBorderColor, ipropParaBorderSpace,
  560.               ipropParaColor, ipropParaFColor, ipropParaShading,
  561.               ipropAnsiCodePage, ipropU, ipropUC,
  562.               ipropPage, ipropField, ipropFldInst, ipropFldRslt, ipropHidden,
  563.               ipropKeepLinesTogether, ipropKeepWithNext,
  564.               // tabs
  565.               ipropTX, ipropTabAlign, ipropTabLeader, ipropListTab,
  566.               // color table:
  567.               ipropRed, ipropGreen, ipropBlue,
  568.               // font table:
  569.               ipropFontFamily,
  570.               ipropFCharset,
  571.               // style sheet
  572.               ipropS, ipropCS, ipropDS, ipropSBasedOn, irpropSNext, ipropAdditive, ipropSHidden,
  573.               // picture
  574.               ipropPicW, ipropPicH, ipropPicScaleX, ipropPicScaleY, ipropPicWGoal, ipropPicHGoal,
  575.               ipropWBMWidthBytes, ipropWBMBitsPixel, ipropWBMPlanes, ipropPictureType,
  576.               ipropMetafile, ipropPicBmp,
  577.               // objects
  578.               ipropObjType, ipropObjWidth, ipropObjHeight,
  579.               // lists
  580.               ipropPNLevel, ipropPNHanging, ipropPNType,
  581.               ipropPNBold, ipropPNItalic, ipropPNUnderline, ipropPNStrike,
  582.               ipropPNColor, ipropPNF, ipropPNFontSize, ipropPNIndent, ipropPNSp,
  583.               ipropPNAlign, ipropPNStart, ipropPNSecLvl,
  584.               // new lists
  585.               ipropListId, ipropListTemplateId, ipropListSimple, ipropListName,
  586.               ipropLevelStartAt, ipropLevelNumberType, ipropLevelJustify, ipropLevelOld,
  587.               ipropLevelIndent, ipropLevelSpace, ipropLevelFollow,
  588.               ipropLevelLegal, ipropLevelNoRestart, ipropLOCount, ipropLONumber,
  589.               ipropLOStart, ipropLevel,
  590.               // tables
  591.               ipropRowEnd, ipropCellEnd, ipropInTbl, ipropItap,
  592.               ipropTRowD, ipropRowAlign, ipropTRGapH, ipropTRLeft, ipropTRRowHeight,
  593.               ipropTRHeader, ipropTRPaddL, ipropTRPaddR, ipropTRPaddT, ipropTRPaddB,
  594.               ipropTRPaddFL, ipropTRPaddFR, ipropTRPaddFT, ipropTRPaddFB,
  595.               ipropTRSpdL, ipropTRSpdR, ipropTRSpdT, ipropTRSpdB,
  596.               ipropTRSpdFL, ipropTRSpdFR, ipropTRSpdFT, ipropTRSpdFB,
  597.               ipropTRwWidth, ipropTRftsWidth,
  598.               ipropCLVMerge, ipropCLHMerge,
  599.               ipropCLwWidth, ipropCLftsWidth, ipropCLColor, ipropCLFColor, ipropCLShading,ipropCLVertAl,
  600.               ipropCellX, ipropTRBorderSide, ipropCLBorderSide, ipropNoTableEv,
  601.               ipropNoResetLev,
  602.               {$IFDEF RICHVIEW}
  603.               ipropRVCellBestWidth,ipropRVCellBestHeight,ipropRVTableBestWidth,
  604.               {$ENDIF}
  605.               ipropMax);
  606. //----------------------------------------------------------------------
  607.     TRTFACTN = (actnSpec, actnByte, actnWord);
  608. //----------------------------------------------------------------------
  609.     TRTFPROPTYPE = (propChp, propPap, propSep, propDop);
  610. //----------------------------------------------------------------------
  611.     TRTFpropmod = record
  612.       actn: TRTFACTN;       // size of value
  613.       prop: TRTFPROPTYPE;   // structure containing value
  614.       offset: Integer;      // offset of value from base of structure
  615.     end; //PROP;
  616. //----------------------------------------------------------------------
  617.     TRTFIPFN = ( ipfnBin, ipfnHex, ipfnSkipDest );
  618. //----------------------------------------------------------------------
  619.     TRTFIDEST = ( idestShpPict, idestNonShpPict,
  620.                   idestPict, idestSkip,  idestFontTable,  idestStyleSheet, idestColorTable,
  621.                   idestStyleSheetParaStyle, idestStyleSheetCharStyle, idestStyleSheetSectStyle,
  622.                   idestField, idestFldInst, idestFldRslt,
  623.                   idestNestedTableProps, idestHeader, idestFooter,
  624.                   idestPNTextAfter, idestPNTextBefore,
  625.                   idestPN, idestPNSecLvl,
  626.                   idestListTable, idestList, idestListName, idestListLevel,
  627.                   idestLevelText, idestLevelNumbers, idestLOTable, idestLO, idestLOLevel,
  628.                   idestObject, idestObjData, idestObjResult);
  629. //----------------------------------------------------------------------
  630.     TRVRTFKeywordType = ( rtf_kwd_Char, rtf_kwd_WideChar, rtf_kwd_Dest, rtf_kwd_Prop, rtf_kwd_Spec );
  631. //----------------------------------------------------------------------
  632.     TRVRTFKeywordAffect = (rtf_af_None, rtf_af_CharProp, rtf_af_ParaProp,
  633.                            rtf_af_BothProp);
  634.     TRVRTFsymbol = record
  635.       Keyword: String;    // RTF keyword
  636.       DefValue: Integer;  // default value to use
  637.       UseDef: Boolean;    // true to use default value from this table
  638.       Kwd: TRVRTFKeywordType; // base action to take
  639.       Idx: Integer;       // index into property table    if Kwd == trf_kwd_Prop
  640.                           // index into destination table if Kwd == trf_kwd_Dest
  641.                           // character to print           if Kwd == trf_kwd_Char
  642.       AffectTo: TRVRTFKeywordAffect;
  643.     end;
  644.     PRVRTFsymbol = ^TRVRTFsymbol;
  645.     {----------------------------------------------------------------------}
  646.     // RTF Style Sheet
  647.     TRVRTFStyleSheetType = (rtf_sst_Char, rtf_sst_Par, rtf_sst_Sect);
  648.     TRVRTFReaderState = class;
  649.     TRVRTFStyleSheetEntry = class
  650.       private
  651.         FParaProps: TRVRTFParaProperties;
  652.         FCharProps: TRVRTFCharProperties;
  653.         FAdditive, FHidden: Boolean;
  654.         FNumber:  Integer;
  655.         FStyleType: TRVRTFStyleSheetType;
  656.         FBasedOn, FNext:  TRVRTFStyleSheetEntry;
  657.         FName: String;
  658.       public
  659.         constructor Create;
  660.         destructor Destroy; override;
  661.         procedure Assign(Source:TRVRTFReaderState);
  662.         property ParaProps: TRVRTFParaProperties  read FParaProps;
  663.         property CharProps: TRVRTFCharProperties  read FCharProps;
  664.         property Additive : Boolean               read FAdditive;
  665.         property Hidden   : Boolean               read FHidden;
  666.         property Number   : Integer               read FNumber;
  667.         property StyleType: TRVRTFStyleSheetType  read FStyleType;
  668.         property BasedOn  : TRVRTFStyleSheetEntry read FBasedOn;
  669.         property Next     : TRVRTFStyleSheetEntry read FNext;
  670.         property Name     : String                read FName;
  671.     end;
  672.     TRVRTFStyleSheet = class (TRVList)
  673.       private
  674.         function Get(Index: Integer): TRVRTFStyleSheetEntry;
  675.         procedure Put(Index: Integer; const Value: TRVRTFStyleSheetEntry);
  676.         procedure AddPara(Number: Integer);
  677.       public
  678.         function GetEntry(Number: Integer): TRVRTFStyleSheetEntry;
  679.         property Items[Index: Integer]: TRVRTFStyleSheetEntry read Get write Put; default;
  680.     end;
  681.     {----------------------------------------------------------------------}
  682.     // RTF font table
  683.     TRVRTFFontFamily = (rtf_ff_Default, rtf_ff_Roman, rtf_ff_Swiss,
  684.                         rtf_ff_Modern, rtf_ff_Script, rtf_ff_Decorative,
  685.                         rtf_ff_Symbol, rtf_ff_BiDi);
  686.     TRVRTFFont = class
  687.       public
  688.         Number: Integer;
  689.         Name: String;
  690.         Family: TRVRTFFontFamily;
  691.         {$IFDEF RICHVIEWCBDEF3}
  692.         Charset: TFontCharset;
  693.         {$ENDIF}
  694.         constructor Create;
  695.     end;
  696.     TRVRTFFontList = class (TRVList)
  697.       private
  698.         function Get(Index: Integer): TRVRTFFont;
  699.         procedure Put(Index: Integer; const Value: TRVRTFFont);
  700.         procedure RemoveChasetFromNames;
  701.       public
  702.         function GetFontIndex(Number, Default: Integer): Integer;
  703.         procedure Add(Number: Integer);
  704.         property Items[Index: Integer]: TRVRTFFont read Get write Put; default;
  705.     end;
  706.     {----------------------------------------------------------------------}
  707.     // RTF color table
  708.     TRVRTFColorList = class (TList)
  709.       private
  710.         function Get(Index: Integer): TColor;
  711.         procedure Put(Index: Integer; const Value: TColor);
  712.         procedure ResetLast;
  713.         procedure SetLastRed(Value: Integer);
  714.         procedure SetLastGreen(Value: Integer);
  715.         procedure SetLastBlue(Value: Integer);
  716.         procedure Finalize;
  717.       public
  718.         procedure Add;
  719.         property Items[Index: Integer]: TColor read Get write Put; default;
  720.     end;
  721. {------------------------------------------------------------------------------}
  722.     TRVRTFCurrentBorderType = (rtf_bt_Para, rtf_bt_Row, rtf_bt_Cell);
  723.     TRVRTFReaderState =  class
  724.       private
  725.         FDefLanguage: Cardinal;
  726.         FCharProps: TRVRTFCharProperties;
  727.         FParaProps: TRVRTFParaProperties;
  728.         FSectProps: TRVRTFSectionProperties;
  729.         FDocProps:  TRVRTFDocProperties;
  730.         FRowProps:  TRVRTFRowProperties;
  731.         FCurrentBorderType: TRVRTFCurrentBorderType;
  732.         rds: TRTFrds;
  733.         ris: TRTFris;
  734.         FFieldCode: String;
  735.         FFieldPictureIncluded: Boolean;
  736.         FInvalidFieldPicture: TGraphic;
  737.         DefFontNumber, DefFontIndex: Integer;
  738.         FHFType: TRVRTFHeaderFooterType;
  739.         procedure ChangeFontStyle(fs: TFontStyle; Val: Integer);
  740.         procedure ChangeFontStyleEx(fs: TRVRTFFontStyleEx; Val: Integer);
  741.         function GetRowProps: TRVRTFRowProperties;
  742.         function GetCurrentBorderSide: TRVRTFBorderSide;
  743.       public
  744.         constructor Create;
  745.         destructor Destroy; override;
  746.         procedure Assign(Source: TRVRTFReaderState);
  747.         procedure Reset;
  748.         property ParaProps: TRVRTFParaProperties    read FParaProps;
  749.         property CharProps: TRVRTFCharProperties    read FCharProps;
  750.         property SectProps: TRVRTFSectionProperties read FSectProps;
  751.         property DocProps:  TRVRTFDocProperties     read FDocProps;
  752.         property RowProps:  TRVRTFRowProperties     read GetRowProps;
  753.         property FieldCode: String                  read FFieldCode;
  754.         property DefLanguage: Cardinal              read FDefLanguage;
  755.     end;
  756. {------------------------------------------------------------------------------}
  757.     TRVRTFReader  = class(TComponent)
  758.       private
  759.         Stream: TStream;
  760.         StreamSize,InputStringIndex: Integer;
  761.         Text,InputString: String;
  762.         {$IFDEF RICHVIEWCBDEF3}
  763.         TextW: WideString;
  764.         {$ENDIF}
  765.         LastChar: Char;
  766.         UseLastChar: Boolean;
  767.         FOnNewText: TRVRTFNewTextEvent;
  768.         FOnHeaderFooter: TRVRTFHeaderFooterEvent;
  769.         FOnImportPicture: TRVRTFImportPictureEvent;
  770.         {$IFDEF RICHVIEWCBDEF3}
  771.         FOnNewUnicodeText: TRVRTFNewUnicodeTextEvent;
  772.         {$ENDIF}
  773.         FOnNewPicture: TRVRTFNewPictureEvent;
  774.         FOnNewObject: TRVRTFNewObjectEvent;
  775.         FOnTable: TRVRTFTableEvent;
  776.         FStyleSheet: TRVRTFStyleSheet;
  777.         FFontTable:  TRVRTFFontList;
  778.         FColorTable: TRVRTFColorList;
  779.         FListTable: TRVRTFListTable97;
  780.         FListOverrideTable: TRVRTFListOverrideTable97;
  781.         FRTFState: TRVRTFReaderState;
  782.         FPicture: TRVRTFPicture;
  783.         FObject: TRVRTFObject;
  784.         FMarkerProps: TRVRTFMarkerProperties;
  785.         FDefCodePage, FCodePage: Cardinal;
  786.         SkipAnsiCount, SkipNext: Integer;
  787.         FOnRequiredPageBreak: TNotifyEvent;
  788.         CurrentNestingLevel: Integer;
  789.         FConvertHighlight: TRVRTFHighlightConvert;
  790.         FOnUpdateMarker: TNotifyEvent;
  791.         FCurPNSecLvl: Integer;
  792.         FBasePath: String;
  793.         FOnProgress: TRVRTFProgressEvent;
  794.         FCallProgress: Boolean;
  795.         ShpPictInserted, ObjectInserted: Boolean;
  796.         FExtractMetafileBitmaps: Boolean;
  797.         FOnEndParsing: TNotifyEvent;
  798.         FPixelsPerInch: Integer;
  799.         FTabAsSeparateChar: Boolean;
  800.         function FindKeyword(const Keyword: String): Integer;
  801.       protected
  802.         ForceEvenEmptyNewLine: Boolean;
  803.         Position: TRVRTFPosition;
  804.         cGroup: Integer;
  805.         SaveList: TRVList;
  806.         cbBin,
  807.         lParam: LongInt;
  808.         PicHexVal: Byte;
  809.         PicHexStrt: Boolean;
  810.         fSkipDestIfUnk: Boolean;
  811.         fpIn: TextFile;
  812.         function EndGroupAction(rds: TRTFrds): TRVRTFErrorCode;
  813.         function TranslateKeyword(const Keyword: String; param: Integer; fParam:Boolean): TRVRTFErrorCode;
  814.         function ParseSpecialProperty(iprop: TRTFiprop; val: Integer): TRVRTFErrorCode;
  815.         function ChangeDest(idest:  TRTFidest; Val: Integer): TRVRTFErrorCode;
  816.         function ParseSpecialKeyword(ipfn:TRTFIPFN): TRVRTFErrorCode;
  817.         function ApplyPropChange(iprop: TRTFiprop; val: Integer): TRVRTFErrorCode;
  818.         function ApplyPropChange_SSEntry(iprop: TRTFiprop; val: Integer): TRVRTFErrorCode;
  819.         function ApplyPropChange_Picture(iprop: TRTFiprop; val: Integer): TRVRTFErrorCode;
  820.         function ApplyPropChange_Object(iprop: TRTFiprop; val: Integer): TRVRTFErrorCode;
  821.         function ApplyPropChange_PN(iprop: TRTFiprop; val: Integer): TRVRTFErrorCode;
  822.         function ApplyPropChange_List(iprop: TRTFiprop; val: Integer): TRVRTFErrorCode;
  823.         function ApplyPropChange_ListLevel(iprop: TRTFiprop; val: Integer): TRVRTFErrorCode;
  824.         function ApplyPropChange_LO(iprop: TRTFiprop; val: Integer): TRVRTFErrorCode;
  825.         function ApplyPropChange_LOLevel(iprop: TRTFiprop; val: Integer): TRVRTFErrorCode;
  826.         function Parse: TRVRTFErrorCode;
  827.         {$IFDEF RVUSEWORDDOC}
  828.         function ParseWordDocFile(const AFileName: String): TRVRTFErrorCode;
  829.         {$ENDIF}
  830.         function PushRtfState: TRVRTFErrorCode;
  831.         function PopRtfState: TRVRTFErrorCode;
  832.         function ParseRtfKeyword: TRVRTFErrorCode;
  833.         function ParseChar(ch: Char): TRVRTFErrorCode;
  834.         procedure UpdateMarker;
  835.         function FlushOutput(var NextPosition: TRVRTFPosition): TRVRTFErrorCode;
  836.         function OutputChar(ch: Char; ACheckTableEnd, ACheckTable: Boolean): TRVRTFErrorCode;
  837.         function InsertExternalPicture: TRVRTFErrorCode;
  838.         function InsertSymbol: TRVRTFErrorCode;
  839.         {$IFDEF RICHVIEWCBDEF3}
  840.         function OutputWideChar(ch: WideChar): TRVRTFErrorCode;
  841.         {$ENDIF}
  842.         procedure UngetC;
  843.         function GetC: Char;
  844.         function IsEOF: Boolean;
  845.         function DoNewText(Position: TRVRTFPosition; var NextPosition: TRVRTFPosition): TRVRTFErrorCode;
  846.         function DoNewPicture(gr: TGraphic; var Inserted: Boolean): TRVRTFErrorCode;
  847.         function DoNewObject: TRVRTFErrorCode;
  848.         procedure DoTable(WhatHappens: TRVRTFTableEventKind);
  849.         procedure CheckTable(AllowEnd: Boolean);
  850.       public
  851.         FTableAlignment: TRVRTFAlignment;
  852.         FTableAlignmentDefined: Boolean;
  853.         constructor Create(AOwner: TComponent); override;
  854.         destructor Destroy; override;
  855.         function GetFieldCommandValue(const s: String): String;
  856.         function GetFieldCommandValueEx(const s: String;
  857.           var NextCharIndex: Integer): String;
  858.         procedure Clear;
  859.         function ReadFromStream(AStream: TStream): TRVRTFErrorCode;
  860.         function ReadFromFile(const AFileName: String): TRVRTFErrorCode;
  861.         {$IFDEF RVUSEWORDDOC}
  862.         function ReadFromWordDocFile(const AFileName: String): TRVRTFErrorCode;
  863.         {$ENDIF}
  864.         {$IFDEF RICHVIEWCBDEF3}
  865.         function AnsiToUnicode(const s: String; CodePage: Cardinal): WideString;
  866.         function UnicodeToAnsi(const s: WideString): String;
  867.         {$ENDIF}
  868.         property StyleSheet: TRVRTFStyleSheet read FStyleSheet;
  869.         property FontTable:  TRVRTFFontList read FFontTable;
  870.         property ColorTable: TRVRTFColorList read FColorTable;
  871.         property ListTable: TRVRTFListTable97 read FListTable;
  872.         property ListOverrideTable: TRVRTFListOverrideTable97 read FListOverrideTable;
  873.         property RTFState: TRVRTFReaderState read FRTFState;
  874.         property BasePath: String read FBasePath write FBasePath;
  875.         property TabAsSeparateChar: Boolean read FTabAsSeparateChar write FTabAsSeparateChar;
  876.         property CodePage: Cardinal read FCodePage;
  877.       published
  878.         property OnNewText: TRVRTFNewTextEvent read FOnNewText write FOnNewText;
  879.         {$IFDEF RICHVIEWCBDEF3}
  880.         property OnNewUnicodeText: TRVRTFNewUnicodeTextEvent
  881.           read FOnNewUnicodeText write FOnNewUnicodeText;
  882.         {$ENDIF}
  883.         property OnNewPicture: TRVRTFNewPictureEvent read FOnNewPicture write FOnNewPicture;
  884.         property OnNewObject: TRVRTFNewObjectEvent read FOnNewObject write FOnNewObject;
  885.         property OnUpdateMarker: TNotifyEvent read FOnUpdateMarker write FOnUpdateMarker;
  886.         property OnTable: TRVRTFTableEvent read FOnTable write FOnTable;
  887.         property OnRequiredPageBreak: TNotifyEvent read FOnRequiredPageBreak write FOnRequiredPageBreak;
  888.         property OnHeaderFooter: TRVRTFHeaderFooterEvent read FOnHeaderFooter write FOnHeaderFooter;
  889.         property OnImportPicture: TRVRTFImportPictureEvent read FOnImportPicture write FOnImportPicture;
  890.         property DefCodePage: Cardinal  read FDefCodePage write FDefCodePage default CP_ACP;
  891.         property ConvertHighlight: TRVRTFHighlightConvert read FConvertHighlight write FConvertHighlight default rtf_hl_FixedColors;
  892.         property OnProgress: TRVRTFProgressEvent read FOnProgress write FOnProgress;
  893.         property ExtractMetafileBitmaps: Boolean read FExtractMetafileBitmaps write FExtractMetafileBitmaps default True;
  894.         property PixelsPerInch: Integer read FPixelsPerInch write FPixelsPerInch default 0;
  895.         property OnEndParsing: TNotifyEvent read FOnEndParsing write FOnEndParsing;
  896.     end;
  897. {$IFNDEF RICHVIEW}
  898. type
  899.   TRV_CreateGraphicsFunction = function (GraphicClass: TGraphicClass): TGraphic;
  900.   TRV_AfterImportGraphicsProc = procedure(Graphic: TGraphic);
  901. var
  902.   RV_CreateGraphics: TRV_CreateGraphicsFunction;
  903.   RV_AfterImportGraphic: TRV_AfterImportGraphicsProc;
  904. {$ENDIF}
  905. implementation
  906. // Keyword descriptions
  907. const
  908.  isymMax = 342{$IFDEF RICHVIEW}+3{$ENDIF};
  909.  rgsymRtf:array[0..isymMax] of TRVRTFsymbol = (
  910.     (Keyword:'object';   DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestObject);   AffectTo:rtf_af_None),
  911.     (Keyword:'objemb';     DefValue:ord(rtf_obj_Emb);     UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropObjType); AffectTo:rtf_af_None),
  912.     (Keyword:'objlink';    DefValue:ord(rtf_obj_Link);    UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropObjType); AffectTo:rtf_af_None),
  913.     (Keyword:'objautlink'; DefValue:ord(rtf_obj_AutLink); UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropObjType); AffectTo:rtf_af_None),
  914.     (Keyword:'objsub';     DefValue:ord(rtf_obj_Sub);     UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropObjType); AffectTo:rtf_af_None),
  915.     (Keyword:'objpub';     DefValue:ord(rtf_obj_Pub);     UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropObjType); AffectTo:rtf_af_None),
  916.     (Keyword:'objicemb';   DefValue:ord(rtf_obj_ICEmb);   UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropObjType); AffectTo:rtf_af_None),
  917.     (Keyword:'objhtml';    DefValue:ord(rtf_obj_HTML);    UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropObjType); AffectTo:rtf_af_None),
  918.     (Keyword:'objocx';     DefValue:ord(rtf_obj_OCX);     UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropObjType); AffectTo:rtf_af_None),
  919.     (Keyword:'objh';       DefValue:0;          UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropObjHeight);       AffectTo:rtf_af_None),
  920.     (Keyword:'objw';       DefValue:0;          UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropObjWidth);        AffectTo:rtf_af_None),
  921.     (Keyword:'objdata';    DefValue:0;          UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestObjData);         AffectTo:rtf_af_None),
  922.     (Keyword:'result';     DefValue:0;          UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestObjResult);       AffectTo:rtf_af_None),
  923.     (Keyword:'shppict';  DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestShpPict);   AffectTo:rtf_af_None),
  924.     (Keyword:'nonshppict'; DefValue:0;          UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestNonShpPict); AffectTo:rtf_af_None),
  925.     (Keyword:'b';        DefValue:1;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropBold);      AffectTo:rtf_af_CharProp),
  926.     (Keyword:'ul';       DefValue:1;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropUnderline); AffectTo:rtf_af_CharProp),
  927.     (Keyword:'ulnone';   DefValue:0;            UseDef:True;   kwd:rtf_kwd_Prop; idx:ord(ipropUnderline); AffectTo:rtf_af_CharProp),
  928.     (Keyword:'i';        DefValue:1;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropItalic);    AffectTo:rtf_af_CharProp),
  929.     (Keyword:'strike';   DefValue:1;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropStrike);    AffectTo:rtf_af_CharProp),
  930.     (Keyword:'fs';       DefValue:24;           UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropFontSize);  AffectTo:rtf_af_CharProp),
  931.     (Keyword:'lang';     DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropLanguage);  AffectTo:rtf_af_CharProp),
  932.     (Keyword:'deflang';  DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropDefLanguage); AffectTo:rtf_af_None),
  933.     (Keyword:'cf';       DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropTextColor); AffectTo:rtf_af_CharProp),
  934.     (Keyword:'chcbpat';  DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropTextBackColor); AffectTo:rtf_af_CharProp),
  935.     (Keyword:'cbpat';    DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropParaColor); AffectTo:rtf_af_ParaProp),
  936.     (Keyword:'cfpat';    DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropParaFColor); AffectTo:rtf_af_ParaProp),
  937.     (Keyword:'shading';  DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropParaShading); AffectTo:rtf_af_ParaProp),
  938.     (Keyword:'li';       DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropLeftInd);   AffectTo:rtf_af_ParaProp),
  939.     (Keyword:'ri';       DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropRightInd);  AffectTo:rtf_af_ParaProp),
  940.     (Keyword:'fi';       DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropFirstInd);  AffectTo:rtf_af_ParaProp),
  941.     (Keyword:'plain';    DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropPlain);     AffectTo:rtf_af_CharProp),
  942.     (Keyword:'u';        DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropU);         AffectTo:rtf_af_None),
  943.     (Keyword:'uc';       DefValue:1;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropUC);        AffectTo:rtf_af_None),
  944.     (Keyword:'cols';     DefValue:1;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropCols);      AffectTo:rtf_af_None),
  945.     (Keyword:'sbknone';  DefValue:ord(rtf_sbk_None);   UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropSbk);  AffectTo:rtf_af_None),
  946.     (Keyword:'sbkcol';   DefValue:ord(rtf_sbk_Column); UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropSbk);  AffectTo:rtf_af_None),
  947.     (Keyword:'sbkeven';  DefValue:ord(rtf_sbk_Even);   UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropSbk);  AffectTo:rtf_af_None),
  948.     (Keyword:'sbkodd';   DefValue:ord(rtf_sbk_Odd);    UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropSbk);  AffectTo:rtf_af_None),
  949.     (Keyword:'sbkpage';  DefValue:ord(rtf_sbk_Page);   UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropSbk);  AffectTo:rtf_af_None),
  950.     (Keyword:'pgnx';     DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropPgnX);      AffectTo:rtf_af_None),
  951.     (Keyword:'pgny';     DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropPgnY);      AffectTo:rtf_af_None),
  952.     (Keyword:'pgndec';   DefValue:ord(rtf_pg_Decimal);     UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropPgnFormat); AffectTo:rtf_af_None),
  953.     (Keyword:'pgnucrm';  DefValue:ord(rtf_pg_UpperRoman);  UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropPgnFormat); AffectTo:rtf_af_None),
  954.     (Keyword:'pgnlcrm';  DefValue:ord(rtf_pg_LowerRoman);  UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropPgnFormat); AffectTo:rtf_af_None),
  955.     (Keyword:'pgnucltr'; DefValue:ord(rtf_pg_UpperLetter); UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropPgnFormat); AffectTo:rtf_af_None),
  956.     (Keyword:'pgnlcltr'; DefValue:ord(rtf_pg_LowerLetter); UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropPgnFormat); AffectTo:rtf_af_None),
  957.     (Keyword:'qc';       DefValue:ord(rtf_al_Center);  UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropJust); AffectTo:rtf_af_ParaProp),
  958.     (Keyword:'ql';       DefValue:ord(rtf_al_Left);    UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropJust); AffectTo:rtf_af_ParaProp),
  959.     (Keyword:'qr';       DefValue:ord(rtf_al_Right);   UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropJust); AffectTo:rtf_af_ParaProp),
  960.     (Keyword:'qj';       DefValue:ord(rtf_al_Justify); UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropJust); AffectTo:rtf_af_ParaProp),
  961.     (Keyword:'paperw';   DefValue:12240;        UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropXaPage);    AffectTo:rtf_af_None),
  962.     (Keyword:'paperh';   DefValue:15480;        UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropYaPage);    AffectTo:rtf_af_None),
  963.     (Keyword:'margl';    DefValue:1800;         UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropXaLeft);    AffectTo:rtf_af_None),
  964.     (Keyword:'margr';    DefValue:1800;         UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropXaRight);   AffectTo:rtf_af_None),
  965.     (Keyword:'margt';    DefValue:1440;         UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropYaTop);     AffectTo:rtf_af_None),
  966.     (Keyword:'margb';    DefValue:1440;         UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropYaBottom);  AffectTo:rtf_af_None),
  967.     (Keyword:'headery';  DefValue:720;          UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropHeaderY);   AffectTo:rtf_af_None),
  968.     (Keyword:'footery';  DefValue:720;          UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropFooterY);   AffectTo:rtf_af_None),    
  969.     (Keyword:'pgnstart'; DefValue:1;            UseDef:False;   kwd:rtf_kwd_Prop; idx:ord(ipropPgnStart);  AffectTo:rtf_af_None),
  970.     (Keyword:'facingp';  DefValue:1;            UseDef:True;   kwd:rtf_kwd_Prop; idx:ord(ipropFacingp);   AffectTo:rtf_af_None),
  971.     (Keyword:'landscape';DefValue:1;            UseDef:True;   kwd:rtf_kwd_Prop; idx:ord(ipropLandscape); AffectTo:rtf_af_None),
  972.     (Keyword:'par';      DefValue:0;            UseDef:False;  kwd:rtf_kwd_Char; idx:$0a;                 AffectTo:rtf_af_None),
  973.     (Keyword:'cell';     DefValue:0;            UseDef:True;   kwd:rtf_kwd_Prop; idx:ord(ipropCellEnd);   AffectTo:rtf_af_None),
  974.     (Keyword:'row';      DefValue:0;            UseDef:True;   kwd:rtf_kwd_Prop; idx:ord(ipropRowEnd);    AffectTo:rtf_af_None),
  975.     (Keyword:'nestcell'; DefValue:1;            UseDef:True;   kwd:rtf_kwd_Prop; idx:ord(ipropCellEnd);   AffectTo:rtf_af_None),
  976.     (Keyword:'nestrow';  DefValue:1;            UseDef:True;   kwd:rtf_kwd_Prop; idx:ord(ipropRowEnd);    AffectTo:rtf_af_None),
  977.     (Keyword:'nesttableprops'; DefValue:0;     UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestNestedTableProps); AffectTo:rtf_af_None),
  978.     (Keyword:'intbl';    DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropInTbl);     AffectTo:rtf_af_None),
  979.     (Keyword:'itap';     DefValue:1;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropItap);      AffectTo:rtf_af_None),
  980.     (Keyword:'nonesttables'; DefValue:0;        UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestSkip);      AffectTo:rtf_af_None),
  981.     (Keyword:'pard';     DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropParD);      AffectTo:rtf_af_ParaProp),
  982.     (Keyword: #10;       DefValue:0;            UseDef:False;  kwd:rtf_kwd_Char; idx:$0A;                 AffectTo:rtf_af_None),
  983.     (Keyword: #13;       DefValue:0;            UseDef:False;  kwd:rtf_kwd_Char; idx:$0A;                 AffectTo:rtf_af_None),
  984.     (Keyword:'line';     DefValue:0;            UseDef:False;  kwd:rtf_kwd_Char; idx:$0D;                 AffectTo:rtf_af_None),
  985.     (Keyword:'tab';      DefValue:0;            UseDef:False;  kwd:rtf_kwd_Char; idx:$09;                 AffectTo:rtf_af_None),
  986.     (Keyword:'~';        DefValue:0;            UseDef:False;  kwd:rtf_kwd_Char; idx:$A0;                 AffectTo:rtf_af_None),
  987.     (Keyword:'bullet';   DefValue:0;            UseDef:False;  kwd:rtf_kwd_Char; idx:$95;                 AffectTo:rtf_af_None),
  988.     (Keyword:'ldblquote';DefValue:$201C;        UseDef:False;  kwd:rtf_kwd_WideChar; idx:$93;             AffectTo:rtf_af_None),
  989.     (Keyword:'rdblquote';DefValue:$201D;        UseDef:False;  kwd:rtf_kwd_WideChar; idx:$94;             AffectTo:rtf_af_None),
  990.     (Keyword:'lquote';   DefValue:$2018;        UseDef:False;  kwd:rtf_kwd_WideChar; idx:$91;             AffectTo:rtf_af_None),
  991.     (Keyword:'rquote';   DefValue:$2019;        UseDef:False;  kwd:rtf_kwd_WideChar; idx:$92;             AffectTo:rtf_af_None),
  992.     (Keyword:'endash';   DefValue:$2013;        UseDef:False;  kwd:rtf_kwd_WideChar; idx:$96;             AffectTo:rtf_af_None),
  993.     (Keyword:'emdash';   DefValue:$2014;        UseDef:False;  kwd:rtf_kwd_WideChar; idx:$97;             AffectTo:rtf_af_None),
  994.     (Keyword:'emspace';  DefValue:$2003;        UseDef:False;  kwd:rtf_kwd_WideChar; idx:ord(' ');        AffectTo:rtf_af_None),
  995.     (Keyword:'enspace';  DefValue:$2002;        UseDef:False;  kwd:rtf_kwd_WideChar; idx:ord(' ');        AffectTo:rtf_af_None),
  996.     (Keyword:'qmspace';  DefValue:$2005;        UseDef:False;  kwd:rtf_kwd_WideChar; idx:ord(' ');        AffectTo:rtf_af_None),
  997.     (Keyword:'-';        DefValue:$00AD;        UseDef:False;  kwd:rtf_kwd_WideChar; idx:$AD;             AffectTo:rtf_af_None),    
  998.     (Keyword:'bin';      DefValue:0;            UseDef:False;  kwd:rtf_kwd_Spec; idx:ord(ipfnBin);        AffectTo:rtf_af_None),
  999.     (Keyword:'*';        DefValue:0;            UseDef:False;  kwd:rtf_kwd_Spec; idx:ord(ipfnSkipDest);   AffectTo:rtf_af_None),
  1000.     (Keyword:'''';       DefValue:0;            UseDef:False;  kwd:rtf_kwd_Spec; idx:ord(ipfnHex);        AffectTo:rtf_af_None),
  1001.     (Keyword:'author';   DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestSkip);      AffectTo:rtf_af_None),
  1002.     (Keyword:'buptim';   DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestSkip);      AffectTo:rtf_af_None),
  1003.     (Keyword:'colortbl'; DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestColorTable);AffectTo:rtf_af_None),
  1004.     (Keyword:'comment';  DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestSkip);      AffectTo:rtf_af_None),
  1005.     (Keyword:'creatim';  DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestSkip);      AffectTo:rtf_af_None),
  1006.     (Keyword:'doccomm';  DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestSkip);      AffectTo:rtf_af_None),
  1007.     (Keyword:'fonttbl';  DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestFontTable); AffectTo:rtf_af_None),
  1008.     (Keyword:'footer';   DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestFooter);    AffectTo:rtf_af_None),
  1009.     (Keyword:'footerf';  DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestSkip);      AffectTo:rtf_af_None),
  1010.     (Keyword:'footerl';  DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestSkip);      AffectTo:rtf_af_None),
  1011.     (Keyword:'footerr';  DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestSkip);      AffectTo:rtf_af_None),
  1012.     {$IFDEF RVTEXTFOOTNOTES}
  1013.     (Keyword:'footnote'; DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropFootNote);  AffectTo:rtf_af_CharProp),
  1014.     {$ELSE}
  1015.     (Keyword:'footnote'; DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestSkip);      AffectTo:rtf_af_None),
  1016.     {$ENDIF}
  1017.     (Keyword:'ftncn';    DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestSkip);      AffectTo:rtf_af_None),
  1018.     (Keyword:'ftnsep';   DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestSkip);      AffectTo:rtf_af_None),
  1019.     (Keyword:'ftnsepc';  DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestSkip);      AffectTo:rtf_af_None),
  1020.     (Keyword:'header';   DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestHeader);    AffectTo:rtf_af_None),
  1021.     (Keyword:'headerf';  DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestSkip);      AffectTo:rtf_af_None),
  1022.     (Keyword:'headerl';  DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestSkip);      AffectTo:rtf_af_None),
  1023.     (Keyword:'headerr';  DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestSkip);      AffectTo:rtf_af_None),
  1024.     (Keyword:'info';     DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestSkip);      AffectTo:rtf_af_None),
  1025.     (Keyword:'keywords'; DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestSkip);      AffectTo:rtf_af_None),
  1026.     (Keyword:'operator'; DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestSkip);      AffectTo:rtf_af_None),
  1027.     (Keyword:'printim';  DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestSkip);      AffectTo:rtf_af_None),
  1028.     (Keyword:'private1'; DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestSkip);      AffectTo:rtf_af_None),
  1029.     (Keyword:'revtim';   DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestSkip);      AffectTo:rtf_af_None),
  1030.     (Keyword:'rxe';      DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestSkip);      AffectTo:rtf_af_None),
  1031.     (Keyword:'stylesheet';DefValue:0;           UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestStyleSheet);AffectTo:rtf_af_None),
  1032.     (Keyword:'subject';  DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestSkip);      AffectTo:rtf_af_None),
  1033.     (Keyword:'tc';       DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestSkip);      AffectTo:rtf_af_None),
  1034.     (Keyword:'title';    DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestSkip);      AffectTo:rtf_af_None),
  1035.     (Keyword:'txe';      DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestSkip);      AffectTo:rtf_af_None),
  1036.     (Keyword:'xe';       DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestSkip);      AffectTo:rtf_af_None),
  1037.     (Keyword:'pict';     DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestPict);      AffectTo:rtf_af_None),
  1038.     (Keyword:'{';        DefValue:0;            UseDef:False;  kwd:rtf_kwd_Char; idx:ord('{');            AffectTo:rtf_af_None),
  1039.     (Keyword:'}';        DefValue:0;            UseDef:False;  kwd:rtf_kwd_Char; idx:ord('}');            AffectTo:rtf_af_None),
  1040.     (Keyword:'';        DefValue:0;            UseDef:False;  kwd:rtf_kwd_Char; idx:ord('');            AffectTo:rtf_af_None),
  1041.     (Keyword:'sectd';    DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropSectd);     AffectTo:rtf_af_None),
  1042.     (Keyword:'charscalex';DefValue:100;         UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropCharScaleX);AffectTo:rtf_af_CharProp),
  1043.     (Keyword:'expndtw';  DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropCharSpacing);AffectTo:rtf_af_CharProp),
  1044.     (Keyword:'caps';     DefValue:1;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropAllCaps);   AffectTo:rtf_af_CharProp),
  1045.     (Keyword:'sub';        DefValue:ord(rtf_ss_Subscript);   UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropSScript); AffectTo:rtf_af_CharProp),
  1046.     (Keyword:'super';      DefValue:ord(rtf_ss_Superscript); UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropSScript); AffectTo:rtf_af_CharProp),
  1047.     (Keyword:'nosupersub'; DefValue:ord(rtf_ss_Normal);      UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropSScript); AffectTo:rtf_af_CharProp),
  1048.     (Keyword:'f';        DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropF);         AffectTo:rtf_af_CharProp),
  1049.     (Keyword:'sb';       DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropSpaceBefore);AffectTo:rtf_af_ParaProp),
  1050.     (Keyword:'sa';       DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropSpaceAfter);AffectTo:rtf_af_ParaProp),
  1051.     (Keyword:'red';      DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropRed);       AffectTo:rtf_af_None),
  1052.     (Keyword:'green';    DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropGreen);     AffectTo:rtf_af_None),
  1053.     (Keyword:'blue';     DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropBlue);      AffectTo:rtf_af_None),
  1054.     (Keyword:'fnil';     DefValue:ord(rtf_ff_Default);    UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropFontFamily); AffectTo:rtf_af_None),
  1055.     (Keyword:'froman';   DefValue:ord(rtf_ff_Roman);      UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropFontFamily); AffectTo:rtf_af_None),
  1056.     (Keyword:'fswiss';   DefValue:ord(rtf_ff_Swiss);      UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropFontFamily); AffectTo:rtf_af_None),
  1057.     (Keyword:'fmodern';  DefValue:ord(rtf_ff_Modern);     UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropFontFamily); AffectTo:rtf_af_None),
  1058.     (Keyword:'fscript';  DefValue:ord(rtf_ff_Script);     UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropFontFamily); AffectTo:rtf_af_None),
  1059.     (Keyword:'fdecor';   DefValue:ord(rtf_ff_Decorative); UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropFontFamily); AffectTo:rtf_af_None),
  1060.     (Keyword:'ftech';    DefValue:ord(rtf_ff_Symbol);     UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropFontFamily); AffectTo:rtf_af_None),
  1061.     (Keyword:'fbidi';    DefValue:ord(rtf_ff_BiDi);       UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropFontFamily); AffectTo:rtf_af_None),
  1062.     (Keyword:'fcharset'; DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropFCharset);  AffectTo:rtf_af_CharProp),
  1063.     (Keyword:'v';        DefValue:1;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropHidden);    AffectTo:rtf_af_CharProp),
  1064.     (Keyword:'s';        DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropS);         AffectTo:rtf_af_None),
  1065.     (Keyword:'cs';       DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropCS);        AffectTo:rtf_af_None),
  1066.     (Keyword:'ds';       DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropDS);        AffectTo:rtf_af_None),
  1067.     (Keyword:'sbasedon'; DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropSBasedOn);  AffectTo:rtf_af_None),
  1068.     (Keyword:'snext';    DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(irpropSNext);    AffectTo:rtf_af_None),
  1069.     (Keyword:'additive'; DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropAdditive);  AffectTo:rtf_af_None),
  1070.     (Keyword:'shidden';  DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropSHidden);   AffectTo:rtf_af_None),
  1071.     (Keyword:'deff';     DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropDefF);      AffectTo:rtf_af_None),
  1072.     (Keyword:'sl';       DefValue:240;          UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropSL);        AffectTo:rtf_af_ParaProp),
  1073.     (Keyword:'slmult';   DefValue:1;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropSLMult);    AffectTo:rtf_af_ParaProp),
  1074.     (Keyword:'brdrnone';      DefValue:ord(rtf_brdr_None);               UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderType); AffectTo:rtf_af_ParaProp),    
  1075.     (Keyword:'brdrs';         DefValue:ord(rtf_brdr_SingleThickness);    UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderType); AffectTo:rtf_af_ParaProp),
  1076.     (Keyword:'brdrth';        DefValue:ord(rtf_brdr_DoubleThickness);    UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderType); AffectTo:rtf_af_ParaProp),
  1077.     (Keyword:'brdrsh';        DefValue:ord(rtf_brdr_Shadow);             UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderType); AffectTo:rtf_af_ParaProp),
  1078.     (Keyword:'brdrdb';        DefValue:ord(rtf_brdr_Double);             UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderType); AffectTo:rtf_af_ParaProp),
  1079.     (Keyword:'brdrdot';       DefValue:ord(rtf_brdr_Dot);                UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderType); AffectTo:rtf_af_ParaProp),
  1080.     (Keyword:'brdrdash';      DefValue:ord(rtf_brdr_Dash);               UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderType); AffectTo:rtf_af_ParaProp),
  1081.     (Keyword:'brdrhair';      DefValue:ord(rtf_brdr_Hairline);           UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderType); AffectTo:rtf_af_ParaProp),
  1082.     (Keyword:'brdrdashsm';    DefValue:ord(rtf_brdr_DashSmall);          UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderType); AffectTo:rtf_af_ParaProp),
  1083.     (Keyword:'brdrdashd';     DefValue:ord(rtf_brdr_DotDash);            UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderType); AffectTo:rtf_af_ParaProp),
  1084.     (Keyword:'brdrdashdd';    DefValue:ord(rtf_brdr_DotDotDash);         UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderType); AffectTo:rtf_af_ParaProp),
  1085.     (Keyword:'brdrtriple';    DefValue:ord(rtf_brdr_Triple);             UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderType); AffectTo:rtf_af_ParaProp),
  1086.     (Keyword:'brdrtnthsg';    DefValue:ord(rtf_brdr_ThickThinSmall);     UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderType); AffectTo:rtf_af_ParaProp),
  1087.     (Keyword:'brdrthtnsg';    DefValue:ord(rtf_brdr_ThinThickSmall);     UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderType); AffectTo:rtf_af_ParaProp),
  1088.     (Keyword:'brdrtnthtnsg';  DefValue:ord(rtf_brdr_ThinThickThinSmall); UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderType); AffectTo:rtf_af_ParaProp),
  1089.     (Keyword:'brdrtnthmg';    DefValue:ord(rtf_brdr_ThickThinMed);       UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderType); AffectTo:rtf_af_ParaProp),
  1090.     (Keyword:'brdrthtnmg';    DefValue:ord(rtf_brdr_ThinThickMed);       UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderType); AffectTo:rtf_af_ParaProp),
  1091.     (Keyword:'brdrtnthtnmg';  DefValue:ord(rtf_brdr_ThinThickThinMed);   UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderType); AffectTo:rtf_af_ParaProp),
  1092.     (Keyword:'brdrtnthlg';    DefValue:ord(rtf_brdr_ThickThinLarge);     UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderType); AffectTo:rtf_af_ParaProp),
  1093.     (Keyword:'brdrthtnlg';    DefValue:ord(rtf_brdr_ThinThickLarge);     UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderType); AffectTo:rtf_af_ParaProp),
  1094.     (Keyword:'brdrtnthtnlg';  DefValue:ord(rtf_brdr_ThinThickThinLarge); UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderType); AffectTo:rtf_af_ParaProp),
  1095.     (Keyword:'brdrwavy';      DefValue:ord(rtf_brdr_Wavy);               UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderType); AffectTo:rtf_af_ParaProp),
  1096.     (Keyword:'brdrwavydb';    DefValue:ord(rtf_brdr_DoubleWavy);         UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderType); AffectTo:rtf_af_ParaProp),
  1097.     (Keyword:'brdrdashdotstr';DefValue:ord(rtf_brdr_Striped);            UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderType); AffectTo:rtf_af_ParaProp),
  1098.     (Keyword:'brdremboss';    DefValue:ord(rtf_brdr_Emboss);             UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderType); AffectTo:rtf_af_ParaProp),
  1099.     (Keyword:'brdrengrave';   DefValue:ord(rtf_brdr_Emboss);             UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderType); AffectTo:rtf_af_ParaProp),
  1100.     (Keyword:'brdrinset';     DefValue:ord(rtf_brdr_Inset);              UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderType); AffectTo:rtf_af_ParaProp),
  1101.     (Keyword:'brdroutset';    DefValue:ord(rtf_brdr_Outset);             UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderType); AffectTo:rtf_af_ParaProp),
  1102.     (Keyword:'brdrl';    DefValue:ord(rtf_side_Left);  UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderSide); AffectTo:rtf_af_ParaProp),
  1103.     (Keyword:'brdrt';    DefValue:ord(rtf_side_Top);   UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderSide); AffectTo:rtf_af_ParaProp),
  1104.     (Keyword:'brdrr';    DefValue:ord(rtf_side_Right); UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderSide); AffectTo:rtf_af_ParaProp),
  1105.     (Keyword:'brdrb';    DefValue:ord(rtf_side_Bottom);UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderSide); AffectTo:rtf_af_ParaProp),
  1106.     (Keyword:'brdrw';    DefValue:1;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderWidth); AffectTo:rtf_af_ParaProp),
  1107.     (Keyword:'brdrcf';   DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderColor); AffectTo:rtf_af_ParaProp),
  1108.     (Keyword:'brsp';     DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropParaBorderSpace); AffectTo:rtf_af_ParaProp),
  1109.     (Keyword:'picw';     DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropPicW);      AffectTo:rtf_af_None),
  1110.     (Keyword:'pich';     DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropPicH);      AffectTo:rtf_af_None),
  1111.     (Keyword:'picwgoal'; DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropPicWGoal);  AffectTo:rtf_af_None),
  1112.     (Keyword:'pichgoal'; DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropPicHGoal);  AffectTo:rtf_af_None),
  1113.     (Keyword:'picscalex'; DefValue:100;         UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropPicScaleX); AffectTo:rtf_af_None),
  1114.     (Keyword:'picscaley'; DefValue:100;         UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropPicScaleY); AffectTo:rtf_af_None),
  1115.     (Keyword:'wbmbitspixel'; DefValue:1;        UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropWBMBitsPixel); AffectTo:rtf_af_None),
  1116.     (Keyword:'wbmplanes'; DefValue:1;           UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropWBMPlanes); AffectTo:rtf_af_None),
  1117.     (Keyword:'wbmwidthbytes'; DefValue:0;       UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropWBMWidthBytes); AffectTo:rtf_af_None),
  1118.     (Keyword:'emfblip';  DefValue:ord(rtf_pict_EMF);        UseDef:True;   kwd:rtf_kwd_Prop; idx:ord(ipropPictureType); AffectTo:rtf_af_None),
  1119.     (Keyword:'pngblip';  DefValue:ord(rtf_pict_PNG);        UseDef:True;   kwd:rtf_kwd_Prop; idx:ord(ipropPictureType); AffectTo:rtf_af_None),
  1120.     (Keyword:'jpegblip'; DefValue:ord(rtf_pict_JPEG);       UseDef:True;   kwd:rtf_kwd_Prop; idx:ord(ipropPictureType); AffectTo:rtf_af_None),
  1121.     (Keyword:'macpict';  DefValue:ord(rtf_pict_MacPict);    UseDef:True;   kwd:rtf_kwd_Prop; idx:ord(ipropPictureType); AffectTo:rtf_af_None),
  1122.     (Keyword:'pmmetafile'; DefValue:ord(rtf_pict_PmMetafile); UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropPictureType); AffectTo:rtf_af_None),
  1123.       // ^- actually, we need to allow to specify parameter - metafile type here; but this picture type is not supported
  1124.     (Keyword:'dibitmap'; DefValue:ord(rtf_pict_DIB);      UseDef:True;   kwd:rtf_kwd_Prop; idx:ord(ipropPictureType); AffectTo:rtf_af_None),
  1125.     (Keyword:'wbitmap';  DefValue:ord(rtf_pict_DDB);      UseDef:True;   kwd:rtf_kwd_Prop; idx:ord(ipropPictureType); AffectTo:rtf_af_None),
  1126.     (Keyword:'wmetafile'; DefValue:1;                     UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropMetafile);    AffectTo:rtf_af_None),
  1127.     (Keyword:'picbmp';   DefValue:1;                      UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropPicBmp);      AffectTo:rtf_af_None),
  1128.     (Keyword:'ansicpg';   DefValue:CP_ACP;                UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropAnsiCodePage);  AffectTo:rtf_af_None),
  1129.     (Keyword:'page';     DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropPage);      AffectTo:rtf_af_None),
  1130.     (Keyword:'field';    DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestField);     AffectTo:rtf_af_None),
  1131.     (Keyword:'fldinst';  DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestFldInst);   AffectTo:rtf_af_None),
  1132.     (Keyword:'fldrslt';  DefValue:0;            UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestFldRslt);   AffectTo:rtf_af_None),
  1133.     (Keyword:'keep';     DefValue:1;            UseDef:True;   kwd:rtf_kwd_Prop; idx:ord(ipropKeepLinesTogether);  AffectTo:rtf_af_ParaProp),
  1134.     (Keyword:'keepn';    DefValue:1;            UseDef:True;   kwd:rtf_kwd_Prop; idx:ord(ipropKeepWithNext);  AffectTo:rtf_af_ParaProp),    
  1135.     (Keyword:'trowd';    DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropTRowD);     AffectTo:rtf_af_None),
  1136.     (Keyword:'trql';     DefValue:ord(rtf_al_Left);    UseDef:True;  kwd:rtf_kwd_Prop; idx:ord(ipropRowAlign);  AffectTo:rtf_af_None),
  1137.     (Keyword:'trqr';     DefValue:ord(rtf_al_Right);   UseDef:True;  kwd:rtf_kwd_Prop; idx:ord(ipropRowAlign);  AffectTo:rtf_af_None),
  1138.     (Keyword:'trqc';     DefValue:ord(rtf_al_Center);  UseDef:True;  kwd:rtf_kwd_Prop; idx:ord(ipropRowAlign);  AffectTo:rtf_af_None),
  1139.     (Keyword:'trhdr';    DefValue:1;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropTRHeader);  AffectTo:rtf_af_None),
  1140.     (Keyword:'trgaph';   DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropTRGapH);    AffectTo:rtf_af_None),
  1141.     (Keyword:'trleft';   DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropTRLeft);    AffectTo:rtf_af_None),
  1142.     (Keyword:'trrh';     DefValue:0;            UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropTRRowHeight); AffectTo:rtf_af_None),
  1143.     (Keyword:'trpaddl';  DefValue:0;            UseDef:False; kwd:rtf_kwd_Prop; idx:ord(ipropTRPaddL); AffectTo:rtf_af_None),
  1144.     (Keyword:'trpaddr';  DefValue:0;            UseDef:False; kwd:rtf_kwd_Prop; idx:ord(ipropTRPaddR); AffectTo:rtf_af_None),
  1145.     (Keyword:'trpaddt';  DefValue:0;            UseDef:False; kwd:rtf_kwd_Prop; idx:ord(ipropTRPaddT); AffectTo:rtf_af_None),
  1146.     (Keyword:'trpaddb';  DefValue:0;            UseDef:False; kwd:rtf_kwd_Prop; idx:ord(ipropTRPaddB); AffectTo:rtf_af_None),
  1147.     (Keyword:'trpaddfl'; DefValue:0;            UseDef:False; kwd:rtf_kwd_Prop; idx:ord(ipropTRPaddFL); AffectTo:rtf_af_None),
  1148.     (Keyword:'trpaddfr'; DefValue:0;            UseDef:False; kwd:rtf_kwd_Prop; idx:ord(ipropTRPaddFR); AffectTo:rtf_af_None),
  1149.     (Keyword:'trpaddft'; DefValue:0;            UseDef:False; kwd:rtf_kwd_Prop; idx:ord(ipropTRPaddFT); AffectTo:rtf_af_None),
  1150.     (Keyword:'trpaddfb'; DefValue:0;            UseDef:False; kwd:rtf_kwd_Prop; idx:ord(ipropTRPaddFB); AffectTo:rtf_af_None),
  1151.     (Keyword:'trspdl';   DefValue:0;            UseDef:False; kwd:rtf_kwd_Prop; idx:ord(ipropTRSpdL);  AffectTo:rtf_af_None),
  1152.     (Keyword:'trspdr';   DefValue:0;            UseDef:False; kwd:rtf_kwd_Prop; idx:ord(ipropTRSpdR);  AffectTo:rtf_af_None),
  1153.     (Keyword:'trspdt';   DefValue:0;            UseDef:False; kwd:rtf_kwd_Prop; idx:ord(ipropTRSpdT);  AffectTo:rtf_af_None),
  1154.     (Keyword:'trspdb';   DefValue:0;            UseDef:False; kwd:rtf_kwd_Prop; idx:ord(ipropTRSpdB);  AffectTo:rtf_af_None),
  1155.     (Keyword:'trspdfl';  DefValue:0;            UseDef:False; kwd:rtf_kwd_Prop; idx:ord(ipropTRSpdFL); AffectTo:rtf_af_None),
  1156.     (Keyword:'trspdfr';  DefValue:0;            UseDef:False; kwd:rtf_kwd_Prop; idx:ord(ipropTRSpdFR); AffectTo:rtf_af_None),
  1157.     (Keyword:'trspdft';  DefValue:0;            UseDef:False; kwd:rtf_kwd_Prop; idx:ord(ipropTRSpdFT); AffectTo:rtf_af_None),
  1158.     (Keyword:'trspdfb';  DefValue:0;            UseDef:False; kwd:rtf_kwd_Prop; idx:ord(ipropTRSpdFB); AffectTo:rtf_af_None),
  1159.     (Keyword:'trwWidth'; DefValue:0;            UseDef:False; kwd:rtf_kwd_Prop; idx:ord(ipropTRwWidth); AffectTo:rtf_af_None),
  1160.     (Keyword:'trftsWidth'; DefValue:0;          UseDef:False; kwd:rtf_kwd_Prop; idx:ord(ipropTRftsWidth); AffectTo:rtf_af_None),
  1161.     (Keyword:'clvmrg';   DefValue:ord(rtf_cm_Merged);  UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropCLVMerge); AffectTo:rtf_af_None),
  1162.     (Keyword:'clvmgf';   DefValue:ord(rtf_cm_First);   UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropCLVMerge); AffectTo:rtf_af_None),
  1163.     (Keyword:'clmrg';    DefValue:ord(rtf_cm_Merged);  UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropCLHMerge); AffectTo:rtf_af_None),
  1164.     (Keyword:'clmgf';    DefValue:ord(rtf_cm_First);   UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropCLHMerge); AffectTo:rtf_af_None),
  1165.     (Keyword:'clwWidth'; DefValue:0;            UseDef:False; kwd:rtf_kwd_Prop; idx:ord(ipropCLwWidth); AffectTo:rtf_af_None),
  1166.     (Keyword:'clftsWidth'; DefValue:0;          UseDef:False; kwd:rtf_kwd_Prop; idx:ord(ipropCLftsWidth); AffectTo:rtf_af_None),
  1167.     (Keyword:'clcbpat';  DefValue:0;            UseDef:False; kwd:rtf_kwd_Prop; idx:ord(ipropCLColor);  AffectTo:rtf_af_None),
  1168.     (Keyword:'clcfpat';  DefValue:ord(clBlack); UseDef:False; kwd:rtf_kwd_Prop; idx:ord(ipropCLFColor);  AffectTo:rtf_af_None),
  1169.     (Keyword:'clshdng';  DefValue:0;            UseDef:False; kwd:rtf_kwd_Prop; idx:ord(ipropCLShading);  AffectTo:rtf_af_None),
  1170.     (Keyword:'clvertalt'; DefValue:ord(rtf_val_Top);   UseDef:True;  kwd:rtf_kwd_Prop; idx:ord(ipropCLVertAl);  AffectTo:rtf_af_None),
  1171.     (Keyword:'clvertalc'; DefValue:ord(rtf_val_Center); UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropCLVertAl);  AffectTo:rtf_af_None),
  1172.     (Keyword:'clvertalb'; DefValue:ord(rtf_val_Bottom); UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropCLVertAl);  AffectTo:rtf_af_None),
  1173.     (Keyword:'cellx';     DefValue:0;           UseDef:False; kwd:rtf_kwd_Prop; idx:ord(ipropCellX);  AffectTo:rtf_af_None),
  1174.     (Keyword:'trbrdrl';    DefValue:ord(rtf_side_Left);  UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropTRBorderSide); AffectTo:rtf_af_ParaProp),
  1175.     (Keyword:'trbrdrt';    DefValue:ord(rtf_side_Top);   UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropTRBorderSide); AffectTo:rtf_af_ParaProp),
  1176.     (Keyword:'trbrdrr';    DefValue:ord(rtf_side_Right); UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropTRBorderSide); AffectTo:rtf_af_ParaProp),
  1177.     (Keyword:'trbrdrb';    DefValue:ord(rtf_side_Bottom);UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropTRBorderSide); AffectTo:rtf_af_ParaProp),
  1178.     (Keyword:'clbrdrl';    DefValue:ord(rtf_side_Left);  UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropCLBorderSide); AffectTo:rtf_af_ParaProp),
  1179.     (Keyword:'clbrdrt';    DefValue:ord(rtf_side_Top);   UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropCLBorderSide); AffectTo:rtf_af_ParaProp),
  1180.     (Keyword:'clbrdrr';    DefValue:ord(rtf_side_Right); UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropCLBorderSide); AffectTo:rtf_af_ParaProp),
  1181.     (Keyword:'clbrdrb';    DefValue:ord(rtf_side_Bottom);UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropCLBorderSide); AffectTo:rtf_af_ParaProp),
  1182.     (Keyword:'absnoovrlp'; DefValue:0; UseDef:False;                  kwd: rtf_kwd_Prop;idx:ord(ipropNoTableEv); AffectTo: rtf_af_ParaProp),
  1183.     //(Keyword:'pvpara';     DefValue:0; UseDef:False;                  kwd: rtf_kwd_Prop;idx:ord(ipropNoTableEv); AffectTo: rtf_af_ParaProp),
  1184.     //(Keyword:'pvmrg';      DefValue:0; UseDef:False;                  kwd: rtf_kwd_Prop;idx:ord(ipropNoTableEv); AffectTo: rtf_af_ParaProp),
  1185.     //(Keyword:'pvpg';       DefValue:0; UseDef:False;                  kwd: rtf_kwd_Prop;idx:ord(ipropNoTableEv); AffectTo: rtf_af_ParaProp),
  1186.     (Keyword:'highlight';  DefValue:0; UseDef:False;                  kwd: rtf_kwd_Prop;idx:ord(ipropHighlight); AffectTo: rtf_af_CharProp),
  1187.     // bullets & numbering, old style
  1188.     (Keyword:'pnseclvl';   DefValue:1; UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropPNSecLvl);  AffectTo:rtf_af_None),
  1189.     (Keyword:'pntext';     DefValue:0; UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestSkip);      AffectTo:rtf_af_None),
  1190.     (Keyword:'pn';         DefValue:0; UseDef:False;  kwd:rtf_kwd_Dest; idx:ord(idestPN);        AffectTo:rtf_af_None),
  1191.     (Keyword:'pnlvl';      DefValue:1; UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropPNLevel);   AffectTo:rtf_af_None),
  1192.     (Keyword:'pnlvlblt';   DefValue:11; UseDef:True;  kwd:rtf_kwd_Prop; idx:ord(ipropPNLevel);   AffectTo:rtf_af_None),
  1193.     (Keyword:'pnlvlbody';  DefValue:10; UseDef:True;  kwd:rtf_kwd_Prop; idx:ord(ipropPNLevel);   AffectTo:rtf_af_None),
  1194.     (Keyword:'pnhang';     DefValue:1; UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropPNHanging);  AffectTo:rtf_af_None),
  1195.     (Keyword:'pndec';      DefValue:ord(rtf_pn_Decimal); UseDef:True;  kwd:rtf_kwd_Prop; idx:ord(ipropPNType);  AffectTo:rtf_af_None),
  1196.     (Keyword:'pnucltr';    DefValue:ord(rtf_pn_UpperLetter); UseDef:True;  kwd:rtf_kwd_Prop; idx:ord(ipropPNType);  AffectTo:rtf_af_None),
  1197.     (Keyword:'pnucrm';     DefValue:ord(rtf_pn_UpperRoman); UseDef:True;  kwd:rtf_kwd_Prop; idx:ord(ipropPNType);  AffectTo:rtf_af_None),
  1198.     (Keyword:'pnlcltr';    DefValue:ord(rtf_pn_LowerLetter); UseDef:True;  kwd:rtf_kwd_Prop; idx:ord(ipropPNType);  AffectTo:rtf_af_None),
  1199.     (Keyword:'pnlcrm';     DefValue:ord(rtf_pn_LowerRoman); UseDef:True;  kwd:rtf_kwd_Prop; idx:ord(ipropPNType);  AffectTo:rtf_af_None),
  1200.     (Keyword:'pnuldash';   DefValue:1; UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropPNUnderline);  AffectTo:rtf_af_None),
  1201.     (Keyword:'pnuldashd';   DefValue:1; UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropPNUnderline);  AffectTo:rtf_af_None),
  1202.     (Keyword:'pnuldashdd';   DefValue:1; UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropPNUnderline);  AffectTo:rtf_af_None),
  1203.     (Keyword:'pnulhair';   DefValue:1; UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropPNUnderline);  AffectTo:rtf_af_None),
  1204.     (Keyword:'pnulth';     DefValue:1; UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropPNUnderline);  AffectTo:rtf_af_None),
  1205.     (Keyword:'pnulwave';   DefValue:1; UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropPNUnderline);  AffectTo:rtf_af_None),
  1206.     (Keyword:'pnul';       DefValue:1; UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropPNUnderline);  AffectTo:rtf_af_None),
  1207.     (Keyword:'pnuld';      DefValue:1; UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropPNUnderline);  AffectTo:rtf_af_None),
  1208.     (Keyword:'pnuld';      DefValue:1; UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropPNUnderline);  AffectTo:rtf_af_None),
  1209.     (Keyword:'pnuldb';     DefValue:1; UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropPNUnderline);  AffectTo:rtf_af_None),
  1210.     (Keyword:'pnulw';      DefValue:1; UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropPNUnderline);  AffectTo:rtf_af_None),
  1211.     (Keyword:'pnulnone';   DefValue:0; UseDef:True;   kwd:rtf_kwd_Prop; idx:ord(ipropPNUnderline);  AffectTo:rtf_af_None),
  1212.     (Keyword:'pnb';        DefValue:1; UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropPNBold);       AffectTo:rtf_af_None),
  1213.     (Keyword:'pni';        DefValue:1; UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropPNItalic);     AffectTo:rtf_af_None),
  1214.     (Keyword:'pnstrike';   DefValue:1; UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropPNStrike);     AffectTo:rtf_af_None),
  1215.     (Keyword:'pncf';       DefValue:0; UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropPNColor);      AffectTo:rtf_af_None),
  1216.     (Keyword:'pnf';        DefValue:0; UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropPNF);          AffectTo:rtf_af_None),
  1217.     (Keyword:'pnfs';       DefValue:0; UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropPNFontSize);   AffectTo:rtf_af_None),
  1218.     (Keyword:'pnindent';   DefValue:0; UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropPNIndent);     AffectTo:rtf_af_None),
  1219.     (Keyword:'pnsp';       DefValue:0; UseDef:False;  kwd:rtf_kwd_Prop; idx:ord(ipropPNSp);         AffectTo:rtf_af_None),
  1220.     (Keyword:'pnqc';       DefValue:ord(rtf_al_Center); UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropPNAlign); AffectTo:rtf_af_None),
  1221.     (Keyword:'pnql';       DefValue:ord(rtf_al_Left);   UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropPNAlign); AffectTo:rtf_af_None),
  1222.     (Keyword:'pnqr';       DefValue:ord(rtf_al_Right);  UseDef:True; kwd:rtf_kwd_Prop; idx:ord(ipropPNAlign); AffectTo:rtf_af_None),
  1223.     (Keyword:'pnstart';    DefValue:1; UseDef:False; kwd:rtf_kwd_Prop; idx:ord(ipropPNStart); AffectTo:rtf_af_None),
  1224.     (Keyword:'pntxta';     DefValue:0; UseDef:False; kwd:rtf_kwd_Dest; idx:ord(idestPNTextAfter);  AffectTo:rtf_af_None),
  1225.     (Keyword:'pntxtb';     DefValue:0; UseDef:False; kwd:rtf_kwd_Dest; idx:ord(idestPNTextBefore); AffectTo:rtf_af_None),
  1226.     // bullets & numbering, new style
  1227.     (Keyword:'listtext';         DefValue:0; UseDef:False; kwd: rtf_kwd_Dest;idx:ord(idestSkip);           AffectTo: rtf_af_None),
  1228.     (Keyword:'listtable';        DefValue:0; UseDef:False; kwd: rtf_kwd_Dest;idx:ord(idestListTable);      AffectTo: rtf_af_None),
  1229.     (Keyword:'list';             DefValue:0; UseDef:False; kwd: rtf_kwd_Dest;idx:ord(idestList);           AffectTo: rtf_af_None),
  1230.     (Keyword:'listid';           DefValue:0; UseDef:False; kwd: rtf_kwd_Prop;idx:ord(ipropListId);         AffectTo: rtf_af_None),
  1231.     (Keyword:'listsimple';       DefValue:1; UseDef:False; kwd: rtf_kwd_Prop;idx:ord(ipropListSimple);     AffectTo: rtf_af_None),
  1232.     (Keyword:'listname';         DefValue:1; UseDef:False; kwd: rtf_kwd_Dest;idx:ord(idestListName);       AffectTo: rtf_af_None),
  1233.     (Keyword:'listlevel';        DefValue:0; UseDef:False; kwd: rtf_kwd_Dest;idx:ord(idestListLevel);      AffectTo: rtf_af_None),
  1234.     (Keyword:'levelstartat';     DefValue:1; UseDef:False; kwd: rtf_kwd_Prop;idx:ord(ipropLevelStartAt);   AffectTo: rtf_af_None),
  1235.     (Keyword:'levelnfc';         DefValue:0; UseDef:False; kwd: rtf_kwd_Prop;idx:ord(ipropLevelNumberType); AffectTo: rtf_af_None),
  1236.     (Keyword:'leveljc';          DefValue:0; UseDef:False; kwd: rtf_kwd_Prop;idx:ord(ipropLevelJustify);   AffectTo: rtf_af_None),
  1237.     (Keyword:'levelold';         DefValue:1; UseDef:False; kwd: rtf_kwd_Prop;idx:ord(ipropLevelOld);       AffectTo: rtf_af_None),
  1238.     (Keyword:'levelindent';      DefValue:0; UseDef:False; kwd: rtf_kwd_Prop;idx:ord(ipropLevelIndent);    AffectTo: rtf_af_None),
  1239.     (Keyword:'levelspace';       DefValue:0; UseDef:False; kwd: rtf_kwd_Prop;idx:ord(ipropLevelSpace);     AffectTo: rtf_af_None),
  1240.     (Keyword:'leveltext';        DefValue:0; UseDef:False; kwd: rtf_kwd_Dest;idx:ord(idestLevelText);      AffectTo: rtf_af_None),
  1241.     (Keyword:'levelnumbers';     DefValue:0; UseDef:False; kwd: rtf_kwd_Dest;idx:ord(idestLevelNumbers);   AffectTo: rtf_af_None),
  1242.     (Keyword:'levelfollow';      DefValue:0; UseDef:False; kwd: rtf_kwd_Prop;idx:ord(ipropLevelFollow);    AffectTo: rtf_af_None),
  1243.     (Keyword:'levellegal';       DefValue:1; UseDef:False; kwd: rtf_kwd_Prop;idx:ord(ipropLevelLegal);     AffectTo: rtf_af_None),
  1244.     (Keyword:'levelnorestart';   DefValue:1; UseDef:False; kwd: rtf_kwd_Prop;idx:ord(ipropLevelNoRestart); AffectTo: rtf_af_None),
  1245.     (Keyword:'listoverridetable';DefValue:0; UseDef:False; kwd: rtf_kwd_Dest;idx:ord(idestLOTable);        AffectTo: rtf_af_None),
  1246.     (Keyword:'listoverride';     DefValue:0; UseDef:False; kwd: rtf_kwd_Dest;idx:ord(idestLO);             AffectTo: rtf_af_None),
  1247.     (Keyword:'listoverridecount';DefValue:0; UseDef:False; kwd: rtf_kwd_Prop;idx:ord(ipropLOCount);        AffectTo: rtf_af_None),
  1248.     (Keyword:'lfolevel';         DefValue:0; UseDef:False; kwd: rtf_kwd_Dest;idx:ord(idestLOLevel);        AffectTo: rtf_af_None),
  1249.     (Keyword:'listoverridestartat';DefValue:1; UseDef:False; kwd: rtf_kwd_Prop;idx:ord(ipropLOStart);      AffectTo: rtf_af_None),
  1250.     (Keyword:'ls';               DefValue:1; UseDef:False; kwd: rtf_kwd_Prop;idx:ord(ipropLONumber);       AffectTo: rtf_af_ParaProp),
  1251.     (Keyword:'ilvl';             DefValue:1; UseDef:False; kwd: rtf_kwd_Prop;idx:ord(ipropLevel);          AffectTo: rtf_af_ParaProp),
  1252.     (Keyword:'tx';               DefValue:0; UseDef:False; kwd: rtf_kwd_Prop;idx:ord(ipropTX);             AffectTo: rtf_af_ParaProp),
  1253.     (Keyword:'tqr';              DefValue:ord(rtf_tab_Right);   UseDef:True; kwd:rtf_kwd_Prop;idx:ord(ipropTabAlign); AffectTo: rtf_af_ParaProp),
  1254.     (Keyword:'tqc';              DefValue:ord(rtf_tab_Center);  UseDef:True; kwd:rtf_kwd_Prop;idx:ord(ipropTabAlign); AffectTo: rtf_af_ParaProp),
  1255.     (Keyword:'tqdec';            DefValue:ord(rtf_tab_Decimal); UseDef:True; kwd:rtf_kwd_Prop;idx:ord(ipropTabAlign); AffectTo: rtf_af_ParaProp),
  1256.     (Keyword:'tldot';            DefValue:ord(rtf_tl_Dot); UseDef:True; kwd:rtf_kwd_Prop;idx:ord(ipropTabLeader); AffectTo: rtf_af_ParaProp),
  1257.     (Keyword:'tlhyph';           DefValue:ord(rtf_tl_Hyphen); UseDef:True; kwd:rtf_kwd_Prop;idx:ord(ipropTabLeader); AffectTo: rtf_af_ParaProp),
  1258.     (Keyword:'tlul';             DefValue:ord(rtf_tl_Underline); UseDef:True; kwd:rtf_kwd_Prop;idx:ord(ipropTabLeader); AffectTo: rtf_af_ParaProp),
  1259.     (Keyword:'tlth';             DefValue:ord(rtf_tl_Underline); UseDef:True; kwd:rtf_kwd_Prop;idx:ord(ipropTabLeader); AffectTo: rtf_af_ParaProp),
  1260.     (Keyword:'tleq';             DefValue:ord(rtf_tl_EqualSign); UseDef:True; kwd:rtf_kwd_Prop;idx:ord(ipropTabLeader); AffectTo: rtf_af_ParaProp),
  1261.     (Keyword:'tlmdot';           DefValue:ord(rtf_tl_MiddleDot); UseDef:True; kwd:rtf_kwd_Prop;idx:ord(ipropTabLeader); AffectTo: rtf_af_ParaProp),
  1262.     (Keyword:'jclisttab';        DefValue:0; UseDef:False; kwd: rtf_kwd_Prop; idx:ord(ipropListTab); AffectTo: rtf_af_ParaProp)
  1263.     {$IFDEF RICHVIEW}
  1264.    ,(Keyword:'richviewcbw'; DefValue:0; UseDef:False; kwd:rtf_kwd_Prop; idx:ord(ipropRVCellBestWidth); AffectTo:rtf_af_None),
  1265.     (Keyword:'richviewcbh'; DefValue:0; UseDef:False; kwd:rtf_kwd_Prop; idx:ord(ipropRVCellBestHeight); AffectTo:rtf_af_None),
  1266.     (Keyword:'richviewtbw'; DefValue:0; UseDef:False; kwd:rtf_kwd_Prop; idx:ord(ipropRVTableBestWidth); AffectTo:rtf_af_None)
  1267.     {$ENDIF}
  1268.     );
  1269. procedure SortKeywords; forward;
  1270. function GetMetafileMapMode(Val: Integer): Integer;
  1271. begin
  1272.   case val of
  1273.     2: Result := MM_LOMETRIC;
  1274.     3: Result := MM_HIMETRIC;
  1275.     4: Result := MM_LOENGLISH;
  1276.     5: Result := MM_HIENGLISH;
  1277.     6: Result := MM_TWIPS;
  1278.     7: Result := MM_ISOTROPIC;
  1279.     8: Result := MM_ANISOTROPIC;
  1280.     else
  1281.       Result := MM_TEXT
  1282.   end;
  1283. end;
  1284. function GetHighlightColor(Index: Integer): TColor;
  1285. begin
  1286.   case Index of
  1287.     1:  Result := clBlack;
  1288.     2:  Result := clBlue;
  1289.     3:  Result := clAqua;
  1290.     4:  Result := clLime;
  1291.     5:  Result := clFuchsia;
  1292.     6:  Result := clRed;
  1293.     7:  Result := clYellow;
  1294.     8:  Result := clWhite; // not used
  1295.     9:  Result := clNavy;
  1296.     10: Result := clTeal;
  1297.     11: Result := clGreen;
  1298.     12: Result := clPurple;
  1299.     13: Result := clMaroon;
  1300.     14: Result := clOlive;
  1301.     15: Result := clGray;
  1302.     16: Result := clSilver;
  1303.     else Result := clNone;
  1304.   end;
  1305. end;
  1306. function ShadeColor(Color1, Color2: TColor; Shading: Integer): TColor;
  1307.     {.................................................}
  1308.     function GetColorChannel(c1,c2: Integer): Integer;
  1309.     begin
  1310.       Result := ((c1*(10000-Shading)+c2*Shading) div 10000) and $FF;
  1311.     end;
  1312.     {.................................................}
  1313. var Red, Green, Blue: Integer;
  1314. begin
  1315.   Red   := GetColorChannel( Color1 and $0000FF,          Color2 and $0000FF);
  1316.   Green := GetColorChannel((Color1 and $00FF00) shr 8,  (Color2 and $00FF00) shr 8);
  1317.   Blue  := GetColorChannel((Color1 and $FF0000) shr 16, (Color2 and $FF0000) shr 16);
  1318.   Result := Red or (Green shl 8) or (Blue shl 16);
  1319. end;
  1320. {======================== TRVRTFReader ========================================}
  1321. constructor TRVRTFReader.Create(AOwner: TComponent);
  1322. begin
  1323.   inherited  Create(AOwner);
  1324.   FFontTable  := TRVRTFFontList.Create;
  1325.   FStyleSheet := TRVRTFStyleSheet.Create;
  1326.   FColorTable := TRVRTFColorList.Create;
  1327.   FListTable  := TRVRTFListTable97.Create;
  1328.   FListOverrideTable  := TRVRTFListOverrideTable97.Create;
  1329.   SaveList    := TRVList.Create;
  1330.   FRTFState   := TRVRTFReaderState.Create;
  1331.   FDefCodePage := CP_ACP;
  1332.   FConvertHighlight := rtf_hl_FixedColors;
  1333.   FExtractMetafileBitmaps := True;
  1334. end;
  1335. {------------------------------------------------------------------------------}
  1336. destructor TRVRTFReader.Destroy;
  1337. begin
  1338.   Clear;
  1339.   FFontTable.Free;
  1340.   FStyleSheet.Free;
  1341.   FColorTable.Free;
  1342.   SaveList.Free;
  1343.   FRTFState.Free;
  1344.   FListTable.Free;
  1345.   FListOverrideTable.Free;
  1346.   inherited Destroy;
  1347. end;
  1348. {------------------------------------------------------------------------------}
  1349. procedure TRVRTFReader.Clear;
  1350. begin
  1351.   SortKeywords;
  1352.   FStyleSheet.Clear;
  1353.   FFontTable.Clear;
  1354.   FColorTable.Clear;
  1355.   FListTable.Clear;
  1356.   FListOverrideTable.Clear;
  1357.   SaveList.Clear;
  1358.   FRTFState.Reset;
  1359.   Text       := '';
  1360.   {$IFDEF RICHVIEWCBDEF3}
  1361.   TextW      := '';
  1362.   {$ENDIF}
  1363.   Position     := rtf_ts_NewPara;
  1364.   UseLastChar := False;
  1365.   FPicture.Free;
  1366.   FPicture := nil;
  1367.   FObject.Free;
  1368.   FObject := nil;
  1369.   FMarkerProps.Free;
  1370.   FMarkerProps := nil;
  1371.   FCodePage := FDefCodePage;
  1372.   SkipAnsiCount := 1;
  1373.   SkipNext      := 0;
  1374.   cGroup        := 0;
  1375.   CurrentNestingLevel := 0;
  1376.   ForceEvenEmptyNewLine := False;
  1377.   if PixelsPerInch = 0 then
  1378.     PixelsPerInch := Screen.PixelsPerInch;
  1379.   ShpPictInserted := False;
  1380.   ObjectInserted  := False;
  1381. end;
  1382. {------------------------------------------------------------------------------}
  1383. function TRVRTFReader.ApplyPropChange_SSEntry(iprop: TRTFiprop; val: Integer): TRVRTFErrorCode;
  1384. begin
  1385.   Result := rtf_ec_Ok;
  1386.   case iprop of
  1387.     ipropS:
  1388.       Result := ChangeDest(idestStyleSheetParaStyle, Val);
  1389.     ipropCS:
  1390.       Result := ChangeDest(idestStyleSheetCharStyle, Val);
  1391.     ipropDS:
  1392.       Result := ChangeDest(idestStyleSheetSectStyle, Val);
  1393.     ipropSBasedOn:
  1394.       FStyleSheet[FStyleSheet.Count-1].FBasedOn := FStyleSheet.GetEntry(Val);
  1395.     irpropSNext:
  1396.       FStyleSheet[FStyleSheet.Count-1].FNext := FStyleSheet.GetEntry(Val);
  1397.     ipropAdditive:
  1398.       FStyleSheet[FStyleSheet.Count-1].FAdditive := True;
  1399.     ipropSHidden:
  1400.       FStyleSheet[FStyleSheet.Count-1].FHidden := True;
  1401.   end;
  1402. end;
  1403. {------------------------------------------------------------------------------}
  1404. function TRVRTFReader.ApplyPropChange_Picture(iprop: TRTFiprop; val: Integer): TRVRTFErrorCode;
  1405. begin
  1406.   Result := rtf_ec_Ok;
  1407.   if FPicture<>nil then
  1408.     case iprop of
  1409.       ipropPictureType:
  1410.         begin
  1411.           FPicture.FType := TRVRTFPictureType(Val);
  1412.           case FPicture.FType of
  1413.             rtf_pict_DIB:
  1414.               begin
  1415.                 FPicture.FData.Position := sizeof(TBitmapFileHeader);
  1416.               end;
  1417.           end;
  1418.         end;
  1419.       ipropMetafile:
  1420.         begin
  1421.           FPicture.FType := rtf_pict_WMF;
  1422.           FPicture.FMetafileMapMode := GetMetafileMapMode(Val);
  1423.         end;
  1424.       ipropPicW:
  1425.         FPicture.FPicW := Val;
  1426.       ipropPicH:
  1427.         FPicture.FPicH := Val;
  1428.       ipropPicWGoal:
  1429.         FPicture.FPicWGoalTw := Val;
  1430.       ipropPicHGoal:
  1431.         FPicture.FPicHGoalTw := Val;
  1432.       ipropPicScaleX:
  1433.         FPicture.FPicScaleX := Val;
  1434.       ipropPicScaleY:
  1435.         FPicture.FPicScaleY := Val;
  1436.       ipropWBMWidthBytes:
  1437.         FPicture.FWBMWidthBytes := Val;
  1438.       ipropWBMBitsPixel:
  1439.         FPicture.FWBMBitsPixel := Val;
  1440.       ipropWBMPlanes:
  1441.         FPicture.FWBMPlanes := Val;
  1442.       ipropPicBmp:
  1443.         FPicture.FMetafileWithBitmap := True;
  1444.     end;
  1445. end;
  1446. {------------------------------------------------------------------------------}
  1447. function TRVRTFReader.ApplyPropChange_Object(iprop: TRTFiprop;
  1448.   val: Integer): TRVRTFErrorCode;
  1449. begin
  1450.   Result := rtf_ec_Ok;
  1451.   if FObject<>nil then
  1452.     case iprop of
  1453.       ipropObjType:
  1454.         FObject.FType := TRVRTFObjectType(val);
  1455.       ipropObjWidth:
  1456.         FObject.FWidthTw := val;
  1457.       ipropObjHeight:
  1458.         FObject.FHeightTw := val;
  1459.     end;
  1460. end;
  1461. {------------------------------------------------------------------------------}
  1462. function TRVRTFReader.ApplyPropChange_PN(iprop: TRTFiprop;
  1463.   val: Integer): TRVRTFErrorCode;
  1464. var
  1465.   CurMarkerProps: TRVRTFMarkerProperties;
  1466. begin
  1467.   Result := rtf_ec_Ok;
  1468.   if FRTFState.rds=rdsPN then
  1469.     CurMarkerProps := FMarkerProps
  1470.   else begin
  1471.     FRTFState.SectProps.InitListDefaults;
  1472.     CurMarkerProps := TRVRTFMarkerProperties(FRTFState.SectProps.FDefMarkerPropsList[FCurPNSecLvl-1]);
  1473.   end;
  1474.   if CurMarkerProps<>nil then
  1475.     case iprop of
  1476.       ipropPNLevel:
  1477.         begin
  1478.           if RTFState.SectProps.FDefMarkerPropsList<>nil then
  1479.             CurMarkerProps.Assign(TRVRTFMarkerProperties(FRTFState.SectProps.FDefMarkerPropsList[val-1]), True);
  1480.           CurMarkerProps.FLevel := val;
  1481.         end;
  1482.       ipropPNHanging:
  1483.         CurMarkerProps.FHanging := True;
  1484.       ipropPNType:
  1485.         CurMarkerProps.FListType := TRVRTFParaListType(val);
  1486.       ipropPNUnderline:
  1487.         CurMarkerProps.ChangeFontStyle(fsUnderline,val);
  1488.       ipropPNBold:
  1489.         CurMarkerProps.ChangeFontStyle(fsBold,val);
  1490.       ipropPNItalic:
  1491.         CurMarkerProps.ChangeFontStyle(fsItalic,val);
  1492.       ipropPNStrike:
  1493.         CurMarkerProps.ChangeFontStyle(fsStrikeOut,val);
  1494.       ipropPNColor:
  1495.         begin
  1496.           if (Val>=0) and (Val<ColorTable.Count) then
  1497.              CurMarkerProps.FColor := ColorTable[Val];
  1498.           Include(CurMarkerProps.FFixedProperties, rtfmp_Color);
  1499.         end;
  1500.       ipropPNF:
  1501.         begin
  1502.           CurMarkerProps.FFontIndex := FFontTable.GetFontIndex(val,RTFState.DefFontNumber);
  1503.           Include(CurMarkerProps.FFixedProperties, rtfmp_FontIndex);
  1504.         end;
  1505.       ipropPNFontSize:
  1506.         begin
  1507.           CurMarkerProps.FFontSize := Round(val/2);
  1508.           Include(CurMarkerProps.FFixedProperties, rtfmp_Size);
  1509.         end;
  1510.       ipropPNIndent:
  1511.         CurMarkerProps.FIndentTw := val;
  1512.       ipropPNSp:
  1513.         CurMarkerProps.FSpaceTw := val;
  1514.       ipropPNAlign:
  1515.         CurMarkerProps.FAlignment := TRVRTFAlignment(val);
  1516.       ipropPNStart:
  1517.         CurMarkerProps.FStart := val;
  1518.     end;
  1519. end;
  1520. {------------------------------------------------------------------------------}
  1521. function TRVRTFReader.ApplyPropChange_List(iprop: TRTFiprop; val: Integer): TRVRTFErrorCode;
  1522. begin
  1523.   Result := rtf_ec_Ok;
  1524.   case iprop of
  1525.     ipropListId:
  1526.       FListTable.GetLastList.FId := Val;
  1527.     ipropListTemplateId:
  1528.       FListTable.GetLastList.FTemplateId := Val;
  1529.     ipropListSimple:
  1530.       FListTable.GetLastList.FSimple := Val<>0;
  1531.   end;
  1532. end;
  1533. {------------------------------------------------------------------------------}
  1534. function TRVRTFReader.ApplyPropChange_ListLevel(iprop: TRTFiprop; val: Integer): TRVRTFErrorCode;
  1535. var Level: TRVRTFListLevel97;
  1536. begin
  1537.   Result := rtf_ec_Ok;
  1538.   Level := FListTable.GetLastList.GetLastLevel;
  1539.   case iprop of
  1540.     ipropLevelStartAt:
  1541.       Level.FStart := Val;
  1542.     ipropLevelNumberType:
  1543.       case Val of
  1544.         1:   Level.FListType := rtf_pn_UpperRoman;
  1545.         2:   Level.FListType := rtf_pn_LowerRoman;
  1546.         3:   Level.FListType := rtf_pn_UpperLetter;
  1547.         4:   Level.FListType := rtf_pn_LowerLetter;
  1548.         23:  Level.FListType := rtf_pn_Bullet;
  1549.         else Level.FListType := rtf_pn_Decimal;
  1550.       end;
  1551.     ipropLevelJustify:
  1552.       case Val of
  1553.         0: Level.FAlignment := rtf_al_Left;
  1554.         1: Level.FAlignment := rtf_al_Center;
  1555.         2: Level.FAlignment := rtf_al_Right;
  1556.       end;
  1557.     ipropLevelOld:
  1558.       Level.FOldStyle := Val<>0;
  1559.     ipropLevelIndent:
  1560.       Level.FIndentTw := Val;
  1561.     ipropLevelSpace:
  1562.       Level.FSpaceTw  := Val;
  1563.     ipropLevelFollow:
  1564.       Level.FFollow := TRVRTFLevelFollow97(Val);
  1565.     ipropLevelLegal:
  1566.       Level.FLegal := Val<>0;
  1567.     ipropLevelNoRestart:
  1568.       Level.FNoRestart := Val<>0;
  1569.     ipropBold:
  1570.       Level.ChangeFontStyle(fsBold, Val);
  1571.     ipropItalic:
  1572.       Level.ChangeFontStyle(fsItalic, Val);
  1573.     ipropUnderline:
  1574.       Level.ChangeFontStyle(fsUnderline, Val);
  1575.     ipropStrike:
  1576.       Level.ChangeFontStyle(fsStrikeOut, Val);
  1577.     ipropFontSize:
  1578.       begin
  1579.         Level.FFontSize := round(Val/2);
  1580.         Level.FFontSizeDefined := True;
  1581.       end;
  1582.     ipropTextColor:
  1583.       if (Val>=0) and (Val<ColorTable.Count) then
  1584.         Level.FColor := ColorTable[Val];
  1585.     ipropF:
  1586.       Level.FFontIndex := FFontTable.GetFontIndex(val,RTFState.DefFontNumber);
  1587.     ipropLeftInd:
  1588.       Level.FLeftIndentTw := val;
  1589.     ipropFirstInd:
  1590.       Level.FFirstIndentTw := val;
  1591.     ipropTX: // actually, we should check tab type here
  1592.       Level.FTabPosTw := val;
  1593.   end;
  1594. end;
  1595. {------------------------------------------------------------------------------}
  1596. function TRVRTFReader.ApplyPropChange_LO(iprop: TRTFiprop;
  1597.   val: Integer): TRVRTFErrorCode;
  1598. var LO: TRVRTFListOverride97;
  1599. begin
  1600.   Result := rtf_ec_Ok;
  1601.   LO := FListOverrideTable.GetLastListOverride;
  1602.   case iprop of
  1603.     ipropListId:
  1604.       LO.FListIndex := FListTable.FindList(val);
  1605.     ipropLONumber:
  1606.       LO.FNumber := Val;
  1607.     ipropLOCount:
  1608.       LO.FOverrideCount := Val;
  1609.   end;
  1610. end;
  1611. {------------------------------------------------------------------------------}
  1612. function TRVRTFReader.ApplyPropChange_LOLevel(iprop: TRTFiprop;
  1613.   val: Integer): TRVRTFErrorCode;
  1614. var LOLevel: TRVRTFListOverrideLevel97;
  1615. begin
  1616.   Result := rtf_ec_Ok;
  1617.   LOLevel := FListOverrideTable.GetLastListOverride.GetLastLevel;
  1618.   case iprop of
  1619.     ipropLOStart:
  1620.       LOLevel.FUseStart := True;
  1621.     ipropLevelStartAt:
  1622.       LOLevel.FStart := val;
  1623.   end;
  1624. end;
  1625. {------------------------------------------------------------------------------}
  1626. function TRVRTFReader.ApplyPropChange(iprop: TRTFiprop; val: Integer): TRVRTFErrorCode;
  1627. {$IFDEF RICHVIEWCBDEF3}
  1628. var s: String;
  1629. {$ENDIF}
  1630. begin
  1631.   Result := rtf_ec_Ok;
  1632.   case FRTFState.rds of
  1633.     rdsSkip:
  1634.       exit;
  1635.     rdsStyleSheetEntry:
  1636.       Result := ApplyPropChange_SSEntry(iprop, val);    
  1637.     rdsPict:
  1638.       Result := ApplyPropChange_Picture(iprop, val);
  1639.     rdsObject:
  1640.       Result := ApplyPropChange_Object(iprop, val);
  1641.     rdsPN, rdsPNSecLvl:
  1642.       Result := ApplyPropChange_PN(iprop, val);
  1643.     rdsList:
  1644.       Result := ApplyPropChange_List(iprop, val);
  1645.     rdsListLevel:
  1646.       Result := ApplyPropChange_ListLevel(iprop, val);
  1647.     rdsLO:
  1648.       Result := ApplyPropChange_LO(iprop, val);
  1649.     rdsLOLevel:
  1650.       Result := ApplyPropChange_LOLevel(iprop, val);
  1651.     rdsColorTable:
  1652.       begin
  1653.         case iprop of
  1654.           ipropRed:
  1655.             FColorTable.SetLastRed(Val);
  1656.           ipropGreen:
  1657.             FColorTable.SetLastGreen(Val);
  1658.           ipropBlue:
  1659.             FColorTable.SetLastBlue(Val);
  1660.         end;
  1661.       end;
  1662.     else
  1663.       case iprop of
  1664.         ipropU:
  1665.           begin
  1666.             {$IFDEF RICHVIEWCBDEF3}
  1667.              case RTFState.rds of
  1668.                rdsNorm:
  1669.                  if Assigned(FOnNewUnicodeText) then begin
  1670.                    SkipNext := SkipAnsiCount;
  1671.                    OutputWideChar(WideChar(PWord(@Val)^));
  1672.                  end;
  1673.                rdsListLevelText:
  1674.                  begin
  1675.                    SkipNext := SkipAnsiCount;
  1676.                    OutputWideChar(WideChar(PWord(@Val)^));
  1677.                  end;
  1678.                rdsPNTextAfter, rdsPNTextBefore:
  1679.                  begin
  1680.                    if (FMarkerProps<>nil) and (FMarkerProps.FFontIndex>=0) and
  1681.                      (FMarkerProps.FFontIndex<FontTable.Count) and
  1682.                      (AnsiCompareText(FontTable[FMarkerProps.FFontIndex].Name, 'Symbol')=0) and
  1683.                      (((PWord(@Val)^) and $FF00) = $F000) then begin
  1684.                      SkipNext := SkipAnsiCount;
  1685.                      ParseChar(Char(Val and $FF));
  1686.                      end
  1687.                    else if SkipAnsiCount>0 then begin
  1688.                      SkipNext := SkipAnsiCount;
  1689.                      s := UnicodeToAnsi(WideChar(PWord(@Val)^));
  1690.                      while s<>'' do begin
  1691.                        Result := ParseChar(s[1]);
  1692.                        s := Copy(s, 2, Length(s));
  1693.                      end;
  1694.                    end;
  1695.                  end;
  1696.                else
  1697.                  begin
  1698.                    if SkipAnsiCount>0 then begin
  1699.                      SkipNext := SkipAnsiCount;
  1700.                      s := UnicodeToAnsi(WideChar(PWord(@Val)^));
  1701.                      while s<>'' do begin
  1702.                        Result := ParseChar(s[1]);
  1703.                        s := Copy(s, 2, Length(s));
  1704.                      end;
  1705.                    end;
  1706.                  end;
  1707.              end;
  1708.             {$ENDIF}
  1709.           end;
  1710.         ipropUC:
  1711.           SkipAnsiCount := Val;
  1712.         {$IFDEF RVTEXTFOOTNOTES}
  1713.         iPropFootnote:
  1714.           begin
  1715.              FRTFState.ChangeFontStyleEx(rtf_fs_Footnote, 1);
  1716.              OutputChar('<', False, False);
  1717.              OutputChar('F', False, False);
  1718.              OutputChar('N', False, False);
  1719.              OutputChar('>', False, False);
  1720.           end;        
  1721.         {$ENDIF}          
  1722.         ipropBold:
  1723.           FRTFState.ChangeFontStyle(fsBold, Val);
  1724.         ipropItalic:
  1725.           FRTFState.ChangeFontStyle(fsItalic, Val);
  1726.         ipropUnderline:
  1727.           FRTFState.ChangeFontStyle(fsUnderline, Val);
  1728.         ipropStrike:
  1729.           FRTFState.ChangeFontStyle(fsStrikeOut, Val);
  1730.         ipropAllCaps:
  1731.           FRTFState.ChangeFontStyleEx(rtf_fs_AllCaps, Val);
  1732.         ipropLanguage:
  1733.           FRTFState.CharProps.FLanguage := Val;
  1734.         ipropDefLanguage:
  1735.           FRTFState.FDefLanguage := Val;
  1736.         ipropHidden:
  1737.           begin
  1738.             if FRTFState.CharProps.FHidden<>(Val<>0) then begin
  1739.               ForceEvenEmptyNewLine := not FRTFState.CharProps.FHidden;
  1740.               if (Val<>0) and (Text='') {$IFDEF RICHVIEWCBDEF3} and (TextW='') {$ENDIF} then
  1741.                 FRTFState.CharProps.FHidden := True;              
  1742.               OutputChar(#0, False, False);
  1743.               ForceEvenEmptyNewLine := False;
  1744.             end;
  1745.            FRTFState.CharProps.FHidden := Val<>0;
  1746.           end;
  1747.         ipropSScript:
  1748.           FRTFState.CharProps.FSScriptType := TRVRTFSScriptType(Val);
  1749.         ipropFontSize:
  1750.           FRTFState.CharProps.FSize := round(Val/2);
  1751.         ipropTextColor:
  1752.           begin
  1753.             if (Val>=0) and (Val<ColorTable.Count) then
  1754.               FRTFState.CharProps.FColor := ColorTable[Val];
  1755.           end;
  1756.         ipropTextBackColor:
  1757.           begin
  1758.             if (Val>=0) and (Val<ColorTable.Count) then
  1759.               FRTFState.CharProps.FBackColor := ColorTable[Val];
  1760.             if FRTFState.CharProps.FBackColor=clWindowText then
  1761.               FRTFState.CharProps.FBackColor := clNone;
  1762.           end;
  1763.         ipropHighlight:
  1764.           case FConvertHighlight of
  1765.            rtf_hl_FixedColors:
  1766.              FRTFState.CharProps.FBackColor := GetHighlightColor(Val);
  1767.            rtf_hl_ColorTable:
  1768.              begin
  1769.                if (Val>=0) and (Val<ColorTable.Count) then
  1770.                  FRTFState.CharProps.FBackColor := ColorTable[Val];
  1771.                if FRTFState.CharProps.FBackColor=clWindowText then
  1772.                  FRTFState.CharProps.FBackColor := clNone;
  1773.              end;
  1774.           end;
  1775.         ipropSL:
  1776.           FRTFState.ParaProps.FLineSpacing := val;
  1777.         ipropSLMult:
  1778.           FRTFState.ParaProps.FLineSpacingMulti := Boolean(val);        
  1779.         ipropLeftInd:
  1780.           FRTFState.ParaProps.FLeftIndentTw := val;
  1781.         ipropRightInd:
  1782.           FRTFState.ParaProps.FRightIndentTw := val;
  1783.         ipropFirstInd:
  1784.           FRTFState.ParaProps.FFirstIndentTw := val;
  1785.         ipropSpaceBefore:
  1786.           FRTFState.ParaProps.FSpaceBeforeTw := val;
  1787.         ipropSpaceAfter:
  1788.           FRTFState.ParaProps.FSpaceAfterTw := val;
  1789.         ipropCols:
  1790.           FRTFState.SectProps.FColumnCount := val;
  1791.         ipropPgnX:
  1792.           FRTFState.SectProps.FPageNumberXTw := val;
  1793.         ipropPgnY:
  1794.           FRTFState.SectProps.FPageNumberYTw :=  val;
  1795.         ipropHeaderY:
  1796.           FRTFState.SectProps.FHeaderYTw :=  val;
  1797.         ipropFooterY:
  1798.           FRTFState.SectProps.FFooterYTw :=  val;
  1799.         ipropXaPage:
  1800.           FRTFState.DocProps.FPaperWidthTw := val;
  1801.         ipropYaPage:
  1802.           FRTFState.DocProps.FPaperHeightTw := val;
  1803.         ipropXaLeft:
  1804.           FRTFState.DocProps.FLeftMarginTw := val;
  1805.         ipropXaRight:
  1806.           FRTFState.DocProps.FRightMarginTw := val;
  1807.         ipropYaTop:
  1808.           FRTFState.DocProps.FTopMarginTw := val;
  1809.         ipropYaBottom:
  1810.           FRTFState.DocProps.FBottomMarginTw := val;
  1811.         ipropPgnStart:
  1812.           FRTFState.DocProps.FPageNumberStart := val;
  1813.         ipropSbk:
  1814.           FRTFState.SectProps.FSectionBreakType := TRVRTFSectionBreakType(val);
  1815.         ipropPgnFormat:
  1816.           FRTFState.SectProps.FPageNumberFormat := TRVRTFPageNumberFormat(val);
  1817.         ipropFacingp:
  1818.           FRTFState.DocProps.FFacingPages := Boolean(val);
  1819.         ipropLandscape:
  1820.           FRTFState.DocProps.FLandscape := Boolean(val);
  1821.         ipropJust:
  1822.           FRTFState.ParaProps.FAlignment := TRVRTFAlignment(val);
  1823.         ipropLONumber:
  1824.           FRTFState.ParaProps.FListOverrideIndex := FListOverrideTable.FindListOverride(val);
  1825.         ipropLevel:
  1826.           FRTFState.ParaProps.FListLevel := val;        
  1827.         ipropDefF:
  1828.           if FRTFState.rds=rdsNorm then begin
  1829.             FRTFState.DefFontNumber := Val;
  1830.           end;
  1831.         ipropF:
  1832.           case FRTFState.rds of
  1833.             rdsFontTable:
  1834.               FFontTable.Add(val);
  1835.             rdsStyleSheet:
  1836.               FStyleSheet[FStyleSheet.Count-1].CharProps.FFontIndex  := FFontTable.GetFontIndex(val,RTFState.DefFontNumber);
  1837.             rdsNorm:
  1838.               FRTFState.CharProps.FFontIndex := FFontTable.GetFontIndex(val,RTFState.DefFontNumber);
  1839.             else
  1840.               ;
  1841.             end;
  1842.         ipropCharScaleX:
  1843.           FRTFState.CharProps.FCharScaleX := val;
  1844.         ipropCharSpacing:
  1845.           FRTFState.CharProps.FCharSpacingTw := val;
  1846.         {$IFNDEF RVDONOTUSETABS}
  1847.         ipropTabLeader:
  1848.           begin
  1849.             if not FRTFState.ParaProps.HasTabs then
  1850.               FRTFState.ParaProps.Tabs.AddNew;
  1851.             FRTFState.ParaProps.Tabs.GetLastTab.FLeader := TRVRTFTabLeader(val);
  1852.           end;
  1853.         ipropTabAlign:
  1854.           begin
  1855.             if not FRTFState.ParaProps.HasTabs then
  1856.               FRTFState.ParaProps.Tabs.AddNew;
  1857.             FRTFState.ParaProps.Tabs.GetLastTab.FAlign := TRVRTFTabAlign(val);
  1858.           end;
  1859.         ipropListTab:
  1860.           begin
  1861.             if not FRTFState.ParaProps.HasTabs then
  1862.               FRTFState.ParaProps.Tabs.AddNew;
  1863.             FRTFState.ParaProps.Tabs.GetLastTab.FIsListTab := True;
  1864.           end;
  1865.         ipropTX:
  1866.           begin
  1867.             if not FRTFState.ParaProps.HasTabs then
  1868.               FRTFState.ParaProps.Tabs.AddNew;
  1869.             FRTFState.ParaProps.Tabs.GetLastTab.FPositionTW := val;
  1870.             FRTFState.ParaProps.Tabs.AddNew;
  1871.           end;
  1872.         {$ENDIF}
  1873.         ipropPard,ipropPlain,ipropSectd,ipropTRowD:
  1874.           Result := ParseSpecialProperty(iprop, val);
  1875.         ipropKeepLinesTogether:
  1876.           FRTFState.ParaProps.FKeepLinesTogether := val<>0;
  1877.         ipropKeepWithNext:
  1878.           FRTFState.ParaProps.FKeepWithNext := val<>0;
  1879.         ipropParaBorderSide:
  1880.           begin
  1881.             FRTFState.FCurrentBorderType := rtf_bt_Para;
  1882.             FRTFState.ParaProps.FCurBorderSide := TRVRTFSide(Val);
  1883.           end;
  1884.         ipropTRBorderSide:
  1885.           begin
  1886.             FRTFState.FCurrentBorderType := rtf_bt_Row;
  1887.             FRTFState.RowProps.FCurBorderSide := TRVRTFSide(Val);
  1888.           end;
  1889.         ipropCLBorderSide:
  1890.           begin
  1891.             FRTFState.FCurrentBorderType := rtf_bt_Cell;
  1892.             FRTFState.RowProps.GetLastCellProp.FCurBorderSide := TRVRTFSide(Val);
  1893.           end;
  1894.         ipropParaBorderType:
  1895.           begin
  1896.             if FRTFState.GetCurrentBorderSide.FBorderType=rtf_brdr_None then
  1897.                FRTFState.GetCurrentBorderSide.FBorderType := TRVRTFBorderType(Val);
  1898.           end;
  1899.         ipropParaBorderWidth:
  1900.           begin
  1901.             FRTFState.GetCurrentBorderSide.FWidthTw := Val;
  1902.           end;
  1903.         ipropParaBorderColor:
  1904.           if (Val>=0) and (Val<ColorTable.Count) then
  1905.             FRTFState.GetCurrentBorderSide.FColor := ColorTable[Val];
  1906.         ipropParaColor:
  1907.           if (Val>=0) and (Val<ColorTable.Count) then
  1908.             FRTFState.ParaProps.FColor := ColorTable[Val];
  1909.         ipropParaFColor:
  1910.           if (Val>=0) and (Val<ColorTable.Count) then
  1911.             FRTFState.ParaProps.ForeColor := ColorTable[Val];
  1912.         ipropParaShading:
  1913.           FRTFState.ParaProps.Shading := Val;
  1914.         ipropParaBorderSpace:
  1915.           FRTFState.ParaProps.Border.Sides[FRTFState.ParaProps.FCurBorderSide].FSpaceTw := Val;
  1916.         ipropAnsiCodepage:
  1917.           FCodePage := Cardinal(Val);
  1918.         ipropPage:
  1919.           begin
  1920.             if Assigned(FOnRequiredPageBreak) then begin
  1921.               Result := OutputChar(#0, True, True);
  1922.               if Result<>rtf_ec_OK then
  1923.                 exit;
  1924.               FOnRequiredPageBreak(Self);
  1925.             end;
  1926.           end;
  1927.         { font table }
  1928.         ipropFontFamily:
  1929.           if FRTFState.rds = rdsFontTable then
  1930.             FFontTable[FFontTable.Count-1].Family := TRVRTFFontFamily(Val);
  1931.         ipropFCharset:
  1932.           {$IFDEF RICHVIEWCBDEF3}
  1933.           if FRTFState.rds = rdsFontTable then
  1934.             if Val>255 then
  1935.               FFontTable[FFontTable.Count-1].Charset := MAC_CHARSET
  1936.             else
  1937.               FFontTable[FFontTable.Count-1].Charset := Val
  1938.           {$ENDIF}
  1939.           ;
  1940.         ipropIntbl:
  1941.           begin
  1942.             FRTFState.ParaProps.FInTable := True;
  1943.           end;
  1944.         ipropPNSecLvl:
  1945.           begin
  1946.             ChangeDest(idestPNSecLvl, val)
  1947.           end;
  1948.         ipropS, ipropCS, ipropDS: ;
  1949.         { table }
  1950.         ipropItap:
  1951.           begin                            
  1952.             FRTFState.ParaProps.FNestingLevel := Val;
  1953.             if Val>0 then
  1954.               FRTFState.ParaProps.FInTable := True;
  1955.           end;
  1956.         ipropRowEnd:
  1957.           begin
  1958.             FRTFState.RowProps.Finalize;
  1959.             CheckTable(True);
  1960.             DoTable(rvf_tbl_RowEnd);
  1961.           end;
  1962.         ipropCellEnd:
  1963.           begin
  1964.             CheckTable(True);
  1965.             Result := OutputChar(#0,True,True);
  1966.             Position := rtf_ts_NewPara;
  1967.             DoTable(rvf_tbl_CellEnd);
  1968.           end;
  1969.         ipropRowAlign:
  1970.           begin
  1971.             FTableAlignment := TRVRTFAlignment(Val);
  1972.             FTableAlignmentDefined := True;
  1973.           end;
  1974.         ipropTRGapH:
  1975.           FRTFState.RowProps.FGapHTw := Val;
  1976.         ipropTRLeft:
  1977.           FRTFState.RowProps.FLeftTw := Val;
  1978.         ipropTRRowHeight:
  1979.           FRTFState.RowProps.FHeightTw := Val;
  1980.         ipropTRHeader:
  1981.           FRTFState.RowProps.FHeading := True;
  1982.         ipropTRPaddL:
  1983.           FRTFState.RowProps.FPaddingTw[rtf_side_Left] := Val;
  1984.         ipropTRPaddR:
  1985.           FRTFState.RowProps.FPaddingTw[rtf_side_Right] := Val;
  1986.         ipropTRPaddT:
  1987.           FRTFState.RowProps.FPaddingTw[rtf_side_Top] := Val;
  1988.         ipropTRPaddB:
  1989.           FRTFState.RowProps.FPaddingTw[rtf_side_Bottom] := Val;
  1990.         ipropTRPaddFL:
  1991.           FRTFState.RowProps.FUsePadding[rtf_side_Left] := Val=3;
  1992.         ipropTRPaddFR:
  1993.           FRTFState.RowProps.FUsePadding[rtf_side_Right] := Val=3;
  1994.         ipropTRPaddFT:
  1995.           FRTFState.RowProps.FUsePadding[rtf_side_Top] := Val=3;
  1996.         ipropTRPaddFB:
  1997.           FRTFState.RowProps.FUsePadding[rtf_side_Bottom] := Val=3;
  1998.         ipropTRSpdL:
  1999.           FRTFState.RowProps.FSpacingTw[rtf_side_Left] := Val;
  2000.         ipropTRSpdR:
  2001.           FRTFState.RowProps.FSpacingTw[rtf_side_Right] := Val;
  2002.         ipropTRSpdT:
  2003.           FRTFState.RowProps.FSpacingTw[rtf_side_Top] := Val;
  2004.         ipropTRSpdB:
  2005.           FRTFState.RowProps.FSpacingTw[rtf_side_Bottom] := Val;
  2006.         ipropTRSpdFL:
  2007.           FRTFState.RowProps.FUseSpacing[rtf_side_Left] := Val=3;
  2008.         ipropTRSpdFR:
  2009.           FRTFState.RowProps.FUseSpacing[rtf_side_Right] := Val=3;
  2010.         ipropTRSpdFT:
  2011.           FRTFState.RowProps.FUseSpacing[rtf_side_Top] := Val=3;
  2012.         ipropTRSpdFB:
  2013.           FRTFState.RowProps.FUseSpacing[rtf_side_Bottom] := Val=3;
  2014.         ipropTRwWidth:
  2015.           if FRTFState.RowProps.InvertWidth then
  2016.             FRTFState.RowProps.FBestWidth := -Val
  2017.           else
  2018.             FRTFState.RowProps.FBestWidth := Val;
  2019.         ipropTRftsWidth:
  2020.           case Val of
  2021.             2:
  2022.               begin
  2023.                 FRTFState.RowProps.InvertWidth := True;
  2024.                 FRTFState.RowProps.FBestWidth := - FRTFState.RowProps.BestWidth;
  2025.               end;
  2026.             3: ;
  2027.             else FRTFState.RowProps.FBestWidth := 0;
  2028.           end;
  2029.         ipropCLVMerge:
  2030.           if FRTFState.RowProps.GetLastCellProp.FVMerge<>rtf_cm_First then
  2031.             FRTFState.RowProps.GetLastCellProp.FVMerge := TRVRTFCellMerge(Val);
  2032.         ipropCLHMerge:
  2033.           if FRTFState.RowProps.GetLastCellProp.FHMerge<>rtf_cm_First then
  2034.             FRTFState.RowProps.GetLastCellProp.FHMerge := TRVRTFCellMerge(Val);
  2035.         ipropCLwWidth:
  2036.           begin
  2037.             if FRTFState.RowProps.GetLastCellProp.InvertWidth then
  2038.               FRTFState.RowProps.GetLastCellProp.FBestWidth := -Val
  2039.             else
  2040.               FRTFState.RowProps.GetLastCellProp.FBestWidth := Val;
  2041.           end;
  2042.         ipropCLftsWidth:
  2043.           case Val of
  2044.             2:
  2045.              begin
  2046.                 FRTFState.RowProps.GetLastCellProp.InvertWidth := True;
  2047.                 FRTFState.RowProps.GetLastCellProp.FBestWidth := - FRTFState.RowProps.GetLastCellProp.BestWidth;
  2048.              end;
  2049.             3: ;
  2050.             else FRTFState.RowProps.GetLastCellProp.FBestWidth := 0;
  2051.           end;
  2052.         ipropCLColor:
  2053.           begin
  2054.             if (Val>=0) and (Val<ColorTable.Count) then
  2055.               FRTFState.RowProps.GetLastCellProp.FColor := ColorTable[Val];
  2056.             if FRTFState.RowProps.GetLastCellProp.FColor=clWindowText then
  2057.               FRTFState.RowProps.GetLastCellProp.FColor := clNone;
  2058.           end;
  2059.         ipropCLFColor:
  2060.           if (Val>=0) and (Val<ColorTable.Count) then
  2061.             FRTFState.RowProps.GetLastCellProp.ForeColor := ColorTable[Val];
  2062.         ipropCLShading:
  2063.           FRTFState.RowProps.GetLastCellProp.Shading := Val;
  2064.         ipropCLVertAl:
  2065.           FRTFState.RowProps.GetLastCellProp.FVAlign := TRVRTFVAlign(Val);
  2066.         ipropCellX:
  2067.           begin
  2068.             FRTFState.RowProps.GetLastCellProp.FRightBoundaryTw := Val;
  2069.             FRTFState.RowProps.CellProps.AddNew;
  2070.             FRTFState.RowProps.AssumedLastCell := True;
  2071.           end;
  2072.         ipropNoTableEv:
  2073.            FRTFState.ParaProps.NoTableEv := True;
  2074.         ipropNoResetLev:
  2075.           FRTFState.ParaProps.NoResetLev := True;
  2076.         {$IFDEF RICHVIEW}
  2077.         ipropRVCellBestWidth:
  2078.           begin
  2079.             FRTFState.RowProps.GetLastCellProp.FBestWidth := Val;
  2080.             FRTFState.RowProps.RichViewSpecial := True;
  2081.           end;
  2082.         ipropRVCellBestHeight:
  2083.           begin
  2084.             FRTFState.RowProps.GetLastCellProp.BestHeight := Val;
  2085.             FRTFState.RowProps.RichViewSpecial := True;
  2086.           end;
  2087.         ipropRVTableBestWidth:
  2088.           begin
  2089.             FRTFState.RowProps.FBestWidth := Val;
  2090.             FRTFState.RowProps.RichViewSpecial := True;
  2091.           end;
  2092.         {$ENDIF}
  2093.         else
  2094.           begin
  2095.             // Result := rtf_ec_BadTable;
  2096.           end;
  2097.       end;
  2098.   end;
  2099. end;
  2100. //----------------------------------------------------------------------
  2101. // %%Function: ecParseSpecialProperty
  2102. // Set a property that requires code to evaluate.
  2103. function TRVRTFReader.ParseSpecialProperty(iprop: TRTFiprop; val: Integer): TRVRTFErrorCode;
  2104. begin
  2105.    Result := rtf_ec_Ok;
  2106.    case (iprop) of
  2107.      ipropPard:
  2108.         FRTFState.ParaProps.Reset;
  2109.      ipropPlain:
  2110.        begin
  2111.          if RTFState.DefFontIndex<0 then
  2112.            RTFState.DefFontIndex := FFontTable.GetFontIndex(RTFState.DefFontNumber,
  2113.              RTFState.DefFontNumber);
  2114.          FRTFState.CharProps.Reset(FRTFState.FDefLanguage, RTFState.DefFontIndex);
  2115.        end;
  2116.      ipropSectd:
  2117.         FRTFState.SectProps.Reset;
  2118.      ipropTRowD:
  2119.         FRTFState.RowProps.Reset;
  2120.      else
  2121.         Result := rtf_ec_BadTable;
  2122.    end;
  2123. end;
  2124. {------------------------------------------------------------------------------}
  2125. function TRVRTFReader.FindKeyword(const Keyword: String): Integer;
  2126. var min,max,cmp: Integer;
  2127. begin
  2128.   min := 0;
  2129.   max := isymMax;
  2130.   while max-min>1 do begin
  2131.     Result := (max+min) div 2;
  2132.     cmp := CompareStr(rgsymRtf[Result].Keyword,Keyword);
  2133.     if cmp=0 then
  2134.       exit;
  2135.     if cmp<0 then
  2136.       min := Result
  2137.     else
  2138.       max := Result;
  2139.   end;
  2140.   if Keyword = rgsymRtf[min].Keyword then
  2141.     Result := min
  2142.   else if (max<>min) and (Keyword = rgsymRtf[max].Keyword) then
  2143.     Result := max
  2144.   else
  2145.     Result := -1;
  2146. end;
  2147. {------------------------------------------------------------------------------}
  2148. // Search rgsymRtf for Keyword and evaluate it appropriately.
  2149. // Inputs:
  2150. // Keyword:   The RTF control to evaluate.
  2151. // param:       The parameter of the RTF control.
  2152. // fParam:      fTrue if the control had a parameter; (that is, if param is valid)
  2153. //              fFalse if it did not.
  2154. function TRVRTFReader.TranslateKeyword(const Keyword: String; param: Integer; fParam:Boolean): TRVRTFErrorCode;
  2155. var  isym: Integer;
  2156. begin
  2157.     Result := rtf_ec_Ok;
  2158.     // search for Keyword in rgsymRtf
  2159.     isym := FindKeyword(Keyword);
  2160.     if isym<0 then  begin            // control word not found
  2161.       if (fSkipDestIfUnk) then        // if this is a new destination
  2162.             FRTFState.rds := rdsSkip;          // skip the destination
  2163.                                     // else just discard it
  2164.         fSkipDestIfUnk := False;
  2165.         exit;
  2166.     end;
  2167.     // found it!  use kwd and idx to determine what to do with it.
  2168.     fSkipDestIfUnk := False;
  2169.     case rgsymRtf[isym].kwd of
  2170.       rtf_kwd_Prop:
  2171.         begin
  2172.           if (rgsymRtf[isym].UseDef or not fParam) then
  2173.             param := rgsymRtf[isym].DefValue;
  2174.           if FRTFState.rds=rdsNorm then begin
  2175.             if rgsymRtf[isym].AffectTo in [rtf_af_CharProp, rtf_af_BothProp] then begin
  2176.               Result := OutputChar(#0, {TRTFIPROP(rgsymRtf[isym].Idx)<>ipropPlain}False,True);
  2177.               if Result<>rtf_ec_OK then
  2178.                 exit;
  2179.             end;
  2180.           end;
  2181.           Result := ApplyPropChange(TRTFiprop(rgsymRtf[isym].idx), param);
  2182.         end;
  2183.       rtf_kwd_Char:
  2184.         if SkipNext=0 then
  2185.           Result := ParseChar(Char(rgsymRtf[isym].idx))
  2186.         else
  2187.           dec(SkipNext);
  2188.       rtf_kwd_WideChar:
  2189.         if SkipNext=0 then begin
  2190.           {$IFDEF RICHVIEWCBDEF3}
  2191.           if (RTFState.rds=rdsNorm) and Assigned(FOnNewUnicodeText) then
  2192.             OutputWideChar(WideChar(PWord(@(rgsymRtf[isym].DefValue))^))
  2193.           else
  2194.           {$ENDIF}
  2195.             ParseChar(Char(rgsymRtf[isym].idx));
  2196.           end
  2197.         else
  2198.           dec(SkipNext);
  2199.       rtf_kwd_Dest:
  2200.         Result := ChangeDest(TRTFidest(rgsymRtf[isym].idx), 0);
  2201.       rtf_kwd_Spec:
  2202.         Result := ParseSpecialKeyword(TRTFipfn(rgsymRtf[isym].idx));
  2203.       else
  2204.         Result := rtf_ec_BadTable;
  2205.     end;
  2206. end;
  2207. {------------------------------------------------------------------------------}
  2208. // Change to the destination specified by idest.
  2209. function TRVRTFReader.ChangeDest(idest:  TRTFidest; Val: Integer): TRVRTFErrorCode;
  2210. var b: Boolean;
  2211. begin
  2212.     Result := rtf_ec_Ok;
  2213.     if (FRTFState.rds = rdsSkip) then             // if we're skipping text,
  2214.       exit;                             // don't do anything
  2215.     case (idest) of
  2216.       idestObject:
  2217.         begin
  2218.           if Assigned(FOnNewObject) then begin
  2219.             FRTFState.rds := rdsObject;
  2220.             FObject := TRVRTFObject.Create;
  2221.             end
  2222.           else
  2223.             FRTFState.rds := rdsNorm;
  2224.         end;
  2225.       idestObjData:
  2226.         begin
  2227.           if FRTFState.rds = rdsObject then begin
  2228.             FRTFState.rds := rdsObjData;
  2229.             ObjectInserted := False;
  2230.             PicHexStrt := True;
  2231.             PicHexVal  := 0;
  2232.             end
  2233.           else
  2234.             FRTFState.rds := rdsSkip;
  2235.         end;
  2236.       idestObjResult:
  2237.         if ObjectInserted then
  2238.           FRTFState.rds := rdsSkip
  2239.         else
  2240.           FRTFState.rds := rdsNorm;
  2241.       idestShpPict:
  2242.         FRTFState.rds := rdsShpPict;
  2243.       idestNonShpPict:
  2244.         if ShpPictInserted then
  2245.           FRTFState.rds := rdsSkip
  2246.         else
  2247.           FRTFState.rds := rdsNorm;
  2248.       idestNestedTableProps:
  2249.         FRTFState.rds := rdsNorm;
  2250.       idestStyleSheetParaStyle:
  2251.          begin
  2252.            FStyleSheet[FStyleSheet.Count-1].FNumber    := Val;
  2253.            FStyleSheet[FStyleSheet.Count-1].FStyleType := rtf_sst_Par;
  2254.            FRTFState.rds := rdsStyleSheetEntry;
  2255.          end;
  2256.       idestStyleSheetCharStyle:
  2257.          begin
  2258.            FStyleSheet[FStyleSheet.Count-1].FNumber    := Val;
  2259.            FStyleSheet[FStyleSheet.Count-1].FStyleType := rtf_sst_Char;
  2260.            FRTFState.rds := rdsStyleSheetEntry;
  2261.          end;
  2262.       idestStyleSheetSectStyle:
  2263.          begin
  2264.            FStyleSheet[FStyleSheet.Count-1].FNumber    := Val;
  2265.            FStyleSheet[FStyleSheet.Count-1].FStyleType := rtf_sst_Sect;
  2266.            FRTFState.rds := rdsStyleSheetEntry;
  2267.          end;
  2268.       idestStyleSheet:
  2269.          begin
  2270.            FStyleSheet.Clear;
  2271.            FRTFState.rds := rdsStyleSheet;
  2272.            exit;
  2273.          end;
  2274.       idestFontTable:
  2275.          begin
  2276.            FFontTable.Clear;
  2277.            FRTFState.rds := rdsFontTable;
  2278.            exit;
  2279.          end;
  2280.       idestColorTable:
  2281.          begin
  2282.            FColorTable.Clear;
  2283.            FColorTable.Add;
  2284.            FRTFState.rds := rdsColorTable;
  2285.          end;
  2286.       idestPict:
  2287.          begin
  2288.            if FPicture<>nil then
  2289.              Result := rtf_ec_InvalidPicture
  2290.            else begin
  2291.              if Assigned(FOnNewPicture) then begin
  2292.                FPicture := TRVRTFPicture.Create;
  2293.                FPicture.FShpPict := FRTFState.rds=rdsShpPict;
  2294.              end;
  2295.              FRTFState.rds := rdsPict;
  2296.              PicHexStrt := True;
  2297.              PicHexVal  := 0;
  2298.            end;
  2299.          end;
  2300.       idestField:
  2301.          begin
  2302.            OutputChar(#0,True,True);
  2303.            FRTFState.rds := rdsField;
  2304.          end;
  2305.       idestFldInst:
  2306.          begin
  2307.            if FRTFState.rds=rdsField then begin
  2308.              RTFState.FFieldCode := '';
  2309.              RTFState.FFieldPictureIncluded := False;
  2310.              RTFState.FInvalidFieldPicture.Free;
  2311.              RTFState.FInvalidFieldPicture := nil;
  2312.              FRTFState.rds := rdsFldInst;
  2313.            end;
  2314.          end;
  2315.       idestFldRslt:
  2316.          begin
  2317.            FRTFState.rds := rdsNorm;
  2318.          end;
  2319.       idestHeader, idestFooter:
  2320.          begin
  2321.             case idest of
  2322.               idestHeader:
  2323.                 FRTFState.FHFType := rtf_hf_Header;
  2324.               idestFooter:
  2325.                 FRTFState.FHFType := rtf_hf_Footer;
  2326.             end;
  2327.             if Assigned(FOnHeaderFooter) then begin
  2328.               FOnHeaderFooter(Self, FRTFState.FHFType, True, b);
  2329.               if not b then
  2330.                 FRTFState.rds := rdsSkip
  2331.               end
  2332.             else
  2333.               FRTFState.rds := rdsSkip
  2334.          end;
  2335.       idestPN:
  2336.          begin
  2337.            FRTFState.rds := rdsPN;
  2338.            FMarkerProps.Free;
  2339.            FMarkerProps := TRVRTFMarkerProperties.Create;
  2340.          end;
  2341.       idestPNTextAfter:
  2342.          begin
  2343.            if FRTFState.rds=rdsPN then
  2344.              FRTFState.rds := rdsPNTextAfter
  2345.            else
  2346.              FRTFState.rds := rdsSkip;
  2347.          end;
  2348.       idestPNTextBefore:
  2349.          begin
  2350.            if FRTFState.rds=rdsPN then
  2351.              FRTFState.rds := rdsPNTextBefore
  2352.            else
  2353.              FRTFState.rds := rdsSkip;
  2354.          end;
  2355.       idestPNSecLvl:
  2356.          begin
  2357.            FCurPNSecLvl := val;
  2358.            FRTFState.rds := rdsPNSecLvl;
  2359.          end;
  2360.       idestListTable:
  2361.          begin
  2362.            FListTable.Clear;
  2363.            FRTFState.rds := rdsListTable;
  2364.          end;
  2365.       idestList:
  2366.          begin
  2367.            if FRTFState.rds<>rdsListTable then
  2368.              FRTFState.rds := rdsSkip
  2369.            else begin
  2370.              FListTable.AddNew;
  2371.              FRTFState.rds := rdsList;
  2372.            end;
  2373.          end;
  2374.       idestListName:
  2375.          begin
  2376.            if FRTFState.rds=rdsList then
  2377.              FRTFState.rds := rdsListName;
  2378.          end;
  2379.       idestListLevel:
  2380.          begin
  2381.            if FRTFState.rds<>rdsList then
  2382.              FRTFState.rds := rdsSkip
  2383.            else begin
  2384.              FListTable.GetLastList.AddNew;
  2385.              FRTFState.rds := rdsListLevel;
  2386.            end;
  2387.          end;
  2388.       idestLevelText:
  2389.          begin
  2390.            if FRTFState.rds<>rdsListLevel then
  2391.              FRTFState.rds := rdsSkip
  2392.            else
  2393.              FRTFState.rds := rdsListLevelText;
  2394.          end;
  2395.       idestLevelNumbers:
  2396.          begin
  2397.            if FRTFState.rds<>rdsListLevel then
  2398.              FRTFState.rds := rdsSkip
  2399.            else
  2400.              FRTFState.rds := rdsListLevelNumbers;
  2401.          end;
  2402.       idestLOTable:
  2403.          begin
  2404.            FListOverrideTable.Clear;
  2405.            FRTFState.rds := rdsLOTable;
  2406.          end;
  2407.       idestLO:
  2408.          begin
  2409.            if FRTFState.rds<>rdsLOTable then
  2410.              FRTFState.rds := rdsSkip
  2411.            else begin
  2412.              FListOverrideTable.AddNew;
  2413.              FRTFState.rds := rdsLO;
  2414.            end;
  2415.          end;
  2416.       idestLOLevel:
  2417.          begin
  2418.            if FRTFState.rds<>rdsLO then
  2419.              RTFState.rds := rdsSkip
  2420.            else begin
  2421.              FListOverrideTable.GetLastListOverride.AddNew;
  2422.              FRTFState.rds := rdsLOLevel;
  2423.            end;
  2424.          end;
  2425.       else
  2426.         FRTFState.rds := rdsSkip;              // when in doubt, skip it...
  2427.     end;
  2428. end;
  2429. {------------------------------------------------------------------------------}
  2430. function TRVRTFReader.GetFieldCommandValue(const s: String): String;
  2431. var NextCharIndex: Integer;
  2432. begin
  2433.   Result := GetFieldCommandValueEx(s, NextCharIndex);
  2434. end;
  2435. {------------------------------------------------------------------------------}
  2436. function TRVRTFReader.GetFieldCommandValueEx(const s: String;
  2437.   var NextCharIndex: Integer): String;
  2438. var i,j, k: Integer;
  2439. begin
  2440.   NextCharIndex := Length(s)+1;
  2441.   Result := '';
  2442.   for i := 2 to Length(s) do
  2443.     if (s[i]<>' ') and (s[i]<>'') and (s[i-1]=' ') then begin
  2444.       k := Length(s)+1;
  2445.       for j := i+1 to Length(s) do
  2446.         if (s[j]=' ') and ((s[i]<>'"') or ((j-1<>i) and (s[j-1]='"'))) then begin
  2447.           k := j;
  2448.           break;
  2449.         end;
  2450.       Result := Copy(s, i, k-i);
  2451.       if (Length(Result)>=2) and (Result[1]='"') then
  2452.         Result := Copy(Result,2, Length(Result)-2);
  2453.       NextCharIndex := k+1;
  2454.       break;
  2455.     end;
  2456. end;
  2457. {------------------------------------------------------------------------------}
  2458. function TRVRTFReader.InsertExternalPicture: TRVRTFErrorCode;
  2459. const Code1 = 'INCLUDEPICTURE';
  2460.       Code2 = 'IMPORT';
  2461.     {....................................................}
  2462.     function LoadGraphic(const FileName: String; var Invalid: Boolean): TGraphic;
  2463.     var pic: TPicture;
  2464.     begin
  2465.       Result := nil;
  2466.       Invalid := False;
  2467.       if Assigned(FOnImportPicture) then
  2468.         FOnImportPicture(Self, FileName, Result, Invalid);
  2469.       if Result=nil then begin
  2470.         pic := TPicture.Create;
  2471.         try
  2472.           try
  2473.             pic.LoadFromFile(FileName);
  2474.           except
  2475.           end;
  2476.           if pic.Graphic<>nil then begin
  2477.             Result := RV_CreateGraphics(TGraphicClass(pic.Graphic.ClassType));
  2478.             Result.Assign(pic.Graphic);
  2479.           end;
  2480.         finally
  2481.           pic.Free;
  2482.         end;
  2483.       end;
  2484.     end;
  2485.     {....................................................}
  2486. var s,s2: String;
  2487.     p: Integer;
  2488.     gr, gr2: TGraphic;
  2489.     Inserted, Invalid: Boolean;
  2490. begin
  2491.   Result := rtf_ec_OK;
  2492.   if not Assigned(FOnNewPicture) then
  2493.     exit;
  2494.   s := Trim(FRTFState.FFieldCode);
  2495.   if s='' then
  2496.     exit;
  2497.   if s[1] = '' then
  2498.     s := Copy(s, 2, Length(s));