diff -urNpw @sfx2/source/appl/appopen.cxx sfx2/source/appl/appopen.cxx --- @sfx2/source/appl/appopen.cxx 2008-04-09 16:18:06.000000000 +0800 +++ sfx2/source/appl/appopen.cxx 2008-04-10 09:18:22.000000000 +0800 @@ -383,14 +383,14 @@ ULONG CheckPasswd_Impl sal_Bool bRetry = sal_True; sal_Bool bGotPasswd = sal_False; ::rtl::OUString aPassword; + ::com::sun::star::task::PasswordRequestMode nDlgMode = ::com::sun::star::task::PasswordRequestMode_PASSWORD_ENTER; while( bRetry ) { bRetry = sal_False; - RequestDocumentPassword* pPasswordRequest = new RequestDocumentPassword( - ::com::sun::star::task::PasswordRequestMode_PASSWORD_ENTER, - INetURLObject( pFile->GetOrigURL() ).GetName( INetURLObject::DECODE_WITH_CHARSET ) ); + RequestDocumentPassword* pPasswordRequest = new RequestDocumentPassword( nDlgMode, + INetURLObject( pFile->GetOrigURL() ).GetMainURL( INetURLObject::DECODE_WITH_CHARSET ) ); Reference< XInteractionRequest > rRequest( pPasswordRequest ); xInteractionHandler->handle( rRequest ); @@ -416,7 +416,7 @@ ULONG CheckPasswd_Impl catch( const packages::WrongPasswordException& ) { // reask for the password - ErrorHandler::HandleError( ERRCODE_SFX_WRONGPASSWORD ); + nDlgMode = ::com::sun::star::task::PasswordRequestMode_PASSWORD_REENTER; bRetry = sal_True; } catch( const uno::Exception& ) diff -urNpw @sfx2/source/dialog/filedlghelper.cxx sfx2/source/dialog/filedlghelper.cxx --- @sfx2/source/dialog/filedlghelper.cxx 2008-02-28 10:42:24.000000000 +0800 +++ sfx2/source/dialog/filedlghelper.cxx 2008-04-10 09:58:42.000000000 +0800 @@ -114,6 +114,9 @@ #ifndef _COM_SUN_STAR_UCB_INTERACTIVEAUGMENTEDIOEXCEPTION_HPP_ #include #endif +#ifndef _COM_SUN_STAR_TASK_XINTERACTIONREQUEST_HPP_ +#include +#endif #ifndef _COMPHELPER_PROCESSFACTORY_HXX_ #include @@ -237,6 +240,9 @@ #ifndef _SFX_FILEDLGIMPL_HXX #include "filedlgimpl.hxx" #endif +#ifndef INCLUDED_SVTOOLS_DOCPASSWDREQUEST_HXX +#include +#endif #include @@ -1654,31 +1660,6 @@ ErrCode FileDialogHelper_Impl::execute( if( !rpSet ) rpSet = new SfxAllItemSet( SFX_APP()->GetPool() ); - // check, wether or not we have to display a password box - if ( mbHasPassword && mbIsPwdEnabled && xCtrlAccess.is() ) - { - try - { - Any aValue = xCtrlAccess->getValue( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, 0 ); - sal_Bool bPassWord = sal_False; - if ( ( aValue >>= bPassWord ) && bPassWord ) - { - // ask for the password - SfxPasswordDialog aPasswordDlg( NULL ); - aPasswordDlg.ShowExtras( SHOWEXTRAS_CONFIRM ); - short nRet = aPasswordDlg.Execute(); - if ( RET_OK == nRet ) - { - String aPasswd = aPasswordDlg.GetPassword(); - rpSet->Put( SfxStringItem( SID_PASSWORD, aPasswd ) ); - } - else - return ERRCODE_ABORT; - } - } - catch( IllegalArgumentException ){} - } - if( mbExport ) { try @@ -1737,6 +1718,22 @@ ErrCode FileDialogHelper_Impl::execute( if ( rpURLList == NULL ) return ERRCODE_ABORT; + // check, whether or not we have to display a password box + if ( mbHasPassword && mbIsPwdEnabled && xCtrlAccess.is() ) + { + uno::Reference < ::com::sun::star::task::XInteractionHandler > xInteractionHandler( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.comp.uui.UUIInteractionHandler")), UNO_QUERY ); + + if( xInteractionHandler.is() ) + { + RequestDocumentPassword* pPasswordRequest = new RequestDocumentPassword( + ::com::sun::star::task::PasswordRequestMode_PASSWORD_CREATE, *(rpURLList->GetObject(0)) ); + + uno::Reference< com::sun::star::task::XInteractionRequest > rRequest( pPasswordRequest ); + xInteractionHandler->handle( rRequest ); + rpSet->Put( SfxStringItem( SID_PASSWORD, pPasswordRequest->getPassword() ) ); + } + } + SaveLastUsedFilter(); return ERRCODE_NONE; }