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;
|
||||
row1, col1, row2, col2: Cardinal;
|
||||
hyperlink: PsHyperlink;
|
||||
fnt: TsFont;
|
||||
fntIndex: Integer;
|
||||
srcSheet: TsWorksheet;
|
||||
i: Integer;
|
||||
begin
|
||||
if (AFromCell = nil) or (AToCell = nil) then
|
||||
exit;
|
||||
|
||||
// Short-cut for source worksheet
|
||||
srcSheet := TsWorksheet(AFromcell^.Worksheet);
|
||||
|
||||
// Remember the row and column indexes of the destination cell.
|
||||
toRow := AToCell^.Row;
|
||||
toCol := AToCell^.Col;
|
||||
@ -1604,6 +1611,22 @@ begin
|
||||
if hyperlink <> nil then
|
||||
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.
|
||||
ChangedFont(AToCell^.Row, AToCell^.Col);
|
||||
end;
|
||||
@ -3810,6 +3833,7 @@ var
|
||||
r, c: Cardinal;
|
||||
i: Integer;
|
||||
hyperlink: TsHyperlink;
|
||||
fmt: TsCellFormat;
|
||||
begin
|
||||
if ACell = nil then
|
||||
exit;
|
||||
@ -3826,9 +3850,11 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
fmt := Workbook.GetCellFormat(ACell^.FormatIndex);
|
||||
|
||||
if (AText = '') then
|
||||
begin
|
||||
if (Workbook.GetCellFormat(ACell^.FormatIndex).UsedFormattingFields = []) and
|
||||
if (fmt.UsedFormattingFields = []) and
|
||||
(ACell^.Flags * [cfHyperlink, cfHasComment, cfMerged] = []) and
|
||||
(ACell^.FormulaValue = '')
|
||||
then
|
||||
|
Reference in New Issue
Block a user