Bug 65856 - Paste Special - Shift Cell misbehaviour
Summary: Paste Special - Shift Cell misbehaviour
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
4.0.3.3 release
Hardware: Other All
: medium normal
Assignee: Winfried Donkers
URL:
Whiteboard: target:4.2.0 target:4.1.0.2 target:4....
Keywords: regression
: 65957 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-06-17 10:55 UTC by Eike Rathke
Modified: 2018-03-18 10:06 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
testcase (10.27 KB, application/vnd.oasis.opendocument.spreadsheet)
2013-06-17 10:55 UTC, Eike Rathke
Details
testcase with problems when shift cells is enabled (6.56 KB, application/vnd.oasis.opendocument.spreadsheet)
2013-06-25 05:56 UTC, Winfried Donkers
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eike Rathke 2013-06-17 10:55:09 UTC
Created attachment 80947 [details]
testcase

Please see attached file:

goal is to copy the content of D and E and insert it before D, while the original D and E are move to the right (so to F and G)

reproduce:

- mark D1:E14
- copy
- mark cell D1
- right click on D1 and "Paste Special"

Shift cell is grayed out.

Expected behavior:

enable the user to shift D and E to the right or even down.

If you right click on B1 and click on "Paste Special" Shift cells is available and if you choose "Right" it copies D and E before B, while shifting B:E to the right.
Comment 1 Eike Rathke 2013-06-17 10:56:07 UTC
Regression, worked in 3.6.6
Comment 2 Eike Rathke 2013-06-21 17:01:37 UTC
*** Bug 65957 has been marked as a duplicate of this bug. ***
Comment 3 Winfried Donkers 2013-06-24 08:47:12 UTC
(In reply to comment #0)
Eike,
I think know the cause of this behaviour, my patch for bug 56098.
I rewrote the checks to be performed before enabling shift options in the paste special dialog.
By doing this I disabled the shift options when source range and destination range intersect, both for cut and for copy mode, on the assumption that the outcome could be unwanted (especially with references and the like).

Before my patch, disabling the shift options was for cut mode only.
I have a patch ready in which intersection of source and destination range will not disable the shift options (and will still disable in case of cut mode).
However, before submitting that patch I would like confirmation that intersection of source and destination range is not a problem when copying.
Comment 4 Winfried Donkers 2013-06-25 05:56:29 UTC
Created attachment 81386 [details]
testcase with problems when shift cells is enabled

When shift cells is enabled in paste special for copy-mode, the following problem(s) occur:
1. open attachment
2. select range C2:D4
3. select B2
4. open paste special dialog and select shift right (of course only possible with modified code)
5. paste
Result is as expected for rows 3 and 4, but not for row 2.
Contents of row 2 are [celladdress, content, result]:
[B2, =$B2, Err:522] [C2, =A2, 0] [D2, 1, 1] [E2, =$D2, 1] [F2, =D2, 1]
The absolute reference in B2 has not been moved with the shift-cells.
The relative reference in C2 has been kept relative to the destination and not kept relative to the source.

IMHO this either is another bug or disabling the shift cells in paste special for copy-mode is correct when source and destination overlap.

@Eike,
Your expert opinion is highly appreciated.

The code change is simple:
core/sc/source/ui/view/cellsh1.cxx, line 1294
    if ( aSource.Intersects( aDest ) )
must be changed to
    if ( pOwnClip->GetDocument()->IsCutMode() && aSource.Intersects( aDest ) )
to enable shift cells for copy-mode.
Comment 5 Winfried Donkers 2013-06-26 05:43:37 UTC
(In reply to comment #4)
I found out that the described behaviour has nothing to do with overlapping source and destination area; it is a problem as described in bug 44383.

I will submit patch for paste special shift cell options in case of copy-mode.
Comment 6 Eike Rathke 2013-06-26 18:33:21 UTC
(In reply to comment #5)
> (In reply to comment #4)
> I found out that the described behaviour has nothing to do with overlapping
> source and destination area; it is a problem as described in bug 44383.

Note that the original description and testcase says that when special-pasting to B1 instead of D1 or C1 the shift-cells option is not disabled, this actually does depend on whether the destination range overlaps the original range. When copy&pasting one column only (e.g. copy E1:E14) it can't be shift-pasted onto E1 but to all other columns.
Comment 7 Eike Rathke 2013-06-26 22:33:28 UTC
The patch indeed fixes the original problem. For the other problem you mentioned (I confused your earlier description with the original submission in my previous comment, sorry) how cell references are updated bug 44383 contains descriptions, especially see https://bugs.freedesktop.org/show_bug.cgi?id=44383#c10
Comment 8 Commit Notification 2013-06-26 22:41:08 UTC
Winfried Donkers committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=e513fffeac1f4a814f644f156d88fc8810af4e46

fdo#65856 allow shift cells in paste special for copy-mode



The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 9 Commit Notification 2013-06-26 22:51:05 UTC
Winfried Donkers committed a patch related to this issue.
It has been pushed to "libreoffice-4-1":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=253052788a9f99af782be3ec30a6812b5922ff28&h=libreoffice-4-1

fdo#65856 allow shift cells in paste special for copy-mode


It will be available in LibreOffice 4.1.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 10 Commit Notification 2013-06-26 22:51:23 UTC
Winfried Donkers committed a patch related to this issue.
It has been pushed to "libreoffice-4-0":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=e51def95b7b2d7627d97ca898846f3d3be791b3d&h=libreoffice-4-0

fdo#65856 allow shift cells in paste special for copy-mode


It will be available in LibreOffice 4.0.5.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 11 Commit Notification 2018-03-18 10:06:17 UTC
Zdeněk Crhonek committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=826d9839e0f24631b330737b86fa520d7d8c5dd1

uitest for bug tdf#65856

It will be available in 6.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.