fpspreadsheet: Improved display of formula result details in BIFFExplorer.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3240 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2014-06-25 14:05:07 +00:00
parent 33924c97bd
commit 421fb86dcf
3 changed files with 71 additions and 42 deletions

View File

@ -342,12 +342,12 @@ object Form1: TForm1
end
object CbBackgroundColor: TColorBox
Left = 507
Height = 22
Height = 26
Top = 2
Width = 149
Style = [cbPrettyNames, cbCustomColors]
OnGetColors = CbBackgroundColorGetColors
ItemHeight = 16
ItemHeight = 20
OnSelect = CbBackgroundColorSelect
TabOrder = 2
end

View File

@ -712,7 +712,7 @@ begin
FormatToolbar.Height := FontCombobox.Height + 2*FontCombobox.Top;
FormatToolbar.ButtonHeight := FormatToolbar.Height - 4;
CbBackgroundCOlor.Height := FontCombobox.Height;
CbBackgroundColor.ItemHeight := FontCombobox.ItemHeight;
// Populate font combobox
FontCombobox.Items.Assign(Screen.Fonts);

View File

@ -1340,6 +1340,8 @@ var
w: Word;
q: QWord;
dbl: double absolute q;
bytearr: array[0..7] of byte absolute q;
wordarr: array[0..3] of word absolute q;
s: String;
tokenBytes: Integer;
firstTokenBufIdx: Integer;
@ -1421,47 +1423,74 @@ begin
// Offset 6: Result of formula
numBytes := 8;
Move(FBuffer[FBufferIndex], q, numBytes);
if (FFormat > sfExcel2) then
case FBuffer[FBufferIndex] of
if (FFormat > sfExcel2) then begin
if wordarr[3] <> $FFFF then begin
if FCurrRow = Row then begin
FDetails.Add('Formula result:'#13);
FDetails.Add(Format('Bytes 0-7: $%.15x --> IEEE 764 floating-point value, 64-bit double precision'#13+
' = %g', [q, dbl]));
end;
ShowInRow(FCurrRow, FBufferIndex, numBytes, FloatToStr(dbl),
'Result of formula (IEEE 764 floating-point value, 64-bit double precision)');
end else begin
case bytearr[0] of
0: begin
if FCurrRow = Row then begin
FDetails.Add('Formula result:'#13);
FDetails.Add('Byte 0 = 0 --> Result is string, follows in STRING record');
FDetails.Add('Bytes 1-5: Not used');
FDetails.Add('Bytes 6&7: Must be $FFFF');
FDetails.Add('Byte 1-5: Not used');
FDetails.Add('Byte 6&7: $FFFF --> no floating point number');
end;
ShowInRow(FCurrRow, FBufferIndex, numBytes, Format('$%.16x', [q]),
'Result is STRING, follows in STRING record');
'Result is a string, follows in STRING record');
end;
1: begin
if FCurrRow = Row then begin
FDetails.Add('Formula result:'#13);
FDetails.Add('Byte 0 = 1 --> Result is BOOLEAN');
FDetails.Add('Byte 1: Not used');
if bytearr[2] = 0
then FDetails.Add('Byte 2 = 0 --> FALSE')
else FDetails.Add('Byte 2 = 1 --> TRUE');
FDetails.Add('Bytes 3-5: Not used');
FDetails.Add('Bytes 6&7: $FFFF --> no floating point number');
end;
1: if FBuffer[FBufferIndex + 2] = 0 then
ShowInRow(FCurrRow, FBufferIndex, numBytes, Format('$%.16x', [q]),
'Result is BOOL (FALSE)')
else
ShowInRow(FCurrRow, FBufferIndex, numBytes, Format('$%.16x', [q]),
'Result is BOOL (TRUE)');
'Result is BOOLEAN');
end;
2: begin
if FCurrRow = Row then begin
FDetails.Add('Formula result:'#13);
FDetails.Add('Byte 0 = 2 --> Token contains an ERROR code');
FDetails.Add('Byte 1: not used');
FDetails.Add(Format('Byte 2 = %d ($%.2x): "%s"', [
FBuffer[FBufferIndex + 2],
FBuffer[FBufferIndex + 2],
ErrorCodeName(FBufferIndex + 2)
]));
FDetails.Add('Bytes 2-5: not used');
FDetails.Add('Bytes 6&7: Must be $FFFF');
FDetails.Add('Byte 0 = 2 --> Result is an ERROR value');
FDetails.Add('Byte 1: Not used');
case bytearr[2] of
$00: FDetails.Add('Byte 2 = $00 --> #NULL! Intersection of two cell ranges is empty');
$07: FDetails.Add('Byte 2 = $07 --> #DIV/0! Division by zero');
$0F: FDetails.Add('Byte 2 = $0F --> #VALUE! Wrong type of operand');
$17: FDetails.Add('Byte 2 = $17 --> #REF! Illegal or deleted cell reference');
$1D: FDetails.Add('Byte 2 = $1D --> #NAME? Wrong function or range name');
$24: FDetails.Add('Byte 2 = $24 --> #NUM! Value range overflow');
$2A: FDetails.Add('Byte 2 = $2A --> #N/A Argument or function not available');
end;
FDetails.Add('Bytes 6&7: $FFFF --> no floating point number');
end;
ShowInRow(FCurrRow, FBufferIndex, numBytes, Format('$%.16x', [q]),
Format('Result is ERROR code $%.2x', [FBuffer[FBufferIndex+2]]));
'Result is an ERROR value');
end;
3: begin
if FCurrRow = Row then begin
FDetails.Add('Formula result:'#13);
FDetails.Add('Byte 0 = 3 --> Result is an empty cell, for example an empty string');
FDetails.Add('Byte 1-5: Not used');
FDetails.Add('Bytes 6&7: $FFFF --> no floating point number');
end;
ShowInRow(FCurrRow, FBufferIndex, numBytes, Format('$%.16x', [q]),
'Result is an EMPTY cell (empty string)');
end;
end;
end;
3: ShowInRow(FCurrRow, FBufferIndex, numBytes, Format('$.16x', [q]),
'Result is EMPTY cell');
else
ShowInRow(FCurrRow, FBufferIndex, numBytes, FloatToStr(dbl),
'Result of formula (IEEE 764 floating-point value, 64-bit double precision)');
end
else begin
else begin // Excel 2
ShowInRow(FCurrRow, FBufferIndex, numBytes, FloatToStr(dbl),
'Result of formula (IEEE 764 floating-point value, 64-bit double precision)');
end;