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: ...@@ -53,6 +53,7 @@ public:
void testResetSelection(); void testResetSelection();
void testSearch(); void testSearch();
void testSearchAll(); void testSearchAll();
void testSearchAllSelections();
#endif #endif
CPPUNIT_TEST_SUITE(SdTiledRenderingTest); CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
...@@ -66,6 +67,7 @@ public: ...@@ -66,6 +67,7 @@ public:
CPPUNIT_TEST(testResetSelection); CPPUNIT_TEST(testResetSelection);
CPPUNIT_TEST(testSearch); CPPUNIT_TEST(testSearch);
CPPUNIT_TEST(testSearchAll); CPPUNIT_TEST(testSearchAll);
CPPUNIT_TEST(testSearchAllSelections);
#endif #endif
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
...@@ -436,6 +438,18 @@ void SdTiledRenderingTest::testSearchAll() ...@@ -436,6 +438,18 @@ void SdTiledRenderingTest::testSearchAll()
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), m_nPart); 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 #endif
CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest); CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest);
......
...@@ -605,6 +605,7 @@ bool Outliner::SearchAndReplaceAll() ...@@ -605,6 +605,7 @@ bool Outliner::SearchAndReplaceAll()
return true; return true;
} }
std::vector<SearchSelection> aSelections;
if( 0 != dynamic_cast< const OutlineViewShell *>( pViewShell.get() )) if( 0 != dynamic_cast< const OutlineViewShell *>( pViewShell.get() ))
{ {
// Put the cursor to the beginning/end of the outliner. // Put the cursor to the beginning/end of the outliner.
...@@ -627,7 +628,6 @@ bool Outliner::SearchAndReplaceAll() ...@@ -627,7 +628,6 @@ bool Outliner::SearchAndReplaceAll()
// Search/replace until the end of the document is reached. // Search/replace until the end of the document is reached.
bool bFoundMatch; bool bFoundMatch;
std::vector<SearchSelection> aSelections;
do do
{ {
bFoundMatch = ! SearchAndReplaceOnce(&aSelections); bFoundMatch = ! SearchAndReplaceOnce(&aSelections);
...@@ -673,6 +673,19 @@ bool Outliner::SearchAndReplaceAll() ...@@ -673,6 +673,19 @@ bool Outliner::SearchAndReplaceAll()
// Find-all, tiled rendering and we have at least one match. // Find-all, tiled rendering and we have at least one match.
OString aPayload = OString::number(mnStartPageIndex); OString aPayload = OString::number(mnStartPageIndex);
pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_SET_PART, aPayload.getStr()); 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; 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