sc/qa/unit/tiledrendering/data/right-aligned-with-overflow.ods |binary sc/qa/unit/tiledrendering/tiledrendering.cxx | 30 ++++++++++ sc/source/ui/view/tabview3.cxx | 5 + 3 files changed, 33 insertions(+), 2 deletions(-)
New commits: commit 99966b82fbc9f88bca47eaeeb43109c1e38455e4 Author: Jaume Pujantell <jaume.pujant...@collabora.com> AuthorDate: Thu May 23 15:30:42 2024 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Mon May 27 11:43:01 2024 +0200 sc: don't overwrite Special Positioning on MakeEditView On LOK, calling UpdateEditPos after SetEditEngine overwrote the outer area of mpLOKSpecialPositioning, making the text show on the wrong position on right alined cells with overflowing content. Changing the order of the calls fixes that. Change-Id: I8ddb31103bb6f0bab1a9a6532af55797ef011214 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167991 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168030 diff --git a/sc/qa/unit/tiledrendering/data/right-aligned-with-overflow.ods b/sc/qa/unit/tiledrendering/data/right-aligned-with-overflow.ods new file mode 100644 index 000000000000..6a32fdc579c2 Binary files /dev/null and b/sc/qa/unit/tiledrendering/data/right-aligned-with-overflow.ods differ diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index 53a558b6ea52..1c3f58d7530d 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -185,6 +185,7 @@ public: void testEditShapeText(); void testCopyMultiSelection(); void testNumberFormatLocaleMultiUser(); + void testLeftOverflowEdit(); CPPUNIT_TEST_SUITE(ScTiledRenderingTest); CPPUNIT_TEST(testRowColumnHeaders); @@ -268,6 +269,7 @@ public: CPPUNIT_TEST(testEditShapeText); CPPUNIT_TEST(testCopyMultiSelection); CPPUNIT_TEST(testNumberFormatLocaleMultiUser); + CPPUNIT_TEST(testLeftOverflowEdit); CPPUNIT_TEST_SUITE_END(); private: @@ -4237,6 +4239,34 @@ void ScTiledRenderingTest::testNumberFormatLocaleMultiUser() } } +void ScTiledRenderingTest::testLeftOverflowEdit() +{ + comphelper::LibreOfficeKit::setCompatFlag(comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs); + ScModelObj* pModelObj = createDoc("right-aligned-with-overflow.ods"); + ViewCallback aView; + + // Go to Cell B5000 + uno::Sequence<beans::PropertyValue> aPropertyValues = { + comphelper::makePropertyValue("ToPoint", OUString("$B$5000")), + }; + dispatchCommand(mxComponent, ".uno:GoToCell", aPropertyValues); + + // Enter edit mode and select all text. + aView.m_aTextSelectionResult.clear(); + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::F2); + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::F2); + Scheduler::ProcessEventsToIdle(); + // CTRL + A + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_MOD1 | awt::Key::A); + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_MOD1 | awt::Key::A); + Scheduler::ProcessEventsToIdle(); + + // Without the accompanying fix this would fail with + // - Expected: 20 + // - Actual : 1300 + CPPUNIT_ASSERT_EQUAL(tools::Long(20), aView.m_aTextSelectionResult.m_aRefPoint.getX()); +} + } CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest); diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx index 8f5fe8ae13b8..94cff18abab5 100644 --- a/sc/source/ui/view/tabview3.cxx +++ b/sc/source/ui/view/tabview3.cxx @@ -2176,14 +2176,15 @@ void ScTabView::MakeEditView( ScEditEngineDefaulter* pEngine, SCCOL nCol, SCROW // MapMode must be set after HideCursor pGridWin[i]->SetMapMode(aViewData.GetLogicMode()); - aViewData.SetEditEngine( static_cast<ScSplitPos>(i), pEngine, pGridWin[i], nCol, nRow ); - if ( !bPosVisible ) { // move the edit view area to the real (possibly negative) position, // or hide if completely above or left of the window pGridWin[i]->UpdateEditViewPos(); } + + aViewData.SetEditEngine(static_cast<ScSplitPos>(i), pEngine, pGridWin[i], nCol, + nRow); } } }