You've already forked lazarus-ccr
fpspreadsheet: Fix missing error to be shown when a sheet containing a formula with circular reference is calculated.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3896 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -795,6 +795,7 @@ type
|
||||
end;
|
||||
|
||||
EExprParser = class(Exception);
|
||||
ECalcEngine = class(Exception);
|
||||
|
||||
function TokenName(AToken: TsTokenType): String;
|
||||
function ResultTypeName(AResult: TsResultType): String;
|
||||
@ -881,7 +882,7 @@ resourcestring
|
||||
ErrInvalidArgumentCount = 'Invalid argument count for function %s';
|
||||
SErrInvalidResultType = 'Invalid result type: %s';
|
||||
SErrNotVariable = 'Identifier %s is not a variable';
|
||||
SErrCircularReference = 'Circular reference found when calculating worksheet formulas';
|
||||
SErrCircularReference = 'Circular reference found when calculating worksheet formula in cell %s';
|
||||
|
||||
{ ---------------------------------------------------------------------
|
||||
Auxiliary functions
|
||||
@ -3846,7 +3847,7 @@ begin
|
||||
csNotCalculated:
|
||||
Worksheet.CalcFormula(cell);
|
||||
csCalculating:
|
||||
raise Exception.Create(SErrCircularReference);
|
||||
raise ECalcEngine.CreateFmt(SErrCircularReference, [GetCellString(cell^.Row, cell^.Col)]);
|
||||
end;
|
||||
|
||||
Result.ResultType := rtCell;
|
||||
|
@ -1386,14 +1386,21 @@ begin
|
||||
begin
|
||||
formula := ACell^.FormulaValue;
|
||||
parser.ActiveCell := nil;
|
||||
end
|
||||
else
|
||||
end else
|
||||
begin
|
||||
formula := ACell^.SharedFormulaBase^.FormulaValue;
|
||||
parser.ActiveCell := ACell;
|
||||
end;
|
||||
parser.Expression := formula;
|
||||
res := parser.Evaluate;
|
||||
try
|
||||
parser.Expression := formula;
|
||||
res := parser.Evaluate;
|
||||
except
|
||||
on E:ECalcEngine do
|
||||
begin
|
||||
Workbook.AddErrorMsg(E.Message);
|
||||
Res := ErrorResult(errIllegalRef);
|
||||
end;
|
||||
end;
|
||||
case res.ResultType of
|
||||
rtEmpty : WriteBlank(ACell);
|
||||
rtError : WriteErrorValue(ACell, res.ResError);
|
||||
@ -1450,7 +1457,7 @@ begin
|
||||
node := FCells.FindSuccessor(node);
|
||||
end;
|
||||
|
||||
// Step 2 - calculate cells. If a not-calculated cell is found it is
|
||||
// Step 2 - calculate cells. If a not-yet-calculated cell is found it is
|
||||
// calculated and then marked as such.
|
||||
node := FCells.FindLowest;
|
||||
while Assigned(Node) do begin
|
||||
|
Reference in New Issue
Block a user