Bug 153709 - "Delete Sheet" command should indicate the number of selected sheets that will be deleted
Summary: "Delete Sheet" command should indicate the number of selected sheets that wil...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium enhancement
Assignee: Laurent Balland
URL:
Whiteboard: target:7.6.0
Keywords:
Depends on:
Blocks:
 
Reported: 2023-02-18 16:22 UTC by Laurent Balland
Modified: 2023-06-01 14:24 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments
Examples of dependencies on "empty" sheet (12.52 KB, application/vnd.oasis.opendocument.spreadsheet)
2023-06-01 14:24 UTC, ady
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Laurent Balland 2023-02-18 16:22:21 UTC
Description: in a file with many sheets, you may have accidentally select several sheets (or intentionally but forget). When deleting sheets, the confirmation message does not specify the exact number of sheets which are selected and will be deleted

Steps to reproduce:
1. Open a spreadsheet with several sheets
2. Select some sheets (or not) but not all
3. Select menu Sheet > Delete Sheet

Actual behavior
Whatever the number of selected sheets, a confirmation message ask:
"Are you sure you want to delete the selected sheet(s)?"

Expected behavior
Confirmation message should be adapted to the number of selected sheet:
For 1 sheet:
"Are you sure you want to delete the selected sheet?"
For x sheets:
"Are you sure you want to delete the x selected sheets?"
Comment 1 Laurent Balland 2023-02-18 16:27:02 UTC
The place where message should be updated:
https://opengrok.libreoffice.org/xref/core/sc/source/ui/view/tabvwshf.cxx?r=0908c7c1#679
Comment 2 Laurent Balland 2023-02-19 10:34:09 UTC
Moreover confirmation message should be skipped if selected tabs are empty
Comment 3 Laurent Balland 2023-02-21 14:07:29 UTC
https://gerrit.libreoffice.org/c/core/+/147309
Comment 4 Commit Notification 2023-02-27 09:43:39 UTC
Laurent Balland committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/41b991ea0cf3f8ce36cbdbf16b9c2c6d2bb16b5d

tdf#153709 Adapt message for Delete Sheet

It will be available in 7.6.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 5 Eike Rathke 2023-05-31 16:26:33 UTC
(In reply to Laurent Balland from comment #2)
> Moreover confirmation message should be skipped if selected tabs are empty
I'm not convinced and this slipped my attention:
Having formulas pointing to the deleted sheet will invalidate the formulas producing a #REF! error and will also irrevocably destroy them as the original sheet name can not be recovered in references.

E.g. have Sheet1, Sheet2, and on Sheet1 the formula =Sheet2.A1 and delete Sheet2. After deleting Sheet2 the formula will read =#REF!.A1 and result in #REF! error. Furthermore, saving the document will unify the erroneous formula to just #REF! (which is defined in ODF for reference errors in formulas).

I suggest to revert that part of deleting without confirmation.
Comment 6 Laurent Balland 2023-05-31 16:38:55 UTC
(In reply to Eike Rathke from comment #5)
> (In reply to Laurent Balland from comment #2)
> > Moreover confirmation message should be skipped if selected tabs are empty
> I'm not convinced and this slipped my attention:
> Having formulas pointing to the deleted sheet will invalidate the formulas
> producing a #REF! error and will also irrevocably destroy them as the
> original sheet name can not be recovered in references.
> 
> E.g. have Sheet1, Sheet2, and on Sheet1 the formula =Sheet2.A1 and delete
> Sheet2. After deleting Sheet2 the formula will read =#REF!.A1 and result in
> #REF! error. Furthermore, saving the document will unify the erroneous
> formula to just #REF! (which is defined in ODF for reference errors in
> formulas).
> 
> I suggest to revert that part of deleting without confirmation.

I see the problem and agree to revert that part of the change.
However, I notice that Excel has the bug: there is no confirmation message when deleting an empty sheet, even if there are some formula pointing to it. It results in #REF! error ;-)
Comment 7 Laurent Balland 2023-05-31 19:50:27 UTC
(In reply to Laurent Balland from comment #6)
> I see the problem and agree to revert that part of the change.
https://gerrit.libreoffice.org/c/core/+/152468
Comment 8 ady 2023-05-31 20:24:16 UTC
(In reply to Eike Rathke from comment #5)
> I suggest to revert that part of deleting without confirmation.

Will/Would there be any hint of such relation/dependency? (I don't know whether this distinction is possible.)

I mean that if a worksheet that has no relation whatsoever with anything else behaves exactly the same as a worksheet that _looks empty_ but includes some kind of relation (either a cell being a precedent to some cell in another worksheet, or some kind of (empty) data Validity, or some Conditional Format, or...), then there would be no advantage of having to confirm the deletion action.

If instead, the confirmation is (only) shown when there is some kind of relation, then that would be a useful advantage.

So, if there is no relation at all of any kind, it would be desirable to then go ahead and delete it directly; and present the confirmation dialog when it is really relevant to confirm (hinting that there is some kind of relation, somewhere in the worksheet).
Comment 9 Laurent Balland 2023-06-01 07:19:01 UTC
(In reply to Laurent Balland from comment #7)
> (In reply to Laurent Balland from comment #6)
> > I see the problem and agree to revert that part of the change.
> https://gerrit.libreoffice.org/c/core/+/152468

After one night sleeping, I changed my mind. The actual confirmation message does not give any information about the content of the selected sheets. So I suggest:
- if selected sheets are empty, change confirmation message to:
"Are you sure you want to delete the (x) selected _empty_ sheet(s)? Formula linked to these sheets would be broken."
Comment 10 Laurent Balland 2023-06-01 07:30:08 UTC
(In reply to ady from comment #8)
> So, if there is no relation at all of any kind
I don't know how to check this, but I will seek
Comment 11 ady 2023-06-01 14:24:12 UTC
Created attachment 187642 [details]
Examples of dependencies on "empty" sheet

For comment 10, I am attaching a simplified example of 3 different dependencies on an "empty" worksheet. I'm not saying it includes all the possibilities, just a sample.

The 3 examples included in the attachment are located in cells A1 to A3 of Sheet1:
* formula
* conditional format
* validity

Note that even Tools > Detective > Trace Dependents (and/or Trace Precedents) are not able to tell where the relation is located (which ATM is a decade-old RFE, bug 63087).

In this attachment, deleting Sheet2 would impact Sheet1.A1:A3, but there is no hint about such relation, whether with or without confirmation dialog.

The issue becomes "what is an _empty_ worksheet?", before deleting it (with or without confirmation dialog).