📄 jvrichedit.pas
字号:
end;
TReObject = _ReObject;
EMSTextConversionError = class(Exception)
private
FErrorCode: FCE;
public
constructor Create(const Msg: string; AErrorCode: FCE = 0);
property ErrorCode: FCE read FErrorCode write FErrorCode;
end;
(* make Delphi 5 compiler happy // andreas
{ RichEdit GUIDs }
IID_IRichEditOle: TGUID = (
D1: $00020D00; D2: $0000; D3: $0000; D4: ($C0, $00, $00, $00, $00, $00, $00, $46));
IID_IRichEditOleCallback: TGUID = (
D1: $00020D03; D2: $0000; D3: $0000; D4: ($C0, $00, $00, $00, $00, $00, $00, $46));
*)
{
* IRichEditOle
*
* Purpose:
* Interface used by the client of RichEdit to perform OLE-related
* operations.
*
* The methods herein may just want to be regular Windows messages.
}
IRichEditOle = interface(IUnknown)
['{00020d00-0000-0000-c000-000000000046}']
function GetClientSite(out clientSite: IOleClientSite): HRESULT; stdcall;
function GetObjectCount: HRESULT; stdcall;
function GetLinkCount: HRESULT; stdcall;
function GetObject(iob: Longint; out ReObject: TReObject;
dwFlags: DWORD): HRESULT; stdcall;
function InsertObject(var ReObject: TReObject): HRESULT; stdcall;
function ConvertObject(iob: Longint; rclsidNew: TIID;
lpstrUserTypeNew: LPCSTR): HRESULT; stdcall;
function ActivateAs(rclsid: TIID; rclsidAs: TIID): HRESULT; stdcall;
function SetHostNames(lpstrContainerApp: LPCSTR;
lpstrContainerObj: LPCSTR): HRESULT; stdcall;
function SetLinkAvailable(iob: Longint; fAvailable: BOOL): HRESULT; stdcall;
function SetDvaspect(iob: Longint; dvAspect: DWORD): HRESULT; stdcall;
function HandsOffStorage(iob: Longint): HRESULT; stdcall;
function SaveCompleted(iob: Longint; const stg: IStorage): HRESULT; stdcall;
function InPlaceDeactivate: HRESULT; stdcall;
function ContextSensitiveHelp(fEnterMode: BOOL): HRESULT; stdcall;
function GetClipboardData(var chrg: TCharRange; reco: DWORD;
out dataObj: IDataObject): HRESULT; stdcall;
function ImportDataObject(dataObj: IDataObject; cf: TClipFormat;
hMetaPict: HGLOBAL): HRESULT; stdcall;
end;
{
* IRichEditOleCallback
*
* Purpose:
* Interface used by the RichEdit to get OLE-related stuff from the
* application using RichEdit.
}
IRichEditOleCallback = interface(IUnknown)
['{00020d03-0000-0000-c000-000000000046}']
function GetNewStorage(out stg: IStorage): HRESULT; stdcall;
function GetInPlaceContext(out Frame: IOleInPlaceFrame;
out Doc: IOleInPlaceUIWindow;
lpFrameInfo: POleInPlaceFrameInfo): HRESULT; stdcall;
function ShowContainerUI(fShow: BOOL): HRESULT; stdcall;
function QueryInsertObject(const clsid: TCLSID; const stg: IStorage;
cp: Longint): HRESULT; stdcall;
function DeleteObject(const oleobj: IOleObject): HRESULT; stdcall;
function QueryAcceptData(const dataObj: IDataObject;
var cfFormat: TClipFormat; reco: DWORD; fReally: BOOL;
hMetaPict: HGLOBAL): HRESULT; stdcall;
function ContextSensitiveHelp(fEnterMode: BOOL): HRESULT; stdcall;
function GetClipboardData(const chrg: TCharRange; reco: DWORD;
out dataObj: IDataObject): HRESULT; stdcall;
function GetDragDropEffect(fDrag: BOOL; grfKeyState: DWORD;
var dwEffect: DWORD): HRESULT; stdcall;
function GetContextMenu(seltype: Word; const oleobj: IOleObject;
const chrg: TCharRange; out Menu: HMENU): HRESULT; stdcall;
end;
TConversionFormatList = class(TObjectList)
private
FRTFConvIndex: Integer;
FTextConvIndex: Integer;
function GetItem(Index: Integer): TJvConversion;
public
constructor Create; virtual;
{ GetConverter implicitly calls Result.Init, thus caller must call Result.Done }
function GetConverter(AParentWindow: THandle; const AFileName: string;
const Kind: TJvConversionKind): TJvConversion; overload;
function GetConverter(AParentWindow: THandle; AStream: TStream;
const Kind: TJvConversionKind): TJvConversion; overload;
function GetFilter(const AKind: TJvConversionKind): string;
function DefaultConverter: TJvConversion;
property Items[Index: Integer]: TJvConversion read GetItem {write SetItem}; default;
end;
TImageDataObject = class(TInterfacedObject, IDataObject)
private
FGraphic: TGraphic;
public
constructor Create(AGraphic: TGraphic); virtual;
{ IDataObject }
function GetData(const FormatEtcIn: TFormatEtc; out Medium: TStgMedium):
HRESULT; stdcall;
function GetDataHere(const FormatEtc: TFormatEtc; out Medium: TStgMedium):
HRESULT; stdcall;
function QueryGetData(const FormatEtc: TFormatEtc): HRESULT;
stdcall;
function GetCanonicalFormatEtc(const FormatEtc: TFormatEtc;
out FormatEtcOut: TFormatEtc): HRESULT; stdcall;
function SetData(const FormatEtc: TFormatEtc; var Medium: TStgMedium;
fRelease: BOOL): HRESULT; stdcall;
function EnumFormatEtc(dwDirection: Longint; out EnumFormatEtc:
IEnumFormatEtc): HRESULT; stdcall;
function DAdvise(const FormatEtc: TFormatEtc; advf: Longint;
const advSink: IAdviseSink; out dwConnection: Longint): HRESULT; stdcall;
function DUnadvise(dwConnection: Longint): HRESULT; stdcall;
function EnumDAdvise(out enumAdvise: IEnumStatData): HRESULT;
stdcall;
end;
TJvRichEditStrings = class(TStrings)
private
FRichEdit: TJvCustomRichEdit;
FFormat: TRichStreamFormat;
FMode: TRichStreamModes;
procedure EnableChange(const Value: Boolean);
protected
procedure ProgressCallback(Sender: TObject);
function Get(Index: Integer): string; override;
function GetCount: Integer; override;
procedure Put(Index: Integer; const S: string); override;
procedure SetUpdateState(Updating: Boolean); override;
procedure SetTextStr(const Value: string); override;
procedure DoImport(AConverter: TJvConversion);
procedure DoExport(AConverter: TJvConversion);
public
procedure Clear; override;
procedure AddStrings(Strings: TStrings); override;
procedure Delete(Index: Integer); override;
procedure Insert(Index: Integer; const S: string); override;
procedure LoadFromFile(const FileName: string); override;
procedure LoadFromStream(Stream: TStream); override;
procedure SaveToFile(const FileName: string); override;
procedure SaveToStream(Stream: TStream); override;
property Format: TRichStreamFormat read FFormat write FFormat;
property Mode: TRichStreamModes read FMode write FMode;
end;
TMSTextConversionThread = class(TThread)
protected
procedure Execute; override;
public
constructor Create; virtual;
end;
{ TOleUILinkInfo - helper interface for Object Properties dialog }
TOleUILinkInfo = class(TInterfacedObject, IOleUILinkInfo)
private
FReObject: TReObject;
FRichEdit: TJvCustomRichEdit;
FOleLink: IOleLink;
public
constructor Create(ARichEdit: TJvCustomRichEdit; ReObject: TReObject);
function GetNextLink(dwLink: Longint): Longint; stdcall;
function SetLinkUpdateOptions(dwLink: Longint;
dwUpdateOpt: Longint): HRESULT; stdcall;
function GetLinkUpdateOptions(dwLink: Longint;
var dwUpdateOpt: Longint): HRESULT; stdcall;
function SetLinkSource(dwLink: Longint; pszDisplayName: PChar;
lenFileName: Longint; var chEaten: Longint;
fValidateSource: BOOL): HRESULT; stdcall;
function GetLinkSource(dwLink: Longint; var pszDisplayName: PChar;
var lenFileName: Longint; var pszFullLinkType: PChar;
var pszShortLinkType: PChar; var fSourceAvailable: BOOL;
var fIsSelected: BOOL): HRESULT; stdcall;
function OpenLinkSource(dwLink: Longint): HRESULT; stdcall;
function UpdateLink(dwLink: Longint; fErrorMessage: BOOL;
fErrorAction: BOOL): HRESULT; stdcall;
function CancelLink(dwLink: Longint): HRESULT; stdcall;
function GetLastUpdate(dwLink: Longint;
var LastUpdate: TFileTime): HRESULT; stdcall;
end;
{ TOleUIObjInfo - helper interface for Object Properties dialog }
TOleUIObjInfo = class(TInterfacedObject, IOleUIObjInfo)
private
FRichEdit: TJvCustomRichEdit;
FReObject: TReObject;
public
constructor Create(ARichEdit: TJvCustomRichEdit; ReObject: TReObject);
function GetObjectInfo(dwObject: Longint;
var dwObjSize: Longint; var lpszLabel: PChar;
var lpszType: PChar; var lpszShortType: PChar;
var lpszLocation: PChar): HRESULT; stdcall;
function GetConvertInfo(dwObject: Longint; var ClassID: TCLSID;
var wFormat: Word; var ConvertDefaultClassID: TCLSID;
var lpClsidExclude: PCLSID; var cClsidExclude: Longint): HRESULT; stdcall;
function ConvertObject(dwObject: Longint;
const clsidNew: TCLSID): HRESULT; stdcall;
function GetViewInfo(dwObject: Longint; var hMetaPict: HGLOBAL;
var dvAspect: Longint; var nCurrentScale: Integer): HRESULT; stdcall;
function SetViewInfo(dwObject: Longint; hMetaPict: HGLOBAL;
dvAspect: Longint; nCurrentScale: Integer;
bRelativeToOrig: BOOL): HRESULT; stdcall;
end;
TRichEditOleCallback = class(TObject, IUnknown, IRichEditOleCallback)
private
FDocForm: IVCLFrameForm;
FFrameForm: IVCLFrameForm;
FAccelTable: HACCEL;
FAccelCount: Integer;
FAutoScroll: Boolean;
procedure CreateAccelTable;
procedure DestroyAccelTable;
procedure AssignFrame;
private
FRefCount: Longint;
FRichEdit: TJvCustomRichEdit;
public
constructor Create(ARichEdit: TJvCustomRichEdit);
destructor Destroy; override;
function QueryInterface(const iid: TGUID; out Obj): HRESULT; stdcall;
function _AddRef: Longint; stdcall;
function _Release: Longint; stdcall;
function GetNewStorage(out stg: IStorage): HRESULT; stdcall;
function GetInPlaceContext(out Frame: IOleInPlaceFrame;
out Doc: IOleInPlaceUIWindow;
lpFrameInfo: POleInPlaceFrameInfo): HRESULT; stdcall;
function GetClipboardData(const chrg: TCharRange; reco: DWORD;
out dataObj: IDataObject): HRESULT; stdcall;
function GetContextMenu(seltype: Word; const oleobj: IOleObject;
const chrg: TCharRange; out Menu: HMENU): HRESULT; stdcall;
function ShowContainerUI(fShow: BOOL): HRESULT; stdcall;
function QueryInsertObject(const clsid: TCLSID; const stg: IStorage;
cp: Longint): HRESULT; stdcall;
function DeleteObject(const oleobj: IOleObject): HRESULT; stdcall;
function QueryAcceptData(const dataObj: IDataObject; var cfFormat: TClipFormat;
reco: DWORD; fReally: BOOL; hMetaPict: HGLOBAL): HRESULT; stdcall;
function ContextSensitiveHelp(fEnterMode: BOOL): HRESULT; stdcall;
function GetDragDropEffect(fDrag: BOOL; grfKeyState: DWORD;
var dwEffect: DWORD): HRESULT; stdcall;
end;
const
{ File Conversion Errors }
fceTrue = FCE(1); // IsFormatCorrect32: recognized the input file.
fceNoErr = FCE(0); // IsFormatCorrect32: Did not recognize the input file.
// Operation completed successfully for other APIs
fceOpenInFileErr = FCE(-1); // could not open input file
fceReadErr = FCE(-2); // error during read
fceOpenConvErr = FCE(-3); // error opening conversion file (obsolete)
fceWriteErr = FCE(-4); // error during write
fceInvalidFile = FCE(-5); // invalid data in conversion file
fceOpenExceptErr = FCE(-6); // error opening exception file (obsolete)
fceWriteExceptErr = FCE(-7); // error writing exception file (obsolete)
fceNoMemory = FCE(-8); // out of memory
fceInvalidDoc = FCE(-9); // invalid document (obsolete)
fceDiskFull = FCE(-10); // out of space on output (obsolete)
fceDocTooLarge = FCE(-11); // conversion document too large for target (obsolete)
fceOpenOutFileErr = FCE(-12); // could not open output file
fceUserCancel = FCE(-13); // conversion cancelled by user
fceWrongFileType = FCE(-14); // wrong file type for this converter
CTwipsPerInch = 1440;
CTwipsPerPoint = 20;
CHundredthMMPerInch = 2540;
CPointsPerInch = 72;
RichEdit10ModuleName = 'RICHED32.DLL';
RichEdit20ModuleName = 'RICHED20.DLL';
FT_DOWN = 1;
// PARAFORMAT2 wNumberingStyle options
PFNS_PAREN = $0000; // default, e.g., 1)
PFNS_PARENS = $0100; // tomListParentheses/256, e.g., (1)
PFNS_PERIOD = $0200; // tomListPeriod/256, e.g., 1.
PFNS_PLAIN = $0300; // tomListPlain/256, e.g., 1
PFNS_NONUMBER = $0400; // Used for continuation w/o number
PFNS_NEWNUMBER = $8000; // Start new number with wNumberingStart
// (can be combined with other PFNS_xxx)
EM_SETTYPOGRAPHYOPTIONS = (WM_USER + 202);
EM_GETTYPOGRAPHYOPTIONS = (WM_USER + 203);
// Options for EM_SETTYPOGRAPHYOPTIONS
TO_ADVANCEDTYPOGRAPHY = 1;
TO_SIMPLELINEBREAK = 2;
TO_DISABLECUSTOMTEXTOUT = 4;
TO_ADVANCEDLAYOUT = 8;
// Underline types. RE 1.0 displays only CFU_UNDERLINE
CFU_CF1UNDERLINE = $FF; // Map charformat's bit underline to CF2
CFU_INVERT = $FE; // For IME composition fake a selection
CFU_UNDERLINETHICKLONGDASH = 18; // (*) display as dash
CFU_UNDERLINETHICKDOTTED = 17; // (*) display as dot
CFU_UNDERLINETHICKDASHDOTDOT = 16; // (*) display as dash dot dot
CFU_UNDERLINETHICKDASHDOT = 15; // (*) display as dash dot
CFU_UNDERLINETHICKDASH = 14; // (*) display as dash
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -