You've already forked lazarus-ccr
fpspreadsheetgrid: Fix "Window has no parent" error if worksheetgrid is inside a TFrame (again...). Fix overflow when loading worksheetgrid from lfm if IDE is compiled with range checking on.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5868 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -4053,19 +4053,17 @@ begin
|
|||||||
begin
|
begin
|
||||||
w := CalcWorksheetColWidth(ColWidths[AIndex]); // w and wdef are at 100% zoom
|
w := CalcWorksheetColWidth(ColWidths[AIndex]); // w and wdef are at 100% zoom
|
||||||
wdef := Worksheet.ReadDefaultColWidth(Workbook.Units);
|
wdef := Worksheet.ReadDefaultColWidth(Workbook.Units);
|
||||||
if not SameValue(w, wdef, EPS) then begin
|
if (AIndex >= FHeaderCount) and not SameValue(w, wdef, EPS) then begin
|
||||||
idx := GetWorksheetCol(AIndex);
|
idx := GetWorksheetCol(AIndex);
|
||||||
if idx >= 0 then
|
Worksheet.WriteColWidth(GetWorksheetCol(AIndex), w, Workbook.Units);
|
||||||
Worksheet.WriteColWidth(GetWorksheetCol(AIndex), w, Workbook.Units);
|
|
||||||
end;
|
end;
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
h := CalcWorksheetRowHeight(RowHeights[AIndex]);
|
h := CalcWorksheetRowHeight(RowHeights[AIndex]);
|
||||||
hdef := Worksheet.ReadDefaultRowHeight(Workbook.Units);
|
hdef := Worksheet.ReadDefaultRowHeight(Workbook.Units);
|
||||||
if not SameValue(h, hdef, EPS) then begin
|
if (AIndex >= FHeaderCount) and not SameValue(h, hdef, EPS) then begin
|
||||||
idx := GetWorksheetRow(AIndex);
|
idx := GetWorksheetRow(AIndex);
|
||||||
if idx >= 0 then
|
Worksheet.WriteRowHeight(GetWorksheetRow(AIndex), h, Workbook.Units);
|
||||||
Worksheet.WriteRowHeight(GetWorksheetRow(AIndex), h, Workbook.Units);
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -5091,15 +5089,16 @@ end;
|
|||||||
initial column widths and row heights.
|
initial column widths and row heights.
|
||||||
-------------------------------------------------------------------------------}
|
-------------------------------------------------------------------------------}
|
||||||
procedure TsCustomWorksheetGrid.Setup;
|
procedure TsCustomWorksheetGrid.Setup;
|
||||||
|
var
|
||||||
|
maxColCount, maxRowCount: Integer;
|
||||||
begin
|
begin
|
||||||
{
|
|
||||||
if csLoading in ComponentState then
|
if csLoading in ComponentState then
|
||||||
exit;
|
exit;
|
||||||
}
|
|
||||||
if FLockSetup > 0 then
|
if FLockSetup > 0 then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
if not HandleAllocated then
|
if not HandleAllocated then //or (not Parent.HandleAllocated) then
|
||||||
//Avoid crash when accessing the canvas, e.g. in GetDefaultHeaderColWidth
|
//Avoid crash when accessing the canvas, e.g. in GetDefaultHeaderColWidth
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
@ -5114,6 +5113,11 @@ begin
|
|||||||
FTopLeft := CalcTopLeft(false);
|
FTopLeft := CalcTopLeft(false);
|
||||||
end else
|
end else
|
||||||
if Worksheet <> nil then begin
|
if Worksheet <> nil then begin
|
||||||
|
maxColCount := IfThen(aeDefault in FAutoExpand, DEFAULT_COL_COUNT, 1);
|
||||||
|
maxRowCount := IfThen(aeDefault in FAutoExpand, DEFAULT_ROW_COUNT, 1);
|
||||||
|
ColCount := Max(GetGridCol(Worksheet.GetLastColIndex) + 1, maxColCount);
|
||||||
|
RowCount := Max(GetGridRow(Worksheet.GetLastRowIndex) + 1, maxRowCount);
|
||||||
|
(*
|
||||||
if aeDefault in FAutoExpand then begin
|
if aeDefault in FAutoExpand then begin
|
||||||
ColCount := Max(GetGridCol(Worksheet.GetLastColIndex)+1, DEFAULT_COL_COUNT); // + FHeaderCount;
|
ColCount := Max(GetGridCol(Worksheet.GetLastColIndex)+1, DEFAULT_COL_COUNT); // + FHeaderCount;
|
||||||
RowCount := Max(GetGridRow(Worksheet.GetLastRowIndex)+1, DEFAULT_ROW_COUNT); // + FHeaderCount;
|
RowCount := Max(GetGridRow(Worksheet.GetLastRowIndex)+1, DEFAULT_ROW_COUNT); // + FHeaderCount;
|
||||||
@ -5128,6 +5132,7 @@ begin
|
|||||||
ColCount := Max(GetGridCol(WorkSheet.GetLastColIndex)+1, 1); // + FHeaderCount;
|
ColCount := Max(GetGridCol(WorkSheet.GetLastColIndex)+1, 1); // + FHeaderCount;
|
||||||
RowCount := Max(GetGridCol(Worksheet.GetLastRowIndex)+1, 1); // + FHeaderCount;
|
RowCount := Max(GetGridCol(Worksheet.GetLastRowIndex)+1, 1); // + FHeaderCount;
|
||||||
end;
|
end;
|
||||||
|
*)
|
||||||
FixedCols := FFrozenCols + FHeaderCount;
|
FixedCols := FFrozenCols + FHeaderCount;
|
||||||
FixedRows := FFrozenRows + FHeaderCount;
|
FixedRows := FFrozenRows + FHeaderCount;
|
||||||
if ShowHeaders then begin
|
if ShowHeaders then begin
|
||||||
@ -6375,11 +6380,12 @@ procedure TsCustomWorksheetGrid.SetDefColWidth(AValue: Integer);
|
|||||||
begin
|
begin
|
||||||
if (AValue = GetDefColWidth) or (AValue < 0) then
|
if (AValue = GetDefColWidth) or (AValue < 0) then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
{ AValue contains the zoom factor.
|
{ AValue contains the zoom factor.
|
||||||
FDefColWidth1000 is the col width at zoom factor 1.0 }
|
FDefColWidth1000 is the col width at zoom factor 1.0 }
|
||||||
FDefColWidth100 := round(AValue / ZoomFactor);
|
FDefColWidth100 := round(AValue / ZoomFactor);
|
||||||
inherited DefaultColWidth := AValue;
|
inherited DefaultColWidth := AValue;
|
||||||
if FHeaderCount > 0 then begin
|
if (FHeaderCount > 0) and HandleAllocated then begin
|
||||||
PrepareCanvasFont;
|
PrepareCanvasFont;
|
||||||
ColWidths[0] := GetDefaultHeaderColWidth;
|
ColWidths[0] := GetDefaultHeaderColWidth;
|
||||||
end;
|
end;
|
||||||
|
Reference in New Issue
Block a user