Kaydet (Commit) 186f32f6 authored tarafından Miklos Vajna's avatar Miklos Vajna

sd tiled rendering: emit CALLBACK_TEXT_SELECTION on multiple search results

Change-Id: Ib6be973bf7c911907c793571b84021dc317dcc80
üst 11754fd7
......@@ -53,6 +53,7 @@ public:
void testResetSelection();
void testSearch();
void testSearchAll();
void testSearchAllSelections();
#endif
CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
......@@ -66,6 +67,7 @@ public:
CPPUNIT_TEST(testResetSelection);
CPPUNIT_TEST(testSearch);
CPPUNIT_TEST(testSearchAll);
CPPUNIT_TEST(testSearchAllSelections);
#endif
CPPUNIT_TEST_SUITE_END();
......@@ -436,6 +438,18 @@ void SdTiledRenderingTest::testSearchAll()
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), m_nPart);
}
void SdTiledRenderingTest::testSearchAllSelections()
{
SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp");
pXImpressDocument->registerCallback(&SdTiledRenderingTest::callback, this);
lcl_search("third", /*bFindAll=*/true);
// Make sure this is found on the 3rd slide.
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), m_nPart);
// This was 1: only the first match was highlighted.
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), m_aSelection.size());
}
#endif
CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest);
......
......@@ -605,6 +605,7 @@ bool Outliner::SearchAndReplaceAll()
return true;
}
std::vector<SearchSelection> aSelections;
if( 0 != dynamic_cast< const OutlineViewShell *>( pViewShell.get() ))
{
// Put the cursor to the beginning/end of the outliner.
......@@ -627,7 +628,6 @@ bool Outliner::SearchAndReplaceAll()
// Search/replace until the end of the document is reached.
bool bFoundMatch;
std::vector<SearchSelection> aSelections;
do
{
bFoundMatch = ! SearchAndReplaceOnce(&aSelections);
......@@ -673,6 +673,19 @@ bool Outliner::SearchAndReplaceAll()
// Find-all, tiled rendering and we have at least one match.
OString aPayload = OString::number(mnStartPageIndex);
pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_SET_PART, aPayload.getStr());
// Emit a selection callback here:
// 1) The original one is no longer valid, as we there was a SET_PART in between
// 2) The underlying editeng will only talk about the first match till
// it doesn't support multi-selection.
std::vector<OString> aRectangles;
for (const SearchSelection& rSelection : aSelections)
{
if (rSelection.m_nPage == mnStartPageIndex)
aRectangles.push_back(rSelection.m_aRectangles);
}
OString sRectangles = comphelper::string::join("; ", aRectangles);
pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION, sRectangles.getStr());
}
mnStartPageIndex = (sal_uInt16)-1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment