From 43d34422ad75c1aac04475e2c50959dbd1279241 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Sun, 1 Apr 2018 10:55:28 +0000 Subject: [PATCH] fpspreadsheet: Fix TsCellIndicator to display only the base of a merged block git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6284 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../source/visual/fpspreadsheetctrls.pas | 50 ++++++++++++------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/components/fpspreadsheet/source/visual/fpspreadsheetctrls.pas b/components/fpspreadsheet/source/visual/fpspreadsheetctrls.pas index cf603c36b..1a8398fe1 100644 --- a/components/fpspreadsheet/source/visual/fpspreadsheetctrls.pas +++ b/components/fpspreadsheet/source/visual/fpspreadsheetctrls.pas @@ -282,6 +282,7 @@ type procedure SetWorkbookSource(AValue: TsWorkbookSource); protected procedure Notification(AComponent: TComponent; Operation: TOperation); override; + procedure UpdateDisplay; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; @@ -2184,26 +2185,10 @@ end; -------------------------------------------------------------------------------} procedure TsCellIndicator.ListenerNotification(AChangedItems: TsNotificationItems; AData: Pointer = nil); -var - sel: TsCellRangeArray; - s: String; - rng: TsCellRange; - numrows, numcols: Integer; begin Unused(AData); if (lniSelection in AChangedItems) and (Worksheet <> nil) then - begin - s := GetCellString(Worksheet.ActiveCellRow, Worksheet.ActiveCellCol); - sel := Worksheet.GetSelection; - if Length(sel) > 0 then begin - rng := sel[High(sel)]; - numrows := rng.Row2 - rng.Row1 + 1; - numcols := rng.Col2 - rng.Col1 + 1; - if (numrows <> 1) or (numcols <> 1) then - s := Format('%s (%d R x %d C)', [s, rng.Row2-rng.Row1+1, rng.Col2-rng.Col1+1]); - end; - Text := s; - end; + UpdateDisplay; end; {@@ ---------------------------------------------------------------------------- @@ -2242,6 +2227,37 @@ begin ListenerNotification([lniSelection]); end; +procedure TsCellIndicator.UpdateDisplay; +var + sel: TsCellRangeArray; + s: String; + rng: TsCellRange; + numrows, numcols: Integer; + r, c: Cardinal; + cell: PCell; +begin + r := Worksheet.ActiveCellRow; + c := Worksheet.ActiveCellCol; + cell := Worksheet.FindCell(r, c); + if cell <> nil then begin + cell := Worksheet.FindMergeBase(cell); + if cell <> nil then begin + r := cell^.Row; + c := cell^.Col; + end; + end; + s := GetCellString(r, c); + sel := Worksheet.GetSelection; + if Length(sel) > 0 then begin + rng := sel[High(sel)]; + numrows := rng.Row2 - rng.Row1 + 1; + numcols := rng.Col2 - rng.Col1 + 1; + if (numrows <> 1) or (numcols <> 1) then + s := Format('%s (%d R x %d C)', [s, rng.Row2-rng.Row1+1, rng.Col2-rng.Col1+1]); + end; + Text := s; +end; + {------------------------------------------------------------------------------} { TsCellCombobox }