📄 crvdata.pas
字号:
function FindControlItemNo(actrl: TControl): Integer;
function GetItemStyle(ItemNo: Integer): Integer;
function SaveTextToStream(const Path: String; Stream: TStream; LineWidth: Integer;
SelectionOnly, TextOnly, Unicode: Boolean):Boolean;
function SaveText(const FileName: String; LineWidth: Integer; Unicode: Boolean):Boolean;
function LoadText(const FileName: String; StyleNo, ParaNo: Integer;
AsSingleParagraph: Boolean):Boolean;
{$IFNDEF RVDONOTUSEHTML}
function SaveBackgroundToHTML(bmp: TBitmap; Color: TColor;
const Path, ImagesPrefix: String; var imgSaveNo: Integer;
OverrideImages: Boolean): String;
function SaveHTMLToStreamEx(Stream: TStream;
const Path, Title, ImagesPrefix, ExtraStyles, ExternalCSS, CPPrefix: String;
Options: TRVSaveOptions; Color: TColor; var CurrentFileColor: TColor;
var imgSaveNo: Integer; LeftMargin, TopMargin, RightMargin, BottomMargin: Integer;
Background: TRVBackground; Bullets: TRVList): Boolean; dynamic;
function SaveHTMLToStream(Stream: TStream; const Path, Title,ImagesPrefix: String;
Options: TRVSaveOptions; Color: TColor; var imgSaveNo: Integer;
LeftMargin, TopMargin, RightMargin, BottomMargin: Integer;
Background: TRVBackground; Bullets: TRVList): Boolean; dynamic;
function SaveHTMLEx(const FileName, Title, ImagesPrefix, ExtraStyles,
ExternalCSS, CPPrefix: String; Options: TRVSaveOptions;
Color: TColor; var CurrentFileColor: TColor;
var imgSaveNo: Integer; LeftMargin, TopMargin, RightMargin, BottomMargin: Integer;
Background: TRVBackground): Boolean;
function SaveHTML(const FileName,Title,ImagesPrefix: String;
Options: TRVSaveOptions; Color: TColor; var imgSaveNo: Integer;
LeftMargin, TopMargin, RightMargin, BottomMargin: Integer;
Background: TRVBackground): Boolean;
{$ENDIF}
{$IFNDEF RVDONOTUSEUNICODE}
function GetTextInItemFormatA(ItemNo: Integer; const s: String): String;
{$IFDEF RICHVIEWCBDEF3}
function GetTextInItemFormatW(ItemNo: Integer; const s: WideString): String;
procedure AddNLWTag(const s: WideString; StyleNo, ParaNo, Tag: Integer);
function GetItemTextW(ItemNo: Integer): WideString;
procedure SetItemTextW(ItemNo: Integer; const s: WideString);
{$ENDIF}
procedure AddNLATag(const s: String; StyleNo, ParaNo, Tag: Integer);
procedure AddTextNLW(const s: String; StyleNo, FirstParaNo, OtherParaNo: Integer;
DefAsSingleParagraph: Boolean);
function LoadTextW(const FileName: String; StyleNo, ParaNo: Integer; DefAsSingleParagraph: Boolean):Boolean;
function GetItemTextA(ItemNo: Integer): String;
procedure SetItemTextA(ItemNo: Integer; const s: String);
{$ENDIF}
function GetItemText(ItemNo: Integer): String;
procedure SetItemText(ItemNo: Integer; const s: String);
procedure SetAddParagraphMode(AllowNewPara: Boolean);
procedure DeleteItems(FirstItemNo, Count: Integer); dynamic;
procedure DeleteSection(const CpName: String);
function GetOffsAfterItem(ItemNo: Integer): Integer;
function GetOffsBeforeItem(ItemNo: Integer): Integer;
procedure AppendFrom(Source: TCustomRVData);
function GetRVFSaveScope(SelectionOnly: Boolean):TRVFSaveScope;
{$IFNDEF RVDONOTUSERVF}
function LoadRVFFromStream(Stream: TStream;
var Color: TColor;
Background: TRVBackground;
Layout: TRVLayoutInfo):Boolean;
function InsertRVFFromStream(Stream: TStream; Index: Integer;
var Color: TColor;
Background: TRVBackground;
Layout: TRVLayoutInfo;
AllowReplaceStyles: Boolean):Boolean;
function AppendRVFFromStream(Stream: TStream; ParaNo: Integer;
var Color: TColor;
Background: TRVBackground):Boolean;
function LoadRVF(const FileName: String;
var Color: TColor;
Background: TRVBackground;
Layout: TRVLayoutInfo):Boolean;
//SelectionOnly=True - reserved here
function SaveRVFToStream(Stream: TStream; SelectionOnly: Boolean;
Color: TColor;
Background: TRVBackground;
Layout: TRVLayoutInfo):Boolean;
function SaveRVFToStreamEx(Stream: TStream; SaveScope: TRVFSaveScope;
Color: TColor;
Background: TRVBackground;
Layout: TRVLayoutInfo):Boolean;
//SelectionOnly=True - reserved here
function SaveRVF(const FileName: String; SelectionOnly: Boolean;
Color: TColor;
Background: TRVBackground;
Layout: TRVLayoutInfo):Boolean;
{$ENDIF}
{$IFNDEF RVDONOTUSERTF}
{$IFNDEF RVDONOTUSELISTS}
procedure SaveRTFListTable97(Stream: TStream; ColorList: TRVColorList;
ListOverrideOffsetsList: TRVIntegerList;
FontTable: TRVRTFFontTable; tpp: Double);
{$ENDIF}
function SaveRTFToStream(Stream: TStream; SelectionOnly: Boolean;
Level: Integer; Color: TColor; Background: TRVBackground; ColorList: TRVColorList;
StyleToFont, ListOverrideOffsetsList1, ListOverrideOffsetsList2: TRVIntegerList;
FontTable: TRVRTFFontTable; tpp: Double):Boolean; dynamic;
function SaveRTF(const FileName: String; SelectionOnly: Boolean;
Color: TColor;
Background: TRVBackground):Boolean;
{$ENDIF}
{$IFNDEF RVDONOTUSERTFIMPORT}
function LoadRTFFromStream(Stream: TStream):TRVRTFErrorCode;
function LoadRTF(const FileName: String):TRVRTFErrorCode;
{$ENDIF}
function GetParentData: TCustomRVData; virtual;
function GetRootData: TCustomRVData; virtual;
function GetAbsoluteParentData: TCustomRVData; virtual;
function GetAbsoluteRootData: TCustomRVData; virtual;
function GetItemNo(Item: TCustomRVItemInfo): Integer;
function GetItem(ItemNo: Integer): TCustomRVItemInfo;
procedure Inserting(RVData: TCustomRVData; Safe: Boolean);
procedure Beep;
{$IFNDEF RVDONOTUSELISTS}
function GetMarkers(AllowCreate: Boolean): TRVMarkerList; dynamic;
function SetListMarkerInfo(AItemNo, AListNo, AListLevel, AStartFrom, AParaNo: Integer; AUseStartFrom: Boolean): Integer;
procedure RecalcMarker(AItemNo: Integer; AllowCreateList: Boolean);
procedure RemoveListMarker(ItemNo: Integer);
function GetListMarkerInfo(AItemNo: Integer; var AListNo, AListLevel, AStartFrom: Integer; var AUseStartFrom: Boolean): Integer;
procedure AddMarkerInList(ItemNo: Integer);
procedure DeleteMarkerFromList(Item: TCustomRVItemInfo; Clearing: Boolean);
{$ENDIF}
function Edit: TCustomRVData; dynamic;
property Items: TStringList read FItems;
property ItemCount: Integer read GetItemCount;
property Options: TRVOptions read GetOptions write SetOptions;
property RVFOptions: TRVFOptions read GetRVFOptions write SetRVFOptions;
property RTFOptions: TRVRTFOptions read GetRTFOptions write SetRTFOptions;
property RVFWarnings: TRVFWarnings read GetRVFWarnings write SetRVFWarnings;
property FirstJumpNo: Integer read FFirstJumpNo write FFirstJumpNo;
property PageBreaksBeforeItems[Index: Integer]: Boolean
read GetPageBreaksBeforeItems write SetPageBreaksBeforeItems;
published
{ Published declarations }
end;
TRVRTFFontTableItem = class
public
FontName: String;
{$IFDEF RICHVIEWCBDEF3}
Charset: TFontCharset;
{$ENDIF}
end;
TRVRTFFontTable = class (TRVList)
private
function Get(Index: Integer): TRVRTFFontTableItem;
procedure Put(Index: Integer; const Value: TRVRTFFontTableItem);
public
function Find(const FontName: String
{$IFDEF RICHVIEWCBDEF3}
; Charset: TFontCharset
{$ENDIF}): Integer;
function AddUnique(const FontName: String
{$IFDEF RICHVIEWCBDEF3}
; Charset: TFontCharset
{$ENDIF}): Integer;
property Items[Index: Integer]: TRVRTFFontTableItem read Get write Put; default;
end;
procedure RVCheckUni(Length: Integer);
{$IFNDEF RVDONOTUSEHTML}
{$IFDEF RICHVIEWCBDEF3}
function RV_CharSet2HTMLLang(CharSet: TFontCharset): String;
{$ENDIF}
function RV_MakeHTMLStr(const str:String;NoEmptyLines,SpecialCode:Boolean): String;
{$ENDIF}
{$IFNDEF RVDONOTUSERTF}
procedure RVSaveFontToRTF(Stream: TStream; Font: TFont;
ColorList: TRVColorList; FontTable: TRVRTFFontTable;
RVStyle: TRVStyle);
procedure RVWriteUnicodeRTFStr(Stream: TStream;
const s: String;
CodePage: TRVCodePage;
SaveAnsi, SpecialCode: Boolean);
function RVMakeRTFStr(const s:String; SpecialCode: Boolean): String;
{$ENDIF}
procedure RV_ReplaceStr(var str: String; oldstr, newstr: String);
const
RichViewPixelsPerInch : Integer = 0;
implementation
uses RVFMisc, RVStr, RVRTFProps;
const RVFVersion = 1;
RVFSubVersion = 2;
const
crlf = #13#10;
{==============================================================================}
procedure RVRaiseUni;
begin
raise ERichViewError.Create(errRVUnicode);
end;
{------------------------------------------------------------------------------}
procedure RVCheckUni(Length: Integer);
begin
if Length mod 2 <> 0 then
RVRaiseUni;
end;
{================================ TRTFFontTable ===============================}
{------------------------------------------------------------------------------}
function TRVRTFFontTable.Find(const FontName: String
{$IFDEF RICHVIEWCBDEF3}
; Charset: TFontCharset
{$ENDIF}): Integer;
var i: Integer;
begin
for i := 0 to Count-1 do
if (AnsiCompareText(Items[i].FontName,FontName)=0)
{$IFDEF RICHVIEWCBDEF3}
and (Items[i].Charset = Charset)
{$ENDIF}
then begin
Result := i;
exit;
end;
Result := -1;
end;
{------------------------------------------------------------------------------}
function TRVRTFFontTable.AddUnique(const FontName: String
{$IFDEF RICHVIEWCBDEF3}
; Charset: TFontCharset
{$ENDIF}): Integer;
var item: TRVRTFFontTableItem;
begin
Result := Find(FontName{$IFDEF RICHVIEWCBDEF3}, Charset{$ENDIF});
if Result<0 then begin
item := TRVRTFFontTableItem.Create;
item.FontName := FontName;
{$IFDEF RICHVIEWCBDEF3}
item.Charset := Charset;
{$ENDIF}
Add(item);
Result := Count-1;
end;
end;
{------------------------------------------------------------------------------}
function TRVRTFFontTable.Get(Index: Integer): TRVRTFFontTableItem;
begin
Result := TRVRTFFontTableItem(inherited Get(Index));
end;
{------------------------------------------------------------------------------}
procedure TRVRTFFontTable.Put(Index: Integer; const Value: TRVRTFFontTableItem);
begin
inherited Put(Index, Value);
end;
{============================ TRVLayoutInfo ===================================}
procedure TRVLayoutInfo.LoadFromStream(Stream: TStream; IncludeSize: Boolean);
var v: Integer;
const defsize1 = sizeof(Integer)*(4+2)+sizeof(TRVBiDiMode);
begin
if IncludeSize then
Stream.ReadBuffer(v, sizeof(Integer)); // ignoring
Stream.ReadBuffer(v, sizeof(Integer));
Stream.ReadBuffer(v, sizeof(Integer));
if v<defsize1 then
raise ERichViewError.Create(errRVFDocProp);
Stream.ReadBuffer(LeftMargin, sizeof(Integer));
Stream.ReadBuffer(RightMargin, sizeof(Integer));
Stream.ReadBuffer(TopMargin, sizeof(Integer));
Stream.ReadBuffer(BottomMargin, sizeof(Integer));
Stream.ReadBuffer(MinTextWidth, sizeof(Integer));
Stream.ReadBuffer(MaxTextWidth, sizeof(Integer));
Stream.ReadBuffer(BiDiMode, sizeof(TRVBiDiMode));
dec(v, defsize1);
if v>0 then
Stream.Seek(v,soFromCurrent);
Loaded := True;
end;
{------------------------------------------------------------------------------}
procedure TRVLayoutInfo.SaveToStream(Stream: TStream; IncludeSize: Boolean);
var v: Integer;
const defsize1 = sizeof(Integer)*(4+2)+sizeof(TRVBiDiMode);
begin
if IncludeSize then begin
v := defsize1+sizeof(Integer)*2;
Stream.WriteBuffer(v, sizeof(Integer));
end;
v := 0;
Stream.WriteBuffer(v, sizeof(Integer));
v := defsize1;
Stream.WriteBuffer(v, sizeof(Integer));
Stream.WriteBuffer(LeftMargin, sizeof(Integer));
Stream.WriteBuffer(RightMargin, sizeof(Integer));
Stream.WriteBuffer(TopMargin, sizeof(Integer));
Stream.WriteBuffer(BottomMargin, sizeof(Integer));
Stream.WriteBuffer(MinTextWidth, sizeof(Integer));
Stream.WriteBuffer(MaxTextWidth, sizeof(Integer));
Stream.WriteBuffer(BiDiMode, sizeof(TRVBiDiMode));
end;
{------------------------------------------------------------------------------}
procedure TRVLayoutInfo.LoadText(const s: String);
var TmpStream: TMemoryStream;
begin
TmpStream := TMemoryStream.Create;
try
RVFTextString2Stream(s, TmpStream);
TmpStream.Position := 0;
LoadFromStream(TmpStream, False);
finally
TmpStream.Free;
end;
end;
{------------------------------------------------------------------------------}
procedure TRVLayoutInfo.LoadBinary(const s: String);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -