diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2020-05-30 15:47:35 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2020-06-04 00:41:49 +0200 |
commit | 18f8340a697be7c076fe111d0bc42faf877b9202 (patch) | |
tree | 8baec1dd8735dd15128a6fff123ffed6231f0f20 | |
parent | 95e5d37b6e62eb39f2d5337e124e86b3d0c3f399 (diff) |
sd: fix issue when PDF search doesn't send a search result + test
This fixes the issue when PDF search doesn't send the search
result, because of premature exit.
Also add test which reproduces this issue and tests the behavior
of searching in multiple objects.
Change-Id: I3a676eeac36bde88c67e90a49583444b8595a346
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95454
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r-- | sd/qa/unit/tiledrendering/LOKitSearchTest.cxx | 86 | ||||
-rw-r--r-- | sd/qa/unit/tiledrendering/data/MixedTest1.odg | bin | 0 -> 25083 bytes | |||
-rw-r--r-- | sd/source/ui/view/Outliner.cxx | 2 |
3 files changed, 87 insertions, 1 deletions
diff --git a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx index 8d8b11e43fa1..24037a0780ba 100644 --- a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx +++ b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx @@ -55,6 +55,7 @@ public: void testDontSearchInMasterPages(); void testSearchInPDFNonExisting(); void testSearchInPDF(); + void testSearchInMixedObject(); CPPUNIT_TEST_SUITE(LOKitSearchTest); CPPUNIT_TEST(testSearch); @@ -65,6 +66,7 @@ public: CPPUNIT_TEST(testDontSearchInMasterPages); CPPUNIT_TEST(testSearchInPDFNonExisting); CPPUNIT_TEST(testSearchInPDF); + CPPUNIT_TEST(testSearchInMixedObject); CPPUNIT_TEST_SUITE_END(); private: @@ -317,6 +319,90 @@ void LOKitSearchTest::testSearchInPDF() mpCallbackRecorder->m_aSelection[0]); } +void LOKitSearchTest::testSearchInMixedObject() +{ + SdXImpressDocument* pXImpressDocument = createDoc("MixedTest1.odg"); + sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); + CPPUNIT_ASSERT(pViewShell); + SdDrawDocument* pDocument = pXImpressDocument->GetDocShell()->GetDoc(); + CPPUNIT_ASSERT(pDocument); + mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase()); + + // Check we have one page + CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), pDocument->GetSdPageCount(PageKind::Standard)); + + SdPage* pPage = pViewShell->GetActualPage(); + CPPUNIT_ASSERT(pPage); + + // Check page hase 2 objects only + CPPUNIT_ASSERT_EQUAL(size_t(2), pPage->GetObjCount()); + + // Check Object 1 + { + SdrObject* pObject = pPage->GetObj(0); + CPPUNIT_ASSERT(pObject); + + CPPUNIT_ASSERT_EQUAL(sal_uInt16(OBJ_TEXT), pObject->GetObjIdentifier()); + } + + // Check Object 2 + { + SdrObject* pObject = pPage->GetObj(1); + CPPUNIT_ASSERT(pObject); + + CPPUNIT_ASSERT_EQUAL(sal_uInt16(OBJ_GRAF), pObject->GetObjIdentifier()); + + SdrGrafObj* pGraphicObject = dynamic_cast<SdrGrafObj*>(pObject); + CPPUNIT_ASSERT(pGraphicObject); + + Graphic aGraphic = pGraphicObject->GetGraphic(); + auto const& pVectorGraphicData = aGraphic.getVectorGraphicData(); + CPPUNIT_ASSERT(pVectorGraphicData); + + CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf, + pVectorGraphicData->getVectorGraphicDataType()); + } + + // Let's try to search now + + lcl_search("ABC"); + + CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound); + CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_nSearchResultCount); + + CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size()); + CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size()); + + CPPUNIT_ASSERT_EQUAL(OString("3546, 3174, 738, 402"), + mpCallbackRecorder->m_aSearchResultSelection[0]); + + // Search next + + lcl_search("ABC"); + + CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound); + CPPUNIT_ASSERT_EQUAL(2, mpCallbackRecorder->m_nSearchResultCount); + + CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size()); + CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size()); + + CPPUNIT_ASSERT_EQUAL(OString("8412, 6385, 519, 174"), + mpCallbackRecorder->m_aSearchResultSelection[0]); + + // Search next again - we should get the first object again + + lcl_search("ABC"); + + CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound); + CPPUNIT_ASSERT_EQUAL(3, mpCallbackRecorder->m_nSearchResultCount); + + CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size()); + CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size()); + + CPPUNIT_ASSERT_EQUAL(OString("3546, 3174, 738, 402"), + mpCallbackRecorder->m_aSearchResultSelection[0]); +} + CPPUNIT_TEST_SUITE_REGISTRATION(LOKitSearchTest); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/qa/unit/tiledrendering/data/MixedTest1.odg b/sd/qa/unit/tiledrendering/data/MixedTest1.odg Binary files differnew file mode 100644 index 000000000000..db952318c735 --- /dev/null +++ b/sd/qa/unit/tiledrendering/data/MixedTest1.odg diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx index cb5219838ec6..52326f0dfbf8 100644 --- a/sd/source/ui/view/Outliner.cxx +++ b/sd/source/ui/view/Outliner.cxx @@ -871,7 +871,7 @@ bool SdOutliner::SearchAndReplaceOnce(std::vector<sd::SearchSelection>* pSelecti { ProvideNextTextObject (); - if (!mbEndOfSearch) + if (!mbEndOfSearch && !mpImpl->mbCurrentIsVectorGraphic) { // Remember the current position as the last one with a // text object. |