Bug 145532 - Sheet copy from doc1 to doc2 breaks "Defined Range" linkage
Summary: Sheet copy from doc1 to doc2 breaks "Defined Range" linkage
Status: UNCONFIRMED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.2.1.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-11-03 19:53 UTC by devMgr
Modified: 2022-11-19 23:33 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
small ods with sample Defined Range use and route to failure (32.81 KB, application/vnd.oasis.opendocument.spreadsheet)
2022-11-19 23:31 UTC, devMgr
Details

Note You need to log in before you can comment on or make changes to this bug.
Description devMgr 2021-11-03 19:53:12 UTC
Description:
Doc2 is a multi-sheet ods with several Defined Range specifications.
Doc1 is an unrelated ods with separate Defined Range specifications.
If a sheet from Doc1 is copied to Doc2, the distinct Defined Ranges in the two docs clash.
I'm guessing that the internal tokens for the Defined Ranges used in Doc1 get confused with the already existing Defined Range tokens in Doc2.
Suffice to say that the defined range names used in the cell formulae of the moved sheet are replaced by syntactically correct but logically senseless references to Doc1 definitions.
Any formula affected in this way is of course invalid and the moved sheet becomes unworkable and not even easily correctable.
There is no obvious route / prep work to avoid this problem.
Possible work-around (v. labour-intensive):  prior to copy, delete all defined ranges in Doc1 (rendering all affected calcs syntactically illegal), move the sheet to Doc2 and recreate the absent Defined Ranges in Doc2 after the copy.
Seems to meet with success, but is a heck of a lot of work.
(BTW, confirms the idea of 'low-level token' mismatch as the root cause of the bug.)
Far preferable that a bugfix can be arranged.


Steps to Reproduce:
1.Create Doc1 with Defined Range specs and valid formulae that use the D.R.s
2.Create Doc2 with distinct Defined Range specs and valid formulae that use the D.R.s
3.Copy a sheet that uses the  D.R.s from Doc1 to Doc2

Actual Results:
The DR names used in the Doc1 sheet after the copy have been confused with the DR names that pre-existed in Doc2. It is as though the low-level representation of the formula uses an index reference into the DR list, and this is used to mistakenly refer to a Doc2 DR.
Examination of the post-move formulae shows that the DR placeholder names have been changed to align with Doc2 DR names.

Expected Results:
1. The DR specifications should copy over without confusion
2. The DR name references in the formulae should remain unchanged
3. The sheet should continue to be useable.


Reproducible: Always


User Profile Reset: No



Additional Info:
Version: 7.2.1.2 (x64) / LibreOffice Community
Build ID: 87b77fad49947c1441b67c559c339af8f3517e22
CPU threads: 6; OS: Windows 10.0 Build 19043; UI render: Skia/Raster; VCL: win
Locale: en-GB (en_GB); UI: en-GB
Calc: threaded
Comment 1 devMgr 2021-11-04 13:37:25 UTC
CORRECTION:
The phrase in the Description "logically senseless references to Doc1 definitions" should read "logically senseless references to Doc2 definitions"
Comment 2 Buovjaga 2022-11-19 17:52:12 UTC
(In reply to devMgr from comment #0)
> Steps to Reproduce:
> 1.Create Doc1 with Defined Range specs and valid formulae that use the D.R.s
> 2.Create Doc2 with distinct Defined Range specs and valid formulae that use
> the D.R.s

Please attach minimal example spreadsheets at this step, so we can quickly reproduce the problem.

Set to NEEDINFO.
Change back to UNCONFIRMED after you have provided the documents.
Comment 3 devMgr 2022-11-19 23:31:51 UTC
Created attachment 183684 [details]
small ods with sample Defined Range use and route to failure

Attached is a sample ods file, as requested.
The file contains comments to identify 'path to failure' to recreate the fault. 

In essence, any change to the sheet population (copy, move, delete but not rename) results in the (inter-sheet) Defined Range(s) relationships becoming corrupt.

Probably stems from the internal sheet identity being inadequately robust/independent.