diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2024-04-24 08:22:10 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2024-04-24 15:11:12 +0200 |
commit | 9f7c961e1c6e7b6aec783ba55a6b8cb6ebcf811d (patch) | |
tree | 8c164419f1ca7ac0fb536ba0145ffb25b303569e /sc/qa/unit | |
parent | 9d29a2a6aad679129218ab4c5020c92bb3ce9cb3 (diff) |
cool#8789 sc lok: classify multi-selection with 2 cells as simple
The trouble was that even if commit
b13c7b31f9ce3c3a25cffd0c35e7ee6b8c2a1895 (cool#8789 sc lok: fix copy for
multi-selections, 2024-04-19) made multi-selection copy work, just 2
cells in a multi-selection was classified as a complex selection at a
LOK level, while 2 cells next to each other is a simple selection, which
is inconsistent. (A LOK client can provide a simpler UI for simple
selections.)
What happens is that the multi-selection clipboard document had no
selection ranges defined, so ScDocument::GetClipArea() returned early,
so the numbers in the ScTransferObj ctor were left initialized, which at
the end lead to a >1000 cells in ScTransferObj::isComplex(), because we
were calculating uninitialized data.
Fix the problem by passing a range (that covers all ranges of the
multi-selection) to ScViewFunc::CopyToTransferable(), which avoids the
wrong col/row start/length, so the selection is classified as simple.
Also adapt testRowColumnSelections, which was just meant to check we
don't crash, but now the cell under the cell cursor is returned, so the
assert about the empty selection would fail.
Change-Id: If98212c623fa75adb2ddf628a6e90f3eef450e59
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166581
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sc/qa/unit')
-rw-r--r-- | sc/qa/unit/tiledrendering/tiledrendering.cxx | 4 | ||||
-rw-r--r-- | sc/qa/unit/tiledrendering2/tiledrendering2.cxx | 8 |
2 files changed, 10 insertions, 2 deletions
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index 6368a7f68b2e..651df397cc71 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -214,7 +214,7 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testRowColumnSelections) // When we copy this, we don't get anything useful, but we must not crash // (used to happen) aResult = apitest::helper::transferable::getTextSelection(pModelObj->getSelection(), "text/plain;charset=utf-8"_ostr); - CPPUNIT_ASSERT_EQUAL(OString(), aResult); + CPPUNIT_ASSERT_EQUAL("9"_ostr, aResult); // TODO check that we really selected what we wanted here @@ -226,7 +226,7 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testRowColumnSelections) // When we copy this, we don't get anything useful, but we must not crash // (used to happen) aResult = apitest::helper::transferable::getTextSelection(pModelObj->getSelection(), "text/plain;charset=utf-8"_ostr); - CPPUNIT_ASSERT_EQUAL(OString(), aResult); + CPPUNIT_ASSERT_EQUAL("1"_ostr, aResult); // TODO check that we really selected what we wanted here diff --git a/sc/qa/unit/tiledrendering2/tiledrendering2.cxx b/sc/qa/unit/tiledrendering2/tiledrendering2.cxx index 65a85c685b33..737a0be6a3c8 100644 --- a/sc/qa/unit/tiledrendering2/tiledrendering2.cxx +++ b/sc/qa/unit/tiledrendering2/tiledrendering2.cxx @@ -11,6 +11,8 @@ #include <boost/property_tree/json_parser.hpp> +#include <com/sun/star/datatransfer/XTransferable2.hpp> + #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <comphelper/lok.hxx> #include <comphelper/servicehelper.hxx> @@ -203,6 +205,12 @@ CPPUNIT_TEST_FIXTURE(Test, testCopyMultiSelection) // Make sure we get A1+A3 instead of an error: CPPUNIT_ASSERT(xTransferable.is()); + + // Also make sure that just 2 cells is classified as a simple selection: + uno::Reference<datatransfer::XTransferable2> xTransferable2(xTransferable, uno::UNO_QUERY); + CPPUNIT_ASSERT(xTransferable2.is()); + // Without the fix, the text selection was complex. + CPPUNIT_ASSERT(!xTransferable2->isComplex()); } } |