You've already forked lazarus-ccr
fpspreadsheet: Make default cell compare procedure public.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6929 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -123,8 +123,6 @@ type
|
|||||||
|
|
||||||
// Sorting
|
// Sorting
|
||||||
function DoCompareCells(AColRow1, AColRow2: Cardinal): Integer;
|
function DoCompareCells(AColRow1, AColRow2: Cardinal): Integer;
|
||||||
function DoInternalCompareCells(ACell1, ACell2: PCell;
|
|
||||||
ASortOptions: TsSortOptions): Integer;
|
|
||||||
procedure DoExchangeColRow(AIsColumn: Boolean; AIndex, WithIndex: Cardinal;
|
procedure DoExchangeColRow(AIsColumn: Boolean; AIndex, WithIndex: Cardinal;
|
||||||
AFromIndex, AToIndex: Cardinal);
|
AFromIndex, AToIndex: Cardinal);
|
||||||
procedure ExchangeCells(ARow1, ACol1, ARow2, ACol2: Cardinal);
|
procedure ExchangeCells(ARow1, ACol1, ARow2, ACol2: Cardinal);
|
||||||
@ -484,6 +482,8 @@ type
|
|||||||
AColWidthType: TsColWidthType = cwtCustom); overload; deprecated 'Use version with parameter AUnits';
|
AColWidthType: TsColWidthType = cwtCustom); overload; deprecated 'Use version with parameter AUnits';
|
||||||
|
|
||||||
// Sorting
|
// Sorting
|
||||||
|
function DefaultCompareCells(ACell1, ACell2: PCell;
|
||||||
|
ASortOptions: TsSortOptions): Integer;
|
||||||
procedure Sort(const ASortParams: TsSortParams;
|
procedure Sort(const ASortParams: TsSortParams;
|
||||||
ARowFrom, AColFrom, ARowTo, AColTo: Cardinal); overload;
|
ARowFrom, AColFrom, ARowTo, AColTo: Cardinal); overload;
|
||||||
procedure Sort(ASortParams: TsSortParams; ARange: String); overload;
|
procedure Sort(ASortParams: TsSortParams; ARange: String); overload;
|
||||||
@ -4299,7 +4299,10 @@ begin
|
|||||||
cell1 := FindCell(FSortParams.Keys[key].ColRowIndex, AColRow1);
|
cell1 := FindCell(FSortParams.Keys[key].ColRowIndex, AColRow1);
|
||||||
cell2 := FindCell(FSortParams.Keys[key].ColRowIndex, AColRow2);
|
cell2 := FindCell(FSortParams.Keys[key].ColRowIndex, AColRow2);
|
||||||
end;
|
end;
|
||||||
Result := DoInternalCompareCells(cell1, cell2, FSortParams.Keys[key].Options);
|
if Assigned(OnCompareCells) then
|
||||||
|
OnCompareCells(Self, cell1, cell2, Result)
|
||||||
|
else
|
||||||
|
Result := DefaultCompareCells(cell1, cell2, FSortParams.Keys[key].Options);
|
||||||
inc(key);
|
inc(key);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -4323,7 +4326,7 @@ end;
|
|||||||
Empty cells are always at the end (in both ascending and descending
|
Empty cells are always at the end (in both ascending and descending
|
||||||
order)
|
order)
|
||||||
-------------------------------------------------------------------------------}
|
-------------------------------------------------------------------------------}
|
||||||
function TsWorksheet.DoInternalCompareCells(ACell1, ACell2: PCell;
|
function TsWorksheet.DefaultCompareCells(ACell1, ACell2: PCell;
|
||||||
ASortOptions: TsSortOptions): Integer;
|
ASortOptions: TsSortOptions): Integer;
|
||||||
// Sort priority in Excel:
|
// Sort priority in Excel:
|
||||||
// numbers < alpha < blank (ascending)
|
// numbers < alpha < blank (ascending)
|
||||||
@ -4331,11 +4334,8 @@ function TsWorksheet.DoInternalCompareCells(ACell1, ACell2: PCell;
|
|||||||
var
|
var
|
||||||
number1, number2: Double;
|
number1, number2: Double;
|
||||||
begin
|
begin
|
||||||
result := 0;
|
Result := 0;
|
||||||
if Assigned(OnCompareCells) then
|
|
||||||
OnCompareCells(Self, ACell1, ACell2, Result)
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
if (ACell1 = nil) and (ACell2 = nil) then
|
if (ACell1 = nil) and (ACell2 = nil) then
|
||||||
Result := 0
|
Result := 0
|
||||||
else
|
else
|
||||||
@ -4354,11 +4354,6 @@ begin
|
|||||||
Result := -1; // Empty cells go to the end
|
Result := -1; // Empty cells go to the end
|
||||||
exit; // Avoid SortOrder to bring the empty cell to the top!
|
exit; // Avoid SortOrder to bring the empty cell to the top!
|
||||||
end else
|
end else
|
||||||
{
|
|
||||||
if (ACell1^.ContentType = cctEmpty) and (ACell2^.ContentType = cctEmpty) then
|
|
||||||
Result := 0
|
|
||||||
else
|
|
||||||
}
|
|
||||||
if (ACell1^.ContentType = cctUTF8String) and (ACell2^.ContentType = cctUTF8String) then
|
if (ACell1^.ContentType = cctUTF8String) and (ACell2^.ContentType = cctUTF8String) then
|
||||||
begin
|
begin
|
||||||
if ssoCaseInsensitive in ASortOptions then
|
if ssoCaseInsensitive in ASortOptions then
|
||||||
@ -4383,7 +4378,7 @@ begin
|
|||||||
ReadNumericValue(ACell2, number2);
|
ReadNumericValue(ACell2, number2);
|
||||||
Result := CompareValue(number1, number2);
|
Result := CompareValue(number1, number2);
|
||||||
end;
|
end;
|
||||||
end;
|
|
||||||
if ssoDescending in ASortOptions then
|
if ssoDescending in ASortOptions then
|
||||||
Result := -Result;
|
Result := -Result;
|
||||||
end;
|
end;
|
||||||
|
Reference in New Issue
Block a user