Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sd / qa / unit / tiledrendering / LOKitSearchTest.cxx
blob2ba0a8f27848fbb19a5bf8355ca0f27cc4b9ae9a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include "CallbackRecorder.hxx"
11 #include <test/unoapi_test.hxx>
13 #include <test/helper/transferable.hxx>
15 #include <comphelper/propertysequence.hxx>
16 #include <comphelper/lok.hxx>
17 #include <svl/srchitem.hxx>
18 #include <vcl/scheduler.hxx>
19 #include <ViewShellBase.hxx>
20 #include <ViewShell.hxx>
21 #include <unomodel.hxx>
23 #include <DrawDocShell.hxx>
24 #include <drawdoc.hxx>
25 #include <sdpage.hxx>
26 #include <svx/svdograf.hxx>
27 #include <vcl/filter/PDFiumLibrary.hxx>
29 using namespace css;
31 class LOKitSearchTest : public UnoApiTest
33 public:
34 LOKitSearchTest()
35 : UnoApiTest("/sd/qa/unit/tiledrendering/data/")
39 virtual void setUp() override;
40 virtual void tearDown() override;
42 void testSearch();
43 void testSearchAll();
44 void testSearchAllSelections();
45 void testSearchAllNotifications();
46 void testSearchAllFollowedBySearch();
47 void testDontSearchInMasterPages();
48 void testSearchInPDFNonExisting();
49 void testSearchInPDF();
50 void testSearchInPDFOnePDFObject();
51 void testSearchInPDFInMultiplePages();
52 void testSearchInPDFInMultiplePagesBackwards();
53 void testSearchIn2MixedObjects();
54 void testSearchIn6MixedObjects();
55 void testReplace();
56 void testReplaceAll();
57 void testReplaceCombined();
59 CPPUNIT_TEST_SUITE(LOKitSearchTest);
60 CPPUNIT_TEST(testSearch);
61 CPPUNIT_TEST(testSearchAll);
62 CPPUNIT_TEST(testSearchAllSelections);
63 CPPUNIT_TEST(testSearchAllNotifications);
64 CPPUNIT_TEST(testSearchAllFollowedBySearch);
65 CPPUNIT_TEST(testDontSearchInMasterPages);
66 CPPUNIT_TEST(testSearchInPDFNonExisting);
67 CPPUNIT_TEST(testSearchInPDF);
68 CPPUNIT_TEST(testSearchInPDFOnePDFObject);
69 CPPUNIT_TEST(testSearchInPDFInMultiplePages);
70 CPPUNIT_TEST(testSearchInPDFInMultiplePagesBackwards);
71 CPPUNIT_TEST(testSearchIn2MixedObjects);
72 CPPUNIT_TEST(testSearchIn6MixedObjects);
73 CPPUNIT_TEST(testReplace);
74 CPPUNIT_TEST(testReplaceAll);
75 CPPUNIT_TEST(testReplaceCombined);
76 CPPUNIT_TEST_SUITE_END();
78 private:
79 SdXImpressDocument* createDoc(const char* pName,
80 const uno::Sequence<beans::PropertyValue>& rArguments
81 = uno::Sequence<beans::PropertyValue>());
82 void lcl_search(const OUString& rKey, bool bFindAll = false, bool bBackwards = false);
83 void lcl_replace(const OUString& rKey, const OUString& rReplace, bool bAll = false);
85 std::unique_ptr<CallbackRecorder> mpCallbackRecorder;
88 void LOKitSearchTest::setUp()
90 UnoApiTest::setUp();
92 // prevent showing warning message box
93 setenv("OOX_NO_SMARTART_WARNING", "1", 1);
94 comphelper::LibreOfficeKit::setActive(true);
96 mpCallbackRecorder = std::make_unique<CallbackRecorder>();
99 void LOKitSearchTest::tearDown()
101 if (mxComponent.is())
103 mxComponent->dispose();
104 mxComponent.clear();
107 comphelper::LibreOfficeKit::setActive(false);
109 UnoApiTest::tearDown();
112 SdXImpressDocument*
113 LOKitSearchTest::createDoc(const char* pName, const uno::Sequence<beans::PropertyValue>& rArguments)
115 loadFromURL(OUString::createFromAscii(pName));
116 SdXImpressDocument* pImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
117 CPPUNIT_ASSERT(pImpressDocument);
118 pImpressDocument->initializeForTiledRendering(rArguments);
119 return pImpressDocument;
122 void LOKitSearchTest::lcl_search(const OUString& rKey, bool bFindAll, bool bBackwards)
124 Scheduler::ProcessEventsToIdle();
125 SvxSearchCmd eSearch = bFindAll ? SvxSearchCmd::FIND_ALL : SvxSearchCmd::FIND;
127 uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence({
128 { "SearchItem.SearchString", uno::Any(rKey) },
129 { "SearchItem.Backward", uno::Any(bBackwards) },
130 { "SearchItem.Command", uno::Any(sal_uInt16(eSearch)) },
131 }));
133 dispatchCommand(mxComponent, ".uno:ExecuteSearch", aPropertyValues);
136 void LOKitSearchTest::lcl_replace(const OUString& rKey, const OUString& rReplace, bool bAll)
138 Scheduler::ProcessEventsToIdle();
140 SvxSearchCmd eSearch = bAll ? SvxSearchCmd::REPLACE_ALL : SvxSearchCmd::REPLACE;
142 uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence({
143 { "SearchItem.SearchString", uno::Any(rKey) },
144 { "SearchItem.ReplaceString", uno::Any(rReplace) },
145 { "SearchItem.Command", uno::Any(sal_uInt16(eSearch)) },
146 }));
148 dispatchCommand(mxComponent, ".uno:ExecuteSearch", aPropertyValues);
151 namespace
153 SdrObject* lclGetSelectedObject(sd::ViewShell* pViewShell)
155 SdrView* pSdrView = pViewShell->GetView();
156 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
157 CPPUNIT_ASSERT_EQUAL(size_t(1), rMarkList.GetMarkCount());
158 SdrObject* pObject = rMarkList.GetMark(0)->GetMarkedSdrObj();
159 return pObject;
162 } // end anonymous namespace
164 void LOKitSearchTest::testSearch()
166 SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp");
167 sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
168 mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
169 uno::Reference<container::XIndexAccess> xDrawPage(
170 pXImpressDocument->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
171 uno::Reference<text::XTextRange> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
172 xShape->setString("Aaa bbb.");
174 lcl_search("bbb");
176 SdrView* pView = pViewShell->GetView();
177 EditView& rEditView = pView->GetTextEditOutlinerView()->GetEditView();
178 // Did we indeed manage to select the second word?
179 CPPUNIT_ASSERT_EQUAL(OUString("bbb"), rEditView.GetSelected());
181 // Did the selection callback fire?
182 CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(1), mpCallbackRecorder->m_aSelection.size());
184 // Search for something on the second slide, and make sure that the set-part callback fired.
185 lcl_search("bbb");
186 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), mpCallbackRecorder->m_nPart);
187 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
188 // This was 0; should be 1 match for "find".
189 CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(1),
190 mpCallbackRecorder->m_aSearchResultSelection.size());
191 // Result is on the second slide.
192 CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_aSearchResultPart[0]);
194 // This should trigger the not-found callback.
195 lcl_search("ccc");
196 CPPUNIT_ASSERT_EQUAL(false, mpCallbackRecorder->m_bFound);
199 void LOKitSearchTest::testSearchAll()
201 SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp");
202 sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
203 mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
205 lcl_search("match", /*bFindAll=*/true);
207 // This was empty: find-all did not highlight the first match.
208 CPPUNIT_ASSERT_EQUAL(OString("match"),
209 apitest::helper::transferable::getTextSelection(
210 pXImpressDocument->getSelection(), "text/plain;charset=utf-8"));
212 // We're on the first slide, search for something on the second slide and make sure we get a SET_PART.
213 mpCallbackRecorder->m_nPart = 0;
214 lcl_search("second", /*bFindAll=*/true);
215 // This was 0: no SET_PART was emitted.
216 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), mpCallbackRecorder->m_nPart);
219 void LOKitSearchTest::testSearchAllSelections()
221 SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp");
222 sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
223 mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
225 lcl_search("third", /*bFindAll=*/true);
226 // Make sure this is found on the 3rd slide.
227 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), mpCallbackRecorder->m_nPart);
228 // This was 1: only the first match was highlighted.
229 CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(2), mpCallbackRecorder->m_aSelection.size());
232 void LOKitSearchTest::testSearchAllNotifications()
234 SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp");
235 sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
236 mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
238 lcl_search("third", /*bFindAll=*/true);
239 // Make sure that we get no notifications about selection changes during search.
240 CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_nSelectionBeforeSearchResult);
241 // But we do get the selection of the first hit.
242 CPPUNIT_ASSERT(mpCallbackRecorder->m_nSelectionAfterSearchResult > 0);
245 void LOKitSearchTest::testSearchAllFollowedBySearch()
247 SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp");
248 sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
249 mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
251 lcl_search("third", /*bFindAll=*/true);
252 lcl_search("match" /*,bFindAll=false*/);
254 // This used to give wrong result: 'search' after 'search all' still
255 // returned 'third'
256 CPPUNIT_ASSERT_EQUAL(OString("match"),
257 apitest::helper::transferable::getTextSelection(
258 pXImpressDocument->getSelection(), "text/plain;charset=utf-8"));
261 void LOKitSearchTest::testDontSearchInMasterPages()
263 SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp");
264 sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
265 mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
267 // This should trigger the not-found callback ("date" is present only on
268 // the master page)
269 lcl_search("date");
270 CPPUNIT_ASSERT_EQUAL(false, mpCallbackRecorder->m_bFound);
273 void LOKitSearchTest::testSearchInPDFNonExisting()
275 auto pPdfium = vcl::pdf::PDFiumLibrary::get();
276 if (!pPdfium)
278 return;
281 SdXImpressDocument* pXImpressDocument = createDoc("PDFSearch.pdf");
282 sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
283 CPPUNIT_ASSERT(pViewShell);
284 mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
286 SdPage* pPage = pViewShell->GetActualPage();
287 CPPUNIT_ASSERT(pPage);
289 SdrObject* pObject = pPage->GetObj(0);
290 CPPUNIT_ASSERT(pObject);
292 SdrGrafObj* pGraphicObject = dynamic_cast<SdrGrafObj*>(pObject);
293 CPPUNIT_ASSERT(pGraphicObject);
295 Graphic aGraphic = pGraphicObject->GetGraphic();
296 auto const& pVectorGraphicData = aGraphic.getVectorGraphicData();
297 CPPUNIT_ASSERT(pVectorGraphicData);
298 CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf, pVectorGraphicData->getType());
300 lcl_search("NonExisting");
302 CPPUNIT_ASSERT_EQUAL(false, mpCallbackRecorder->m_bFound);
305 void LOKitSearchTest::testSearchInPDF()
307 auto pPdfium = vcl::pdf::PDFiumLibrary::get();
308 if (!pPdfium)
310 return;
313 SdXImpressDocument* pXImpressDocument = createDoc("PDFSearch.pdf");
314 sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
315 CPPUNIT_ASSERT(pViewShell);
316 mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
318 SdPage* pPage = pViewShell->GetActualPage();
319 CPPUNIT_ASSERT(pPage);
321 SdrObject* pObject = pPage->GetObj(0);
322 CPPUNIT_ASSERT(pObject);
324 SdrGrafObj* pGraphicObject = dynamic_cast<SdrGrafObj*>(pObject);
325 CPPUNIT_ASSERT(pGraphicObject);
327 Graphic aGraphic = pGraphicObject->GetGraphic();
328 auto const& pVectorGraphicData = aGraphic.getVectorGraphicData();
329 CPPUNIT_ASSERT(pVectorGraphicData);
330 CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf, pVectorGraphicData->getType());
332 // Search
333 lcl_search("ABC");
335 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
336 CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_nSearchResultCount);
338 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
339 CPPUNIT_ASSERT_EQUAL(OString("3763, 1331, 1432, 483"),
340 mpCallbackRecorder->m_aSearchResultSelection[0]);
341 CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(3763, 1331), Size(1433, 484)),
342 mpCallbackRecorder->m_aSelection[0]);
344 // Search again - same result
345 lcl_search("ABC");
347 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
348 CPPUNIT_ASSERT_EQUAL(2, mpCallbackRecorder->m_nSearchResultCount);
350 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
351 CPPUNIT_ASSERT_EQUAL(OString("3763, 1331, 1432, 483"),
352 mpCallbackRecorder->m_aSearchResultSelection[0]);
353 CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(3763, 1331), Size(1433, 484)),
354 mpCallbackRecorder->m_aSelection[0]);
357 void LOKitSearchTest::testSearchInPDFOnePDFObject()
359 auto pPdfium = vcl::pdf::PDFiumLibrary::get();
360 if (!pPdfium)
362 return;
365 SdXImpressDocument* pXImpressDocument = createDoc("OnePDFObject.odg");
366 sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
367 CPPUNIT_ASSERT(pViewShell);
368 mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
370 SdPage* pPage = pViewShell->GetActualPage();
371 CPPUNIT_ASSERT(pPage);
373 SdrObject* pObject = pPage->GetObj(0);
374 CPPUNIT_ASSERT(pObject);
376 SdrGrafObj* pGraphicObject = dynamic_cast<SdrGrafObj*>(pObject);
377 CPPUNIT_ASSERT(pGraphicObject);
379 Graphic aGraphic = pGraphicObject->GetGraphic();
380 auto const& pVectorGraphicData = aGraphic.getVectorGraphicData();
381 CPPUNIT_ASSERT(pVectorGraphicData);
382 CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf, pVectorGraphicData->getType());
384 // Search down
385 lcl_search("ABC", false, false);
387 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
388 CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_nSearchResultCount);
390 // Search up
391 lcl_search("ABC", false, true); // This caused a crash
393 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
394 CPPUNIT_ASSERT_EQUAL(2, mpCallbackRecorder->m_nSearchResultCount);
397 void LOKitSearchTest::testSearchInPDFInMultiplePages()
399 auto pPdfium = vcl::pdf::PDFiumLibrary::get();
400 if (!pPdfium)
402 return;
405 SdXImpressDocument* pXImpressDocument = createDoc("PDFSearch.pdf");
406 sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
407 CPPUNIT_ASSERT(pViewShell);
408 mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
410 SdPage* pPage = pViewShell->GetActualPage();
411 CPPUNIT_ASSERT(pPage);
414 SdrObject* pObject = pPage->GetObj(0);
415 CPPUNIT_ASSERT(pObject);
417 SdrGrafObj* pGraphicObject = dynamic_cast<SdrGrafObj*>(pObject);
418 CPPUNIT_ASSERT(pGraphicObject);
420 Graphic aGraphic = pGraphicObject->GetGraphic();
421 auto const& pVectorGraphicData = aGraphic.getVectorGraphicData();
422 CPPUNIT_ASSERT(pVectorGraphicData);
423 CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf, pVectorGraphicData->getType());
426 // Search for "him"
427 lcl_search("him");
429 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
430 CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_nSearchResultCount);
432 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
433 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
435 CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_aSearchResultPart[0]);
436 CPPUNIT_ASSERT_EQUAL(OString("9463, 3382, 1099, 499"),
437 mpCallbackRecorder->m_aSearchResultSelection[0]);
439 // Search for "him"
440 lcl_search("him");
442 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
443 CPPUNIT_ASSERT_EQUAL(2, mpCallbackRecorder->m_nSearchResultCount);
445 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
446 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
448 CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_aSearchResultPart[0]);
449 CPPUNIT_ASSERT_EQUAL(OString("5592, 5038, 1100, 499"),
450 mpCallbackRecorder->m_aSearchResultSelection[0]);
452 // Search for "him"
453 lcl_search("him");
455 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
456 CPPUNIT_ASSERT_EQUAL(3, mpCallbackRecorder->m_nSearchResultCount);
458 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
459 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
461 CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_aSearchResultPart[0]);
462 CPPUNIT_ASSERT_EQUAL(OString("9463, 1308, 1099, 499"),
463 mpCallbackRecorder->m_aSearchResultSelection[0]);
465 // Search for "him"
466 lcl_search("him");
468 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
469 CPPUNIT_ASSERT_EQUAL(4, mpCallbackRecorder->m_nSearchResultCount);
471 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
472 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
474 CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_aSearchResultPart[0]);
475 CPPUNIT_ASSERT_EQUAL(OString("5592, 2964, 1100, 499"),
476 mpCallbackRecorder->m_aSearchResultSelection[0]);
478 // Search for "him" - back to start
479 lcl_search("him");
481 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
482 CPPUNIT_ASSERT_EQUAL(5, mpCallbackRecorder->m_nSearchResultCount);
484 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
485 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
487 CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_aSearchResultPart[0]);
488 CPPUNIT_ASSERT_EQUAL(OString("9463, 3382, 1099, 499"),
489 mpCallbackRecorder->m_aSearchResultSelection[0]);
492 void LOKitSearchTest::testSearchInPDFInMultiplePagesBackwards()
494 auto pPdfium = vcl::pdf::PDFiumLibrary::get();
495 if (!pPdfium)
497 return;
500 SdXImpressDocument* pXImpressDocument = createDoc("PDFSearch.pdf");
501 sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
502 CPPUNIT_ASSERT(pViewShell);
503 mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
505 SdPage* pPage = pViewShell->GetActualPage();
506 CPPUNIT_ASSERT(pPage);
509 SdrObject* pObject = pPage->GetObj(0);
510 CPPUNIT_ASSERT(pObject);
512 SdrGrafObj* pGraphicObject = dynamic_cast<SdrGrafObj*>(pObject);
513 CPPUNIT_ASSERT(pGraphicObject);
515 Graphic aGraphic = pGraphicObject->GetGraphic();
516 auto const& pVectorGraphicData = aGraphic.getVectorGraphicData();
517 CPPUNIT_ASSERT(pVectorGraphicData);
518 CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf, pVectorGraphicData->getType());
521 // Expected for backwards search is:
522 // - Start with Page 1
523 // + search backwards through objects
524 // + inside objects search backwards through text
525 // - Switch to Page 2
526 // + search backwards through objects
527 // + inside objects search backwards through text
529 // Search for "him"
530 lcl_search("him", /*FindAll*/ false, /*Backwards*/ true);
532 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
533 CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_nSearchResultCount);
535 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
536 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
538 CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_aSearchResultPart[0]);
539 CPPUNIT_ASSERT_EQUAL(OString("5592, 5038, 1100, 499"),
540 mpCallbackRecorder->m_aSearchResultSelection[0]);
542 // Search for "him"
543 lcl_search("him", /*FindAll*/ false, /*Backwards*/ true);
545 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
546 CPPUNIT_ASSERT_EQUAL(2, mpCallbackRecorder->m_nSearchResultCount);
548 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
549 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
551 CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_aSearchResultPart[0]);
552 CPPUNIT_ASSERT_EQUAL(OString("9463, 3382, 1099, 499"),
553 mpCallbackRecorder->m_aSearchResultSelection[0]);
555 // Search for "him"
556 lcl_search("him", /*FindAll*/ false, /*Backwards*/ true);
558 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
559 CPPUNIT_ASSERT_EQUAL(3, mpCallbackRecorder->m_nSearchResultCount);
561 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
562 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
564 CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_aSearchResultPart[0]);
565 CPPUNIT_ASSERT_EQUAL(OString("5592, 2964, 1100, 499"),
566 mpCallbackRecorder->m_aSearchResultSelection[0]);
568 // Search for "him"
569 lcl_search("him", /*FindAll*/ false, /*Backwards*/ true);
571 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
572 CPPUNIT_ASSERT_EQUAL(4, mpCallbackRecorder->m_nSearchResultCount);
574 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
575 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
577 CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_aSearchResultPart[0]);
578 CPPUNIT_ASSERT_EQUAL(OString("9463, 1308, 1099, 499"),
579 mpCallbackRecorder->m_aSearchResultSelection[0]);
581 // Search for "him" - back to start
582 lcl_search("him", /*FindAll*/ false, /*Backwards*/ true);
584 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
585 CPPUNIT_ASSERT_EQUAL(5, mpCallbackRecorder->m_nSearchResultCount);
587 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
588 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
590 CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_aSearchResultPart[0]);
591 CPPUNIT_ASSERT_EQUAL(OString("5592, 5038, 1100, 499"),
592 mpCallbackRecorder->m_aSearchResultSelection[0]);
595 // Test searching in document with mixed objects.
596 // We have 2 objects: 1. Text Object, 2. Graphic Object with PDF
597 void LOKitSearchTest::testSearchIn2MixedObjects()
599 auto pPdfium = vcl::pdf::PDFiumLibrary::get();
600 if (!pPdfium)
602 return;
605 SdXImpressDocument* pXImpressDocument = createDoc("MixedTest1.odg");
606 sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
607 CPPUNIT_ASSERT(pViewShell);
608 SdDrawDocument* pDocument = pXImpressDocument->GetDocShell()->GetDoc();
609 CPPUNIT_ASSERT(pDocument);
610 mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
612 // Check we have one page
613 CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), pDocument->GetSdPageCount(PageKind::Standard));
615 SdPage* pPage = pViewShell->GetActualPage();
616 CPPUNIT_ASSERT(pPage);
618 // Check page has 2 objects only
619 CPPUNIT_ASSERT_EQUAL(size_t(2), pPage->GetObjCount());
621 // Check Object 1
623 SdrObject* pObject = pPage->GetObj(0);
624 CPPUNIT_ASSERT(pObject);
626 CPPUNIT_ASSERT_EQUAL(SdrObjKind::Text, pObject->GetObjIdentifier());
629 // Check Object 2
631 SdrObject* pObject = pPage->GetObj(1);
632 CPPUNIT_ASSERT(pObject);
634 CPPUNIT_ASSERT_EQUAL(SdrObjKind::Graphic, pObject->GetObjIdentifier());
636 SdrGrafObj* pGraphicObject = dynamic_cast<SdrGrafObj*>(pObject);
637 CPPUNIT_ASSERT(pGraphicObject);
639 Graphic aGraphic = pGraphicObject->GetGraphic();
640 auto const& pVectorGraphicData = aGraphic.getVectorGraphicData();
641 CPPUNIT_ASSERT(pVectorGraphicData);
643 CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf, pVectorGraphicData->getType());
646 // Let's try to search now
648 lcl_search("ABC");
650 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
651 CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_nSearchResultCount);
653 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
654 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
656 CPPUNIT_ASSERT_EQUAL(OString("3546, 3174, 738, 402"),
657 mpCallbackRecorder->m_aSearchResultSelection[0]);
659 // Search next
661 lcl_search("ABC");
663 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
664 CPPUNIT_ASSERT_EQUAL(2, mpCallbackRecorder->m_nSearchResultCount);
666 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
667 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
669 CPPUNIT_ASSERT_EQUAL(OString("8412, 6385, 519, 174"),
670 mpCallbackRecorder->m_aSearchResultSelection[0]);
672 // Search next again - we should get the first object again
674 lcl_search("ABC");
676 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
677 CPPUNIT_ASSERT_EQUAL(3, mpCallbackRecorder->m_nSearchResultCount);
679 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
680 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
682 CPPUNIT_ASSERT_EQUAL(OString("3546, 3174, 738, 402"),
683 mpCallbackRecorder->m_aSearchResultSelection[0]);
686 // Test searching in document with mixed objects. We have 6 objects.
687 void LOKitSearchTest::testSearchIn6MixedObjects()
689 auto pPdfium = vcl::pdf::PDFiumLibrary::get();
690 if (!pPdfium)
692 return;
695 SdXImpressDocument* pXImpressDocument = createDoc("MixedTest2.odg");
696 sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
697 CPPUNIT_ASSERT(pViewShell);
698 SdDrawDocument* pDocument = pXImpressDocument->GetDocShell()->GetDoc();
699 CPPUNIT_ASSERT(pDocument);
700 mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
702 // Check we have one page
703 CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), pDocument->GetSdPageCount(PageKind::Standard));
705 SdPage* pPage = pViewShell->GetActualPage();
706 CPPUNIT_ASSERT(pPage);
708 // Check page has 6 objects only
709 CPPUNIT_ASSERT_EQUAL(size_t(6), pPage->GetObjCount());
711 // Check we have the right objects that we expect
713 // Check Object 1
715 SdrObject* pObject = pPage->GetObj(0);
716 CPPUNIT_ASSERT(pObject);
717 CPPUNIT_ASSERT_EQUAL(SdrObjKind::Text, pObject->GetObjIdentifier());
720 // Check Object 2
722 SdrObject* pObject = pPage->GetObj(1);
723 CPPUNIT_ASSERT(pObject);
724 CPPUNIT_ASSERT_EQUAL(SdrObjKind::Graphic, pObject->GetObjIdentifier());
725 SdrGrafObj* pGraphicObject = dynamic_cast<SdrGrafObj*>(pObject);
726 CPPUNIT_ASSERT(pGraphicObject);
727 auto const& pVectorGraphicData = pGraphicObject->GetGraphic().getVectorGraphicData();
728 CPPUNIT_ASSERT(pVectorGraphicData);
729 CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf, pVectorGraphicData->getType());
732 // Check Object 3
734 SdrObject* pObject = pPage->GetObj(2);
735 CPPUNIT_ASSERT(pObject);
736 CPPUNIT_ASSERT_EQUAL(SdrObjKind::CustomShape, pObject->GetObjIdentifier());
739 // Check Object 4
741 SdrObject* pObject = pPage->GetObj(3);
742 CPPUNIT_ASSERT(pObject);
743 CPPUNIT_ASSERT_EQUAL(SdrObjKind::CustomShape, pObject->GetObjIdentifier());
746 // Check Object 5
748 SdrObject* pObject = pPage->GetObj(4);
749 CPPUNIT_ASSERT(pObject);
750 CPPUNIT_ASSERT_EQUAL(SdrObjKind::Graphic, pObject->GetObjIdentifier());
751 SdrGrafObj* pGraphicObject = dynamic_cast<SdrGrafObj*>(pObject);
752 CPPUNIT_ASSERT(pGraphicObject);
753 auto const& pVectorGraphicData = pGraphicObject->GetGraphic().getVectorGraphicData();
754 CPPUNIT_ASSERT(pVectorGraphicData);
755 CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Svg, pVectorGraphicData->getType());
758 // Check Object 6
760 SdrObject* pObject = pPage->GetObj(5);
761 CPPUNIT_ASSERT(pObject);
762 CPPUNIT_ASSERT_EQUAL(SdrObjKind::Graphic, pObject->GetObjIdentifier());
763 SdrGrafObj* pGraphicObject = dynamic_cast<SdrGrafObj*>(pObject);
764 CPPUNIT_ASSERT(pGraphicObject);
765 auto const& pVectorGraphicData = pGraphicObject->GetGraphic().getVectorGraphicData();
766 CPPUNIT_ASSERT(pVectorGraphicData);
767 CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf, pVectorGraphicData->getType());
770 // Search "ABC" which is in all objects (2 times in Object 3)
772 // Object 1
773 lcl_search("ABC");
775 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
776 CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_nSearchResultCount);
778 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
779 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
780 CPPUNIT_ASSERT_EQUAL(pPage->GetObj(0), lclGetSelectedObject(pViewShell));
782 // Object 2
783 lcl_search("ABC");
785 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
786 CPPUNIT_ASSERT_EQUAL(2, mpCallbackRecorder->m_nSearchResultCount);
788 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
789 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
790 CPPUNIT_ASSERT_EQUAL(pPage->GetObj(1), lclGetSelectedObject(pViewShell));
792 // Object 3
793 lcl_search("ABC");
795 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
796 CPPUNIT_ASSERT_EQUAL(3, mpCallbackRecorder->m_nSearchResultCount);
798 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
799 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
800 CPPUNIT_ASSERT_EQUAL(pPage->GetObj(2), lclGetSelectedObject(pViewShell));
802 // Object 3 again
803 lcl_search("ABC");
805 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
806 CPPUNIT_ASSERT_EQUAL(4, mpCallbackRecorder->m_nSearchResultCount);
808 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
809 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
810 CPPUNIT_ASSERT_EQUAL(pPage->GetObj(2), lclGetSelectedObject(pViewShell));
812 // Object 4
813 lcl_search("ABC");
815 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
816 CPPUNIT_ASSERT_EQUAL(5, mpCallbackRecorder->m_nSearchResultCount);
818 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
819 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
820 CPPUNIT_ASSERT_EQUAL(pPage->GetObj(3), lclGetSelectedObject(pViewShell));
822 // Object 5
823 lcl_search("ABC");
825 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
826 CPPUNIT_ASSERT_EQUAL(6, mpCallbackRecorder->m_nSearchResultCount);
828 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
829 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
830 CPPUNIT_ASSERT_EQUAL(pPage->GetObj(4), lclGetSelectedObject(pViewShell));
832 // Object 6
833 lcl_search("ABC");
835 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
836 CPPUNIT_ASSERT_EQUAL(7, mpCallbackRecorder->m_nSearchResultCount);
838 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
839 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
840 CPPUNIT_ASSERT_EQUAL(pPage->GetObj(5), lclGetSelectedObject(pViewShell));
842 // Loop to Object 1 again
843 lcl_search("ABC");
845 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
846 CPPUNIT_ASSERT_EQUAL(8, mpCallbackRecorder->m_nSearchResultCount);
848 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
849 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
850 CPPUNIT_ASSERT_EQUAL(pPage->GetObj(0), lclGetSelectedObject(pViewShell));
852 namespace
854 OUString getShapeText(SdXImpressDocument* pXImpressDocument, sal_uInt32 nPage, sal_uInt32 nShape)
856 uno::Reference<container::XIndexAccess> xDrawPage;
857 xDrawPage.set(pXImpressDocument->getDrawPages()->getByIndex(nPage), uno::UNO_QUERY);
859 uno::Reference<text::XTextRange> xShape(xDrawPage->getByIndex(nShape), uno::UNO_QUERY);
860 return xShape->getString();
864 void LOKitSearchTest::testReplace()
866 SdXImpressDocument* pXImpressDocument = createDoc("ReplaceTest.odp");
867 sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
868 mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
870 CPPUNIT_ASSERT_EQUAL(OUString("bbb"), getShapeText(pXImpressDocument, 0, 0));
871 CPPUNIT_ASSERT_EQUAL(OUString("Bbb bbb bbb bbb"), getShapeText(pXImpressDocument, 1, 0));
872 CPPUNIT_ASSERT_EQUAL(OUString("bbb"), getShapeText(pXImpressDocument, 2, 0));
873 CPPUNIT_ASSERT_EQUAL(OUString("bbb"), getShapeText(pXImpressDocument, 3, 0));
874 CPPUNIT_ASSERT_EQUAL(OUString("bbb"), getShapeText(pXImpressDocument, 4, 0));
876 lcl_replace("bbb", "aaa", false); // select
878 CPPUNIT_ASSERT_EQUAL(OUString("bbb"), getShapeText(pXImpressDocument, 0, 0));
879 CPPUNIT_ASSERT_EQUAL(OUString("Bbb bbb bbb bbb"), getShapeText(pXImpressDocument, 1, 0));
880 CPPUNIT_ASSERT_EQUAL(OUString("bbb"), getShapeText(pXImpressDocument, 2, 0));
881 CPPUNIT_ASSERT_EQUAL(OUString("bbb"), getShapeText(pXImpressDocument, 3, 0));
882 CPPUNIT_ASSERT_EQUAL(OUString("bbb"), getShapeText(pXImpressDocument, 4, 0));
884 lcl_replace("bbb", "aaa", false); // replace
886 CPPUNIT_ASSERT_EQUAL(OUString("aaa"), getShapeText(pXImpressDocument, 0, 0));
887 CPPUNIT_ASSERT_EQUAL(OUString("Bbb bbb bbb bbb"), getShapeText(pXImpressDocument, 1, 0));
888 CPPUNIT_ASSERT_EQUAL(OUString("bbb"), getShapeText(pXImpressDocument, 2, 0));
889 CPPUNIT_ASSERT_EQUAL(OUString("bbb"), getShapeText(pXImpressDocument, 3, 0));
890 CPPUNIT_ASSERT_EQUAL(OUString("bbb"), getShapeText(pXImpressDocument, 4, 0));
893 void LOKitSearchTest::testReplaceAll()
895 SdXImpressDocument* pXImpressDocument = createDoc("ReplaceTest.odp");
896 sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
897 mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
899 CPPUNIT_ASSERT_EQUAL(OUString("bbb"), getShapeText(pXImpressDocument, 0, 0));
900 CPPUNIT_ASSERT_EQUAL(OUString("Bbb bbb bbb bbb"), getShapeText(pXImpressDocument, 1, 0));
901 CPPUNIT_ASSERT_EQUAL(OUString("bbb"), getShapeText(pXImpressDocument, 2, 0));
902 CPPUNIT_ASSERT_EQUAL(OUString("bbb"), getShapeText(pXImpressDocument, 3, 0));
903 CPPUNIT_ASSERT_EQUAL(OUString("bbb"), getShapeText(pXImpressDocument, 4, 0));
905 lcl_replace("bbb", "ccc", true);
907 CPPUNIT_ASSERT_EQUAL(OUString("ccc"), getShapeText(pXImpressDocument, 0, 0));
908 CPPUNIT_ASSERT_EQUAL(OUString("ccc ccc ccc ccc"), getShapeText(pXImpressDocument, 1, 0));
909 CPPUNIT_ASSERT_EQUAL(OUString("ccc"), getShapeText(pXImpressDocument, 2, 0));
910 CPPUNIT_ASSERT_EQUAL(OUString("ccc"), getShapeText(pXImpressDocument, 3, 0));
911 CPPUNIT_ASSERT_EQUAL(OUString("ccc"), getShapeText(pXImpressDocument, 4, 0));
913 lcl_replace("ccc", "bbb", true);
915 CPPUNIT_ASSERT_EQUAL(OUString("bbb"), getShapeText(pXImpressDocument, 0, 0));
916 CPPUNIT_ASSERT_EQUAL(OUString("bbb bbb bbb bbb"), getShapeText(pXImpressDocument, 1, 0));
917 CPPUNIT_ASSERT_EQUAL(OUString("bbb"), getShapeText(pXImpressDocument, 2, 0));
918 CPPUNIT_ASSERT_EQUAL(OUString("bbb"), getShapeText(pXImpressDocument, 3, 0));
919 CPPUNIT_ASSERT_EQUAL(OUString("bbb"), getShapeText(pXImpressDocument, 4, 0));
922 void LOKitSearchTest::testReplaceCombined()
924 SdXImpressDocument* pXImpressDocument = createDoc("ReplaceTest.odp");
925 sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
926 mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
928 lcl_replace("bbb", "aaa", false); // select
929 lcl_replace("bbb", "aaa", false); // replace
931 CPPUNIT_ASSERT_EQUAL(OUString("aaa"), getShapeText(pXImpressDocument, 0, 0));
932 CPPUNIT_ASSERT_EQUAL(OUString("Bbb bbb bbb bbb"), getShapeText(pXImpressDocument, 1, 0));
933 CPPUNIT_ASSERT_EQUAL(OUString("bbb"), getShapeText(pXImpressDocument, 2, 0));
934 CPPUNIT_ASSERT_EQUAL(OUString("bbb"), getShapeText(pXImpressDocument, 3, 0));
935 CPPUNIT_ASSERT_EQUAL(OUString("bbb"), getShapeText(pXImpressDocument, 4, 0));
937 lcl_replace("bbb", "ccc", true);
939 CPPUNIT_ASSERT_EQUAL(OUString("aaa"), getShapeText(pXImpressDocument, 0, 0));
940 CPPUNIT_ASSERT_EQUAL(OUString("ccc ccc ccc ccc"), getShapeText(pXImpressDocument, 1, 0));
941 CPPUNIT_ASSERT_EQUAL(OUString("ccc"), getShapeText(pXImpressDocument, 2, 0));
942 CPPUNIT_ASSERT_EQUAL(OUString("ccc"), getShapeText(pXImpressDocument, 3, 0));
943 CPPUNIT_ASSERT_EQUAL(OUString("ccc"), getShapeText(pXImpressDocument, 4, 0));
946 CPPUNIT_TEST_SUITE_REGISTRATION(LOKitSearchTest);
948 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */