[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.0' - 10 commits - desktop/qa editeng/source include/editeng 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:57:25 PDT 2015


 desktop/qa/desktop_lib/test_desktop_lib.cxx    |    8 ++
 editeng/source/editeng/editview.cxx            |    5 +
 editeng/source/editeng/impedit.cxx             |   22 +++++-
 editeng/source/editeng/impedit.hxx             |    1 
 editeng/source/outliner/outlvw.cxx             |    5 +
 include/LibreOfficeKit/LibreOfficeKitEnums.h   |   14 ++--
 include/editeng/editview.hxx                   |    2 
 include/editeng/outliner.hxx                   |    1 
 sc/source/ui/view/viewfun2.cxx                 |    3 
 sd/inc/Outliner.hxx                            |   19 +++++
 sd/qa/unit/tiledrendering/tiledrendering.cxx   |   28 +++++++-
 sd/source/ui/inc/DrawViewShell.hxx             |    1 
 sd/source/ui/view/Outliner.cxx                 |   85 ++++++++++++++++++++++---
 sd/source/ui/view/sdwindow.cxx                 |    4 +
 sw/qa/extras/tiledrendering/tiledrendering.cxx |    8 ++
 sw/source/uibase/uiview/viewsrch.cxx           |    3 
 16 files changed, 184 insertions(+), 25 deletions(-)

New commits:
commit 5f0d16b1dc8db77aaca3d13091d61ad862648f49
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
    (cherry picked from commit ad280b67f8fda8f832a6a83bc5665df448c6ad00)

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index e77bc89..30d8ae7 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 2be84a4..95fd13a 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -1866,7 +1866,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 9aece07..33c3683 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 ff297a3..b5d394c 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -643,7 +643,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);
@@ -770,7 +771,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 c0a0458..30a2d0c 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 3eefa774e41d2f813044b67a363895e8328a76e5
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
    (cherry picked from commit dd1fc2242a64a0b9ae8031a5edc7ecfcde4ec3df)

diff --git a/sd/inc/Outliner.hxx b/sd/inc/Outliner.hxx
index f01e244..9f1f6aa 100644
--- a/sd/inc/Outliner.hxx
+++ b/sd/inc/Outliner.hxx
@@ -41,6 +41,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
@@ -364,7 +378,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 b694c49..ff297a3 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:
@@ -621,7 +627,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);
@@ -634,10 +640,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);
@@ -655,7 +661,7 @@ bool Outliner::SearchAndReplaceAll()
     return true;
 }
 
-bool Outliner::SearchAndReplaceOnce(std::vector<OString>* pSelections)
+bool Outliner::SearchAndReplaceOnce(std::vector<SearchSelection>* pSelections)
 {
     DetectChange ();
 
@@ -775,7 +781,7 @@ bool Outliner::SearchAndReplaceOnce(std::vector<OString>* pSelections)
         }
         else
         {
-            pSelections->push_back(sRectangles);
+            pSelections->push_back(SearchSelection(maCurrentPosition.mnPageIndex, sRectangles));
         }
     }
 
commit 6ed1d969bc10bacd2bb8dbaeb432e67955c89540
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Oct 14 11:38:47 2015 +0200

    sd tiled rendering: initial search all
    
    Change-Id: Icee3a07103fad1bf70637fbf23299f50b7ad838d
    (cherry picked from commit 32d573cdd13126c13e46b4e3684446e888e8b8e6)

diff --git a/sd/inc/Outliner.hxx b/sd/inc/Outliner.hxx
index 26ad349..f01e244 100644
--- a/sd/inc/Outliner.hxx
+++ b/sd/inc/Outliner.hxx
@@ -357,11 +357,14 @@ private:
     bool SearchAndReplaceAll();
 
     /** Do search and replace for next match.
+        @param pSelections
+            When tiled rendering and not 0, then don't emit LOK events, instead
+            assume the caller will do so.
         @return
             The return value specifies whether the search ended (</sal_True>) or
             another call to this method is required (</sal_False>).
     */
-    bool SearchAndReplaceOnce();
+    bool SearchAndReplaceOnce(std::vector<OString>* 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 a70ab9a..b694c49 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -490,7 +490,7 @@ bool Outliner::StartSearchAndReplace (const SvxSearchItem* pSearchItem)
         Initialize ( ! mpSearchItem->GetBackward());
 
         const SvxSearchCmd nCommand (mpSearchItem->GetCommand());
-        if (nCommand == SvxSearchCmd::REPLACE_ALL)
+        if (nCommand == SvxSearchCmd::FIND_ALL || nCommand == SvxSearchCmd::REPLACE_ALL)
             bEndOfSearch = SearchAndReplaceAll ();
         else
         {
@@ -621,11 +621,32 @@ bool Outliner::SearchAndReplaceAll()
 
         // Search/replace until the end of the document is reached.
         bool bFoundMatch;
+        std::vector<OString> aSelections;
         do
         {
-            bFoundMatch = ! SearchAndReplaceOnce();
+            bFoundMatch = ! SearchAndReplaceOnce(&aSelections);
         }
         while (bFoundMatch);
+
+        if (mpSearchItem->GetCommand() == SvxSearchCmd::FIND_ALL && pViewShell->GetDoc()->isTiledRendering() && !aSelections.empty())
+        {
+            boost::property_tree::ptree aTree;
+            aTree.put("searchString", mpSearchItem->GetSearchString().toUtf8().getStr());
+
+            boost::property_tree::ptree aChildren;
+            for (const OString& rSelection : aSelections)
+            {
+                boost::property_tree::ptree aChild;
+                aChild.put("", rSelection.getStr());
+                aChildren.push_back(std::make_pair("", aChild));
+            }
+            aTree.add_child("searchResultSelection", aChildren);
+
+            std::stringstream aStream;
+            boost::property_tree::write_json(aStream, aTree);
+            OString aPayload = aStream.str().c_str();
+            pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_SEARCH_RESULT_SELECTION, aPayload.getStr());
+        }
     }
 
     RestoreStartPosition ();
@@ -634,7 +655,7 @@ bool Outliner::SearchAndReplaceAll()
     return true;
 }
 
-bool Outliner::SearchAndReplaceOnce()
+bool Outliner::SearchAndReplaceOnce(std::vector<OString>* pSelections)
 {
     DetectChange ();
 
@@ -724,30 +745,38 @@ bool Outliner::SearchAndReplaceOnce()
 
     if (pViewShell && pViewShell->GetDoc()->isTiledRendering() && mbStringFound)
     {
-        // notify LibreOfficeKit about changed page
-        OString aPayload = OString::number(maCurrentPosition.mnPageIndex);
-        pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_SET_PART, aPayload.getStr());
-
-        // also about search result selections
         std::vector<Rectangle> aLogicRects;
         pOutlinerView->GetSelectionRectangles(aLogicRects);
 
-        boost::property_tree::ptree aTree;
-        aTree.put("searchString", mpSearchItem->GetSearchString().toUtf8().getStr());
-
         std::vector<OString> aLogicRectStrings;
         std::transform(aLogicRects.begin(), aLogicRects.end(), std::back_inserter(aLogicRectStrings), [](const Rectangle& rRectangle) { return rRectangle.toString(); });
         OString sRectangles = comphelper::string::join("; ", aLogicRectStrings);
-        boost::property_tree::ptree aChildren;
-        boost::property_tree::ptree aChild;
-        aChild.put("", sRectangles.getStr());
-        aChildren.push_back(std::make_pair("", aChild));
-        aTree.add_child("searchResultSelection", aChildren);
-
-        std::stringstream aStream;
-        boost::property_tree::write_json(aStream, aTree);
-        aPayload = aStream.str().c_str();
-        pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_SEARCH_RESULT_SELECTION, aPayload.getStr());
+
+        if (!pSelections)
+        {
+            // notify LibreOfficeKit about changed page
+            OString aPayload = OString::number(maCurrentPosition.mnPageIndex);
+            pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_SET_PART, aPayload.getStr());
+
+            // also about search result selections
+            boost::property_tree::ptree aTree;
+            aTree.put("searchString", mpSearchItem->GetSearchString().toUtf8().getStr());
+
+            boost::property_tree::ptree aChildren;
+            boost::property_tree::ptree aChild;
+            aChild.put("", sRectangles.getStr());
+            aChildren.push_back(std::make_pair("", aChild));
+            aTree.add_child("searchResultSelection", aChildren);
+
+            std::stringstream aStream;
+            boost::property_tree::write_json(aStream, aTree);
+            aPayload = aStream.str().c_str();
+            pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_SEARCH_RESULT_SELECTION, aPayload.getStr());
+        }
+        else
+        {
+            pSelections->push_back(sRectangles);
+        }
     }
 
     return mbEndOfSearch;
commit 675d86e88cc899d533cb9dccd292c07e375b8e4d
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Oct 13 16:38:37 2015 +0200

    CppunitTest_sd_tiledrendering: CALLBACK_SEARCH_RESULT_SELECTION testcase
    
    Change-Id: I8a2fcaad5806ef204cdac0f6eaac615d50d6d9e8
    (cherry picked from commit 28a5d4b5d3641837f3be8bc39ead111f9bba7015)

diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index c636e28..9aece07 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -7,6 +7,10 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+#include <test/bootstrapfixture.hxx>
+#include <unotest/macros_test.hxx>
+#include <test/xmltesttools.hxx>
+#include <boost/property_tree/json_parser.hpp>
 #define LOK_USE_UNSTABLE_API
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
 #include <com/sun/star/frame/Desktop.hpp>
@@ -19,9 +23,6 @@
 #include <editeng/outliner.hxx>
 #include <sfx2/dispatch.hxx>
 #include <sfx2/viewfrm.hxx>
-#include <test/bootstrapfixture.hxx>
-#include <test/xmltesttools.hxx>
-#include <unotest/macros_test.hxx>
 
 #include <DrawDocShell.hxx>
 #include <ViewShell.hxx>
@@ -78,6 +79,7 @@ private:
     std::vector<Rectangle> m_aSelection;
     bool m_bFound;
     sal_Int32 m_nPart;
+    std::vector<OString> m_aSearchResultSelection;
 #endif
 };
 
@@ -182,6 +184,16 @@ void SdTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
         m_nPart = aPayload.toInt32();
     }
     break;
+    case LOK_CALLBACK_SEARCH_RESULT_SELECTION:
+    {
+        m_aSearchResultSelection.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());
+    }
+    break;
     }
 }
 
@@ -387,6 +399,8 @@ void SdTiledRenderingTest::testSearch()
     lcl_search("bbb");
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), m_nPart);
     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());
 
     // This should trigger the not-found callback.
     lcl_search("ccc");
commit c46a29c2bc40229108d4c33523876b552d6fb24f
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Oct 13 15:55:55 2015 +0200

    sd tiled rendering: implement LOK_CALLBACK_SEARCH_RESULT_SELECTION
    
    Given that sd doesn't support find-all yet, this works for normal find
    only at the moment (so it may report multiple rectangles, but always a
    single match).
    
    Change-Id: I47bd0d0161b9d1dc843bb503f5521f311fc158c4
    (cherry picked from commit 395cfab05752b87ae419304789d894c0fe9a98c2)

diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index 6d59a70..a70ab9a 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -18,6 +18,7 @@
  */
 
 #include "Outliner.hxx"
+#include <boost/property_tree/json_parser.hpp>
 #include <vcl/wrkwin.hxx>
 #include <vcl/settings.hxx>
 
@@ -71,6 +72,7 @@
 #include <svx/svxids.hrc>
 #include <editeng/editerr.hxx>
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <comphelper/string.hxx>
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
@@ -720,11 +722,32 @@ bool Outliner::SearchAndReplaceOnce()
 
     mpDrawDocument->GetDocSh()->SetWaitCursor( false );
 
-    // notify LibreOfficeKit about changed page
     if (pViewShell && pViewShell->GetDoc()->isTiledRendering() && mbStringFound)
     {
+        // notify LibreOfficeKit about changed page
         OString aPayload = OString::number(maCurrentPosition.mnPageIndex);
         pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_SET_PART, aPayload.getStr());
+
+        // also about search result selections
+        std::vector<Rectangle> aLogicRects;
+        pOutlinerView->GetSelectionRectangles(aLogicRects);
+
+        boost::property_tree::ptree aTree;
+        aTree.put("searchString", mpSearchItem->GetSearchString().toUtf8().getStr());
+
+        std::vector<OString> aLogicRectStrings;
+        std::transform(aLogicRects.begin(), aLogicRects.end(), std::back_inserter(aLogicRectStrings), [](const Rectangle& rRectangle) { return rRectangle.toString(); });
+        OString sRectangles = comphelper::string::join("; ", aLogicRectStrings);
+        boost::property_tree::ptree aChildren;
+        boost::property_tree::ptree aChild;
+        aChild.put("", sRectangles.getStr());
+        aChildren.push_back(std::make_pair("", aChild));
+        aTree.add_child("searchResultSelection", aChildren);
+
+        std::stringstream aStream;
+        boost::property_tree::write_json(aStream, aTree);
+        aPayload = aStream.str().c_str();
+        pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_SEARCH_RESULT_SELECTION, aPayload.getStr());
     }
 
     return mbEndOfSearch;
commit b20dd57672d7fa54fcd7b507ea8ccec744d751a8
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Oct 13 15:54:56 2015 +0200

    editeng: add EditView::GetSelectionRectangles()
    
    This gives sd access to the selection rectangles as well (as opposed
    only to the document model positions of selections).
    
    Change-Id: Icb903e91f9e868573403b360bbe839705ddf2916
    (cherry picked from commit f7764214f2ab8aff030aaeb29efd693275822761)

diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index 049c5a1..66a49ed 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -264,6 +264,11 @@ SvtScriptType EditView::GetSelectedScriptType() const
     return pImpEditView->pEditEngine->GetScriptType( pImpEditView->GetEditSelection() );
 }
 
+void EditView::GetSelectionRectangles(std::vector<Rectangle>& rLogicRects) const
+{
+    return pImpEditView->GetSelectionRectangles(rLogicRects);
+}
+
 void EditView::Paint( const Rectangle& rRect, OutputDevice* pTargetDevice )
 {
     pImpEditView->pEditEngine->pImpEditEngine->Paint( pImpEditView, rRect, pTargetDevice );
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index 7fac113..f78cfab 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -185,12 +185,10 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
 
     // pRegion: When not NULL, then only calculate Region.
 
+    vcl::Region* pOldRegion = pRegion;
     vcl::Region aRegion;
-    if (isTiledRendering())
-    {
-        assert(!pRegion);
+    if (isTiledRendering() && !pRegion)
         pRegion = &aRegion;
-    }
 
     tools::PolyPolygon* pPolyPoly = NULL;
     if ( pRegion )
@@ -327,7 +325,7 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
     {
         *pRegion = vcl::Region( *pPolyPoly );
 
-        if (isTiledRendering())
+        if (isTiledRendering() && !pOldRegion)
         {
             bool bMm100ToTwip = pOutWin->GetMapMode().GetMapUnit() == MAP_100TH_MM;
             OString sRectangle;
@@ -379,6 +377,20 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
     }
 }
 
+void ImpEditView::GetSelectionRectangles(std::vector<Rectangle>& rLogicRects)
+{
+    bool bMm100ToTwip = pOutWin->GetMapMode().GetMapUnit() == MAP_100TH_MM;
+    vcl::Region aRegion;
+    DrawSelection(aEditSelection, &aRegion);
+    aRegion.GetRegionRectangles(rLogicRects);
+
+    for (Rectangle& rRectangle : rLogicRects)
+    {
+        if (bMm100ToTwip)
+            rRectangle = OutputDevice::LogicToLogic(rRectangle, MAP_100TH_MM, MAP_TWIP);
+    }
+}
+
 void ImpEditView::ImplDrawHighlightRect( OutputDevice* _pTarget, const Point& rDocPosTopLeft, const Point& rDocPosBottomRight, tools::PolyPolygon* pPolyPoly )
 {
     if ( rDocPosTopLeft.X() != rDocPosBottomRight.X() )
diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
index 4866523..7b24e6e 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -319,6 +319,7 @@ public:
 
     void            DrawSelection() { DrawSelection( aEditSelection ); }
     void            DrawSelection( EditSelection, vcl::Region* pRegion = NULL, OutputDevice* pTargetDevice = NULL );
+    void GetSelectionRectangles(std::vector<Rectangle>& rLogicRects);
 
     vcl::Window*         GetWindow() const           { return pOutWin; }
 
diff --git a/editeng/source/outliner/outlvw.cxx b/editeng/source/outliner/outlvw.cxx
index 92f9678..329b5f3 100644
--- a/editeng/source/outliner/outlvw.cxx
+++ b/editeng/source/outliner/outlvw.cxx
@@ -1213,6 +1213,11 @@ void OutlinerView::SetSelection( const ESelection& rSel )
     pEditView->SetSelection( rSel );
 }
 
+void OutlinerView::GetSelectionRectangles(std::vector<Rectangle>& rLogicRects) const
+{
+    pEditView->GetSelectionRectangles(rLogicRects);
+}
+
 void OutlinerView::SetReadOnly( bool bReadOnly )
 {
     pEditView->SetReadOnly( bReadOnly );
diff --git a/include/editeng/editview.hxx b/include/editeng/editview.hxx
index bb09117..41146fa 100644
--- a/include/editeng/editview.hxx
+++ b/include/editeng/editview.hxx
@@ -114,6 +114,8 @@ public:
     ESelection      GetSelection() const;
     void            SetSelection( const ESelection& rNewSel );
     bool            SelectCurrentWord( sal_Int16 nWordType = ::com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES );
+    /// Returns the rectangles of the current selection in TWIPs.
+    void GetSelectionRectangles(std::vector<Rectangle>& rLogicRects) const;
 
     bool            IsInsertMode() const;
     void            SetInsertMode( bool bInsert );
diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx
index 5a2dbe9..dddb221 100644
--- a/include/editeng/outliner.hxx
+++ b/include/editeng/outliner.hxx
@@ -310,6 +310,7 @@ public:
 
     void        SetVisArea( const Rectangle& rRect );
     void        SetSelection( const ESelection& );
+    void GetSelectionRectangles(std::vector<Rectangle>& rLogicRects) const;
 
     void        RemoveAttribs( bool bRemoveParaAttribs = false, sal_uInt16 nWhich = 0, bool bKeepLanguages = false );
     void        RemoveAttribsKeepLanguages( bool bRemoveParaAttribs );
commit a778dc1e24ba5581b91f833871d1f000fb73d9dc
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Oct 13 10:46:59 2015 +0200

    tdf#95002 sd tiled rendering: fix handling of images on page switch
    
    It turns out a full invalidation is still needed to trigger the loading
    of graphics on the new page, so instead of not invalidating just don't
    emit the notification about it during page switch.
    
    Change-Id: Ic99a3d4e268b3db61cf09c78ed0f310c9d365867
    (cherry picked from commit 1631fa9a722553da1ebe0650a65e859862c4405d)

diff --git a/include/svx/svdpagv.hxx b/include/svx/svdpagv.hxx
index 3b890c1..f28e3e7 100644
--- a/include/svx/svdpagv.hxx
+++ b/include/svx/svdpagv.hxx
@@ -224,7 +224,7 @@ public:
     const SetOfByte& GetLockedLayers() const { return aLayerLock; }
 
     const SdrHelpLineList& GetHelpLines() const { return aHelpLines; }
-    void SetHelpLines(const SdrHelpLineList& rHLL, bool bInvalidate = true);
+    void SetHelpLines(const SdrHelpLineList& rHLL);
     //void SetHelpLinePos(sal_uInt16 nNum, const Point& rNewPos);
     void SetHelpLine(sal_uInt16 nNum, const SdrHelpLine& rNewHelpLine);
     void DeleteHelpLine(sal_uInt16 nNum);
diff --git a/sd/source/ui/inc/DrawViewShell.hxx b/sd/source/ui/inc/DrawViewShell.hxx
index d77ece6..d83162b 100644
--- a/sd/source/ui/inc/DrawViewShell.hxx
+++ b/sd/source/ui/inc/DrawViewShell.hxx
@@ -378,6 +378,7 @@ public:
 
     const Color& GetAppBackgroundColor() const { return mnAppBackgroundColor; }
     void SetAppBackgroundColor( Color nNewColor )  { mnAppBackgroundColor = nNewColor; }
+    bool IsInSwitchPage() { return mbIsInSwitchPage; }
 
     //move this method to ViewShell.
     //void  NotifyAccUpdate();
diff --git a/sd/source/ui/view/drviews1.cxx b/sd/source/ui/view/drviews1.cxx
index b236177..6270438 100644
--- a/sd/source/ui/view/drviews1.cxx
+++ b/sd/source/ui/view/drviews1.cxx
@@ -999,8 +999,7 @@ bool DrawViewShell::SwitchPage(sal_uInt16 nSelectedPage)
                 }
                 else
                 {
-                    bool bInvalidate = !comphelper::LibreOfficeKit::isActive();
-                    pNewPageView->SetHelpLines( mpFrameView->GetStandardHelpLines(), bInvalidate );
+                    pNewPageView->SetHelpLines( mpFrameView->GetStandardHelpLines() );
                 }
             }
 
