fpspreadsheet: Size property cannot be changed (public in ancestor). Raise an exception now if new size is <> 0.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8931 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2023-10-03 20:40:56 +00:00
parent 186e9b86a3
commit 31205a2ddc

View File

@ -30,6 +30,7 @@ type
function GetPosition: Int64; override; function GetPosition: Int64; override;
function GetSize: Int64; override; function GetSize: Int64; override;
class function IsWritingMode(AMode: Word): Boolean; class function IsWritingMode(AMode: Word): Boolean;
procedure SetSize64(const NewValue: Int64); override;
public public
constructor Create(AFileName: String; AMode: Word; constructor Create(AFileName: String; AMode: Word;
ABufSize: Cardinal = Cardinal(-1)); overload; ABufSize: Cardinal = Cardinal(-1)); overload;
@ -43,7 +44,6 @@ type
function Read(var Buffer; Count: Longint): Longint; override; function Read(var Buffer; Count: Longint): Longint; override;
function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override; function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override;
function Write(const ABuffer; ACount: Longint): Longint; override; function Write(const ABuffer; ACount: Longint): Longint; override;
property Size64: Int64 read GetSize;
end; end;
procedure ResetStream(var AStream: TStream); procedure ResetStream(var AStream: TStream);
@ -327,6 +327,14 @@ begin
FillBuffer; FillBuffer;
end; end;
procedure TBufStream.SetSize64(const NewValue: Int64);
begin
if NewValue = 0 then
Clear
else
raise Exception.Create('Setting the TBufStream.Size is not allowed.');
end;
procedure TBufStream.Clear; procedure TBufStream.Clear;
begin begin
FMemoryStream.Clear; FMemoryStream.Clear;