tdf#155685 sw: ExtendedSelectAll with tables, group the Undo objects

Change-Id: I2fba70968c97cd9704212cd799b333d2d158a042
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153115
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
(cherry picked from commit 5ab4fb27f4232fe0f36cfc079acb065d1712a355)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153089
diff --git a/sw/source/core/edit/eddel.cxx b/sw/source/core/edit/eddel.cxx
index 6082dab..10d086b 100644
--- a/sw/source/core/edit/eddel.cxx
+++ b/sw/source/core/edit/eddel.cxx
@@ -99,6 +99,12 @@ void SwEditShell::DeleteSel(SwPaM& rPam, bool const isArtificialSelection, bool 
        SwPaM * pPam = &rPam;
        if (oSelectAll)
        {
            if (!oSelectAll->second.empty())
            {
                SwRewriter aRewriter;
                aRewriter.AddRule(UndoArg1, SwResId(STR_MULTISEL));
                GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::DELETE, &aRewriter);
            }
            // tdf#155685 tables at the end must be deleted separately
            for (SwTableNode *const pTable : oSelectAll->second)
            {
@@ -115,6 +121,10 @@ void SwEditShell::DeleteSel(SwPaM& rPam, bool const isArtificialSelection, bool 
        GetDoc()->getIDocumentContentOperations().DeleteAndJoin(*pPam,
            isArtificialSelection ? SwDeleteFlags::ArtificialSelection : SwDeleteFlags::Default);
        SaveTableBoxContent( pPam->GetPoint() );
        if (oSelectAll && !oSelectAll->second.empty())
        {
            GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::END, nullptr);
        }
    }

    // Selection is not needed anymore