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

sd tiled rendering: let find-all at least select the first match physically

The LOK API can describe a multi-selection, so find-all can signal all
matches, editeng can have a single selection only. Instead of having no
selections after a find-all, select the first match, so e.g. copy works.

Change-Id: I0eab2565916f0c3cce5d77279c0d927ad4b7054c
(cherry picked from commit cd497698)
üst 05bb293c
......@@ -23,6 +23,7 @@
#include <editeng/outliner.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/viewfrm.hxx>
#include <svl/srchitem.hxx>
#include <DrawDocShell.hxx>
#include <ViewShell.hxx>
......@@ -51,6 +52,7 @@ public:
void testSetGraphicSelection();
void testResetSelection();
void testSearch();
void testSearchAll();
#endif
CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
......@@ -63,6 +65,7 @@ public:
CPPUNIT_TEST(testSetGraphicSelection);
CPPUNIT_TEST(testResetSelection);
CPPUNIT_TEST(testSearch);
CPPUNIT_TEST(testSearchAll);
#endif
CPPUNIT_TEST_SUITE_END();
......@@ -371,12 +374,13 @@ void SdTiledRenderingTest::testResetSelection()
CPPUNIT_ASSERT(!pView->GetTextEditObject());
}
static void lcl_search(const OUString& rKey)
static void lcl_search(const OUString& rKey, bool bFindAll = false)
{
uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
{
{"SearchItem.SearchString", uno::makeAny(rKey)},
{"SearchItem.Backward", uno::makeAny(false)}
{"SearchItem.Backward", uno::makeAny(false)},
{"SearchItem.Command", uno::makeAny(static_cast<sal_uInt16>(bFindAll ? SvxSearchCmd::FIND_ALL : SvxSearchCmd::FIND))},
}));
comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues);
}
......@@ -414,6 +418,17 @@ void SdTiledRenderingTest::testSearch()
CPPUNIT_ASSERT_EQUAL(false, m_bFound);
}
void SdTiledRenderingTest::testSearchAll()
{
SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp");
lcl_search("match", /*bFindAll=*/true);
OString aUsedFormat;
// This was empty: find-all did not highlight the first match.
CPPUNIT_ASSERT_EQUAL(OString("match"), pXImpressDocument->getTextSelection("text/plain;charset=utf-8", aUsedFormat));
}
#endif
CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest);
......
......@@ -599,6 +599,7 @@ void Outliner::Initialize (bool bDirectionIsForward)
bool Outliner::SearchAndReplaceAll()
{
bool bRet = true;
// Save the current position to be restored after having replaced all
// matches.
RememberStartPosition ();
......@@ -636,6 +637,16 @@ bool Outliner::SearchAndReplaceAll()
do
{
bFoundMatch = ! SearchAndReplaceOnce(&aSelections);
if (mpSearchItem->GetCommand() == SvxSearchCmd::FIND_ALL && pViewShell->GetDoc()->isTiledRendering() && bFoundMatch && aSelections.size() == 1)
{
// Without this, RememberStartPosition() will think it already has a remembered position.
mnStartPageIndex = (sal_uInt16)-1;
RememberStartPosition();
// So when RestoreStartPosition() restores the first match, then spellchecker doesn't kill the selection.
bRet = false;
}
}
while (bFoundMatch);
......@@ -664,7 +675,7 @@ bool Outliner::SearchAndReplaceAll()
RestoreStartPosition ();
mnStartPageIndex = (sal_uInt16)-1;
return true;
return bRet;
}
bool Outliner::SearchAndReplaceOnce(std::vector<SearchSelection>* pSelections)
......
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