diff --git a/sc/qa/unit/uicalc/uicalc2.cxx b/sc/qa/unit/uicalc/uicalc2.cxx index 38c4e0b6657f..1bacff12b971 100644 --- a/sc/qa/unit/uicalc/uicalc2.cxx +++ b/sc/qa/unit/uicalc/uicalc2.cxx @@ -2207,6 +2207,22 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest2, testTdf166791_PasteArrayOriginCellRefShiftin pMod->SetInputOptions(aInputOption); } +CPPUNIT_TEST_FIXTURE(ScUiCalcTest2, testTdf82404_SelectAllMoveActiveCell) +{ + createScDoc(); + ScDocShell* pDocSh = getScDocShell(); + + // Move to random cell and select entire sheet + goToCell(u"D5"_ustr); + dispatchCommand(mxComponent, u".uno:SelectAll"_ustr, {}); + + // Without the fix in place, this test would have failed with + // - Expected: A1 + // - Actual : D5 + // i.e. the active cell was not moved to A1 + checkCurrentCursorPosition(*pDocSh, u"A1"); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx index eaedba7e2b72..bd9a012f28b1 100644 --- a/sc/source/ui/view/tabview2.cxx +++ b/sc/source/ui/view/tabview2.cxx @@ -1293,17 +1293,16 @@ void ScTabView::SelectAll( bool bContinue ) ScMarkData& rMark = aViewData.GetMarkData(); SCTAB nTab = aViewData.CurrentTabForData(); + // Check if entire sheet is already selected + const ScRange aScRange(0, 0, nTab, rDoc.MaxCol(), rDoc.MaxRow(), nTab); if (rMark.IsMarked()) { - if ( rMark.GetMarkArea() == ScRange( 0,0,nTab, rDoc.MaxCol(),rDoc.MaxRow(),nTab ) ) + if (rMark.GetMarkArea() == aScRange) return; } - DoneBlockMode( bContinue ); - InitBlockMode( 0,0,nTab ); - MarkCursor( rDoc.MaxCol(),rDoc.MaxRow(),nTab ); - - SelectionChanged(); + // tdf#82404 - move active cell to A1 when whole sheet is selected + MarkRange(aScRange, true /* bSetCursor */, bContinue); } void ScTabView::SelectAllTables()