From 764878984eaaf6099dc2eb7dced5f6faa775bb8a Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 9 Oct 2015 08:08:48 +0200 Subject: [PATCH 197/398] LOK: CALLBACK_SEARCH_RESULT_COUNT is redundant 1) The size of the searchResultSelection array in LOK_CALLBACK_SEARCH_RESULT_SELECTION provides the same information. 2) None of the clients except lokdocview used it. 3) Only sw provided this callback, not sc/sd. Change-Id: I9da639b6693f24634f298f9bc4773f705e944359 (cherry picked from commit f0e3fe840b6f103c589f044bbde18b2faa345279) --- include/LibreOfficeKit/LibreOfficeKitEnums.h | 6 ------ libreofficekit/source/gtk/lokdocview.cxx | 14 ++++++-------- sw/qa/extras/tiledrendering/tiledrendering.cxx | 12 +----------- sw/source/uibase/uiview/viewsrch.cxx | 14 +++++--------- 4 files changed, 12 insertions(+), 34 deletions(-) diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h index b87f69a39989..0da87699b1b5 100644 --- a/include/LibreOfficeKit/LibreOfficeKitEnums.h +++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h @@ -158,12 +158,6 @@ typedef enum LOK_CALLBACK_SET_PART, /** - * Number of search results followed by the original searched phrase. - * count;phrase - */ - LOK_CALLBACK_SEARCH_RESULT_COUNT, - - /** * Selection rectangles of the search result when find all is performed. * * Payload format example, in case of two matches: diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index a40496eb7357..3f1d5815d05d 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -12,6 +12,7 @@ #include #include #include +#include #include #define LOK_USE_UNSTABLE_API @@ -227,8 +228,6 @@ callbackTypeToString (int nType) return "LOK_CALLBACK_STATUS_INDICATOR_FINISH"; case LOK_CALLBACK_SEARCH_NOT_FOUND: return "LOK_CALLBACK_SEARCH_NOT_FOUND"; - case LOK_CALLBACK_SEARCH_RESULT_COUNT: - return "LOK_CALLBACK_SEARCH_RESULT_COUNT"; case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED: return "LOK_CALLBACK_DOCUMENT_SIZE_CHANGED"; case LOK_CALLBACK_SET_PART: @@ -661,12 +660,6 @@ callback (gpointer pData) searchNotFound(pDocView, pCallback->m_aPayload); } break; - case LOK_CALLBACK_SEARCH_RESULT_COUNT: - { - size_t nPos = pCallback->m_aPayload.find_first_of(";"); - searchResultCount(pDocView, pCallback->m_aPayload.substr(0, nPos)); - } - break; case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED: { payloadToSize(pCallback->m_aPayload.c_str(), priv->m_nDocumentWidthTwips, priv->m_nDocumentHeightTwips); @@ -684,6 +677,11 @@ callback (gpointer pData) break; case LOK_CALLBACK_SEARCH_RESULT_SELECTION: { + boost::property_tree::ptree aTree; + std::stringstream aStream(pCallback->m_aPayload); + boost::property_tree::read_json(aStream, aTree); + int nCount = aTree.get_child("searchResultSelection").size(); + searchResultCount(pDocView, std::to_string(nCount)); } break; default: diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 1eb57dea109e..eb59b62b9208 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -72,13 +72,11 @@ private: Size m_aDocumentSize; OString m_aTextSelection; bool m_bFound; - sal_Int32 m_nSearchResultCount; std::vector m_aSearchResultSelection; }; SwTiledRenderingTest::SwTiledRenderingTest() - : m_bFound(true), - m_nSearchResultCount(0) + : m_bFound(true) { } @@ -134,12 +132,6 @@ void SwTiledRenderingTest::callbackImpl(int nType, const char* pPayload) m_bFound = false; } break; - case LOK_CALLBACK_SEARCH_RESULT_COUNT: - { - std::string aStrPayload(pPayload); - m_nSearchResultCount = std::stoi(aStrPayload.substr(0, aStrPayload.find_first_of(";"))); - } - break; case LOK_CALLBACK_SEARCH_RESULT_SELECTION: { m_aSearchResultSelection.clear(); @@ -485,8 +477,6 @@ void SwTiledRenderingTest::testSearchAll() })); comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues); // This was 0; should be 2 results in the body text. - CPPUNIT_ASSERT_EQUAL(static_cast(2), m_nSearchResultCount); - // Make sure that we get exactly as many rectangle lists as matches. CPPUNIT_ASSERT_EQUAL(static_cast(2), m_aSearchResultSelection.size()); comphelper::LibreOfficeKit::setActive(false); diff --git a/sw/source/uibase/uiview/viewsrch.cxx b/sw/source/uibase/uiview/viewsrch.cxx index c8d3e7a571ea..7f1addcc3f6b 100644 --- a/sw/source/uibase/uiview/viewsrch.cxx +++ b/sw/source/uibase/uiview/viewsrch.cxx @@ -103,11 +103,8 @@ static void lcl_addContainerToJson(boost::property_tree::ptree& rTree, const OSt } /// Emits LOK callbacks (count, selection) for search results. -static void lcl_emitSearchResultCallbacks(sal_uInt16 nFound, SvxSearchItem* pSearchItem, SwWrtShell* pWrtShell) +static void lcl_emitSearchResultCallbacks(SvxSearchItem* pSearchItem, SwWrtShell* pWrtShell) { - OString aPayload = OString::number(nFound) + ";" + pSearchItem->GetSearchString().toUtf8(); - pWrtShell->libreOfficeKitCallback(LOK_CALLBACK_SEARCH_RESULT_COUNT, aPayload.getStr()); - // Emit a callback also about the selection rectangles, grouped by matches. if (SwPaM* pPaM = pWrtShell->GetCrsr()) { @@ -141,7 +138,7 @@ static void lcl_emitSearchResultCallbacks(sal_uInt16 nFound, SvxSearchItem* pSea std::stringstream aStream; boost::property_tree::write_json(aStream, aTree); - aPayload = aStream.str().c_str(); + OString aPayload = aStream.str().c_str(); pWrtShell->libreOfficeKitCallback(LOK_CALLBACK_SEARCH_RESULT_SELECTION, aPayload.getStr()); } @@ -256,7 +253,7 @@ void SwView::ExecSearch(SfxRequest& rReq, bool bNoMessage) { Scroll(m_pWrtShell->GetCharRect().SVRect()); if (comphelper::LibreOfficeKit::isActive()) - lcl_emitSearchResultCallbacks(1, m_pSrchItem, m_pWrtShell); + lcl_emitSearchResultCallbacks(m_pSrchItem, m_pWrtShell); } rReq.SetReturnValue(SfxBoolItem(nSlot, bRet)); #if HAVE_FEATURE_DESKTOP @@ -275,8 +272,7 @@ void SwView::ExecSearch(SfxRequest& rReq, bool bNoMessage) break; case SvxSearchCmd::FIND_ALL: { - sal_uInt16 nFound = 0; - bool bRet = SearchAll(&nFound); + bool bRet = SearchAll(); if( !bRet ) { #if HAVE_FEATURE_DESKTOP @@ -290,7 +286,7 @@ void SwView::ExecSearch(SfxRequest& rReq, bool bNoMessage) m_bFound = false; } else if (comphelper::LibreOfficeKit::isActive()) - lcl_emitSearchResultCallbacks(nFound, m_pSrchItem, m_pWrtShell); + lcl_emitSearchResultCallbacks(m_pSrchItem, m_pWrtShell); rReq.SetReturnValue(SfxBoolItem(nSlot, bRet)); #if HAVE_FEATURE_DESKTOP { -- 2.12.0