diff options
author | Noel Grandin <noel@peralex.com> | 2013-02-12 09:23:05 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2013-02-12 10:14:45 +0200 |
commit | 4b51374a7021d52f7f1be1861e2ee6a011b30ecd (patch) | |
tree | 77a0121f0eda201befd57a5848bd08aa906473f0 /basctl/source | |
parent | 53ec703c14470cb18845fc4483ec36c13b0d744e (diff) |
fdo#46808, Adapt ui::dialogs::FilePicker UNO service to new style
Change-Id: I1cafbfc53994e5d74241042dbd1d292ddbda67d5
Diffstat (limited to 'basctl/source')
-rw-r--r-- | basctl/source/basicide/baside2.cxx | 37 | ||||
-rw-r--r-- | basctl/source/basicide/baside3.cxx | 41 | ||||
-rw-r--r-- | basctl/source/basicide/moduldl2.cxx | 56 |
3 files changed, 44 insertions, 90 deletions
diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx index 4dcc13a9e1bd..7bcc2dccd359 100644 --- a/basctl/source/basicide/baside2.cxx +++ b/basctl/source/basicide/baside2.cxx @@ -34,6 +34,7 @@ #include <com/sun/star/script/ModuleType.hpp> #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> +#include <com/sun/star/ui/dialogs/FilePicker.hpp> #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp> #include <com/sun/star/ui/dialogs/XFilterManager.hpp> #include <comphelper/processfactory.hxx> @@ -433,23 +434,15 @@ bool ModulWindow::LoadBasic() DBG_CHKTHIS( ModulWindow, 0 ); bool bDone = false; - Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() ); - Reference < XFilePicker > xFP; - if( xMSF.is() ) - { - Sequence <Any> aServiceType(1); - aServiceType[0] <<= TemplateDescription::FILEOPEN_SIMPLE; - xFP = Reference< XFilePicker >( xMSF->createInstanceWithArguments( - "com.sun.star.ui.dialogs.FilePicker", aServiceType ), UNO_QUERY ); - } + Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); + Reference < XFilePicker3 > xFP = FilePicker::createWithMode(xContext, TemplateDescription::FILEOPEN_SIMPLE); if ( !aCurPath.isEmpty() ) xFP->setDisplayDirectory ( aCurPath ); - Reference< XFilterManager > xFltMgr(xFP, UNO_QUERY); - xFltMgr->appendFilter( "BASIC" , "*.bas" ); - xFltMgr->appendFilter( IDE_RESSTR(RID_STR_FILTER_ALLFILES), OUString( FilterMask_All ) ); - xFltMgr->setCurrentFilter( "BASIC" ); + xFP->appendFilter( "BASIC" , "*.bas" ); + xFP->appendFilter( IDE_RESSTR(RID_STR_FILTER_ALLFILES), OUString( FilterMask_All ) ); + xFP->setCurrentFilter( "BASIC" ); if( xFP->execute() == RET_OK ) { @@ -487,15 +480,8 @@ bool ModulWindow::SaveBasicSource() DBG_CHKTHIS( ModulWindow, 0 ); bool bDone = false; - Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() ); - Reference < XFilePicker > xFP; - if( xMSF.is() ) - { - Sequence <Any> aServiceType(1); - aServiceType[0] <<= TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD; - xFP = Reference< XFilePicker >( xMSF->createInstanceWithArguments( - "com.sun.star.ui.dialogs.FilePicker", aServiceType ), UNO_QUERY ); - } + Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); + Reference < XFilePicker3 > xFP = FilePicker::createWithMode(xContext, TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD); Reference< XFilePickerControlAccess > xFPControl(xFP, UNO_QUERY); xFPControl->enableControl(ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, false); @@ -506,10 +492,9 @@ bool ModulWindow::SaveBasicSource() if ( !aCurPath.isEmpty() ) xFP->setDisplayDirectory ( aCurPath ); - Reference< XFilterManager > xFltMgr(xFP, UNO_QUERY); - xFltMgr->appendFilter( "BASIC", "*.bas" ); - xFltMgr->appendFilter( IDE_RESSTR(RID_STR_FILTER_ALLFILES), OUString( FilterMask_All ) ); - xFltMgr->setCurrentFilter( "BASIC" ); + xFP->appendFilter( "BASIC", "*.bas" ); + xFP->appendFilter( IDE_RESSTR(RID_STR_FILTER_ALLFILES), OUString( FilterMask_All ) ); + xFP->setCurrentFilter( "BASIC" ); if( xFP->execute() == RET_OK ) { diff --git a/basctl/source/basicide/baside3.cxx b/basctl/source/basicide/baside3.cxx index 4d4e0bc9591e..a23b09cd3346 100644 --- a/basctl/source/basicide/baside3.cxx +++ b/basctl/source/basicide/baside3.cxx @@ -39,6 +39,7 @@ #include <com/sun/star/ucb/SimpleFileAccess.hpp> #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> +#include <com/sun/star/ui/dialogs/FilePicker.hpp> #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp> #include <com/sun/star/ui/dialogs/XFilterManager.hpp> #include <comphelper/processfactory.hxx> @@ -689,15 +690,8 @@ bool DialogWindow::SaveDialog() DBG_CHKTHIS( DialogWindow, 0 ); bool bDone = false; - Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() ); - Reference < XFilePicker > xFP; - if( xMSF.is() ) - { - Sequence <Any> aServiceType(1); - aServiceType[0] <<= TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD; - xFP = Reference< XFilePicker >( xMSF->createInstanceWithArguments( - "com.sun.star.ui.dialogs.FilePicker", aServiceType ), UNO_QUERY ); - } + Reference< XComponentContext > xContext( comphelper::getProcessComponentContext() ); + Reference < XFilePicker3 > xFP = FilePicker::createWithMode(xContext, TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD); Reference< XFilePickerControlAccess > xFPControl(xFP, UNO_QUERY); xFPControl->enableControl(ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, false); @@ -711,10 +705,9 @@ bool DialogWindow::SaveDialog() xFP->setDefaultName( OUString( GetName() ) ); OUString aDialogStr(IDE_RESSTR(RID_STR_STDDIALOGNAME)); - Reference< XFilterManager > xFltMgr(xFP, UNO_QUERY); - xFltMgr->appendFilter( aDialogStr, String( "*.xdl" ) ); - xFltMgr->appendFilter( IDE_RESSTR(RID_STR_FILTER_ALLFILES), String( FilterMask_All ) ); - xFltMgr->setCurrentFilter( aDialogStr ); + xFP->appendFilter( aDialogStr, String( "*.xdl" ) ); + xFP->appendFilter( IDE_RESSTR(RID_STR_FILTER_ALLFILES), String( FilterMask_All ) ); + xFP->setCurrentFilter( aDialogStr ); if( xFP->execute() == RET_OK ) { @@ -723,11 +716,10 @@ bool DialogWindow::SaveDialog() // export dialog model to xml Reference< container::XNameContainer > xDialogModel = GetDialog(); - Reference< XComponentContext > xContext( comphelper::getProcessComponentContext() ); Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, GetDocument().isDocument() ? GetDocument().getDocument() : Reference< frame::XModel >() ); Reference< XInputStream > xInput( xISP->createInputStream() ); - Reference< XSimpleFileAccess3 > xSFI( SimpleFileAccess::create(comphelper::getProcessComponentContext()) ); + Reference< XSimpleFileAccess3 > xSFI( SimpleFileAccess::create(xContext) ); Reference< XOutputStream > xOutput; try @@ -950,14 +942,8 @@ bool implImportDialog( Window* pWin, const OUString& rCurPath, const ScriptDocum bool bDone = false; Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() ); - Reference < XFilePicker > xFP; - if( xMSF.is() ) - { - Sequence <Any> aServiceType(1); - aServiceType[0] <<= TemplateDescription::FILEOPEN_SIMPLE; - xFP = Reference< XFilePicker >( xMSF->createInstanceWithArguments( - "com.sun.star.ui.dialogs.FilePicker", aServiceType ), UNO_QUERY ); - } + Reference< XComponentContext > xContext( comphelper::getComponentContext( xMSF ) ); + Reference < XFilePicker3 > xFP = FilePicker::createWithMode(xContext, TemplateDescription::FILEOPEN_SIMPLE); Reference< XFilePickerControlAccess > xFPControl(xFP, UNO_QUERY); xFPControl->enableControl(ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, false); @@ -970,10 +956,9 @@ bool implImportDialog( Window* pWin, const OUString& rCurPath, const ScriptDocum xFP->setDisplayDirectory ( aCurPath ); OUString aDialogStr(IDE_RESSTR(RID_STR_STDDIALOGNAME)); - Reference< XFilterManager > xFltMgr(xFP, UNO_QUERY); - xFltMgr->appendFilter( aDialogStr, String( "*.xdl" ) ); - xFltMgr->appendFilter( IDE_RESSTR(RID_STR_FILTER_ALLFILES), String( FilterMask_All ) ); - xFltMgr->setCurrentFilter( aDialogStr ); + xFP->appendFilter( aDialogStr, String( "*.xdl" ) ); + xFP->appendFilter( IDE_RESSTR(RID_STR_FILTER_ALLFILES), String( FilterMask_All ) ); + xFP->setCurrentFilter( aDialogStr ); if( xFP->execute() == RET_OK ) { @@ -998,8 +983,6 @@ bool implImportDialog( Window* pWin, const OUString& rCurPath, const ScriptDocum if( xSFI->exists( aCurPath ) ) xInput = xSFI->openFileRead( aCurPath ); - Reference< XComponentContext > xContext( - comphelper::getComponentContext( xMSF ) ); ::xmlscript::importDialogModel( xInput, xDialogModel, xContext, rDocument.isDocument() ? rDocument.getDocument() : Reference< frame::XModel >() ); OUString aXmlDlgName; diff --git a/basctl/source/basicide/moduldl2.cxx b/basctl/source/basicide/moduldl2.cxx index 4437f64a7021..f07e1af64be5 100644 --- a/basctl/source/basicide/moduldl2.cxx +++ b/basctl/source/basicide/moduldl2.cxx @@ -45,7 +45,7 @@ #include <sot/storage.hxx> #include <com/sun/star/io/Pipe.hpp> -#include <com/sun/star/ui/dialogs/XFilePicker.hpp> +#include <com/sun/star/ui/dialogs/FilePicker.hpp> #include <com/sun/star/ui/dialogs/FolderPicker.hpp> #include <com/sun/star/ui/dialogs/XFilterManager.hpp> #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> @@ -781,16 +781,10 @@ void LibPage::NewLib() void LibPage::InsertLib() { - // file open dialog Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() ); - Reference < XFilePicker > xFP; - if( xMSF.is() ) - { - Sequence <Any> aServiceType(1); - aServiceType[0] <<= TemplateDescription::FILEOPEN_SIMPLE; - xFP = Reference< XFilePicker >( xMSF->createInstanceWithArguments( - "com.sun.star.ui.dialogs.FilePicker", aServiceType ), UNO_QUERY ); - } + Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); + // file open dialog + Reference < XFilePicker3 > xFP = FilePicker::createWithMode(xContext, TemplateDescription::FILEOPEN_SIMPLE); xFP->setTitle( String( IDEResId( RID_STR_APPENDLIBS ) ) ); // filter @@ -852,27 +846,24 @@ void LibPage::InsertLib() aDlgURLObj.setBase( aDlgBase ); } - if ( xMSF.is() ) - { - Reference< XSimpleFileAccess3 > xSFA( SimpleFileAccess::create(comphelper::getProcessComponentContext()) ); + Reference< XSimpleFileAccess3 > xSFA( SimpleFileAccess::create(comphelper::getProcessComponentContext()) ); - OUString aModURL( aModURLObj.GetMainURL( INetURLObject::NO_DECODE ) ); - if ( xSFA->exists( aModURL ) ) - { - Sequence <Any> aSeqModURL(1); - aSeqModURL[0] <<= aModURL; - xModLibContImport = Reference< script::XLibraryContainer2 >( xMSF->createInstanceWithArguments( - "com.sun.star.script.DocumentScriptLibraryContainer", aSeqModURL ), UNO_QUERY ); - } + OUString aModURL( aModURLObj.GetMainURL( INetURLObject::NO_DECODE ) ); + if ( xSFA->exists( aModURL ) ) + { + Sequence <Any> aSeqModURL(1); + aSeqModURL[0] <<= aModURL; + xModLibContImport = Reference< script::XLibraryContainer2 >( xMSF->createInstanceWithArguments( + "com.sun.star.script.DocumentScriptLibraryContainer", aSeqModURL ), UNO_QUERY ); + } - OUString aDlgURL( aDlgURLObj.GetMainURL( INetURLObject::NO_DECODE ) ); - if ( xSFA->exists( aDlgURL ) ) - { - Sequence <Any> aSeqDlgURL(1); - aSeqDlgURL[0] <<= aDlgURL; - xDlgLibContImport = Reference< script::XLibraryContainer2 >( xMSF->createInstanceWithArguments( - "com.sun.star.script.DocumentDialogLibraryContainer", aSeqDlgURL ), UNO_QUERY ); - } + OUString aDlgURL( aDlgURLObj.GetMainURL( INetURLObject::NO_DECODE ) ); + if ( xSFA->exists( aDlgURL ) ) + { + Sequence <Any> aSeqDlgURL(1); + aSeqDlgURL[0] <<= aDlgURL; + xDlgLibContImport = Reference< script::XLibraryContainer2 >( xMSF->createInstanceWithArguments( + "com.sun.star.script.DocumentDialogLibraryContainer", aSeqDlgURL ), UNO_QUERY ); } if ( xModLibContImport.is() || xDlgLibContImport.is() ) @@ -1253,16 +1244,11 @@ Reference< XProgressHandler > OLibCommandEnvironment::getProgressHandler() void LibPage::ExportAsPackage( const String& aLibName ) { // file open dialog - Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() ); Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); Reference< task::XInteractionHandler2 > xHandler( task::InteractionHandler::createWithParent(xContext, 0) ); Reference< XSimpleFileAccess3 > xSFA = SimpleFileAccess::create(xContext); - Reference < XFilePicker > xFP; - Sequence <Any> aServiceType(1); - aServiceType[0] <<= TemplateDescription::FILESAVE_SIMPLE; - xFP = Reference< XFilePicker >( xMSF->createInstanceWithArguments( - "com.sun.star.ui.dialogs.FilePicker", aServiceType ), UNO_QUERY ); + Reference < XFilePicker3 > xFP = FilePicker::createWithMode(xContext, TemplateDescription::FILESAVE_SIMPLE); xFP->setTitle( String( IDEResId( RID_STR_EXPORTPACKAGE ) ) ); |