fpspreadsheet: Enable/disable workbook notifications and formula recalculations in WorksheetGrid.BeginUpdate/EndUpdate. See https://forum.lazarus.freepascal.org/index.php/topic,44547.msg313254.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6825 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2019-03-05 11:32:48 +00:00
parent f79ae2fd57
commit ae6b7cc7f1

View File

@ -1499,6 +1499,8 @@ end;
procedure TsCustomWorksheetGrid.BeginUpdate;
begin
inc(FLockCount);
Workbook.DisableNotifications;
Workbook.LockFormulas;
inherited BeginUpdate;
end;
@ -3357,6 +3359,8 @@ end;
procedure TsCustomWorksheetGrid.EndUpdate(ARefresh: Boolean = true);
begin
inherited EndUpdate(false);
Workbook.UnlockFormulas;
Workbook.EnableNotifications;
dec(FLockCount);
if (FLockCount = 0) and ARefresh then
VisualChange;
@ -6627,9 +6631,13 @@ begin
Worksheet.WriteFormula(r, c, Copy(s, 2, Length(s)), true)
else
begin
cell := Worksheet.GetCell(r, c);
HTMLToRichText(Workbook, Worksheet.ReadCellFont(cell), s, plain, rtParams);
Worksheet.WriteText(cell, plain, rtParams); // This will erase a non-formatted cell if s = ''
if cell = nil then cell := Worksheet.GetCell(r, c);
if s = '' then
Worksheet.WriteBlank(cell)
else begin
HTMLToRichText(Workbook, Worksheet.ReadCellFont(cell), s, plain, rtParams);
Worksheet.WriteText(cell, plain, rtParams); // This will erase a non-formatted cell if s = ''
end;
end;
end else
if VarIsType(AValue, varDate) then