91a9b47
From ba2c708809f6cfd75ee597b2903507adb5d36aea Mon Sep 17 00:00:00 2001
91a9b47
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
91a9b47
Date: Tue, 1 Sep 2015 16:32:15 +0100
91a9b47
Subject: [PATCH] implement undo of delete impress cell contents
91a9b47
91a9b47
Change-Id: I7aa99f3a6668e66b8d02e20b7ea1cf0862e5d760
91a9b47
(cherry picked from commit d38e4b2ee73ad38881465f9f97eb8d8397ee98ff)
91a9b47
---
91a9b47
 include/svx/svdstr.hrc               |  1 +
91a9b47
 svx/source/svdraw/svdstr.src         |  5 +++++
91a9b47
 svx/source/table/tablecontroller.cxx | 15 +++++++++++++--
91a9b47
 3 files changed, 19 insertions(+), 2 deletions(-)
91a9b47
91a9b47
diff --git a/include/svx/svdstr.hrc b/include/svx/svdstr.hrc
91a9b47
index 90ef697..f45b55f 100644
91a9b47
--- a/include/svx/svdstr.hrc
91a9b47
+++ b/include/svx/svdstr.hrc
91a9b47
@@ -711,5 +711,6 @@
91a9b47
 #define STR_TABLE_STYLE                     (SIP_Begin + 274)
91a9b47
 #define STR_TABLE_STYLE_SETTINGS            (SIP_Begin + 275)
91a9b47
 #define SIP_SA_CROP_MARKERS                 (SIP_Begin + 276)
91a9b47
+#define STR_TABLE_DELETE_CELL_CONTENTS      (SIP_Begin + 277)
91a9b47
 
91a9b47
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
91a9b47
diff --git a/svx/source/svdraw/svdstr.src b/svx/source/svdraw/svdstr.src
91a9b47
index 364749a..c7977c1 100644
91a9b47
--- a/svx/source/svdraw/svdstr.src
91a9b47
+++ b/svx/source/svdraw/svdstr.src
91a9b47
@@ -2770,6 +2770,11 @@ String STR_TABLE_DISTRIBUTE_COLUMNS
91a9b47
     Text [ en-US ] = "Distribute columns" ;
91a9b47
 };
91a9b47
 
91a9b47
+String STR_TABLE_DELETE_CELL_CONTENTS
91a9b47
+{
91a9b47
+    Text [ en-US ] = "Delete cell contents" ;
91a9b47
+};
91a9b47
+
91a9b47
 String STR_TABLE_STYLE
91a9b47
 {
91a9b47
     Text [ en-US ] = "Table style" ;
91a9b47
diff --git a/svx/source/table/tablecontroller.cxx b/svx/source/table/tablecontroller.cxx
91a9b47
index d85a89c..4be8eb9 100644
91a9b47
--- a/svx/source/table/tablecontroller.cxx
91a9b47
+++ b/svx/source/table/tablecontroller.cxx
91a9b47
@@ -1302,6 +1302,10 @@ bool SvxTableController::DeleteMarked()
91a9b47
     {
91a9b47
         if( mxTable.is() )
91a9b47
         {
91a9b47
+            const bool bUndo = mpModel && mpModel->IsUndoEnabled();
91a9b47
+            if (bUndo)
91a9b47
+                mpModel->BegUndo(ImpGetResStr(STR_TABLE_DELETE_CELL_CONTENTS));
91a9b47
+
91a9b47
             CellPos aStart, aEnd;
91a9b47
             getSelectedCells( aStart, aEnd );
91a9b47
             for( sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++ )
91a9b47
@@ -1309,11 +1313,18 @@ bool SvxTableController::DeleteMarked()
91a9b47
                 for( sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++ )
91a9b47
                 {
91a9b47
                     CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
91a9b47
-                    if( xCell.is() )
91a9b47
-                        xCell->SetOutlinerParaObject( 0 );
91a9b47
+                    if (xCell.is() && xCell->hasText())
91a9b47
+                    {
91a9b47
+                        if (bUndo)
91a9b47
+                            xCell->AddUndo();
91a9b47
+                        xCell->SetOutlinerParaObject(0);
91a9b47
+                    }
91a9b47
                 }
91a9b47
             }
91a9b47
 
91a9b47
+            if (bUndo)
91a9b47
+                mpModel->EndUndo();
91a9b47
+
91a9b47
             UpdateTableShape();
91a9b47
             return true;
91a9b47
         }
91a9b47
-- 
91a9b47
2.4.0
91a9b47