fpspreadsheet: Handle nil values when copy backgrounds and borders in the spreadsheet chart.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9082 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2023-12-13 23:04:51 +00:00
parent 51a5d7bf97
commit a8350fad5a

View File

@ -135,9 +135,9 @@ type
TsChartFill = class TsChartFill = class
Style: TsChartFillStyle; Style: TsChartFillStyle;
Color: TsColor; Color: TsColor;
Gradient: Integer; Gradient: Integer; // Index into chart's Gradients list
Hatch: Integer; Hatch: Integer; // Index into chart's Hatches list
Image: Integer; Image: Integer; // Index into chart's Images list
Transparency: Double; // 0.0 ... 1.0 Transparency: Double; // 0.0 ... 1.0
procedure CopyFrom(AFill: TsChartFill); procedure CopyFrom(AFill: TsChartFill);
end; end;
@ -1197,6 +1197,7 @@ end;
procedure TsChartElement.CopyFrom(ASource: TsChartElement); procedure TsChartElement.CopyFrom(ASource: TsChartElement);
begin begin
if ASource <> nil then
Visible := ASource.Visible; Visible := ASource.Visible;
end; end;
@ -1225,12 +1226,30 @@ begin
end; end;
procedure TsChartFillElement.CopyFrom(ASource: TsChartElement); procedure TsChartFillElement.CopyFrom(ASource: TsChartElement);
var
srcElement: TsChartFillElement;
begin begin
inherited CopyFrom(ASource); inherited CopyFrom(ASource);
if ASource is TsChartFillElement then if ASource is TsChartFillElement then
begin begin
FBackground.CopyFrom(TsChartFillElement(ASource).Background); srcElement := TsChartFillElement(ASource);
FBorder.CopyFrom(TsChartFillElement(ASource).Border);
if srcElement.Background <> nil then
begin
if FBackground = nil then
FBackground := TsChartFill.Create;
FBackground.CopyFrom(srcElement.Background);
end else
FreeAndNil(FBackground);
if srcElement.Border <> nil then
begin
if FBorder = nil then
FBorder := TsChartLine.Create;
FBorder.CopyFrom(srcElement.Border);
end else
FreeAndNil(FBorder);
end; end;
end; end;
@ -1434,6 +1453,8 @@ begin
FChart := AChart; FChart := AChart;
end; end;
{ Note: You have the responsibility to destroy the AFill and ALine instances
after calling AddFillAndLine ! }
function TsChartDataPointStyleList.AddFillAndLine(AFill: TsChartFill; ALine: TsChartLine; function TsChartDataPointStyleList.AddFillAndLine(AFill: TsChartFill; ALine: TsChartLine;
ACount: Integer = 1): Integer; ACount: Integer = 1): Integer;
var var