desktop/qa/data/empty.ods                   |binary
 desktop/qa/desktop_lib/test_desktop_lib.cxx |   43 ++++++++++++++++++++++++++++
 sc/source/ui/view/cellsh3.cxx               |    3 +
 3 files changed, 46 insertions(+)

New commits:
commit 0696b89daf811f2dad4fb33286eebc9c001b9c3b
Author:     Gökay Şatır <[email protected]>
AuthorDate: Wed Jul 16 14:45:10 2025 +0300
Commit:     Gökay ŞATIR <[email protected]>
CommitDate: Fri Sep 12 09:24:40 2025 +0200

    Call UpdateInputHandler after handling AcceptFormula uno command.
    
    Issue:
    On Online side, setting focus on the calc input bar doesn't allow to 
continue typing.
    
    Steps:
        1. open calc
        2. start typing into cell
        3. click "accept formula" button
        4. click again at formulabar
        5. try to type
    
    UpdateInputHandler finalizes the text editing and send notification back to 
the client.
    Also a test is added to ensure that formula bar gets "setText" event after 
sending "AcceptFormula" uno command.
    
    Signed-off-by: Gökay Şatır <[email protected]>
    Change-Id: I8e3a64753deeb908f7727b0473596f6f3c07ff4b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187959
    Reviewed-by: Miklos Vajna <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190803
    Reviewed-by: Gökay ŞATIR <[email protected]>
    Tested-by: Jenkins

diff --git a/desktop/qa/data/empty.ods b/desktop/qa/data/empty.ods
new file mode 100644
index 000000000000..8d9e14cf449c
Binary files /dev/null and b/desktop/qa/data/empty.ods differ
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 02ad4a2da30b..68dc0b6cbfa6 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -150,6 +150,7 @@ public:
     void testGetPartPageRectangles();
     void testSearchCalc();
     void testPropertySettingOnFormulaBar();
+    void testFormulaBarAcceptButton();
     void testSearchAllNotificationsCalc();
     void testPaintTile();
     void testSaveAs();
@@ -228,6 +229,7 @@ public:
     CPPUNIT_TEST(testGetPartPageRectangles);
     CPPUNIT_TEST(testSearchCalc);
     CPPUNIT_TEST(testPropertySettingOnFormulaBar);
+    CPPUNIT_TEST(testFormulaBarAcceptButton);
     CPPUNIT_TEST(testSearchAllNotificationsCalc);
     CPPUNIT_TEST(testPaintTile);
     CPPUNIT_TEST(testSaveAs);
@@ -3177,6 +3179,47 @@ void DesktopLOKTest::testPropertySettingOnFormulaBar()
     CPPUNIT_ASSERT_EQUAL(false, aView.m_stateBold); // This line doesn't pass 
without the fix in this commit.
 }
 
+void DesktopLOKTest::testFormulaBarAcceptButton()
+{
+    LibLibreOffice_Impl aOffice;
+    LibLODocument_Impl* pDocument = loadDoc("empty.ods");
+    Scheduler::ProcessEventsToIdle();
+
+    pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}");
+    Scheduler::ProcessEventsToIdle();
+
+    ViewCallback aView(pDocument);
+    Scheduler::ProcessEventsToIdle();
+
+    // Go to A1.
+    pDocument->pClass->postMouseEvent(pDocument, 
LOK_MOUSEEVENT_MOUSEBUTTONDOWN, 1000, 150, 1, 1, 0);
+    pDocument->pClass->postMouseEvent(pDocument, LOK_MOUSEEVENT_MOUSEBUTTONUP, 
1000, 150, 1, 1, 0);
+    Scheduler::ProcessEventsToIdle();
+
+    // Set the focus to formulabar.
+    pDocument->pClass->sendDialogEvent(pDocument, 0, 
"{\"id\":\"sc_input_window\", \"cmd\": \"grab_focus\", \"data\": \"null\", 
\"type\": \"drawingarea\"}");
+    Scheduler::ProcessEventsToIdle();
+
+    // Set selection (nothing selected).
+    pDocument->pClass->sendDialogEvent(pDocument, 0, 
"{\"id\":\"sc_input_window\", \"cmd\": \"textselection\", \"data\": 
\"0;0;0;0\", \"type\": \"drawingarea\"}");
+    Scheduler::ProcessEventsToIdle();
+
+    // Set text.
+    pDocument->pClass->postWindowExtTextInputEvent(pDocument, 0, 
LOK_EXT_TEXTINPUT, "H");
+    pDocument->pClass->postWindowExtTextInputEvent(pDocument, 0, 
LOK_EXT_TEXTINPUT_END, "H");
+    Scheduler::ProcessEventsToIdle();
+
+    aView.m_JSONDialog.clear();
+    pDocument->pClass->postUnoCommand(pDocument, ".uno:AcceptFormula", 
nullptr, false);
+    Scheduler::ProcessEventsToIdle();
+    // Client should have receive a JSDialog event for formulabar by now.
+
+    // These lines don't pass without the fix in this commit.
+    CPPUNIT_ASSERT_EQUAL(std::string("formulabar"), 
aView.m_JSONDialog.get_child("jsontype").get_value<std::string>());
+    CPPUNIT_ASSERT_EQUAL(std::string("setText"), 
aView.m_JSONDialog.get_child("data").get_child("action_type").get_value<std::string>());
+    CPPUNIT_ASSERT_EQUAL(std::string("sc_input_window"), 
aView.m_JSONDialog.get_child("data").get_child("control_id").get_value<std::string>());
+}
+
 void DesktopLOKTest::testRunMacro()
 {
     LibLibreOffice_Impl aOffice;
diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx
index 6f049ee43a06..e9ba63b4dec8 100644
--- a/sc/source/ui/view/cellsh3.cxx
+++ b/sc/source/ui/view/cellsh3.cxx
@@ -1069,7 +1069,10 @@ void ScCellShell::Execute( SfxRequest& rReq )
         case SID_ACCEPT_FORMULA:
             {
                 if (GetViewData().HasEditView(GetViewData().GetActivePart()))
+                {
                     pScMod->InputEnterHandler();
+                    pTabViewShell->UpdateInputHandler();
+                }
             }
             break;
 

Reply via email to