From b873069b548dd97dea241c62bfcc439d92f1551d Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Fri, 9 Oct 2015 14:47:37 +0000 Subject: [PATCH] fpspreadsheet: Fix incorrect detection of cell ranges in ods files. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4374 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/fpspreadsheet/fpsexprparser.pas | 27 +++++++++++++--------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/components/fpspreadsheet/fpsexprparser.pas b/components/fpspreadsheet/fpsexprparser.pas index de243aa9e..6f739a136 100644 --- a/components/fpspreadsheet/fpsexprparser.pas +++ b/components/fpspreadsheet/fpsexprparser.pas @@ -700,6 +700,7 @@ type procedure SetExpression(const AValue: String); procedure SetLocalizedExpression(const AFormatSettings: TFormatSettings; const AValue: String); virtual; + procedure CheckResultType(const Res: TsExpressionResult; AType: TsResultType); inline; function CurrentToken: String; @@ -1070,33 +1071,37 @@ end; function TsExpressionScanner.DoSquareBracket: TsTokenType; var C: Char; - p: Integer; r1,c1,r2,c2: Cardinal; flags: TsRelFlags; + isRange: Boolean; begin + isRange := false; FToken := ''; C := NextPos; while (C <> ']') do begin - if C = cNull then - ScanError(SErrUnexpectedEndOfExpression); - FToken := FToken + C; + case C of + cNull: ScanError(SErrUnexpectedEndOfExpression); + '.' : ; // ignore + ':' : begin isRange := true; FToken := FToken + C; end; + else FToken := FToken + C; + end; C := NextPos; end; C := NextPos; - p := system.pos('.', FToken); // Delete up tp "." (--> to be considered later!) - if p <> 0 then Delete(FToken, 1, p); - if system.pos(':', FToken) > 0 then + if isRange then begin if ParseCellRangeString(FToken, r1, c1, r2, c2, flags) then Result := ttCellRange else ScanError(Format(SErrInvalidCellRange, [FToken])); end else - if ParseCellString(FToken, r1, c1, flags) then - Result := ttCell - else - ScanError(Format(SErrInvalidCell, [FToken])); + begin + if ParseCellString(FToken, r1, c1, flags) then + Result := ttCell + else + ScanError(Format(SErrInvalidCell, [FToken])); + end; end; function TsExpressionScanner.DoString: TsTokenType;