summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-10-15 15:20:23 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-10-15 16:25:13 +0200
commitcd4976988cf3acb4f1a23f1df7fcc2bfec0f3da0 (patch)
tree87906c91a0df1039fa8f50302a11e0180069749a /sd
parent74d686bc59cd70e7ad89f7845199eb751aa7145d (diff)
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
Diffstat (limited to 'sd')
-rw-r--r--sd/qa/unit/tiledrendering/data/search-all.odpbin0 -> 10744 bytes
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx19
-rw-r--r--sd/source/ui/view/Outliner.cxx13
3 files changed, 29 insertions, 3 deletions
diff --git a/sd/qa/unit/tiledrendering/data/search-all.odp b/sd/qa/unit/tiledrendering/data/search-all.odp
new file mode 100644
index 000000000000..cb3cb31cf5c7
--- /dev/null
+++ b/sd/qa/unit/tiledrendering/data/search-all.odp
Binary files differ
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 4a5c81b7498a..89a2bf11b228 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -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);
diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index 263ea6f92d5e..8c79ac4048ac 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -593,6 +593,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 ();
@@ -630,6 +631,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);
@@ -658,7 +669,7 @@ bool Outliner::SearchAndReplaceAll()
RestoreStartPosition ();
mnStartPageIndex = (sal_uInt16)-1;
- return true;
+ return bRet;
}
bool Outliner::SearchAndReplaceOnce(std::vector<SearchSelection>* pSelections)