diff options
author | Eike Rathke <erack@redhat.com> | 2018-02-23 11:15:54 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2018-02-23 11:16:58 +0100 |
commit | 2d5a9e9f26daf95f33afb0d28ffd088cdd41ae8c (patch) | |
tree | 7d600516c943b56f37612e9f69eea003d4ab6d9c | |
parent | 0fe1b2fb823470e2f5eae574f9c9f877eecc932d (diff) |
tdf#115933 set document read-only on presence of hashValue attribute
Though there's currently no way (password dialog) to edit the
document other than saving it to a different file, this seems to
be what is expected.
Change-Id: Iafa8ac9f6e41c3011ed0ad4b19cc57382c9f2a75
-rw-r--r-- | sc/source/filter/oox/workbooksettings.cxx | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/sc/source/filter/oox/workbooksettings.cxx b/sc/source/filter/oox/workbooksettings.cxx index 9dd4caff95f1..34be4e5608fa 100644 --- a/sc/source/filter/oox/workbooksettings.cxx +++ b/sc/source/filter/oox/workbooksettings.cxx @@ -192,15 +192,31 @@ void WorkbookSettings::finalizeImport() aPropSet.setProperty( PROP_Wildcards, true ); // always in Excel // write protection - if( maFileSharing.mbRecommendReadOnly || (maFileSharing.mnPasswordHash != 0) ) try + if (maFileSharing.mbRecommendReadOnly || (maFileSharing.mnPasswordHash != 0) || + !maFileSharing.maHashValue.isEmpty()) try { getBaseFilter().getMediaDescriptor()[ "ReadOnly" ] <<= true; Reference< XPropertySet > xDocumentSettings( getBaseFilter().getModelFactory()->createInstance( "com.sun.star.document.Settings" ), UNO_QUERY_THROW ); PropertySet aSettingsProp( xDocumentSettings ); - if( maFileSharing.mbRecommendReadOnly ) + + /* TODO: not setting read-only if only mnPasswordHash ('password' + * attribute) is present looks a bit silly, any reason for that? + * 'readOnlyRecommended' is defined as "indicates on open, whether the + * application alerts the user that the file be marked as read-only", + * which sounds silly in itself and seems not to be present if the + * 'password' attribute isn't present, but.. */ + if (maFileSharing.mbRecommendReadOnly || !maFileSharing.maHashValue.isEmpty()) aSettingsProp.setProperty( PROP_LoadReadonly, true ); + + /* TODO: setting ModifyPasswordHash was commented out with commit + * 1a842832cd174d5ccfd832fdb94c93ae42e8eacc of which the filter + * fragment parts meanwhile contain PASSWORDTOMODIFY again, also for + * calc_OOXML.xcu, but setting the property doesn't raise a dialog. If + * it worked, a Sequence<PropertyValue> should be used for + * algorithmName,hashValue,... see also + * SfxObjectShell::SetModifyPasswordInfo() */ // if( maFileSharing.mnPasswordHash != 0 ) // aSettingsProp.setProperty( PROP_ModifyPasswordHash, static_cast< sal_Int32 >( maFileSharing.mnPasswordHash ) ); } |