fpspreadsheet: Introduce a TBufStream.Clear method and make the Size property read-only to avoid issues when setting Size to arbitrary values.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8930 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2023-10-03 20:33:22 +00:00
parent 477a3290f0
commit 186e9b86a3

View File

@@ -30,7 +30,6 @@ type
function GetPosition: Int64; override;
function GetSize: Int64; override;
class function IsWritingMode(AMode: Word): Boolean;
procedure SetSize64(const NewSize: Int64); override;
public
constructor Create(AFileName: String; AMode: Word;
ABufSize: Cardinal = Cardinal(-1)); overload;
@@ -38,11 +37,13 @@ type
ABufSize: Cardinal = Cardinal(-1)); overload;
constructor Create(ABufSize: Cardinal = Cardinal(-1)); overload;
destructor Destroy; override;
procedure Clear;
procedure FillBuffer;
procedure FlushBuffer;
function Read(var Buffer; Count: Longint): Longint; override;
function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override;
function Write(const ABuffer; ACount: Longint): Longint; override;
property Size64: Int64 read GetSize;
end;
procedure ResetStream(var AStream: TStream);
@@ -326,9 +327,7 @@ begin
FillBuffer;
end;
procedure TBufStream.SetSize64(const NewSize: Int64);
begin
if NewSize = 0 then
procedure TBufStream.Clear;
begin
FMemoryStream.Clear;
if not Assigned(FFileStream) then
@@ -337,8 +336,6 @@ begin
FFileStream.Position := 0;
FFileStreamPos := 0;
end;
inherited;
end;
function TBufStream.Write(const ABuffer; ACount: LongInt): LongInt;
var