Bug 133257 - The protection icon does not show in front of sheeet name when lock a sheet from LibreOffice BASIC.
Summary: The protection icon does not show in front of sheeet name when lock a sheet f...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
6.2.8.2 release
Hardware: All All
: medium normal
Assignee: An-Kh
URL:
Whiteboard: target:7.2.0
Keywords: difficultyBeginner, easyHack, skillCpp
: 138168 (view as bug list)
Depends on:
Blocks: Cell-Sheet-Protection
  Show dependency treegraph
 
Reported: 2020-05-22 03:49 UTC by Nukool Chompuparn
Modified: 2021-04-05 12:52 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
The protection icon does not show. (40.46 KB, image/png)
2020-05-22 03:56 UTC, Nukool Chompuparn
Details
On the other hand, it will show after moving such sheet. (41.23 KB, image/png)
2020-05-22 03:56 UTC, Nukool Chompuparn
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nukool Chompuparn 2020-05-22 03:49:43 UTC
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/
Comment 1 Nukool Chompuparn 2020-05-22 03:56:13 UTC
Created attachment 161111 [details]
The protection icon does not show.
Comment 2 Nukool Chompuparn 2020-05-22 03:56:56 UTC
Created attachment 161112 [details]
On the other hand, it will show after moving such sheet.
Comment 3 Mike Kaganski 2020-05-22 05:42:04 UTC
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.
Comment 4 Mike Kaganski 2020-05-22 05:45:16 UTC
(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".
Comment 5 An-Kh 2020-12-02 04:35:19 UTC
Please have a look :

https://gerrit.libreoffice.org/c/core/+/107041
Comment 6 Commit Notification 2021-01-02 06:29:22 UTC
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.
Comment 7 An-Kh 2021-01-02 09:24:32 UTC
Should I close this bug?
Comment 8 Buovjaga 2021-01-02 09:52:50 UTC
(In reply to An-Kh from comment #7)
> Should I close this bug?

I think you should.
Comment 9 Timur 2021-04-05 12:52:23 UTC
*** Bug 138168 has been marked as a duplicate of this bug. ***