From e9ca7a1e2daf173c5eeceef3976fd7695bba40ef Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Tue, 11 Apr 2017 19:59:54 +0000 Subject: [PATCH] fpspreadsheet: Fix writing vertically distorted images due to incorrect row height calculation (see http://forum.lazarus.freepascal.org/index.php/topic,31740.msg243224.html#msg243224) git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5832 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../source/common/fpspreadsheet.pas | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/components/fpspreadsheet/source/common/fpspreadsheet.pas b/components/fpspreadsheet/source/common/fpspreadsheet.pas index b19cca002..9d8fa1b2d 100644 --- a/components/fpspreadsheet/source/common/fpspreadsheet.pas +++ b/components/fpspreadsheet/source/common/fpspreadsheet.pas @@ -3887,13 +3887,6 @@ begin AWidth := obj.ImageWidth * img.ScaleX; // in workbook units AHeight := obj.ImageHeight * img.ScaleY; // in workbook units - if UsePixels then - begin - // If we don't know the ppi of the screen the calculation is not exact! - w_px := ptsToPx(FWorkbook.ConvertUnits(AWidth, u, suPoints), ppi); - h_px := ptsToPx(FWorkbook.ConvertUnits(AHeight, u, suPoints), ppi); - end; - // Find x coordinate of left image edge, in workbook units x := AColOffs1; for c := 0 to ACol1-1 do @@ -3909,10 +3902,12 @@ begin y := y + rowH; end; - if UsePixels then // Use pixels for calculation. Better for Excel, maybe due to rounding error? begin + // If we don't know the ppi of the screen the calculation is not exact! + w_px := ptsToPx(FWorkbook.ConvertUnits(AWidth, u, suPoints), ppi); + h_px := ptsToPx(FWorkbook.ConvertUnits(AHeight, u, suPoints), ppi); // Find cell with right image edge. Find horizontal within-cell-offsets totW_px := -ptsToPx(FWorkbook.ConvertUnits(AColOffs1, u, suPoints), ppi); ACol2 := ACol1; @@ -6870,10 +6865,18 @@ end; function TsWorksheet.CalcRowHeight(ARow: Cardinal): Single; // In workbook units +var + r: PRow; begin - Result := CalcAutoRowHeight(ARow); - if Result = 0 then - Result := GetRowHeight(ARow, FWorkbook.Units); + r := FindRow(ARow); + if (r <> nil) and (r^.RowHeightType = rhtCustom) then + Result := GetRowHeight(ARow, FWorkbook.Units) + else + begin + Result := CalcAutoRowHeight(ARow); + if Result = 0 then + Result := GetRowHeight(ARow, FWorkbook.Units); + end; end; {@@ ----------------------------------------------------------------------------