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

merttumer (via logerrit) logerrit at kemper.freedesktop.org
Fri Jun 4 08:40:11 UTC 2021


 svx/source/table/tablecontroller.cxx |   30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

New commits:
commit 13f981e262b04f40c377d0e4fff717b57855d8a3
Author:     merttumer <mert.tumer at collabora.com>
AuthorDate: Mon May 17 05:52:01 2021 +0300
Commit:     Mert Tumer <mert.tumer at collabora.com>
CommitDate: Fri Jun 4 10:39:24 2021 +0200

    Implemented Delete key deletes the table when all the cells are selected
    
    Change-Id: I8a17c73781a3399b214d5655b83036652933a90a
    Signed-off-by: merttumer <mert.tumer at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115689
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116298
    Tested-by: Jenkins

diff --git a/svx/source/table/tablecontroller.cxx b/svx/source/table/tablecontroller.cxx
index 0f8faaa0fc6d..06aa2d615127 100644
--- a/svx/source/table/tablecontroller.cxx
+++ b/svx/source/table/tablecontroller.cxx
@@ -1425,30 +1425,44 @@ bool SvxTableController::DeleteMarked()
     SdrTableObj& rTableObj(*mxTableObj);
     SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
     const bool bUndo(rModel.IsUndoEnabled());
+    bool bDeleteTable = false;
 
     if (bUndo)
         rModel.BegUndo(SvxResId(STR_TABLE_DELETE_CELL_CONTENTS));
 
     CellPos aStart, aEnd;
     getSelectedCells( aStart, aEnd );
-    for( sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++ )
+    const sal_Int32 nRemovedColumns = aEnd.mnCol - aStart.mnCol + 1;
+    const sal_Int32 nRemovedRows = aEnd.mnRow - aStart.mnRow + 1;
+    if( nRemovedColumns == mxTable->getColumnCount() && nRemovedRows == mxTable->getRowCount())
     {
-        for( sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++ )
+        bDeleteTable = true;
+    }
+    else
+    {
+        for( sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++ )
         {
-            CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
-            if (xCell.is() && xCell->hasText())
+            for( sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++ )
             {
-                if (bUndo)
-                    xCell->AddUndo();
-                xCell->SetOutlinerParaObject(nullptr);
+                CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
+                if (xCell.is() && xCell->hasText())
+                {
+                    if (bUndo)
+                        xCell->AddUndo();
+                    xCell->SetOutlinerParaObject(nullptr);
+                }
             }
         }
     }
 
+    if (bDeleteTable)
+        mrView.DeleteMarkedObj();
+
     if (bUndo)
         rModel.EndUndo();
 
-    UpdateTableShape();
+    if (!bDeleteTable)
+        UpdateTableShape();
     return true;
 }
 


More information about the Libreoffice-commits mailing list