From 21fc0ce61a25a7ab6f9bb83cecfd880f17033c4e Mon Sep 17 00:00:00 2001 From: Lionel Elie Mamane Date: Thu, 4 Oct 2018 16:16:46 +0200 Subject: tdf#119564 column id is not always the same as position MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GetColumnAtXPosPixel returns the column position (index in mvCols vector), _not_ the column id! These differ in particular when some columns are hidden. Change-Id: Ifc068bd3cc090969278f10e48d9d7d3f8a682e13 Reviewed-on: https://gerrit.libreoffice.org/60975 Tested-by: Jenkins Reviewed-by: Lionel Elie Mamane (cherry picked from commit 2f792ac91fdaaea1df38e64833dd1c258bb41c03) Reviewed-on: https://gerrit.libreoffice.org/61619 Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- svx/source/fmcomp/gridctrl.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'svx/source') diff --git a/svx/source/fmcomp/gridctrl.cxx b/svx/source/fmcomp/gridctrl.cxx index 2048e63e7a35..eb81535f5018 100644 --- a/svx/source/fmcomp/gridctrl.cxx +++ b/svx/source/fmcomp/gridctrl.cxx @@ -2774,7 +2774,7 @@ bool DbGridControl::canCopyCellText(sal_Int32 _nRow, sal_uInt16 _nColId) return (_nRow >= 0) && (_nRow < GetRowCount()) && (_nColId != HandleColumnId) - && (_nColId <= ColCount()); + && (GetModelColumnPos(_nColId) != GRID_COLUMN_NOT_FOUND); } void DbGridControl::copyCellText(sal_Int32 _nRow, sal_uInt16 _nColId) @@ -2821,7 +2821,7 @@ void DbGridControl::Command(const CommandEvent& rEvt) } } - sal_uInt16 nColId = GetColumnAtXPosPixel(rEvt.GetMousePosPixel().X()); + sal_uInt16 nColId = GetColumnId(GetColumnAtXPosPixel(rEvt.GetMousePosPixel().X())); long nRow = GetRowAtYPosPixel(rEvt.GetMousePosPixel().Y()); if (nColId == HandleColumnId) -- cgit