[Libreoffice-commits] core.git: Branch 'libreoffice-6-4' - sw/source

László Németh (via logerrit) logerrit at kemper.freedesktop.org
Thu Dec 19 11:25:58 UTC 2019


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

New commits:
commit 20d91d5f45f3d1429dd64ad27469368f36f5fe5e
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: Thu Dec 19 12:25:20 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>
    (cherry picked from commit 4ea1f7363d68296219f371076a93d3e480289368)
    Reviewed-on: https://gerrit.libreoffice.org/85421

diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index 0555a19171e2..f6e5990b1b3d 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -3782,6 +3782,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