You've already forked lazarus-ccr
fpspreadsheet: Fix speed loss introduced by merging of cells (-> speed-up of some unit tests)
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3600 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -2941,8 +2941,8 @@ var
|
|||||||
r,c, r1,c1, r2,c2: Cardinal;
|
r,c, r1,c1, r2,c2: Cardinal;
|
||||||
cell: PCell;
|
cell: PCell;
|
||||||
begin
|
begin
|
||||||
for r := 0 to GetLastOccupiedRowIndex do
|
for r := GetFirstRowIndex to GetLastOccupiedRowIndex do
|
||||||
for c := 0 to GetlastOccupiedColIndex do
|
for c := GetFirstColIndex to GetlastOccupiedColIndex do
|
||||||
begin
|
begin
|
||||||
cell := FindCell(r, c);
|
cell := FindCell(r, c);
|
||||||
if FindSharedFormulaRange(cell, r1, c1, r2, c2) and (r1 = r2) and (c1 = c2) then
|
if FindSharedFormulaRange(cell, r1, c1, r2, c2) and (r1 = r2) and (c1 = c2) then
|
||||||
@ -2964,9 +2964,9 @@ var
|
|||||||
begin
|
begin
|
||||||
n := 0;
|
n := 0;
|
||||||
SetLength(AList, n);
|
SetLength(AList, n);
|
||||||
for r := 0 to GetLastOccupiedRowIndex do
|
for r := GetFirstRowIndex to GetLastOccupiedRowIndex do
|
||||||
begin
|
begin
|
||||||
c := 0;
|
c := GetFirstColIndex;
|
||||||
while (c <= GetLastOccupiedColIndex) do
|
while (c <= GetLastOccupiedColIndex) do
|
||||||
begin
|
begin
|
||||||
cell := FindCell(r, c);
|
cell := FindCell(r, c);
|
||||||
@ -4891,7 +4891,7 @@ var
|
|||||||
row: PRow;
|
row: PRow;
|
||||||
begin
|
begin
|
||||||
Result := 0;
|
Result := 0;
|
||||||
for r := 0 to GetLastRowIndex do begin
|
for r := GetFirstRowIndex to GetLastRowIndex do begin
|
||||||
cell := FindCell(r, ACol);
|
cell := FindCell(r, ACol);
|
||||||
if cell <> nil then
|
if cell <> nil then
|
||||||
inc(Result)
|
inc(Result)
|
||||||
@ -4979,13 +4979,14 @@ var
|
|||||||
r, c, rr, cc: Cardinal;
|
r, c, rr, cc: Cardinal;
|
||||||
r1, c1, r2, c2: Cardinal;
|
r1, c1, r2, c2: Cardinal;
|
||||||
cell, nextcell, basecell: PCell;
|
cell, nextcell, basecell: PCell;
|
||||||
lastCol, lastRow: Cardinal;
|
firstRow, lastCol, lastRow: Cardinal;
|
||||||
begin
|
begin
|
||||||
lastCol := GetLastColIndex;
|
lastCol := GetLastColIndex;
|
||||||
lastRow := GetLastOccupiedRowIndex;
|
lastRow := GetLastOccupiedRowIndex;
|
||||||
|
firstRow := GetFirstRowIndex;
|
||||||
|
|
||||||
// Loop along the column to be deleted and fix merged cells and shared formulas
|
// Loop along the column to be deleted and fix merged cells and shared formulas
|
||||||
for r := 0 to lastRow do
|
for r := firstRow to lastRow do
|
||||||
begin
|
begin
|
||||||
cell := FindCell(r, ACol);
|
cell := FindCell(r, ACol);
|
||||||
|
|
||||||
@ -5027,7 +5028,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// Delete cells
|
// Delete cells
|
||||||
for r := lastRow downto 0 do
|
for r := lastRow downto firstRow do
|
||||||
RemoveCell(r, ACol);
|
RemoveCell(r, ACol);
|
||||||
|
|
||||||
// Update column index of cell records
|
// Update column index of cell records
|
||||||
@ -5066,10 +5067,15 @@ var
|
|||||||
i: Integer;
|
i: Integer;
|
||||||
r, c, rr, cc: Cardinal;
|
r, c, rr, cc: Cardinal;
|
||||||
r1, c1, r2, c2: Cardinal;
|
r1, c1, r2, c2: Cardinal;
|
||||||
|
firstCol, lastCol, lastRow: Cardinal;
|
||||||
cell, nextcell, basecell: PCell;
|
cell, nextcell, basecell: PCell;
|
||||||
begin
|
begin
|
||||||
|
firstCol := GetFirstColIndex;
|
||||||
|
lastCol := GetLastOccupiedColIndex;
|
||||||
|
lastRow := GetLastOccupiedRowIndex;
|
||||||
|
|
||||||
// Loop along the row to be deleted and fix merged cells and shared formulas
|
// Loop along the row to be deleted and fix merged cells and shared formulas
|
||||||
for c := 0 to GetLastOccupiedColIndex do
|
for c := firstCol to lastCol do
|
||||||
begin
|
begin
|
||||||
cell := FindCell(ARow, c);
|
cell := FindCell(ARow, c);
|
||||||
|
|
||||||
@ -5098,8 +5104,8 @@ begin
|
|||||||
// Write adapted formula to the cell below.
|
// Write adapted formula to the cell below.
|
||||||
WriteFormula(nextcell, basecell^.FormulaValue); //ReadFormulaAsString(nextcell));
|
WriteFormula(nextcell, basecell^.FormulaValue); //ReadFormulaAsString(nextcell));
|
||||||
// Have all cells sharing the formula use the new formula base
|
// Have all cells sharing the formula use the new formula base
|
||||||
for rr := ARow+1 to GetLastOccupiedRowIndex do
|
for rr := ARow+1 to lastRow do
|
||||||
for cc := c to GetLastOccupiedColIndex do
|
for cc := c to lastCol do
|
||||||
begin
|
begin
|
||||||
cell := FindCell(rr, cc);
|
cell := FindCell(rr, cc);
|
||||||
if (cell <> nil) and (cell^.SharedFormulaBase = basecell) then
|
if (cell <> nil) and (cell^.SharedFormulaBase = basecell) then
|
||||||
@ -5111,7 +5117,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// Delete cells
|
// Delete cells
|
||||||
for c := GetLastColIndex downto 0 do
|
for c := lastCol downto 0 do
|
||||||
RemoveCell(ARow, c);
|
RemoveCell(ARow, c);
|
||||||
|
|
||||||
// Update row index of cell reocrds
|
// Update row index of cell reocrds
|
||||||
@ -5152,7 +5158,7 @@ var
|
|||||||
i: Integer;
|
i: Integer;
|
||||||
r, c, cc: Cardinal;
|
r, c, cc: Cardinal;
|
||||||
r1, c1, r2, c2: Cardinal;
|
r1, c1, r2, c2: Cardinal;
|
||||||
rLast, cLast: Cardinal;
|
rFirst, rLast, cLast: Cardinal;
|
||||||
cell, nextcell, gapcell, oldbase, newbase: PCell;
|
cell, nextcell, gapcell, oldbase, newbase: PCell;
|
||||||
begin
|
begin
|
||||||
// Handling of shared formula references is too complicated for me...
|
// Handling of shared formula references is too complicated for me...
|
||||||
@ -5185,11 +5191,12 @@ begin
|
|||||||
// with dummy cells and set their MergeBase correctly.
|
// with dummy cells and set their MergeBase correctly.
|
||||||
if ACol > 0 then
|
if ACol > 0 then
|
||||||
begin
|
begin
|
||||||
|
rFirst := GetFirstRowIndex;
|
||||||
rLast := GetLastOccupiedRowIndex;
|
rLast := GetLastOccupiedRowIndex;
|
||||||
cLast := GetlastOccupiedColIndex;
|
cLast := GetlastOccupiedColIndex;
|
||||||
c := ACol - 1;
|
c := ACol - 1;
|
||||||
// Seek along the column immediately to the left of the inserted column
|
// Seek along the column immediately to the left of the inserted column
|
||||||
for r := 0 to rLast do
|
for r := rFirst to rLast do
|
||||||
begin
|
begin
|
||||||
cell := FindCell(r, c);
|
cell := FindCell(r, c);
|
||||||
if not Assigned(cell) then
|
if not Assigned(cell) then
|
||||||
@ -5298,7 +5305,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
r := ARow - 1;
|
r := ARow - 1;
|
||||||
// Seek along the row immediately above the inserted row
|
// Seek along the row immediately above the inserted row
|
||||||
for c := 0 to GetLastOccupiedColIndex do
|
for c := GetFirstColIndex to GetLastOccupiedColIndex do
|
||||||
begin
|
begin
|
||||||
cell := FindCell(r, c);
|
cell := FindCell(r, c);
|
||||||
if not Assigned(cell) then
|
if not Assigned(cell) then
|
||||||
|
@ -1505,6 +1505,7 @@ var
|
|||||||
MyWorksheet: TsWorksheet;
|
MyWorksheet: TsWorksheet;
|
||||||
MyWorkbook: TsWorkbook;
|
MyWorkbook: TsWorkbook;
|
||||||
row, col: Integer;
|
row, col: Integer;
|
||||||
|
lastCol, lastRow: Cardinal;
|
||||||
r1,c1,r2,c2: Cardinal;
|
r1,c1,r2,c2: Cardinal;
|
||||||
MyCell: PCell;
|
MyCell: PCell;
|
||||||
TempFile: string; //write xls/xml to this file and read back from it
|
TempFile: string; //write xls/xml to this file and read back from it
|
||||||
@ -1609,10 +1610,14 @@ begin
|
|||||||
if MyWorksheet=nil then
|
if MyWorksheet=nil then
|
||||||
fail('Error in test code. Failed to get named worksheet');
|
fail('Error in test code. Failed to get named worksheet');
|
||||||
|
|
||||||
for row := 0 to MyWorksheet.GetLastRowIndex do begin
|
lastRow := MyWorksheet.GetLastOccupiedRowIndex;
|
||||||
|
lastCol := MyWorksheet.GetLastOccupiedColIndex;
|
||||||
|
|
||||||
|
for row := 0 to lastRow do
|
||||||
|
begin
|
||||||
expected := L[row];
|
expected := L[row];
|
||||||
actual := '';
|
actual := '';
|
||||||
for col := 0 to MyWorksheet.GetLastColIndex do
|
for col := 0 to lastcol do
|
||||||
begin
|
begin
|
||||||
MyCell := MyWorksheet.FindCell(row, col);
|
MyCell := MyWorksheet.FindCell(row, col);
|
||||||
|
|
||||||
|
@ -48,7 +48,6 @@
|
|||||||
<Unit1>
|
<Unit1>
|
||||||
<Filename Value="datetests.pas"/>
|
<Filename Value="datetests.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="datetests"/>
|
|
||||||
</Unit1>
|
</Unit1>
|
||||||
<Unit2>
|
<Unit2>
|
||||||
<Filename Value="stringtests.pas"/>
|
<Filename Value="stringtests.pas"/>
|
||||||
@ -57,6 +56,7 @@
|
|||||||
<Unit3>
|
<Unit3>
|
||||||
<Filename Value="numberstests.pas"/>
|
<Filename Value="numberstests.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
|
<UnitName Value="numberstests"/>
|
||||||
</Unit3>
|
</Unit3>
|
||||||
<Unit4>
|
<Unit4>
|
||||||
<Filename Value="manualtests.pas"/>
|
<Filename Value="manualtests.pas"/>
|
||||||
@ -71,11 +71,11 @@
|
|||||||
<Unit6>
|
<Unit6>
|
||||||
<Filename Value="internaltests.pas"/>
|
<Filename Value="internaltests.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="internaltests"/>
|
|
||||||
</Unit6>
|
</Unit6>
|
||||||
<Unit7>
|
<Unit7>
|
||||||
<Filename Value="formattests.pas"/>
|
<Filename Value="formattests.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
|
<UnitName Value="formattests"/>
|
||||||
</Unit7>
|
</Unit7>
|
||||||
<Unit8>
|
<Unit8>
|
||||||
<Filename Value="colortests.pas"/>
|
<Filename Value="colortests.pas"/>
|
||||||
@ -96,6 +96,7 @@
|
|||||||
<Unit12>
|
<Unit12>
|
||||||
<Filename Value="rpnformulaunit.pas"/>
|
<Filename Value="rpnformulaunit.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
|
<UnitName Value="rpnFormulaUnit"/>
|
||||||
</Unit12>
|
</Unit12>
|
||||||
<Unit13>
|
<Unit13>
|
||||||
<Filename Value="formulatests.pas"/>
|
<Filename Value="formulatests.pas"/>
|
||||||
@ -105,10 +106,12 @@
|
|||||||
<Unit14>
|
<Unit14>
|
||||||
<Filename Value="emptycelltests.pas"/>
|
<Filename Value="emptycelltests.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
|
<UnitName Value="emptycelltests"/>
|
||||||
</Unit14>
|
</Unit14>
|
||||||
<Unit15>
|
<Unit15>
|
||||||
<Filename Value="errortests.pas"/>
|
<Filename Value="errortests.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
|
<UnitName Value="errortests"/>
|
||||||
</Unit15>
|
</Unit15>
|
||||||
<Unit16>
|
<Unit16>
|
||||||
<Filename Value="virtualmodetests.pas"/>
|
<Filename Value="virtualmodetests.pas"/>
|
||||||
|
Reference in New Issue
Block a user