sc/qa/unit/tiledrendering/data/right-aligned-with-overflow.ods |binary
 sc/qa/unit/tiledrendering/tiledrendering.cxx                   |   28 
++++++++++
 sc/source/ui/view/tabview3.cxx                                 |    5 +
 3 files changed, 31 insertions(+), 2 deletions(-)

New commits:
commit 3009eebbad4b1d9883a68066d758a67eeaf3c379
Author:     Jaume Pujantell <jaume.pujant...@collabora.com>
AuthorDate: Thu May 23 15:30:42 2024 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Fri May 24 14:24:33 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>

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 17048a4ca8df..a29abeb1ac00 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -4007,6 +4007,34 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, 
testNumberFormatLocaleMultiUser)
     }
 }
 
+CPPUNIT_TEST_FIXTURE(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_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index 8345ba9f42d0..602256a34900 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -2211,14 +2211,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);
             }
         }
     }

Reply via email to