diff options
author | Henry Castro <hcastro@collabora.com> | 2023-04-27 17:05:09 -0400 |
---|---|---|
committer | Henry Castro <hcastro@collabora.com> | 2023-06-20 20:46:36 +0200 |
commit | 862cdd148d5c6f9563f8a9b11f7559cd022c9c4a (patch) | |
tree | ca40e1ae42eb32def60b6413b9a72b92554f80ca | |
parent | c318f7bf20f21ea0e61b7069e4879868265b70c7 (diff) |
lok: sc: fix layout RTL mouse selection
If the Calc is in layout RTL, the edit view mouse
selection does not change.
Signed-off-by: Henry Castro <hcastro@collabora.com>
Change-Id: I0bd2640dac3cdc96fa247c305c379b2d1a8564ee
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150757
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151974
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153357
Tested-by: Jenkins
-rw-r--r-- | sc/source/ui/view/gridwin.cxx | 74 |
1 files changed, 71 insertions, 3 deletions
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 6efcc68453a2..275c9dbcec25 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -50,6 +50,7 @@ #include <vcl/weldutils.hxx> #include <sot/formats.hxx> #include <comphelper/classids.hxx> +#include <comphelper/scopeguard.hxx> #include <svx/svdview.hxx> #include <svx/svdocapt.hxx> @@ -347,6 +348,18 @@ static bool lcl_GetHyperlinkCell( return bFound; } +static void lcl_GetMirror(Point& rPoint, tools::Rectangle& rRect, const tools::Long nWidth) +{ + tools::Long nLeft = rRect.Left(); + tools::Long nRight = rRect.Right(); + tools::Long nMirrorPX = o3tl::convert(nWidth, o3tl::Length::twip, o3tl::Length::px); + tools::Long nMirrorMM = o3tl::convert(nWidth, o3tl::Length::twip, o3tl::Length::mm100); + + rPoint.setX(nMirrorPX - rPoint.X()); + rRect.SetLeft(nMirrorMM - nRight); + rRect.SetRight(nMirrorMM - nLeft); +} + // WB_DIALOGCONTROL needed for UNO-Controls ScGridWindow::ScGridWindow( vcl::Window* pParent, ScViewData& rData, ScSplitPos eWhichPos ) : DocWindow( pParent, WB_CLIPCHILDREN | WB_DIALOGCONTROL ), @@ -1940,7 +1953,25 @@ void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt, MouseEventSta pScMod->SetInputMode( SC_INPUT_TABLE ); bEEMouse = true; - pEditView->MouseButtonDown( rMEvt ); + + if (comphelper::LibreOfficeKit::isActive() && rDoc.IsLayoutRTL(mrViewData.GetTabNo())) + { + Point aMouse = rMEvt.GetPosPixel(); + tools::Rectangle aOutputArea = pEditView->GetOutputArea(); + comphelper::ScopeGuard aOutputGuard( + [pEditView, aOutputArea] { + pEditView->SetOutputArea(aOutputArea); + }); + + lcl_GetMirror(aMouse, aOutputArea, mrViewData.getLOKVisibleArea().GetWidth()); + pEditView->SetOutputArea(aOutputArea); + + MouseEvent aEvent(aMouse, rMEvt.GetClicks(), rMEvt.GetMode(), + rMEvt.GetButtons(), rMEvt.GetModifier()); + pEditView->MouseButtonDown( aEvent ); + } + else + pEditView->MouseButtonDown( rMEvt ); return; } } @@ -2208,7 +2239,25 @@ void ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt ) SCCOL nEditCol; SCROW nEditRow; mrViewData.GetEditView( eWhich, pEditView, nEditCol, nEditRow ); - pEditView->MouseButtonUp( rMEvt ); + + if (comphelper::LibreOfficeKit::isActive() && rDoc.IsLayoutRTL(mrViewData.GetTabNo())) + { + Point aMouse = rMEvt.GetPosPixel(); + tools::Rectangle aOutputArea = pEditView->GetOutputArea(); + comphelper::ScopeGuard aOutputGuard( + [pEditView, aOutputArea] { + pEditView->SetOutputArea(aOutputArea); + }); + + lcl_GetMirror(aMouse, aOutputArea, mrViewData.getLOKVisibleArea().GetWidth()); + pEditView->SetOutputArea(aOutputArea); + + MouseEvent aEvent(aMouse, rMEvt.GetClicks(), rMEvt.GetMode(), + rMEvt.GetButtons(), rMEvt.GetModifier()); + pEditView->MouseButtonUp( aEvent ); + } + else + pEditView->MouseButtonUp( rMEvt ); if ( rMEvt.IsMiddle() && GetSettings().GetMouseSettings().GetMiddleButtonAction() == MouseMiddleButtonAction::PasteSelection ) @@ -2697,7 +2746,26 @@ void ScGridWindow::MouseMove( const MouseEvent& rMEvt ) SCCOL nEditCol; SCROW nEditRow; mrViewData.GetEditView( eWhich, pEditView, nEditCol, nEditRow ); - pEditView->MouseMove( rMEvt ); + + if (comphelper::LibreOfficeKit::isActive() && mrViewData.GetDocument().IsLayoutRTL(mrViewData.GetTabNo())) + { + Point aMouse = rMEvt.GetPosPixel(); + tools::Rectangle aOutputArea = pEditView->GetOutputArea(); + comphelper::ScopeGuard aOutputGuard( + [pEditView, aOutputArea] { + pEditView->SetOutputArea(aOutputArea); + }); + + lcl_GetMirror(aMouse, aOutputArea, mrViewData.getLOKVisibleArea().GetWidth()); + pEditView->SetOutputArea(aOutputArea); + + MouseEvent aEvent(aMouse, rMEvt.GetClicks(), rMEvt.GetMode(), + rMEvt.GetButtons(), rMEvt.GetModifier()); + + pEditView->MouseMove( aEvent ); + } + else + pEditView->MouseMove( rMEvt ); return; } |