desktop/qa/data/formulabar.ods              |binary
 desktop/qa/desktop_lib/test_desktop_lib.cxx |   59 +++++++++++++++++++++++++++-
 sc/source/ui/app/inputwin.cxx               |    2 
 3 files changed, 58 insertions(+), 3 deletions(-)

New commits:
commit 3b2ab8bee22bde4e2f379a6cdcc91fef44dfe96f
Author:     Gökay Şatır <gokaysa...@gmail.com>
AuthorDate: Mon Jul 14 12:30:53 2025 +0300
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue Jul 15 14:34:06 2025 +0200

    Online: This reverts fix for FormulaBar focus.
    
    Reverted commit: 6c1e3cd597cba07ff637173ab298794dba463054
    
    The reverted commit fixes issue:
    1. open calc
    2. start typing into cell
    3. click "accept formula" button
    4. click again at formulabar
    5. try to type
    
    result: no text is shown.
    
    After reverting the commit, the issue that the reverted commit targets is 
still not reproducible.
    
    The reason for the revert:
    * Select a word in formula bar.
    * Switch to / from bold text.
    * Click on another word on formulabar, without leaving the formulabar.
    * The switch from bold text gets cancelled.
    
    This commit also adds a test for the formula bar property reset issue.
    
    Signed-off-by: Gökay Şatır <gokaysa...@gmail.com>
    Change-Id: Ia219255ea4725276847490326a3ce55b4c8b714a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187898
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/desktop/qa/data/formulabar.ods b/desktop/qa/data/formulabar.ods
new file mode 100644
index 000000000000..ea099e24077c
Binary files /dev/null and b/desktop/qa/data/formulabar.ods differ
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 49fa3e5a4a5d..0f7806287c92 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -155,6 +155,7 @@ public:
     void testGetFilterTypes();
     void testGetPartPageRectangles();
     void testSearchCalc();
+    void testPropertySettingOnFormulaBar();
     void testSearchAllNotificationsCalc();
     void testPaintTile();
     void testSaveAs();
@@ -232,6 +233,7 @@ public:
     CPPUNIT_TEST(testGetFilterTypes);
     CPPUNIT_TEST(testGetPartPageRectangles);
     CPPUNIT_TEST(testSearchCalc);
+    CPPUNIT_TEST(testPropertySettingOnFormulaBar);
     CPPUNIT_TEST(testSearchAllNotificationsCalc);
     CPPUNIT_TEST(testPaintTile);
     CPPUNIT_TEST(testSaveAs);
@@ -2264,6 +2266,7 @@ public:
     bool m_bEmptyTableSelection;
     bool m_bTilesInvalidated;
     bool m_bZeroCursor;
+    bool m_stateBold;
     tools::Rectangle m_aOwnCursor;
     boost::property_tree::ptree m_aCommentCallbackResult;
     boost::property_tree::ptree m_aColorPaletteCallbackResult;
@@ -2274,7 +2277,8 @@ public:
           m_nTableSelectionCount(0),
           m_bEmptyTableSelection(false),
           m_bTilesInvalidated(false),
-          m_bZeroCursor(false)
+          m_bZeroCursor(false),
+          m_stateBold(false)
     {
         mnView = SfxLokHelper::getView();
         mpDocument->m_pDocumentClass->registerCallback(pDocument, 
&ViewCallback::callback, this);
@@ -2362,6 +2366,13 @@ public:
             m_aLastRedlineInfo = redlines[0];
         }
         break;
+        case LOK_CALLBACK_STATE_CHANGED:
+        {
+            if (aPayload.startsWith(".uno:Bold="))
+            {
+                m_stateBold = 
aPayload.copy(".uno:Bold="_ostr.getLength()).toBoolean();
+            }
+        }
         }
     }
 };
@@ -3127,6 +3138,52 @@ void 
DesktopLOKTest::testCalcValidityDropdownInReadonlyMode()
     CPPUNIT_ASSERT_EQUAL(true, aView.m_JSONDialog.empty());
 }
 
+void DesktopLOKTest::testPropertySettingOnFormulaBar()
+{
+    LibLibreOffice_Impl aOffice;
+    LibLODocument_Impl* pDocument = loadDoc("formulabar.ods");
+    Scheduler::ProcessEventsToIdle();
+
+    pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}");
+    Scheduler::ProcessEventsToIdle();
+
+    ViewCallback aView(pDocument);
+    Scheduler::ProcessEventsToIdle();
+
+    // Go to A1. There are 2 words in the cell.
+    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();
+
+    // Select the first word.
+    pDocument->pClass->sendDialogEvent(pDocument, 0, 
"{\"id\":\"sc_input_window\", \"cmd\": \"textselection\", \"data\": 
\"0;3;0;0\", \"type\": \"drawingarea\"}");
+    Scheduler::ProcessEventsToIdle();
+
+    // Set bold property for the selected word.
+    pDocument->pClass->postUnoCommand(pDocument, ".uno:Bold", nullptr, false);
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT_EQUAL(true, aView.m_stateBold);
+
+    // Select the second word. Without the fix, this selection removes the 
"bold" attribute.
+    pDocument->pClass->sendDialogEvent(pDocument, 0, 
"{\"id\":\"sc_input_window\", \"cmd\": \"textselection\", \"data\": 
\"4;9;0;0\", \"type\": \"drawingarea\"}");
+    Scheduler::ProcessEventsToIdle();
+
+    // Select the first word again.
+    pDocument->pClass->sendDialogEvent(pDocument, 0, 
"{\"id\":\"sc_input_window\", \"cmd\": \"textselection\", \"data\": 
\"0;3;0;0\", \"type\": \"drawingarea\"}");
+    Scheduler::ProcessEventsToIdle();
+
+    // Unset bold property for the selected word.
+    pDocument->pClass->postUnoCommand(pDocument, ".uno:Bold", nullptr, false);
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT_EQUAL(false, aView.m_stateBold); // This line doesn't pass 
without the fix in this commit.
+}
+
 void DesktopLOKTest::testRunMacro()
 {
     LibLibreOffice_Impl aOffice;
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 9f35d615039a..42589e193c42 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -1824,8 +1824,6 @@ bool ScTextWnd::Command( const CommandEvent& rCEvt )
             return true;
 
         ScModule* mod = ScModule::get();
-        // if we focus input after "Accept Formula" command, we need to notify 
to get it working
-        mod->InputChanged(m_xEditView.get());
 
         // information about paragraph is in additional data
         // information about position in a paragraph in a Mouse Pos

Reply via email to