Bug 156233 - Validation #REF! error when deleting original worksheet after duplicating it
Summary: Validation #REF! error when deleting original worksheet after duplicating it
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
4.2.0.4 release
Hardware: x86-64 (AMD64) All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisected, bisected, regression
Depends on:
Blocks: Cell-Validity
  Show dependency treegraph
 
Reported: 2023-07-11 09:46 UTC by fumagiufio
Modified: 2023-12-28 16:31 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
File to test (9.17 KB, application/vnd.oasis.opendocument.spreadsheet)
2023-07-12 20:21 UTC, LeroyG
Details
File to test, without messing with duplicate sheet. (9.20 KB, application/vnd.oasis.opendocument.spreadsheet)
2023-07-13 20:28 UTC, LeroyG
Details
screenshot (13.79 KB, image/png)
2023-07-13 20:35 UTC, LeroyG
Details
Simplified test and STR (7.49 KB, application/vnd.oasis.opendocument.spreadsheet)
2023-07-14 00:13 UTC, ady
Details

Note You need to log in before you can comment on or make changes to this bug.
Description fumagiufio 2023-07-11 09:46:27 UTC
Description:
When I duplicate a sheet and then later delete original sheet ,in the new sheet data validation loss reference to cells.
For example this formula "E(F22 >=F7;F22 <= F9)" change in "E(#RIF! >=#RIF!;#RIF! <= #RIF!)"
To highlight the problem it is necessary to save the file and then reopen it
after the original sheet has been deleted

Steps to Reproduce:
0) Insert "validation data" formula to check value of an other cell
1.duplicate sheet
2.delete original sheet
3.save file
4. reopen file

Actual Results:
Into the validation data the formula contains
"E(#RIF! >=#RIF!;#RIF! <= #RIF!)"

Expected Results:
"E(F22 >=F7;F22 <= F9)" 


Reproducible: Always


User Profile Reset: No

Additional Info:
Version: 7.5.3.2 (X86_64) / LibreOffice Community
Build ID: 9f56dff12ba03b9acd7730a5a481eea045e468f3
CPU threads: 12; OS: Windows 10.0 Build 22621; UI render: Skia/Raster; VCL: win
Locale: it-IT (it_IT); UI: it-IT
Calc: CL threaded
Comment 1 ady 2023-07-11 11:21:06 UTC Comment hidden (obsolete)
Comment 2 LeroyG 2023-07-12 20:21:40 UTC Comment hidden (obsolete)
Comment 3 LeroyG 2023-07-12 20:23:01 UTC Comment hidden (obsolete)
Comment 4 ady 2023-07-13 00:13:40 UTC Comment hidden (obsolete)
Comment 5 LeroyG 2023-07-13 20:25:24 UTC Comment hidden (obsolete)
Comment 6 LeroyG 2023-07-13 20:28:14 UTC Comment hidden (obsolete)
Comment 7 LeroyG 2023-07-13 20:35:04 UTC Comment hidden (obsolete)
Comment 8 ady 2023-07-13 23:51:49 UTC
The prior attachments are less than ideal but usable (if the user/tester knows what to look for). Further investigations confirm the bug:

Using any cell reference in any of the possible validation types (not only custom but any and all of them), will result in a #REF! error in the source values of the Validity dialog when following these steps (which use just one of the possible validity types, as example)

1. A1: 1
2. A2: 3

3. A3: Menu Data > Validity:
3.1. Allow: Whole Numbers
3.2. Data: valid range
3.3. Min: =A1  (Calc will delete the "=" sign when closing the dialogue)
3.4. Max: =A2  (Calc will delete the "=" sign when closing the dialogue)
3.5. OK

4. A3: 2
5. Duplicate the current worksheet (aka "copy" worksheet in older versions).
6. Delete the original worksheet.  <- The corruption is generated at this point!!!
6.1. A3: 3 (the value is rejected, same as trying the prior value "2" again).
7. Save the file.
8. Close the file; reopen.  <-  This is required in order to _see_ the problem.
9. A3: 3 (the value is rejected, same as trying the prior value "2" again).
10. A3: Menu Data > Validity; the Min and Max fields will show the #REF! error.

Notes:
* Step 9 is optional.
* Step 6 already causes the corruption/problem.
* Step 6.1 is optional.
* Adding a "6.2" step to show the Min and Max fields will not show the #REF! error yet. Closing the dialogue with OK at this point "restores" the correct values.

The problem is reproduced in LO 4.2 but not in 4.1 and older > regression.
Comment 9 ady 2023-07-14 00:13:58 UTC
Created attachment 188366 [details]
Simplified test and STR

I'm attaching a simple ods file for testing with the STR from comment 8.

This test points to the problem in the Validity dialogue. It also demonstrates that:
* there is no relation to the specific Calc function (e.g. AND());
* there is no relation to circular references of any form;
* there is no direct relation to the "custom" form of Validity, since the problem can be reproduced with other types of Validity.
Comment 10 raal 2023-12-28 16:31:22 UTC
step 5. Duplicate the current worksheet (aka "copy" worksheet in older versions). -> copy the sheet after current one ( to the last position), suprisingly this is important.

This seems to have begun at the below commit in bibisect repository/OS bibisect-42max.
Adding Cc: to Kohei Yoshida ; Could you possibly take a look at this one?
Thanks
 0b21f7cae90b8405aa4bc081e0024f05b5438c1c is the first bad commit
commit 0b21f7cae90b8405aa4bc081e0024f05b5438c1c
Author: Matthew Francis <mjay.francis@gmail.com>
Date:   Sat Sep 5 19:29:39 2015 +0800

    source-hash-8eb6de29009d009b8fa61fa8bb0e3bc60c7bfdf9
    
    commit 8eb6de29009d009b8fa61fa8bb0e3bc60c7bfdf9
    Author:     Kohei Yoshida <kohei.yoshida@gmail.com>
    AuthorDate: Thu Jul 25 22:35:47 2013 -0400
    Commit:     Kohei Yoshida <kohei.yoshida@gmail.com>
    CommitDate: Tue Jul 30 23:49:55 2013 -0400
    
        Make this guy unused, and remove it.
    
        Change-Id: Ib4a2f195b3ff1d291b0ffe99c27b1d3e807252d5