Bug 71271 - sheet's CodeName not saved
Summary: sheet's CodeName not saved
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: x86-64 (AMD64) All
: medium minor
Assignee: Andreas Heinisch
URL:
Whiteboard: target:7.1.0
Keywords:
Depends on:
Blocks: Macro-UNOAPI
  Show dependency treegraph
 
Reported: 2013-11-05 15:59 UTC by Roman Polach
Modified: 2020-11-21 09:39 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
Example document of not-saved-CodeName value (8.45 KB, application/vnd.oasis.opendocument.spreadsheet)
2013-11-05 15:59 UTC, Roman Polach
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Roman Polach 2013-11-05 15:59:35 UTC
Created attachment 88706 [details]
Example document of not-saved-CodeName value

When sheet's .CodeName value is changed
by basic macro and document is saved and
then reopened, new .CodeName value is lost.

See attached example - using two functions,
first for setting .CodeName before saving the document,
second for displaying it after reopen:

Sub ABCD
  Dim MySheet As Object
  Set MySheet = ThisComponent.getSheets().getByName("List1")
  MsgBox(MySheet.CodeName)
  MySheet.CodeName = "NewName"
  MsgBox(MySheet.CodeName)
End Sub

Sub EFGH
  Dim MySheet As Object
  Set MySheet = ThisComponent.getSheets().getByName("List1")
  MsgBox(MySheet.CodeName)
End Sub
Comment 1 Buovjaga 2014-11-07 15:34:30 UTC
Yep, I don't get NewName after saving & reopening.

Win 7 64-bit Version: 4.4.0.0.alpha1+
Build ID: 8b21b5cbe78945b27525b4ce78ae3d981f90590f
TinderBox: Win-x86@39, Branch:master, Time: 2014-11-06_03:55:51
Comment 2 QA Administrators 2015-12-20 16:15:38 UTC Comment hidden (obsolete)
Comment 3 QA Administrators 2017-01-03 19:49:18 UTC Comment hidden (obsolete)
Comment 4 Buovjaga 2019-08-11 11:18:28 UTC
Still repro

Arch Linux 64-bit
Version: 6.4.0.0.alpha0+
Build ID: 37fc9f51a8de11d40632e8cda17ccf1fa4b1f503
CPU threads: 8; OS: Linux 5.2; UI render: default; VCL: gtk3; 
Locale: fi-FI (fi_FI.UTF-8); UI-Language: en-US
Calc: threaded
Built on 6 August 2019
Comment 7 elmau 2020-09-16 19:32:31 UTC
Still repro

Arch Linux 64-bit
Version: 7.0.1.2
Build ID: 00(Build:2)
CPU threads: 8; OS: Linux 5.8; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
=7.0.1-1
Calc: threaded
Comment 8 JJPalacios 2020-09-16 21:05:59 UTC
Comment on attachment 88706 [details]
Example document of not-saved-CodeName value

Version: 7.0.1.2
Build ID: 00(Build:2)
CPU threads: 8; OS: Linux 4.19; UI render: default; VCL: kf5
Locale: es-ES (es_ES.UTF-8); Interfaz: es-ES
=7.0.1-1
Calc: threaded

Please, this behavior has been like this for a long time. Time to fix it and it won't take much developer time.

CodeName is updated on all sheets when the document is opened. In the first one, it takes the default value for the new sheet, for the rest, it takes the value of the sheet name. 
sheet.CodeName = sheet.Name

CodeName should be persistent.
Comment 9 Andreas Heinisch 2020-09-21 19:35:38 UTC
As himajin100000@gmail.com pointed out, if we drop the line at https://opengrok.libreoffice.org/xref/core/sc/source/filter/xml/xmlexprt.cxx?r=09402293#5143 (vba compatibility mode) the codename persists after closing and reopening the document. I have to clarify via IIRC, how we could solve this issue.
Comment 10 Andreas Heinisch 2020-09-22 21:19:34 UTC
It seems that this was done on purpose: https://github.com/LibreOffice/core/commit/d51b5501b66fd73252a4788ba0e2e215156c5488

So what do you think about dropping it again?
Comment 11 JJPalacios 2020-09-22 22:36:53 UTC
175/5000
I dont know. I don't understand what CodeName has to do with CodeNameProvider and CodeNameAccess. However, if you think that fixes the CodeName persistence issue, go ahead.
Comment 12 Andreas Heinisch 2020-09-29 05:47:05 UTC
https://gerrit.libreoffice.org/c/core/+/103589
Comment 13 Commit Notification 2020-11-15 18:16:13 UTC
Andreas Heinisch committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/7f43c1d203b3513462bb36eaea7bf7b41956c7b6

tdf#71271 - add code names regardless of VBA compatibility mode

It will be available in 7.1.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 14 Andreas Heinisch 2020-11-15 18:30:42 UTC
Thx again to himajin100000@gmail.com and Mike Kaganski.
Comment 15 elmau 2020-11-18 00:56:59 UTC
Confirm fix it in:

Version 7.1.0.0 alpha1


Thanks.
Comment 16 himajin100000 2020-11-21 09:35:46 UTC
note: It seems that closing the ods file after running this program does not give any warning about being unsaved.
Comment 17 Andreas Heinisch 2020-11-21 09:39:56 UTC
Should there be filed a different bug for this behaviour?