[Libreoffice-commits] core.git: 3 commits - sc/source

Eike Rathke erack at redhat.com
Fri Feb 23 10:17:22 UTC 2018


 sc/source/filter/inc/workbooksettings.hxx  |    8 ++++++--
 sc/source/filter/inc/worksheetsettings.hxx |    6 +++++-
 sc/source/filter/oox/workbooksettings.cxx  |   25 +++++++++++++++++++++++--
 sc/source/filter/oox/worksheetsettings.cxx |    5 +++++
 4 files changed, 39 insertions(+), 5 deletions(-)

New commits:
commit 2d5a9e9f26daf95f33afb0d28ffd088cdd41ae8c
Author: Eike Rathke <erack at redhat.com>
Date:   Fri Feb 23 11:15:54 2018 +0100

    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

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 ) );
     }
commit 0fe1b2fb823470e2f5eae574f9c9f877eecc932d
Author: Eike Rathke <erack at redhat.com>
Date:   Fri Feb 23 10:17:01 2018 +0100

    Read algorithmName, hashValue, saltValue, spinCount, tdf#115933 prep
    
    Change-Id: I799d4652099059fcd09088c02537ed5dec087259

diff --git a/sc/source/filter/inc/workbooksettings.hxx b/sc/source/filter/inc/workbooksettings.hxx
index 02c8fa204a7f..dda6cc366f15 100644
--- a/sc/source/filter/inc/workbooksettings.hxx
+++ b/sc/source/filter/inc/workbooksettings.hxx
@@ -30,8 +30,12 @@ namespace xls {
 /** Settings for workbook write protection. */
 struct FileSharingModel
 {
-    OUString     maUserName;             /// User who added the write protection password.
-    sal_uInt16          mnPasswordHash;         /// Hash value of the write protection password.
+    OUString            maUserName;             /// User who added the write protection password.
+    OUString            maAlgorithmName;        /// Algorithm name, "SHA-512", "SHA-1", ...
+    OUString            maHashValue;            /// Hash value computed by the algorithm, base-64 encoded
+    OUString            maSaltValue;            /// Salt value to be prepended to the password, base-64 encoded
+    sal_uInt32          mnSpinCount;            /// Spin count, iterations to run algorithm
+    sal_uInt16          mnPasswordHash;         /// Hash value of the write protection password. (unrelated to the above)
     bool                mbRecommendReadOnly;    /// True = recommend read-only mode on opening.
 
     explicit            FileSharingModel();
diff --git a/sc/source/filter/oox/workbooksettings.cxx b/sc/source/filter/oox/workbooksettings.cxx
index 44c017bbafbc..9dd4caff95f1 100644
--- a/sc/source/filter/oox/workbooksettings.cxx
+++ b/sc/source/filter/oox/workbooksettings.cxx
@@ -63,6 +63,7 @@ const sal_Int16 API_SHOWMODE_PLACEHOLDER        = 2;        /// Show placeholder
 } // namespace
 
 FileSharingModel::FileSharingModel() :
+    mnSpinCount( 0 ),
     mnPasswordHash( 0 ),
     mbRecommendReadOnly( false )
 {
@@ -108,6 +109,10 @@ WorkbookSettings::WorkbookSettings( const WorkbookHelper& rHelper ) :
 void WorkbookSettings::importFileSharing( const AttributeList& rAttribs )
 {
     maFileSharing.maUserName          = rAttribs.getXString( XML_userName, OUString() );
+    maFileSharing.maAlgorithmName     = rAttribs.getString( XML_algorithmName, OUString());
+    maFileSharing.maHashValue         = rAttribs.getString( XML_hashValue, OUString());
+    maFileSharing.maSaltValue         = rAttribs.getString( XML_saltValue, OUString());
+    maFileSharing.mnSpinCount         = rAttribs.getUnsigned( XML_spinCount, 0);
     maFileSharing.mnPasswordHash      = oox::core::CodecHelper::getPasswordHash( rAttribs, XML_reservationPassword );
     maFileSharing.mbRecommendReadOnly = rAttribs.getBool( XML_readOnlyRecommended, false );
 }
commit 62767cf6062d4e90ba5de9b19927b1a96d0f7e62
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Feb 22 22:22:00 2018 +0100

    Read algorithmName, hashValue, saltValue, spinCount, tdf#104250 prep
    
    Change-Id: Idc68ad62e8420646d5aecd0d4126084390a1ed55

diff --git a/sc/source/filter/inc/worksheetsettings.hxx b/sc/source/filter/inc/worksheetsettings.hxx
index d2988d1150e9..46e19ee15f6c 100644
--- a/sc/source/filter/inc/worksheetsettings.hxx
+++ b/sc/source/filter/inc/worksheetsettings.hxx
@@ -43,7 +43,11 @@ struct SheetSettingsModel
 /** Sheet protection settings. */
 struct SheetProtectionModel
 {
-    sal_uInt16          mnPasswordHash;         /// Hash value from sheet protection password.
+    OUString            maAlgorithmName;        /// Algorithm name, "SHA-512", "SHA-1", ...
+    OUString            maHashValue;            /// Hash value computed by the algorithm, base-64 encoded
+    OUString            maSaltValue;            /// Salt value to be prepended to the password, base-64 encoded
+    sal_uInt32          mnSpinCount;            /// Spin count, iterations to run algorithm
+    sal_uInt16          mnPasswordHash;         /// Hash value from sheet protection password. (unrelated to the above)
     bool                mbSheet;                /// True = sheet protection enabled, locked cells are protected.
     bool                mbObjects;              /// True = objects locked.
     bool                mbScenarios;            /// True = scenarios locked.
diff --git a/sc/source/filter/oox/worksheetsettings.cxx b/sc/source/filter/oox/worksheetsettings.cxx
index f86abd370a12..06fc1db11da0 100644
--- a/sc/source/filter/oox/worksheetsettings.cxx
+++ b/sc/source/filter/oox/worksheetsettings.cxx
@@ -55,6 +55,7 @@ SheetSettingsModel::SheetSettingsModel() :
 }
 
 SheetProtectionModel::SheetProtectionModel() :
+    mnSpinCount( 0 ),
     mnPasswordHash( 0 ),
     mbSheet( false ),
     mbObjects( false ),
@@ -106,6 +107,10 @@ void WorksheetSettings::importOutlinePr( const AttributeList& rAttribs )
 
 void WorksheetSettings::importSheetProtection( const AttributeList& rAttribs )
 {
+    maSheetProt.maAlgorithmName    = rAttribs.getString( XML_algorithmName, OUString());
+    maSheetProt.maHashValue        = rAttribs.getString( XML_hashValue, OUString());
+    maSheetProt.maSaltValue        = rAttribs.getString( XML_saltValue, OUString());
+    maSheetProt.mnSpinCount        = rAttribs.getUnsigned( XML_spinCount, 0);
     maSheetProt.mnPasswordHash     = oox::core::CodecHelper::getPasswordHash( rAttribs, XML_password );
     maSheetProt.mbSheet            = rAttribs.getBool( XML_sheet, false );
     maSheetProt.mbObjects          = rAttribs.getBool( XML_objects, false );


More information about the Libreoffice-commits mailing list