sw/inc/strings.hrc | 1 + sw/inc/view.hxx | 2 +- sw/source/uibase/uiview/viewsrch.cxx | 23 ++++++++++++++++------- 3 files changed, 18 insertions(+), 8 deletions(-)
New commits: commit 218624bdf176010e18afc06b453b4535d7a00a04 Author: Jim Raykowski <rayk...@gmail.com> AuthorDate: Fri Sep 9 15:29:23 2022 -0800 Commit: Jim Raykowski <rayk...@gmail.com> CommitDate: Sun Sep 11 07:13:01 2022 +0200 tdf#126535 show search key found times in find and replace dialog search label Change-Id: I2850652896027ec04668d1fe3e0134c1ff53562e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139745 Tested-by: Jenkins Reviewed-by: Jim Raykowski <rayk...@gmail.com> diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc index 26d199336afa..81a54280d92c 100644 --- a/sw/inc/strings.hrc +++ b/sw/inc/strings.hrc @@ -1384,6 +1384,7 @@ #define STR_NUM_OUTLINE NC_("STR_NUM_OUTLINE", "Outline ") #define STR_EDIT_FOOTNOTE NC_("STR_EDIT_FOOTNOTE", "Edit Footnote/Endnote") #define STR_NB_REPLACED NC_("STR_NB_REPLACED", "Search key replaced XX times.") +#define STR_SEARCH_KEY_FOUND_TIMES NC_("STR_SEARCH_KEY_FOUND_TIMES", "Search key found %1 times.") #define STR_SRCVIEW_ROW NC_("STR_SRCVIEW_ROW", "Row ") #define STR_SRCVIEW_COL NC_("STR_SRCVIEW_COL", "Column ") #define STR_SAVEAS_SRC NC_("STR_SAVEAS_SRC", "~Export source...") diff --git a/sw/inc/view.hxx b/sw/inc/view.hxx index e348f74fd73e..45d38b0cf231 100644 --- a/sw/inc/view.hxx +++ b/sw/inc/view.hxx @@ -268,7 +268,7 @@ class SW_DLLPUBLIC SwView: public SfxViewShell // methods for searching // set search context SAL_DLLPRIVATE bool SearchAndWrap(bool bApi); - SAL_DLLPRIVATE bool SearchAll(); + SAL_DLLPRIVATE sal_uInt16 SearchAll(); SAL_DLLPRIVATE sal_uLong FUNC_Search( const SwSearchOptions& rOptions ); SAL_DLLPRIVATE void Replace(); diff --git a/sw/source/uibase/uiview/viewsrch.cxx b/sw/source/uibase/uiview/viewsrch.cxx index 7dd4ec1063f2..7559b7bf2fb8 100644 --- a/sw/source/uibase/uiview/viewsrch.cxx +++ b/sw/source/uibase/uiview/viewsrch.cxx @@ -251,7 +251,7 @@ void SwView::ExecSearch(SfxRequest& rReq) { // Disable LOK selection notifications during search. m_pWrtShell->GetSfxViewShell()->setTiledSearching(true); - bool bRet = SearchAll(); + const auto nFound = SearchAll(); m_pWrtShell->GetSfxViewShell()->setTiledSearching(false); GetDocShell()->Broadcast( @@ -259,7 +259,7 @@ void SwView::ExecSearch(SfxRequest& rReq) GetDocShell()->Broadcast( SfxHint(SfxHintId::SwNavigatorSelectOutlinesWithSelections)); - if( !bRet ) + if (nFound == 0) { #if HAVE_FEATURE_DESKTOP if( !bQuiet ) @@ -270,9 +270,18 @@ void SwView::ExecSearch(SfxRequest& rReq) #endif s_bFound = false; } - else if (comphelper::LibreOfficeKit::isActive()) - lcl_emitSearchResultCallbacks(s_pSrchItem, m_pWrtShell.get(), /* bHighlightAll = */ true); - rReq.SetReturnValue(SfxBoolItem(nSlot, bRet)); + else + { + if (comphelper::LibreOfficeKit::isActive()) + lcl_emitSearchResultCallbacks(s_pSrchItem, m_pWrtShell.get(), /* bHighlightAll = */ true); + if (!bQuiet) + { + OUString sText(SwResId(STR_SEARCH_KEY_FOUND_TIMES)); + sText = sText.replaceFirst("%1", OUString::number(nFound)); + SvxSearchDialogWrapper::SetSearchLabel(sText); + } + } + rReq.SetReturnValue(SfxBoolItem(nSlot, nFound != 0)); } break; case SvxSearchCmd::REPLACE: @@ -594,7 +603,7 @@ bool SwView::SearchAndWrap(bool bApi) return s_bFound; } -bool SwView::SearchAll() +sal_uInt16 SwView::SearchAll() { SwWait aWait( *GetDocShell(), true ); m_pWrtShell->StartAllAction(); @@ -616,7 +625,7 @@ bool SwView::SearchAll() s_bFound = 0 != nFound; m_pWrtShell->EndAllAction(); - return s_bFound; + return nFound; } void SwView::Replace()