sw/qa/extras/tiledrendering/tiledrendering.cxx |   35 ++++++++++++++++++++++++-
 sw/source/core/crsr/viscrs.cxx                 |    3 +-
 sw/source/uibase/uiview/viewsrch.cxx           |    9 ++++++
 3 files changed, 45 insertions(+), 2 deletions(-)

New commits:
commit aa82ad378a78a039c3bc00da8df021d3a22697b3
Author: Miklos Vajna <vmik...@collabora.co.uk>
Date:   Fri Jan 15 08:24:09 2016 +0100

    sw tiled rendering: it's pointless to send selection changes during search 
all
    
    (cherry picked from commit 07054b050eb24442be92c1733aee27fe0a80ef69)
    
    Change-Id: Iad3436c74d0ff95c84b5da870124b1e335241ca2

diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 4901653..48757af 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -53,6 +53,7 @@ public:
     void testSearchTextFrameWrapAround();
     void testDocumentSizeChanged();
     void testSearchAll();
+    void testSearchAllNotifications();
 
     CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
     CPPUNIT_TEST(testRegisterCallback);
@@ -68,6 +69,7 @@ public:
     CPPUNIT_TEST(testSearchTextFrameWrapAround);
     CPPUNIT_TEST(testDocumentSizeChanged);
     CPPUNIT_TEST(testSearchAll);
+    CPPUNIT_TEST(testSearchAllNotifications);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -80,10 +82,14 @@ private:
     bool m_bFound;
     std::vector<OString> m_aSearchResultSelection;
     std::vector<int> m_aSearchResultPart;
+    int m_nSelectionBeforeSearchResult;
+    int m_nSelectionAfterSearchResult;
 };
 
 SwTiledRenderingTest::SwTiledRenderingTest()
-    : m_bFound(true)
+    : m_bFound(true),
+    m_nSelectionBeforeSearchResult(0),
+    m_nSelectionAfterSearchResult(0)
 {
 }
 
@@ -132,6 +138,10 @@ void SwTiledRenderingTest::callbackImpl(int nType, const 
char* pPayload)
     case LOK_CALLBACK_TEXT_SELECTION:
     {
         m_aTextSelection = pPayload;
+        if (m_aSearchResultSelection.empty())
+            ++m_nSelectionBeforeSearchResult;
+        else
+            ++m_nSelectionAfterSearchResult;
     }
     break;
     case LOK_CALLBACK_SEARCH_NOT_FOUND:
@@ -461,6 +471,29 @@ void SwTiledRenderingTest::testSearchAll()
     comphelper::LibreOfficeKit::setActive(false);
 }
 
+void SwTiledRenderingTest::testSearchAllNotifications()
+{
+    comphelper::LibreOfficeKit::setActive();
+    SwXTextDocument* pXTextDocument = createDoc("search.odt");
+    pXTextDocument->registerCallback(&SwTiledRenderingTest::callback, this);
+    uno::Sequence<beans::PropertyValue> 
aPropertyValues(comphelper::InitPropertySequence(
+    {
+        {"SearchItem.SearchString", uno::makeAny(OUString("shape"))},
+        {"SearchItem.Backward", uno::makeAny(false)},
+        {"SearchItem.Command", 
uno::makeAny(static_cast<sal_uInt16>(SvxSearchCmd::FIND_ALL))},
+    }));
+    comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues);
+    Application::Reschedule(true);
+    Scheduler::ProcessTaskScheduling(false);
+
+    // This was 5, make sure that we get no notifications about selection 
changes during search.
+    CPPUNIT_ASSERT_EQUAL(0, m_nSelectionBeforeSearchResult);
+    // But we do get the selection afterwards.
+    CPPUNIT_ASSERT(m_nSelectionAfterSearchResult > 0);
+
+    comphelper::LibreOfficeKit::setActive(false);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index ff37421..1a0d423 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -364,7 +364,8 @@ void SwSelPaintRects::Show(std::vector<OString>* 
pSelectionRectangles)
         // being edited.
         if (comphelper::LibreOfficeKit::isActive() && 
!pView->GetTextEditObject())
         {
-            if (!empty())
+            // If pSelectionRectangles is set, we're just collecting the text 
selections -> don't emit start/end.
+            if (!empty() && !pSelectionRectangles)
             {
                 // The selection may be a complex polygon, emit the logical
                 // start/end cursor rectangle of the selection as separate
diff --git a/sw/source/uibase/uiview/viewsrch.cxx 
b/sw/source/uibase/uiview/viewsrch.cxx
index 98d2925..f3f30ce 100644
--- a/sw/source/uibase/uiview/viewsrch.cxx
+++ b/sw/source/uibase/uiview/viewsrch.cxx
@@ -71,6 +71,8 @@
 #include <view.hrc>
 #include <SwRewriter.hxx>
 #include <comcore.hrc>
+#include <IDocumentDrawModelAccess.hxx>
+#include <drawdoc.hxx>
 
 #include "PostItMgr.hxx"
 
@@ -275,7 +277,14 @@ void SwView::ExecSearch(SfxRequest& rReq, bool bNoMessage)
             break;
             case SvxSearchCmd::FIND_ALL:
             {
+                // Disable LOK selection notifications during search.
+                SwDrawModel* pModel = 
m_pWrtShell->getIDocumentDrawModelAccess()->GetDrawModel();
+                if (pModel)
+                    pModel->setTiledSearching(true);
                 bool bRet = SearchAll();
+                if (pModel)
+                    pModel->setTiledSearching(false);
+
                 if( !bRet )
                 {
 #if HAVE_FEATURE_DESKTOP
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to