Bug 142201 - EDITING: Cut paste transposed: formula references from wrong cells adjusted
Summary: EDITING: Cut paste transposed: formula references from wrong cells adjusted
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.1.2.2 release
Hardware: All All
: medium normal
Assignee: Roland Kurmann
URL:
Whiteboard: target:7.2.0
Keywords:
Depends on:
Blocks: Cell-Formula Paste-Special
  Show dependency treegraph
 
Reported: 2021-05-10 20:33 UTC by Roland Kurmann
Modified: 2021-06-08 04:58 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Roland Kurmann 2021-05-10 20:33:10 UTC
Description:
Formula references from wrong cells are adjusted after cut paste transposed. Transposed location changes are not taken into account.

In version 7.1, it can only be reproduced if the cut cells start in A1 due to bugs 68976, 71058. After these bugs have been fixed, it happens everywhere.

Technical background:
sc::RefUpdateResult ScTokenArray::AdjustReferenceOnMove() and ScDocument::UpdateTranspose() are responsible for adjusting cell references for cut and paste transposed. Location change due to transpose has to be taken into account as well.

Steps to Reproduce:
1. Open an empty Calc spreadsheet.
2. Enter
    A1: 1
    B1: 11
    A2: 2
    B2: 12

    A4: =$A$1
    B4: =$B$1
    A5: =$A$2
    B5: =$B$2

    D4: 1
    E4: 11
    D5: 2
    E5: 12

3. Select A1:A2
4. Cut
5. Go to cell A7
6. Context menu > Special Paste > Special Paste > Transpose button

Actual Results:
i) LibreOffice 7.1.2.2:
A4: =$A$7 (value: 1)
B4: =$B$7 (value: 2)    <- wrong
A5: =$A$2 (value: 0)    <- wrong (bug 71058)
B5: =$B$2 (value: 12)

Displayed values changed

ii) LibreOffice 7.2 alpha (after fixing bug 71058):
A4: =$A$7 (value: 1)
B4: =$B$7 (value: 2)    <- wrong
A5: =$A$2 (value: 2)
B5: =$B$2 (value: 12)

Displayed values changed

Expected Results:
A4: =$A$7 (value: 1)    <- changed reference
B4: =$B$2 (value: 11)
A5: =$B$7 (value: 2)    <- changed reference
B5: =$B$2 (value: 12)

Displayed values stay the same, only 2 references change


Reproducible: Always


User Profile Reset: No



Additional Info:
I've discovered this bug while fixing and testing bugs 68976, 71058, 142065.

I document this bug for QA.

Version: 7.1.1.2 / LibreOffice Community
Build ID: 10(Build:2)
CPU threads: 4; OS: Linux 5.3; UI render: GL; VCL: kf5
Locale: de-CH (en_US.UTF-8); UI: de-DE
Calc: threaded

Version: 7.2.0.0.alpha0+ / LibreOffice Community
Build ID: 4cc8406abaf8acd5dc2bdba8d46d6c3c44fbc985
CPU threads: 4; OS: Linux 5.3; UI render: default; VCL: x11
Locale: de-CH (en_US.UTF-8); UI: en-US
Calc: threaded
Comment 1 Roland Kurmann 2021-05-24 18:35:58 UTC
I've submitted a patch: https://gerrit.libreoffice.org/c/core/+/116073
Waiting for review
Comment 2 Commit Notification 2021-05-29 20:47:11 UTC
scito committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/bda9929821de620f1f85528abd1c4bba46d937d6

tdf#142201 tdf#142065 fix cut paste transpose references, incl. undo

It will be available in 7.2.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 3 BogdanB 2021-06-08 04:58:15 UTC
I think you have an error in description
-----------------------------
Expected Results:
A4: =$A$7 (value: 1)    <- changed reference
B4: =$B$2 (value: 11)   <- HERE SHOULD BE $B$1 not $B$2
A5: =$B$7 (value: 2)    <- changed reference
B5: =$B$2 (value: 12)
-----------------------------
But the bug is fixed. Thanks for solving this.

Verified in
Version: 7.2.0.0.alpha1+ / LibreOffice Community
Build ID: ec629c5ee22d02f99d66a5cf975ce239876b7f4d
CPU threads: 4; OS: Linux 5.8; UI render: default; VCL: gtk3
Locale: ro-RO (ro_RO.UTF-8); UI: en-US
Calc: threaded