Kaydet (Commit) 69b50555 authored tarafından Jan Holesovsky's avatar Jan Holesovsky

sc tiled editing: Reuse the selection method.

Change-Id: I05175f0d8c37994658e0dcdf355a753bf7c840b8
üst 7e056939
......@@ -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)
{
......
......@@ -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;
}
}
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment