From ec61694abf3a2fb70ce295ba87e18e196b6bbc3a Mon Sep 17 00:00:00 2001 From: Mihai Varga Date: Mon, 5 Oct 2015 17:07:06 +0300 Subject: [PATCH 177/398] LOK: add the search phrase to the search result count callback We need this to notify the user for which search phrase no results were found Change-Id: I8cc7ab235b9129dfdcb022145456180ff7e4ca92 (cherry picked from commit c30defcf8e34daec6ea0455d772fe296cc26ecc9) --- include/LibreOfficeKit/LibreOfficeKitEnums.h | 6 +++++- libreofficekit/source/gtk/lokdocview.cxx | 10 ++++++++++ sw/qa/extras/tiledrendering/tiledrendering.cxx | 4 +++- sw/source/uibase/uiview/viewsrch.cxx | 2 +- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h index dc3e0f94f3dc..97c089ffef50 100644 --- a/include/LibreOfficeKit/LibreOfficeKitEnums.h +++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h @@ -156,7 +156,11 @@ typedef enum * Payload is a single 0-based integer. */ LOK_CALLBACK_SET_PART, - /// Number of search results, in case something is found. + + /** + * Number of search results followed by the original searched phrase. + * count;phrase + */ LOK_CALLBACK_SEARCH_RESULT_COUNT } LibreOfficeKitCallbackType; diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index 0bd735088586..fa0386ba77f8 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -658,6 +658,16 @@ callback (gpointer pData) searchNotFound(pDocView, pCallback->m_aPayload); } break; + case LOK_CALLBACK_SEARCH_RESULT_COUNT: + { + size_t nPos = pCallback->m_aPayload.find_first_of(";"); + int nSearchResultCount = std::stoi(pCallback->m_aPayload.substr(0, nPos)); + if (nSearchResultCount == 0) + { + searchNotFound(pDocView, pCallback->m_aPayload.substr(nPos + 1)); + } + } + break; case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED: { payloadToSize(pCallback->m_aPayload.c_str(), priv->m_nDocumentWidthTwips, priv->m_nDocumentHeightTwips); diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index c836f4bc5eab..bcc328e366a3 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -23,6 +23,7 @@ #include #include #include +#include static const char* DATA_DIRECTORY = "/sw/qa/extras/tiledrendering/data/"; @@ -132,7 +133,8 @@ void SwTiledRenderingTest::callbackImpl(int nType, const char* pPayload) break; case LOK_CALLBACK_SEARCH_RESULT_COUNT: { - m_nSearchResultCount = OString(pPayload).toInt32(); + std::string aStrPayload(pPayload); + m_nSearchResultCount = std::stoi(aStrPayload.substr(0, aStrPayload.find_first_of(";"))); } break; } diff --git a/sw/source/uibase/uiview/viewsrch.cxx b/sw/source/uibase/uiview/viewsrch.cxx index 11764126e165..3ccc852065fb 100644 --- a/sw/source/uibase/uiview/viewsrch.cxx +++ b/sw/source/uibase/uiview/viewsrch.cxx @@ -225,7 +225,7 @@ void SwView::ExecSearch(SfxRequest& rReq, bool bNoMessage) } else { - OString aPayload = OString::number(nFound); + OString aPayload = OString::number(nFound) + ";" + m_pSrchItem->GetSearchString().toUtf8(); m_pWrtShell->libreOfficeKitCallback(LOK_CALLBACK_SEARCH_RESULT_COUNT, aPayload.getStr()); } rReq.SetReturnValue(SfxBoolItem(nSlot, bRet)); -- 2.12.0