summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPranam Lashkari <lpranam@collabora.com>2021-01-22 01:27:28 +0530
committerPranam Lashkari <lpranam@collabora.com>2021-02-11 13:54:06 +0100
commit45fb849a44ca5be3f9dc1f9af5848279e02c77f5 (patch)
tree7272ad9109ab66b2548f69932a32012aa045dfd2
parentdbeab98b54b43756aefa06790e7ea890fa431c5a (diff)
prevent reference range resetting on panning in mobile
Change-Id: Ic6cabe1d4e5a1e7c4d42294550d654e38e27db22 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110461 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Pranam Lashkari <lpranam@collabora.com>
-rw-r--r--sc/source/ui/inc/select.hxx1
-rw-r--r--sc/source/ui/view/gridwin.cxx15
-rw-r--r--sc/source/ui/view/select.cxx16
3 files changed, 29 insertions, 3 deletions
diff --git a/sc/source/ui/inc/select.hxx b/sc/source/ui/inc/select.hxx
index d3071f31e344..3e8be2ffa017 100644
--- a/sc/source/ui/inc/select.hxx
+++ b/sc/source/ui/inc/select.hxx
@@ -70,6 +70,7 @@ public:
virtual void DeselectAll() override;
bool SetCursorAtCell( SCCOL nPosX, SCROW nPosY, bool bScroll );
+ bool CheckRefBounds(SCCOL nPosX, SCROW nPosY);
};
class ScHeaderFunctionSet : public FunctionSet // Column / row headers
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 5a8bf3a1734f..c2a1a244f2e4 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -1418,6 +1418,21 @@ void ScGridWindow::LogicMouseMove(const MouseEvent& rMouseEvent)
void ScGridWindow::MouseButtonDown( const MouseEvent& rMEvt )
{
+ if (SfxLokHelper::getDeviceFormFactor() == LOKDeviceFormFactor::MOBILE)
+ {
+ ScViewFunc* pView = pViewData->GetView();
+ ScTabViewShell* pViewShell = pViewData->GetViewShell();
+ bool bRefMode = pViewShell && pViewShell->IsRefInputMode();
+
+ Point aPos(rMEvt.GetPosPixel());
+ SCCOL nPosX;
+ SCROW nPosY;
+ pViewData->GetPosFromPixel(aPos.X(), aPos.Y(), eWhich, nPosX, nPosY);
+
+ if (bRefMode && pView->GetFunctionSet().CheckRefBounds(nPosX, nPosY))
+ return;
+ }
+
nNestedButtonState = ScNestedButtonState::Down;
MouseEventState aState;
diff --git a/sc/source/ui/view/select.cxx b/sc/source/ui/view/select.cxx
index b165234df5c2..99d8707bce75 100644
--- a/sc/source/ui/view/select.cxx
+++ b/sc/source/ui/view/select.cxx
@@ -417,6 +417,17 @@ void ScViewFunctionSet::SetCursorAtPoint( const Point& rPointPixel, bool /* bDon
SetCursorAtCell( nPosX, nPosY, bScroll );
}
+bool ScViewFunctionSet::CheckRefBounds(SCCOL nPosX, SCROW nPosY)
+{
+ SCCOL startX = pViewData->GetRefStartX();
+ SCROW startY = pViewData->GetRefStartY();
+
+ SCCOL endX = pViewData->GetRefEndX();
+ SCROW endY = pViewData->GetRefEndY();
+
+ return nPosX >= startX && nPosX <= endX && nPosY >= startY && nPosY <= endY;
+}
+
bool ScViewFunctionSet::SetCursorAtCell( SCCOL nPosX, SCROW nPosY, bool bScroll )
{
ScTabView* pView = pViewData->GetView();
@@ -468,7 +479,7 @@ bool ScViewFunctionSet::SetCursorAtCell( SCCOL nPosX, SCROW nPosY, bool bScroll
if (bRefMode)
{
// if no input is possible from this doc, don't move the reference cursor around
- if ( !pScMod->IsModalMode(pViewData->GetSfxDocShell()) )
+ if ( !pScMod->IsModalMode(pViewData->GetSfxDocShell()) && (!CheckRefBounds(nPosX, nPosY) || SfxLokHelper::getDeviceFormFactor() != LOKDeviceFormFactor::MOBILE))
{
if (!bAnchor)
{
@@ -476,8 +487,7 @@ bool ScViewFunctionSet::SetCursorAtCell( SCCOL nPosX, SCROW nPosY, bool bScroll
pView->InitRefMode( nPosX, nPosY, pViewData->GetTabNo(), SC_REFTYPE_REF );
}
- if(SfxLokHelper::getDeviceFormFactor() != LOKDeviceFormFactor::MOBILE)
- pView->UpdateRef( nPosX, nPosY, pViewData->GetTabNo() );
+ pView->UpdateRef( nPosX, nPosY, pViewData->GetTabNo() );
pView->SelectionChanged();
}