fpspreadsheet: Fix incorrect column calculation when ODS formula refers to column index > 25 (> 'AA') (https://forum.lazarus.freepascal.org/index.php/topic,59001).

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8245 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2022-04-08 10:57:15 +00:00
parent e924763a40
commit 0f64e793db
2 changed files with 6 additions and 4 deletions

View File

@ -999,6 +999,7 @@ begin
FToken := ''; FToken := '';
C := NextPos; C := NextPos;
prevC := #0; prevC := #0;
val := 0;
while (C <> ']') and (C <> cNULL) do begin while (C <> ']') and (C <> cNULL) do begin
case C of case C of
cNULL: ScanError(rsUnexpectedEndOfExpression); cNULL: ScanError(rsUnexpectedEndOfExpression);
@ -1046,12 +1047,12 @@ begin
else else
case C of case C of
'A'..'Z': 'A'..'Z':
val := val*10 + ord(C) - ord('A'); val := val*26 + ord(C) - ord('A') + 1;
'a'..'z': 'a'..'z':
val := val*10 + ord(C) - ord('a'); val := val*26 + ord(C) - ord('a') + 1;
'0'..'9': '0'..'9':
if state = ssInCol1 then begin if state = ssInCol1 then begin
FCellRange.Col1 := val; FCellRange.Col1 := val - 1;
val := (ord(C) - ord('0')); val := (ord(C) - ord('0'));
state := ssInRow1; state := ssInRow1;
end else end else
@ -1059,7 +1060,7 @@ begin
val := val*10 + (ord(C) - ord('0')) val := val*10 + (ord(C) - ord('0'))
else else
if state = ssInCol2 then begin if state = ssInCol2 then begin
FCellRange.Col2 := val; FCellRange.Col2 := val - 1;
val := (ord(C) - ord('0')); val := (ord(C) - ord('0'));
state := ssInRow2; state := ssInRow2;
end else end else

View File

@ -601,6 +601,7 @@ function ParseCellString(const AStr: String; out ACellRow, ACellCol: Cardinal;
isAbs: Boolean; isAbs: Boolean;
begin begin
Result := false; Result := false;
ACellCol := 0;
i := AStartPos; i := AStartPos;
// Scan letters // Scan letters