[Libreoffice-commits] core.git: Branch 'feature/cib_contract3756' - package/source sfx2/source

Serge Krot (via logerrit) logerrit at kemper.freedesktop.org
Fri Nov 8 20:20:12 UTC 2019


 package/source/zippackage/ZipPackage.cxx |   20 +-------------------
 sfx2/source/dialog/filedlghelper.cxx     |    9 +++++++--
 sfx2/source/doc/objserv.cxx              |   17 ++---------------
 sfx2/source/doc/objstor.cxx              |    8 +++++---
 4 files changed, 15 insertions(+), 39 deletions(-)

New commits:
commit 6cee6c0e9dd98ec6f22e1191121a0e6f8d6676fc
Author:     Serge Krot <Serge.Krot at cib.de>
AuthorDate: Fri Nov 8 21:14:28 2019 +0100
Commit:     Serge Krot (CIB) <Serge.Krot at cib.de>
CommitDate: Fri Nov 8 21:19:20 2019 +0100

    Source code clean up: do not clean up EncryptionData during SaveAs
    
    Change-Id: I1213ec55d6dc42f062930467976de45c73152f0b
    Reviewed-on: https://gerrit.libreoffice.org/82326
    Reviewed-by: Serge Krot (CIB) <Serge.Krot at cib.de>
    Tested-by: Serge Krot (CIB) <Serge.Krot at cib.de>

diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index cf8df0b417cc..63178c7fec24 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -1748,27 +1748,9 @@ void SAL_CALL ZipPackage::setPropertyValue( const OUString& aPropertyName, const
         // this property is only necessary to support raw passwords in storage API;
         // because of this support the storage has to operate with more than one key dependent on storage generation algorithm;
         // when this support is removed, the storage will get only one key from outside
-        uno::Sequence< beans::NamedValue > aKeys;
-        if ( !( aValue >>= aKeys ) )
+        if ( !( aValue >>= m_aStorageEncryptionKeys ) )
             throw IllegalArgumentException(THROW_WHERE, uno::Reference< uno::XInterface >(), 2 );
 
-/*        if ( aKeys.hasElements() )
-        {
-            bool bHasSHA256 = false;
-            bool bHasSHA1 = false;
-            for ( const auto& rKey : std::as_const(aKeys) )
-            {
-                if ( rKey.Name == PACKAGE_ENCRYPTIONDATA_SHA256UTF8 )
-                    bHasSHA256 = true;
-                if ( rKey.Name == PACKAGE_ENCRYPTIONDATA_SHA1UTF8 )
-                    bHasSHA1 = true;
-            }
-
-            if ( !bHasSHA256 && !bHasSHA1 )
-                throw IllegalArgumentException(THROW_WHERE "Expected keys are not provided!", uno::Reference< uno::XInterface >(), 2 );
-        }*/
-
-        m_aStorageEncryptionKeys = aKeys;
         m_aEncryptionKey.realloc( 0 );
     }
     else if ( aPropertyName == ENCRYPTION_ALGORITHMS_PROPERTY )
diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx
index 4347715a15ab..3b982bbcacf3 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -1414,8 +1414,13 @@ ErrCode FileDialogHelper_Impl::execute( std::vector<OUString>& rpURLList,
 
         // the password will be set in case user decide so
         rpSet->ClearItem( SID_PASSWORDINTERACTION );
-        rpSet->ClearItem( SID_PASSWORD );
-        //rpSet->ClearItem( SID_ENCRYPTIONDATA );
+        if (rpSet->HasItem( SID_PASSWORD ))
+        {
+            // As the SID_ENCRYPTIONDATA and SID_PASSWORD are using for setting password together, we need to clear them both.
+            // Note: Do not remove SID_ENCRYPTIONDATA without SID_PASSWORD
+            rpSet->ClearItem( SID_PASSWORD );
+            rpSet->ClearItem( SID_ENCRYPTIONDATA );
+        }
         rpSet->ClearItem( SID_RECOMMENDREADONLY );
         rpSet->ClearItem( SID_MODIFYPASSWORDINFO );
 
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 9e386d8c5964..512fe81d6efd 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -809,22 +809,9 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
                 }
 
 
-                bool bPreselectPassword = false;
                 const SfxStringItem* pOldPasswordItem = SfxItemSet::GetItem<SfxStringItem>(GetMedium()->GetItemSet(), SID_PASSWORD, false);
-                if (pOldPasswordItem)
-                {
-                    bPreselectPassword = true;
-                }
-                else
-                {
-                    const SfxUnoAnyItem* pOldEncryptionDataItem = SfxItemSet::GetItem<SfxUnoAnyItem>(GetMedium()->GetItemSet(), SID_ENCRYPTIONDATA, false);
-                    if (pOldEncryptionDataItem)
-                    {
-                        uno::Sequence< beans::NamedValue > aEncryptionData;
-                        pOldEncryptionDataItem->GetValue() >>= aEncryptionData;
-
-                    }
-                }
+                const SfxUnoAnyItem* pOldEncryptionDataItem = SfxItemSet::GetItem<SfxUnoAnyItem>(GetMedium()->GetItemSet(), SID_ENCRYPTIONDATA, false);
+                bool bPreselectPassword = (pOldPasswordItem && pOldEncryptionDataItem);
 
                 uno::Sequence< beans::PropertyValue > aDispatchArgs;
                 if ( rReq.GetArgs() )
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index ae58f9a88e97..174b06c761f3 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -2764,11 +2764,13 @@ bool SfxObjectShell::PreDoSaveAs_Impl(const OUString& rFileName, const OUString&
     std::unique_ptr<SfxAllItemSet> pMergedParams(new SfxAllItemSet( *pMedium->GetItemSet() ));
 
     // in "SaveAs" title and password will be cleared ( maybe the new itemset contains new values, otherwise they will be empty )
-    //pMergedParams->ClearItem( SID_ENCRYPTIONDATA );
-    pMergedParams->ClearItem( SID_PASSWORD );
     // #i119366# - As the SID_ENCRYPTIONDATA and SID_PASSWORD are using for setting password together, we need to clear them both.
     // Also, ( maybe the new itemset contains new values, otherwise they will be empty )
-//    pMergedParams->ClearItem( SID_ENCRYPTIONDATA );
+    if (pMergedParams->HasItem( SID_PASSWORD ))
+    {
+        pMergedParams->ClearItem( SID_PASSWORD );
+        pMergedParams->ClearItem( SID_ENCRYPTIONDATA );
+    }
     pMergedParams->ClearItem( SID_DOCINFO_TITLE );
 
     pMergedParams->ClearItem( SID_INPUTSTREAM );


More information about the Libreoffice-commits mailing list