From 14e306efae35f01fa63237ce005ad4067ca16909 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Wed, 29 Jan 2020 12:44:30 +0100 Subject: lok: preserve mouse event logic position and use in calc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When clicking in online Calc any of the charts, shapes (and other objects), sometimes the cell underneath is selected instead. The problem is that the object is not correctly recognised to be hit. From lok we get the mouse event position in logic coordinates, which we usually can just use in writer and impress. In calc however we need the coordinates in pixels, so we transform them before sending the mouse event to calc. Still calc also uses common SdrObjects (chart, shapes,...), which operate in logic coordinates. So in case of SdrObject we need to convert the coordniates back from pixel to logic again, which causes problems because conversion doesn't have access to the displaying conditions on an stateless online client. OTOH we already had the correct logic coordinates, and we can just send them along. This is what this change does. It adds an optional maLogicPosition to MouseEvent, which is filled with logic position if those is known. Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87681 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit 82196472291c4ccbcacb5c2513d1961ba9460cdf) Change-Id: I26f6466085baf613850b5861e368f22cad7c1d26 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87708 Tested-by: Jenkins CollaboraOffice Reviewed-by: Tomaž Vajngerl --- include/vcl/event.hxx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'include/vcl') diff --git a/include/vcl/event.hxx b/include/vcl/event.hxx index f160a27c4cd1..9d1ffdba1f5d 100644 --- a/include/vcl/event.hxx +++ b/include/vcl/event.hxx @@ -27,6 +27,7 @@ #include #include #include +#include class CommandEvent; @@ -99,7 +100,6 @@ namespace o3tl #define MOUSE_MIDDLE (sal_uInt16(0x0002)) #define MOUSE_RIGHT (sal_uInt16(0x0004)) - class VCL_DLLPUBLIC MouseEvent { private: @@ -108,6 +108,9 @@ private: sal_uInt16 mnClicks; sal_uInt16 mnCode; + // Set, if the document relative logic position are available + boost::optional maLogicPosition; + public: explicit MouseEvent(); explicit MouseEvent( const Point& rPos, sal_uInt16 nClicks = 1, @@ -119,6 +122,16 @@ public: sal_uInt16 GetClicks() const { return mnClicks; } + void setLogicPosition(Point aLogicPosition) + { + maLogicPosition = aLogicPosition; + } + + boost::optional getLogicPosition() const + { + return maLogicPosition; + } + bool IsEnterWindow() const { return bool(mnMode & MouseEventModifiers::ENTERWINDOW); } bool IsLeaveWindow() const -- cgit