summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2020-01-02 19:30:06 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2020-01-02 19:30:38 +0100
commitd8a188d8d59ae51621a0540fe931e1c70db285fe (patch)
tree2ba081ffb5330180d6b64e8a26f1ff687f3d70e5
parent9d31d8f1d8d3a73f8c07ca39f5ed45e2bb7b088c (diff)
tdf#129743: don't delete mark of current cursor when creating new cursor
The deletion was there since initial import in commit 84a3db80b4fd66c6854b3135b5f69b61fd828e62. It's unclear why would it be necessary and what depend on it. All tests pass => let's drop it. Another (less intrusive, and IMO more of a workaround) way would be to move setting mark of pCursor after the loop over GetNext() in SwCursorShell::SetSelection. Change-Id: I5402db58d8f829799bc16b8f4f6014bcea133995 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86142 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r--sw/qa/extras/unowriter/unowriter.cxx38
-rw-r--r--sw/source/core/crsr/crsrsh.cxx2
2 files changed, 38 insertions, 2 deletions
diff --git a/sw/qa/extras/unowriter/unowriter.cxx b/sw/qa/extras/unowriter/unowriter.cxx
index 630a72afa6b1..1cceb108181d 100644
--- a/sw/qa/extras/unowriter/unowriter.cxx
+++ b/sw/qa/extras/unowriter/unowriter.cxx
@@ -20,6 +20,7 @@
#include <com/sun/star/awt/XToolkit.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
#include <com/sun/star/style/LineSpacing.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
#include <comphelper/propertyvalue.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <vcl/graphicfilter.hxx>
@@ -786,6 +787,43 @@ CPPUNIT_TEST_FIXTURE(SwUnoWriter, testTextConvertToTableLineSpacing)
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(convertTwipToMm100(220)), aLineSpacing.Height);
}
+CPPUNIT_TEST_FIXTURE(SwUnoWriter, testMultiSelect)
+{
+ // Create a new document and add a text with several repeated sequences.
+ loadURL("private:factory/swriter", nullptr);
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, css::uno::UNO_QUERY_THROW);
+ auto xSimpleText = xTextDocument->getText();
+ xSimpleText->insertString(xSimpleText->getStart(), "abc abc abc", false);
+
+ // Create a search descriptor and find all occurencies of search string
+ css::uno::Reference<css::util::XSearchable> xSearchable(mxComponent, css::uno::UNO_QUERY_THROW);
+ auto xSearchDescriptor = xSearchable->createSearchDescriptor();
+ xSearchDescriptor->setPropertyValue("SearchStyles", css::uno::Any(false));
+ xSearchDescriptor->setPropertyValue("SearchCaseSensitive", css::uno::Any(false));
+ xSearchDescriptor->setPropertyValue("SearchBackwards", css::uno::Any(true));
+ xSearchDescriptor->setPropertyValue("SearchRegularExpression", css::uno::Any(false));
+ xSearchDescriptor->setSearchString("Abc");
+ auto xSearchResult = xSearchable->findAll(xSearchDescriptor);
+
+ // Select them all
+ auto xController = xTextDocument->getCurrentController();
+ css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(
+ xController, css::uno::UNO_QUERY_THROW);
+ xSelectionSupplier->select(css::uno::Any(xSearchResult));
+ css::uno::Reference<css::container::XIndexAccess> xSelection(xSelectionSupplier->getSelection(),
+ css::uno::UNO_QUERY_THROW);
+ // Now check that they all are selected.
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xSelection->getCount());
+ for (sal_Int32 i = 0; i < xSelection->getCount(); ++i)
+ {
+ css::uno::Reference<css::text::XTextRange> xTextRange(xSelection->getByIndex(i),
+ css::uno::UNO_QUERY_THROW);
+ // For i=0, result was empty (cursor was put before the last occurence without selection)
+ const OString sComment = "i=" + OString::number(i);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sComment.getStr(), OUString("abc"), xTextRange->getString());
+ }
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 838159a28034..29293a841ebe 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -127,8 +127,6 @@ SwPaM * SwCursorShell::CreateCursor()
// copied PaM (#i75172#)
pNew->swapContent(*m_pCurrentCursor);
- m_pCurrentCursor->DeleteMark();
-
UpdateCursor( SwCursorShell::SCROLLWIN );
return pNew;
}