fpspreadsheet: Working solution for avoiding storing TsWorksheetGrid's colwidths and rowheights in lfm file, requires Laz trunk.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3880 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2015-01-11 15:52:30 +00:00
parent 988c2a3d7a
commit c65e2b60d5
5 changed files with 301 additions and 179 deletions

View File

@ -57,7 +57,7 @@ object Form1: TForm1
Left = 6 Left = 6
Height = 582 Height = 582
Top = 46 Top = 46
Width = 380 Width = 388
TabIndex = 0 TabIndex = 0
Tabs.Strings = ( Tabs.Strings = (
'Sheet1' 'Sheet1'
@ -70,7 +70,7 @@ object Form1: TForm1
Left = 2 Left = 2
Height = 557 Height = 557
Top = 23 Top = 23
Width = 376 Width = 384
FrozenCols = 0 FrozenCols = 0
FrozenRows = 0 FrozenRows = 0
ReadFormulas = False ReadFormulas = False
@ -88,53 +88,24 @@ object Form1: TForm1
TitleFont.Color = clBlack TitleFont.Color = clBlack
TitleFont.Height = -15 TitleFont.Height = -15
TitleFont.Name = 'Calibri' TitleFont.Name = 'Calibri'
ColWidths = (
48
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
)
end end
end end
object Panel2: TPanel object Panel2: TPanel
Left = 392 Left = 400
Height = 594 Height = 594
Top = 40 Top = 40
Width = 478 Width = 470
Align = alRight Align = alRight
BevelOuter = bvNone BevelOuter = bvNone
Caption = 'Panel2' Caption = 'Panel2'
ClientHeight = 594 ClientHeight = 594
ClientWidth = 478 ClientWidth = 470
TabOrder = 3 TabOrder = 3
object Chart1: TChart object Chart1: TChart
Left = 0 Left = 0
Height = 183 Height = 183
Top = 0 Top = 0
Width = 478 Width = 470
AxisList = < AxisList = <
item item
Minors = <> Minors = <>
@ -166,7 +137,7 @@ object Form1: TForm1
Left = 0 Left = 0
Height = 218 Height = 218
Top = 183 Top = 183
Width = 478 Width = 470
AxisList = < AxisList = <
item item
Minors = <> Minors = <>
@ -204,7 +175,7 @@ object Form1: TForm1
Left = 0 Left = 0
Height = 193 Height = 193
Top = 401 Top = 401
Width = 478 Width = 470
AxisList = < AxisList = <
item item
Visible = False Visible = False

View File

@ -13,7 +13,7 @@ object Form1: TForm1
Left = 0 Left = 0
Height = 497 Height = 497
Top = 83 Top = 83
Width = 688 Width = 683
TabIndex = 0 TabIndex = 0
Tabs.Strings = ( Tabs.Strings = (
'Sheet1' 'Sheet1'
@ -25,7 +25,7 @@ object Form1: TForm1
Left = 2 Left = 2
Height = 472 Height = 472
Top = 23 Top = 23
Width = 684 Width = 679
FrozenCols = 0 FrozenCols = 0
FrozenRows = 0 FrozenRows = 0
ReadFormulas = False ReadFormulas = False
@ -45,42 +45,13 @@ object Form1: TForm1
TitleFont.Height = -13 TitleFont.Height = -13
TitleFont.Name = 'Arial' TitleFont.Name = 'Arial'
TitleStyle = tsNative TitleStyle = tsNative
ColWidths = (
50
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
)
end end
end end
object InspectorTabControl: TTabControl object InspectorTabControl: TTabControl
Left = 693 Left = 688
Height = 497 Height = 497
Top = 83 Top = 83
Width = 248 Width = 253
OnChange = InspectorTabControlChange OnChange = InspectorTabControlChange
TabIndex = 0 TabIndex = 0
Tabs.Strings = ( Tabs.Strings = (
@ -96,7 +67,7 @@ object Form1: TForm1
Left = 2 Left = 2
Height = 472 Height = 472
Top = 23 Top = 23
Width = 244 Width = 249
Align = alClient Align = alClient
RowCount = 25 RowCount = 25
TabOrder = 1 TabOrder = 1
@ -133,14 +104,37 @@ object Form1: TForm1
) )
WorkbookSource = WorkbookSource WorkbookSource = WorkbookSource
Mode = imWorkbook Mode = imWorkbook
ColWidths = ( RowHeights = (
111 22
112 22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
) )
end end
end end
object Splitter1: TSplitter object Splitter1: TSplitter
Left = 688 Left = 683
Height = 497 Height = 497
Top = 83 Top = 83
Width = 5 Width = 5

View File

@ -2,21 +2,21 @@ object Form1: TForm1
Left = 409 Left = 409
Height = 649 Height = 649
Top = 248 Top = 248
Width = 884 Width = 895
Caption = 'fpsGrid' Caption = 'fpsGrid'
ClientHeight = 649 ClientHeight = 649
ClientWidth = 884 ClientWidth = 895
ShowHint = True ShowHint = True
LCLVersion = '1.3' LCLVersion = '1.3'
object Panel1: TPanel object Panel1: TPanel
Left = 0 Left = 0
Height = 41 Height = 41
Top = 608 Top = 608
Width = 884 Width = 895
Align = alBottom Align = alBottom
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 41 ClientHeight = 41
ClientWidth = 884 ClientWidth = 895
TabOrder = 0 TabOrder = 0
object BtnOpen: TButton object BtnOpen: TButton
Left = 96 Left = 96
@ -50,7 +50,7 @@ object Form1: TForm1
Left = 0 Left = 0
Height = 572 Height = 572
Top = 36 Top = 36
Width = 884 Width = 895
FrozenCols = 0 FrozenCols = 0
FrozenRows = 0 FrozenRows = 0
ReadFormulas = False ReadFormulas = False
@ -62,45 +62,119 @@ object Form1: TForm1
RowCount = 101 RowCount = 101
TabOrder = 1 TabOrder = 1
TitleStyle = tsNative TitleStyle = tsNative
ColWidths = ( RowHeights = (
42 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
) )
end end
object Panel2: TPanel object Panel2: TPanel
Left = 0 Left = 0
Height = 36 Height = 36
Top = 0 Top = 0
Width = 884 Width = 895
Align = alTop Align = alTop
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 36 ClientHeight = 36
ClientWidth = 884 ClientWidth = 895
TabOrder = 2 TabOrder = 2
object Label1: TLabel object Label1: TLabel
Left = 8 Left = 8
@ -114,7 +188,7 @@ object Form1: TForm1
Left = 72 Left = 72
Height = 23 Height = 23
Top = 4 Top = 4
Width = 808 Width = 819
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
ItemHeight = 15 ItemHeight = 15
ItemIndex = 0 ItemIndex = 0

View File

@ -412,7 +412,7 @@ object MainFrm: TMainFrm
end end
end end
object InspectorSplitter: TSplitter object InspectorSplitter: TSplitter
Left = 648 Left = 638
Height = 453 Height = 453
Top = 84 Top = 84
Width = 5 Width = 5
@ -420,10 +420,10 @@ object MainFrm: TMainFrm
ResizeAnchor = akRight ResizeAnchor = akRight
end end
object InspectorPageControl: TPageControl object InspectorPageControl: TPageControl
Left = 653 Left = 643
Height = 453 Height = 453
Top = 84 Top = 84
Width = 231 Width = 241
ActivePage = PgCellValue ActivePage = PgCellValue
Align = alRight Align = alRight
TabIndex = 0 TabIndex = 0
@ -432,12 +432,12 @@ object MainFrm: TMainFrm
object PgCellValue: TTabSheet object PgCellValue: TTabSheet
Caption = 'Cell value' Caption = 'Cell value'
ClientHeight = 425 ClientHeight = 425
ClientWidth = 223 ClientWidth = 233
object CellInspector: TValueListEditor object CellInspector: TValueListEditor
Left = 0 Left = 0
Height = 425 Height = 425
Top = 0 Top = 0
Width = 223 Width = 233
Align = alClient Align = alClient
FixedCols = 0 FixedCols = 0
RowCount = 15 RowCount = 15
@ -464,9 +464,22 @@ object MainFrm: TMainFrm
'' ''
'' ''
) )
ColWidths = ( RowHeights = (
109 22
110 22
22
22
22
22
22
22
22
22
22
22
22
22
22
) )
end end
end end
@ -481,7 +494,7 @@ object MainFrm: TMainFrm
Left = 0 Left = 0
Height = 453 Height = 453
Top = 84 Top = 84
Width = 648 Width = 638
OnChange = TabControlChange OnChange = TabControlChange
Align = alClient Align = alClient
TabOrder = 3 TabOrder = 3
@ -489,7 +502,7 @@ object MainFrm: TMainFrm
Left = 2 Left = 2
Height = 448 Height = 448
Top = 3 Top = 3
Width = 644 Width = 634
FrozenCols = 0 FrozenCols = 0
FrozenRows = 0 FrozenRows = 0
ReadFormulas = False ReadFormulas = False
@ -504,34 +517,108 @@ object MainFrm: TMainFrm
TitleStyle = tsNative TitleStyle = tsNative
OnHeaderClick = WorksheetGridHeaderClick OnHeaderClick = WorksheetGridHeaderClick
OnSelection = WorksheetGridSelection OnSelection = WorksheetGridSelection
ColWidths = ( RowHeights = (
42 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
64 22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
) )
end end
end end

View File

@ -30,6 +30,13 @@ uses
LCLVersion, LCLVersion,
fpspreadsheet, fpspreadsheetctrls; fpspreadsheet, fpspreadsheetctrls;
const
{$IF (lcl_fullversion >= 1030000)}
ENABLE_MULTI_SELECT = 1; // requires Laz trunk after r46767
{$ELSE}
ENABLE_MULTI_SELECT = 0;
{$ENDIF}
type type
{ TsCustomWorksheetGrid } { TsCustomWorksheetGrid }
@ -155,16 +162,16 @@ type
AJustification: Byte; ACellHorAlign: TsHorAlignment; AJustification: Byte; ACellHorAlign: TsHorAlignment;
ACellVertAlign: TsVertAlignment; ATextRot: TsTextRotation; ACellVertAlign: TsVertAlignment; ATextRot: TsTextRotation;
ATextWrap, ReplaceTooLong: Boolean); ATextWrap, ReplaceTooLong: Boolean);
{$IFDEF DO_NOT_STORE_COLWIDTHS_ROWHEIGHTS_IN_LFM}
function IsColWidthsStored: Boolean; override;
function IsRowHeightsStored: Boolean; override;
{$ENDIF}
procedure KeyDown(var Key : Word; Shift : TShiftState); override; procedure KeyDown(var Key : Word; Shift : TShiftState); override;
procedure Loaded; override; procedure Loaded; override;
procedure LoadFromWorksheet(AWorksheet: TsWorksheet); procedure LoadFromWorksheet(AWorksheet: TsWorksheet);
procedure MouseDown(Button: TMouseButton; Shift:TShiftState; X,Y:Integer); override; procedure MouseDown(Button: TMouseButton; Shift:TShiftState; X,Y:Integer); override;
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override; procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
procedure MoveSelection; override; procedure MoveSelection; override;
{$IFDEF DO_NOT_STORE_COLWIDTHS_ROWHEIGHTS_IN_LFM}
procedure NeedRowHeightsOrColWidths(Filer: TFiler;
out NeedHeights, NeedWidths: Boolean); override;
{$ENDIF}
procedure Notification(AComponent: TComponent; Operation: TOperation); override; procedure Notification(AComponent: TComponent; Operation: TOperation); override;
// function SelectCell(AGridCol, AGridRow: Integer): Boolean; override; // function SelectCell(AGridCol, AGridRow: Integer): Boolean; override;
procedure SelectEditor; override; procedure SelectEditor; override;
@ -337,7 +344,7 @@ type
read GetWordwraps write SetWordwraps; read GetWordwraps write SetWordwraps;
// inherited // inherited
{$IFDEF ENABLE_MULTI_SELECT} {$IF (ENABLE_MULTI_SELECT = 1)}
{@@ Allow multiple selections} {@@ Allow multiple selections}
property RangeSelectMode default rsmMulti; property RangeSelectMode default rsmMulti;
{$ENDIF} {$ENDIF}
@ -582,11 +589,6 @@ const
tlBottom, tlTop, tlCenter, tlBottom tlBottom, tlTop, tlCenter, tlBottom
); );
{$IF (lcl_fullversion >= 1030000)}
ENABLE_MULTI_SELECT = 1; // requires Laz trunk after r46767
{$ELSE}
ENABLE_MULTI_SELECT = 0;
{$ENDIF}
var var
{@@ Auxiliary bitmap containing the fill pattern used by biff2 cell backgrounds. } {@@ Auxiliary bitmap containing the fill pattern used by biff2 cell backgrounds. }
@ -2882,26 +2884,6 @@ begin
end; end;
end; end;
{$IFDEF DO_NOT_STORE_COLWIDTHS_ROWHEIGHTS_IN_LFM}
{@@ ----------------------------------------------------------------------------
Prevents storing of column widths in lfm file, they are retrieved from the
worksheet file
-------------------------------------------------------------------------------}
function TsCustomWorksheetGrid.IsColWidthsStored: Boolean;
begin
Result := false;
end;
{@@ ----------------------------------------------------------------------------
Prevents storing of row heights in lfm file, they are retrieved from the
worksheet file
-------------------------------------------------------------------------------}
function TsCustomWorksheetGrid.IsRowHeightsStored: Boolean;
begin
Result := false;
end;
{$ENDIF}
{@@ ---------------------------------------------------------------------------- {@@ ----------------------------------------------------------------------------
Standard key handling method inherited from TCustomGrid. Is overridden to Standard key handling method inherited from TCustomGrid. Is overridden to
catch the ESC key during editing in order to restore the old cell text catch the ESC key during editing in order to restore the old cell text
@ -3173,6 +3155,20 @@ begin
Refresh; Refresh;
end; end;
{$IFDEF DO_NOT_STORE_COLWIDTHS_ROWHEIGHTS_IN_LFM}
{@@ ----------------------------------------------------------------------------
Inherited method of TCustomGrid called during the streaming of the lfm file.
Since RowHeights and ColWidths are taken from the WorkSheet there is no need
to store them in the lfm file again.
-------------------------------------------------------------------------------}
procedure TsCustomWorksheetGrid.NeedRowHeightsOrColWidths(Filer: TFiler;
out NeedHeights, NeedWidths: Boolean);
begin
NeedHeights := false;
NeedWidths := false;
end;
{$ENDIF}
{@@ ---------------------------------------------------------------------------- {@@ ----------------------------------------------------------------------------
Creates a new empty workbook with the specified number of columns and rows. Creates a new empty workbook with the specified number of columns and rows.