summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorPranav Kant <pranavk@collabora.com>2016-03-19 01:23:07 +0530
committerAshod Nakashian <ashod.nakashian@collabora.co.uk>2016-07-20 01:26:01 -0400
commit31224ed0b55bfa6ae35813758f004fa4c75372f7 (patch)
tree7a96478911fdb94496f62cfe1061b9a4e2931a38 /sc
parent16807519d54a78db31623713a213b2f57a5ff796 (diff)
sc tiled rendering: Fix a corner case with shift modifier
With shift modifier, all rows/cols should get deselected upto the current cursor position from the last cursor position *if* the last cursor position *with* KEY_MOD1 resulted in a deselection of row or column. Added a unit test to support this. Reviewed-on: https://gerrit.libreoffice.org/23364 Reviewed-by: Jan Holesovsky <kendy@collabora.com> Tested-by: Jan Holesovsky <kendy@collabora.com> (cherry picked from commit 3dbcae4df48426ec6115ce4d3b5fa2afad96226b) Change-Id: I7b338ca52505d59480209802ee65a6d64b0ac67d
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/unit/tiledrendering/tiledrendering.cxx28
-rw-r--r--sc/source/ui/view/tabview3.cxx18
2 files changed, 32 insertions, 14 deletions
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 1ad67faaac51..e4d829a82592 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -220,8 +220,32 @@ void ScTiledRenderingTest::testRowColumnSelections()
// TODO check that we really selected what we wanted here
- // TODO: Add test for negative selection: .uno:SelectRow/Column on already
- // selected row/column should deselect it.
+ // Test for deselection of already selected rows
+ // First Deselect Row 13 because copy doesn't work for multiple selections
+ aArgs[0].Name = OUString::fromUtf8("Row");
+ aArgs[0].Value <<= static_cast<sal_Int32>(13 - 1);
+ aArgs[1].Name = OUString::fromUtf8("Modifier");
+ aArgs[1].Value <<= static_cast<sal_uInt16>(KEY_MOD1);
+ comphelper::dispatchCommand(".uno:SelectRow", aArgs);
+
+ // Deselect row 10
+ aArgs[0].Name = OUString::fromUtf8("Row");
+ aArgs[0].Value <<= static_cast<sal_Int32>(10 - 1);
+ aArgs[1].Name = OUString::fromUtf8("Modifier");
+ aArgs[1].Value <<= static_cast<sal_uInt16>(KEY_MOD1);
+ comphelper::dispatchCommand(".uno:SelectRow", aArgs);
+
+ // Click at row 6 holding shift
+ aArgs[0].Name = OUString::fromUtf8("Row");
+ aArgs[0].Value <<= static_cast<sal_Int32>(6 - 1);
+ aArgs[1].Name = OUString::fromUtf8("Modifier");
+ aArgs[1].Value <<= static_cast<sal_uInt16>(KEY_SHIFT);
+ comphelper::dispatchCommand(".uno:SelectRow", aArgs);
+
+ // only row 5 should remain selected
+ aResult = pModelObj->getTextSelection("text/plain;charset=utf-8", aUsedMimeType);
+ aExpected = "1\t2\t3\t4\t5\t6\t7\t8\t9\t10\t11\t12\t13\t14\t15\t16\t17\t18\t19\t20\t21\n";
+ CPPUNIT_ASSERT_EQUAL(aExpected, aResult);
comphelper::LibreOfficeKit::setActive(false);
}
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index 9334e36ea126..34c5ecb3f79a 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -1471,17 +1471,14 @@ void ScTabView::MarkColumns(SCCOL nCol, sal_Int16 nModifier)
{
SCCOL nStartCol = nCol;
SCTAB nTab = aViewData.GetTabNo();
- bool bTestNeg = true;
if ((nModifier & KEY_SHIFT) == KEY_SHIFT)
- {
- nStartCol = aViewData.GetCurX();
- bTestNeg = false;
- }
+ bMoveIsShift = true;
DoneBlockMode( nModifier != 0 );
- InitBlockMode( nStartCol, 0, nTab, bTestNeg, true, false );
+ InitBlockMode( nStartCol, 0, nTab, true, true);
MarkCursor( nCol, MAXROW, nTab );
+ bMoveIsShift = false;
SetCursor( nCol, 0 );
SelectionChanged();
}
@@ -1490,17 +1487,14 @@ void ScTabView::MarkRows(SCROW nRow, sal_Int16 nModifier)
{
SCROW nStartRow = nRow;
SCTAB nTab = aViewData.GetTabNo();
- bool bTestNeg = true;
if ((nModifier & KEY_SHIFT) == KEY_SHIFT)
- {
- nStartRow = aViewData.GetCurY();
- bTestNeg = false;
- }
+ bMoveIsShift = true;
DoneBlockMode( nModifier != 0 );
- InitBlockMode( 0, nStartRow, nTab, bTestNeg, false, true );
+ InitBlockMode( 0, nStartRow, nTab, true, false, true );
MarkCursor( MAXCOL, nRow, nTab );
+ bMoveIsShift = false;
SetCursor( 0, nRow );
SelectionChanged();
}