Blame SOURCES/0208-LOK-include-part-numbers-in-CALLBACK_SEARCH_RESULT_S.patch

f325b2
From 5cfe5701f287fcceee39cd2eb8ed403cda6eeea4 Mon Sep 17 00:00:00 2001
f325b2
From: Miklos Vajna <vmiklos@collabora.co.uk>
f325b2
Date: Wed, 14 Oct 2015 15:39:07 +0200
f325b2
Subject: [PATCH 208/398] LOK: include part numbers in
f325b2
 CALLBACK_SEARCH_RESULT_SELECTION payload
f325b2
f325b2
Without that, the result in Calc/Impress is ambiguous.
f325b2
f325b2
Change-Id: I8dfd8dafc996102ed583688fddd721c7600dc48c
f325b2
(cherry picked from commit ad280b67f8fda8f832a6a83bc5665df448c6ad00)
f325b2
---
f325b2
 desktop/qa/desktop_lib/test_desktop_lib.cxx    |  8 +++++++-
f325b2
 include/LibreOfficeKit/LibreOfficeKitEnums.h   | 14 ++++++++++----
f325b2
 sc/source/ui/view/viewfun2.cxx                 |  3 ++-
f325b2
 sd/qa/unit/tiledrendering/tiledrendering.cxx   |  9 ++++++++-
f325b2
 sd/source/ui/view/Outliner.cxx                 |  6 ++++--
f325b2
 sw/qa/extras/tiledrendering/tiledrendering.cxx |  8 +++++++-
f325b2
 sw/source/uibase/uiview/viewsrch.cxx           |  3 ++-
f325b2
 7 files changed, 40 insertions(+), 11 deletions(-)
f325b2
f325b2
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
f325b2
index e77bc8984bbf..30d8ae7adaf0 100644
f325b2
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
f325b2
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
f325b2
@@ -74,6 +74,7 @@ public:
f325b2
     uno::Reference<lang::XComponent> mxComponent;
f325b2
     OString m_aTextSelection;
f325b2
     std::vector<OString> m_aSearchResultSelection;
f325b2
+    std::vector<int> m_aSearchResultPart;
f325b2
 };
f325b2
 
f325b2
 LibLODocument_Impl* DesktopLOKTest::loadDoc(const char* pName, LibreOfficeKitDocumentType eType)
f325b2
@@ -131,7 +132,10 @@ void DesktopLOKTest::callbackImpl(int nType, const char* pPayload)
f325b2
         std::stringstream aStream(pPayload);
f325b2
         boost::property_tree::read_json(aStream, aTree);
f325b2
         for (boost::property_tree::ptree::value_type& rValue : aTree.get_child("searchResultSelection"))
f325b2
-            m_aSearchResultSelection.push_back(rValue.second.data().c_str());
f325b2
+        {
f325b2
+            m_aSearchResultSelection.push_back(rValue.second.get<std::string>("rectangles").c_str());
f325b2
+            m_aSearchResultPart.push_back(std::atoi(rValue.second.get<std::string>("part").c_str()));
f325b2
+        }
f325b2
     }
f325b2
     break;
f325b2
     }
f325b2
@@ -269,6 +273,8 @@ void DesktopLOKTest::testSearchCalc()
f325b2
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), aSelections.size());
f325b2
     // Make sure that we get exactly as many rectangle lists as matches.
f325b2
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), m_aSearchResultSelection.size());
f325b2
+    // Result is on the first sheet.
f325b2
+    CPPUNIT_ASSERT_EQUAL(0, m_aSearchResultPart[0]);
f325b2
 
f325b2
     closeDoc();
f325b2
     comphelper::LibreOfficeKit::setActive(false);
f325b2
diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h
f325b2
index 0da87699b1b5..459da5d196f4 100644
f325b2
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
f325b2
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
f325b2
@@ -165,14 +165,20 @@ typedef enum
f325b2
      * {
f325b2
      *     "searchString": "...",
f325b2
      *     "searchResultSelection": [
f325b2
-     *         "...",
f325b2
-     *         "..."
f325b2
+     *         {
f325b2
+     *             "part": "...",
f325b2
+     *             "rectangles": "..."
f325b2
+     *         },
f325b2
+     *         {
f325b2
+     *             "part": "...",
f325b2
+     *             "rectangles": "..."
f325b2
+     *         }
f325b2
      *     ]
f325b2
      * }
f325b2
      *
f325b2
      * - searchString is the search query
f325b2
-     * - searchResultSelection is an array of rectangle list, in
f325b2
-     *   LOK_CALLBACK_TEXT_SELECTION format.
f325b2
+     * - searchResultSelection is an array of part-number and rectangle list
f325b2
+     *   pairs, in LOK_CALLBACK_SET_PART / LOK_CALLBACK_TEXT_SELECTION format.
f325b2
      */
f325b2
     LOK_CALLBACK_SEARCH_RESULT_SELECTION
f325b2
 }
f325b2
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
f325b2
index 2be84a4c8e39..95fd13a1bf93 100644
f325b2
--- a/sc/source/ui/view/viewfun2.cxx
f325b2
+++ b/sc/source/ui/view/viewfun2.cxx
f325b2
@@ -1866,7 +1866,8 @@ bool ScViewFunc::SearchAndReplace( const SvxSearchItem* pSearchItem,
f325b2
                 for (const Rectangle& rLogicRect : aLogicRects)
f325b2
                 {
f325b2
                     boost::property_tree::ptree aSelection;
f325b2
-                    aSelection.put("", rLogicRect.toString().getStr());
f325b2
+                    aSelection.put("part", OString::number(nTab).getStr());
f325b2
+                    aSelection.put("rectangles", rLogicRect.toString().getStr());
f325b2
                     aSelections.push_back(std::make_pair("", aSelection));
f325b2
                 }
f325b2
                 aTree.add_child("searchResultSelection", aSelections);
f325b2
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
f325b2
index f35449b12b2c..62ad1cdcad7e 100644
f325b2
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
f325b2
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
f325b2
@@ -80,6 +80,7 @@ private:
f325b2
     bool m_bFound;
f325b2
     sal_Int32 m_nPart;
f325b2
     std::vector<OString> m_aSearchResultSelection;
f325b2
+    std::vector<int> m_aSearchResultPart;
f325b2
 #endif
f325b2
 };
f325b2
 
f325b2
@@ -187,11 +188,15 @@ void SdTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
f325b2
     case LOK_CALLBACK_SEARCH_RESULT_SELECTION:
f325b2
     {
f325b2
         m_aSearchResultSelection.clear();
f325b2
+        m_aSearchResultPart.clear();
f325b2
         boost::property_tree::ptree aTree;
f325b2
         std::stringstream aStream(pPayload);
f325b2
         boost::property_tree::read_json(aStream, aTree);
f325b2
         for (boost::property_tree::ptree::value_type& rValue : aTree.get_child("searchResultSelection"))
f325b2
-            m_aSearchResultSelection.push_back(rValue.second.data().c_str());
f325b2
+        {
f325b2
+            m_aSearchResultSelection.push_back(rValue.second.get<std::string>("rectangles").c_str());
f325b2
+            m_aSearchResultPart.push_back(std::atoi(rValue.second.get<std::string>("part").c_str()));
f325b2
+        }
f325b2
     }
f325b2
     break;
f325b2
     }
f325b2
@@ -401,6 +406,8 @@ void SdTiledRenderingTest::testSearch()
f325b2
     CPPUNIT_ASSERT_EQUAL(true, m_bFound);
f325b2
     // This was 0; should be 1 match for "find".
f325b2
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), m_aSearchResultSelection.size());
f325b2
+    // Result is on the second slide.
f325b2
+    CPPUNIT_ASSERT_EQUAL(1, m_aSearchResultPart[0]);
f325b2
 
f325b2
     // This should trigger the not-found callback.
f325b2
     Application::EnableHeadlessMode(false);
f325b2
diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
f325b2
index 22db187ab7c8..51635d5cba14 100644
f325b2
--- a/sd/source/ui/view/Outliner.cxx
f325b2
+++ b/sd/source/ui/view/Outliner.cxx
f325b2
@@ -643,7 +643,8 @@ bool Outliner::SearchAndReplaceAll()
f325b2
             for (const SearchSelection& rSelection : aSelections)
f325b2
             {
f325b2
                 boost::property_tree::ptree aChild;
f325b2
-                aChild.put("", rSelection.m_aRectangles.getStr());
f325b2
+                aChild.put("part", OString::number(rSelection.m_nPage).getStr());
f325b2
+                aChild.put("rectangles", rSelection.m_aRectangles.getStr());
f325b2
                 aChildren.push_back(std::make_pair("", aChild));
f325b2
             }
f325b2
             aTree.add_child("searchResultSelection", aChildren);
f325b2
@@ -770,7 +771,8 @@ bool Outliner::SearchAndReplaceOnce(std::vector<SearchSelection>* pSelections)
f325b2
 
f325b2
             boost::property_tree::ptree aChildren;
f325b2
             boost::property_tree::ptree aChild;
f325b2
-            aChild.put("", sRectangles.getStr());
f325b2
+            aChild.put("part", OString::number(maCurrentPosition.mnPageIndex).getStr());
f325b2
+            aChild.put("rectangles", sRectangles.getStr());
f325b2
             aChildren.push_back(std::make_pair("", aChild));
f325b2
             aTree.add_child("searchResultSelection", aChildren);
f325b2
 
f325b2
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
f325b2
index 5e2b30ab7fde..4598c50e5842 100644
f325b2
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
f325b2
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
f325b2
@@ -72,6 +72,7 @@ private:
f325b2
     OString m_aTextSelection;
f325b2
     bool m_bFound;
f325b2
     std::vector<OString> m_aSearchResultSelection;
f325b2
+    std::vector<int> m_aSearchResultPart;
f325b2
 };
f325b2
 
f325b2
 SwTiledRenderingTest::SwTiledRenderingTest()
f325b2
@@ -138,7 +139,10 @@ void SwTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
f325b2
         std::stringstream aStream(pPayload);
f325b2
         boost::property_tree::read_json(aStream, aTree);
f325b2
         for (boost::property_tree::ptree::value_type& rValue : aTree.get_child("searchResultSelection"))
f325b2
-            m_aSearchResultSelection.push_back(rValue.second.data().c_str());
f325b2
+        {
f325b2
+            m_aSearchResultSelection.push_back(rValue.second.get<std::string>("rectangles").c_str());
f325b2
+            m_aSearchResultPart.push_back(std::atoi(rValue.second.get<std::string>("part").c_str()));
f325b2
+        }
f325b2
     }
f325b2
     break;
f325b2
     }
f325b2
@@ -477,6 +481,8 @@ void SwTiledRenderingTest::testSearchAll()
f325b2
     comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues);
f325b2
     // This was 0; should be 2 results in the body text.
f325b2
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), m_aSearchResultSelection.size());
f325b2
+    // Writer documents are always a single part.
f325b2
+    CPPUNIT_ASSERT_EQUAL(0, m_aSearchResultPart[0]);
f325b2
 
f325b2
     comphelper::LibreOfficeKit::setActive(false);
f325b2
 #endif
f325b2
diff --git a/sw/source/uibase/uiview/viewsrch.cxx b/sw/source/uibase/uiview/viewsrch.cxx
f325b2
index 7f1addcc3f6b..53485eb9361b 100644
f325b2
--- a/sw/source/uibase/uiview/viewsrch.cxx
f325b2
+++ b/sw/source/uibase/uiview/viewsrch.cxx
f325b2
@@ -95,7 +95,8 @@ static void lcl_addContainerToJson(boost::property_tree::ptree& rTree, const OSt
f325b2
     for (const OString& rMatch : rMatches)
f325b2
     {
f325b2
         boost::property_tree::ptree aChild;
f325b2
-        aChild.put("", rMatch.getStr());
f325b2
+        aChild.put("part", "0");
f325b2
+        aChild.put("rectangles", rMatch.getStr());
f325b2
         aChildren.push_back(std::make_pair("", aChild));
f325b2
     }
f325b2
 
f325b2
-- 
f325b2
2.12.0
f325b2