Bug 159847 - CALC Duplicates Sheet creates the new sheet in the wrong file
Summary: CALC Duplicates Sheet creates the new sheet in the wrong file
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.4.0.3 release
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Rafael Lima
URL:
Whiteboard: target:24.8.0
Keywords: implementationError
Depends on:
Blocks:
 
Reported: 2024-02-22 16:39 UTC by Christophe
Modified: 2024-02-29 21:44 UTC (History)
1 user (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 Christophe 2024-02-22 16:39:51 UTC
If you have two opened  Calc files that have the same name (i.e. they have different extension ods/xls or they are in different directories), when you use the "Duplicate sheet" function (in the right-clic menu), the new sheet is created in the first opened file.

If it's the file you are working in, it's ok, but if it's the other...

Way to reproduce:
1) Create a new Calc file as save it as testfile.ods
2) Type "File 1" in A1 (or anything else anywhere else)
3) Save your file
4) Create a second new calc file with the same name but in another directory or with another extension (xls)
5) Type "File 2" in A1 (or anything else anywhere else, just something different from the first file)
6) Save your file
7) Duplicate the sheet of the second file => Nothing seems to happen
8) Go to the first file => You will discover your duplicated sheet (compare the contents to confirm that it comes from the other file)
Comment 1 ady 2024-02-22 16:55:41 UTC
Repro on a recent 24.8 alpha and in LO 7.6.3.2 on Windows.
Comment 2 ady 2024-02-22 17:09:07 UTC
This happens also with LO 7.4, when the Duplicate Sheet context menu entry was introduced > implementation error.

tdf#145745

CC'ing Rafael Lima.
Comment 3 Rafael Lima 2024-02-22 20:24:18 UTC
Indeed, I can reproduce the issue. Thanks for reporting the issue.

I'll take a look at it.
Comment 4 Rafael Lima 2024-02-22 20:39:29 UTC
Fix here:
https://gerrit.libreoffice.org/c/core/+/163763
Comment 5 ady 2024-02-22 21:02:11 UTC
FWIW, in comment 1 I replicated this with 2 files with the same name and in the _same_ directory, just with different file type (ods vs xls).

I mention this because gerrit 163763 ATM says:

"
...if two files were opened and had the same file name (but in a different directory)...
"

and my repro was slightly different.

I'll test anyway in the coming days.
Comment 6 Rafael Lima 2024-02-22 22:08:38 UTC
(In reply to ady from comment #5)
> FWIW, in comment 1 I replicated this with 2 files with the same name and in
> the _same_ directory, just with different file type (ods vs xls).

This also works, because now the full path, file name and extension are considered.

I've just tested it here and it works.
Comment 7 Commit Notification 2024-02-29 11:28:22 UTC
Rafael Lima committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/3432dec53cfa6409dffebfdd67ce663362c71115

tdf#159847 Fix "Duplicate Sheet" when two files have the same name

It will be available in 24.8.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.