📄 acefile.pas
字号:
procedure TAceAceFile.TextRect(rect: TRect; x,y: Integer; const Text: string);
begin
WriteType(AceRT_TextRect);
WriteRect(Rect);
WriteSmallInt(x);
WriteSmallInt(y);
WriteString(Text);
end;
procedure TAceAceFile.FillRect(Rect: TRect);
begin
WriteType(AceRT_FillRect);
WriteRect(Rect);
end;
procedure TAceAceFile.Rectangle(x1,y1,x2,y2: Integer);
begin
WriteType(AceRT_Rectangle);
WriteSmallInt(x1);
WriteSmallInt(y1);
WriteSmallInt(x2);
WriteSmallInt(y2);
end;
procedure TAceAceFile.RoundRect(x1,y1,x2,y2,x3,y3: Integer);
begin
WriteType(AceRT_RoundRect);
WriteSmallInt(x1);
WriteSmallInt(y1);
WriteSmallInt(x2);
WriteSmallInt(y2);
WriteSmallInt(x3);
WriteSmallInt(y3);
end;
procedure TAceAceFile.Ellipse(x1,y1,x2,y2: Integer);
begin
WriteType(AceRT_Ellipse);
WriteSmallInt(x1);
WriteSmallInt(y1);
WriteSmallInt(x2);
WriteSmallInt(y2);
end;
procedure TAceAceFile.Draw(x,y: Integer; Graphic: TGraphic);
var
gtype: Integer;
St: TMemoryStream;
begin
if Graphic is graphics.TBitMap Then gtype := AceRT_DrawBitmap
else if Graphic is TIcon Then gtype := AceRT_DrawIcon
else if Graphic is TMetaFile Then gtype := AceRT_DrawMetaFile
else gtype := AceRT_DrawJPeg; { D3 only }
St := TMemoryStream.Create;
try
Graphic.SaveToStream(St);
if St.Size > 0 then
begin
WriteType(AceRT_Draw);
WriteSmallInt(x);
WriteSmallInt(y);
WriteType(gtype);
WriteStream(St);
end;
finally
St.Free;
end;
end;
procedure TAceAceFile.StretchDraw(Rect: TRect; Graphic: TGraphic);
var
gtype: Integer;
St: TMemoryStream;
begin
if Graphic is graphics.TBitMap Then gtype := AceRT_DrawBitmap
else if Graphic is TIcon Then gtype := AceRT_DrawIcon
else if Graphic is TMetaFile Then gtype := AceRT_DrawMetaFile
else gtype := AceRT_DrawJPeg; { D3 only }
St := TMemoryStream.Create;
try
Graphic.SaveToStream(St);
if St.Size > 0 then
begin
WriteType(AceRT_StretchDraw);
WriteRect(Rect);
WriteType(gtype);
WriteStream(St);
end;
finally
St.Free;
end;
end;
procedure TAceAceFile.DrawBitmap(X, Y: Integer; Stream: TStream);
begin
WriteType(AceRT_AceDrawBitmap);
WriteSmallInt(X);
WriteSmallInt(Y);
Stream.Position := 0;
WriteStream(Stream);
end;
procedure TAceAceFile.StretchDrawBitmap(Rect: TRect; Stream: TStream);
begin
WriteType(AceRT_AceStretchDrawBitmap);
WriteRect(Rect);
Stream.Position := 0;
WriteStream(Stream);
end;
procedure TAceAceFile.ShadeRect(Rect: TRect; Shade: TAceShadePercent);
begin
WriteType(AceRT_ShadeRect);
WriteRect(Rect);
WriteSmallInt(SmallInt(Ord(Shade)));
end;
procedure TAceAceFile.SetBkColor(bkColor: LongInt);
begin
WriteType(AceRT_SetBkColor);
WriteLongInt(bkColor);
end;
procedure TAceAceFile.TextJustify(Rect: TRect; x,y: Integer; const Text: string;
EndParagraph: Boolean; FullRect: TRect);
begin
WriteType(AceRT_TextJustify);
WriteRect(Rect);
WriteSmallInt(x);
WriteSmallInt(y);
WriteString(Text);
WriteBoolean(EndParagraph);
WriteRect(FullRect);
end;
{$ifdef WIN32}
procedure TAceAceFile.RtfDraw(Rect: TRect; Stream: TStream; StartPos,EndPos: LongInt; SetDefFont: Boolean);
begin
WriteType(AceRT_RtfDraw);
WriteLongInt(SizeOf(Rect) + Stream.Size + (SizeOf(LongInt) * 2) + SizeOf(Boolean));
WriteRect(Rect);
WriteBoolean(SetDefFont);
WriteLongInt(StartPos);
WriteLongInt(EndPos);
Stream.Position := 0;
WriteStream(Stream);
end;
{$endif}
procedure TAceAceFile.DrawCheckBox(Rect: TRect; CheckStyle: TAceCheckStyle; Color: TColor; Thickness: Integer);
begin
WriteType(AceRT_DrawCheckBox);
WriteRect(Rect);
WriteSmallInt(Ord(CheckStyle));
WriteLongInt(Ord(Color));
WriteSmallInt(Thickness);
end;
procedure TAceAceFile.DrawShapeType(dt: TAceDrawType; x1,y1,x2,y2,x3,y3,x4,y4: Integer);
begin
WriteType(AceRT_DrawShapeType);
WriteSmallInt(Ord(dt));
WriteLongInt(x1);
WriteLongInt(x2);
WriteLongInt(x3);
WriteLongInt(x4);
WriteLongInt(y1);
WriteLongInt(y2);
WriteLongInt(y3);
WriteLongInt(y4);
end;
procedure TAceAceFile.PolyDrawType(pt: TAcePolyType; const Points: array of TPoint);
var
Spot: Integer;
begin
WriteType(AceRT_PolyDrawType);
WriteSmallInt(Ord(pt));
WriteSmallInt(High(Points) + 1);
for Spot := 0 to High(Points) do
begin
WriteLongInt(Points[Spot].x);
WriteLongInt(Points[Spot].y);
end;
end;
procedure TAceAceFile.Print3of9Barcode(Left, Top, Width, Height, NarrowWidth, WideWidth: Integer;
Inches, Vertical: Boolean; BarData: String);
begin
WriteType(AceRT_3of9BarCode);
WriteSmallInt(Left);
WriteSmallInt(Top);
WriteSmallInt(Width);
WriteSmallInt(Height);
WriteSmallInt(NarrowWidth);
WriteSmallInt(WideWidth);
WriteBoolean(Inches);
WriteBoolean(Vertical);
WriteString(BarData);
end;
procedure TAceAceFile.Print2of5Barcode(Left, Top, Width, Height, NarrowWidth, WideWidth: Integer;
Inches, Vertical: Boolean; BarData: String);
begin
WriteType(AceRT_2of5BarCode);
WriteSmallInt(Left);
WriteSmallInt(Top);
WriteSmallInt(Width);
WriteSmallInt(Height);
WriteSmallInt(NarrowWidth);
WriteSmallInt(WideWidth);
WriteBoolean(Inches);
WriteBoolean(Vertical);
WriteString(BarData);
end;
procedure TAceAceFile.WritePrinterInfo(pi: TAceFilePrinterInfo);
begin
WriteType(AceRT_PrinterInfo);
Stream.Write(pi, SizeOf(pi));
end;
procedure TAceAceFile.WriteType(RecType: Word);
begin
Stream.Write(RecType, Sizeof(RecType));
end;
procedure TAceAceFile.WriteRect(Rect: TRect);
begin
WriteSmallInt(Rect.left);
WriteSmallInt(Rect.top);
WriteSmallInt(Rect.right);
WriteSmallInt(Rect.bottom);
end;
procedure TAceAceFile.WriteWord(W: Word);
begin
Stream.Write(W, SizeOf(W));
end;
procedure TAceAceFile.WriteSmallInt(I: SmallInt);
begin
Stream.Write(I, Sizeof(I));
end;
procedure TAceAceFile.WriteLongInt(LI: LongInt);
begin
Stream.Write(LI, Sizeof(LI));
end;
procedure TAceAceFile.WriteString(S: String);
var
Len: LongInt;
begin
Len := Length(S);
Stream.Write( Len, SizeOf(Len));
if Len > 0 then
begin
{$ifdef WIN32}
Stream.WriteBuffer(Pointer(S)^, Len);
{$else}
Stream.WriteBuffer(S[1], Len);
{$endif}
end;
end;
procedure TAceAceFile.WritePChar(S: PChar; Len: LongInt);
begin
Stream.Write( Len, SizeOf(Len));
Stream.Write( S^, Len);
end;
procedure TAceAceFile.WriteStream(S: TStream);
var
Len: LongInt;
begin
Len := S.Size;
Stream.Write(Len, SizeOf(Len));
S.Position := 0;
Stream.CopyFrom(S, S.Size);
end;
procedure TAceAceFile.WriteBoolean(Value: Boolean);
begin
Stream.Write(Value, SizeOf(Value));
end;
procedure TAceAceFile.ReadPrinterInfo(var pi: TAceFilePrinterInfo);
begin
Stream.Read(pi, SizeOf(pi));
end;
procedure TAceAceFile.ReadType(var RecType: Word);
begin
Stream.Read(RecType, SizeOf(RecType));
end;
procedure TAceAceFile.ReadRect(var Rect: TRect);
var
value: SmallInt;
begin
ReadSmallInt(value);
Rect.left := value;
ReadSmallInt(value);
Rect.top := value;
ReadSmallInt(value);
Rect.right := value;
ReadSmallInt(value);
Rect.bottom := value;
end;
procedure TAceAceFile.ReadWord(var W: Word);
begin
Stream.Read(W, SizeOf(W));
end;
procedure TAceAceFile.ReadSmallInt(var I: SmallInt);
begin
Stream.Read(I, SizeOf(I));
end;
procedure TAceAceFile.ReadLongInt(var LI: LongInt);
begin
Stream.Read(LI, SizeOf(LI));
end;
procedure TAceAceFile.ReadString(var S: String);
var
Len: SmallInt;
LongLen: LongInt;
{$ifndef WIN32}
MStream: TMemoryStream;
BLen: Byte;
{$endif}
begin
S := '';
if AceFileHeader.Version < 4.0 then
begin
Stream.Read(Len, SizeOf(Len));
LongLen := Len;
end else
begin
Stream.Read(LongLen, SizeOf(LongLen));
end;
if LongLen > 0 then
begin
{$ifdef WIN32}
SetString(S, PChar(nil), LongLen);
Stream.Read(Pointer(S)^, LongLen);
{$else}
MStream := TMemoryStream.Create;
MStream.CopyFrom(Stream, LongLen);
if LongLen > 255 then BLen := 255
else BLen := LongLen;
MStream.Position := 0;
S[0] := Char(BLen);
MStream.Read(S[1], BLen);
MStream.Free;
{$endif}
end;
end;
procedure TAceAceFile.ReadPChar(var S: PChar; Len: LongInt);
begin
Stream.Read(S^, Len);
end;
procedure TAceAceFile.ReadStream(S: TStream);
var
len: LongInt;
begin
Stream.Read(Len, SizeOf(Len));
S.CopyFrom(Stream, Len);
end;
procedure TAceAceFile.ReadBoolean(var Value: Boolean);
begin
Stream.Read(Value, SizeOf(Value));
end;
procedure TAceAceFile.Send(AceFile: TAceFile);
begin
AceFile.LoadAceFile(Self)
end;
procedure TAceAceFile.SendPage(AceFile: TAceFile; page: LongInt);
begin
AceFile.LoadPage(Self, page)
end;
procedure TAceAceFile.SendPages(AceFile: TAceFile; StartPage, EndPage: LongInt);
begin
AceFile.LoadPages(Self, StartPage, EndPage);
end;
procedure TAceAceFile.SaveToFile(FileName: String);
var
fs: TFileStream;
begin
if Not Running then
begin
fs := TFileStream.Create(FileName, fmCreate);
try
SaveToStream(fs);
finally
fs.free;
end;
end;
end;
procedure TAceAceFile.SaveToStream(SaveStream: TStream);
var
SavePos: LongInt;
pos: Integer;
Spot: LongInt;
Len: LongInt;
begin
if Not Running then
begin
for pos := 0 to SizeOf(AceFileHeader.Description) -1 do
AceFileHeader.Description[pos] := #0;
StrPLCopy(AceFileHeader.Description, Description,SizeOf(AceFileHeader.Description)-1);
SaveStream.Write(AceFileHeader, SizeOf(AceFileHeader));
SaveStream.Write(AceFileInfo, SizeOf(AceFileInfo));
AcePrinterSetup.WriteToStream(SaveStream);
Len := FUserStream.Size;;
SaveStream.Write(Len, SizeOf(Len));
FUserStream.Position := 0;
SaveStream.CopyFrom(FUserStream, FUserStream.Size);
for pos := 0 to pages.count - 1 do
begin
Spot := TAcePagePosition(pages.items(pos)).Pos;
SaveStream.Write(Spot, SizeOf(Spot));
end;
for pos := 0 to objects.count - 1 do TAceAceFileObject(objects.items[pos]).Write(SaveStream);
AceFileHeader.HeaderLen := SaveStream.Size;
SaveStream.Position := 0;
SaveStream.Write(AceFileHeader, SizeOf(AceFileHeader));
SaveStream.Position := SaveStream.Size;
SavePos := Stream.Position;
Stream.Position := 0;
SaveStream.CopyFrom(Stream, Stream.Size);
Stream.Position := SavePos;
end;
end;
procedure TAceAceFile.LoadFromFile(FileName: String);
var
str: TFileStream;
begin
str := TFileStream.Create(FileName, fmOpenRead);
try
LoadFromStream(str);
finally
str.free;
end;
end;
procedure TAceAceFile.LoadFromStream(LoadStream: TStream);
var
Spot, Pos: LongInt;
pp: TAcePagePosition;
rc: Word;
obj: TAceAceFileObject;
Len: LongInt;
begin
if Stream <> nil then Clear;
if FObjects <> nil then Clear;
FStream := TAceStream.Create;
FObjects := TList.Create;
LoadStream.Read(AceFileHeader, SizeOf(AceFileHeader));
if AceFileHeader.Key = 101071 then
begin
Description := StrPas(AceFileHeader.Description);
LoadStream.Read(AceFileInfo, SizeOf(AceFileInfo));
if AceFileHeader.Version < 3.0 then
begin
LoadStream.Read(AceFilePrinterInfo,
SizeOf(AceFilePrinterInfo)- SizeOf(AceFilePrinterInfo.CollatedCopies) );
AceFilePrinterInfo.CollatedCopies := True;
AcePrinterSetup.SetPrintInfo( AceFilePrinterInfo );
end else if AceFileHeader.Version < 4.0 then
begin
LoadStream.Read(AceFilePrinterInfo, SizeOf(AceFilePrinterInfo));
AcePrinterSetup.SetPrintInfo( AceFilePrinterInfo );
end else
begin
LoadStream.Read(rc, SizeOf(rc));
AcePrinterSetup.ReadFromStream(LoadStream);
end;
TMemoryStream(FUserStream).Clear;
LoadStream.Read(Len, SizeOf(Len));
if Len > 0 then FUserStream.CopyFrom(LoadStream, Len);
for spot := 0 to AceFileInfo.pages - 1 do
begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -