Kaydet (Commit) 07054b05 authored tarafından Miklos Vajna's avatar Miklos Vajna

sw tiled rendering: it's pointless to send selection changes during search all

Change-Id: Iad3436c74d0ff95c84b5da870124b1e335241ca2
üst 21af07a8
......@@ -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();
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment