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 c8838d6dded9bcf77da657af50b48a7bfa90b85b
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:58:27 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>
    (cherry picked from commit 3009eebbad4b1d9883a68066d758a67eeaf3c379)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167946
    Tested-by: Jenkins

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 cea5554d2f5c..f184251132e3 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -3964,6 +3964,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 0b8dcb4b8f61..8b075bf45cbc 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -2212,14 +2212,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