You've already forked lazarus-ccr
fpspreadsheet: Add exception handling for CF expressions writing to the workbook's error log.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7542 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -78,6 +78,8 @@ const
|
||||
];
|
||||
|
||||
type
|
||||
EGeneralExprParserError = Exception;
|
||||
|
||||
// Forward declarations
|
||||
TsExpressionParser = class;
|
||||
TsBuiltInExpressionManager = class;
|
||||
@@ -672,7 +674,7 @@ type
|
||||
property SheetnameTerminator: char read FSheetNameTerminator write FSheetNameTerminator;
|
||||
end;
|
||||
|
||||
EExprScanner = class(Exception);
|
||||
EExprScanner = class(EGeneralExprParserError);
|
||||
PFormatSettings = ^TFormatSettings;
|
||||
|
||||
{ TsExpressionParser }
|
||||
@@ -833,8 +835,8 @@ type
|
||||
PsFormula = ^TsFormula;
|
||||
|
||||
{ Exception classes }
|
||||
EExprParser = class(Exception);
|
||||
ECalcEngine = class(Exception);
|
||||
EExprParser = class(EGeneralExprParserError);
|
||||
ECalcEngine = class(EGeneralExprParserError);
|
||||
|
||||
function TokenName(AToken: TsTokenType): String;
|
||||
function ResultTypeName(AResult: TsResultType): String;
|
||||
|
@@ -436,8 +436,16 @@ begin
|
||||
begin
|
||||
parser := TsSpreadsheetParser.Create(AWorksheet);
|
||||
try
|
||||
parser.Expression[fdExcelA1] := Result; // Parse in Excel-A1 dialect
|
||||
Result := parser.Expression[fdOpenDocument]; // Convert to ODS dialect
|
||||
try
|
||||
parser.Expression[fdExcelA1] := Result; // Parse in Excel-A1 dialect
|
||||
Result := parser.Expression[fdOpenDocument]; // Convert to ODS dialect
|
||||
except
|
||||
on EGeneralExprParserError do
|
||||
begin
|
||||
Result := VarToStr(v);
|
||||
AWorksheet.Workbook.AddErrorMsg('Error in CF Expression ' + Result);
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
parser.Free;
|
||||
end;
|
||||
|
@@ -289,8 +289,16 @@ begin
|
||||
begin
|
||||
parser := TsSpreadsheetParser.Create(AWorksheet);
|
||||
try
|
||||
parser.Expression[fdExcelA1] := Result; // Parse in Excel-A1 dialect
|
||||
Result := parser.R1C1Expression[nil]; // Convert to R1C1 dialect
|
||||
try
|
||||
parser.Expression[fdExcelA1] := Result; // Parse in Excel-A1 dialect
|
||||
Result := parser.R1C1Expression[nil]; // Convert to R1C1 dialect
|
||||
except
|
||||
on EGeneralExprParserError do
|
||||
begin
|
||||
Result := VarToStr(v);
|
||||
AWorksheet.Workbook.AddErrorMsg('Error in CF Expression ' + Result);
|
||||
end;
|
||||
end;
|
||||
// Note: Using nil here to get absolute references.
|
||||
finally
|
||||
parser.Free;
|
||||
|
Reference in New Issue
Block a user