diff options
Diffstat (limited to 'sfx2/source/dialog/filedlghelper.cxx')
-rw-r--r-- | sfx2/source/dialog/filedlghelper.cxx | 64 |
1 files changed, 24 insertions, 40 deletions
diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 33359a45ec96..b9fe056112c5 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -45,9 +45,7 @@ #include <com/sun/star/ui/dialogs/XFilePreview.hpp> #include <com/sun/star/ui/dialogs/XFilterManager.hpp> #include <com/sun/star/ui/dialogs/XFilterGroupManager.hpp> -#ifndef _COM_SUN_STAR_UI_DIALOGS_XFOLDERPICKER_HDL_ #include <com/sun/star/ui/dialogs/XFolderPicker.hpp> -#endif #include <com/sun/star/ui/dialogs/XFilePicker2.hpp> #include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> @@ -82,12 +80,9 @@ #include <svtools/filter.hxx> #include <svtools/viewoptions.hxx> #include <svtools/moduleoptions.hxx> -#ifndef _SVT_HELPID_HRC #include <svtools/helpid.hrc> -#endif #include <svtools/pickerhelper.hxx> -#include <svtools/docpasswdrequest.hxx> -#include <svtools/docmspasswdrequest.hxx> +#include <comphelper/docpasswordrequest.hxx> #include <ucbhelper/content.hxx> #include <ucbhelper/commandenvironment.hxx> #include <comphelper/storagehelper.hxx> @@ -99,13 +94,9 @@ #include <sfx2/passwd.hxx> #include "sfxresid.hxx" #include <sfx2/sfxsids.hrc> -#ifndef _SFX_FILEDLGHELPER_HRC #include "filedlghelper.hrc" -#endif #include "filtergrouping.hxx" -#ifndef SFX2_REQUEST_HXX #include <sfx2/request.hxx> -#endif #include "filedlgimpl.hxx" #include <sfxlocal.hrc> @@ -557,13 +548,15 @@ void FileDialogHelper_Impl::updateSelectionBox() } // ------------------------------------------------------------------------ -struct CheckMSPasswordCapability + +namespace { + +bool lclCheckMSPasswordCapability( const String rFilterName ) { - sal_Bool operator() ( const String rFilterName ) - { - return rFilterName.EqualsAscii("MS Word 97"); - } -}; + return rFilterName.EqualsAscii("MS Word 97"); +} + +} // namespace // ------------------------------------------------------------------------ struct CheckPasswordCapability @@ -584,7 +577,7 @@ struct CheckPasswordCapability return ( _pFilter->IsOwnFormat() && _pFilter->UsesStorage() && ( SOFFICE_FILEFORMAT_60 <= _pFilter->GetVersion() ) ) - || CheckMSPasswordCapability()( _pFilter->GetFilterName() ); + || lclCheckMSPasswordCapability( _pFilter->GetFilterName() ); } }; @@ -1671,30 +1664,21 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, if( xInteractionHandler.is() ) { // TODO: find out a way to set the 1-15 char limits on MS Excel 97 filter. - if ( CheckMSPasswordCapability()( rFilter ) ) - { - RequestMSDocumentPassword* pMSPasswordRequest = new RequestMSDocumentPassword( - ::com::sun::star::task::PasswordRequestMode_PASSWORD_CREATE, *(rpURLList->GetObject(0)) ); - - uno::Reference< com::sun::star::task::XInteractionRequest > rRequest( pMSPasswordRequest ); - xInteractionHandler->handle( rRequest ); - if ( pMSPasswordRequest->isPassword() ) - rpSet->Put( SfxStringItem( SID_PASSWORD, pMSPasswordRequest->getPassword() ) ); - else - return ERRCODE_ABORT; - } + + bool bMSType = lclCheckMSPasswordCapability( rFilter ); + ::comphelper::DocPasswordRequestType eType = bMSType ? + ::comphelper::DocPasswordRequestType_MS : + ::comphelper::DocPasswordRequestType_STANDARD; + + ::comphelper::DocPasswordRequest* pPasswordRequest = new ::comphelper::DocPasswordRequest( + eType, ::com::sun::star::task::PasswordRequestMode_PASSWORD_CREATE, *(rpURLList->GetObject(0)) ); + + uno::Reference< com::sun::star::task::XInteractionRequest > rRequest( pPasswordRequest ); + xInteractionHandler->handle( rRequest ); + if ( pPasswordRequest->isPassword() ) + rpSet->Put( SfxStringItem( SID_PASSWORD, pPasswordRequest->getPassword() ) ); else - { - 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 ); - if ( pPasswordRequest->isPassword() ) - rpSet->Put( SfxStringItem( SID_PASSWORD, pPasswordRequest->getPassword() ) ); - else - return ERRCODE_ABORT; - } + return ERRCODE_ABORT; } } } |