diff --git a/components/fpspreadsheet/fpspreadsheet.pas b/components/fpspreadsheet/fpspreadsheet.pas index 268511917..c71f73604 100755 --- a/components/fpspreadsheet/fpspreadsheet.pas +++ b/components/fpspreadsheet/fpspreadsheet.pas @@ -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