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