summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2013-02-12 09:23:05 +0200
committerNoel Grandin <noel@peralex.com>2013-02-12 10:14:45 +0200
commit4b51374a7021d52f7f1be1861e2ee6a011b30ecd (patch)
tree77a0121f0eda201befd57a5848bd08aa906473f0 /cui
parent53ec703c14470cb18845fc4483ec36c13b0d744e (diff)
fdo#46808, Adapt ui::dialogs::FilePicker UNO service to new style
Change-Id: I1cafbfc53994e5d74241042dbd1d292ddbda67d5
Diffstat (limited to 'cui')
-rw-r--r--cui/source/dialogs/insdlg.cxx52
-rw-r--r--cui/source/options/personalization.cxx14
2 files changed, 24 insertions, 42 deletions
diff --git a/cui/source/dialogs/insdlg.cxx b/cui/source/dialogs/insdlg.cxx
index 4163afc14d8d..36253d3b185d 100644
--- a/cui/source/dialogs/insdlg.cxx
+++ b/cui/source/dialogs/insdlg.cxx
@@ -19,7 +19,7 @@
#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
-#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
+#include <com/sun/star/ui/dialogs/FilePicker.hpp>
#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
@@ -112,40 +112,28 @@ IMPL_LINK_INLINE_END( SvInsertOleDlg, DoubleClickHdl, ListBox *, pListBox )
IMPL_LINK_NOARG(SvInsertOleDlg, BrowseHdl)
{
- Reference< XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
- if( xFactory.is() )
- {
- Reference< XFilePicker > xFilePicker( xFactory->createInstance( "com.sun.star.ui.dialogs.FilePicker" ), UNO_QUERY );
- DBG_ASSERT( xFilePicker.is(), "could not get FilePicker service" );
+ Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
- Reference< XInitialization > xInit( xFilePicker, UNO_QUERY );
- Reference< XFilterManager > xFilterMgr( xFilePicker, UNO_QUERY );
- if( xInit.is() && xFilePicker.is() && xFilterMgr.is() )
- {
- Sequence< Any > aServiceType( 1 );
- aServiceType[0] <<= TemplateDescription::FILEOPEN_SIMPLE;
- xInit->initialize( aServiceType );
+ Reference< XFilePicker3 > xFilePicker = FilePicker::createWithMode(xContext, TemplateDescription::FILEOPEN_SIMPLE);
- // add filter
- try
- {
- xFilterMgr->appendFilter(
- OUString(),
- OUString( "*.*" )
- );
- }
- catch( IllegalArgumentException& )
- {
- DBG_ASSERT( 0, "caught IllegalArgumentException when registering filter\n" );
- }
+ // add filter
+ try
+ {
+ xFilePicker->appendFilter(
+ OUString(),
+ OUString( "*.*" )
+ );
+ }
+ catch( const IllegalArgumentException& )
+ {
+ DBG_ASSERT( 0, "caught IllegalArgumentException when registering filter\n" );
+ }
- if( xFilePicker->execute() == ExecutableDialogResults::OK )
- {
- Sequence< OUString > aPathSeq( xFilePicker->getFiles() );
- INetURLObject aObj( aPathSeq[0] );
- m_pEdFilepath->SetText( aObj.PathToFileName() );
- }
- }
+ if( xFilePicker->execute() == ExecutableDialogResults::OK )
+ {
+ Sequence< OUString > aPathSeq( xFilePicker->getFiles() );
+ INetURLObject aObj( aPathSeq[0] );
+ m_pEdFilepath->SetText( aObj.PathToFileName() );
}
return 0;
diff --git a/cui/source/options/personalization.cxx b/cui/source/options/personalization.cxx
index 14e071f2dd8e..f1ba9801aac9 100644
--- a/cui/source/options/personalization.cxx
+++ b/cui/source/options/personalization.cxx
@@ -24,7 +24,7 @@
#include <com/sun/star/ucb/SimpleFileAccess.hpp>
#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
-#include <com/sun/star/ui/dialogs/XFilePicker.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>
@@ -209,13 +209,9 @@ void SvxPersonalizationTabPage::Reset( const SfxItemSet & )
IMPL_LINK( SvxPersonalizationTabPage, SelectBackground, PushButton*, /*pButton*/ )
{
- uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
- if ( !xFactory.is() )
- return 0;
+ uno::Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
- uno::Reference< ui::dialogs::XFilePicker > xFilePicker( xFactory->createInstance( "com.sun.star.ui.dialogs.FilePicker" ), uno::UNO_QUERY );
- if ( !xFilePicker.is() )
- return 0;
+ uno::Reference< ui::dialogs::XFilePicker3 > xFilePicker = ui::dialogs::FilePicker::createDefault(xContext);
xFilePicker->setMultiSelectionMode( false );
@@ -223,9 +219,7 @@ IMPL_LINK( SvxPersonalizationTabPage, SelectBackground, PushButton*, /*pButton*/
if ( xController.is() )
xController->setValue( ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, 0, uno::makeAny( sal_True ) );
- uno::Reference< ui::dialogs::XFilterManager > xFilterMgr( xFilePicker, uno::UNO_QUERY );
- if ( xFilterMgr.is() )
- xFilterMgr->appendFilter( "Background images (*.jpg;*.png)", "*.jpg;*.png" ); // TODO localize
+ xFilePicker->appendFilter( "Background images (*.jpg;*.png)", "*.jpg;*.png" ); // TODO localize
while ( xFilePicker->execute() == ui::dialogs::ExecutableDialogResults::OK )
{