Description: Option Explicit Sub LockThisSheet LockSheet("Sheet1") End Sub Function LockSheet(passedSheetname) Dim oDoc As Object : oDoc = ThisComponent Dim oSheet As Object : oSheet = oDoc.Sheets.getByName(passedSheetname) Dim pPassword As String If IsMissing(pPassword) Then pPassword = "" oSheet.UnProtect(pPassword) oSheet.Protect(pPassword) End Function Cells are locked as needed but the protection icon does not show in front of sheeet name unless the sheet is moved to another position. Steps to Reproduce: 1.Run Option Explicit Sub LockThisSheet LockSheet("Sheet1") End Sub Function LockSheet(passedSheetname) Dim oDoc As Object : oDoc = ThisComponent Dim oSheet As Object : oSheet = oDoc.Sheets.getByName(passedSheetname) Dim pPassword As String If IsMissing(pPassword) Then pPassword = "" oSheet.UnProtect(pPassword) oSheet.Protect(pPassword) End Function 2. Cells are locked as needed. 3. The protection icon does not show in front of sheeet name. Actual Results: 1. Cells are locked as needed. 2. The protection icon does not show in front of sheeet name. 3. The protection icon will show in front of sheeet name if the sheet is moved to another position. Expected Results: The protection icon shows in front of sheeet name. Reproducible: Always User Profile Reset: No Additional Info: https://ask.libreoffice.org/en/question/245509/lo-basic-calc-the-protection-icon-does-not-show/
Created attachment 161111 [details] The protection icon does not show.
Created attachment 161112 [details] On the other hand, it will show after moving such sheet.
Repro with Version: 6.4.4.2 (x64) Build ID: 3d775be2011f3886db32dfd395a6a6d1ca2630ff CPU threads: 12; OS: Windows 10.0 Build 18363; UI render: GL; VCL: win; Locale: ru-RU (ru_RU); UI-Language: en-US Calc: CL. The problem is that setting the protection via API uses ScTableSheetObj::protect/unprotect (sc/source/ui/unoobj/cellsuno.cxx), while UI operation uses ScViewFunc::ProtectSheet/Unprotect (sc/source/ui/view/viewfunc.cxx). The latter functions call SetTabProtectionSymbol function (sc/source/ui/view/tabview3.cxx), that sets the symbol. Interestingly, ScViewFunc::Protect doesn't do that. Both pathways call ScDocFunc::ProtectSheet/Unprotect (sc/source/ui/docshell/docfunc.cxx). The proposal is to move calling ScTabView::SetTabProtectionSymbol there; and in the process, ScDocFunc::Protect should be also changes to call ScDocFunc::ProtectSheet when doing sheet protection to unify the code. SetTabProtectionSymbol must be called for *all* visible document's view frames, not only the active one. To iterate over all active view frames, use SfxViewFrame::GetFirst/GetNext; see implementation of ScTabViewShell::GetActiveViewShell for additional details.
(In reply to Mike Kaganski from comment #3) > see implementation of ScTabViewShell::GetActiveViewShell for additional > details. A thinko: instead of "ScTabViewShell::GetActiveViewShell" should had been "ScDocShell::GetBestViewShell".
Please have a look : https://gerrit.libreoffice.org/c/core/+/107041
Anshu committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/05284641e381ec2bb3b72a39b5c7334127f6c7ba tdf#133257 : Protection icon in front of sheet name It will be available in 7.2.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.
Should I close this bug?
(In reply to An-Kh from comment #7) > Should I close this bug? I think you should.
*** Bug 138168 has been marked as a duplicate of this bug. ***