summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-01-15 10:06:33 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-01-15 10:37:31 +0100
commit61161254ab880f02a7a26822d45ff96ec7ca76c3 (patch)
tree8d7b565bef0bf0f8648d246c8aaf406cb1b832dc
parent79fa9bb77c702571de753c739e257ff6c27071ca (diff)
sc tiled rendering: it's pointless to send selection changes during search all
Change-Id: I787cd1760bca0bf7fbc3132579b569882ec25ae2
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx37
-rw-r--r--sc/source/ui/view/viewfun2.cxx6
2 files changed, 42 insertions, 1 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 987ac1be9618..f06959545722 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -36,7 +36,9 @@ using namespace desktop;
class DesktopLOKTest : public UnoApiTest
{
public:
- DesktopLOKTest() : UnoApiTest("/desktop/qa/data/")
+ DesktopLOKTest() : UnoApiTest("/desktop/qa/data/"),
+ m_nSelectionBeforeSearchResult(0),
+ m_nSelectionAfterSearchResult(0)
{
}
@@ -67,6 +69,7 @@ public:
void testGetFilterTypes();
void testGetPartPageRectangles();
void testSearchCalc();
+ void testSearchAllNotificationsCalc();
void testPaintTile();
void testSaveAs();
void testSaveAsCalc();
@@ -83,6 +86,7 @@ public:
CPPUNIT_TEST(testGetFilterTypes);
CPPUNIT_TEST(testGetPartPageRectangles);
CPPUNIT_TEST(testSearchCalc);
+ CPPUNIT_TEST(testSearchAllNotificationsCalc);
CPPUNIT_TEST(testPaintTile);
CPPUNIT_TEST(testSaveAs);
CPPUNIT_TEST(testSaveAsCalc);
@@ -97,6 +101,8 @@ public:
OString m_aTextSelection;
std::vector<OString> m_aSearchResultSelection;
std::vector<int> m_aSearchResultPart;
+ int m_nSelectionBeforeSearchResult;
+ int m_nSelectionAfterSearchResult;
// for testCommandResult
osl::Condition m_aCommandResultCondition;
@@ -149,6 +155,10 @@ void DesktopLOKTest::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_RESULT_SELECTION:
@@ -311,6 +321,31 @@ void DesktopLOKTest::testSearchCalc()
comphelper::LibreOfficeKit::setActive(false);
}
+void DesktopLOKTest::testSearchAllNotificationsCalc()
+{
+ LibLibreOffice_Impl aOffice;
+ comphelper::LibreOfficeKit::setActive();
+ LibLODocument_Impl* pDocument = loadDoc("search.ods");
+ pDocument->pClass->initializeForRendering(pDocument, nullptr);
+ pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
+
+ uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
+ {
+ {"SearchItem.SearchString", uno::makeAny(OUString("foo"))},
+ {"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 1, 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);
+}
+
void DesktopLOKTest::testPaintTile()
{
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 3beb225e8f9d..e88e5da8ba25 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -1820,7 +1820,10 @@ bool ScViewFunc::SearchAndReplace( const SvxSearchItem* pSearchItem,
}
}
+ // Avoid LOK selection notifications before we have all the results.
+ rDoc.GetDrawLayer()->setTiledSearching(true);
MarkDataChanged();
+ rDoc.GetDrawLayer()->setTiledSearching(false);
if ( bFound )
{
@@ -1872,6 +1875,9 @@ bool ScViewFunc::SearchAndReplace( const SvxSearchItem* pSearchItem,
boost::property_tree::write_json(aStream, aTree);
OString aPayload = aStream.str().c_str();
rDoc.GetDrawLayer()->libreOfficeKitCallback(LOK_CALLBACK_SEARCH_RESULT_SELECTION, aPayload.getStr());
+
+ // Trigger LOK_CALLBACK_TEXT_SELECTION now.
+ MarkDataChanged();
}
}