tdf#156595 sw tracked table column: fix crash at row deletion

In Hide Changes mode, deleting a row, which has
a hidden column deletion before the first cell,
resulted a crash because of missing cell frame/table
cursor.

Regression from commit aff269c18b9029fec992135a406dc5031927c401
"tdf#155345 sw tracked table column: hide them in Hide Changes mode".

Note: it seems, plain uiwriter testing is not enough to catch
the problem.

Change-Id: I12675ecd402d6411107b90809728454f13e60580
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155287
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
(cherry picked from commit 1d12c5de5ab39fba33e016299cc8234475003612)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155295
Tested-by: Jenkins
diff --git a/sw/qa/uitest/table/tdf146145.py b/sw/qa/uitest/table/tdf146145.py
index 84cda61..55d2092 100644
--- a/sw/qa/uitest/table/tdf146145.py
+++ b/sw/qa/uitest/table/tdf146145.py
@@ -250,4 +250,36 @@ class tdf146145(UITestCase):
            xToolkit.processEventsToIdle()
            self.assertEqual(len(tables[0].getColumns()), 5)

   def test_crashWithHiddenFirstTableColumn(self):
        with self.ui_test.load_file(get_url_for_data_file("TC-table-del-add.docx")) as self.document:

            # accept all tracked changes
            self.xUITest.executeCommand(".uno:AcceptAllTrackedChanges")
            # delete first table column
            self.xUITest.executeCommand(".uno:DeleteColumns")

            # Check enabling Accept/Reject Track Change icons
            # and Accept Change/Reject Change context menu items
            # on table columns with tracked deletion or insertion

            # enable Track Changes toolbar
            self.xUITest.executeCommand(".uno:AvailableToolbars?Toolbar:string=changes")

            xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
            xToolkit.processEventsToIdle()

            # cursor at changed text: Accept Track Change is enabled
            self.assertTrue(self.is_enabled_Accept_Track_Change())

            # hide changes
            self.xUITest.executeCommand(".uno:ShowTrackedChanges")
            while self.is_enabled_Accept_Track_Change():
                time.sleep(0.1)
            self.assertFalse(self.is_enabled_Accept_Track_Change())

            # Without the fix in place, this test would have crashed here
            self.xUITest.executeCommand(".uno:DeleteRows")

            self.xUITest.executeCommand(".uno:ShowTrackedChanges")

# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/source/core/crsr/trvltbl.cxx b/sw/source/core/crsr/trvltbl.cxx
index 0aaa899..689457d 100644
--- a/sw/source/core/crsr/trvltbl.cxx
+++ b/sw/source/core/crsr/trvltbl.cxx
@@ -128,7 +128,7 @@ bool SwCursorShell::SelTableRowOrCol( bool bRow, bool bRowSimple )
{
    // check if the current cursor's SPoint/Mark are in a table
    SwFrame *pFrame = GetCurrFrame();
    if( !pFrame->IsInTab() )
    if( !pFrame || !pFrame->IsInTab() )
        return false;

    const SwTabFrame* pTabFrame = pFrame->FindTabFrame();
diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx
index 8a6a664..a766596 100644
--- a/sw/source/core/frmedt/fetab.cxx
+++ b/sw/source/core/frmedt/fetab.cxx
@@ -535,18 +535,24 @@ bool SwFEShell::DeleteRow(bool bCompleteTable)
                if ( SwWrtShell* pWrtShell = dynamic_cast<SwWrtShell*>(this) )
                {
                    pWrtShell->SelectTableRow();
                    SwShellTableCursor* pTableCursor = GetTableCursor();
                    SwCursor* pTableCursor = static_cast<SwCursor*>(GetTableCursor());
                    auto pStt = aBoxes[0];
                    auto pEnd = aBoxes.back();
                    pTableCursor->DeleteMark();
                    if ( pTableCursor )
                        pTableCursor->DeleteMark();
                    else
                        pTableCursor = GetCursor(true);

                    // set start and end of the selection
                    pTableCursor->GetPoint()->Assign( *pEnd->GetSttNd()->EndOfSectionNode() );
                    pTableCursor->Move( fnMoveBackward, GoInContent );
                    pTableCursor->SetMark();
                    pTableCursor->GetPoint()->Assign( *pStt->GetSttNd()->EndOfSectionNode() );
                    pTableCursor->Move( fnMoveBackward, GoInContent );
                    pWrtShell->UpdateCursor();
                    if ( pTableCursor )
                    {
                        // set start and end of the selection
                        pTableCursor->GetPoint()->Assign( *pEnd->GetSttNd()->EndOfSectionNode() );
                        pTableCursor->Move( fnMoveBackward, GoInContent );
                        pTableCursor->SetMark();
                        pTableCursor->GetPoint()->Assign( *pStt->GetSttNd()->EndOfSectionNode() );
                        pTableCursor->Move( fnMoveBackward, GoInContent );
                        pWrtShell->UpdateCursor();
                    }
                }

                if (pEditShell)