[Libreoffice-commits] core.git: 2 commits - desktop/qa include/LibreOfficeKit sc/source sd/inc sd/qa sd/source sw/qa sw/source

Miklos Vajna vmiklos at collabora.co.uk
Wed Oct 14 06:40:09 PDT 2015


 desktop/qa/desktop_lib/test_desktop_lib.cxx    |    8 +++++++-
 include/LibreOfficeKit/LibreOfficeKitEnums.h   |   14 ++++++++++----
 sc/source/ui/view/viewfun2.cxx                 |    3 ++-
 sd/inc/Outliner.hxx                            |   16 +++++++++++++++-
 sd/qa/unit/tiledrendering/tiledrendering.cxx   |    9 ++++++++-
 sd/source/ui/view/Outliner.cxx                 |   20 ++++++++++++++------
 sw/qa/extras/tiledrendering/tiledrendering.cxx |    8 +++++++-
 sw/source/uibase/uiview/viewsrch.cxx           |    3 ++-
 8 files changed, 65 insertions(+), 16 deletions(-)

New commits:
commit ad280b67f8fda8f832a6a83bc5665df448c6ad00
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Oct 14 15:39:07 2015 +0200

    LOK: include part numbers in CALLBACK_SEARCH_RESULT_SELECTION payload
    
    Without that, the result in Calc/Impress is ambiguous.
    
    Change-Id: I8dfd8dafc996102ed583688fddd721c7600dc48c

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 6302ac4..2894809 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -74,6 +74,7 @@ public:
     uno::Reference<lang::XComponent> mxComponent;
     OString m_aTextSelection;
     std::vector<OString> m_aSearchResultSelection;
+    std::vector<int> m_aSearchResultPart;
 };
 
 LibLODocument_Impl* DesktopLOKTest::loadDoc(const char* pName, LibreOfficeKitDocumentType eType)
@@ -131,7 +132,10 @@ void DesktopLOKTest::callbackImpl(int nType, const char* pPayload)
         std::stringstream aStream(pPayload);
         boost::property_tree::read_json(aStream, aTree);
         for (boost::property_tree::ptree::value_type& rValue : aTree.get_child("searchResultSelection"))
-            m_aSearchResultSelection.push_back(rValue.second.data().c_str());
+        {
+            m_aSearchResultSelection.push_back(rValue.second.get<std::string>("rectangles").c_str());
+            m_aSearchResultPart.push_back(std::atoi(rValue.second.get<std::string>("part").c_str()));
+        }
     }
     break;
     }
@@ -269,6 +273,8 @@ void DesktopLOKTest::testSearchCalc()
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), aSelections.size());
     // Make sure that we get exactly as many rectangle lists as matches.
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), m_aSearchResultSelection.size());
+    // Result is on the first sheet.
+    CPPUNIT_ASSERT_EQUAL(0, m_aSearchResultPart[0]);
 
     closeDoc();
     comphelper::LibreOfficeKit::setActive(false);
diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index 0da8769..459da5d 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -165,14 +165,20 @@ typedef enum
      * {
      *     "searchString": "...",
      *     "searchResultSelection": [
-     *         "...",
-     *         "..."
+     *         {
+     *             "part": "...",
+     *             "rectangles": "..."
+     *         },
+     *         {
+     *             "part": "...",
+     *             "rectangles": "..."
+     *         }
      *     ]
      * }
      *
      * - searchString is the search query
-     * - searchResultSelection is an array of rectangle list, in
-     *   LOK_CALLBACK_TEXT_SELECTION format.
+     * - searchResultSelection is an array of part-number and rectangle list
+     *   pairs, in LOK_CALLBACK_SET_PART / LOK_CALLBACK_TEXT_SELECTION format.
      */
     LOK_CALLBACK_SEARCH_RESULT_SELECTION
 }
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index b306823..9f808d0 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -1865,7 +1865,8 @@ bool ScViewFunc::SearchAndReplace( const SvxSearchItem* pSearchItem,
                 for (const Rectangle& rLogicRect : aLogicRects)
                 {
                     boost::property_tree::ptree aSelection;
-                    aSelection.put("", rLogicRect.toString().getStr());
+                    aSelection.put("part", OString::number(nTab).getStr());
+                    aSelection.put("rectangles", rLogicRect.toString().getStr());
                     aSelections.push_back(std::make_pair("", aSelection));
                 }
                 aTree.add_child("searchResultSelection", aSelections);
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 1313b0a..4a5c81b 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -80,6 +80,7 @@ private:
     bool m_bFound;
     sal_Int32 m_nPart;
     std::vector<OString> m_aSearchResultSelection;
+    std::vector<int> m_aSearchResultPart;
 #endif
 };
 
@@ -187,11 +188,15 @@ void SdTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
     case LOK_CALLBACK_SEARCH_RESULT_SELECTION:
     {
         m_aSearchResultSelection.clear();
+        m_aSearchResultPart.clear();
         boost::property_tree::ptree aTree;
         std::stringstream aStream(pPayload);
         boost::property_tree::read_json(aStream, aTree);
         for (boost::property_tree::ptree::value_type& rValue : aTree.get_child("searchResultSelection"))
-            m_aSearchResultSelection.push_back(rValue.second.data().c_str());
+        {
+            m_aSearchResultSelection.push_back(rValue.second.get<std::string>("rectangles").c_str());
+            m_aSearchResultPart.push_back(std::atoi(rValue.second.get<std::string>("part").c_str()));
+        }
     }
     break;
     }
@@ -401,6 +406,8 @@ void SdTiledRenderingTest::testSearch()
     CPPUNIT_ASSERT_EQUAL(true, m_bFound);
     // This was 0; should be 1 match for "find".
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), m_aSearchResultSelection.size());
+    // Result is on the second slide.
+    CPPUNIT_ASSERT_EQUAL(1, m_aSearchResultPart[0]);
 
     // This should trigger the not-found callback.
     lcl_search("ccc");
diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index a18b022..f51c91f 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -637,7 +637,8 @@ bool Outliner::SearchAndReplaceAll()
             for (const SearchSelection& rSelection : aSelections)
             {
                 boost::property_tree::ptree aChild;
-                aChild.put("", rSelection.m_aRectangles.getStr());
+                aChild.put("part", OString::number(rSelection.m_nPage).getStr());
+                aChild.put("rectangles", rSelection.m_aRectangles.getStr());
                 aChildren.push_back(std::make_pair("", aChild));
             }
             aTree.add_child("searchResultSelection", aChildren);
@@ -764,7 +765,8 @@ bool Outliner::SearchAndReplaceOnce(std::vector<SearchSelection>* pSelections)
 
             boost::property_tree::ptree aChildren;
             boost::property_tree::ptree aChild;
-            aChild.put("", sRectangles.getStr());
+            aChild.put("part", OString::number(maCurrentPosition.mnPageIndex).getStr());
+            aChild.put("rectangles", sRectangles.getStr());
             aChildren.push_back(std::make_pair("", aChild));
             aTree.add_child("searchResultSelection", aChildren);
 
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index eb59b62..523c9d2 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -73,6 +73,7 @@ private:
     OString m_aTextSelection;
     bool m_bFound;
     std::vector<OString> m_aSearchResultSelection;
+    std::vector<int> m_aSearchResultPart;
 };
 
 SwTiledRenderingTest::SwTiledRenderingTest()
@@ -139,7 +140,10 @@ void SwTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
         std::stringstream aStream(pPayload);
         boost::property_tree::read_json(aStream, aTree);
         for (boost::property_tree::ptree::value_type& rValue : aTree.get_child("searchResultSelection"))
-            m_aSearchResultSelection.push_back(rValue.second.data().c_str());
+        {
+            m_aSearchResultSelection.push_back(rValue.second.get<std::string>("rectangles").c_str());
+            m_aSearchResultPart.push_back(std::atoi(rValue.second.get<std::string>("part").c_str()));
+        }
     }
     break;
     }
@@ -478,6 +482,8 @@ void SwTiledRenderingTest::testSearchAll()
     comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues);
     // This was 0; should be 2 results in the body text.
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), m_aSearchResultSelection.size());
+    // Writer documents are always a single part.
+    CPPUNIT_ASSERT_EQUAL(0, m_aSearchResultPart[0]);
 
     comphelper::LibreOfficeKit::setActive(false);
 #endif
