You've already forked lazarus-ccr
fpspreadsheet: Fix crash of worksheetGrid if methods using external workbooksource are accessed and only internal source is active.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4273 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -79,6 +79,7 @@ object Form1: TForm1
|
||||
FrozenCols = 0
|
||||
FrozenRows = 0
|
||||
ReadFormulas = False
|
||||
WorkbookSource = WorksheetGrid.internal
|
||||
Align = alClient
|
||||
AutoAdvance = aaDown
|
||||
ColCount = 27
|
||||
|
@ -136,6 +136,7 @@ begin
|
||||
Screen.Cursor := crHourglass;
|
||||
try
|
||||
WorksheetGrid.SaveToSpreadsheetFile(UTF8ToAnsi(SaveDialog.FileName));
|
||||
//WorksheetGrid.WorkbookSource.SaveToSpreadsheetFile(UTF8ToAnsi(SaveDialog.FileName)); // works as well
|
||||
finally
|
||||
Screen.Cursor := crDefault;
|
||||
// Show a message in case of error(s)
|
||||
|
@ -263,7 +263,7 @@ type
|
||||
|
||||
{ public properties }
|
||||
{@@ Link to the workbook }
|
||||
property WorkbookSource: TsWorkbookSource read FWorkbookSource write SetWorkbookSource;
|
||||
property WorkbookSource: TsWorkbookSource read GetWorkbookSource write SetWorkbookSource;
|
||||
{@@ Currently selected worksheet of the workbook }
|
||||
property Worksheet: TsWorksheet read GetWorksheet;
|
||||
{@@ Workbook displayed in the grid }
|
||||
@ -849,6 +849,7 @@ end;
|
||||
constructor TsCustomWorksheetGrid.Create(AOwner: TComponent);
|
||||
begin
|
||||
FInternalWorkbookSource := TsWorkbookSource.Create(self); //AOwner);
|
||||
FInternalWorkbookSource.Name := 'internal';
|
||||
inherited Create(AOwner);
|
||||
AutoAdvance := aaDown;
|
||||
ExtendedSelect := true;
|
||||
@ -873,8 +874,6 @@ begin
|
||||
SetWorkbookSource(nil);
|
||||
if FInternalWorkbookSource <> nil then
|
||||
FInternalWorkbookSource.RemoveListener(self); // will be destroyed automatically
|
||||
// FreeAndNil(FInternalWorkbookSource);
|
||||
// end;
|
||||
FreeAndNil(FCellFont);
|
||||
inherited Destroy;
|
||||
end;
|
||||
@ -4348,6 +4347,13 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TsCustomWorksheetGrid.GetWorkbookSource: TsWorkbookSource;
|
||||
begin
|
||||
if FWorkbookSource <> nil then
|
||||
Result := FWorkbookSource else
|
||||
Result := FInternalWorkbookSource;
|
||||
end;
|
||||
|
||||
function TsCustomWorksheetGrid.GetVertAlignment(ACol, ARow: Integer): TsVertAlignment;
|
||||
var
|
||||
cell: PCell;
|
||||
@ -4381,13 +4387,6 @@ begin
|
||||
Result := GetWorkbookSource.Workbook;
|
||||
end;
|
||||
|
||||
function TsCustomWorksheetGrid.GetWorkbookSource: TsWorkbookSource;
|
||||
begin
|
||||
if FWorkbookSource <> nil then
|
||||
Result := FWorkbookSource else
|
||||
Result := FInternalWorkbookSource;
|
||||
end;
|
||||
|
||||
function TsCustomWorksheetGrid.GetWorksheet: TsWorksheet;
|
||||
begin
|
||||
Result := GetWorkbookSource.Worksheet;
|
||||
|
Reference in New Issue
Block a user