fpspreadsheet: Fix circular reference issue and #REF! issue for some formulas (https://forum.lazarus.freepascal.org/index.php/topic,41161.msg288278.html#msg288278)

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6486 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2018-06-10 20:20:50 +00:00
parent 842ff47426
commit cc7ef858c4

View File

@ -601,10 +601,9 @@ type
TsCellExprNode = class(TsExprNode) TsCellExprNode = class(TsExprNode)
private private
FWorksheet: TsBasicWorksheet; // sheet containing the formula FWorksheet: TsBasicWorksheet; // sheet containing the formula
FRow, FCol: Cardinal; FRow, FCol: Cardinal; // row/col of referenced cell
FFlags: TsRelFlags; FFlags: TsRelFlags; // abs/rel flags of reference
FCell: PCell; // cell which contains the formula // FCell: PCell; // cell which contains the formula
// FSheetName: String; // referenced other sheet
FSheetIndex: Integer; // index of referenced other sheet FSheetIndex: Integer; // index of referenced other sheet
FHas3DLink: Boolean; FHas3DLink: Boolean;
FIsRef: Boolean; FIsRef: Boolean;
@ -3842,6 +3841,10 @@ end;
{ TsCellExprNode } { TsCellExprNode }
{ AWorksheet -- sheet which contains the formula (needed for non-3d formulas)
ASheetIndex -- referenced sheet (needed for 3d formulas, empty for non-3d)
ARow, ACol -- row/col indexes of referenced cell
AFlags -- determines whether the reference is absolute or relative }
constructor TsCellExprNode.Create(AParser: TsExpressionParser; constructor TsCellExprNode.Create(AParser: TsExpressionParser;
AWorksheet: TsBasicWorksheet; ASheetName: String; ARow, ACol: Cardinal; AWorksheet: TsBasicWorksheet; ASheetName: String; ARow, ACol: Cardinal;
AFlags: TsRelFlags); AFlags: TsRelFlags);
@ -3861,8 +3864,7 @@ begin
FRow := ARow; FRow := ARow;
FCol := ACol; FCol := ACol;
FFlags := AFlags; FFlags := AFlags;
FCell := TsWorksheet(FWorksheet).FindCell(FRow, FCol); // FCell := TsWorksheet(FWorksheet).FindCell(FRow, FCol);
// FCell := (GetSheet as TsWorksheet).FindCell(FRow, FCol);
end; end;
function TsCellExprNode.AsRPNItem(ANext: PRPNItem): PRPNItem; function TsCellExprNode.AsRPNItem(ANext: PRPNItem): PRPNItem;
@ -3951,10 +3953,13 @@ begin
exit; exit;
end; end;
cell := TsWorksheet(GetSheet).FindCell(GetRow, GetCol);
{
if Parser.CopyMode then if Parser.CopyMode then
cell := (FWorksheet as TsWorksheet).FindCell(GetRow, GetCol) cell := (FWorksheet as TsWorksheet).FindCell(GetRow, GetCol)
else else
cell := FCell; cell := FCell;
}
if (cell <> nil) and HasFormula(cell) then begin if (cell <> nil) and HasFormula(cell) then begin
sheet := TsWorksheet(cell^.Worksheet); sheet := TsWorksheet(cell^.Worksheet);