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

Generated by: LCOV version 1.10