📄 rvrtf.pas
字号:
unit RVRTF;
interface
{$I RV_Defs.inc}
uses Windows, Classes, Graphics, StdCtrls, SysUtils,
{$IFDEF RICHVIEW}
RVFuncs,
{$ENDIF}
RVClasses, Forms,
{$IFNDEF RVDONOTUSEJPEGIMAGE}
Jpeg,
{$ENDIF}
RVRTFErr;
type
TRVRTFHighlightConvert = (rtf_hl_Ignore, rtf_hl_FixedColors, rtf_hl_ColorTable);
TRVRTFReader = class;
TRVRTFPosition = (rtf_ts_ContinuePara, rtf_ts_NewLine, rtf_ts_NewPara);
TRVRTFNewTextEvent = procedure (Sender: TRVRTFReader; const Text: String; Position: TRVRTFPosition) of object;
TRVRTFHeaderFooterType = (rtf_hf_MainText, rtf_hf_Header, rtf_hf_Footer);
TRVRTFHeaderFooterEvent = procedure (Sender: TRVRTFReader; HFType: TRVRTFHeaderFooterType; Starting: Boolean) of object;
{$IFDEF RICHVIEWCBDEF3}
TRVRTFNewUnicodeTextEvent = procedure (Sender: TRVRTFReader; const Text: WideString; Position: TRVRTFPosition) of object;
{$ENDIF}
{------------------------------------------------------------------------------}
TRVRTFParaListType = (
// both for old and new style
rtf_pn_Decimal, rtf_pn_LowerLetter, rtf_pn_UpperLetter,
rtf_pn_LowerRoman, rtf_pn_UpperRoman,
// for new style
rtf_pn_Bullet
);
TRVRTFPictureType = (rtf_pict_EMF, rtf_pict_PNG, rtf_pict_JPEG,
rtf_pict_MacPict, rtf_pict_PmMetafile,
rtf_pict_WMF, rtf_pict_DIB, rtf_pict_DDB);
TRVRTFPicture = class
private
FType: TRVRTFPictureType;
FMetafileMapMode: Integer; // MM_ constant
FPicW, FPicH, FPicScaleX, FPicScaleY: Integer;
FWBMWidthBytes: Integer;
FMetafileWithBitmap: Boolean;
public
FData: TMemoryStream;
SuggestedWidth, SuggestedHeight: Integer;
constructor Create;
destructor Destroy; override;
property PicW: Integer read FPicW;
property PicH: Integer read FPicH;
property PicScaleX: Integer read FPicScaleX;
property PicScaleY: Integer read FPicScaleY;
property PicType: TRVRTFPictureType read FType;
property MetafileWithBitmap: Boolean read FMetafileWithBitmap;
end;
TRVRTFTableEventKind = (rvf_tbl_TableStart, rvf_tbl_TableEnd,
rvf_tbl_RowEnd, rvf_tbl_CellEnd);
TRVRTFTableEvent = procedure (Sender: TRVRTFReader; WhatHappens: TRVRTFTableEventKind) of object;
TRVRTFNewPictureEvent = procedure (Sender: TRVRTFReader; RTFPicture: TRVRTFPicture; Graphic: TGraphic;
Position: TRVRTFPosition) of object;
{-------------------- character properties -----------------------}
TRVRTFAlignment = (rtf_al_Left, rtf_al_Right, rtf_al_Center, rtf_al_Justify);
TRVRTFVAlign = (rtf_val_Top, rtf_val_Bottom, rtf_val_Center);
TRVRTFSScriptType = (rtf_ss_Normal, rtf_ss_Subscript, rtf_ss_Superscript);
TRVRTFFontStyleEx = (rtf_fs_AllCaps);
TRVRTFFontStylesEx = set of TRVRTFFontStyleEx;
TRVRTFCharProperties = class
private
FHidden: Boolean;
FSize: Integer;
FColor, FBackColor: TColor;
FFontIndex: Integer;
FStyle: TFontStyles;
FStyleEx: TRVRTFFontStylesEx;
FCharScaleX: Integer;
FSScriptType: TRVRTFSScriptType;
FCharSpacingTw: Integer;
FFontName: String;
public
constructor Create;
procedure Reset;
procedure Assign(Source: TRVRTFCharProperties);
property Size : Integer read FSize;
property Color : TColor read FColor;
property BackColor: TColor read FBackColor;
property FontIndex: Integer read FFontIndex;
property Style : TFontStyles read FStyle;
property StyleEx : TRVRTFFontStylesEx read FStyleEx;
property CharScaleX: Integer read FCharScaleX;
property SScriptType: TRVRTFSScriptType read FSScriptType;
property CharSpacingTw: Integer read FCharSpacingTw;
property Hidden: Boolean read FHidden;
property FontName: String read FFontName;
end;
{-------------------- paragraph properties -----------------------}
TRVRTFBorderType = (rtf_brdr_None,
rtf_brdr_SingleThickness, rtf_brdr_DoubleThickness,
rtf_brdr_Shadow, rtf_brdr_Double, rtf_brdr_Dot,
rtf_brdr_Dash, rtf_brdr_Hairline,
rtf_brdr_DashSmall, rtf_brdr_DotDash,
rtf_brdr_DotDotDash, rtf_brdr_Triple,
rtf_brdr_ThickThinSmall, rtf_brdr_ThinThickSmall,
rtf_brdr_ThinThickThinSmall,
rtf_brdr_ThickThinMed, rtf_brdr_ThinThickMed,
rtf_brdr_ThinThickThinMed,
rtf_brdr_ThickThinLarge, rtf_brdr_ThinThickLarge,
rtf_brdr_ThinThickThinLarge,
rtf_brdr_Wavy, rtf_brdr_DoubleWavy,
rtf_brdr_Striped, rtf_brdr_Emboss,
rtf_brdr_Engrave,
rtf_brdr_Inset, rtf_brdr_Outset);
TRVRTFSide = (rtf_side_Left, rtf_side_Top, rtf_side_Right, rtf_side_Bottom);
TRVRTFBorderSide = class
private
FBorderType: TRVRTFBorderType;
FWidthTw: Integer;
FColor: TColor;
FSpaceTw: Integer; // Space between borders and the paragraph
public
procedure Assign(Source: TRVRTFBorderSide);
property BorderType: TRVRTFBorderType read FBorderType;
procedure Reset;
property WidthTw : Integer read FWidthTw;
property Color : TColor read FColor;
property SpaceTw : Integer read FSpaceTw;
end;
TRVRTFParaBorder = class
private
FSides: array [TRVRTFSide] of TRVRTFBorderSide;
function GetSides(Index: TRVRTFSide): TRVRTFBorderSide;
public
procedure Assign(Source: TRVRTFParaBorder);
destructor Destroy; override;
procedure Reset;
property Sides[Index:TRVRTFSide]:TRVRTFBorderSide read GetSides;
end;
TRVRTFMarkerProp = (rtfmp_FontIndex, rtfmp_Size, rtfmp_Color,
rtfmp_Bold, rtfmp_Italic, rtfmp_Underline, rtfmp_StrikeOut);
TRVRTFMarkerProps = set of TRVRTFMarkerProp;
TRVRTFCustomMarkerProperties = class
private
FListType: TRVRTFParaListType;
FFontIndex, FFontSize, FIndentTw, FSpaceTw, FStart: Integer;
FFontStyle: TFontStyles;
FColor: TColor;
FAlignment: TRVRTFAlignment;
FFixedProperties: TRVRTFMarkerProps;
procedure ChangeFontStyle(fs: TFontStyle; Val: Integer);
public
constructor Create;
procedure Reset; dynamic;
procedure Assign(Source: TRVRTFCustomMarkerProperties; FromDefaults: Boolean);
procedure UpdateFrom(CharProps: TRVRTFCharProperties);
property ListType: TRVRTFParaListType read FListType;
property FontIndex: Integer read FFontIndex;
property FontSize: Integer read FFontSize;
property IndentTw: Integer read FIndentTw;
property SpaceTw: Integer read FSpaceTw;
property Start: Integer read FStart;
property FontStyle: TFontStyles read FFontStyle;
property Color : TColor read FColor;
property Alignment: TRVRTFAlignment read FAlignment;
end;
TRVRTFMarkerProperties = class (TRVRTFCustomMarkerProperties)
private
FLevel: Integer;
FHanging: Boolean;
FTextAfter, FTextBefore: String;
public
procedure Reset; override;
procedure Assign(Source: TRVRTFMarkerProperties; FromDefaults: Boolean);
property Level: Integer read FLevel;
property TextAfter: String read FTextAfter;
property TextBefore: String read FTextBefore;
property Hanging: Boolean read FHanging;
end;
TRVRTFLevelFollow97 = (rtf_lf_Tab, rtf_lf_Space, rtf_lf_None);
TRVRTFListLevel97 = class (TRVRTFCustomMarkerProperties)
private
FOldStyle, FLegal, FNoRestart: Boolean;
FText,FNumbers: String;
{$IFDEF RICHVIEWCBDEF3}
FTextW: WideString;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -