[Libreoffice-commits] core.git: sw/source

László Németh (via logerrit) logerrit at kemper.freedesktop.org
Wed Dec 18 18:58:31 UTC 2019


 sw/source/uibase/dochdl/swdtflvr.cxx |   61 +++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

New commits:
commit 4ea1f7363d68296219f371076a93d3e480289368
Author:     László Németh <nemeth at numbertext.org>
AuthorDate: Wed Dec 18 11:33:56 2019 +0100
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Wed Dec 18 19:56:38 2019 +0100

    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 at numbertext.org>

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;
     }


More information about the Libreoffice-commits mailing list