fpspreadsheet: Fix incorrect row height when row switches from hidden to visible (https://forum.lazarus.freepascal.org/index.php?topic=58792.msg438138#msg438138).

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8218 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2022-03-22 10:11:23 +00:00
parent 321ebdb047
commit b5c5632668
2 changed files with 28 additions and 20 deletions

View File

@ -5967,26 +5967,30 @@ begin
if h = 0 then
h := DefaultRowHeight; // Zoom factor is applied by getter function
end;
end else
end;
// No row record so far.
if Worksheet.GetCellCountInRow(sr) > 0 then
if lRow = nil then
begin
// Case 1: This row does contain cells
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
else
lRow^.RowHeightType := rhtDefault;
if h = 0 then
h := DefaultRowHeight; // Zoom factor is applied by getter function
end else
// Case 2: No cells in row
h := DefaultRowHeight; // Zoom factor is applied by getter function
if Worksheet.GetCellCountInRow(sr) > 0 then
begin
// Case 1: This row does contain cells
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
else
lRow^.RowHeightType := rhtDefault;
if h = 0 then
h := DefaultRowHeight; // Zoom factor is applied by getter function
end else
// Case 2: No cells in row
h := DefaultRowHeight; // Zoom factor is applied by getter function
end;
end;
inc(FZoomLock); // We don't want to modify the sheet row heights here.

View File

@ -326,9 +326,10 @@ function RichTextWidth(ACanvas: TCanvas; AWorkbook: TsWorkbook; ARect: TRect;
var
painter: TsTextPainter;
begin
// In contrast to RichTextHeight, the next two lines have no effect on col
// width when a column switches from hidden to visible.
if (ARect.Left = ARect.Right) or (ARect.Top = ARect.Bottom) then
exit(0);
painter := TsTextPainter.Create(ACanvas, AWorkbook, ARect, AText, ARichTextParams,
AFontIndex, ATextRotation, haLeft, vaTop, AWordWrap, ARightToLeft, AZoomFactor);
try
@ -345,9 +346,12 @@ function RichTextHeight(ACanvas: TCanvas; AWorkbook: TsWorkbook; ARect: TRect;
var
painter: TsTextPainter;
begin
{ -- causes incorrect row height, when row switches from hidden to visible.
// see: https://forum.lazarus.freepascal.org/index.php/topic,58792.msg438090.html#msg438090
if (ARect.Left = ARect.Right) or (ARect.Top = ARect.Bottom) then
exit(0);
}
painter := TsTextPainter.Create(ACanvas, AWorkbook, ARect, AText, ARichTextParams,
AFontIndex, ATextRotation, haLeft, vaTop, AWordWrap, ARightToLeft, AZoomFactor);
try