summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx32
-rw-r--r--sw/source/uibase/uiview/viewsrch.cxx15
2 files changed, 45 insertions, 2 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index ba8237e61699..b139b16a7d66 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -26,6 +26,7 @@ static const char* DATA_DIRECTORY = "/sw/qa/extras/tiledrendering/data/";
class SwTiledRenderingTest : public SwModelTestBase
{
public:
+ SwTiledRenderingTest();
void testRegisterCallback();
void testPostKeyEvent();
void testPostMouseEvent();
@@ -35,6 +36,7 @@ public:
void testSearch();
void testSearchViewArea();
void testSearchTextFrame();
+ void testSearchTextFrameWrapAround();
void testDocumentSizeChanged();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
@@ -47,6 +49,7 @@ public:
CPPUNIT_TEST(testSearch);
CPPUNIT_TEST(testSearchViewArea);
CPPUNIT_TEST(testSearchTextFrame);
+ CPPUNIT_TEST(testSearchTextFrameWrapAround);
CPPUNIT_TEST(testDocumentSizeChanged);
CPPUNIT_TEST_SUITE_END();
@@ -57,8 +60,14 @@ private:
Rectangle m_aInvalidation;
Size m_aDocumentSize;
OString m_aTextSelection;
+ bool m_bFound;
};
+SwTiledRenderingTest::SwTiledRenderingTest()
+ : m_bFound(true)
+{
+}
+
SwXTextDocument* SwTiledRenderingTest::createDoc(const char* pName)
{
load(DATA_DIRECTORY, pName);
@@ -106,6 +115,11 @@ void SwTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
m_aTextSelection = pPayload;
}
break;
+ case LOK_CALLBACK_SEARCH_NOT_FOUND:
+ {
+ m_bFound = false;
+ }
+ break;
}
}
@@ -342,6 +356,24 @@ void SwTiledRenderingTest::testSearchTextFrame()
#endif
}
+void SwTiledRenderingTest::testSearchTextFrameWrapAround()
+{
+#if !defined(WNT) && !defined(MACOSX)
+ SwXTextDocument* pXTextDocument = createDoc("search.odt");
+ pXTextDocument->registerCallback(&SwTiledRenderingTest::callback, this);
+ uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
+ {
+ {"SearchItem.SearchString", uno::makeAny(OUString("TextFrame"))},
+ {"SearchItem.Backward", uno::makeAny(false)},
+ }));
+ comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues);
+ CPPUNIT_ASSERT(m_bFound);
+ comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues);
+ // This failed, i.e. the second time 'not found' was reported, instead of wrapping around.
+ CPPUNIT_ASSERT(m_bFound);
+#endif
+}
+
void SwTiledRenderingTest::testDocumentSizeChanged()
{
#if !defined(WNT) && !defined(MACOSX)
diff --git a/sw/source/uibase/uiview/viewsrch.cxx b/sw/source/uibase/uiview/viewsrch.cxx
index a4951ef44e71..28fc2c920ac3 100644
--- a/sw/source/uibase/uiview/viewsrch.cxx
+++ b/sw/source/uibase/uiview/viewsrch.cxx
@@ -554,13 +554,24 @@ bool SwView::SearchAndWrap(bool bApi)
if (bHasSrchInOther)
{
m_pWrtShell->ClearMark();
+ // Select the start or the end of the entire document
if (bSrchBkwrd)
- m_pWrtShell->EndDoc();
+ m_pWrtShell->SttEndDoc(false);
else
- m_pWrtShell->SttDoc();
+ m_pWrtShell->SttEndDoc(true);
}
m_bFound = bool(FUNC_Search( aOpts ));
+
+ // If WrapAround found no matches in the body text, search in the special
+ // sections, too.
+ if (!m_bFound && !m_pSrchItem->GetSelection() && !m_bExtra)
+ {
+ m_bExtra = true;
+ if (FUNC_Search(aOpts))
+ m_bFound = true;
+ }
+
m_pWrtShell->EndAllAction();
pWait.reset();
#if HAVE_FEATURE_DESKTOP