summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-07-28 18:51:01 +0200
committerEike Rathke <erack@redhat.com>2016-07-28 19:04:08 +0200
commit984b0d1599ff1672cb0d28019bd652d58d6bdefa (patch)
tree2ecbcf72013f22886d3e85a9d92e13d003492b0e
parent4e85daeb78e9d9f290e49518b11efc2285f86713 (diff)
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
-rw-r--r--sc/source/ui/inc/viewdata.hxx3
-rw-r--r--sc/source/ui/view/cellsh.cxx13
-rw-r--r--sc/source/ui/view/viewdata.cxx12
-rw-r--r--sc/source/ui/view/viewfun3.cxx3
4 files changed, 30 insertions, 1 deletions
diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx
index a7446e1c854b..7c1c09834ca4 100644
--- a/sc/source/ui/inc/viewdata.hxx
+++ b/sc/source/ui/inc/viewdata.hxx
@@ -354,6 +354,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 96b82624a1c5..7379cdb94897 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 d188643b660c..d07f711c28be 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -854,6 +854,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 3facbf1951a8..f798690cb8a2 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)