kbrown / rpms / libreoffice

Forked from rpms/libreoffice 2 years ago
Clone

Blame SOURCES/0177-LOK-add-the-search-phrase-to-the-search-result-count.patch

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