diff --git a/sw/source/uibase/uiview/viewsrch.cxx b/sw/source/uibase/uiview/viewsrch.cxx
index e2b73f2..92d9076 100644
--- a/sw/source/uibase/uiview/viewsrch.cxx
+++ b/sw/source/uibase/uiview/viewsrch.cxx
@@ -96,7 +96,8 @@ static void lcl_addContainerToJson(boost::property_tree::ptree& rTree, const OSt
     for (const OString& rMatch : rMatches)
     {
         boost::property_tree::ptree aChild;
-        aChild.put("", rMatch.getStr());
+        aChild.put("part", "0");
+        aChild.put("rectangles", rMatch.getStr());
         aChildren.push_back(std::make_pair("", aChild));
     }
 
commit dd1fc2242a64a0b9ae8031a5edc7ecfcde4ec3df
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Oct 14 12:32:12 2015 +0200

    sd tiled rendering: search rectangle is part-specific
    
    Change-Id: I88865db539779bc401550d7b4a3729b89d7e18b1

diff --git a/sd/inc/Outliner.hxx b/sd/inc/Outliner.hxx
index a5bb966..931854d 100644
--- a/sd/inc/Outliner.hxx
+++ b/sd/inc/Outliner.hxx
@@ -39,6 +39,20 @@ class View;
 class ViewShell;
 class Window;
 
+/// Describes a single search hit: a set of rectangles on a given page.
+struct SearchSelection
+{
+    /// 0-based index of the page that has the selection.
+    int m_nPage;
+    /**
+     * List of selection rectangles in twips -- multiple rectangles only in
+     * case the selection spans over more layout lines.
+     */
+    OString m_aRectangles;
+
+    SearchSelection(int nPage, const OString& rRectangles);
+};
+
 /** The main purpose of this class is searching and replacing as well as
     spelling of impress documents.  The main part of both tasks lies in
     iterating over the pages and view modes of a document and apply the
@@ -357,7 +371,7 @@ private:
             The return value specifies whether the search ended (</sal_True>) or
             another call to this method is required (</sal_False>).
     */
-    bool SearchAndReplaceOnce(std::vector<OString>* pSelections = 0);
+    bool SearchAndReplaceOnce(std::vector<SearchSelection>* pSelections = 0);
 
     /** Detect changes of the document or view and react accordingly.  Such
         changes may occur because different calls to
diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index 45de021..a18b022 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -83,6 +83,12 @@ class SfxStyleSheetPool;
 
 namespace sd {
 
+SearchSelection::SearchSelection(int nPage, const OString& rRectangles)
+    : m_nPage(nPage),
+    m_aRectangles(rRectangles)
+{
+}
+
 class Outliner::Implementation
 {
 public:
@@ -615,7 +621,7 @@ bool Outliner::SearchAndReplaceAll()
 
         // Search/replace until the end of the document is reached.
         bool bFoundMatch;
-        std::vector<OString> aSelections;
+        std::vector<SearchSelection> aSelections;
         do
         {
             bFoundMatch = ! SearchAndReplaceOnce(&aSelections);
@@ -628,10 +634,10 @@ bool Outliner::SearchAndReplaceAll()
             aTree.put("searchString", mpSearchItem->GetSearchString().toUtf8().getStr());
 
             boost::property_tree::ptree aChildren;
-            for (const OString& rSelection : aSelections)
+            for (const SearchSelection& rSelection : aSelections)
             {
                 boost::property_tree::ptree aChild;
-                aChild.put("", rSelection.getStr());
+                aChild.put("", rSelection.m_aRectangles.getStr());
                 aChildren.push_back(std::make_pair("", aChild));
             }
             aTree.add_child("searchResultSelection", aChildren);
@@ -649,7 +655,7 @@ bool Outliner::SearchAndReplaceAll()
     return true;
 }
 
-bool Outliner::SearchAndReplaceOnce(std::vector<OString>* pSelections)
+bool Outliner::SearchAndReplaceOnce(std::vector<SearchSelection>* pSelections)
 {
     DetectChange ();
 
@@ -769,7 +775,7 @@ bool Outliner::SearchAndReplaceOnce(std::vector<OString>* pSelections)
         }
         else
         {
-            pSelections->push_back(sRectangles);
+            pSelections->push_back(SearchSelection(maCurrentPosition.mnPageIndex, sRectangles));
         }
     }
 


More information about the Libreoffice-commits mailing list