summaryrefslogtreecommitdiff
path: root/svtools
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 /svtools
parent53ec703c14470cb18845fc4483ec36c13b0d744e (diff)
fdo#46808, Adapt ui::dialogs::FilePicker UNO service to new style
Change-Id: I1cafbfc53994e5d74241042dbd1d292ddbda67d5
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/control/filectrl2.cxx56
1 files changed, 24 insertions, 32 deletions
diff --git a/svtools/source/control/filectrl2.cxx b/svtools/source/control/filectrl2.cxx
index 58e079b74838..cb48f4242c41 100644
--- a/svtools/source/control/filectrl2.cxx
+++ b/svtools/source/control/filectrl2.cxx
@@ -20,8 +20,7 @@
// this file contains code from filectrl.cxx which needs to be compiled with enabled exception hanling
#include <svtools/filectrl.hxx>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
+#include <com/sun/star/ui/dialogs/FilePicker.hpp>
#include <comphelper/processfactory.hxx>
#include <tools/urlobj.hxx>
#include <osl/file.h>
@@ -37,43 +36,36 @@ void FileControl::ImplBrowseFile( )
{
XubString aNewText;
- const ::rtl::OUString sServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ));
+ Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
+ Reference < dialogs::XFilePicker3 > xFilePicker = dialogs::FilePicker::createDefault( xContext );
+ // transform the system notation text into a file URL
+ ::rtl::OUString sSystemNotation = GetText(), sFileURL;
+ oslFileError nError = osl_getFileURLFromSystemPath( sSystemNotation.pData, &sFileURL.pData );
+ if ( nError == osl_File_E_INVAL )
+ sFileURL = GetText(); // #97709# Maybe URL is already a file URL...
- Reference< XMultiServiceFactory > xMSF = comphelper::getProcessServiceFactory();
- Reference < dialogs::XFilePicker > xFilePicker( xMSF->createInstance( sServiceName ), UNO_QUERY );
- if ( xFilePicker.is() )
+ //#90430# Check if URL is really a file URL
+ ::rtl::OUString aTmp;
+ if ( osl_getSystemPathFromFileURL( sFileURL.pData, &aTmp.pData ) == osl_File_E_None )
{
- // transform the system notation text into a file URL
- ::rtl::OUString sSystemNotation = GetText(), sFileURL;
- oslFileError nError = osl_getFileURLFromSystemPath( sSystemNotation.pData, &sFileURL.pData );
- if ( nError == osl_File_E_INVAL )
- sFileURL = GetText(); // #97709# Maybe URL is already a file URL...
+ // initially set this directory
+ xFilePicker->setDisplayDirectory( sFileURL );
+ }
- //#90430# Check if URL is really a file URL
- ::rtl::OUString aTmp;
- if ( osl_getSystemPathFromFileURL( sFileURL.pData, &aTmp.pData ) == osl_File_E_None )
- {
- // initially set this directory
- xFilePicker->setDisplayDirectory( sFileURL );
- }
+ if ( xFilePicker->execute() )
+ {
+ Sequence < rtl::OUString > aPathSeq = xFilePicker->getFiles();
- if ( xFilePicker.is() && xFilePicker->execute() )
+ if ( aPathSeq.getLength() )
{
- Sequence < rtl::OUString > aPathSeq = xFilePicker->getFiles();
-
- if ( aPathSeq.getLength() )
- {
- aNewText = aPathSeq[0];
- INetURLObject aObj( aNewText );
- if ( aObj.GetProtocol() == INET_PROT_FILE )
- aNewText = aObj.PathToFileName();
- SetText( aNewText );
- maEdit.GetModifyHdl().Call( &maEdit );
- }
+ aNewText = aPathSeq[0];
+ INetURLObject aObj( aNewText );
+ if ( aObj.GetProtocol() == INET_PROT_FILE )
+ aNewText = aObj.PathToFileName();
+ SetText( aNewText );
+ maEdit.GetModifyHdl().Call( &maEdit );
}
}
- else
- ShowServiceNotAvailableError( this, sServiceName, sal_True );
}
catch( const Exception& )
{