Apache OpenOffice (AOO) Bugzilla – Issue 8426
Excel import/export of document protection state
Last modified: 2013-08-07 15:14:58 UTC
I've found two problems related to each other and, I think, to issue #7497. First, if you password protect a document, or sheet and save it in Excel format then open it in Excel, the password protection has been taken off - you can get at everything - at least in Office XP. Second, if an Excel document has password protection on a document, you cannot open it. This prevents you opening even if you know the password or if it is merely protecting individual sheets or part of the document. Sorry if this is a duplicate - I have searched and only #7497 came up.
Hi Peter, this Issue is a double to Issue 402 and has nothing in common with Issue 7497. This deals with an document that was protected under windows and do not open on an Unix machine. Best regards Frank *** This issue has been marked as a duplicate of 402 ***
duplicate
Additional comment for your first problem: The protection state of sheets will be exported. Only the password gets lost. The protection state of the document gets lost completely on import/export. I will take this issue to implement at least this.
I take it
started
Daniel, I wish to clarify this bug. The document protection we are talking about is prevention of insertion/deleting/copying of sheets or moving/copying sheets. Thus we wish to preserve this feature on import/export while at the same time we will lose the document password if it exists. The Cell protection currently imports/exports correctly whether the sheet and/or document is protected.
John, yes, it is the workbook protection you can find in Excel under Tools|Protect|Workbook and in Calc under Tools|Protect|Document, just a Boolean setting. We cannot import a document with workbook protection and password because these files are encrypted. Means that import and export work without loss, if they work at all. I have updated the file format specification, see chapter 4.11.2 and 4.11.3.
Created attachment 3860 [details] sample patch to get initial feedback
Daniel, This patch is not complete. I have only modified the Biff8 format. But I was anxious to get some feedback to ensure that I am on the correct track. I don't know if it is wise to split up the ExcDummy8_040 strucure into 3 to accomodate this change etc.When you get a moment, you might look at it. Thanks.
Looks good and should work (I think you have tried it :-)) Another possibility is using the class XclExpBoolRecord from inc/xerecord.hxx. If you use this class, you can drop the ExcDummy8_*** and XclDocProtection classes completely.
Thanks for the hint Daniel. That code suggestion would certainly make it cleaner. I have two more queries. 1. I see that PROTECT is available for all available BIFF types i.e. 2,3,4,5,6,7,8,8x. I assume that means that this change needs to be implemented for all those types or as this ID, in this case is related to workbook protection, then this should be implemented for BIFF4 only onwards. 2. This could be a separate issue. I see that we don't support the ID WINDOWPROTECTION. Should we be capable of preserving this value if it has been originally set by Excel?
1) Yes, I think import could be done for BIFF4 (Workbook) and import/export for BIFF5-BIFF8. I think in BIFF2-3 the protection of workbook and sheet is mixed up anyhow. But the filters for BIFF2-3 need updates in very serious cases only... 2) Currently we do not have a place in our core structures to remember the WINDOWPROTECTION state after import. Maybe the ScExtDocOptions class (sc/inc/scextopt.hxx) can be extended for this purpose. The import filter creates an instance of this class and attaches it to the Calc document. If the export filter finds such a structure, it can use the information to restore unsupported features. My first impression was "nice to have later", but I think it is not that complex to implement. So feel free to experiment a little bit :-)
Created attachment 3904 [details] latest patch following feedback from Daniel on first patch
Daniel, I will create a separate issue for the WINDOWPROTECTION ID. I also notice that the Biff4 format WorkBook protection sets the WINDOWPROTECTION ID only of the Document. Biff5 onwards supports both the PROTECT and WINDOWPROTECT of the Document. I believe that this patch is ready for review at your convenience. I am anxious to do the correct thing starting off, so please let me know if you have any issues with the proposed code. Thanks.
Hi John, some comments on the 2nd patch: Using xlconst.hxx is the right thing, well done :-) ImportExcel8 is derived from ImportExcel, so you do not need the method DocProtect() on ImportExcel8. Saves a few bytes code. I suggest + Add( new XclExpDocProtection(rDoc.IsDocProtected()) ); instead of + if( rDoc.IsDocProtected() ) + Add( new XclExpDocProtection(TRUE) ); + else + Add( new XclExpDocProtection(FALSE) ); The rest is ok. When do you plan to check in the patch? Daniel
The BIFF4 thing: If a newer Excel exports to BIFF4(sheet), it takes the WINDOWPROTECT setting from Protect/Workbook/Window, and the PROTECT setting from Protect/WorkSHEET/Content, because it's a single sheet. So, import from BIFF4(sheet) should result in sheet protection (the "case Z_Biff4:" area in read.cxx), import from BIFF4(workbook) in document protection (the "case Z_Biff4W:" area in read.cxx).
OK. I missed that difference between Biff4(sheet) and Biff4(workbook). So Daniel, I presume that I should include both cases in this fix. My latest patch does not support the import of Document protection ("case Z_Biff4W") and the existing code does not support the import of sheet protection ("case Z_Biff4").
John, Yes, please include both cases sheet/book for BIFF4.
Created attachment 3933 [details] latest patch - adding Biff4(sheet) and Biff4)workbook) plus review from dr
Ok. This issue started out as Document Protection. But now that I have added sheet protection for Biff4(sheet), I can see now that sheet protection is missing in the import of Biff4(workbook) and Biff5(workbook). I propose that I should also add sheet protection to both these versions and this should complete the issue.
Jes, completing sheet protection sounds good.
Created attachment 3943 [details] extend sheet protection support for import/export and clean up spacing
checked in this latest patch today.
taking responsibility for this now.
Marking this as fixed
fixed for OOo 1.1 Beta
re-open to assign to QA
assign to QA
re-set status to fixed
Verified in OOo 1.1 Beta2.
closed ...
*** Issue 29387 has been marked as a duplicate of this issue. ***