diff options
author | Eike Rathke <erack@redhat.com> | 2016-07-28 18:51:01 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-07-28 19:25:36 +0000 |
commit | 7d40a0b8fcba1bda84c8e756d8000b92e768f9e2 (patch) | |
tree | 6993c794ca87d60c67e8e990c423a240e8b82b9b | |
parent | 6dfc4eb0163d501992d2f9726e4eec0565dd4eb0 (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
(cherry picked from commit 984b0d1599ff1672cb0d28019bd652d58d6bdefa)
Reviewed-on: https://gerrit.libreoffice.org/27647
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r-- | sc/source/ui/inc/viewdata.hxx | 3 | ||||
-rw-r--r-- | sc/source/ui/view/cellsh.cxx | 13 | ||||
-rw-r--r-- | sc/source/ui/view/viewdata.cxx | 12 | ||||
-rw-r--r-- | sc/source/ui/view/viewfun3.cxx | 3 |
4 files changed, 30 insertions, 1 deletions
diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx index 6657e83dfd07..c314a9d09731 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 f88274eb3419..6a11bfc22a3d 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 85dbb4627f52..f8283f3486cb 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 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) |