summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-01-15 08:24:09 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-01-15 09:15:34 +0100
commitaa82ad378a78a039c3bc00da8df021d3a22697b3 (patch)
tree8d13bd5e6eb6ed67611dc8d8004714eeb7b7328d /sw
parentebbef33046b2f0b2a68a4f3b798e0cdf05b51c8a (diff)
sw tiled rendering: it's pointless to send selection changes during search all
(cherry picked from commit 07054b050eb24442be92c1733aee27fe0a80ef69) Change-Id: Iad3436c74d0ff95c84b5da870124b1e335241ca2
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx35
-rw-r--r--sw/source/core/crsr/viscrs.cxx3
-rw-r--r--sw/source/uibase/uiview/viewsrch.cxx9
3 files changed, 45 insertions, 2 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 490165389d3d..48757af68504 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 ff37421674c5..1a0d4233ad55 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 98d29251568e..f3f30ce7af7f 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