Kaydet (Commit) b6a895d8 authored tarafından Miklos Vajna's avatar Miklos Vajna Kaydeden (comit) Jan Holesovsky

SwView::SearchAndWrap: fix WrapAround search in fly frames

First, SttDoc() / EndDoc() is the implementation of Ctrl-Home, i.e. it
goes to the start of the current text (like a fly frame), not to the
start of the whole document. When wrapping around, we want the later.

Second, if the normal search have two passes, first searching in the
body text, then searching in the special sections, then the wrap-around
search should do the same.

Change-Id: I0b7466c80476f6fb45174be19215a5d68374d047
(cherry picked from commit c88802829832a315550cb7e19e17030dc4c2bd77)
üst ffac19f7
...@@ -26,6 +26,7 @@ static const char* DATA_DIRECTORY = "/sw/qa/extras/tiledrendering/data/"; ...@@ -26,6 +26,7 @@ static const char* DATA_DIRECTORY = "/sw/qa/extras/tiledrendering/data/";
class SwTiledRenderingTest : public SwModelTestBase class SwTiledRenderingTest : public SwModelTestBase
{ {
public: public:
SwTiledRenderingTest();
void testRegisterCallback(); void testRegisterCallback();
void testPostKeyEvent(); void testPostKeyEvent();
void testPostMouseEvent(); void testPostMouseEvent();
...@@ -35,6 +36,7 @@ public: ...@@ -35,6 +36,7 @@ public:
void testSearch(); void testSearch();
void testSearchViewArea(); void testSearchViewArea();
void testSearchTextFrame(); void testSearchTextFrame();
void testSearchTextFrameWrapAround();
void testDocumentSizeChanged(); void testDocumentSizeChanged();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
...@@ -47,6 +49,7 @@ public: ...@@ -47,6 +49,7 @@ public:
CPPUNIT_TEST(testSearch); CPPUNIT_TEST(testSearch);
CPPUNIT_TEST(testSearchViewArea); CPPUNIT_TEST(testSearchViewArea);
CPPUNIT_TEST(testSearchTextFrame); CPPUNIT_TEST(testSearchTextFrame);
CPPUNIT_TEST(testSearchTextFrameWrapAround);
CPPUNIT_TEST(testDocumentSizeChanged); CPPUNIT_TEST(testDocumentSizeChanged);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
...@@ -57,8 +60,14 @@ private: ...@@ -57,8 +60,14 @@ private:
Rectangle m_aInvalidation; Rectangle m_aInvalidation;
Size m_aDocumentSize; Size m_aDocumentSize;
OString m_aTextSelection; OString m_aTextSelection;
bool m_bFound;
}; };
SwTiledRenderingTest::SwTiledRenderingTest()
: m_bFound(true)
{
}
SwXTextDocument* SwTiledRenderingTest::createDoc(const char* pName) SwXTextDocument* SwTiledRenderingTest::createDoc(const char* pName)
{ {
load(DATA_DIRECTORY, pName); load(DATA_DIRECTORY, pName);
...@@ -106,6 +115,11 @@ void SwTiledRenderingTest::callbackImpl(int nType, const char* pPayload) ...@@ -106,6 +115,11 @@ void SwTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
m_aTextSelection = pPayload; m_aTextSelection = pPayload;
} }
break; break;
case LOK_CALLBACK_SEARCH_NOT_FOUND:
{
m_bFound = false;
}
break;
} }
} }
...@@ -342,6 +356,24 @@ void SwTiledRenderingTest::testSearchTextFrame() ...@@ -342,6 +356,24 @@ void SwTiledRenderingTest::testSearchTextFrame()
#endif #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() void SwTiledRenderingTest::testDocumentSizeChanged()
{ {
#if !defined(WNT) && !defined(MACOSX) #if !defined(WNT) && !defined(MACOSX)
......
...@@ -554,13 +554,24 @@ bool SwView::SearchAndWrap(bool bApi) ...@@ -554,13 +554,24 @@ bool SwView::SearchAndWrap(bool bApi)
if (bHasSrchInOther) if (bHasSrchInOther)
{ {
m_pWrtShell->ClearMark(); m_pWrtShell->ClearMark();
// Select the start or the end of the entire document
if (bSrchBkwrd) if (bSrchBkwrd)
m_pWrtShell->EndDoc(); m_pWrtShell->SttEndDoc(false);
else else
m_pWrtShell->SttDoc(); m_pWrtShell->SttEndDoc(true);
} }
m_bFound = bool(FUNC_Search( aOpts )); 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(); m_pWrtShell->EndAllAction();
pWait.reset(); pWait.reset();
#if HAVE_FEATURE_DESKTOP #if HAVE_FEATURE_DESKTOP
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment