[Libreoffice-commits] core.git: desktop/qa sc/source

Miklos Vajna vmiklos at collabora.co.uk
Fri Jan 15 01:38:00 PST 2016


 desktop/qa/desktop_lib/test_desktop_lib.cxx |   37 +++++++++++++++++++++++++++-
 sc/source/ui/view/viewfun2.cxx              |    6 ++++
 2 files changed, 42 insertions(+), 1 deletion(-)

New commits:
commit 61161254ab880f02a7a26822d45ff96ec7ca76c3
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Jan 15 10:06:33 2016 +0100

    sc tiled rendering: it's pointless to send selection changes during search all
    
    Change-Id: I787cd1760bca0bf7fbc3132579b569882ec25ae2

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 987ac1b..f069595 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 3beb225..e88e5da 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();
             }
         }
 


More information about the Libreoffice-commits mailing list