From 69b505553331480c0ab97e3776ba31ef11e649a3 Mon Sep 17 00:00:00 2001 From: Jan Holesovsky Date: Wed, 8 Apr 2015 22:16:21 +0200 Subject: sc tiled editing: Reuse the selection method. Change-Id: I05175f0d8c37994658e0dcdf355a753bf7c840b8 --- sc/source/ui/unoobj/docuno.cxx | 9 +-------- sc/source/ui/view/gridwin.cxx | 14 ++------------ sc/source/ui/view/gridwin4.cxx | 15 +++++++++++++-- 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index 1df53bb5c960..f2d62cfbe539 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -622,14 +622,7 @@ void ScModelObj::setTextSelection(int nType, int nX, int nY) Point aPoint(convertTwipToMm100(nX), convertTwipToMm100(nY)); - if (!pTableView->GetOutputArea().IsInside(aPoint)) - { - // if the handle does not stay in the editeng area, we want to turn - // the selection into the cell selection - pViewShell->UpdateInputLine(); - pViewShell->UpdateInputHandler(); - } - else + if (pTableView->GetOutputArea().IsInside(aPoint)) { switch (nType) { diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index b351c4ccac47..6c15dd163ff6 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -1718,18 +1718,8 @@ void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt, MouseEventSta aCell.assign(*pViewData->GetDocument(), ScAddress(nPosX, nPosY, nTab)); if (aCell.isEmpty()) { - // stop editing - ScTabViewShell* pViewShell = pViewData->GetViewShell(); - pViewShell->UpdateInputLine(); - pViewShell->UpdateInputHandler(); - - // select the given cell - ScTabView* pTabView = pViewData->GetView(); - pTabView->SetCursor(nPosX, nPosY); - pTabView->DoneBlockMode(); - pTabView->InitBlockMode(nPosX, nPosY, nTab, true); - pTabView->MarkCursor(nPosX, nPosY, nTab); - pTabView->SelectionChanged(); + SetCellSelectionPixel(LOK_SETTEXTSELECTION_START, aPos.X(), aPos.Y()); + SetCellSelectionPixel(LOK_SETTEXTSELECTION_END, aPos.X(), aPos.Y()); return; } } diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index a14c04e447ac..e9d21852fc49 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -1010,6 +1010,15 @@ void ScGridWindow::LogicInvalidate(const Rectangle* pRectangle) void ScGridWindow::SetCellSelectionPixel(int nType, int nPixelX, int nPixelY) { ScTabView* pTabView = pViewData->GetView(); + ScTabViewShell* pViewShell = pViewData->GetViewShell(); + ScInputHandler* pInputHandler = SC_MOD()->GetInputHdl(pViewShell); + + if (pInputHandler && pInputHandler->IsInputMode()) + { + // we need to switch off the editeng + pViewShell->UpdateInputLine(); + pViewShell->UpdateInputHandler(); + } if (nType == LOK_SETTEXTSELECTION_RESET) { @@ -1024,10 +1033,12 @@ void ScGridWindow::SetCellSelectionPixel(int nType, int nPixelX, int nPixelY) SCROW nRow1, nRow2; SCTAB nTab1, nTab2; + bool bWasEmpty = false; if (aRangeList.empty()) { nCol1 = nCol2 = pViewData->GetCurX(); nRow1 = nRow2 = pViewData->GetCurY(); + bWasEmpty = true; } else aRangeList.Combine().GetVars(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2); @@ -1042,7 +1053,7 @@ void ScGridWindow::SetCellSelectionPixel(int nType, int nPixelX, int nPixelY) switch (nType) { case LOK_SETTEXTSELECTION_START: - if (nNewPosX != nCol1 || nNewPosY != nRow1) + if (nNewPosX != nCol1 || nNewPosY != nRow1 || bWasEmpty) { pTabView->SetCursor(nNewPosX, nNewPosY); pTabView->DoneBlockMode(); @@ -1051,7 +1062,7 @@ void ScGridWindow::SetCellSelectionPixel(int nType, int nPixelX, int nPixelY) } break; case LOK_SETTEXTSELECTION_END: - if (nNewPosX != nCol2 || nNewPosY != nRow2) + if (nNewPosX != nCol2 || nNewPosY != nRow2 || bWasEmpty) { pTabView->SetCursor(nCol1, nRow1); pTabView->DoneBlockMode(); -- cgit