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 end
object CbBackgroundColor: TColorBox object CbBackgroundColor: TColorBox
Left = 507 Left = 507
Height = 22 Height = 26
Top = 2 Top = 2
Width = 149 Width = 149
Style = [cbPrettyNames, cbCustomColors] Style = [cbPrettyNames, cbCustomColors]
OnGetColors = CbBackgroundColorGetColors OnGetColors = CbBackgroundColorGetColors
ItemHeight = 16 ItemHeight = 20
OnSelect = CbBackgroundColorSelect OnSelect = CbBackgroundColorSelect
TabOrder = 2 TabOrder = 2
end end

View File

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

View File

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