diff options
author | Mikhail Voytenko <mav@openoffice.org> | 2010-11-24 13:45:55 +0100 |
---|---|---|
committer | Mikhail Voytenko <mav@openoffice.org> | 2010-11-24 13:45:55 +0100 |
commit | a3816d55a7bb3273046dccbb200a9637a539e001 (patch) | |
tree | d472247876903e0a2fb108c400b70587d68adeff | |
parent | 31fe9daed03de3deb52443b4a795fbc75b870575 (diff) |
pl08: #i115742# fix excel export and import functionality
-rw-r--r-- | sc/source/filter/excel/xestream.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/excel/xistream.cxx | 22 |
2 files changed, 23 insertions, 1 deletions
diff --git a/sc/source/filter/excel/xestream.cxx b/sc/source/filter/excel/xestream.cxx index b15568e8ce9a..356b0d8bab42 100644 --- a/sc/source/filter/excel/xestream.cxx +++ b/sc/source/filter/excel/xestream.cxx @@ -600,7 +600,7 @@ void XclExpBiff8Encrypter::Init( const uno::Sequence< beans::NamedValue >& aEncr // generate salt hash. ::msfilter::MSCodec_Std97 aCodec; aCodec.InitCodec( aEncryptionData ); - aCodec.GetDigestFromSalt( mpnSalt, mpnSaltDigest ); + aCodec.CreateSaltDigest( mpnSalt, mpnSaltDigest ); // verify to make sure it's in good shape. mbValid = maCodec.VerifyKey( mpnSalt, mpnSaltDigest ); diff --git a/sc/source/filter/excel/xistream.cxx b/sc/source/filter/excel/xistream.cxx index 6b4851292e11..534d40fa5cd5 100644 --- a/sc/source/filter/excel/xistream.cxx +++ b/sc/source/filter/excel/xistream.cxx @@ -28,6 +28,9 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sc.hxx" +#include <comphelper/docpasswordhelper.hxx> +#include <comphelper/sequenceashashmap.hxx> + #include "xistream.hxx" #include "xlstring.hxx" #include "xiroot.hxx" @@ -153,7 +156,26 @@ uno::Sequence< beans::NamedValue > XclImpBiff5Decrypter::OnVerifyPassword( const maCodec.InitKey( (sal_uInt8*)aBytePassword.getStr() ); if ( maCodec.VerifyKey( mnKey, mnHash ) ) + { maEncryptionData = maCodec.GetEncryptionData(); + + // since the export uses Std97 encryption always we have to request it here + ::std::vector< sal_uInt16 > aPassVect( 16 ); + ::std::vector< sal_uInt16 >::iterator aIt = aPassVect.begin(); + for( sal_Int32 nInd = 0; nInd < nLen; ++nInd, ++aIt ) + *aIt = static_cast< sal_uInt16 >( rPassword.getStr()[nInd] ); + + uno::Sequence< sal_Int8 > aDocId = ::comphelper::DocPasswordHelper::GenerateRandomByteSequence( 16 ); + OSL_ENSURE( aDocId.getLength() == 16, "Unexpected length of the senquence!" ); + + ::msfilter::MSCodec_Std97 aCodec97; + aCodec97.InitKey( &aPassVect.front(), (sal_uInt8*)aDocId.getConstArray() ); + + // merge the EncryptionData, there should be no conflicts + ::comphelper::SequenceAsHashMap aEncryptionHash( maEncryptionData ); + aEncryptionHash.update( ::comphelper::SequenceAsHashMap( aCodec97.GetEncryptionData() ) ); + aEncryptionHash >> maEncryptionData; + } } return maEncryptionData; |