Issue 108245 - Password protection and unprotection of sheet with API/Macro is broken
Summary: Password protection and unprotection of sheet with API/Macro is broken
Status: CLOSED FIXED
Alias: None
Product: Calc
Classification: Application
Component: code (show other issues)
Version: OOo 3.2 RC1
Hardware: Unknown Linux, all
: P3 Trivial with 2 votes (vote)
Target Milestone: ---
Assignee: oc
QA Contact: issues@sc
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-12 09:03 UTC by cno
Modified: 2017-05-20 10:34 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
test document (10.10 KB, application/vnd.oasis.opendocument.spreadsheet)
2010-01-12 09:05 UTC, cno
no flags Details
test case protect (12.04 KB, application/vnd.oasis.opendocument.spreadsheet)
2010-03-04 13:07 UTC, aladdin2k7
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description cno 2010-01-12 09:03:50 UTC
When I unprotect a sheet with a Macro, the password used in the macro is not
relevant.

When setting the protection in the same macro, the first time the original
password (set via the GUI) is kept. 
Only after running the second time, the password used in the macro is set...

To test:
Open tstSheetProtection_WithAPI

Instructions there
1. set sheet protection with password “testpw”
2. run macro standard.module1.main (Alt-F11)
3. check the protection of the sheet via Tools|Protection|Sheet
4. note that you still have to use “testpw”
5. now run the macro again
6. to unprotect via Tools|Protect|Sheet, now you have to use “doesnt matter”
Comment 1 cno 2010-01-12 09:05:26 UTC
Created attachment 67142 [details]
test document
Comment 2 cno 2010-01-12 09:06:29 UTC
first stumbled over the bug in 3.2.0rc1
but it also exists in 3.1.1
Comment 3 bmarcelly 2010-01-14 10:43:38 UTC
I cannot reproduce on OOO 3.1.1, Windows XP.

The macro does not unprotect, nor change the password of a sheet protected by
another password.
Comment 4 aladdin2k7 2010-03-01 16:36:29 UTC
I confirm on OOo 3.2.0 (OOo320m12 (Build 9483)) that :

- The unprotect() method doesn't return an error if you enter the wrong password.
Moreover, it doesn't return an exception if you enter an integer as a parameter
of the method unprotect() : void unprotect(string aPassword)[1]. 

- The protect() method overrides the current password (set via the GUI) !  

[1]
http://api.openoffice.org/docs/common/ref/com/sun/star/util/XProtectable.html#unprotect
Comment 5 Oliver Brinzing 2010-03-01 17:23:03 UTC
.
Comment 6 niklas.nebel 2010-03-02 18:03:45 UTC
taking the issue
Comment 7 niklas.nebel 2010-03-02 18:06:39 UTC
Fixed in CWS "dr73":

1. unprotect with a wrong password throws an IllegalArgumentException.

2. protect on a sheet that was already protected doesn't modify the password
(but no exception - consistent with other operations on protected cells).

Note: The second case includes protection without password. If protect is first
called with an empty string, and then again with a password, in OOo 3.1.1 the
result was protection with the password. Now, it's protection without password,
to be consistent.
Comment 8 aladdin2k7 2010-03-04 13:07:57 UTC
Created attachment 68147 [details]
test case protect
Comment 9 aladdin2k7 2010-03-04 13:09:02 UTC
Protect on a sheet that was already protected does modify the password with a
macro (see protect.ods).
Comment 10 mr_jay_01 2010-03-04 13:26:50 UTC
I confirm that a protect() call overrides the previous sheet protection password
on OOo 3.2.0 (OOo320m12 (Build 9483)) on Linux. I tested it with aladdin2k7's
test file (protect.ods,
http://www.openoffice.org/nonav/issues/showattachment.cgi/68147/protect.ods).
Comment 11 niklas.nebel 2010-03-17 17:04:34 UTC
reassigning to QA for verification
Comment 12 oc 2010-04-08 10:59:20 UTC
verified in internal build cws_dr73