diff --git a/sd/source/ui/view/sdwindow.cxx b/sd/source/ui/view/sdwindow.cxx
index c9c4bfe..7149cf9 100644
--- a/sd/source/ui/view/sdwindow.cxx
+++ b/sd/source/ui/view/sdwindow.cxx
@@ -1006,6 +1006,10 @@ Selection Window::GetSurroundingTextSelection() const
 
 void Window::LogicInvalidate(const Rectangle* pRectangle)
 {
+    DrawViewShell* pDrawViewShell = dynamic_cast<DrawViewShell*>(mpViewShell);
+    if (pDrawViewShell && pDrawViewShell->IsInSwitchPage())
+        return;
+
     OString sRectangle;
     if (!pRectangle)
         sRectangle = "EMPTY";
diff --git a/svx/source/svdraw/svdpagv.cxx b/svx/source/svdraw/svdpagv.cxx
index 47fa8f5..9c74d43 100644
--- a/svx/source/svdraw/svdpagv.cxx
+++ b/svx/source/svdraw/svdpagv.cxx
@@ -741,11 +741,10 @@ void SdrPageView::ImpInvalidateHelpLineArea(sal_uInt16 nNum) const
     }
 }
 
-void SdrPageView::SetHelpLines(const SdrHelpLineList& rHLL, bool bInvalidate)
+void SdrPageView::SetHelpLines(const SdrHelpLineList& rHLL)
 {
     aHelpLines=rHLL;
-    if (bInvalidate)
-        InvalidateAllWin();
+    InvalidateAllWin();
 }
 
 void SdrPageView::SetHelpLine(sal_uInt16 nNum, const SdrHelpLine& rNewHelpLine)
commit 4357300aa9f786ebb548ffa056666d4fe53244a8
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Oct 12 14:25:18 2015 +0200

    sd tiled rendering: make invalidation in DrawViewShell::SwitchPage() optional
    
    In case of tiled rendering clients already get LOK_CALLBACK_SET_PART
    when switching slides, so it's pointless to additionally invalidate
    windows for help lines.
    
    Change-Id: Ibc15c9862ae85bd72328161fa5f7e72d82fd2a97
    (cherry picked from commit ca3436723455a0d0f3ced6f33b646b7c79ab05a1)

diff --git a/include/svx/svdpagv.hxx b/include/svx/svdpagv.hxx
index f28e3e7..3b890c1 100644
--- a/include/svx/svdpagv.hxx
+++ b/include/svx/svdpagv.hxx
@@ -224,7 +224,7 @@ public:
     const SetOfByte& GetLockedLayers() const { return aLayerLock; }
 
     const SdrHelpLineList& GetHelpLines() const { return aHelpLines; }
-    void SetHelpLines(const SdrHelpLineList& rHLL);
+    void SetHelpLines(const SdrHelpLineList& rHLL, bool bInvalidate = true);
     //void SetHelpLinePos(sal_uInt16 nNum, const Point& rNewPos);
     void SetHelpLine(sal_uInt16 nNum, const SdrHelpLine& rNewHelpLine);
     void DeleteHelpLine(sal_uInt16 nNum);
diff --git a/sd/source/ui/view/drviews1.cxx b/sd/source/ui/view/drviews1.cxx
index 6270438..b236177 100644
--- a/sd/source/ui/view/drviews1.cxx
+++ b/sd/source/ui/view/drviews1.cxx
@@ -999,7 +999,8 @@ bool DrawViewShell::SwitchPage(sal_uInt16 nSelectedPage)
                 }
                 else
                 {
-                    pNewPageView->SetHelpLines( mpFrameView->GetStandardHelpLines() );
+                    bool bInvalidate = !comphelper::LibreOfficeKit::isActive();
+                    pNewPageView->SetHelpLines( mpFrameView->GetStandardHelpLines(), bInvalidate );
                 }
             }
 
