You've already forked lazarus-ccr
fpspreadsheet: Remove new WorksheetGrid property AutoCalcRowHeights again. Row heights are recalculated only if still at initial value of 0.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5238 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -6452,23 +6452,23 @@ end;
|
|||||||
|
|
||||||
@param ARow Index of the row considered
|
@param ARow Index of the row considered
|
||||||
@param AUnits Units for the row height.
|
@param AUnits Units for the row height.
|
||||||
@return Height of the row
|
@return Height of the row. This is the "raw" value, without application of
|
||||||
Note that the row height value can be negative to indicate that this
|
the zoom factor.
|
||||||
is an auto-calculated value (i.e. the value can change for example
|
|
||||||
when the font size changes).
|
|
||||||
-------------------------------------------------------------------------------}
|
-------------------------------------------------------------------------------}
|
||||||
function TsWorksheet.GetRowHeight(ARow: Cardinal; AUnits: TsSizeUnits): Single;
|
function TsWorksheet.GetRowHeight(ARow: Cardinal; AUnits: TsSizeUnits): Single;
|
||||||
var
|
var
|
||||||
row: PRow;
|
lRow: PRow;
|
||||||
begin
|
begin
|
||||||
if ARow = UNASSIGNED_ROW_COL_INDEX then
|
if ARow = UNASSIGNED_ROW_COL_INDEX then
|
||||||
Result := 0
|
Result := 0
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
row := FindRow(ARow);
|
lRow := FindRow(ARow);
|
||||||
if row <> nil then
|
if lRow <> nil then begin
|
||||||
Result := row^.Height
|
Result := lRow^.Height;
|
||||||
else
|
if lRow.RowHeightType = rhtDefault then
|
||||||
|
Result := FDefaultRowHeight;
|
||||||
|
end else
|
||||||
Result := FDefaultRowHeight;
|
Result := FDefaultRowHeight;
|
||||||
Result := FWorkbook.ConvertUnits(Result, FWorkbook.Units, AUnits);
|
Result := FWorkbook.ConvertUnits(Result, FWorkbook.Units, AUnits);
|
||||||
end;
|
end;
|
||||||
@ -6485,10 +6485,8 @@ end;
|
|||||||
|
|
||||||
@param ARow Index of the row considered
|
@param ARow Index of the row considered
|
||||||
@param AUnits Units for the row height.
|
@param AUnits Units for the row height.
|
||||||
@return Height of the row
|
@return Height of the row. This is the "raw" value, without application of
|
||||||
Note that the row height value can be negative to indicate that this
|
the zoom factor.
|
||||||
is an auto-calculated value (i.e. the value can change for example
|
|
||||||
when the font size changes).
|
|
||||||
-------------------------------------------------------------------------------}
|
-------------------------------------------------------------------------------}
|
||||||
function TsWorksheet.GetRowHeightType(ARow: Cardinal): TsRowHeightType;
|
function TsWorksheet.GetRowHeightType(ARow: Cardinal): TsRowHeightType;
|
||||||
var
|
var
|
||||||
|
@ -72,7 +72,6 @@ type
|
|||||||
FDrawingCell: PCell;
|
FDrawingCell: PCell;
|
||||||
FTextOverflowing: Boolean;
|
FTextOverflowing: Boolean;
|
||||||
FAutoExpand: TsAutoExpandModes;
|
FAutoExpand: TsAutoExpandModes;
|
||||||
FAutoCalcRowHeights: Boolean;
|
|
||||||
FEnhEditMode: Boolean;
|
FEnhEditMode: Boolean;
|
||||||
FSelPen: TsSelPen;
|
FSelPen: TsSelPen;
|
||||||
FHyperlinkTimer: TTimer;
|
FHyperlinkTimer: TTimer;
|
||||||
@ -245,15 +244,11 @@ type
|
|||||||
procedure Sort(AColSorting: Boolean; AIndex, AIndxFrom, AIndxTo:Integer); override;
|
procedure Sort(AColSorting: Boolean; AIndex, AIndxFrom, AIndxTo:Integer); override;
|
||||||
function TrimToCell(ACell: PCell): String;
|
function TrimToCell(ACell: PCell): String;
|
||||||
procedure UpdateColWidths(AStartIndex: Integer = 0);
|
procedure UpdateColWidths(AStartIndex: Integer = 0);
|
||||||
procedure UpdateRowHeight(ARow: Integer; EnforceCalcRowHeight: Boolean = false);
|
procedure UpdateRowHeight(ARow: Integer; AEnforceCalcRowHeight: Boolean = false);
|
||||||
procedure UpdateRowHeights;
|
procedure UpdateRowHeights(AStartRow: Integer = -1);
|
||||||
|
|
||||||
{@@ Automatically recalculate formulas whenever a cell value changes. }
|
{@@ Automatically recalculate formulas whenever a cell value changes. }
|
||||||
property AutoCalc: Boolean read FAutoCalc write SetAutoCalc default false;
|
property AutoCalc: Boolean read FAutoCalc write SetAutoCalc default false;
|
||||||
{@@ Automatically recalculate row heights after loading a file. Gets rid of
|
|
||||||
possibly incorrect row heights stored by the writing application. But:
|
|
||||||
slow in case of large files. }
|
|
||||||
property AutoCalcRowHeights: Boolean read FAutoCalcRowHeights write FAutoCalcRowHeights default false;
|
|
||||||
{@@ Automatically expand grid dimensions }
|
{@@ Automatically expand grid dimensions }
|
||||||
property AutoExpand: TsAutoExpandModes read FAutoExpand write FAutoExpand;
|
property AutoExpand: TsAutoExpandModes read FAutoExpand write FAutoExpand;
|
||||||
{@@ Displays column and row headers in the fixed col/row style of the grid.
|
{@@ Displays column and row headers in the fixed col/row style of the grid.
|
||||||
@ -502,10 +497,6 @@ type
|
|||||||
// inherited from TsCustomWorksheetGrid
|
// inherited from TsCustomWorksheetGrid
|
||||||
{@@ Automatically recalculates the worksheet if a cell value changes. }
|
{@@ Automatically recalculates the worksheet if a cell value changes. }
|
||||||
property AutoCalc;
|
property AutoCalc;
|
||||||
{@@ Automatically recalculate row heights after loading a file. Gets rid of
|
|
||||||
possibly incorrect row heights stored by the writing application. But:
|
|
||||||
slow in case of large files. }
|
|
||||||
property AutoCalcRowHeights;
|
|
||||||
{@@ Automatically expand grid dimensions }
|
{@@ Automatically expand grid dimensions }
|
||||||
property AutoExpand default [aeData, aeNavigation];
|
property AutoExpand default [aeData, aeNavigation];
|
||||||
{@@ Displays column and row headers in the fixed col/row style of the grid.
|
{@@ Displays column and row headers in the fixed col/row style of the grid.
|
||||||
@ -1016,7 +1007,6 @@ begin
|
|||||||
FSelPen.JoinStyle := pjsMiter;
|
FSelPen.JoinStyle := pjsMiter;
|
||||||
FSelPen.OnChange := @SelPenChangeHandler;
|
FSelPen.OnChange := @SelPenChangeHandler;
|
||||||
FAutoExpand := [aeData, aeNavigation];
|
FAutoExpand := [aeData, aeNavigation];
|
||||||
FAutoCalcRowHeights := false;
|
|
||||||
FHyperlinkTimer := TTimer.Create(self);
|
FHyperlinkTimer := TTimer.Create(self);
|
||||||
FHyperlinkTimer.Interval := HYPERLINK_TIMER_INTERVAL;
|
FHyperlinkTimer.Interval := HYPERLINK_TIMER_INTERVAL;
|
||||||
FHyperlinkTimer.OnTimer := @HyperlinkTimerElapsed;
|
FHyperlinkTimer.OnTimer := @HyperlinkTimerElapsed;
|
||||||
@ -1530,8 +1520,8 @@ begin
|
|||||||
|
|
||||||
Worksheet.DeleteRow(GetWorksheetRow(AGridRow));
|
Worksheet.DeleteRow(GetWorksheetRow(AGridRow));
|
||||||
|
|
||||||
// wp: next line probably not required
|
// Update following row heights because their index has changed
|
||||||
//UpdateRowHeights(AGridRow);
|
UpdateRowHeights(AGridRow);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TsCustomWorksheetGrid.CreateHandle;
|
procedure TsCustomWorksheetGrid.CreateHandle;
|
||||||
@ -3624,8 +3614,11 @@ begin
|
|||||||
r := GetWorksheetRow(AGridRow);
|
r := GetWorksheetRow(AGridRow);
|
||||||
Worksheet.InsertRow(r);
|
Worksheet.InsertRow(r);
|
||||||
|
|
||||||
|
// Calculate row height if new row
|
||||||
UpdateRowHeight(AGridRow, true);
|
UpdateRowHeight(AGridRow, true);
|
||||||
// UpdateRowHeights(AGridRow);
|
|
||||||
|
// Update following row heights because their index has changed.
|
||||||
|
UpdateRowHeights(AGridRow);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{@@ ----------------------------------------------------------------------------
|
{@@ ----------------------------------------------------------------------------
|
||||||
@ -4759,18 +4752,19 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{@@ ----------------------------------------------------------------------------
|
{@@ ----------------------------------------------------------------------------
|
||||||
Updates the height if the specified row in the grid by the value stored in the
|
Updates the height if the specified row in the grid with the value stored in
|
||||||
Worksheet and multiplied by the current zoom factor. If the stored rowheight
|
the worksheet multiplied by the current zoom factor. If the stored row height
|
||||||
type is rhtAuto (meaning: "row height is auto-calculated") and row height
|
type is rhtAuto (meaning: "row height is auto-calculated") and the current
|
||||||
calculation is enabled (if internal flag FAutoCalcRowHeight is true, or the
|
row height in the row record is 0 then the row height is calculated by
|
||||||
parameter EnforceCalcRowHeight is true9, then the current row height is
|
iterating over all cells in this row. This happens also if the parameter
|
||||||
calculated by iterating over all cells in the row.
|
AEnforceCalcRowHeight is true.
|
||||||
-------------------------------------------------------------------------------}
|
-------------------------------------------------------------------------------}
|
||||||
procedure TsCustomWorksheetGrid.UpdateRowHeight(ARow: Integer;
|
procedure TsCustomWorksheetGrid.UpdateRowHeight(ARow: Integer;
|
||||||
EnforceCalcRowHeight: Boolean = false);
|
AEnforceCalcRowHeight: Boolean = false);
|
||||||
var
|
var
|
||||||
lRow: PRow;
|
lRow: PRow;
|
||||||
h: Integer; // Row height, in pixels. Contains zoom factor.
|
h: Integer; // Row height, in pixels. Contains zoom factor.
|
||||||
|
doCalcRowHeight: Boolean;
|
||||||
begin
|
begin
|
||||||
h := 0;
|
h := 0;
|
||||||
if Worksheet <> nil then
|
if Worksheet <> nil then
|
||||||
@ -4781,32 +4775,41 @@ begin
|
|||||||
rhtCustom:
|
rhtCustom:
|
||||||
h := round(CalcRowHeightFromSheet(lRow^.Height) * ZoomFactor);
|
h := round(CalcRowHeightFromSheet(lRow^.Height) * ZoomFactor);
|
||||||
rhtAuto, rhtDefault:
|
rhtAuto, rhtDefault:
|
||||||
if FAutoCalcRowHeights or EnforceCalcRowHeight then begin
|
begin
|
||||||
// Calculate current grid row height in pixels by iterating over all cells in row
|
doCalcRowHeight := AEnforceCalcRowHeight or (lRow^.Height = 0);
|
||||||
h := CalcAutoRowHeight(ARow); // ZoomFactor already applied to font heights
|
if doCalcRowHeight then begin
|
||||||
if h = 0 then begin
|
// Calculate current grid row height in pixels by iterating over all cells in row
|
||||||
h := DefaultRowHeight; // Zoom factor applied by getter function
|
h := CalcAutoRowHeight(ARow); // ZoomFactor already applied to font heights
|
||||||
lRow^.RowHeightType := rhtDefault;
|
if h = 0 then begin
|
||||||
|
h := DefaultRowHeight; // Zoom factor applied by getter function
|
||||||
|
lRow^.RowHeightType := rhtDefault;
|
||||||
|
end else
|
||||||
|
lRow^.RowHeightType := rhtAuto;
|
||||||
|
// Calculate the unzoomed row height in workbook units and store
|
||||||
|
// in row record
|
||||||
|
lRow^.Height := CalcRowHeightToSheet(round(h / ZoomFactor));
|
||||||
end else
|
end else
|
||||||
lRow^.RowHeightType := rhtAuto;
|
// If autocalc mode is off we just take the row height from the row record
|
||||||
// Calculate the unzoomed row height in workbook units and store
|
h := round(CalcRowHeightFromSheet(lRow^.Height) * ZoomFactor);
|
||||||
// in row record
|
end;
|
||||||
lRow^.Height := CalcRowHeightToSheet(round(h / ZoomFactor));
|
|
||||||
end else
|
|
||||||
// If autocalc mode is off we just take the row height from the row record
|
|
||||||
h := round(CalcRowHeightFromSheet(lRow^.Height) * ZoomFactor);
|
|
||||||
end; // case
|
end; // case
|
||||||
end else
|
end else
|
||||||
// No row record so far.
|
// No row record so far.
|
||||||
if FAutoCalcRowHeights or EnforceCalcRowHeight then begin
|
if Worksheet.GetCellCountInRow(ARow - FHeaderCount) > 0 then
|
||||||
|
begin
|
||||||
|
// Case 1: This row does contain cells
|
||||||
|
lRow := Worksheet.GetRow(ARow - FHeaderCount);
|
||||||
h := CalcAutoRowHeight(ARow);
|
h := CalcAutoRowHeight(ARow);
|
||||||
if h <> DefaultRowHeight then begin
|
lRow^.Height := CalcRowHeightToSheet(round(h / ZoomFactor));
|
||||||
lRow := Worksheet.GetRow(ARow - FHeaderCount);
|
if h <> DefaultRowHeight then
|
||||||
lRow^.Height := CalcRowHeightToSheet(round(h / ZoomFactor));
|
lRow^.RowHeightType := rhtAuto
|
||||||
lRow^.RowHeightType := rhtAuto;
|
else
|
||||||
end;
|
lRow^.RowHeightType := rhtDefault;
|
||||||
end;
|
end else
|
||||||
|
// Case 2: No cells in row
|
||||||
|
h := DefaultRowHeight; // Zoom factor is applied by getter function
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if h = 0 then
|
if h = 0 then
|
||||||
h := DefaultRowHeight; // Zoom factor is applied by getter function
|
h := DefaultRowHeight; // Zoom factor is applied by getter function
|
||||||
|
|
||||||
@ -4818,15 +4821,24 @@ end;
|
|||||||
{@@ ----------------------------------------------------------------------------
|
{@@ ----------------------------------------------------------------------------
|
||||||
Updates grid row heights by using the data from the TRow records.
|
Updates grid row heights by using the data from the TRow records.
|
||||||
-------------------------------------------------------------------------------}
|
-------------------------------------------------------------------------------}
|
||||||
procedure TsCustomWorksheetGrid.UpdateRowHeights;
|
procedure TsCustomWorksheetGrid.UpdateRowHeights(AStartRow: Integer = -1);
|
||||||
var
|
var
|
||||||
r: Integer;
|
r, r1: Integer;
|
||||||
begin
|
begin
|
||||||
if FRowHeightLock > 0 then
|
if FRowHeightLock > 0 then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
for r:=FHeaderCount to RowCount-1 do
|
if AStartRow = -1 then
|
||||||
UpdateRowHeight(r);
|
r1 := FHeaderCount else
|
||||||
|
r1 := AStartRow;
|
||||||
|
|
||||||
|
BeginUpdate;
|
||||||
|
try
|
||||||
|
for r:=r1 to RowCount-1 do
|
||||||
|
UpdateRowHeight(r);
|
||||||
|
finally
|
||||||
|
EndUpdate;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user