From d25efe02f0eb78c42b2a6c6e33ccccfc7be19585 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Sat, 23 Apr 2016 13:01:15 +0000 Subject: [PATCH] fpspreadsheet: Avoid destruction of cell in TsWorksheet.WriteText if text is empty (issue #0030049). git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4627 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/fpspreadsheet/fpspreadsheet.pas | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/components/fpspreadsheet/fpspreadsheet.pas b/components/fpspreadsheet/fpspreadsheet.pas index 1cc64e59f..39c657275 100755 --- a/components/fpspreadsheet/fpspreadsheet.pas +++ b/components/fpspreadsheet/fpspreadsheet.pas @@ -4098,6 +4098,8 @@ end; @param ARichTextParams Array of formatting instructions for characters or groups of characters (see TsRichTextParam). + @note The cell content will be set to cctEmpty if the string is empty. + @see TsRichTextParams @see TsRichTextParam -------------------------------------------------------------------------------} @@ -4119,7 +4121,6 @@ begin if pos('file:', hyperlink.Target)=1 then begin URIToFileName(AText, AText); -// Delete(AText, 1, Length('file:///')); ForcePathDelims(AText); end; end; @@ -4128,17 +4129,12 @@ begin if (AText = '') then begin - if (fmt.UsedFormattingFields = []) and - (ACell^.Flags * [cfHyperlink, cfHasComment, cfMerged] = []) and - (ACell^.FormulaValue = '') - then - begin - r := ACell^.Row; - c := ACell^.Col; - RemoveAndFreeCell(r, c); - ChangedCell(r, c); - end else - WriteBlank(ACell); + { Initially, the cell was destroyed here if AText = '' and the cell is not + formatted, has no comment, no hyperlink, no formula, and is not merged. + This is not good... The calling procedure cannot be notified that + ACell is destroyed here. + See issue #0030049 } + WriteBlank(ACell); exit; end;