diff options
author | Ivo Hinkelmann <ihi@openoffice.org> | 2011-04-01 10:18:41 +0200 |
---|---|---|
committer | Ivo Hinkelmann <ihi@openoffice.org> | 2011-04-01 10:18:41 +0200 |
commit | 85ea8e9095f6be2faef2531ac1cba57bbbdc2c26 (patch) | |
tree | 8a7f14203dc1f458a847af209f537ba3994a179b /sfx2 | |
parent | 5524a24f2116fb7f54ce35384dfeb7ea916af32e (diff) | |
parent | 65d4580044ab82df5ef30f00875e98d61e000ae4 (diff) |
CWS-TOOLING: integrate CWS mav60
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/appl/appopen.cxx | 5 | ||||
-rw-r--r-- | sfx2/source/doc/DocumentMetadataAccess.cxx | 10 | ||||
-rw-r--r-- | sfx2/source/doc/guisaveas.cxx | 8 | ||||
-rw-r--r-- | sfx2/source/doc/objstor.cxx | 42 |
4 files changed, 48 insertions, 17 deletions
diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx index 281a87c962f7..8b76024c1afb 100644 --- a/sfx2/source/appl/appopen.cxx +++ b/sfx2/source/appl/appopen.cxx @@ -288,8 +288,9 @@ private: } catch( const uno::Exception& ) { - // unknown error, do not try to ask again - eResult = ::comphelper::DocPasswordVerifierResult_ABORT; + // unknown error, report it as wrong password + // TODO/LATER: we need an additional way to report unknown problems in this case + eResult = ::comphelper::DocPasswordVerifierResult_WRONG_PASSWORD; } return eResult; } diff --git a/sfx2/source/doc/DocumentMetadataAccess.cxx b/sfx2/source/doc/DocumentMetadataAccess.cxx index df0781be8877..0ff55513c547 100644 --- a/sfx2/source/doc/DocumentMetadataAccess.cxx +++ b/sfx2/source/doc/DocumentMetadataAccess.cxx @@ -699,11 +699,11 @@ writeStream(struct DocumentMetadataAccess_Impl & i_rImpl, buf.append(dir).append(static_cast<sal_Unicode>('/')); writeStream(i_rImpl, xDir, i_xGraphName, rest, buf.makeStringAndClear()); - } - const uno::Reference<embed::XTransactedObject> xTransaction( - i_xStorage, uno::UNO_QUERY); - if (xTransaction.is()) { - xTransaction->commit(); + uno::Reference<embed::XTransactedObject> const xTransaction( + xDir, uno::UNO_QUERY); + if (xTransaction.is()) { + xTransaction->commit(); + } } } catch (uno::RuntimeException &) { throw; diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx index 2ccf5fa7a849..1df7d2b01920 100644 --- a/sfx2/source/doc/guisaveas.cxx +++ b/sfx2/source/doc/guisaveas.cxx @@ -670,6 +670,10 @@ sal_Int8 ModelData_Impl::CheckSaveAcceptable( sal_Int8 nCurStatus ) //------------------------------------------------------------------------- sal_Int8 ModelData_Impl::CheckStateForSave() { + // if the document is readonly or a new one a SaveAs operation must be used + if ( !GetStorable()->hasLocation() || GetStorable()->isReadonly() ) + return STATUS_SAVEAS; + // check acceptable entries for media descriptor sal_Bool bVersInfoNeedsStore = sal_False; ::comphelper::SequenceAsHashMap aAcceptedArgs; @@ -701,10 +705,6 @@ sal_Int8 ModelData_Impl::CheckStateForSave() if ( !GetModifiable()->isModified() && !bVersInfoNeedsStore ) return STATUS_NO_ACTION; - // if the document is readonly or a new one a SaveAs operation must be used - if ( !GetStorable()->hasLocation() || GetStorable()->isReadonly() ) - return STATUS_SAVEAS; - // check that the old filter is acceptable ::rtl::OUString aOldFilterName = GetDocProps().getUnpackedValueOrDefault( aFilterNameString, diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 9a86e962cac6..38f30b78974a 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -67,9 +67,12 @@ #include <com/sun/star/embed/XLinkageSupport.hpp> #include <com/sun/star/embed/EntryInitModes.hpp> #include <com/sun/star/embed/XOptimizedStorage.hpp> +#include <com/sun/star/embed/XEncryptionProtectedStorage.hpp> #include <com/sun/star/io/XTruncate.hpp> #include <com/sun/star/util/XModifiable.hpp> #include <com/sun/star/security/XDocumentDigitalSignatures.hpp> +#include <com/sun/star/xml/crypto/CipherID.hpp> +#include <com/sun/star/xml/crypto/DigestID.hpp> #include <com/sun/star/document/XDocumentProperties.hpp> #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> @@ -357,24 +360,51 @@ void SfxObjectShell::SetupStorage( const uno::Reference< embed::XStorage >& xSto const_cast<SfxObjectShell*>( this )->SetError( ERRCODE_IO_GENERAL, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); } - ::rtl::OUString aVersion; SvtSaveOptions aSaveOpt; SvtSaveOptions::ODFDefaultVersion nDefVersion = aSaveOpt.GetODFDefaultVersion(); - // older versions can not have this property set, it exists only starting from ODF1.2 - if ( nDefVersion >= SvtSaveOptions::ODFVER_012 ) - aVersion = ODFVER_012_TEXT; + uno::Sequence< beans::NamedValue > aEncryptionAlgs( 3 ); + aEncryptionAlgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StartKeyGenerationAlgorithm" ) ); + aEncryptionAlgs[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EncryptionAlgorithm" ) ); + aEncryptionAlgs[2].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ChecksumAlgorithm" ) ); + // the default values, that should be used for ODF1.1 and older formats + aEncryptionAlgs[0].Value <<= xml::crypto::DigestID::SHA1; + aEncryptionAlgs[1].Value <<= xml::crypto::CipherID::BLOWFISH_CFB_8; + aEncryptionAlgs[2].Value <<= xml::crypto::DigestID::SHA1_1K; - if ( aVersion.getLength() ) + if ( nDefVersion >= SvtSaveOptions::ODFVER_012 ) { try { - xProps->setPropertyValue( ::rtl::OUString::createFromAscii( "Version" ), uno::makeAny( aVersion ) ); + // older versions can not have this property set, it exists only starting from ODF1.2 + xProps->setPropertyValue( ::rtl::OUString::createFromAscii( "Version" ), uno::makeAny( ODFVER_012_TEXT ) ); } catch( uno::Exception& ) { } + + if ( !aSaveOpt.IsUseSHA1InODF12() ) + { + aEncryptionAlgs[0].Value <<= xml::crypto::DigestID::SHA256; + aEncryptionAlgs[2].Value <<= xml::crypto::DigestID::SHA256_1K; + } + if ( !aSaveOpt.IsUseBlowfishInODF12() ) + aEncryptionAlgs[1].Value <<= xml::crypto::CipherID::AES_CBC_W3C_PADDING; + } + + try + { + // set the encryption algorithms accordingly; + // the setting does not trigger encryption, + // it just provides the format for the case that contents should be encrypted + uno::Reference< embed::XEncryptionProtectedStorage > xEncr( xStorage, uno::UNO_QUERY_THROW ); + xEncr->setEncryptionAlgorithms( aEncryptionAlgs ); } + catch( uno::Exception& ) + { + const_cast<SfxObjectShell*>( this )->SetError( ERRCODE_IO_GENERAL, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); + } + } } } |