Revert "Grids: uses const paramterers for strings where applicable. Patch by Alexey Torgashin. Issue #39851."

This reverts commit 72344a65f7.

These changes break compatibility (change signatures of virtual
methods), potentially unsafe (these strings can be potentially changed
through user callbacks and this will lead to crashes) and provide very
little (if at all) performance improvements.

(cherry picked from commit dbfbdee461)
This commit is contained in:
Maxim Ganetsky 2023-07-08 18:35:38 +03:00
parent 6045132105
commit 53aaae9c5e
2 changed files with 26 additions and 26 deletions

View File

@ -439,9 +439,9 @@ type
procedure DoOnChangeBounds; override; procedure DoOnChangeBounds; override;
procedure DoPrepareCanvas(aCol,aRow:Integer; aState: TGridDrawState); override; procedure DoPrepareCanvas(aCol,aRow:Integer; aState: TGridDrawState); override;
procedure DoLoadColumn(sender: TCustomGrid; aColumn: TGridColumn; aColIndex: Integer; procedure DoLoadColumn(sender: TCustomGrid; aColumn: TGridColumn; aColIndex: Integer;
aCfg: TXMLConfig; aVersion: Integer; const aPath: string); override; aCfg: TXMLConfig; aVersion: Integer; aPath: string); override;
procedure DoSaveColumn(sender: TCustomGrid; aColumn: TGridColumn; aColIndex: Integer; procedure DoSaveColumn(sender: TCustomGrid; aColumn: TGridColumn; aColIndex: Integer;
aCfg: TXMLConfig; aVersion: Integer; const aPath: string); override; aCfg: TXMLConfig; aVersion: Integer; aPath: string); override;
procedure DrawAllRows; override; procedure DrawAllRows; override;
procedure DrawFocusRect(aCol,aRow:Integer; ARect:TRect); override; procedure DrawFocusRect(aCol,aRow:Integer; ARect:TRect); override;
procedure DrawRow(ARow: Integer); override; procedure DrawRow(ARow: Integer); override;
@ -552,9 +552,9 @@ type
function ExecuteAction(AAction: TBasicAction): Boolean; override; function ExecuteAction(AAction: TBasicAction): Boolean; override;
function UpdateAction(AAction: TBasicAction): Boolean; override; function UpdateAction(AAction: TBasicAction): Boolean; override;
procedure SaveToFile(const FileName: string); override; procedure SaveToFile(FileName: string); override;
procedure SaveToStream(AStream: TStream); override; procedure SaveToStream(AStream: TStream); override;
procedure LoadFromFile(const FileName: string); override; procedure LoadFromFile(FileName: string); override;
procedure LoadFromStream(AStream: TStream); override; procedure LoadFromStream(AStream: TStream); override;
property AllowOutboundEvents; property AllowOutboundEvents;
@ -2302,7 +2302,7 @@ begin
end; end;
procedure TCustomDBGrid.DoLoadColumn(sender: TCustomGrid; aColumn: TGridColumn; procedure TCustomDBGrid.DoLoadColumn(sender: TCustomGrid; aColumn: TGridColumn;
aColIndex: Integer; aCfg: TXMLConfig; aVersion: Integer; const aPath: string); aColIndex: Integer; aCfg: TXMLConfig; aVersion: Integer; aPath: string);
var var
c: TColumn; c: TColumn;
s: string; s: string;
@ -2318,7 +2318,7 @@ begin
end; end;
procedure TCustomDBGrid.DoSaveColumn(sender: TCustomGrid; aColumn: TGridColumn; procedure TCustomDBGrid.DoSaveColumn(sender: TCustomGrid; aColumn: TGridColumn;
aColIndex: Integer; aCfg: TXMLConfig; aVersion: Integer; const aPath: string); aColIndex: Integer; aCfg: TXMLConfig; aVersion: Integer; aPath: string);
var var
c: TColumn; c: TColumn;
begin begin
@ -3952,7 +3952,7 @@ begin
and DataLink.UpdateAction(AAction); and DataLink.UpdateAction(AAction);
end; end;
procedure TCustomDBGrid.SaveToFile(const FileName: string); procedure TCustomDBGrid.SaveToFile(FileName: string);
begin begin
SaveOptions:=[ soDesign ]; SaveOptions:=[ soDesign ];
inherited SaveToFile(Filename); inherited SaveToFile(Filename);
@ -3964,7 +3964,7 @@ begin
inherited SaveToStream(AStream); inherited SaveToStream(AStream);
end; end;
procedure TCustomDBGrid.LoadFromFile(const FileName: string); procedure TCustomDBGrid.LoadFromFile(FileName: string);
begin begin
SaveOptions:=[ soDesign ]; SaveOptions:=[ soDesign ];
Include(FGridStatus, gsLoadingGrid); Include(FGridStatus, gsLoadingGrid);

