[Libreoffice-commits] core.git: Branch 'libreoffice-5-2' - sc/source

Eike Rathke erack at redhat.com
Thu Jul 28 19:26:03 UTC 2016


 sc/source/ui/inc/viewdata.hxx  |    3 +++
 sc/source/ui/view/cellsh.cxx   |   13 ++++++++++++-
 sc/source/ui/view/viewdata.cxx |   12 ++++++++++++
 sc/source/ui/view/viewfun3.cxx |    3 +++
 4 files changed, 30 insertions(+), 1 deletion(-)

New commits:
commit 7d40a0b8fcba1bda84c8e756d8000b92e768f9e2
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Jul 28 18:51:01 2016 +0200

    Resolves: tdf#60021 disallow Paste when entire sheet is selected
    
    ... which exhausts memory unless you have 100GB or more of free RAM.
    
    Change-Id: Ie6f02c48457f80acad33d2286194765f8343f2fb
    (cherry picked from commit 984b0d1599ff1672cb0d28019bd652d58d6bdefa)
    Reviewed-on: https://gerrit.libreoffice.org/27647
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx
index 6657e83..c314a9d 100644
--- a/sc/source/ui/inc/viewdata.hxx
+++ b/sc/source/ui/inc/viewdata.hxx
@@ -343,6 +343,9 @@ public:
 
     bool            IsMultiMarked();
 
+                    /// Disallow paste on Ctrl+A all selected. We'd go DOOM.
+    bool            SelectionForbidsPaste();
+
     void            SetFillMode( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow );
     void            SetDragMode( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
                                     ScFillMode nMode );
diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx
index f88274e..6a11bfc 100644
--- a/sc/source/ui/view/cellsh.cxx
+++ b/sc/source/ui/view/cellsh.cxx
@@ -205,6 +205,14 @@ void ScCellShell::GetBlockState( SfxItemSet& rSet )
                 bDisable = (!bSimpleArea);
                 break;
 
+            case SID_PASTE:
+            case SID_PASTE_SPECIAL:
+            case SID_PASTE_ONLY_VALUE:
+            case SID_PASTE_ONLY_TEXT:
+            case SID_PASTE_ONLY_FORMULA:
+                bDisable = GetViewData()->SelectionForbidsPaste();
+                break;
+
             case FID_INS_ROW:
             case FID_INS_ROWS_BEFORE:           // insert rows
             case FID_INS_ROWS_AFTER:
@@ -490,6 +498,9 @@ bool checkDestRanges(ScViewData& rViewData)
             return false;
     }
 
+    if (rViewData.SelectionForbidsPaste())
+        return false;
+
     // Multiple destination ranges.
 
     ScDocument* pDoc = rViewData.GetDocument();
@@ -552,7 +563,7 @@ void ScCellShell::GetClipState( SfxItemSet& rSet )
         if (!rDoc.IsBlockEditable( nTab, nCol,nRow, nCol,nRow ))
             bDisable = true;
 
-        if (!checkDestRanges(*GetViewData()))
+        if (!bDisable && !checkDestRanges(*GetViewData()))
             bDisable = true;
     }
 
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index 85dbb46..f8283f3 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -849,6 +849,18 @@ bool ScViewData::IsMultiMarked()
     return (eType & SC_MARK_SIMPLE) != SC_MARK_SIMPLE;
 }
 
+bool ScViewData::SelectionForbidsPaste()
+{
+    SCCOL nCol1, nCol2;
+    SCROW nRow1, nRow2;
+    SCTAB nTab1, nTab2;
+    ScMarkType eMarkType = GetSimpleArea( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2);
+    /* TODO: it is still possible to select one row less than the entire sheet
+     * and fool around. We could narrow this down to some "sane" value, just
+     * what would be sane? At least this helps against the Ctrl+A cases. */
+    return eMarkType != SC_MARK_MULTI && nCol1 == 0 && nCol2 == MAXCOL && nRow1 == 0 && nRow2 == MAXROW;
+}
+
 void ScViewData::SetFillMode( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow )
 {
     nFillMode   = ScFillMode::FILL;
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index 3facbf1..f798690 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -859,6 +859,9 @@ bool ScViewFunc::PasteFromClip( InsertDeleteFlags nFlags, ScDocument* pClipDoc,
         return false;
     }
 
+    if (GetViewData().SelectionForbidsPaste())
+        return false;
+
     //  undo: save all or no content
     InsertDeleteFlags nContFlags = InsertDeleteFlags::NONE;
     if (nFlags & InsertDeleteFlags::CONTENTS)


More information about the Libreoffice-commits mailing list