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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Feb 19 08:10:02 UTC 2019


 sw/qa/extras/uiwriter/uiwriter2.cxx  |   36 +++++++++++++++++++++++++++++++++++
 sw/source/uibase/uiview/viewsrch.cxx |    2 +
 2 files changed, 38 insertions(+)

New commits:
commit 9c1383e4da135db28c422752153e9a77558e8c2f
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Feb 18 21:50:53 2019 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Feb 19 09:09:40 2019 +0100

    tdf#101873 sw: fix search for second term after double not found
    
    Regression from commit 8d2fe8d7e5f374f3a106a4fc58ef597a52815ad0
    (SwView::SearchAndWrap: fix WrapAround search in fly frames,
    2015-06-03).
    
    The search implementation looks in the body text, then in case searching
    in extra content was not enabled already, it attempts to search there.
    
    The problem was that while the wrap-around implementation intended to do
    the same, it failed to unset the "search in extra" flag in case nothing
    was found, fix that now.
    
    Change-Id: Idf078e464824cad69c9709309435f2db207503b8
    Reviewed-on: https://gerrit.libreoffice.org/67986
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 0f1cb7f2ad9d..33b8ac9b53ed 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -60,6 +60,7 @@ public:
     void testTdf122901();
     void testTdf122942();
     void testTdf52391();
+    void testTdf101873();
 
     CPPUNIT_TEST_SUITE(SwUiWriterTest2);
     CPPUNIT_TEST(testRedlineMoveInsertInDelete);
@@ -81,6 +82,7 @@ public:
     CPPUNIT_TEST(testTdf122901);
     CPPUNIT_TEST(testTdf122942);
     CPPUNIT_TEST(testTdf52391);
+    CPPUNIT_TEST(testTdf101873);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -878,6 +880,40 @@ void SwUiWriterTest2::testTdf52391()
     CPPUNIT_ASSERT_EQUAL(OUString("Portion1Portion2"), xRun->getString());
 }
 
+void SwUiWriterTest2::testTdf101873()
+{
+    SwDoc* pDoc = createDoc();
+    CPPUNIT_ASSERT(pDoc);
+
+    SwDocShell* pDocShell = pDoc->GetDocShell();
+    CPPUNIT_ASSERT(pDocShell);
+
+    SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
+    CPPUNIT_ASSERT(pWrtShell);
+
+    // Insert some content.
+    pWrtShell->Insert("something");
+
+    // Search for something which does not exist, twice.
+    uno::Sequence<beans::PropertyValue> aFirst(comphelper::InitPropertySequence({
+        { "SearchItem.SearchString", uno::makeAny(OUString("fig")) },
+        { "SearchItem.Backward", uno::makeAny(false) },
+    }));
+    lcl_dispatchCommand(mxComponent, ".uno:ExecuteSearch", aFirst);
+    lcl_dispatchCommand(mxComponent, ".uno:ExecuteSearch", aFirst);
+
+    uno::Sequence<beans::PropertyValue> aSecond(comphelper::InitPropertySequence({
+        { "SearchItem.SearchString", uno::makeAny(OUString("something")) },
+        { "SearchItem.Backward", uno::makeAny(false) },
+    }));
+    lcl_dispatchCommand(mxComponent, ".uno:ExecuteSearch", aSecond);
+
+    // Without the accompanying fix in place, this test would have failed with "Expected: something;
+    // Actual:", i.e. searching for "something" failed, even if it was inserted above.
+    SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false);
+    CPPUNIT_ASSERT_EQUAL(OUString("something"), pShellCursor->GetText());
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest2);
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/uiview/viewsrch.cxx b/sw/source/uibase/uiview/viewsrch.cxx
index ca2aa004a257..a4c2f2d32582 100644
--- a/sw/source/uibase/uiview/viewsrch.cxx
+++ b/sw/source/uibase/uiview/viewsrch.cxx
@@ -608,6 +608,8 @@ bool SwView::SearchAndWrap(bool bApi)
         m_bExtra = true;
         if (FUNC_Search(aOpts))
             m_bFound = true;
+        else
+            m_bExtra = false;
     }
 
     m_pWrtShell->EndAllAction();


More information about the Libreoffice-commits mailing list