LCOV - code coverage report
Current view: top level - fpicker/source/office - OfficeFolderPicker.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 15 79 19.0 %
Date: 2014-11-03 Functions: 8 25 32.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             : #include "OfficeFolderPicker.hxx"
      21             : 
      22             : #include "iodlg.hxx"
      23             : 
      24             : #include <list>
      25             : #include <tools/urlobj.hxx>
      26             : #include <com/sun/star/container/XContentEnumerationAccess.hpp>
      27             : #include <com/sun/star/container/XSet.hpp>
      28             : #include <com/sun/star/uno/Any.hxx>
      29             : #include <cppuhelper/factory.hxx>
      30             : #include <cppuhelper/supportsservice.hxx>
      31             : #include <com/sun/star/beans/XPropertySet.hpp>
      32             : #include <unotools/pathoptions.hxx>
      33             : 
      34             : using namespace     ::com::sun::star::container;
      35             : using namespace     ::com::sun::star::lang;
      36             : using namespace     ::com::sun::star::uno;
      37             : using namespace     ::com::sun::star::beans;
      38             : 
      39           2 : SvtFolderPicker::SvtFolderPicker( const Reference < XMultiServiceFactory >& _rxFactory )
      40           2 :     :SvtFolderPicker_Base( _rxFactory )
      41             : {
      42           2 : }
      43             : 
      44           4 : SvtFolderPicker::~SvtFolderPicker()
      45             : {
      46           4 : }
      47             : 
      48           0 : void SAL_CALL SvtFolderPicker::setTitle( const OUString& _rTitle ) throw (RuntimeException, std::exception)
      49             : {
      50           0 :     OCommonPicker::setTitle( _rTitle );
      51           0 : }
      52             : 
      53           0 : sal_Int16 SAL_CALL SvtFolderPicker::execute(  ) throw (RuntimeException, std::exception)
      54             : {
      55           0 :     return OCommonPicker::execute();
      56             : }
      57             : 
      58           0 : void SAL_CALL SvtFolderPicker::setDialogTitle( const OUString& _rTitle) throw (RuntimeException, std::exception)
      59             : {
      60           0 :     setTitle( _rTitle );
      61           0 : }
      62             : 
      63           0 : void SAL_CALL SvtFolderPicker::startExecuteModal( const Reference< ::com::sun::star::ui::dialogs::XDialogClosedListener >& xListener ) throw (RuntimeException, std::exception)
      64             : {
      65           0 :     m_xListener = xListener;
      66           0 :     prepareDialog();
      67           0 :     prepareExecute();
      68           0 :     getDialog()->EnableAutocompletion( true );
      69           0 :     getDialog()->StartExecuteModal( LINK( this, SvtFolderPicker, DialogClosedHdl ) );
      70           0 : }
      71             : 
      72           0 : SvtFileDialog* SvtFolderPicker::implCreateDialog( vcl::Window* _pParent )
      73             : {
      74           0 :     return new SvtFileDialog( _pParent, SFXWB_PATHDIALOG );
      75             : }
      76             : 
      77           0 : sal_Int16 SvtFolderPicker::implExecutePicker( )
      78             : {
      79           0 :     prepareExecute();
      80             : 
      81             :     // now we are ready to execute the dialog
      82           0 :     getDialog()->EnableAutocompletion( false );
      83           0 :     sal_Int16 nRet = getDialog()->Execute();
      84             : 
      85           0 :     return nRet;
      86             : }
      87             : 
      88           0 : void SvtFolderPicker::prepareExecute()
      89             : {
      90             :     // set the default directory
      91           0 :     if ( !m_aDisplayDirectory.isEmpty() )
      92           0 :         getDialog()->SetPath( m_aDisplayDirectory );
      93             :     else
      94             :     {
      95             :         // Default-Standard-Dir setzen
      96           0 :         INetURLObject aStdDirObj( SvtPathOptions().GetWorkPath() );
      97           0 :         getDialog()->SetPath( aStdDirObj.GetMainURL( INetURLObject::NO_DECODE) );
      98             :     }
      99           0 : }
     100             : 
     101           0 : IMPL_LINK( SvtFolderPicker, DialogClosedHdl, Dialog*, pDlg )
     102             : {
     103           0 :     if ( m_xListener.is() )
     104             :     {
     105           0 :         sal_Int16 nRet = static_cast< sal_Int16 >( pDlg->GetResult() );
     106           0 :         ::com::sun::star::ui::dialogs::DialogClosedEvent aEvent( *this, nRet );
     107           0 :         m_xListener->dialogClosed( aEvent );
     108           0 :         m_xListener.clear();
     109             :     }
     110           0 :     return 0;
     111             :   }
     112             : 
     113           0 : void SAL_CALL SvtFolderPicker::setDisplayDirectory( const OUString& aDirectory )
     114             :     throw( IllegalArgumentException, RuntimeException, std::exception )
     115             : {
     116           0 :     m_aDisplayDirectory = aDirectory;
     117           0 : }
     118             : 
     119           0 : OUString SAL_CALL SvtFolderPicker::getDisplayDirectory() throw( RuntimeException, std::exception )
     120             : {
     121           0 :     if ( ! getDialog() )
     122           0 :         return m_aDisplayDirectory;
     123             : 
     124           0 :     std::vector<OUString> aPathList(getDialog()->GetPathList());
     125             : 
     126           0 :     if(!aPathList.empty())
     127           0 :         return aPathList[0];
     128             : 
     129           0 :     return OUString();
     130             : }
     131             : 
     132           0 : OUString SAL_CALL SvtFolderPicker::getDirectory() throw( RuntimeException, std::exception )
     133             : {
     134           0 :     if ( ! getDialog() )
     135           0 :         return m_aDisplayDirectory;
     136             : 
     137           0 :     std::vector<OUString> aPathList(getDialog()->GetPathList());
     138             : 
     139           0 :     if(!aPathList.empty())
     140           0 :         return aPathList[0];
     141             : 
     142           0 :     return OUString();
     143             : }
     144             : 
     145           0 : void SAL_CALL SvtFolderPicker::setDescription( const OUString& aDescription )
     146             :     throw( RuntimeException, std::exception )
     147             : {
     148           0 :     m_aDescription = aDescription;
     149           0 : }
     150             : 
     151           0 : void SvtFolderPicker::cancel() throw (RuntimeException, std::exception)
     152             : {
     153           0 :     OCommonPicker::cancel();
     154           0 : }
     155             : 
     156             : /* XServiceInfo */
     157           0 : OUString SAL_CALL SvtFolderPicker::getImplementationName() throw( RuntimeException, std::exception )
     158             : {
     159           0 :     return impl_getStaticImplementationName();
     160             : }
     161             : 
     162             : /* XServiceInfo */
     163           0 : sal_Bool SAL_CALL SvtFolderPicker::supportsService( const OUString& sServiceName ) throw( RuntimeException, std::exception )
     164             : {
     165           0 :     return cppu::supportsService(this, sServiceName);
     166             : }
     167             : 
     168             : /* XServiceInfo */
     169           0 : Sequence< OUString > SAL_CALL SvtFolderPicker::getSupportedServiceNames() throw( RuntimeException, std::exception )
     170             : {
     171           0 :     return impl_getStaticSupportedServiceNames();
     172             : }
     173             : 
     174             : /* Helper for XServiceInfo */
     175           2 : Sequence< OUString > SvtFolderPicker::impl_getStaticSupportedServiceNames()
     176             : {
     177           2 :     Sequence< OUString > seqServiceNames(1);
     178           2 :     seqServiceNames[0] = "com.sun.star.ui.dialogs.OfficeFolderPicker";
     179           2 :     return seqServiceNames ;
     180             : }
     181             : 
     182             : /* Helper for XServiceInfo */
     183           2 : OUString SvtFolderPicker::impl_getStaticImplementationName()
     184             : {
     185           2 :     return OUString( "com.sun.star.svtools.OfficeFolderPicker" );
     186             : }
     187             : 
     188             : /* Helper for registry */
     189           2 : Reference< XInterface > SAL_CALL SvtFolderPicker::impl_createInstance( const Reference< XComponentContext >& rxContext )
     190             :     throw( Exception )
     191             : {
     192           2 :     Reference< XMultiServiceFactory > xServiceManager (rxContext->getServiceManager(), UNO_QUERY_THROW);
     193           2 :     return Reference< XInterface >( *new SvtFolderPicker( xServiceManager ) );
     194           6 : }
     195             : 
     196             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10