fpspreadsheet: Fix application of cell format to a cell range by TsNumberFormatAction.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7064 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2019-07-20 21:33:59 +00:00
parent 42926f53d3
commit de42ac0072

View File

@ -273,6 +273,7 @@ type
private private
FNumberFormat: TsNumberFormat; FNumberFormat: TsNumberFormat;
FNumberFormatStr: string; FNumberFormatStr: string;
FCustomNumberFormatStr: String;
FOnGetNumFormatStr: TsNumFormatStrEvent; FOnGetNumFormatStr: TsNumFormatStrEvent;
procedure SetNumberFormat(AValue: TsNumberFormat); procedure SetNumberFormat(AValue: TsNumberFormat);
procedure SetNumberFormatStr(AValue: String); procedure SetNumberFormatStr(AValue: String);
@ -282,6 +283,7 @@ type
procedure UpdateCaptionAndHint; procedure UpdateCaptionAndHint;
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
procedure ExecuteTarget(Target: TObject); override;
published published
property NumberFormat: TsNumberFormat property NumberFormat: TsNumberFormat
read FNumberFormat write SetNumberFormat default nfGeneral; read FNumberFormat write SetNumberFormat default nfGeneral;
@ -1221,7 +1223,7 @@ begin
Caption := rsNumberFormatCaption_General; Caption := rsNumberFormatCaption_General;
Hint := rsNumberFormatHint_General; Hint := rsNumberFormatHint_General;
GroupIndex := 1411141258; // Date/time when this code was written GroupIndex := 1411141258; // Date/time when this code was written
AutoCheck := true; //AutoCheck := true;
end; end;
procedure TsNumberFormatAction.ApplyFormatToCell(ACell: PCell); procedure TsNumberFormatAction.ApplyFormatToCell(ACell: PCell);
@ -1231,16 +1233,11 @@ var
begin begin
if Checked then if Checked then
begin begin
if (FNumberFormat = nfCustom) and Assigned(FOnGetNumFormatStr) then nf := FNumberFormat;
begin if FNumberFormat = nfCustom then
Worksheet.ReadNumFormat(ACell, nf, nfstr); nfstr := FCustomNumberFormatStr
FOnGetNumFormatStr(self, Workbook, nfstr); else
nf := nfCustom;
end else
begin
nf := FNumberFormat;
nfstr := FNumberFormatStr; nfstr := FNumberFormatStr;
end;
end else end else
begin begin
nf := nfGeneral; nf := nfGeneral;
@ -1252,6 +1249,23 @@ begin
Worksheet.WriteNumberFormat(ACell, nf, nfstr); Worksheet.WriteNumberFormat(ACell, nf, nfstr);
end; end;
procedure TsNumberFormatAction.ExecuteTarget(Target: TObject);
var
nf: TsNumberFormat;
nfstr: String;
begin
if (FNumberFormat = nfCustom) and Assigned(FOnGetNumFormatStr) then
begin
Worksheet.ReadNumFormat(ActiveCell, nf, nfstr);
FOnGetNumFormatStr(self, Workbook, nfstr);
FCustomNumberFormatStr := nfstr;
Checked := true;
end else
Checked := not Checked;
inherited;
end;
procedure TsNumberFormatAction.ExtractFromCell(ACell: PCell); procedure TsNumberFormatAction.ExtractFromCell(ACell: PCell);
var var
nf: TsNumberFormat; nf: TsNumberFormat;