fpspreadsheet: Fix ods reader crashing when the file contains an embedded chart.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8066 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2021-08-08 15:24:43 +00:00
parent 6a58c84249
commit e9fc0f2a36

View File

@ -4731,24 +4731,25 @@ procedure TsSpreadOpenDocReader.ReadShape(ANode: TDOMNode;
if href <> '' then if href <> '' then
begin begin
idx := TsWorkbook(FWorkbook).FindEmbeddedObj(ExtractFileName(href)); idx := TsWorkbook(FWorkbook).FindEmbeddedObj(ExtractFileName(href));
with FWorksheet as TsWorksheet do begin if idx > -1 then
// When called from a cell node, x and y are relative to the cell. with FWorksheet as TsWorksheet do begin
// When called from the Shapes node, x and y refer to the worksheet. // When called from a cell node, x and y are relative to the cell.
CalcImageCell(idx, x, y, w, h, r, c, dy, dx, sx, sy); // order of dx and dy is correct! // When called from the Shapes node, x and y refer to the worksheet.
if ARow <> UNASSIGNED_ROW_COL_INDEX then begin CalcImageCell(idx, x, y, w, h, r, c, dy, dx, sx, sy); // order of dx and dy is correct!
r := ARow; if ARow <> UNASSIGNED_ROW_COL_INDEX then begin
dy := y; r := ARow;
dy := y;
end;
if ACol <> UNASSIGNED_ROW_COL_INDEX then begin
c := ACol;
dx := x;
end;
idx := WriteImage(r, c, idx, dx, dy, sx, sy);
if AHLink <> '' then begin
img := GetPointerToImage(idx);
img^.HyperlinkTarget := AHLink;
end;
end; end;
if ACol <> UNASSIGNED_ROW_COL_INDEX then begin
c := ACol;
dx := x;
end;
idx := WriteImage(r, c, idx, dx, dy, sx, sy);
if AHLink <> '' then begin
img := GetPointerToImage(idx);
img^.HyperlinkTarget := AHLink;
end;
end;
end; end;
childNode := childnode.NextSibling; childNode := childnode.NextSibling;
end; end;