LCOV - code coverage report
Current view: top level - libreoffice/svtools/source/control - filectrl2.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 27 0.0 %
Date: 2012-12-27 Functions: 0 1 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : // this file contains code from filectrl.cxx which needs to be compiled with enabled exception hanling
      22             : #include <svtools/filectrl.hxx>
      23             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      24             : #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
      25             : #include <comphelper/processfactory.hxx>
      26             : #include <tools/urlobj.hxx>
      27             : #include <osl/file.h>
      28             : #include <vcl/stdtext.hxx>
      29             : 
      30             : using namespace ::com::sun::star::uno;
      31             : using namespace ::com::sun::star::lang;
      32             : using namespace ::com::sun::star::ui;
      33             : 
      34           0 : void FileControl::ImplBrowseFile( )
      35             : {
      36             :     try
      37             :     {
      38           0 :         XubString aNewText;
      39             : 
      40           0 :         const ::rtl::OUString sServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ));
      41             : 
      42           0 :         Reference< XMultiServiceFactory > xMSF = comphelper::getProcessServiceFactory();
      43           0 :         Reference < dialogs::XFilePicker > xFilePicker( xMSF->createInstance( sServiceName ), UNO_QUERY );
      44           0 :         if ( xFilePicker.is() )
      45             :         {
      46             :             // transform the system notation text into a file URL
      47           0 :             ::rtl::OUString sSystemNotation = GetText(), sFileURL;
      48           0 :             oslFileError nError = osl_getFileURLFromSystemPath( sSystemNotation.pData, &sFileURL.pData );
      49           0 :             if ( nError == osl_File_E_INVAL )
      50           0 :                 sFileURL = GetText();   // #97709# Maybe URL is already a file URL...
      51             : 
      52             :             //#90430# Check if URL is really a file URL
      53           0 :             ::rtl::OUString aTmp;
      54           0 :             if ( osl_getSystemPathFromFileURL( sFileURL.pData, &aTmp.pData ) == osl_File_E_None )
      55             :             {
      56             :                 // initially set this directory
      57           0 :                 xFilePicker->setDisplayDirectory( sFileURL );
      58             :             }
      59             : 
      60           0 :             if ( xFilePicker.is() && xFilePicker->execute() )
      61             :             {
      62           0 :                 Sequence < rtl::OUString > aPathSeq = xFilePicker->getFiles();
      63             : 
      64           0 :                 if ( aPathSeq.getLength() )
      65             :                 {
      66           0 :                     aNewText = aPathSeq[0];
      67           0 :                     INetURLObject aObj( aNewText );
      68           0 :                     if ( aObj.GetProtocol() == INET_PROT_FILE )
      69           0 :                         aNewText = aObj.PathToFileName();
      70           0 :                     SetText( aNewText );
      71           0 :                     maEdit.GetModifyHdl().Call( &maEdit );
      72           0 :                 }
      73           0 :             }
      74             :         }
      75             :         else
      76           0 :             ShowServiceNotAvailableError( this, sServiceName, sal_True );
      77             :     }
      78           0 :     catch( const Exception& )
      79             :     {
      80             :         OSL_FAIL( "FileControl::ImplBrowseFile: caught an exception while executing the file picker!" );
      81             :     }
      82           0 : }
      83             : 
      84             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10