[Libreoffice-commits] core.git: 2 commits - sd/qa sd/source

Miklos Vajna vmiklos at collabora.co.uk
Thu Oct 15 07:56:45 PDT 2015


 sd/qa/unit/tiledrendering/data/search-all.odp |binary
 sd/qa/unit/tiledrendering/tiledrendering.cxx  |   26 ++++++++++++++++++++++++--
 sd/source/ui/view/Outliner.cxx                |   21 ++++++++++++++++++++-
 3 files changed, 44 insertions(+), 3 deletions(-)

New commits:
commit 6a35a75a6bb2753f40edf59f360130e452b3c7f0
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Oct 15 16:56:14 2015 +0200

    sd tiled rendering: implement CALLBACK_SET_PART for find-all
    
    Change-Id: I607b3719e0f508f9ae24db7482323847aa8e2491

diff --git a/sd/qa/unit/tiledrendering/data/search-all.odp b/sd/qa/unit/tiledrendering/data/search-all.odp
index cb3cb31..0fd069c 100644
Binary files a/sd/qa/unit/tiledrendering/data/search-all.odp and b/sd/qa/unit/tiledrendering/data/search-all.odp differ
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 89a2bf1..1073d14 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -421,12 +421,19 @@ void SdTiledRenderingTest::testSearch()
 void SdTiledRenderingTest::testSearchAll()
 {
     SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp");
+    pXImpressDocument->registerCallback(&SdTiledRenderingTest::callback, this);
 
     lcl_search("match", /*bFindAll=*/true);
 
     OString aUsedFormat;
     // This was empty: find-all did not highlight the first match.
     CPPUNIT_ASSERT_EQUAL(OString("match"), pXImpressDocument->getTextSelection("text/plain;charset=utf-8", aUsedFormat));
+
+    // We're on the first slide, search for something on the second slide and make sure we get a SET_PART.
+    m_nPart = 0;
+    lcl_search("second", /*bFindAll=*/true);
+    // This was 0: no SET_PART was emitted.
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), m_nPart);
 }
 
 #endif
diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index 8c79ac4..4ccd33c 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -667,6 +667,14 @@ bool Outliner::SearchAndReplaceAll()
     }
 
     RestoreStartPosition ();
+
+    if (mpSearchItem->GetCommand() == SvxSearchCmd::FIND_ALL && pViewShell->GetDoc()->isTiledRendering() && !bRet)
+    {
+        // Find-all, tiled rendering and we have at least one match.
+        OString aPayload = OString::number(mnStartPageIndex);
+        pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_SET_PART, aPayload.getStr());
+    }
+
     mnStartPageIndex = (sal_uInt16)-1;
 
     return bRet;
commit cd4976988cf3acb4f1a23f1df7fcc2bfec0f3da0
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Oct 15 15:20:23 2015 +0200

    sd tiled rendering: let find-all at least select the first match physically
    
    The LOK API can describe a multi-selection, so find-all can signal all
    matches, editeng can have a single selection only. Instead of having no
    selections after a find-all, select the first match, so e.g. copy works.
    
    Change-Id: I0eab2565916f0c3cce5d77279c0d927ad4b7054c

diff --git a/sd/qa/unit/tiledrendering/data/search-all.odp b/sd/qa/unit/tiledrendering/data/search-all.odp
new file mode 100644
index 0000000..cb3cb31
Binary files /dev/null and b/sd/qa/unit/tiledrendering/data/search-all.odp differ
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 4a5c81b..89a2bf1 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -23,6 +23,7 @@
 #include <editeng/outliner.hxx>
 #include <sfx2/dispatch.hxx>
 #include <sfx2/viewfrm.hxx>
+#include <svl/srchitem.hxx>
 
 #include <DrawDocShell.hxx>
 #include <ViewShell.hxx>
@@ -51,6 +52,7 @@ public:
     void testSetGraphicSelection();
     void testResetSelection();
     void testSearch();
+    void testSearchAll();
 #endif
 
     CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
@@ -63,6 +65,7 @@ public:
     CPPUNIT_TEST(testSetGraphicSelection);
     CPPUNIT_TEST(testResetSelection);
     CPPUNIT_TEST(testSearch);
+    CPPUNIT_TEST(testSearchAll);
 #endif
     CPPUNIT_TEST_SUITE_END();
 
@@ -371,12 +374,13 @@ void SdTiledRenderingTest::testResetSelection()
     CPPUNIT_ASSERT(!pView->GetTextEditObject());
 }
 
-static void lcl_search(const OUString& rKey)
+static void lcl_search(const OUString& rKey, bool bFindAll = false)
 {
     uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
     {
         {"SearchItem.SearchString", uno::makeAny(rKey)},
-        {"SearchItem.Backward", uno::makeAny(false)}
+        {"SearchItem.Backward", uno::makeAny(false)},
+        {"SearchItem.Command", uno::makeAny(static_cast<sal_uInt16>(bFindAll ? SvxSearchCmd::FIND_ALL : SvxSearchCmd::FIND))},
     }));
     comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues);
 }
@@ -414,6 +418,17 @@ void SdTiledRenderingTest::testSearch()
     CPPUNIT_ASSERT_EQUAL(false, m_bFound);
 }
 
+void SdTiledRenderingTest::testSearchAll()
+{
+    SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp");
+
+    lcl_search("match", /*bFindAll=*/true);
+
+    OString aUsedFormat;
+    // This was empty: find-all did not highlight the first match.
+    CPPUNIT_ASSERT_EQUAL(OString("match"), pXImpressDocument->getTextSelection("text/plain;charset=utf-8", aUsedFormat));
+}
+
 #endif
 
 CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest);
diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index 263ea6f..8c79ac4 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -593,6 +593,7 @@ void Outliner::Initialize (bool bDirectionIsForward)
 
 bool Outliner::SearchAndReplaceAll()
 {
+    bool bRet = true;
     // Save the current position to be restored after having replaced all
     // matches.
     RememberStartPosition ();
@@ -630,6 +631,16 @@ bool Outliner::SearchAndReplaceAll()
         do
         {
             bFoundMatch = ! SearchAndReplaceOnce(&aSelections);
+            if (mpSearchItem->GetCommand() == SvxSearchCmd::FIND_ALL && pViewShell->GetDoc()->isTiledRendering() && bFoundMatch && aSelections.size() == 1)
+            {
+                // Without this, RememberStartPosition() will think it already has a remembered position.
+                mnStartPageIndex = (sal_uInt16)-1;
+
+                RememberStartPosition();
+
+                // So when RestoreStartPosition() restores the first match, then spellchecker doesn't kill the selection.
+                bRet = false;
+            }
         }
         while (bFoundMatch);
 
@@ -658,7 +669,7 @@ bool Outliner::SearchAndReplaceAll()
     RestoreStartPosition ();
     mnStartPageIndex = (sal_uInt16)-1;
 
-    return true;
+    return bRet;
 }
 
 bool Outliner::SearchAndReplaceOnce(std::vector<SearchSelection>* pSelections)


More information about the Libreoffice-commits mailing list