[Libreoffice-commits] core.git: Branch 'libreoffice-5-2' - sc/source
Eike Rathke
erack at redhat.com
Sat Jul 30 20:33:54 UTC 2016
sc/source/ui/docshell/docfunc.cxx | 5 +++++
sc/source/ui/inc/viewdata.hxx | 2 ++
sc/source/ui/view/cellsh.cxx | 13 +++++++++++++
sc/source/ui/view/cellsh1.cxx | 6 ++++++
sc/source/ui/view/viewdata.cxx | 15 ++++++++++-----
5 files changed, 36 insertions(+), 5 deletions(-)
New commits:
commit d460db76504378ed7e0ec10cf3cdd9b5f2b354df
Author: Eike Rathke <erack at redhat.com>
Date: Fri Jul 29 13:30:07 2016 +0200
Resolves: tdf#60056 disallow Fill and Random when entire sheet is selected
This is a combination of 3 commits.
move range detection to ScViewData::SelectionFillDOOM()
(cherry picked from commit 4b90c9dc83d96908d3732d95e75c2f71d0f5d988)
Resolves: tdf#60056 disallow Fill when entire sheet is selected
(cherry picked from commit c729ee7622b1d54b2dc82b1807c68899efeab6d7)
disallow Random Number when entire sheet is selected, tdf#60056 related
(cherry picked from commit 77327759c9053da493430ee01b4d7fe98c174574)
866f84d72c27be962dbad8f8e4dcb345aa336bff
e9e229c3d3e5a5a7e3f3e90ebd181471927bd452
Change-Id: Ic5205428136fc323affed8d956d6ee0434d43988
Reviewed-on: https://gerrit.libreoffice.org/27690
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 6f923ba..4c4ede2 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -4604,6 +4604,11 @@ bool ScDocFunc::FillAuto( ScRange& rRange, const ScMarkData* pTabMark, FillDir e
return false;
}
+ // FID_FILL_... slots should already had been disabled, check here for API
+ // calls, no message.
+ if (ScViewData::SelectionFillDOOM( aDestArea))
+ return false;
+
WaitObject aWait( ScDocShell::GetActiveDialogParent() );
ScDocument* pUndoDoc = nullptr;
diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx
index c314a9d..75bcb41 100644
--- a/sc/source/ui/inc/viewdata.hxx
+++ b/sc/source/ui/inc/viewdata.hxx
@@ -345,6 +345,8 @@ public:
/// Disallow paste on Ctrl+A all selected. We'd go DOOM.
bool SelectionForbidsPaste();
+ /// Determine DOOM condition, i.e. from selected range.
+ static bool SelectionFillDOOM( const ScRange& rRange );
void SetFillMode( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow );
void SetDragMode( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx
index 6a11bfc..f8bcb6f 100644
--- a/sc/source/ui/view/cellsh.cxx
+++ b/sc/source/ui/view/cellsh.cxx
@@ -129,6 +129,8 @@ void ScCellShell::GetBlockState( SfxItemSet& rSet )
case FID_FILL_TO_BOTTOM: // fill to top / bottom
{
bDisable = !bSimpleArea || (nRow1 == 0 && nRow2 == 0);
+ if (!bDisable && GetViewData()->SelectionForbidsPaste())
+ bDisable = true;
if ( !bDisable && bEditable )
{ // do not damage matrix
bDisable = pDoc->HasSelectedBlockMatrixFragment(
@@ -139,6 +141,8 @@ void ScCellShell::GetBlockState( SfxItemSet& rSet )
case FID_FILL_TO_TOP:
{
bDisable = (!bSimpleArea) || (nRow1 == MAXROW && nRow2 == MAXROW);
+ if (!bDisable && GetViewData()->SelectionForbidsPaste())
+ bDisable = true;
if ( !bDisable && bEditable )
{ // do not damage matrix
bDisable = pDoc->HasSelectedBlockMatrixFragment(
@@ -149,6 +153,8 @@ void ScCellShell::GetBlockState( SfxItemSet& rSet )
case FID_FILL_TO_RIGHT: // fill to left / right
{
bDisable = !bSimpleArea || (nCol1 == 0 && nCol2 == 0);
+ if (!bDisable && GetViewData()->SelectionForbidsPaste())
+ bDisable = true;
if ( !bDisable && bEditable )
{ // do not damage matrix
bDisable = pDoc->HasSelectedBlockMatrixFragment(
@@ -159,6 +165,8 @@ void ScCellShell::GetBlockState( SfxItemSet& rSet )
case FID_FILL_TO_LEFT:
{
bDisable = (!bSimpleArea) || (nCol1 == MAXCOL && nCol2 == MAXCOL);
+ if (!bDisable && GetViewData()->SelectionForbidsPaste())
+ bDisable = true;
if ( !bDisable && bEditable )
{ // do not damage matrix
bDisable = pDoc->HasSelectedBlockMatrixFragment(
@@ -168,6 +176,8 @@ void ScCellShell::GetBlockState( SfxItemSet& rSet )
break;
case SID_RANDOM_NUMBER_GENERATOR_DIALOG:
+ bDisable = !bSimpleArea || GetViewData()->SelectionForbidsPaste();
+ break;
case SID_SAMPLING_DIALOG:
case SID_DESCRIPTIVE_STATISTICS_DIALOG:
case SID_ANALYSIS_OF_VARIANCE_DIALOG:
@@ -185,6 +195,9 @@ void ScCellShell::GetBlockState( SfxItemSet& rSet )
else
bDisable = (!bSimpleArea) || (nCol1 == nCol2 && nRow1 == nRow2);
+ if (!bDisable && GetViewData()->SelectionForbidsPaste())
+ bDisable = true;
+
if ( !bDisable && bEditable && nWhich == FID_FILL_SERIES )
{ // do not damage matrix
bDisable = pDoc->HasSelectedBlockMatrixFragment(
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 797bf86..10a3430 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -527,6 +527,12 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
case FID_FILL_SERIES:
{
+ if (GetViewData()->SelectionForbidsPaste())
+ // Slot should be already disabled, but in case it wasn't
+ // don't even attempt to do the evaluation and popup a
+ // dialog.
+ break;
+
SCCOL nStartCol;
SCROW nStartRow;
SCTAB nStartTab;
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index f8283f3..2364393 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -851,14 +851,19 @@ bool ScViewData::IsMultiMarked()
bool ScViewData::SelectionForbidsPaste()
{
- SCCOL nCol1, nCol2;
- SCROW nRow1, nRow2;
- SCTAB nTab1, nTab2;
- ScMarkType eMarkType = GetSimpleArea( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2);
+ ScRange aSelRange( ScAddress::UNINITIALIZED );
+ ScMarkType eMarkType = GetSimpleArea( aSelRange);
+ return eMarkType != SC_MARK_MULTI && SelectionFillDOOM( aSelRange);
+}
+
+// static
+bool ScViewData::SelectionFillDOOM( const ScRange& rRange )
+{
/* 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;
+ return rRange.aStart.Col() == 0 && rRange.aEnd.Col() == MAXCOL &&
+ rRange.aStart.Row() == 0 && rRange.aEnd.Row() == MAXROW;
}
void ScViewData::SetFillMode( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow )
More information about the Libreoffice-commits
mailing list