summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasily Melenchuk <vasily.melenchuk@cib.de>2019-10-14 00:01:52 +0300
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2019-12-04 13:42:22 +0100
commit3a734de43ad32ae9d081dcea1568d743051c01f2 (patch)
tree9c7349d5d9a4f803fd03481ad5560178197284a8
parentf85117615147a34ee8ac826744691a212b3b094b (diff)
do not clean up EncryptionData during SaveAs
As the SID_ENCRYPTIONDATA and SID_PASSWORD are used for setting password together, EncryptionData should be removed only when Password was set (reset of Password protection for the document). Elsewhere EncryptionData should remain as is, while it could contain encryption data used for opened document. Change-Id: I46b757af81e68ad4781e83b1a0e0b6da3a5e13e1 Change-Id: I1213ec55d6dc42f062930467976de45c73152f0b Reviewed-on: https://gerrit.libreoffice.org/82616 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Conflicts: package/source/zippackage/ZipPackage.cxx
-rw-r--r--package/source/zippackage/ZipPackage.cxx20
-rw-r--r--sfx2/source/dialog/filedlghelper.cxx9
-rw-r--r--sfx2/source/doc/objserv.cxx6
-rw-r--r--sfx2/source/doc/objstor.cxx8
4 files changed, 15 insertions, 28 deletions
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index 5a715d3ccfda..78627441b506 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -1752,27 +1752,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 ( sal_Int32 nInd = 0; nInd < aKeys.getLength(); nInd++ )
- {
- if ( aKeys[nInd].Name == PACKAGE_ENCRYPTIONDATA_SHA256UTF8 )
- bHasSHA256 = true;
- if ( aKeys[nInd].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 dd6cde167da1..214a7f48a622 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -1432,8 +1432,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 f088dfc11848..f586fe446b5d 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -786,11 +786,9 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
}
- bool bPreselectPassword = false;
- const SfxUnoAnyItem* pOldEncryptionDataItem = SfxItemSet::GetItem<SfxUnoAnyItem>(GetMedium()->GetItemSet(), SID_ENCRYPTIONDATA, false);
const SfxStringItem* pOldPasswordItem = SfxItemSet::GetItem<SfxStringItem>(GetMedium()->GetItemSet(), SID_PASSWORD, false);
- if ( pOldEncryptionDataItem || pOldPasswordItem )
- bPreselectPassword = true;
+ 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 e0feb44ccfae..04c907ff32ed 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -2752,11 +2752,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 );