diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-01-15 08:24:09 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-01-15 08:54:04 +0100 |
commit | 07054b050eb24442be92c1733aee27fe0a80ef69 (patch) | |
tree | 7e6cb400c00e0b0e7f71aa98d7e428fb1e1d81f0 /sw | |
parent | 21af07a8bb152adfebf7dfea83ac7e698e37cb4b (diff) |
sw tiled rendering: it's pointless to send selection changes during search all
Change-Id: Iad3436c74d0ff95c84b5da870124b1e335241ca2
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 34 | ||||
-rw-r--r-- | sw/source/core/crsr/viscrs.cxx | 3 | ||||
-rw-r--r-- | sw/source/uibase/uiview/viewsrch.cxx | 9 |
3 files changed, 44 insertions, 2 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 0e5539c70bbf..6d5cb783a081 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -47,6 +47,7 @@ public: void testSearchTextFrameWrapAround(); void testDocumentSizeChanged(); void testSearchAll(); + void testSearchAllNotifications(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -62,6 +63,7 @@ public: CPPUNIT_TEST(testSearchTextFrameWrapAround); CPPUNIT_TEST(testDocumentSizeChanged); CPPUNIT_TEST(testSearchAll); + CPPUNIT_TEST(testSearchAllNotifications); CPPUNIT_TEST_SUITE_END(); private: @@ -74,10 +76,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) { } @@ -126,6 +132,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,28 @@ 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); + Scheduler::ProcessEventsToIdle(); + + // 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 50344ee42e9e..e25b3348f288 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 815fbba15430..8918ff12ff57 100644 --- a/sw/source/uibase/uiview/viewsrch.cxx +++ b/sw/source/uibase/uiview/viewsrch.cxx @@ -65,6 +65,8 @@ #include <view.hrc> #include <SwRewriter.hxx> #include <comcore.hrc> +#include <IDocumentDrawModelAccess.hxx> +#include <drawdoc.hxx> #include "PostItMgr.hxx" @@ -267,7 +269,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 |