tdf#82404 - Move active cell to A1 when whole sheet is selected

Change-Id: Ic34a37a8a737954c2279c01bdd47c45bbdc70270
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205498
Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
Tested-by: Jenkins
This commit is contained in:
Andreas Heinisch
2026-05-22 07:49:42 +02:00
parent 47f593c865
commit eb9044babc
2 changed files with 21 additions and 6 deletions
+16
View File
@@ -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: */
+5 -6
View File
@@ -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()