diff options
author | László Németh <nemeth@numbertext.org> | 2019-12-18 11:33:56 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2019-12-18 19:56:38 +0100 |
commit | 4ea1f7363d68296219f371076a93d3e480289368 (patch) | |
tree | 6895960c3353833fe0f62a205496882406e36937 /sw/source | |
parent | 9bd87473687856f2a3c7ded26e8658c39f369aed (diff) |
tdf#35570 Writer: drag and drop rows/columns without overwriting
cells of the target table. Instead, paste rows above or
columns before in the case of enhanced table selection
(clicking in front of the copied rows or columns) or in
the case of wholly selected tables.
At moving (without pressing Ctrl during drag and drop),
remove the originally selected rows or columns instead
of emptying them.
Change-Id: I4072d51fa8e8ae9a5b9d57f43643eadcad712597
Reviewed-on: https://gerrit.libreoffice.org/85375
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/uibase/dochdl/swdtflvr.cxx | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx index 5b875cc3bdbe..4823706a4a3d 100644 --- a/sw/source/uibase/dochdl/swdtflvr.cxx +++ b/sw/source/uibase/dochdl/swdtflvr.cxx @@ -3790,6 +3790,67 @@ bool SwTransferable::PrivateDrop( SwWrtShell& rSh, const Point& rDragPt, if( rSrcSh.IsTableMode() ) { bTableSel = true; + const SelectionType nSelection = rSrcSh.GetSelectionType(); + // at enhanced table row/column selection or wholly selected tables, + // paste rows above or columns before, and in the case of moving, remove the selection + // (limit only to the single document case temporarily) + if( rSrcSh.GetDoc() == rSh.GetDoc() && + ( (( SelectionType::TableRow | SelectionType::TableCol) & nSelection ) || rSrcSh.HasWholeTabSelection() ) ) + { + bool bTableCol(SelectionType::TableCol & nSelection); + + SwUndoId eUndoId = bMove ? SwUndoId::UI_DRAG_AND_MOVE : SwUndoId::UI_DRAG_AND_COPY; + + SwRewriter aRewriter; + + aRewriter.AddRule(UndoArg1, rSrcSh.GetSelDescr()); + + if(rSrcSh.GetDoc() != rSh.GetDoc()) + rSrcSh.StartUndo( eUndoId, &aRewriter ); + rSh.StartUndo( eUndoId, &aRewriter ); + + rSh.StartAction(); + rSrcSh.StartAction(); + + SfxDispatcher* pDispatch = rSrcSh.GetView().GetViewFrame()->GetDispatcher(); + pDispatch->Execute(SID_COPY, SfxCallMode::SYNCHRON); + + rSrcSh.Push(); // save selection for later restoration + rSh.EnterStdMode(); + rSh.SwCursorShell::SetCursor(rDragPt, false); + + // store cursor + ::sw::mark::IMark* pMark = rSh.SetBookmark( + vcl::KeyCode(), + OUString(), + IDocumentMarkAccess::MarkType::UNO_BOOKMARK ); + + rSrcSh.Pop(SwCursorShell::PopMode::DeleteCurrent); // restore selection... + + // delete source rows/columns + if (bMove) + pDispatch->Execute(bTableCol ? FN_TABLE_DELETE_COL : FN_TABLE_DELETE_ROW, SfxCallMode::SYNCHRON); + + // restore cursor position + if (pMark != nullptr) + { + rSh.GotoMark( pMark ); + rSh.getIDocumentMarkAccess()->deleteMark( pMark ); + } + + // paste rows above/columns before + pDispatch->Execute(bTableCol ? FN_TABLE_PASTE_COL_BEFORE : FN_TABLE_PASTE_ROW_BEFORE, SfxCallMode::SYNCHRON); + + if( rSrcSh.GetDoc() != rSh.GetDoc() ) + rSrcSh.EndUndo(); + + rSh.DestroyCursor(); + rSh.EndUndo(); + rSh.EndAction(); + rSh.EndAction(); + return true; + } + if ( bMove && rSrcSh.HasWholeTabSelection() ) bTableMove = true; } |