diff --git a/svx/source/svdraw/svdpagv.cxx b/svx/source/svdraw/svdpagv.cxx
index 9c74d43..47fa8f5 100644
--- a/svx/source/svdraw/svdpagv.cxx
+++ b/svx/source/svdraw/svdpagv.cxx
@@ -741,10 +741,11 @@ void SdrPageView::ImpInvalidateHelpLineArea(sal_uInt16 nNum) const
     }
 }
 
-void SdrPageView::SetHelpLines(const SdrHelpLineList& rHLL)
+void SdrPageView::SetHelpLines(const SdrHelpLineList& rHLL, bool bInvalidate)
 {
     aHelpLines=rHLL;
-    InvalidateAllWin();
+    if (bInvalidate)
+        InvalidateAllWin();
 }
 
 void SdrPageView::SetHelpLine(sal_uInt16 nNum, const SdrHelpLine& rNewHelpLine)
commit 3839eba175e2b4be1544ef02041f32c60398672e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Oct 12 11:53:02 2015 +0200

    sd: avoid unnecessary invalidations during search
    
    Search works by using sd::outliner::OutlinerContainer to iterate over
    all text objects of the document. We used to switch to each and every
    object, and only then search in it. In large presentations this means
    the number of invalidations during search was dependent on the number of
    slides between the current slide and the first match.
    
    Fix this by not calling sd::Outliner::SetObject() (which would call
    sd::Outliner::SetPage()) right after finding a text object, only later
    when we know it has matching content.
    
    The result is that the number of invalidations is not O(n) but O(1) till
    we find the first match.
    
    Change-Id: I29a11c8737a7e1db6a247eb98617d12495c8bb41
    (cherry picked from commit aa5f4bb22e6f6b38b60ee45d1079f2bc934c0611)

diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index e073118..6d59a70 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -957,7 +957,11 @@ void Outliner::ProvideNextTextObject()
             // Switch to the current object only if it is a valid text object.
             if (IsValidTextObject (maCurrentPosition))
             {
-                mpObj = SetObject (maCurrentPosition);
+                // Don't set yet in case of searching: the text object may not match.
+                if (meMode != SEARCH)
+                    mpObj = SetObject(maCurrentPosition);
+                else
+                    mpObj = maCurrentPosition.mxObject.get();
             }
             ++maObjectIterator;
 
@@ -983,6 +987,10 @@ void Outliner::ProvideNextTextObject()
         }
         else
         {
+            if (meMode == SEARCH)
+                // Instead of doing a full-blown SetObject(), which would do the same -- but would also possibly switch pages.
+                mbStringFound = false;
+
             mbEndOfSearch = true;
             EndOfSearch ();
         }
@@ -1175,6 +1183,9 @@ void Outliner::PrepareSearchAndReplace()
 {
     if (HasText( *mpSearchItem ))
     {
+        // Set the object now that we know it matches.
+        mpObj = SetObject(maCurrentPosition);
+
         mbStringFound = true;
         mbMatchMayExist = true;
 
commit d7db62b7cfe1b993f864c6b288ba6c924b5d4ac6
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Oct 12 11:34:31 2015 +0200

    Related: tdf#74132 CppunitTest_sd_export_tests: clean up testSearch()
    
    Not needed anymore since the dialog is gone.
    
    Change-Id: Icd3747683d2656a9404b405fc29aae6183dcfe15
    (cherry picked from commit 8d1d280741f62d60fe56cd86da995b08228a1594)

diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 8ed0919..c636e28 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -389,7 +389,6 @@ void SdTiledRenderingTest::testSearch()
     CPPUNIT_ASSERT_EQUAL(true, m_bFound);
 
     // This should trigger the not-found callback.
-    Application::EnableHeadlessMode(false);
     lcl_search("ccc");
     CPPUNIT_ASSERT_EQUAL(false, m_bFound);
 }


More information about the Libreoffice-commits mailing list