From f1fcd9f1f8abe81d0ef59a064cf0d4347eeb4585 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Sun, 20 Apr 2014 15:10:41 +0000 Subject: [PATCH] fpspreadsheet: Add reading support of row heights for biff2 and biff5 git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2953 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/fpspreadsheet/xlsbiff2.pas | 25 +++++++++++++++++++++++++ components/fpspreadsheet/xlsbiff5.pas | 2 ++ 2 files changed, 27 insertions(+) diff --git a/components/fpspreadsheet/xlsbiff2.pas b/components/fpspreadsheet/xlsbiff2.pas index f9547571b..a2fb680b2 100755 --- a/components/fpspreadsheet/xlsbiff2.pas +++ b/components/fpspreadsheet/xlsbiff2.pas @@ -45,6 +45,7 @@ type WorkBookEncoding: TsEncoding; RecordSize: Word; FWorksheet: TsWorksheet; + procedure ReadRowInfo(AStream: TStream); public { General reading methods } procedure ReadFromStream(AStream: TStream; AData: TsWorkbook); override; @@ -80,6 +81,7 @@ const INT_EXCEL_ID_NUMBER = $0003; INT_EXCEL_ID_LABEL = $0004; INT_EXCEL_ID_FORMULA = $0006; + INT_EXCEL_ID_ROWINFO = $0008; INT_EXCEL_ID_BOF = $0009; INT_EXCEL_ID_EOF = $000A; @@ -461,6 +463,7 @@ begin INT_EXCEL_ID_NUMBER: ReadNumber(AStream); INT_EXCEL_ID_LABEL: ReadLabel(AStream); INT_EXCEL_ID_FORMULA: ReadFormula(AStream); + INT_EXCEL_ID_ROWINFO: ReadRowInfo(AStream); INT_EXCEL_ID_BOF: ; INT_EXCEL_ID_EOF: BIFF2EOF := True; @@ -558,6 +561,28 @@ begin FWorksheet.WriteNumber(ARow, ACol, AWord); end; +procedure TsSpreadBIFF2Reader.ReadRowInfo(AStream: TStream); +type + TRowRecord = packed record + RowIndex: Word; + Col1: Word; + Col2: Word; + Height: Word; + end; +var + rowrec: TRowRecord; + lRow: PRow; + h: word; +begin + AStream.ReadBuffer(rowrec, SizeOf(TRowRecord)); + h := WordLEToN(rowrec.Height); + if h and $8000 = 0 then begin // if this bit were set, rowheight would be default + lRow := FWorksheet.GetRow(WordLEToN(rowrec.RowIndex)); + // Row height is encoded into the 15 remaining bits in units "twips" (1/20 pt) + lRow^.Height := TwipsToMillimeters(h and $7FFF); + end; +end; + {******************************************************************* * Initialization section * diff --git a/components/fpspreadsheet/xlsbiff5.pas b/components/fpspreadsheet/xlsbiff5.pas index be98d31d4..9b6986c16 100755 --- a/components/fpspreadsheet/xlsbiff5.pas +++ b/components/fpspreadsheet/xlsbiff5.pas @@ -144,6 +144,7 @@ const INT_EXCEL_ID_INDEX = $020B; INT_EXCEL_ID_LABEL = $0204; INT_EXCEL_ID_NUMBER = $0203; + INT_EXCEL_ID_ROWINFO = $0208; INT_EXCEL_ID_STYLE = $0293; INT_EXCEL_ID_WINDOW1 = $003D; INT_EXCEL_ID_WINDOW2 = $023E; @@ -1130,6 +1131,7 @@ begin INT_EXCEL_ID_RSTRING: ReadRichString(AStream); //(RSTRING) This record stores a formatted text cell (Rich-Text). In BIFF8 it is usually replaced by the LABELSST record. Excel still uses this record, if it copies formatted text cells to the clipboard. INT_EXCEL_ID_RK: ReadRKValue(AStream); //(RK) This record represents a cell that contains an RK value (encoded integer or floating-point value). If a floating-point value cannot be encoded to an RK value, a NUMBER record will be written. This record replaces the record INTEGER written in BIFF2. INT_EXCEL_ID_MULRK: ReadMulRKValues(AStream); + INT_EXCEL_ID_ROWINFO: ReadRowInfo(AStream); INT_EXCEL_ID_FORMULA: ReadFormulaExcel(AStream); INT_EXCEL_ID_BOF: ; INT_EXCEL_ID_EOF: SectionEOF := True;