Kaydet (Commit) 2d5a9e9f authored tarafından Eike Rathke's avatar Eike Rathke

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
üst 0fe1b2fb
...@@ -192,15 +192,31 @@ void WorkbookSettings::finalizeImport() ...@@ -192,15 +192,31 @@ void WorkbookSettings::finalizeImport()
aPropSet.setProperty( PROP_Wildcards, true ); // always in Excel aPropSet.setProperty( PROP_Wildcards, true ); // always in Excel
// write protection // write protection
if( maFileSharing.mbRecommendReadOnly || (maFileSharing.mnPasswordHash != 0) ) try if (maFileSharing.mbRecommendReadOnly || (maFileSharing.mnPasswordHash != 0) ||
!maFileSharing.maHashValue.isEmpty()) try
{ {
getBaseFilter().getMediaDescriptor()[ "ReadOnly" ] <<= true; getBaseFilter().getMediaDescriptor()[ "ReadOnly" ] <<= true;
Reference< XPropertySet > xDocumentSettings( getBaseFilter().getModelFactory()->createInstance( Reference< XPropertySet > xDocumentSettings( getBaseFilter().getModelFactory()->createInstance(
"com.sun.star.document.Settings" ), UNO_QUERY_THROW ); "com.sun.star.document.Settings" ), UNO_QUERY_THROW );
PropertySet aSettingsProp( xDocumentSettings ); 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 ); 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 ) // if( maFileSharing.mnPasswordHash != 0 )
// aSettingsProp.setProperty( PROP_ModifyPasswordHash, static_cast< sal_Int32 >( maFileSharing.mnPasswordHash ) ); // aSettingsProp.setProperty( PROP_ModifyPasswordHash, static_cast< sal_Int32 >( maFileSharing.mnPasswordHash ) );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment