nss: upgrade to release 3.73
[LibreOffice.git] / sd / qa / unit / tiledrendering / LOKitSearchTest.cxx
blobbeba53b67078aa8bc9dfe2e8ca7dfa720f1f05ee
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 "../sdmodeltestbase.hxx"
11 #include <config_features.h>
13 #include "CallbackRecorder.hxx"
15 #include <test/bootstrapfixture.hxx>
16 #include <test/helper/transferable.hxx>
17 #include <test/xmltesttools.hxx>
19 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
20 #include <comphelper/dispatchcommand.hxx>
21 #include <comphelper/processfactory.hxx>
22 #include <comphelper/propertysequence.hxx>
23 #include <comphelper/string.hxx>
24 #include <comphelper/lok.hxx>
25 #include <sfx2/dispatch.hxx>
26 #include <sfx2/lokhelper.hxx>
27 #include <sfx2/viewfrm.hxx>
28 #include <svl/srchitem.hxx>
29 #include <svl/stritem.hxx>
30 #include <vcl/scheduler.hxx>
31 #include <ViewShellBase.hxx>
32 #include <ViewShell.hxx>
33 #include <unomodel.hxx>
35 #include <sdpage.hxx>
36 #include <svx/svdograf.hxx>
38 #include <com/sun/star/frame/Desktop.hpp>
40 using namespace css;
42 class LOKitSearchTest : public SdModelTestBase, public XmlTestTools
44 private:
45 static constexpr char DATA_DIRECTORY[] = "/sd/qa/unit/tiledrendering/data/";
47 public:
48 LOKitSearchTest() = default;
50 virtual void setUp() override;
51 virtual void tearDown() override;
53 void testSearch();
54 void testSearchAll();
55 void testSearchAllSelections();
56 void testSearchAllNotifications();
57 void testSearchAllFollowedBySearch();
58 void testDontSearchInMasterPages();
59 void testSearchInPDFNonExisting();
60 void testSearchInPDF();
61 void testSearchInPDFOnePDFObject();
62 void testSearchInPDFInMultiplePages();
63 void testSearchInPDFInMultiplePagesBackwards();
64 void testSearchIn2MixedObjects();
65 void testSearchIn6MixedObjects();
66 void testReplace();
67 void testReplaceAll();
68 void testReplaceCombined();
70 CPPUNIT_TEST_SUITE(LOKitSearchTest);
71 CPPUNIT_TEST(testSearch);
72 CPPUNIT_TEST(testSearchAll);
73 CPPUNIT_TEST(testSearchAllSelections);
74 CPPUNIT_TEST(testSearchAllNotifications);
75 CPPUNIT_TEST(testSearchAllFollowedBySearch);
76 CPPUNIT_TEST(testDontSearchInMasterPages);
77 CPPUNIT_TEST(testSearchInPDFNonExisting);
78 CPPUNIT_TEST(testSearchInPDF);
79 CPPUNIT_TEST(testSearchInPDFOnePDFObject);
80 CPPUNIT_TEST(testSearchInPDFInMultiplePages);
81 CPPUNIT_TEST(testSearchInPDFInMultiplePagesBackwards);
82 CPPUNIT_TEST(testSearchIn2MixedObjects);
83 CPPUNIT_TEST(testSearchIn6MixedObjects);
84 CPPUNIT_TEST(testReplace);
85 CPPUNIT_TEST(testReplaceAll);
86 CPPUNIT_TEST(testReplaceCombined);
87 CPPUNIT_TEST_SUITE_END();
89 private:
90 SdXImpressDocument* createDoc(const char* pName,
91 const uno::Sequence<beans::PropertyValue>& rArguments
92 = uno::Sequence<beans::PropertyValue>());
94 uno::Reference<lang::XComponent> mxComponent;
95 std::unique_ptr<CallbackRecorder> mpCallbackRecorder;
98 void LOKitSearchTest::setUp()
100 test::BootstrapFixture::setUp();
102 // prevent showing warning message box
103 setenv("OOX_NO_SMARTART_WARNING", "1", 1);
104 comphelper::LibreOfficeKit::setActive(true);
106 mxDesktop.set(
107 css::frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory())));
108 mpCallbackRecorder = std::make_unique<CallbackRecorder>();
111 void LOKitSearchTest::tearDown()
113 if (mxComponent.is())
114 mxComponent->dispose();
116 comphelper::LibreOfficeKit::setActive(false);
118 test::BootstrapFixture::tearDown();
121 SdXImpressDocument*
122 LOKitSearchTest::createDoc(const char* pName, const uno::Sequence<beans::PropertyValue>& rArguments)
124 if (mxComponent.is())
125 mxComponent->dispose();
127 mxComponent = loadFromDesktop(m_directories.getURLFromSrc(DATA_DIRECTORY)
128 + OUString::createFromAscii(pName));
130 CPPUNIT_ASSERT(mxComponent.is());
131 SdXImpressDocument* pImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
132 CPPUNIT_ASSERT(pImpressDocument);
133 pImpressDocument->initializeForTiledRendering(rArguments);
134 return pImpressDocument;
137 namespace
139 void lcl_search(const OUString& rKey, bool bFindAll = false, bool bBackwards = false)
141 Scheduler::ProcessEventsToIdle();
142 SvxSearchCmd eSearch = bFindAll ? SvxSearchCmd::FIND_ALL : SvxSearchCmd::FIND;
144 uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence({
145 { "SearchItem.SearchString", uno::makeAny(rKey) },
146 { "SearchItem.Backward", uno::makeAny(bBackwards) },
147 { "SearchItem.Command", uno::makeAny(sal_uInt16(eSearch)) },
148 }));
150 comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues);
151 Scheduler::ProcessEventsToIdle();
154 void lcl_replace(const OUString& rKey, const OUString& rReplace, bool bAll = false)
156 Scheduler::ProcessEventsToIdle();
158 SvxSearchCmd eSearch = bAll ? SvxSearchCmd::REPLACE_ALL : SvxSearchCmd::REPLACE;
160 uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence({
161 { "SearchItem.SearchString", uno::makeAny(rKey) },
162 { "SearchItem.ReplaceString", uno::makeAny(rReplace) },
163 { "SearchItem.Command", uno::makeAny(sal_uInt16(eSearch)) },
164 }));
166 comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues);
167 Scheduler::ProcessEventsToIdle();
170 #if HAVE_FEATURE_PDFIUM
171 SdrObject* lclGetSelectedObject(sd::ViewShell* pViewShell)
173 SdrView* pSdrView = pViewShell->GetView();
174 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
175 CPPUNIT_ASSERT_EQUAL(size_t(1), rMarkList.GetMarkCount());
176 SdrObject* pObject = rMarkList.GetMark(0)->GetMarkedSdrObj();
177 return pObject;
179 #endif
181 } // end anonymous namespace
183 void LOKitSearchTest::testSearch()
185 SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp");
186 sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
187 mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
188 uno::Reference<container::XIndexAccess> xDrawPage(
189 pXImpressDocument->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
190 uno::Reference<text::XTextRange> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
191 xShape->setString("Aaa bbb.");
193 lcl_search("bbb");
195 SdrView* pView = pViewShell->GetView();
196 EditView& rEditView = pView->GetTextEditOutlinerView()->GetEditView();
197 // Did we indeed manage to select the second word?
198 CPPUNIT_ASSERT_EQUAL(OUString("bbb"), rEditView.GetSelected());
200 // Did the selection callback fire?
201 CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(1), mpCallbackRecorder->m_aSelection.size());
203 // Search for something on the second slide, and make sure that the set-part callback fired.
204 lcl_search("bbb");
205 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), mpCallbackRecorder->m_nPart);
206 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
207 // This was 0; should be 1 match for "find".
208 CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(1),
209 mpCallbackRecorder->m_aSearchResultSelection.size());
210 // Result is on the second slide.
211 CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_aSearchResultPart[0]);
213 // This should trigger the not-found callback.
214 lcl_search("ccc");
215 CPPUNIT_ASSERT_EQUAL(false, mpCallbackRecorder->m_bFound);
218 void LOKitSearchTest::testSearchAll()
220 SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp");
221 sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
222 mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
224 lcl_search("match", /*bFindAll=*/true);
226 // This was empty: find-all did not highlight the first match.
227 CPPUNIT_ASSERT_EQUAL(OString("match"),
228 apitest::helper::transferable::getTextSelection(
229 pXImpressDocument->getSelection(), "text/plain;charset=utf-8"));
231 // We're on the first slide, search for something on the second slide and make sure we get a SET_PART.
232 mpCallbackRecorder->m_nPart = 0;
233 lcl_search("second", /*bFindAll=*/true);
234 // This was 0: no SET_PART was emitted.
235 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), mpCallbackRecorder->m_nPart);
238 void LOKitSearchTest::testSearchAllSelections()
240 SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp");
241 sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
242 mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
244 lcl_search("third", /*bFindAll=*/true);
245 // Make sure this is found on the 3rd slide.
246 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), mpCallbackRecorder->m_nPart);
248 CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(1), mpCallbackRecorder->m_aSelection.size());
251 void LOKitSearchTest::testSearchAllNotifications()
253 SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp");
254 sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
255 mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
257 lcl_search("third", /*bFindAll=*/true);
258 // Make sure that we get no notifications about selection changes during search.
259 CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_nSelectionBeforeSearchResult);
260 // But we do get the selection of the first hit.
261 CPPUNIT_ASSERT(mpCallbackRecorder->m_nSelectionAfterSearchResult > 0);
264 void LOKitSearchTest::testSearchAllFollowedBySearch()
266 SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp");
267 sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
268 mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
270 lcl_search("third", /*bFindAll=*/true);
271 lcl_search("match" /*,bFindAll=false*/);
273 // This used to give wrong result: 'search' after 'search all' still
274 // returned 'third'
275 CPPUNIT_ASSERT_EQUAL(OString("match"),
276 apitest::helper::transferable::getTextSelection(
277 pXImpressDocument->getSelection(), "text/plain;charset=utf-8"));
280 void LOKitSearchTest::testDontSearchInMasterPages()
282 SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp");
283 sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
284 mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
286 // This should trigger the not-found callback ("date" is present only on
287 // the master page)
288 lcl_search("date");
289 CPPUNIT_ASSERT_EQUAL(false, mpCallbackRecorder->m_bFound);
292 void LOKitSearchTest::testSearchInPDFNonExisting()
294 #if HAVE_FEATURE_PDFIUM
295 SdXImpressDocument* pXImpressDocument = createDoc("PDFSearch.pdf");
296 sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
297 CPPUNIT_ASSERT(pViewShell);
298 mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
300 SdPage* pPage = pViewShell->GetActualPage();
301 CPPUNIT_ASSERT(pPage);
303 SdrObject* pObject = pPage->GetObj(0);
304 CPPUNIT_ASSERT(pObject);
306 SdrGrafObj* pGraphicObject = dynamic_cast<SdrGrafObj*>(pObject);
307 CPPUNIT_ASSERT(pGraphicObject);
309 Graphic aGraphic = pGraphicObject->GetGraphic();
310 auto const& pVectorGraphicData = aGraphic.getVectorGraphicData();
311 CPPUNIT_ASSERT(pVectorGraphicData);
312 CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
313 pVectorGraphicData->getVectorGraphicDataType());
315 lcl_search("NonExisting");
317 CPPUNIT_ASSERT_EQUAL(false, mpCallbackRecorder->m_bFound);
318 #endif
321 void LOKitSearchTest::testSearchInPDF()
323 #if HAVE_FEATURE_PDFIUM
324 SdXImpressDocument* pXImpressDocument = createDoc("PDFSearch.pdf");
325 sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
326 CPPUNIT_ASSERT(pViewShell);
327 mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
329 SdPage* pPage = pViewShell->GetActualPage();
330 CPPUNIT_ASSERT(pPage);
332 SdrObject* pObject = pPage->GetObj(0);
333 CPPUNIT_ASSERT(pObject);
335 SdrGrafObj* pGraphicObject = dynamic_cast<SdrGrafObj*>(pObject);
336 CPPUNIT_ASSERT(pGraphicObject);
338 Graphic aGraphic = pGraphicObject->GetGraphic();
339 auto const& pVectorGraphicData = aGraphic.getVectorGraphicData();
340 CPPUNIT_ASSERT(pVectorGraphicData);
341 CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
342 pVectorGraphicData->getVectorGraphicDataType());
344 // Search
345 lcl_search("ABC");
347 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
348 CPPUNIT_ASSERT_EQUAL(1, 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]);
356 // Search again - same result
357 lcl_search("ABC");
359 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
360 CPPUNIT_ASSERT_EQUAL(2, mpCallbackRecorder->m_nSearchResultCount);
362 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
363 CPPUNIT_ASSERT_EQUAL(OString("3763, 1331, 1432, 483"),
364 mpCallbackRecorder->m_aSearchResultSelection[0]);
365 CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(3763, 1331), Size(1433, 484)),
366 mpCallbackRecorder->m_aSelection[0]);
367 #endif
370 void LOKitSearchTest::testSearchInPDFOnePDFObject()
372 #if HAVE_FEATURE_PDFIUM
373 SdXImpressDocument* pXImpressDocument = createDoc("OnePDFObject.odg");
374 sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
375 CPPUNIT_ASSERT(pViewShell);
376 mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
378 SdPage* pPage = pViewShell->GetActualPage();
379 CPPUNIT_ASSERT(pPage);
381 SdrObject* pObject = pPage->GetObj(0);
382 CPPUNIT_ASSERT(pObject);
384 SdrGrafObj* pGraphicObject = dynamic_cast<SdrGrafObj*>(pObject);
385 CPPUNIT_ASSERT(pGraphicObject);
387 Graphic aGraphic = pGraphicObject->GetGraphic();
388 auto const& pVectorGraphicData = aGraphic.getVectorGraphicData();
389 CPPUNIT_ASSERT(pVectorGraphicData);
390 CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
391 pVectorGraphicData->getVectorGraphicDataType());
393 // Search down
394 lcl_search("ABC", false, false);
396 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
397 CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_nSearchResultCount);
399 // Search up
400 lcl_search("ABC", false, true); // This caused a crash
402 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
403 CPPUNIT_ASSERT_EQUAL(2, mpCallbackRecorder->m_nSearchResultCount);
404 #endif
407 void LOKitSearchTest::testSearchInPDFInMultiplePages()
409 #if HAVE_FEATURE_PDFIUM
410 SdXImpressDocument* pXImpressDocument = createDoc("PDFSearch.pdf");
411 sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
412 CPPUNIT_ASSERT(pViewShell);
413 mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
415 SdPage* pPage = pViewShell->GetActualPage();
416 CPPUNIT_ASSERT(pPage);
419 SdrObject* pObject = pPage->GetObj(0);
420 CPPUNIT_ASSERT(pObject);
422 SdrGrafObj* pGraphicObject = dynamic_cast<SdrGrafObj*>(pObject);
423 CPPUNIT_ASSERT(pGraphicObject);
425 Graphic aGraphic = pGraphicObject->GetGraphic();
426 auto const& pVectorGraphicData = aGraphic.getVectorGraphicData();
427 CPPUNIT_ASSERT(pVectorGraphicData);
428 CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
429 pVectorGraphicData->getVectorGraphicDataType());
432 // Search for "him"
433 lcl_search("him");
435 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
436 CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_nSearchResultCount);
438 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
439 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
441 CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_aSearchResultPart[0]);
442 CPPUNIT_ASSERT_EQUAL(OString("9463, 3382, 1099, 499"),
443 mpCallbackRecorder->m_aSearchResultSelection[0]);
445 // Search for "him"
446 lcl_search("him");
448 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
449 CPPUNIT_ASSERT_EQUAL(2, mpCallbackRecorder->m_nSearchResultCount);
451 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
452 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
454 CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_aSearchResultPart[0]);
455 CPPUNIT_ASSERT_EQUAL(OString("5592, 5038, 1100, 499"),
456 mpCallbackRecorder->m_aSearchResultSelection[0]);
458 // Search for "him"
459 lcl_search("him");
461 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
462 CPPUNIT_ASSERT_EQUAL(3, mpCallbackRecorder->m_nSearchResultCount);
464 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
465 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
467 CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_aSearchResultPart[0]);
468 CPPUNIT_ASSERT_EQUAL(OString("9463, 1308, 1099, 499"),
469 mpCallbackRecorder->m_aSearchResultSelection[0]);
471 // Search for "him"
472 lcl_search("him");
474 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
475 CPPUNIT_ASSERT_EQUAL(4, mpCallbackRecorder->m_nSearchResultCount);
477 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
478 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
480 CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_aSearchResultPart[0]);
481 CPPUNIT_ASSERT_EQUAL(OString("5592, 2964, 1100, 499"),
482 mpCallbackRecorder->m_aSearchResultSelection[0]);
484 // Search for "him" - back to start
485 lcl_search("him");
487 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
488 CPPUNIT_ASSERT_EQUAL(5, mpCallbackRecorder->m_nSearchResultCount);
490 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
491 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
493 CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_aSearchResultPart[0]);
494 CPPUNIT_ASSERT_EQUAL(OString("9463, 3382, 1099, 499"),
495 mpCallbackRecorder->m_aSearchResultSelection[0]);
496 #endif
499 void LOKitSearchTest::testSearchInPDFInMultiplePagesBackwards()
501 #if HAVE_FEATURE_PDFIUM
502 SdXImpressDocument* pXImpressDocument = createDoc("PDFSearch.pdf");
503 sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
504 CPPUNIT_ASSERT(pViewShell);
505 mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
507 SdPage* pPage = pViewShell->GetActualPage();
508 CPPUNIT_ASSERT(pPage);
511 SdrObject* pObject = pPage->GetObj(0);
512 CPPUNIT_ASSERT(pObject);
514 SdrGrafObj* pGraphicObject = dynamic_cast<SdrGrafObj*>(pObject);
515 CPPUNIT_ASSERT(pGraphicObject);
517 Graphic aGraphic = pGraphicObject->GetGraphic();
518 auto const& pVectorGraphicData = aGraphic.getVectorGraphicData();
519 CPPUNIT_ASSERT(pVectorGraphicData);
520 CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
521 pVectorGraphicData->getVectorGraphicDataType());
524 // Expected for backwards search is:
525 // - Start with Page 1
526 // + search backwards through objects
527 // + inside objects search backwards through text
528 // - Switch to Page 2
529 // + search backwards through objects
530 // + inside objects search backwards through text
532 // Search for "him"
533 lcl_search("him", /*FindAll*/ false, /*Backwards*/ true);
535 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
536 CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_nSearchResultCount);
538 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
539 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
541 CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_aSearchResultPart[0]);
542 CPPUNIT_ASSERT_EQUAL(OString("5592, 5038, 1100, 499"),
543 mpCallbackRecorder->m_aSearchResultSelection[0]);
545 // Search for "him"
546 lcl_search("him", /*FindAll*/ false, /*Backwards*/ true);
548 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
549 CPPUNIT_ASSERT_EQUAL(2, mpCallbackRecorder->m_nSearchResultCount);
551 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
552 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
554 CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_aSearchResultPart[0]);
555 CPPUNIT_ASSERT_EQUAL(OString("9463, 3382, 1099, 499"),
556 mpCallbackRecorder->m_aSearchResultSelection[0]);
558 // Search for "him"
559 lcl_search("him", /*FindAll*/ false, /*Backwards*/ true);
561 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
562 CPPUNIT_ASSERT_EQUAL(3, mpCallbackRecorder->m_nSearchResultCount);
564 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
565 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
567 CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_aSearchResultPart[0]);
568 CPPUNIT_ASSERT_EQUAL(OString("5592, 2964, 1100, 499"),
569 mpCallbackRecorder->m_aSearchResultSelection[0]);
571 // Search for "him"
572 lcl_search("him", /*FindAll*/ false, /*Backwards*/ true);
574 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
575 CPPUNIT_ASSERT_EQUAL(4, mpCallbackRecorder->m_nSearchResultCount);
577 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
578 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
580 CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_aSearchResultPart[0]);
581 CPPUNIT_ASSERT_EQUAL(OString("9463, 1308, 1099, 499"),
582 mpCallbackRecorder->m_aSearchResultSelection[0]);
584 // Search for "him" - back to start
585 lcl_search("him", /*FindAll*/ false, /*Backwards*/ true);
587 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
588 CPPUNIT_ASSERT_EQUAL(5, mpCallbackRecorder->m_nSearchResultCount);
590 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
591 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
593 CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_aSearchResultPart[0]);
594 CPPUNIT_ASSERT_EQUAL(OString("5592, 5038, 1100, 499"),
595 mpCallbackRecorder->m_aSearchResultSelection[0]);
596 #endif
599 // Test searching in document with mixed objects.
600 // We have 2 objects: 1. Text Object, 2. Graphic Object with PDF
601 void LOKitSearchTest::testSearchIn2MixedObjects()
603 #if HAVE_FEATURE_PDFIUM
604 SdXImpressDocument* pXImpressDocument = createDoc("MixedTest1.odg");
605 sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
606 CPPUNIT_ASSERT(pViewShell);
607 SdDrawDocument* pDocument = pXImpressDocument->GetDocShell()->GetDoc();
608 CPPUNIT_ASSERT(pDocument);
609 mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
611 // Check we have one page
612 CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), pDocument->GetSdPageCount(PageKind::Standard));
614 SdPage* pPage = pViewShell->GetActualPage();
615 CPPUNIT_ASSERT(pPage);
617 // Check page has 2 objects only
618 CPPUNIT_ASSERT_EQUAL(size_t(2), pPage->GetObjCount());
620 // Check Object 1
622 SdrObject* pObject = pPage->GetObj(0);
623 CPPUNIT_ASSERT(pObject);
625 CPPUNIT_ASSERT_EQUAL(OBJ_TEXT, pObject->GetObjIdentifier());
628 // Check Object 2
630 SdrObject* pObject = pPage->GetObj(1);
631 CPPUNIT_ASSERT(pObject);
633 CPPUNIT_ASSERT_EQUAL(OBJ_GRAF, pObject->GetObjIdentifier());
635 SdrGrafObj* pGraphicObject = dynamic_cast<SdrGrafObj*>(pObject);
636 CPPUNIT_ASSERT(pGraphicObject);
638 Graphic aGraphic = pGraphicObject->GetGraphic();
639 auto const& pVectorGraphicData = aGraphic.getVectorGraphicData();
640 CPPUNIT_ASSERT(pVectorGraphicData);
642 CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
643 pVectorGraphicData->getVectorGraphicDataType());
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]);
684 #endif
687 // Test searching in document with mixed objects. We have 6 objects.
688 void LOKitSearchTest::testSearchIn6MixedObjects()
690 #if HAVE_FEATURE_PDFIUM
691 SdXImpressDocument* pXImpressDocument = createDoc("MixedTest2.odg");
692 sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
693 CPPUNIT_ASSERT(pViewShell);
694 SdDrawDocument* pDocument = pXImpressDocument->GetDocShell()->GetDoc();
695 CPPUNIT_ASSERT(pDocument);
696 mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
698 // Check we have one page
699 CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), pDocument->GetSdPageCount(PageKind::Standard));
701 SdPage* pPage = pViewShell->GetActualPage();
702 CPPUNIT_ASSERT(pPage);
704 // Check page has 6 objects only
705 CPPUNIT_ASSERT_EQUAL(size_t(6), pPage->GetObjCount());
707 // Check we have the right objects that we expect
709 // Check Object 1
711 SdrObject* pObject = pPage->GetObj(0);
712 CPPUNIT_ASSERT(pObject);
713 CPPUNIT_ASSERT_EQUAL(OBJ_TEXT, pObject->GetObjIdentifier());
716 // Check Object 2
718 SdrObject* pObject = pPage->GetObj(1);
719 CPPUNIT_ASSERT(pObject);
720 CPPUNIT_ASSERT_EQUAL(OBJ_GRAF, pObject->GetObjIdentifier());
721 SdrGrafObj* pGraphicObject = dynamic_cast<SdrGrafObj*>(pObject);
722 CPPUNIT_ASSERT(pGraphicObject);
723 auto const& pVectorGraphicData = pGraphicObject->GetGraphic().getVectorGraphicData();
724 CPPUNIT_ASSERT(pVectorGraphicData);
725 CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
726 pVectorGraphicData->getVectorGraphicDataType());
729 // Check Object 3
731 SdrObject* pObject = pPage->GetObj(2);
732 CPPUNIT_ASSERT(pObject);
733 CPPUNIT_ASSERT_EQUAL(OBJ_CUSTOMSHAPE, pObject->GetObjIdentifier());
736 // Check Object 4
738 SdrObject* pObject = pPage->GetObj(3);
739 CPPUNIT_ASSERT(pObject);
740 CPPUNIT_ASSERT_EQUAL(OBJ_CUSTOMSHAPE, pObject->GetObjIdentifier());
743 // Check Object 5
745 SdrObject* pObject = pPage->GetObj(4);
746 CPPUNIT_ASSERT(pObject);
747 CPPUNIT_ASSERT_EQUAL(OBJ_GRAF, pObject->GetObjIdentifier());
748 SdrGrafObj* pGraphicObject = dynamic_cast<SdrGrafObj*>(pObject);
749 CPPUNIT_ASSERT(pGraphicObject);
750 auto const& pVectorGraphicData = pGraphicObject->GetGraphic().getVectorGraphicData();
751 CPPUNIT_ASSERT(pVectorGraphicData);
752 CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Svg,
753 pVectorGraphicData->getVectorGraphicDataType());
756 // Check Object 6
758 SdrObject* pObject = pPage->GetObj(5);
759 CPPUNIT_ASSERT(pObject);
760 CPPUNIT_ASSERT_EQUAL(OBJ_GRAF, pObject->GetObjIdentifier());
761 SdrGrafObj* pGraphicObject = dynamic_cast<SdrGrafObj*>(pObject);
762 CPPUNIT_ASSERT(pGraphicObject);
763 auto const& pVectorGraphicData = pGraphicObject->GetGraphic().getVectorGraphicData();
764 CPPUNIT_ASSERT(pVectorGraphicData);
765 CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
766 pVectorGraphicData->getVectorGraphicDataType());
769 // Search "ABC" which is in all objects (2 times in Object 3)
771 // Object 1
772 lcl_search("ABC");
774 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
775 CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_nSearchResultCount);
777 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
778 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
779 CPPUNIT_ASSERT_EQUAL(pPage->GetObj(0), lclGetSelectedObject(pViewShell));
781 // Object 2
782 lcl_search("ABC");
784 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
785 CPPUNIT_ASSERT_EQUAL(2, mpCallbackRecorder->m_nSearchResultCount);
787 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
788 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
789 CPPUNIT_ASSERT_EQUAL(pPage->GetObj(1), lclGetSelectedObject(pViewShell));
791 // Object 3
792 lcl_search("ABC");
794 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
795 CPPUNIT_ASSERT_EQUAL(3, mpCallbackRecorder->m_nSearchResultCount);
797 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
798 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
799 CPPUNIT_ASSERT_EQUAL(pPage->GetObj(2), lclGetSelectedObject(pViewShell));
801 // Object 3 again
802 lcl_search("ABC");
804 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
805 CPPUNIT_ASSERT_EQUAL(4, mpCallbackRecorder->m_nSearchResultCount);
807 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
808 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
809 CPPUNIT_ASSERT_EQUAL(pPage->GetObj(2), lclGetSelectedObject(pViewShell));
811 // Object 4
812 lcl_search("ABC");
814 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
815 CPPUNIT_ASSERT_EQUAL(5, mpCallbackRecorder->m_nSearchResultCount);
817 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
818 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
819 CPPUNIT_ASSERT_EQUAL(pPage->GetObj(3), lclGetSelectedObject(pViewShell));
821 // Object 5
822 lcl_search("ABC");
824 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
825 CPPUNIT_ASSERT_EQUAL(6, mpCallbackRecorder->m_nSearchResultCount);
827 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
828 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
829 CPPUNIT_ASSERT_EQUAL(pPage->GetObj(4), lclGetSelectedObject(pViewShell));
831 // Object 6
832 lcl_search("ABC");
834 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
835 CPPUNIT_ASSERT_EQUAL(7, mpCallbackRecorder->m_nSearchResultCount);
837 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
838 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
839 CPPUNIT_ASSERT_EQUAL(pPage->GetObj(5), lclGetSelectedObject(pViewShell));
841 // Loop to Object 1 again
842 lcl_search("ABC");
844 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
845 CPPUNIT_ASSERT_EQUAL(8, mpCallbackRecorder->m_nSearchResultCount);
847 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
848 CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
849 CPPUNIT_ASSERT_EQUAL(pPage->GetObj(0), lclGetSelectedObject(pViewShell));
850 #endif
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: */