[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.0' - desktop/qa sc/source

Miklos Vajna vmiklos at collabora.co.uk
Fri Jan 15 01:51:49 PST 2016


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

New commits:
commit 1dbb050657a7390e3d85aba88242253258e5966b
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
    
    (cherry picked from commit 61161254ab880f02a7a26822d45ff96ec7ca76c3)
    
    Change-Id: I787cd1760bca0bf7fbc3132579b569882ec25ae2

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index fa432de..87aaf2f 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -33,6 +33,7 @@
 #include <svl/srchitem.hxx>
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
 #include <unotools/tempfile.hxx>
+#include <vcl/svapp.hxx>
 
 #include "../../inc/lib/init.hxx"
 
@@ -42,7 +43,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)
     {
     }
 
@@ -73,6 +76,7 @@ public:
     void testGetFilterTypes();
     void testGetPartPageRectangles();
     void testSearchCalc();
+    void testSearchAllNotificationsCalc();
     void testPaintTile();
     void testSaveAs();
     void testSaveAsCalc();
@@ -88,6 +92,7 @@ public:
     CPPUNIT_TEST(testGetFilterTypes);
     CPPUNIT_TEST(testGetPartPageRectangles);
     CPPUNIT_TEST(testSearchCalc);
+    CPPUNIT_TEST(testSearchAllNotificationsCalc);
     CPPUNIT_TEST(testPaintTile);
     CPPUNIT_TEST(testSaveAs);
     CPPUNIT_TEST(testSaveAsCalc);
@@ -101,6 +106,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;
@@ -153,6 +160,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:
@@ -315,6 +326,32 @@ 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);
+    Application::Reschedule(true);
+    Scheduler::ProcessTaskScheduling(false);
+
+    // 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 b2ec3fd..b0f73bc 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -1830,7 +1830,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 )
     {
@@ -1882,6 +1885,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