Bug 140868 - Copy-pasted chart references source sheet instead of self if target sheet moved before source sheet after copying
Summary: Copy-pasted chart references source sheet instead of self if target sheet mov...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Not Assigned
URL: https://ask.libreoffice.org/t/copying...
Whiteboard:
Keywords:
Depends on:
Blocks: Paste Chart-Data Sheet
  Show dependency treegraph
 
Reported: 2021-03-08 03:19 UTC by BPH
Modified: 2024-03-05 05:35 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:


Attachments
This spreadsheet exhibits the effects of the bug. (74.41 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2021-03-08 03:28 UTC, BPH
Details
This spreadsheet exhibits the effects of the bug. (282.58 KB, application/vnd.oasis.opendocument.spreadsheet)
2021-03-08 03:30 UTC, BPH
Details
A sample .ods file with a bit of data and one chart (13.81 KB, application/vnd.oasis.opendocument.spreadsheet)
2022-01-17 23:59 UTC, LeroyG
Details

Note You need to log in before you can comment on or make changes to this bug.
Description BPH 2021-03-08 03:19:19 UTC Comment hidden (obsolete)
Comment 1 BPH 2021-03-08 03:28:18 UTC Comment hidden (obsolete)
Comment 2 BPH 2021-03-08 03:30:29 UTC Comment hidden (obsolete)
Comment 3 LeroyG 2022-01-17 23:59:18 UTC
Created attachment 177625 [details]
A sample .ods file with a bit of data and one chart

In the following examples, Sheet1 name could have any number; Sheet2 name could have any number greater than Sheet1.

I found a faulty method:
- Copy from Sheet1, insert/move Sheet2 (or Sheet3) to the left of Sheet1 tab, and paste.


Workarounds:

If Sheet2 tab would be to the left of Sheet1 tab:
- Copy from Sheet1 after inserting/moving Sheet2

If you already copied from Sheet1, and Sheet2 (or Sheet3) tab is (are) to the left of Sheet1 tab:
- Move Sheet2 (and Sheet3) tab(s) to the right of Sheet1 tab
- Paste
- Reorder the sheet tabs


Version: 7.1.8.1 (x64) / LibreOffice Community
Build ID: e1f30c802c3269a1d052614453f260e49458c82c
CPU threads: 4; OS: Windows 10.0 Build 19043; UI render: default; VCL: win
Locale: es-MX (es_ES); UI: en-US
Calc: CL

Related question: https://ask.libreoffice.org/t/copying-chart-in-calc/72866
Comment 4 Buovjaga 2022-12-02 13:24:28 UTC
(In reply to LeroyG from comment #3)
> Created attachment 177625 [details]
> A sample .ods file with a bit of data and one chart
> 
> In the following examples, Sheet1 name could have any number; Sheet2 name
> could have any number greater than Sheet1.
> 
> I found a faulty method:
> - Copy from Sheet1, insert/move Sheet2 (or Sheet3) to the left of Sheet1
> tab, and paste.

Testing with attachment 177625 [details]. If I select A1:J21, copy, insert new sheet, paste into it, everything is pasted just fine.

Of the related reports you mentioned in Ask, bug 142635 is fixed and bug 99969 is still reproduced.

BPH and Leroy: is there still a problem?

Set to NEEDINFO.
Change back to UNCONFIRMED, if the problem persists. Change to RESOLVED WORKSFORME, if the problem went away.

Arch Linux 64-bit
Version: 7.5.0.0.alpha1+ (X86_64) / LibreOffice Community
Build ID: 2b093d27b7e6f231512920f20089fcac291b021f
CPU threads: 8; OS: Linux 6.0; UI render: default; VCL: kf5 (cairo+xcb)
Locale: fi-FI (fi_FI.UTF-8); UI: en-US
Calc: threaded
Built on 2 December 2022
Comment 5 QA Administrators 2023-06-02 03:17:00 UTC Comment hidden (obsolete)
Comment 6 LeroyG 2023-06-02 12:57:32 UTC
Reproducible with:

Version: 7.4.7.2 (x86) / LibreOffice Community
Build ID: 723314e595e8007d3cf785c16538505a1c878ca5
CPU threads: 4; OS: Windows 6.1 Service Pack 1 Build 7601; UI render: Skia/Raster; VCL: win
Locale: es-MX (es_MX); UI: en-US
Calc: threaded


Version: 7.5.3.2 (x86) / LibreOffice Community
Build ID: 9f56dff12ba03b9acd7730a5a481eea045e468f3
CPU threads: 4; OS: Windows 6.1 Service Pack 1 Build 7601; UI render: Skia/Raster; VCL: win
Locale: es-MX (es_MX); UI: fr-FR
Calc: threaded

Note that you must Copy before moving Sheet2 to the left of Sheet1, and then Paste.
Comment 7 Stéphane Guillou (stragu) 2024-03-01 06:52:33 UTC
Regarding Leroy's steps and sample:
I reproduce the inconsistency, which depends on the order of copying and moving sheets.

1. Open attachment 177625 [details]
2. Copy A1:J21 in Sheet1
3. Insert a second sheet (Sheet2) at the end
4. Paste into Sheet2
Result A: range references the new sheet ($Sheet2.$A$1:$B$3) (expected)
5. Copy A1:J21 in Sheet1 again
6. Insert a third sheet (Sheet3)
7. Move Sheet3 to first position (before Sheet1)
8. Paste in Sheet3
Result B: range references the source sheet ($Sheet1.$A$1:$B$3) (unexpected)

If the new sheet is moved _before_ copying, no issue.

Reproduced in OOo 3.3 and recent trunk build:

Version: 24.8.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: e2473fe3a547e5a11d3b91ab8ded833bf5b74356
CPU threads: 8; OS: Linux 6.5; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

Regarding BPH's sample files:
It is not clear enough what steps need to be taken to reproduce the problem with the attachments (e.g. _which_ sheet, or part thereof, do we copy? Where to? Which chart has a problem?).
Given the difficulty reproducing, and the various issues reported, let us focus on Leroy's example here, for which we have clear steps. (But if you can still reproduce in a recent version, please do open a new report with clear, precise steps.)
Comment 8 Stéphane Guillou (stragu) 2024-03-05 05:12:21 UTC
Mike, given your recent work on copy-pasting of cell ranges containing a chart object, I thought you might be interested in this one. See comment 7.
Comment 9 Mike Kaganski 2024-03-05 05:35:34 UTC
(In reply to Stéphane Guillou (stragu) from comment #8)

I saw this bug.
However, I have no idea if it is possible to handle it at all, without a deep reimplementation of a huge part of Calc internals. A *calc document* is created for placement to clipboard; the selected part plus its references are copied to it from the current document; there is a way to tell that this calc document is based on "this specific normal document", which avoids creation of internal data set for charts when pasting to itself. But in any case, pasting back, it's the structure of the clipboard document that defines the references, not the structure of the (updated) source document. There is no way for clipboard to know that "the sheet number X, which was the source for the chart, is now sheer number Y in the source document". (See how the sheets are referenced by numbers internally, not by names (which would not help, since you can rename freely), nor by pointers / references, etc.).