fpspreadsheet: Temporarily activate all WorksheetGrid's AutoExpand modes during file loading (see forum http://forum.lazarus.freepascal.org/index.php/topic,34276.msg224096/topicseen.html#new).

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5241 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2016-10-03 17:59:08 +00:00
parent 9eb50b81d3
commit abe0de42e1
2 changed files with 29 additions and 10 deletions

View File

@ -100,12 +100,6 @@ procedure TMainForm.FormCreate(Sender: TObject);
var var
priorityFormats: Array[0..7] of TsSpreadFormatID; priorityFormats: Array[0..7] of TsSpreadFormatID;
begin begin
{
Grid.RowCount:=2;
Grid.ColCount:=2;
Grid.AutoExpand:= [];
}
priorityFormats[0] := ord(sfOOXML); priorityFormats[0] := ord(sfOOXML);
priorityFormats[1] := ord(sfExcel8); priorityFormats[1] := ord(sfExcel8);
priorityFormats[2] := ord(sfExcel5); priorityFormats[2] := ord(sfExcel5);

View File

@ -238,6 +238,8 @@ type
procedure MoveSelection; override; procedure MoveSelection; override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override; procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure PrepareCanvasFont; procedure PrepareCanvasFont;
function RelaxAutoExpand: TsAutoExpandModes;
procedure RestoreAutoExpand(AValue: TsAutoExpandModes);
procedure SelPenChangeHandler(Sender: TObject); procedure SelPenChangeHandler(Sender: TObject);
procedure SetEditText(ACol, ARow: Longint; const AValue: string); override; procedure SetEditText(ACol, ARow: Longint; const AValue: string); override;
procedure Setup; procedure Setup;
@ -3945,9 +3947,12 @@ end;
-------------------------------------------------------------------------------} -------------------------------------------------------------------------------}
procedure TsCustomWorksheetGrid.LoadFromSpreadsheetFile(AFileName: string; procedure TsCustomWorksheetGrid.LoadFromSpreadsheetFile(AFileName: string;
AFormat: TsSpreadsheetFormat; AWorksheetIndex: Integer); AFormat: TsSpreadsheetFormat; AWorksheetIndex: Integer);
var
ae: TsAutoExpandModes;
begin begin
// ZoomFactor := 1.0; ae := RelaxAutoExpand;
GetWorkbookSource.LoadFromSpreadsheetFile(AFileName, AFormat, AWorksheetIndex); GetWorkbookSource.LoadFromSpreadsheetFile(AFileName, AFormat, AWorksheetIndex);
RestoreAutoExpand(ae);
end; end;
{@@ ---------------------------------------------------------------------------- {@@ ----------------------------------------------------------------------------
@ -3964,9 +3969,12 @@ end;
-------------------------------------------------------------------------------} -------------------------------------------------------------------------------}
procedure TsCustomWorksheetGrid.LoadFromSpreadsheetFile(AFileName: string; procedure TsCustomWorksheetGrid.LoadFromSpreadsheetFile(AFileName: string;
AFormatID: TsSpreadFormatID = sfidUnknown; AWorksheetIndex: Integer = -1); AFormatID: TsSpreadFormatID = sfidUnknown; AWorksheetIndex: Integer = -1);
var
ae: TsAutoExpandModes;
begin begin
// ZoomFactor := 1.0; ae := RelaxAutoExpand;
GetWorkbookSource.LoadFromSpreadsheetFile(AFileName, AFormatID, AWorksheetIndex); GetWorkbookSource.LoadFromSpreadsheetFile(AFileName, AFormatID, AWorksheetIndex);
RestoreAutoExpand(ae);
end; end;
{@@ ---------------------------------------------------------------------------- {@@ ----------------------------------------------------------------------------
@ -3981,9 +3989,12 @@ end;
-------------------------------------------------------------------------------} -------------------------------------------------------------------------------}
procedure TsCustomWorksheetGrid.LoadSheetFromSpreadsheetFile(AFileName: String; procedure TsCustomWorksheetGrid.LoadSheetFromSpreadsheetFile(AFileName: String;
AWorksheetIndex: Integer = -1; AFormatID: TsSpreadFormatID = sfidUnknown); AWorksheetIndex: Integer = -1; AFormatID: TsSpreadFormatID = sfidUnknown);
var
ae: TsAutoExpandModes;
begin begin
// ZoomFactor := 1.0; ae := RelaxAutoExpand;
GetWorkbookSource.LoadFromSpreadsheetFile(AFilename, AFormatID, AWorksheetIndex); GetWorkbookSource.LoadFromSpreadsheetFile(AFilename, AFormatID, AWorksheetIndex);
RestoreAutoExpand(ae);
end; end;
{@@ ---------------------------------------------------------------------------- {@@ ----------------------------------------------------------------------------
@ -3998,9 +4009,12 @@ end;
-------------------------------------------------------------------------------} -------------------------------------------------------------------------------}
procedure TsCustomWorksheetGrid.LoadFromWorkbook(AWorkbook: TsWorkbook; procedure TsCustomWorksheetGrid.LoadFromWorkbook(AWorkbook: TsWorkbook;
AWorksheetIndex: Integer = -1); AWorksheetIndex: Integer = -1);
var
ae: TsAutoExpandModes;
begin begin
// ZoomFactor := 1.0; ae := RelaxAutoExpand;
GetWorkbookSource.LoadFromWorkbook(AWorkbook, AWorksheetIndex); GetWorkbookSource.LoadFromWorkbook(AWorkbook, AWorksheetIndex);
RestoreAutoExpand(ae);
Invalidate; Invalidate;
end; end;
@ -4297,6 +4311,17 @@ begin
Canvas.Font.Height := Round(ZoomFactor * Canvas.Font.Height); Canvas.Font.Height := Round(ZoomFactor * Canvas.Font.Height);
end; end;
function TsCustomWorksheetGrid.RelaxAutoExpand: TsAutoExpandModes;
begin
Result := FAutoExpand;
FAutoExpand := [aeData, aeNavigation];
end;
procedure TsCustomWorksheetGrid.RestoreAutoExpand(AValue: TsAutoExpandModes);
begin
FAutoExpand := AValue;
end;
{@@ ---------------------------------------------------------------------------- {@@ ----------------------------------------------------------------------------
Removes the link of the WorksheetGrid to the WorkbookSource. Removes the link of the WorksheetGrid to the WorkbookSource.
Required before destruction. Required before destruction.