From 9f7c961e1c6e7b6aec783ba55a6b8cb6ebcf811d Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 24 Apr 2024 08:22:10 +0200 Subject: 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 Tested-by: Jenkins --- sc/source/ui/view/viewfun3.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sc/source') diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx index 615fa4ae89af..e287609906b6 100644 --- a/sc/source/ui/view/viewfun3.cxx +++ b/sc/source/ui/view/viewfun3.cxx @@ -462,7 +462,7 @@ rtl::Reference ScViewFunc::CopyToTransferable() { ScDocumentUniquePtr pClipDoc(new ScDocument(SCDOCMODE_CLIP)); // This takes care of the input line and calls CopyToClipMultiRange() for us. - CopyToClip(pClipDoc.get(), /*bCut=*/false, /*bApi=*/true); + CopyToClip(pClipDoc.get(), aRange, /*bCut=*/false, /*bApi=*/true); TransferableObjectDescriptor aObjDesc; return new ScTransferObj(std::move(pClipDoc), std::move(aObjDesc)); } -- cgit v1.2.3