fpspreadsheet: Unless enforced, no row height calculation for rows without row record. Remove useless Disable/EnableControls methods of TsWorkbookSource.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5256 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
c3ee25b99e
commit
f05e437ba3
@ -409,6 +409,7 @@ type
|
||||
function GetLastRowNumber: Cardinal; deprecated 'Use GetLastRowIndex';
|
||||
|
||||
{ Data manipulation methods - For Rows and Cols }
|
||||
function AddRow(ARow: Cardinal): PRow;
|
||||
function CalcAutoRowHeight(ARow: Cardinal): Single;
|
||||
function CalcRowHeight(ARow: Cardinal): Single;
|
||||
function FindRow(ARow: Cardinal): PRow;
|
||||
@ -6399,16 +6400,27 @@ end;
|
||||
function TsWorksheet.GetRow(ARow: Cardinal): PRow;
|
||||
begin
|
||||
Result := FindRow(ARow);
|
||||
if (Result = nil) then begin
|
||||
Result := GetMem(SizeOf(TRow));
|
||||
FillChar(Result^, SizeOf(TRow), #0);
|
||||
Result^.Row := ARow;
|
||||
FRows.Add(Result);
|
||||
if FLastRowIndex = 0 then
|
||||
FLastRowIndex := GetLastRowIndex(true)
|
||||
else
|
||||
FLastRowIndex := Max(FLastRowIndex, ARow);
|
||||
end;
|
||||
if (Result = nil) then
|
||||
Result := AddRow(ARow);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Creates a new row record for the specific row index. It is not checked whether
|
||||
a row record already exists for this index. Dupliate records must be avoided!
|
||||
|
||||
@param ARow Index of the row considered
|
||||
@return Pointer to the row record with this row index.
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsWorksheet.AddRow(ARow: Cardinal): PRow;
|
||||
begin
|
||||
Result := GetMem(SizeOf(TRow));
|
||||
FillChar(Result^, SizeOf(TRow), #0);
|
||||
Result^.Row := ARow;
|
||||
FRows.Add(Result);
|
||||
if FLastRowIndex = 0 then
|
||||
FLastRowIndex := GetLastRowIndex(true)
|
||||
else
|
||||
FLastRowIndex := Max(FLastRowIndex, ARow);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
|
@ -64,7 +64,7 @@ type
|
||||
FUserFileFormatID: TsSpreadFormatID;
|
||||
FPendingSelection: TsCellRangeArray;
|
||||
FPendingOperation: TsCopyOperation;
|
||||
FControlLockCount: Integer;
|
||||
// FControlLockCount: Integer;
|
||||
FOptions: TsWorkbookOptions;
|
||||
FOnError: TsWorkbookSourceErrorEvent;
|
||||
|
||||
@ -128,8 +128,8 @@ type
|
||||
procedure SaveToSpreadsheetFile(AFileName: string; AFormatID: TsSpreadFormatID;
|
||||
AOverwriteExisting: Boolean = true); overload;
|
||||
|
||||
procedure DisableControls;
|
||||
procedure EnableControls;
|
||||
// procedure DisableControls;
|
||||
// procedure EnableControls;
|
||||
|
||||
procedure SelectCell(ASheetRow, ASheetCol: Cardinal);
|
||||
procedure SelectWorksheet(AWorkSheet: TsWorksheet);
|
||||
@ -779,14 +779,14 @@ begin
|
||||
FWorksheet := FWorkbook.AddWorksheet(Format(rsDefaultSheetName,[1]));
|
||||
SelectWorksheet(FWorksheet);
|
||||
end;
|
||||
|
||||
(*
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Disables notification of listening controls
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorkbookSource.DisableControls;
|
||||
begin
|
||||
inc(FControlLockCount);
|
||||
end;
|
||||
end; *)
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
An error has occured during loading of the workbook. Shows a message box by
|
||||
@ -804,14 +804,14 @@ begin
|
||||
else
|
||||
MessageDlg(AErrorMsg, mtError, [mbOK], 0);
|
||||
end;
|
||||
|
||||
(*
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Enables notification of listening controls
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorkbookSource.EnableControls;
|
||||
begin
|
||||
dec(FControlLockCount);
|
||||
end;
|
||||
end; *)
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Executes a "pending operation"
|
||||
@ -969,12 +969,13 @@ begin
|
||||
book.ReadFromFile(AFileName, AFormatID);
|
||||
except
|
||||
book.AddErrorMsg(rsCannotReadFile, [AFileName]);
|
||||
// Code executed subsequently will be a pain if there is no worksheet!
|
||||
// Code executed subsequently will be a pain if there is no worksheet! --> Add one.
|
||||
if book.GetWorksheetCount = 0 then
|
||||
book.AddWorksheet(Format(rsDefaultSheetName, [1]));
|
||||
end;
|
||||
|
||||
InternalLoadFromWorkbook(book, AWorksheetIndex);
|
||||
|
||||
(*
|
||||
|
||||
|
||||
@ -1016,6 +1017,8 @@ end;
|
||||
procedure TsWorkbookSource.InternalLoadFromWorkbook(AWorkbook: TsWorkbook;
|
||||
AWorksheetIndex: Integer = -1);
|
||||
begin
|
||||
AWorkbook.DisableNotifications;
|
||||
|
||||
InternalCreateNewWorkbook(AWorkbook);
|
||||
WorkbookOpenedHandler(self);
|
||||
|
||||
@ -1027,6 +1030,8 @@ begin
|
||||
end;
|
||||
SelectWorksheet(FWorkbook.GetWorksheetByIndex(AWorksheetIndex));
|
||||
|
||||
AWorkbook.EnableNotifications;
|
||||
|
||||
// If required, display loading error message
|
||||
if FWorkbook.ErrorMsg <> '' then
|
||||
DoShowError(FWorkbook.ErrorMsg);
|
||||
|
@ -966,6 +966,9 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
{*******************************************************************************
|
||||
* TsSelPen *
|
||||
*******************************************************************************}
|
||||
constructor TsSelPen.Create;
|
||||
begin
|
||||
inherited;
|
||||
@ -973,6 +976,7 @@ begin
|
||||
JoinStyle := pjsMiter;
|
||||
end;
|
||||
|
||||
|
||||
{*******************************************************************************
|
||||
* TsCustomWorksheetGrid *
|
||||
*******************************************************************************}
|
||||
@ -4475,6 +4479,7 @@ begin
|
||||
//Avoid crash when accessing the canvas, e.g. in GetDefaultHeaderColWidth
|
||||
exit;
|
||||
}
|
||||
|
||||
if (Worksheet = nil) or (Worksheet.GetCellCount = 0) then begin
|
||||
FixedCols := FFrozenCols + FHeaderCount;
|
||||
FixedRows := FFrozenRows + FHeaderCount;
|
||||
@ -4824,13 +4829,15 @@ procedure TsCustomWorksheetGrid.UpdateRowHeight(ARow: Integer;
|
||||
AEnforceCalcRowHeight: Boolean = false);
|
||||
var
|
||||
lRow: PRow;
|
||||
sr: Cardinal;
|
||||
h: Integer; // Row height, in pixels. Contains zoom factor.
|
||||
doCalcRowHeight: Boolean;
|
||||
begin
|
||||
h := 0;
|
||||
if Worksheet <> nil then
|
||||
begin
|
||||
lRow := Worksheet.FindRow(ARow - FHeaderCount);
|
||||
sr := ARow - FHeaderCount; // worksheet row index
|
||||
lRow := Worksheet.FindRow(sr);
|
||||
if (lRow <> nil) then begin
|
||||
case lRow^.RowHeightType of
|
||||
rhtCustom:
|
||||
@ -4856,11 +4863,13 @@ begin
|
||||
end; // case
|
||||
end else
|
||||
// No row record so far.
|
||||
if Worksheet.GetCellCountInRow(ARow - FHeaderCount) > 0 then
|
||||
if Worksheet.GetCellCountInRow(sr) > 0 then
|
||||
begin
|
||||
// Case 1: This row does contain cells
|
||||
lRow := Worksheet.GetRow(ARow - FHeaderCount);
|
||||
h := CalcAutoRowHeight(ARow);
|
||||
lRow := Worksheet.AddRow(sr);
|
||||
if AEnforceCalcRowHeight then
|
||||
h := CalcAutoRowHeight(ARow) else
|
||||
h := DefaultRowHeight;
|
||||
lRow^.Height := CalcRowHeightToSheet(round(h / ZoomFactor));
|
||||
if h <> DefaultRowHeight then
|
||||
lRow^.RowHeightType := rhtAuto
|
||||
@ -5972,8 +5981,12 @@ end;
|
||||
procedure TsCustomWorksheetGrid.SetZoomFactor(AValue: Double);
|
||||
begin
|
||||
if (AValue <> GetZoomFactor) and Assigned(Worksheet) then begin
|
||||
Worksheet.ZoomFactor := abs(AValue);
|
||||
AdaptToZoomFactor;
|
||||
try
|
||||
Worksheet.ZoomFactor := abs(AValue);
|
||||
AdaptToZoomFactor;
|
||||
finally
|
||||
EndUpdate;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user