fpspreadsheet: Improved/added info on RK/MULRK records in BIFFExplorer

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3043 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2014-05-11 17:46:28 +00:00
parent 75f2a8c0a5
commit ec0d54a269
2 changed files with 101 additions and 20 deletions

View File

@ -62,6 +62,7 @@ type
procedure ShowLeftMargin; procedure ShowLeftMargin;
procedure ShowMMS; procedure ShowMMS;
procedure ShowMulBlank; procedure ShowMulBlank;
procedure ShowMulRK;
procedure ShowNote; procedure ShowNote;
procedure ShowNumberCell; procedure ShowNumberCell;
procedure ShowObj; procedure ShowObj;
@ -336,6 +337,8 @@ begin
ShowFnGroupCount; ShowFnGroupCount;
$00BE: $00BE:
ShowMulBlank; ShowMulBlank;
$00BD:
ShowMulRK;
$00DA: $00DA:
ShowBookBool; ShowBookBool;
$00E0: $00E0:
@ -2148,6 +2151,77 @@ begin
end; end;
procedure TBIFFGrid.ShowMulRK;
var
w: Word;
numBytes: Integer;
i, nc: Integer;
dw: DWord;
encint: DWord;
encdbl: QWord;
dbl: Double absolute encdbl;
s: String;
begin
nc := (Length(FBuffer) - 6) div 6;
RowCount := FixedRows + 3 + nc*2;
numBytes := 2;
Move(FBuffer[FBufferIndex], w, numbytes);
ShowInRow(FCurrRow, FBufferIndex, numbytes, IntToStr(WordLEToN(w)),
'Index to row');
Move(FBuffer[FBufferIndex], w, numbytes);
ShowInRow(FCurrRow, FBufferIndex, numbytes, IntToStr(WordLEToN(w)),
'Index to first column');
for i:=0 to nc-1 do begin
numBytes := 2;
Move(FBuffer[FBufferIndex], w, numbytes);
ShowInRow(FCurrRow, FBufferIndex, numbytes, IntToStr(WordLEToN(w)),
Format('Index to XF record #%d', [i]));
numBytes := 4;
Move(FBuffer[FBufferIndex], dw, numbytes);
dw := DWordLEToN(dw);
if Row = FCurrRow then begin
FDetails.Add('RK Value:'#13);
if dw and $00000001 = 0
then FDetails.Add('Bit 0 = 0: Value not changed')
else FDetails.Add('Bit 0 = 1: Encoded value is multiplied by 100.');
if dw and $00000002 = 0
then FDetails.Add('Bit 1 = 0: Floating point value')
else FDetails.Add('Bit 1 = 1: Signed integer value');
if dw and $00000002 = 0 then begin
encdbl := (QWord(dw) and QWord($FFFFFFFFFFFFFFFC)) shl 32;
if dw and $00000001 = 1 then
s := Format('%.2f', [dbl*0.01])
else
s := Format('%.0f', [dbl]);
end
else begin
s := Format('$%.16x', [-59000000]);
encint := ((dw and DWord($FFFFFFFC)) shr 2) or (dw and DWord($C0000000));
// "arithmetic shift" = replace left-most bits by original bits
if dw and $00000001 = 1 then
s := FloatToStr(encint*0.01)
else
s := IntToStr(encint);
end;
FDetails.Add('Bits 31-2: Encoded value ' + s);
end;
ShowInRow(FCurrRow, FBufferIndex, numBytes,
Format('$%.8x', [dw]),
Format('RK value #%d', [i])
);
end;
numBytes := 2;
Move(FBuffer[FBufferIndex], w, numbytes);
ShowInRow(FCurrRow, FBufferIndex, numbytes, IntToStr(WordLEToN(w)),
'Index to last column');
end;
procedure TBIFFGrid.ShowNote; procedure TBIFFGrid.ShowNote;
var var
numBytes: Integer; numBytes: Integer;
@ -2697,6 +2771,14 @@ begin
Move(FBuffer[FBufferIndex], dw, numBytes); Move(FBuffer[FBufferIndex], dw, numBytes);
dw := DWordLEToN(dw); dw := DWordLEToN(dw);
if Row = FCurrRow then begin
FDetails.Add('RK Value:'#13);
if dw and $00000001 = 0
then FDetails.Add('Bit 0 = 0: Value not changed')
else FDetails.Add('Bit 0 = 1: Encoded value is multiplied by 100.');
if dw and $00000002 = 0
then FDetails.Add('Bit 1 = 0: Floating point value')
else FDetails.Add('Bit 1 = 1: Signed integer value');
if dw and $00000002 = 0 then begin if dw and $00000002 = 0 then begin
encdbl := (QWord(dw) and QWord($FFFFFFFFFFFFFFFC)) shl 32; encdbl := (QWord(dw) and QWord($FFFFFFFFFFFFFFFC)) shl 32;
if dw and $00000001 = 1 then if dw and $00000001 = 1 then
@ -2713,11 +2795,10 @@ begin
else else
s := IntToStr(encint); s := IntToStr(encint);
end; end;
FDetails.Add('Bits 31-2: Encoded value ' + s);
end;
ShowInRow(FCurrRow, FBufferIndex, numBytes, ShowInRow(FCurrRow, FBufferIndex, numBytes,
Format('$%.8x', [dw]), Format('$%.8x', [dw]), 'RK value');
Format('RK value (Bit 0=Unchanged/Encoded value multiplied by 100, Bit 1=float/signed int, '+
'Bits 2-31=encoded value (here: %s)', [s])
);
end; end;

View File

@ -288,7 +288,7 @@ begin
$0236: Result := 'TABLE: Data table'; $0236: Result := 'TABLE: Data table';
$023E: Result := 'WINDOW2: Sheet window information'; $023E: Result := 'WINDOW2: Sheet window information';
$0243: Result := 'XF: Extended format'; $0243: Result := 'XF: Extended format';
$027E: Result := 'RK'; $027E: Result := 'RK: Cell value, RK number';
$0293: Result := 'STYLE: Style information'; $0293: Result := 'STYLE: Style information';
$0406: Result := 'FORMULA: Cell formula'; $0406: Result := 'FORMULA: Cell formula';
$0409: Result := 'BOF'; $0409: Result := 'BOF';