From 22a7e50170bb1bcb25fd59fd75062a65de607436 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Sat, 24 Jan 2015 22:52:22 +0000 Subject: [PATCH] fpspreadsheet: Put numerical data of the TCell record into a variant record --> further reduction of memory consumption per cell (now by 70% of original TCell). git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3898 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../examples/fpsspeedtest/mainform.lfm | 9 +++++--- components/fpspreadsheet/fpspreadsheet.pas | 23 +++++++++++++++---- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/components/fpspreadsheet/examples/fpsspeedtest/mainform.lfm b/components/fpspreadsheet/examples/fpsspeedtest/mainform.lfm index 73125ed9f..f57bda52c 100644 --- a/components/fpspreadsheet/examples/fpsspeedtest/mainform.lfm +++ b/components/fpspreadsheet/examples/fpsspeedtest/mainform.lfm @@ -38,11 +38,14 @@ object Form1: TForm1 TabOrder = 0 end object LblCancel: TLabel - Left = 208 - Height = 30 + Left = 184 + Height = 39 Top = 6 - Width = 309 + Width = 576 + Anchors = [akTop, akLeft, akRight] + AutoSize = False Caption = 'Press ESC to cancel when current file is completely written.'#13#10'This may take some time...' + Layout = tlCenter ParentColor = False Visible = False end diff --git a/components/fpspreadsheet/fpspreadsheet.pas b/components/fpspreadsheet/fpspreadsheet.pas index 7a16d9d52..8d54997fb 100755 --- a/components/fpspreadsheet/fpspreadsheet.pas +++ b/components/fpspreadsheet/fpspreadsheet.pas @@ -37,8 +37,8 @@ type {@@ Cell structure for TsWorksheet The cell record contains information on the location of the cell (row and - column index), on the value contained (number, date, text, ...), and on - formatting. + column index), on the value contained (number, date, text, ...), on + formatting, etc. Never suppose that all *Value fields are valid, only one of the ContentTypes is valid. For other fields @@ -46,9 +46,11 @@ type @see ReadAsUTF8Text } TCell = record + { Location of the cell } Worksheet: TsWorksheet; Col: Cardinal; // zero-based Row: Cardinal; // zero-based + (* ContentType: TCellContentType; { Possible values for the cells } FormulaValue: string; @@ -57,12 +59,25 @@ type DateTimeValue: TDateTime; BoolValue: Boolean; ErrorValue: TsErrorValue; - SharedFormulaBase: PCell; // Cell containing the shared formula - MergeBase: PCell; // Upper left cell if a merged range + *) { Index of format record } FormatIndex: Integer; { Status flags } CalcState: TsCalcState; + { Special information } + SharedFormulaBase: PCell; // Cell containing the shared formula + MergeBase: PCell; // Upper left cell of a merged range + { Cell content } + UTF8StringValue: String; // strings cannot be part of a variant record + FormulaValue: String; + case ContentType: TCellContentType of // must be at the end of the declaration + cctEmpty : (); // has no data at all + cctFormula : (); // UTF8StringValue is outside the variant record + cctNumber : (Numbervalue: Double); + cctUTF8String : (); // FormulaValue is outside the variant record + cctDateTime : (DateTimevalue: TDateTime); + cctBool : (BoolValue: boolean); + cctError : (ErrorValue: TsErrorValue); end; {@@ The record TRow contains information about a spreadsheet row: