desktop/qa/desktop_lib/test_desktop_lib.cxx | 60 ++++++++++++++++++++++++++++ svx/source/dialog/srchdlg.cxx | 36 ++++++++++------ 2 files changed, 83 insertions(+), 13 deletions(-)
New commits: commit b94016a09641fc0157f8af98697c7388cb288b2e Author: Gökay Şatır <[email protected]> AuthorDate: Wed Sep 17 15:57:49 2025 +0300 Commit: Andras Timar <[email protected]> CommitDate: Thu Sep 18 09:20:33 2025 +0200 cool#12896: Reset search string when Online is active. Issue: Core side remembers the last searched text but Online side may have multiple users at the same time. Other users see the current user's last searched text when they use search dialog. This commit resets the searched text every time to avoid the issue. Signed-off-by: Gökay Şatır <[email protected]> Change-Id: Iecf1cca6a2c9ce4b278cc6ebe68bb71dd9be9f4e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191089 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Andras Timar <[email protected]> (cherry picked from commit 36770166f551af6b87051cba95b0219238305ca1) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191110 Tested-by: Andras Timar <[email protected]> diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index b466e07532b6..df6976bbf21a 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -156,6 +156,7 @@ public: void testGetPartPageRectangles(); void testSearchCalc(); void testPropertySettingOnFormulaBar(); + void testSearchTermReset(); void testFormulaBarAcceptButton(); void testSearchAllNotificationsCalc(); void testPaintTile(); @@ -235,6 +236,7 @@ public: CPPUNIT_TEST(testGetPartPageRectangles); CPPUNIT_TEST(testSearchCalc); CPPUNIT_TEST(testPropertySettingOnFormulaBar); + CPPUNIT_TEST(testSearchTermReset); CPPUNIT_TEST(testFormulaBarAcceptButton); CPPUNIT_TEST(testSearchAllNotificationsCalc); CPPUNIT_TEST(testPaintTile); @@ -2274,6 +2276,8 @@ public: boost::property_tree::ptree m_aCommentCallbackResult; boost::property_tree::ptree m_aColorPaletteCallbackResult; RedlineInfo m_aLastRedlineInfo; + std::string m_searchTerm; + int m_findReplaceDialogId; ViewCallback(LibLODocument_Impl* pDocument) : mpDocument(pDocument), @@ -2356,6 +2360,27 @@ public: m_JSONDialog.clear(); std::stringstream aStream(pPayload); boost::property_tree::read_json(aStream, m_JSONDialog); + + if (m_JSONDialog.find("id") != m_JSONDialog.not_found() && m_JSONDialog.get_child("id").get_value<std::string>() == "FindReplaceDialog") + { + m_findReplaceDialogId = m_JSONDialog.get_child("lokWindowId").get_value<int>(); + } + if (m_JSONDialog.find("jsontype") != m_JSONDialog.not_found() && m_JSONDialog.get_child("jsontype").get_value<std::string>() == "dialog") + { + if (m_JSONDialog.find("data") != m_JSONDialog.not_found()) + { + if (m_JSONDialog.get_child("data").find("control_id") != m_JSONDialog.get_child("data").not_found()) + { + if (m_JSONDialog.get_child("data").get_child("control_id").get_value<std::string>() == "searchterm") + { + if (m_JSONDialog.get_child("data").find("text") != m_JSONDialog.get_child("data").not_found()) + { + m_searchTerm = m_JSONDialog.get_child("data").get_child("text").get_value<std::string>(); + } + } + } + } + } } break; case LOK_CALLBACK_REDLINE_TABLE_SIZE_CHANGED: @@ -3187,6 +3212,41 @@ void DesktopLOKTest::testPropertySettingOnFormulaBar() CPPUNIT_ASSERT_EQUAL(false, aView.m_stateBold); // This line doesn't pass without the fix in this commit. } +void DesktopLOKTest::testSearchTermReset() +{ + LibLibreOffice_Impl aOffice; + LibLODocument_Impl* pDocument = loadDoc("empty.ods"); + Scheduler::ProcessEventsToIdle(); + + pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}"); + Scheduler::ProcessEventsToIdle(); + + ViewCallback aView(pDocument); + Scheduler::ProcessEventsToIdle(); + + pDocument->pClass->postUnoCommand(pDocument, ".uno:SearchDialog", nullptr, false); + Scheduler::ProcessEventsToIdle(); + + // Send "something" as current search string (searchterm). + pDocument->pClass->sendDialogEvent(pDocument, aView.m_findReplaceDialogId, "{\"id\":\"searchterm\", \"cmd\": \"change\", \"data\": \"something\", \"type\": \"combobox\"}"); + Scheduler::ProcessEventsToIdle(); + + // Press search button. + pDocument->pClass->sendDialogEvent(pDocument, aView.m_findReplaceDialogId, "{\"id\":\"search\", \"cmd\": \"click\", \"data\": \"undefined\", \"type\": \"pushbutton\"}"); + Scheduler::ProcessEventsToIdle(); + + // Close the dialog. + pDocument->pClass->sendDialogEvent(pDocument, aView.m_findReplaceDialogId, "{\"id\":\"__DIALOG__\", \"cmd\": \"close\", \"data\": \"null\", \"type\": \"dialog\"}"); + Scheduler::ProcessEventsToIdle(); + + // Reopen search dialog. + pDocument->pClass->postUnoCommand(pDocument, ".uno:SearchDialog", nullptr, false); + Scheduler::ProcessEventsToIdle(); + + // We should have got the "searchterm" again. It should be empty. Below line doesn't pass without the changes in this commit. + CPPUNIT_ASSERT_EQUAL(std::string(""), aView.m_searchTerm); +} + void DesktopLOKTest::testFormulaBarAcceptButton() { LibLibreOffice_Impl aOffice; diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx index 9b2eff684252..466538a2f68b 100644 --- a/svx/source/dialog/srchdlg.cxx +++ b/svx/source/dialog/srchdlg.cxx @@ -311,6 +311,12 @@ SvxSearchDialog::SvxSearchDialog(weld::Window* pParent, SfxChildWindow* pChildWi { m_xCloseBtn->hide(); m_xHelpBtn->hide(); +<<<<<<< HEAD (b9e06e lok: use locale units for all dialogs) +======= + m_xSearchLB->set_entry_text(u""_ustr); + m_xReplaceLB->set_entry_text(u""_ustr); + m_xSearchLB->grab_focus(); +>>>>>>> CHANGE (367701 cool#12896: Reset search string when Online is active.) } m_aPresentIdle.SetTimeout(50); @@ -989,25 +995,29 @@ void SvxSearchDialog::Init_Impl( bool bSearchPattern ) bool bSetSearch = !( nModifyFlag & ModifyFlags::Search ); bool bSetReplace = !( nModifyFlag & ModifyFlags::Replace ); - if ( !(pSearchItem->GetSearchString().isEmpty()) && bSetSearch ) - m_xSearchLB->set_entry_text( pSearchItem->GetSearchString() ); - else if (!aSearchStrings.empty()) + if (!comphelper::LibreOfficeKit::isActive()) { - bool bAttributes = - ( ( pSearchList && pSearchList->Count() ) || - ( pReplaceList && pReplaceList->Count() ) ); + if ( !(pSearchItem->GetSearchString().isEmpty()) && bSetSearch ) + m_xSearchLB->set_entry_text( pSearchItem->GetSearchString() ); + else if (!aSearchStrings.empty()) + { + bool bAttributes = + ( ( pSearchList && pSearchList->Count() ) || + ( pReplaceList && pReplaceList->Count() ) ); - if ( bSetSearch && !bAttributes ) - m_xSearchLB->set_entry_text(aSearchStrings[0]); + if ( bSetSearch && !bAttributes ) + m_xSearchLB->set_entry_text(aSearchStrings[0]); - OUString aReplaceTxt = pSearchItem->GetReplaceString(); + OUString aReplaceTxt = pSearchItem->GetReplaceString(); - if (!aReplaceStrings.empty()) - aReplaceTxt = aReplaceStrings[0]; + if (!aReplaceStrings.empty()) + aReplaceTxt = aReplaceStrings[0]; - if ( bSetReplace && !bAttributes ) - m_xReplaceLB->set_entry_text( aReplaceTxt ); + if ( bSetReplace && !bAttributes ) + m_xReplaceLB->set_entry_text( aReplaceTxt ); + } } + m_xSearchLB->show(); if ( bConstruct )
