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
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 0: begin
if FCurrRow = Row then begin if FCurrRow = Row then begin
FDetails.Add('Formula result:'#13); FDetails.Add('Formula result:'#13);
FDetails.Add('Byte 0 = 0 --> Result is string, follows in STRING record'); FDetails.Add('Byte 0 = 0 --> Result is string, follows in STRING record');
FDetails.Add('Bytes 1-5: Not used'); FDetails.Add('Byte 1-5: Not used');
FDetails.Add('Bytes 6&7: Must be $FFFF'); FDetails.Add('Byte 6&7: $FFFF --> no floating point number');
end; end;
ShowInRow(FCurrRow, FBufferIndex, numBytes, Format('$%.16x', [q]), 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; end;
1: if FBuffer[FBufferIndex + 2] = 0 then
ShowInRow(FCurrRow, FBufferIndex, numBytes, Format('$%.16x', [q]), ShowInRow(FCurrRow, FBufferIndex, numBytes, Format('$%.16x', [q]),
'Result is BOOL (FALSE)') 'Result is BOOLEAN');
else end;
ShowInRow(FCurrRow, FBufferIndex, numBytes, Format('$%.16x', [q]),
'Result is BOOL (TRUE)');
2: begin 2: begin
if FCurrRow = Row then begin if FCurrRow = Row then begin
FDetails.Add('Formula result:'#13); FDetails.Add('Formula result:'#13);
FDetails.Add('Byte 0 = 2 --> Token contains an ERROR code'); FDetails.Add('Byte 0 = 2 --> Result is an ERROR value');
FDetails.Add('Byte 1: not used'); FDetails.Add('Byte 1: Not used');
FDetails.Add(Format('Byte 2 = %d ($%.2x): "%s"', [ case bytearr[2] of
FBuffer[FBufferIndex + 2], $00: FDetails.Add('Byte 2 = $00 --> #NULL! Intersection of two cell ranges is empty');
FBuffer[FBufferIndex + 2], $07: FDetails.Add('Byte 2 = $07 --> #DIV/0! Division by zero');
ErrorCodeName(FBufferIndex + 2) $0F: FDetails.Add('Byte 2 = $0F --> #VALUE! Wrong type of operand');
])); $17: FDetails.Add('Byte 2 = $17 --> #REF! Illegal or deleted cell reference');
FDetails.Add('Bytes 2-5: not used'); $1D: FDetails.Add('Byte 2 = $1D --> #NAME? Wrong function or range name');
FDetails.Add('Bytes 6&7: Must be $FFFF'); $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; end;
ShowInRow(FCurrRow, FBufferIndex, numBytes, Format('$%.16x', [q]), 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; 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 end
else begin 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;