fpspreadsheet: Fix merged cells painting into the fixed cells of TsWorksheetGrid.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4439 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz 2016-01-19 12:04:41 +00:00
parent a433fc3fce
commit d769397eae

View File

@ -1426,8 +1426,8 @@ end;
procedure TsCustomWorksheetGrid.DefineProperties(Filer: TFiler); procedure TsCustomWorksheetGrid.DefineProperties(Filer: TFiler);
begin begin
// Don't call inherited, this is where to ColWidths/RwoHeights are stored in // Don't call inherited, this is where the ColWidths/RowHeights are written
// the lfm file - we don't need them, we get them from the workbook! // to the lfm file - we don't need them, we get them from the workbook!
Unused(Filer); Unused(Filer);
end; end;
@ -1923,10 +1923,10 @@ end;
{@@ ---------------------------------------------------------------------------- {@@ ----------------------------------------------------------------------------
Draws a complete row of cells. Is mostly duplicated from Grids.pas, but adds Draws a complete row of cells. Is mostly duplicated from Grids.pas, but adds
code for merged cells and overflow text, the section on drawing the default code for merged cells and overflow text, the section for drawing the default
focus rectangle is removed. focus rectangle is removed.
@param ARow Index of the row to be drawn (index in grid coordinates) @param ARow Index of the row to be drawn (in grid coordinates)
-------------------------------------------------------------------------------} -------------------------------------------------------------------------------}
procedure TsCustomWorksheetGrid.DrawRow(ARow: Integer); procedure TsCustomWorksheetGrid.DrawRow(ARow: Integer);
var var
@ -1934,7 +1934,7 @@ var
sr, sr1,sc1,sr2,sc2, scLastUsed: Cardinal; // sheet row/column sr, sr1,sc1,sr2,sc2, scLastUsed: Cardinal; // sheet row/column
gr, gc, gcNext, gcLast, gc1, gc2, gcLastUsed: Integer; // grid row/column gr, gc, gcNext, gcLast, gc1, gc2, gcLastUsed: Integer; // grid row/column
i: Integer; i: Integer;
rct, saved_rct, temp_rct, commentcell_rct: TRect; rct, saved_rct, temp_rct, fixed_rct, commentcell_rct: TRect;
clipArea: Trect; clipArea: Trect;
cell: PCell; cell: PCell;
fmt: PsCellFormat; fmt: PsCellFormat;
@ -1987,6 +1987,10 @@ begin
ColRowToOffSet(False, True, ARow, rct.Top, rct.Bottom); ColRowToOffSet(False, True, ARow, rct.Top, rct.Bottom);
saved_rct := rct; saved_rct := rct;
fixed_rct := Rect(0, 0, 0, 0);
if HeaderCount > 0 then
ColRowToOffset(true, false, 0, fixed_rct.Left, fixed_rct.Right);
// is this row within the ClipRect? // is this row within the ClipRect?
clipArea := Canvas.ClipRect; clipArea := Canvas.ClipRect;
if (rct.Top >= rct.Bottom) or not VerticalIntersect(rct, clipArea) then begin if (rct.Top >= rct.Bottom) or not VerticalIntersect(rct, clipArea) then begin
@ -2032,7 +2036,7 @@ begin
end; end;
// Now find the last column. Again text can overflow into the visible area // Now find the last column. Again text can overflow into the visible area
// from cells to the right. // from invisible cells at the right.
gcLast := Right; gcLast := Right;
if FTextOverflow and (sr <> UNASSIGNED_ROW_COL_INDEX) and Assigned(Worksheet) then if FTextOverflow and (sr <> UNASSIGNED_ROW_COL_INDEX) and Assigned(Worksheet) then
begin begin
@ -2059,7 +2063,7 @@ begin
end; end;
end; end;
// Here begins the drawing loop of all cells in the row // Here begins the drawing loop of all cells in the row between gc and gclast
while (gc <= gcLast) do begin while (gc <= gcLast) do begin
gr := ARow; gr := ARow;
rct := saved_rct; rct := saved_rct;
@ -2142,7 +2146,11 @@ begin
if (rct.Left < rct.Right) and HorizontalIntersect(rct, clipArea) then if (rct.Left < rct.Right) and HorizontalIntersect(rct, clipArea) then
begin begin
gds := GetGridDrawState(gc, gr); gds := GetGridDrawState(gc, gr);
DoDrawCell(gc, gr, rct, rct); temp_rct := rct;
// Avoid painting into the fixed cells
if temp_rct.Left < fixed_rct.Right then temp_rct.Left := fixed_rct.Right;
// Draw cell
DoDrawCell(gc, gr, temp_rct, rct);
// Draw comment marker // Draw comment marker
if (commentcell_rct.Left <> 0) and (commentcell_rct.Right <> 0) and if (commentcell_rct.Left <> 0) and (commentcell_rct.Right <> 0) and
(commentcell_rct.Top <> 0) and (commentcell_rct.Bottom <> 0) (commentcell_rct.Top <> 0) and (commentcell_rct.Bottom <> 0)