LCOV - code coverage report
Current view: top level - fpicker/source/office - OfficeFolderPicker.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 82 0.0 %
Date: 2012-08-25 Functions: 0 27 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

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

Generated by: LCOV version 1.10