You've already forked lazarus-ccr
fpspreadsheet: Introduce read/write flag to indicate that workbook is currently being read or written. Avoid calculation of formulas during reading (--> signficant speed-up of reading of large files)
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4030 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -545,7 +545,7 @@ type
|
|||||||
FPalette: array of TsColorValue;
|
FPalette: array of TsColorValue;
|
||||||
FVirtualColCount: Cardinal;
|
FVirtualColCount: Cardinal;
|
||||||
FVirtualRowCount: Cardinal;
|
FVirtualRowCount: Cardinal;
|
||||||
FWriting: Boolean;
|
FReadWriteFlag: TsReadWriteFlag;
|
||||||
FCalculationLock: Integer;
|
FCalculationLock: Integer;
|
||||||
FOptions: TsWorkbookOptions;
|
FOptions: TsWorkbookOptions;
|
||||||
FActiveWorksheet: TsWorksheet;
|
FActiveWorksheet: TsWorksheet;
|
||||||
@ -1607,6 +1607,9 @@ end;
|
|||||||
-------------------------------------------------------------------------------}
|
-------------------------------------------------------------------------------}
|
||||||
procedure TsWorksheet.ChangedCell(ARow, ACol: Cardinal);
|
procedure TsWorksheet.ChangedCell(ARow, ACol: Cardinal);
|
||||||
begin
|
begin
|
||||||
|
if FWorkbook.FReadWriteFlag = rwfRead then
|
||||||
|
exit;
|
||||||
|
|
||||||
if (FWorkbook.FCalculationLock = 0) and (boAutoCalc in FWorkbook.Options) then
|
if (FWorkbook.FCalculationLock = 0) and (boAutoCalc in FWorkbook.Options) then
|
||||||
begin
|
begin
|
||||||
if CellUsedInFormula(ARow, ACol) then
|
if CellUsedInFormula(ARow, ACol) then
|
||||||
@ -1625,7 +1628,10 @@ end;
|
|||||||
-------------------------------------------------------------------------------}
|
-------------------------------------------------------------------------------}
|
||||||
procedure TsWorksheet.ChangedFont(ARow, ACol: Cardinal);
|
procedure TsWorksheet.ChangedFont(ARow, ACol: Cardinal);
|
||||||
begin
|
begin
|
||||||
if Assigned(FOnChangeFont) then FOnChangeFont(Self, ARow, ACol);
|
if FWorkbook.FReadWriteFlag = rwfRead then
|
||||||
|
exit;
|
||||||
|
if Assigned(FOnChangeFont) then
|
||||||
|
FOnChangeFont(Self, ARow, ACol);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{@@ ----------------------------------------------------------------------------
|
{@@ ----------------------------------------------------------------------------
|
||||||
@ -6379,6 +6385,7 @@ begin
|
|||||||
FFileName := AFileName;
|
FFileName := AFileName;
|
||||||
PrepareBeforeReading;
|
PrepareBeforeReading;
|
||||||
ok := false;
|
ok := false;
|
||||||
|
FReadWriteFlag := rwfRead;
|
||||||
inc(FLockCount); // This locks various notifications from being sent
|
inc(FLockCount); // This locks various notifications from being sent
|
||||||
try
|
try
|
||||||
AReader.ReadFromFile(AFileName);
|
AReader.ReadFromFile(AFileName);
|
||||||
@ -6388,6 +6395,7 @@ begin
|
|||||||
Recalc;
|
Recalc;
|
||||||
FFormat := AFormat;
|
FFormat := AFormat;
|
||||||
finally
|
finally
|
||||||
|
FReadWriteFlag := rwfNormal;
|
||||||
dec(FLockCount);
|
dec(FLockCount);
|
||||||
if ok and Assigned(FOnOpenWorkbook) then // ok is true if file has been read successfully
|
if ok and Assigned(FOnOpenWorkbook) then // ok is true if file has been read successfully
|
||||||
FOnOpenWorkbook(self); // send common notification
|
FOnOpenWorkbook(self); // send common notification
|
||||||
@ -6513,13 +6521,13 @@ end;
|
|||||||
|
|
||||||
procedure TsWorkbook.SetVirtualColCount(AValue: Cardinal);
|
procedure TsWorkbook.SetVirtualColCount(AValue: Cardinal);
|
||||||
begin
|
begin
|
||||||
if FWriting then exit;
|
if FReadWriteFlag = rwfWrite then exit;
|
||||||
FVirtualColCount := AValue;
|
FVirtualColCount := AValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TsWorkbook.SetVirtualRowCount(AValue: Cardinal);
|
procedure TsWorkbook.SetVirtualRowCount(AValue: Cardinal);
|
||||||
begin
|
begin
|
||||||
if FWriting then exit;
|
if FReadWriteFlag = rwfWrite then exit;
|
||||||
FVirtualRowCount := AValue;
|
FVirtualRowCount := AValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -6542,10 +6550,10 @@ begin
|
|||||||
FFileName := AFileName;
|
FFileName := AFileName;
|
||||||
PrepareBeforeSaving;
|
PrepareBeforeSaving;
|
||||||
AWriter.CheckLimitations;
|
AWriter.CheckLimitations;
|
||||||
FWriting := true;
|
FReadWriteFlag := rwfWrite;
|
||||||
AWriter.WriteToFile(AFileName, AOverwriteExisting);
|
AWriter.WriteToFile(AFileName, AOverwriteExisting);
|
||||||
finally
|
finally
|
||||||
FWriting := false;
|
FReadWriteFlag := rwfNormal;
|
||||||
AWriter.Free;
|
AWriter.Free;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -6588,10 +6596,10 @@ begin
|
|||||||
try
|
try
|
||||||
PrepareBeforeSaving;
|
PrepareBeforeSaving;
|
||||||
AWriter.CheckLimitations;
|
AWriter.CheckLimitations;
|
||||||
FWriting := true;
|
FReadWriteFlag := rwfWrite;
|
||||||
AWriter.WriteToStream(AStream);
|
AWriter.WriteToStream(AStream);
|
||||||
finally
|
finally
|
||||||
FWriting := false;
|
FReadWriteFlag := rwfNormal;
|
||||||
AWriter.Free;
|
AWriter.Free;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -12,6 +12,9 @@ type
|
|||||||
TsSpreadsheetFormat = (sfExcel2, sfExcel5, sfExcel8,
|
TsSpreadsheetFormat = (sfExcel2, sfExcel5, sfExcel8,
|
||||||
sfOOXML, sfOpenDocument, sfCSV, sfWikiTable_Pipes, sfWikiTable_WikiMedia);
|
sfOOXML, sfOpenDocument, sfCSV, sfWikiTable_Pipes, sfWikiTable_WikiMedia);
|
||||||
|
|
||||||
|
{@@ Flag set during reading or writing of a workbook }
|
||||||
|
TsReadWriteFlag = (rwfNormal, rwfRead, rwfWrite);
|
||||||
|
|
||||||
{@@ Record collection limitations of a particular file format }
|
{@@ Record collection limitations of a particular file format }
|
||||||
TsSpreadsheetFormatLimitations = record
|
TsSpreadsheetFormatLimitations = record
|
||||||
MaxRowCount: Cardinal;
|
MaxRowCount: Cardinal;
|
||||||
|
Reference in New Issue
Block a user