Issue 8426 - Excel import/export of document protection state
Summary: Excel import/export of document protection state
Status: CLOSED FIXED
Alias: None
Product: Calc
Classification: Application
Component: code (show other issues)
Version: OOo 1.0.1
Hardware: PC Windows 98
: P3 Trivial (vote)
Target Milestone: ---
Assignee: oc
QA Contact: issues@sc
URL:
Keywords:
: 29387 (view as issue list)
Depends on:
Blocks:
 
Reported: 2002-10-16 22:42 UTC by peterturner
Modified: 2013-08-07 15:14 UTC (History)
1 user (show)

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


Attachments
sample patch to get initial feedback (5.52 KB, patch)
2002-12-02 18:19 UTC, john.marmion
no flags Details | Diff
latest patch following feedback from Daniel on first patch (6.54 KB, patch)
2002-12-04 17:40 UTC, john.marmion
no flags Details | Diff
latest patch - adding Biff4(sheet) and Biff4)workbook) plus review from dr (7.18 KB, patch)
2002-12-06 11:06 UTC, john.marmion
no flags Details | Diff
extend sheet protection support for import/export and clean up spacing (7.90 KB, patch)
2002-12-06 15:57 UTC, john.marmion
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description peterturner 2002-10-16 22:42:54 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.
Comment 1 frank 2002-10-17 09:35:49 UTC
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 ***
Comment 2 frank 2002-10-17 09:36:18 UTC
duplicate
Comment 3 daniel.rentz 2002-10-17 11:06:19 UTC
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.
Comment 4 daniel.rentz 2002-10-17 11:09:00 UTC
I take it
Comment 5 daniel.rentz 2002-10-17 11:09:19 UTC
started
Comment 6 john.marmion 2002-11-29 15:22:02 UTC
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.

Comment 7 daniel.rentz 2002-11-29 15:58:06 UTC
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.
Comment 8 john.marmion 2002-12-02 18:19:27 UTC
Created attachment 3860 [details]
sample patch to get initial feedback
Comment 9 john.marmion 2002-12-02 18:23:02 UTC
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.
Comment 10 daniel.rentz 2002-12-03 07:46:52 UTC
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.
Comment 11 john.marmion 2002-12-03 18:20:08 UTC
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?
Comment 12 daniel.rentz 2002-12-04 08:09:36 UTC
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 :-)
Comment 13 john.marmion 2002-12-04 17:40:45 UTC
Created attachment 3904 [details]
latest patch following feedback from Daniel on first patch
Comment 14 john.marmion 2002-12-04 17:46:30 UTC
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.
Comment 15 daniel.rentz 2002-12-05 08:11:34 UTC
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
Comment 16 daniel.rentz 2002-12-05 10:36:26 UTC
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).
Comment 17 john.marmion 2002-12-05 14:53:57 UTC
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").
Comment 18 daniel.rentz 2002-12-05 16:13:42 UTC
John,
Yes, please include both cases sheet/book for BIFF4.
Comment 19 john.marmion 2002-12-06 11:06:37 UTC
Created attachment 3933 [details]
latest patch - adding Biff4(sheet) and Biff4)workbook) plus review from dr
Comment 20 john.marmion 2002-12-06 11:50:29 UTC
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.
Comment 21 daniel.rentz 2002-12-06 11:54:19 UTC
Jes, completing sheet protection sounds good.
Comment 22 john.marmion 2002-12-06 15:57:03 UTC
Created attachment 3943 [details]
extend sheet protection support for import/export and clean up spacing
Comment 23 john.marmion 2002-12-06 16:10:23 UTC
checked in this latest patch today.
Comment 24 john.marmion 2003-01-02 11:32:54 UTC
taking responsibility for this now.
Comment 25 john.marmion 2003-01-02 11:33:46 UTC
Marking this as fixed
Comment 26 john.marmion 2003-02-19 14:07:49 UTC
fixed for OOo 1.1 Beta
Comment 27 john.marmion 2003-02-19 14:08:27 UTC
re-open to assign to QA
Comment 28 john.marmion 2003-02-19 14:08:56 UTC
assign to QA
Comment 29 john.marmion 2003-02-19 14:09:24 UTC
re-set status to fixed
Comment 30 thorsten.ziehm 2003-05-20 11:22:48 UTC
Verified in OOo 1.1 Beta2.
Comment 31 thorsten.ziehm 2003-05-20 11:25:02 UTC
closed ...
Comment 32 oc 2004-05-28 09:41:09 UTC
*** Issue 29387 has been marked as a duplicate of this issue. ***