View File

@ -1030,9 +1030,9 @@ type
procedure DoExit; override; procedure DoExit; override;
procedure DoEnter; override; procedure DoEnter; override;
procedure DoLoadColumn(Sender: TCustomGrid; aColumn: TGridColumn; aColIndex: Integer; procedure DoLoadColumn(Sender: TCustomGrid; aColumn: TGridColumn; aColIndex: Integer;
aCfg: TXMLConfig; aVersion: Integer; const aPath: string); virtual; aCfg: TXMLConfig; aVersion: Integer; aPath: string); virtual;
procedure DoSaveColumn(Sender: TCustomGrid; aColumn: TGridColumn; aColIndex: Integer; procedure DoSaveColumn(Sender: TCustomGrid; aColumn: TGridColumn; aColIndex: Integer;
aCfg: TXMLConfig; aVersion: Integer; const aPath: string); virtual; aCfg: TXMLConfig; aVersion: Integer; aPath: string); virtual;
function DoMouseWheel(Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint): Boolean; override; function DoMouseWheel(Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint): Boolean; override;
function DoMouseWheelDown(Shift: TShiftState; MousePos: TPoint): Boolean; override; function DoMouseWheelDown(Shift: TShiftState; MousePos: TPoint): Boolean; override;
function DoMouseWheelUp(Shift: TShiftState; MousePos: TPoint): Boolean; override; function DoMouseWheelUp(Shift: TShiftState; MousePos: TPoint): Boolean; override;
@ -1057,7 +1057,7 @@ type
procedure DrawCellGrid(aCol,aRow: Integer; aRect: TRect; aState: TGridDrawState); virtual; procedure DrawCellGrid(aCol,aRow: Integer; aRect: TRect; aState: TGridDrawState); virtual;
procedure DrawTextInCell(aCol,aRow: Integer; aRect: TRect; aState: TGridDrawState); virtual; procedure DrawTextInCell(aCol,aRow: Integer; aRect: TRect; aState: TGridDrawState); virtual;
procedure DrawThemedCell(aCol,aRow: Integer; aRect: TRect; aState: TGridDrawState); procedure DrawThemedCell(aCol,aRow: Integer; aRect: TRect; aState: TGridDrawState);
procedure DrawCellText(aCol,aRow: Integer; aRect: TRect; aState: TGridDrawState; const aText: String); virtual; procedure DrawCellText(aCol,aRow: Integer; aRect: TRect; aState: TGridDrawState; aText: String); virtual;
procedure DrawGridCheckboxBitmaps(const aCol,aRow: Integer; const aRect: TRect; procedure DrawGridCheckboxBitmaps(const aCol,aRow: Integer; const aRect: TRect;
const aState: TCheckboxState); virtual; const aState: TCheckboxState); virtual;
procedure DrawButtonCell(const aCol,aRow: Integer; aRect: TRect; const aState:TGridDrawState); procedure DrawButtonCell(const aCol,aRow: Integer; aRect: TRect; const aState:TGridDrawState);
@ -1360,14 +1360,14 @@ type
procedure InvalidateRow(ARow: Integer); procedure InvalidateRow(ARow: Integer);
function IsCellVisible(aCol, aRow: Integer): Boolean; function IsCellVisible(aCol, aRow: Integer): Boolean;
function IsFixedCellVisible(aCol, aRow: Integer): boolean; function IsFixedCellVisible(aCol, aRow: Integer): boolean;
procedure LoadFromFile(const FileName: string); virtual; procedure LoadFromFile(FileName: string); virtual;
procedure LoadFromStream(AStream: TStream); virtual; procedure LoadFromStream(AStream: TStream); virtual;
function MouseCoord(X,Y: Integer): TGridCoord; function MouseCoord(X,Y: Integer): TGridCoord;
function MouseToCell(const Mouse: TPoint): TPoint; overload; function MouseToCell(const Mouse: TPoint): TPoint; overload;
procedure MouseToCell(X,Y: Integer; out ACol,ARow: Longint); overload; procedure MouseToCell(X,Y: Integer; out ACol,ARow: Longint); overload;
function MouseToLogcell(Mouse: TPoint): TPoint; function MouseToLogcell(Mouse: TPoint): TPoint;
function MouseToGridZone(X,Y: Integer): TGridZone; function MouseToGridZone(X,Y: Integer): TGridZone;
procedure SaveToFile(const FileName: string); virtual; procedure SaveToFile(FileName: string); virtual;
procedure SaveToStream(AStream: TStream); virtual; procedure SaveToStream(AStream: TStream); virtual;
procedure ScaleFontsPPI(const AToPPI: Integer; const AProportion: Double); override; procedure ScaleFontsPPI(const AToPPI: Integer; const AProportion: Double); override;
procedure SetFocus; override; procedure SetFocus; override;
@ -1787,8 +1787,8 @@ type
procedure SaveContent(cfg: TXMLConfig); override; procedure SaveContent(cfg: TXMLConfig); override;
//procedure DrawInteriorCells; override; //procedure DrawInteriorCells; override;
//procedure SelectEditor; override; //procedure SelectEditor; override;
procedure SelectionSetText(const TheText: String); procedure SelectionSetText(TheText: String);
procedure SelectionSetHTML(const TheHTML: String; TheText: String); procedure SelectionSetHTML(TheHTML, TheText: String);
procedure SetCells(ACol, ARow: Integer; const AValue: string); virtual; procedure SetCells(ACol, ARow: Integer; const AValue: string); virtual;
procedure SetCheckboxState(const aCol, aRow:Integer; const aState: TCheckboxState); override; procedure SetCheckboxState(const aCol, aRow:Integer; const aState: TCheckboxState); override;
procedure SetEditText(aCol, aRow: Longint; const aValue: string); override; procedure SetEditText(aCol, aRow: Longint; const aValue: string); override;
@ -1809,11 +1809,11 @@ type
procedure InsertRowWithValues(Index: Integer; Values: array of String); procedure InsertRowWithValues(Index: Integer; Values: array of String);
procedure LoadFromCSVStream(AStream: TStream; ADelimiter: Char=','; procedure LoadFromCSVStream(AStream: TStream; ADelimiter: Char=',';
UseTitles: boolean=true; FromLine: Integer=0; SkipEmptyLines: Boolean=true); virtual; UseTitles: boolean=true; FromLine: Integer=0; SkipEmptyLines: Boolean=true); virtual;
procedure LoadFromCSVFile(const AFilename: string; ADelimiter: Char=','; procedure LoadFromCSVFile(AFilename: string; ADelimiter: Char=',';
UseTitles: boolean=true; FromLine: Integer=0; SkipEmptyLines: Boolean=true); UseTitles: boolean=true; FromLine: Integer=0; SkipEmptyLines: Boolean=true);
procedure SaveToCSVStream(AStream: TStream; ADelimiter: Char=','; procedure SaveToCSVStream(AStream: TStream; ADelimiter: Char=',';
WriteTitles: boolean=true; VisibleColumnsOnly: boolean=false); WriteTitles: boolean=true; VisibleColumnsOnly: boolean=false);
procedure SaveToCSVFile(const AFileName: string; ADelimiter: Char=','; procedure SaveToCSVFile(AFileName: string; ADelimiter: Char=',';
WriteTitles: boolean=true; VisibleColumnsOnly: boolean=false); WriteTitles: boolean=true; VisibleColumnsOnly: boolean=false);
property Cells[ACol, ARow: Integer]: string read GetCells write SetCells; property Cells[ACol, ARow: Integer]: string read GetCells write SetCells;
@ -4738,7 +4738,7 @@ begin
end; end;
procedure TCustomGrid.DrawCellText(aCol, aRow: Integer; aRect: TRect; procedure TCustomGrid.DrawCellText(aCol, aRow: Integer; aRect: TRect;
aState: TGridDrawState; const aText: String); aState: TGridDrawState; aText: String);
var var
Rtxt, Rrot, R: TRect; Rtxt, Rrot, R: TRect;
angle: Double; angle: Double;
@ -7585,14 +7585,14 @@ begin
end; end;
procedure TCustomGrid.DoLoadColumn(Sender: TCustomGrid; aColumn: TGridColumn; procedure TCustomGrid.DoLoadColumn(Sender: TCustomGrid; aColumn: TGridColumn;
aColIndex: Integer; aCfg: TXMLConfig; aVersion: Integer; const aPath: string); aColIndex: Integer; aCfg: TXMLConfig; aVersion: Integer; aPath: string);
begin begin
if Assigned(FOnLoadColumn) then if Assigned(FOnLoadColumn) then
FOnLoadColumn(Self, aColumn, aColIndex, aCfg, aVersion, aPath); FOnLoadColumn(Self, aColumn, aColIndex, aCfg, aVersion, aPath);
end; end;
procedure TCustomGrid.DoSaveColumn(Sender: TCustomGrid; aColumn: TGridColumn; procedure TCustomGrid.DoSaveColumn(Sender: TCustomGrid; aColumn: TGridColumn;
aColIndex: Integer; aCfg: TXMLConfig; aVersion: Integer; const aPath: string); aColIndex: Integer; aCfg: TXMLConfig; aVersion: Integer; aPath: string);
begin begin
if Assigned(FOnSaveColumn) then if Assigned(FOnSaveColumn) then
FOnSaveColumn(Self, aColumn, aColIndex, aCfg, aVersion, aPath); FOnSaveColumn(Self, aColumn, aColIndex, aCfg, aVersion, aPath);
@ -10108,7 +10108,7 @@ begin
end; end;
end; end;
procedure TCustomGrid.LoadFromFile(const FileName: string); procedure TCustomGrid.LoadFromFile(FileName: string);
var var
Cfg: TXMLConfig; Cfg: TXMLConfig;
begin begin
@ -10136,7 +10136,7 @@ begin
end; end;
end; end;
procedure TCustomGrid.SaveToFile(const FileName: string); procedure TCustomGrid.SaveToFile(FileName: string);
var var
Cfg: TXMLConfig; Cfg: TXMLConfig;
begin begin
@ -11845,7 +11845,7 @@ begin
end; end;
end; end;
procedure TCustomStringGrid.SelectionSetText(const TheText: String); procedure TCustomStringGrid.SelectionSetText(TheText: String);
var var
StartCol,StartRow: Integer; StartCol,StartRow: Integer;
Stream: TStringStream; Stream: TStringStream;
@ -11885,7 +11885,7 @@ begin
end; end;
procedure TCustomStringGrid.SelectionSetHTML(const TheHTML: String; TheText: String); procedure TCustomStringGrid.SelectionSetHTML(TheHTML, TheText: String);
var var
bStartCol, bStartRow, bCol, bRow: Integer; bStartCol, bStartRow, bCol, bRow: Integer;
bCellStr: string; bCellStr: string;
@ -12263,7 +12263,7 @@ begin
end; end;
end; end;
procedure TCustomStringGrid.LoadFromCSVFile(const AFilename: string; procedure TCustomStringGrid.LoadFromCSVFile(AFilename: string;
ADelimiter: Char=','; UseTitles: boolean=true; FromLine: Integer=0; ADelimiter: Char=','; UseTitles: boolean=true; FromLine: Integer=0;
SkipEmptyLines: Boolean=true); SkipEmptyLines: Boolean=true);
var var
@ -12349,7 +12349,7 @@ begin
end; end;
end; end;
procedure TCustomStringGrid.SaveToCSVFile(const AFileName: string; ADelimiter: Char; procedure TCustomStringGrid.SaveToCSVFile(AFileName: string; ADelimiter: Char;
WriteTitles: boolean=true; VisibleColumnsOnly: boolean=false); WriteTitles: boolean=true; VisibleColumnsOnly: boolean=false);
var var
TheStream: TFileStream; TheStream: TFileStream;