diff options
author | Pranav Kant <pranavk@collabora.com> | 2016-03-19 01:23:07 +0530 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2016-03-21 09:11:26 +0000 |
commit | 3dbcae4df48426ec6115ce4d3b5fa2afad96226b (patch) | |
tree | 84094217ceab552f08222d2d058e91bec01217ac | |
parent | 4bf2b6b2e6641c82e2b714e394482f1a1620b436 (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.
Change-Id: I7b338ca52505d59480209802ee65a6d64b0ac67d
Reviewed-on: https://gerrit.libreoffice.org/23364
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
-rw-r--r-- | sc/qa/unit/tiledrendering/tiledrendering.cxx | 28 | ||||
-rw-r--r-- | sc/source/ui/view/tabview3.cxx | 18 |
2 files changed, 32 insertions, 14 deletions
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index 539fe188ef99..574723e6a9a3 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -213,8 +213,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 a5db784f0a1a..cca5f6ca1004 100644 --- a/sc/source/ui/view/tabview3.cxx +++ b/sc/source/ui/view/tabview3.cxx @@ -1414,17 +1414,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 ); + InitBlockMode( nStartCol, 0, nTab, true, true); MarkCursor( nCol, MAXROW, nTab ); + bMoveIsShift = false; SetCursor( nCol, 0 ); SelectionChanged(); } @@ -1433,17 +1430,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(); } |