diff options
-rw-r--r-- | sc/source/ui/app/transobj.cxx | 15 | ||||
-rw-r--r-- | sc/source/ui/inc/transobj.hxx | 8 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin.cxx | 14 | ||||
-rw-r--r-- | sc/source/ui/view/select.cxx | 1 | ||||
-rw-r--r-- | sc/source/ui/view/tabcont.cxx | 2 |
5 files changed, 37 insertions, 3 deletions
diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx index 85f65e2dc168..d1ac04ec53c6 100644 --- a/sc/source/ui/app/transobj.cxx +++ b/sc/source/ui/app/transobj.cxx @@ -116,6 +116,8 @@ ScTransferObj::ScTransferObj( ScDocument* pClipDoc, const TransferableObjectDesc aObjDesc( rDesc ), nDragHandleX( 0 ), nDragHandleY( 0 ), + nSourceCursorX( MAXCOL + 1 ), + nSourceCursorY( MAXROW + 1 ), nDragSourceFlags( 0 ), bDragWasInternal( false ), bUsedForLink( false ), @@ -517,6 +519,19 @@ void ScTransferObj::SetDragHandlePos( SCCOL nX, SCROW nY ) nDragHandleY = nY; } +void ScTransferObj::SetSourceCursorPos( SCCOL nX, SCROW nY ) +{ + nSourceCursorX = nX; + nSourceCursorY = nY; +} + +bool ScTransferObj::WasSourceCursorInSelection() const +{ + return + nSourceCursorX >= aBlock.aStart.Col() && nSourceCursorX <= aBlock.aEnd.Col() && + nSourceCursorY >= aBlock.aStart.Row() && nSourceCursorY <= aBlock.aEnd.Row(); +} + void ScTransferObj::SetVisibleTab( SCTAB nNew ) { nVisibleTab = nNew; diff --git a/sc/source/ui/inc/transobj.hxx b/sc/source/ui/inc/transobj.hxx index a29fd4c25838..abce98926d0f 100644 --- a/sc/source/ui/inc/transobj.hxx +++ b/sc/source/ui/inc/transobj.hxx @@ -49,6 +49,8 @@ private: css::uno::Reference<css::sheet::XSheetCellRanges> xDragSourceRanges; SCCOL nDragHandleX; SCROW nDragHandleY; + SCCOL nSourceCursorX; + SCROW nSourceCursorY; SCTAB nVisibleTab; sal_uInt16 nDragSourceFlags; bool bDragWasInternal; @@ -83,8 +85,11 @@ public: SCROW GetNonFilteredRows() const { return nNonFiltered; } SCCOL GetDragHandleX() const { return nDragHandleX; } SCROW GetDragHandleY() const { return nDragHandleY; } + bool WasSourceCursorInSelection() const; + SCCOL GetSourceCursorX() const { return nSourceCursorX; } + SCROW GetSourceCursorY() const { return nSourceCursorY; } SCTAB GetVisibleTab() const { return nVisibleTab; } - sal_uInt16 GetDragSourceFlags() const { return nDragSourceFlags; } + sal_uInt16 GetDragSourceFlags() const { return nDragSourceFlags; } bool HasFilteredRows() const { return bHasFiltered; } bool GetUseInApi() const { return bUseInApi; } ScDocShell* GetSourceDocShell(); @@ -93,6 +98,7 @@ public: void SetDrawPersist( const SfxObjectShellRef& rRef ); void SetDragHandlePos( SCCOL nX, SCROW nY ); + void SetSourceCursorPos( SCCOL nX, SCROW nY ); void SetVisibleTab( SCTAB nNew ); void SetDragSource( ScDocShell* pSourceShell, const ScMarkData& rMark ); void SetDragSourceFlags( sal_uInt16 nFlags ); diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index dd0d6d1d0fb5..5c185bb47d8c 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -4325,8 +4325,18 @@ sal_Int8 ScGridWindow::DropTransferObj( ScTransferObj* pTransObj, SCCOL nDestPos { pView->MarkRange( aDest, false ); - SCCOL nDCol = pViewData->GetCurX() - aSource.aStart.Col() + nCorrectCursorPosCol; - SCROW nDRow = pViewData->GetCurY() - aSource.aStart.Row() + nCorrectCursorPosRow; + SCCOL nDCol; + SCROW nDRow; + if (pTransObj->WasSourceCursorInSelection()) + { + nDCol = pTransObj->GetSourceCursorX() - aSource.aStart.Col() + nCorrectCursorPosCol; + nDRow = pTransObj->GetSourceCursorY() - aSource.aStart.Row() + nCorrectCursorPosRow; + } + else + { + nDCol = 0; + nDRow = 0; + } pView->SetCursor( aDest.aStart.Col() + nDCol, aDest.aStart.Row() + nDRow ); } diff --git a/sc/source/ui/view/select.cxx b/sc/source/ui/view/select.cxx index a9b4a20ff2b6..b7a629aedf54 100644 --- a/sc/source/ui/view/select.cxx +++ b/sc/source/ui/view/select.cxx @@ -198,6 +198,7 @@ void ScViewFunctionSet::BeginDrag() SCCOL nHandleX = (nPosX >= (SCsCOL) nStartX) ? nPosX - nStartX : 0; SCROW nHandleY = (nPosY >= (SCsROW) nStartY) ? nPosY - nStartY : 0; pTransferObj->SetDragHandlePos( nHandleX, nHandleY ); + pTransferObj->SetSourceCursorPos( pViewData->GetCurX(), pViewData->GetCurY() ); pTransferObj->SetVisibleTab( nTab ); pTransferObj->SetDragSource( pDocSh, rMark ); diff --git a/sc/source/ui/view/tabcont.cxx b/sc/source/ui/view/tabcont.cxx index a2f5d101a14d..7b55ed7b84c3 100644 --- a/sc/source/ui/view/tabcont.cxx +++ b/sc/source/ui/view/tabcont.cxx @@ -477,6 +477,8 @@ void ScTabControl::DoDrag( const vcl::Region& /* rRegion */ ) pTransferObj->SetDragSource( pDocSh, aTabMark ); + pTransferObj->SetSourceCursorPos( pViewData->GetCurX(), pViewData->GetCurY() ); + vcl::Window* pWindow = pViewData->GetActiveWin(); SC_MOD()->SetDragObject( pTransferObj, nullptr ); // for internal D&D pTransferObj->StartDrag( pWindow, DND_ACTION_COPYMOVE | DND_ACTION_LINK ); |