sw/qa/extras/tiledrendering/data/2-pages.odt |binary sw/qa/extras/tiledrendering/data/search.odt |binary sw/qa/extras/tiledrendering/tiledrendering.cxx | 118 +++++++++++++++++++++++++ sw/source/uibase/uiview/viewsrch.cxx | 15 ++- 4 files changed, 131 insertions(+), 2 deletions(-)
New commits: commit 45d26bfe091e00a1a897c6944dbeb2be9b6a5c92 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Wed Jun 3 09:03:48 2015 +0200 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) diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index ba8237e..b139b16 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 dbd792b..94b987a 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 commit fae7413e13e204ce0bd43a124a62ca48d94fdf48 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Tue Jun 2 15:26:56 2015 +0200 CppunitTest_sw_tiledrendering: add TextFrame search testcase Fails without commit 2d17cd6b03a214393755ddfed5ba50a18f0cd774 (sw: LOK_CALLBACK_TEXT_SELECTION should be the union of all selections, 2015-06-02). Change-Id: I1d45eabf53dadd24051ff46acbf4bbfb85fb60a9 (cherry picked from commit 3f3ea9fadd6dc643fbd12e99075a23d59ff73207) diff --git a/sw/qa/extras/tiledrendering/data/search.odt b/sw/qa/extras/tiledrendering/data/search.odt index 9d98145..76ab2e1 100644 Binary files a/sw/qa/extras/tiledrendering/data/search.odt and b/sw/qa/extras/tiledrendering/data/search.odt differ diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index c8d4b92..ba8237e 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -34,6 +34,7 @@ public: void testResetSelection(); void testSearch(); void testSearchViewArea(); + void testSearchTextFrame(); void testDocumentSizeChanged(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); @@ -45,6 +46,7 @@ public: CPPUNIT_TEST(testResetSelection); CPPUNIT_TEST(testSearch); CPPUNIT_TEST(testSearchViewArea); + CPPUNIT_TEST(testSearchTextFrame); CPPUNIT_TEST(testDocumentSizeChanged); CPPUNIT_TEST_SUITE_END(); @@ -54,6 +56,7 @@ private: void callbackImpl(int nType, const char* pPayload); Rectangle m_aInvalidation; Size m_aDocumentSize; + OString m_aTextSelection; }; SwXTextDocument* SwTiledRenderingTest::createDoc(const char* pName) @@ -98,6 +101,11 @@ void SwTiledRenderingTest::callbackImpl(int nType, const char* pPayload) m_aDocumentSize.setHeight(aSeq[1].toInt32()); } break; + case LOK_CALLBACK_TEXT_SELECTION: + { + m_aTextSelection = pPayload; + } + break; } } @@ -318,6 +326,22 @@ void SwTiledRenderingTest::testSearchViewArea() #endif } +void SwTiledRenderingTest::testSearchTextFrame() +{ +#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); + // This was empty: nothing was highlighted after searching for 'TextFrame'. + CPPUNIT_ASSERT(!m_aTextSelection.isEmpty()); +#endif +} + void SwTiledRenderingTest::testDocumentSizeChanged() { #if !defined(WNT) && !defined(MACOSX) commit 6a206dd90c156965bfbf10dfa5729a427d3238af Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Mon Jun 1 17:01:21 2015 +0200 CppunitTest_sw_tiledrendering: add search start point testcase Fails without the sw/source hunk of commit 1dc60bc9e99304c58007bfd5a964ff3f78480106 (SvxSearchItem: add m_nStartPoint{X,Y}, 2015-05-28). Change-Id: I7b13294760a8a3c9c413a4a11582bc2a14d3d499 (cherry picked from commit 54619b4fa1cc477c92d0fa48cafffefe1b15a8fe) diff --git a/sw/qa/extras/tiledrendering/data/search.odt b/sw/qa/extras/tiledrendering/data/search.odt index 5fb02fa..9d98145 100644 Binary files a/sw/qa/extras/tiledrendering/data/search.odt and b/sw/qa/extras/tiledrendering/data/search.odt differ diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index a6dbe60..c8d4b92 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -33,6 +33,7 @@ public: void testSetGraphicSelection(); void testResetSelection(); void testSearch(); + void testSearchViewArea(); void testDocumentSizeChanged(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); @@ -43,6 +44,7 @@ public: CPPUNIT_TEST(testSetGraphicSelection); CPPUNIT_TEST(testResetSelection); CPPUNIT_TEST(testSearch); + CPPUNIT_TEST(testSearchViewArea); CPPUNIT_TEST(testDocumentSizeChanged); CPPUNIT_TEST_SUITE_END(); @@ -289,6 +291,33 @@ void SwTiledRenderingTest::testSearch() #endif } +void SwTiledRenderingTest::testSearchViewArea() +{ +#if !defined(WNT) && !defined(MACOSX) + SwXTextDocument* pXTextDocument = createDoc("search.odt"); + SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); + // Go to the second page, 1-based. + pWrtShell->GotoPage(2, false); + SwShellCrsr* pShellCrsr = pWrtShell->getShellCrsr(false); + // Get the ~top left corner of the second page. + Point aPoint = pShellCrsr->GetSttPos(); + + // Go back to the first page, search while the cursor is there, but the + // visible area is the second page. + pWrtShell->GotoPage(1, false); + uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence( + { + {"SearchItem.SearchString", uno::makeAny(OUString("Heading"))}, + {"SearchItem.Backward", uno::makeAny(false)}, + {"SearchItem.SearchStartPointX", uno::makeAny(static_cast<sal_Int32>(aPoint.getX()))}, + {"SearchItem.SearchStartPointY", uno::makeAny(static_cast<sal_Int32>(aPoint.getY()))} + })); + comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues); + // This was just "Heading", i.e. SwView::SearchAndWrap() did not search from only the top of the second page. + CPPUNIT_ASSERT_EQUAL(OUString("Heading on second page"), pShellCrsr->GetPoint()->nNode.GetNode().GetTextNode()->GetText()); +#endif +} + void SwTiledRenderingTest::testDocumentSizeChanged() { #if !defined(WNT) && !defined(MACOSX) commit adcbe2fea4799764f467b75b455015698d2aac55 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Fri May 29 12:05:32 2015 +0200 LOK: add DOCUMENT_SIZE_CHANGED testcase This failed without the SwViewShell::SizeChgNotify() hunk of commit 63a40c45018ad2e6f4a660a520a5907beb1d7801 (LOK: change PAGE_COUNT to a more generic DOCUMENT_SIZE, 2015-05-27). Change-Id: Id230420f60d1a6f3caf822f7e23ffca010919196 (cherry picked from commit 560c3fdca41843c29ea33c1e9c14429537f4e4b6) diff --git a/sw/qa/extras/tiledrendering/data/2-pages.odt b/sw/qa/extras/tiledrendering/data/2-pages.odt new file mode 100644 index 0000000..04953e5 Binary files /dev/null and b/sw/qa/extras/tiledrendering/data/2-pages.odt differ diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 4d6cc99..a6dbe60 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -33,6 +33,7 @@ public: void testSetGraphicSelection(); void testResetSelection(); void testSearch(); + void testDocumentSizeChanged(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -42,6 +43,7 @@ public: CPPUNIT_TEST(testSetGraphicSelection); CPPUNIT_TEST(testResetSelection); CPPUNIT_TEST(testSearch); + CPPUNIT_TEST(testDocumentSizeChanged); CPPUNIT_TEST_SUITE_END(); private: @@ -49,6 +51,7 @@ private: static void callback(int nType, const char* pPayload, void* pData); void callbackImpl(int nType, const char* pPayload); Rectangle m_aInvalidation; + Size m_aDocumentSize; }; SwXTextDocument* SwTiledRenderingTest::createDoc(const char* pName) @@ -75,6 +78,8 @@ void SwTiledRenderingTest::callbackImpl(int nType, const char* pPayload) if (m_aInvalidation.IsEmpty()) { uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated(OUString::createFromAscii(pPayload)); + if (OString("EMPTY") == pPayload) + return; CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), aSeq.getLength()); m_aInvalidation.setX(aSeq[0].toInt32()); m_aInvalidation.setY(aSeq[1].toInt32()); @@ -83,6 +88,14 @@ void SwTiledRenderingTest::callbackImpl(int nType, const char* pPayload) } } break; + case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED: + { + uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated(OUString::createFromAscii(pPayload)); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), aSeq.getLength()); + m_aDocumentSize.setWidth(aSeq[0].toInt32()); + m_aDocumentSize.setHeight(aSeq[1].toInt32()); + } + break; } } @@ -276,6 +289,26 @@ void SwTiledRenderingTest::testSearch() #endif } +void SwTiledRenderingTest::testDocumentSizeChanged() +{ +#if !defined(WNT) && !defined(MACOSX) + // Get the current document size. + SwXTextDocument* pXTextDocument = createDoc("2-pages.odt"); + pXTextDocument->registerCallback(&SwTiledRenderingTest::callback, this); + SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); + pXTextDocument->initializeForTiledRendering(); + Size aSize = pXTextDocument->getDocumentSize(); + + // Delete the second page and see how the size changes. + pWrtShell->Down(false); + pWrtShell->DelLeft(); + // Document width should not change, this was 0. + CPPUNIT_ASSERT_EQUAL(aSize.getWidth(), m_aDocumentSize.getWidth()); + // Document height should be smaller now. + CPPUNIT_ASSERT(aSize.getHeight() > m_aDocumentSize.getHeight()); +#endif +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits