You've already forked lazarus-ccr
fpspreadsheet: Fix CopyCell to make sure that fonts used in RichTextParams exist for destination cell.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4308 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -1565,10 +1565,17 @@ var
|
|||||||
toRow, toCol: LongInt;
|
toRow, toCol: LongInt;
|
||||||
row1, col1, row2, col2: Cardinal;
|
row1, col1, row2, col2: Cardinal;
|
||||||
hyperlink: PsHyperlink;
|
hyperlink: PsHyperlink;
|
||||||
|
fnt: TsFont;
|
||||||
|
fntIndex: Integer;
|
||||||
|
srcSheet: TsWorksheet;
|
||||||
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
if (AFromCell = nil) or (AToCell = nil) then
|
if (AFromCell = nil) or (AToCell = nil) then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
|
// Short-cut for source worksheet
|
||||||
|
srcSheet := TsWorksheet(AFromcell^.Worksheet);
|
||||||
|
|
||||||
// Remember the row and column indexes of the destination cell.
|
// Remember the row and column indexes of the destination cell.
|
||||||
toRow := AToCell^.Row;
|
toRow := AToCell^.Row;
|
||||||
toCol := AToCell^.Col;
|
toCol := AToCell^.Col;
|
||||||
@ -1604,6 +1611,22 @@ begin
|
|||||||
if hyperlink <> nil then
|
if hyperlink <> nil then
|
||||||
WriteHyperlink(AToCell, hyperlink^.Target, hyperlink^.Tooltip);
|
WriteHyperlink(AToCell, hyperlink^.Target, hyperlink^.Tooltip);
|
||||||
|
|
||||||
|
// Copy rich text parameters
|
||||||
|
if (AFromCell^.ContentType = cctUTF8String) and (Length(AFromCell^.RichTextParams) > 0) then
|
||||||
|
begin
|
||||||
|
SetLength(AToCell^.RichTextParams, Length(AFromCell^.RichTextParams));
|
||||||
|
// Make sure that fonts exist at destination
|
||||||
|
for i := 0 to High(AFromCell^.RichTextParams) do
|
||||||
|
begin
|
||||||
|
AToCell^.RichTextParams[i] := AFromCell^.RichTextParams[i];
|
||||||
|
fnt := srcSheet.Workbook.GetFont(AFromCell^.RichTextParams[i].FontIndex);
|
||||||
|
fntIndex := Workbook.FindFont(fnt.FontName, fnt.Size, fnt.Style, fnt.Color, fnt.Position);
|
||||||
|
if fntIndex = -1 then
|
||||||
|
fntIndex := Workbook.AddFont(fnt.FontName, fnt.Size, fnt.Style, fnt.Color, fnt.Position);
|
||||||
|
AToCell^.RichTextParams[i].FontIndex := fntIndex;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
// Notify visual controls of possibly changed row heights.
|
// Notify visual controls of possibly changed row heights.
|
||||||
ChangedFont(AToCell^.Row, AToCell^.Col);
|
ChangedFont(AToCell^.Row, AToCell^.Col);
|
||||||
end;
|
end;
|
||||||
@ -3810,6 +3833,7 @@ var
|
|||||||
r, c: Cardinal;
|
r, c: Cardinal;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
hyperlink: TsHyperlink;
|
hyperlink: TsHyperlink;
|
||||||
|
fmt: TsCellFormat;
|
||||||
begin
|
begin
|
||||||
if ACell = nil then
|
if ACell = nil then
|
||||||
exit;
|
exit;
|
||||||
@ -3826,9 +3850,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
fmt := Workbook.GetCellFormat(ACell^.FormatIndex);
|
||||||
|
|
||||||
if (AText = '') then
|
if (AText = '') then
|
||||||
begin
|
begin
|
||||||
if (Workbook.GetCellFormat(ACell^.FormatIndex).UsedFormattingFields = []) and
|
if (fmt.UsedFormattingFields = []) and
|
||||||
(ACell^.Flags * [cfHyperlink, cfHasComment, cfMerged] = []) and
|
(ACell^.Flags * [cfHyperlink, cfHasComment, cfMerged] = []) and
|
||||||
(ACell^.FormulaValue = '')
|
(ACell^.FormulaValue = '')
|
||||||
then
|
then
|
||||||
|
Reference in New Issue
Block a user