LCOV - code coverage report
Current view: top level - vcl/unx/gtk/fpicker - SalGtkFolderPicker.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 55 0.0 %
Date: 2012-08-25 Functions: 0 10 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                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifdef AIX
      30                 :            : #define _LINUX_SOURCE_COMPAT
      31                 :            : #include <sys/timer.h>
      32                 :            : #undef _LINUX_SOURCE_COMPAT
      33                 :            : #endif
      34                 :            : 
      35                 :            : #include <com/sun/star/lang/XMultiComponentFactory.hpp>
      36                 :            : #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
      37                 :            : #include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
      38                 :            : #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
      39                 :            : #include <osl/diagnose.h>
      40                 :            : #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
      41                 :            : #include <com/sun/star/uno/Any.hxx>
      42                 :            : #include <osl/mutex.hxx>
      43                 :            : #include <vcl/svapp.hxx>
      44                 :            : #include "unx/gtk/gtkinst.hxx"
      45                 :            : #include "gtk/fpicker/SalGtkFolderPicker.hxx"
      46                 :            : 
      47                 :            : #include <string.h>
      48                 :            : 
      49                 :            : using namespace ::rtl;
      50                 :            : using namespace ::com::sun::star;
      51                 :            : using namespace ::com::sun::star::ui::dialogs;
      52                 :            : using namespace ::com::sun::star::lang;
      53                 :            : using namespace ::com::sun::star::uno;
      54                 :            : 
      55                 :            : //-----------------------------------------------------------------------------------------
      56                 :            : // constructor
      57                 :            : //-----------------------------------------------------------------------------------------
      58                 :          0 : SalGtkFolderPicker::SalGtkFolderPicker( const uno::Reference< uno::XComponentContext >& xContext ) :
      59                 :          0 :     SalGtkPicker( xContext )
      60                 :            : {
      61                 :            :     m_pDialog = gtk_file_chooser_dialog_new(
      62                 :            :         OUStringToOString( getResString( FOLDERPICKER_TITLE ), RTL_TEXTENCODING_UTF8 ).getStr(),
      63                 :            :         NULL, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
      64                 :          0 :         GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, (char *)NULL );
      65                 :            : 
      66                 :          0 :     gtk_dialog_set_default_response( GTK_DIALOG (m_pDialog), GTK_RESPONSE_ACCEPT );
      67                 :          0 :     gtk_file_chooser_set_local_only( GTK_FILE_CHOOSER( m_pDialog ), sal_False );
      68                 :          0 :     gtk_file_chooser_set_select_multiple( GTK_FILE_CHOOSER( m_pDialog ), sal_False );
      69                 :          0 : }
      70                 :            : 
      71                 :            : // -------------------------------------------------
      72                 :            : // XEventListener
      73                 :            : // -------------------------------------------------
      74                 :            : 
      75                 :          0 : void SAL_CALL SalGtkFolderPicker::disposing( const lang::EventObject& )
      76                 :            :     throw( uno::RuntimeException )
      77                 :            : {
      78                 :          0 : }
      79                 :            : 
      80                 :          0 : void SAL_CALL SalGtkFolderPicker::setDisplayDirectory( const rtl::OUString& aDirectory )
      81                 :            :     throw( lang::IllegalArgumentException, uno::RuntimeException )
      82                 :            : {
      83                 :          0 :     SolarMutexGuard g;
      84                 :            : 
      85                 :            :     OSL_ASSERT( m_pDialog != NULL );
      86                 :            : 
      87                 :          0 :     OString aTxt = unicodetouri( aDirectory );
      88                 :            : 
      89                 :          0 :     if( !aTxt.isEmpty() && aTxt.lastIndexOf('/') == aTxt.getLength() - 1 )
      90                 :          0 :         aTxt = aTxt.copy( 0, aTxt.getLength() - 1 );
      91                 :            : 
      92                 :            :     OSL_TRACE( "setting path to %s", aTxt.getStr() );
      93                 :            : 
      94                 :          0 :     gtk_file_chooser_set_current_folder_uri( GTK_FILE_CHOOSER( m_pDialog ),
      95                 :          0 :         aTxt.getStr() );
      96                 :          0 : }
      97                 :            : 
      98                 :          0 : rtl::OUString SAL_CALL SalGtkFolderPicker::getDisplayDirectory() throw( uno::RuntimeException )
      99                 :            : {
     100                 :          0 :     SolarMutexGuard g;
     101                 :            : 
     102                 :            :     OSL_ASSERT( m_pDialog != NULL );
     103                 :            : 
     104                 :            :     gchar* pCurrentFolder =
     105                 :          0 :         gtk_file_chooser_get_current_folder_uri( GTK_FILE_CHOOSER( m_pDialog ) );
     106                 :          0 :     ::rtl::OUString aCurrentFolderName = uritounicode(pCurrentFolder);
     107                 :          0 :     g_free( pCurrentFolder );
     108                 :            : 
     109                 :          0 :     return aCurrentFolderName;
     110                 :            : }
     111                 :            : 
     112                 :          0 : rtl::OUString SAL_CALL SalGtkFolderPicker::getDirectory() throw( uno::RuntimeException )
     113                 :            : {
     114                 :          0 :     return getDisplayDirectory();
     115                 :            : }
     116                 :            : 
     117                 :          0 : void SAL_CALL SalGtkFolderPicker::setDescription( const rtl::OUString& rDescription )
     118                 :            :     throw( uno::RuntimeException )
     119                 :            : {
     120                 :          0 :     ::rtl::OString aDescription = OUStringToOString( rDescription, RTL_TEXTENCODING_UTF8 );
     121                 :          0 : }
     122                 :            : 
     123                 :            : //-----------------------------------------------------------------------------------------
     124                 :            : // XExecutableDialog functions
     125                 :            : //-----------------------------------------------------------------------------------------
     126                 :            : 
     127                 :          0 : void SAL_CALL SalGtkFolderPicker::setTitle( const rtl::OUString& aTitle ) throw( uno::RuntimeException )
     128                 :            : {
     129                 :          0 :     SolarMutexGuard g;
     130                 :            : 
     131                 :            :     OSL_ASSERT( m_pDialog != NULL );
     132                 :            : 
     133                 :          0 :     ::rtl::OString aWindowTitle = OUStringToOString( aTitle, RTL_TEXTENCODING_UTF8 );
     134                 :            : 
     135                 :          0 :     gtk_window_set_title( GTK_WINDOW( m_pDialog ), aWindowTitle.getStr() );
     136                 :          0 : }
     137                 :            : 
     138                 :          0 : sal_Int16 SAL_CALL SalGtkFolderPicker::execute() throw( uno::RuntimeException )
     139                 :            : {
     140                 :          0 :     SolarMutexGuard g;
     141                 :            : 
     142                 :            :     OSL_TRACE( "1: HERE WE ARE");
     143                 :            :     OSL_ASSERT( m_pDialog != NULL );
     144                 :            : 
     145                 :          0 :     sal_Int16 retVal = 0;
     146                 :            : 
     147                 :            :     uno::Reference< awt::XExtendedToolkit > xToolkit(
     148                 :            :         createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.Toolkit"))),
     149                 :          0 :         uno::UNO_QUERY);
     150                 :            : 
     151                 :            :     uno::Reference< frame::XDesktop > xDesktop(
     152                 :            :         createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")) ),
     153                 :          0 :         uno::UNO_QUERY);
     154                 :            : 
     155                 :          0 :     RunDialog* pRunDialog = new RunDialog(m_pDialog, xToolkit, xDesktop);
     156                 :          0 :     uno::Reference < awt::XTopWindowListener > xLifeCycle(pRunDialog);
     157                 :          0 :     gint nStatus = pRunDialog->run();
     158                 :          0 :     switch( nStatus )
     159                 :            :     {
     160                 :            :         case GTK_RESPONSE_ACCEPT:
     161                 :          0 :             retVal = ExecutableDialogResults::OK;
     162                 :          0 :             break;
     163                 :            :         case GTK_RESPONSE_CANCEL:
     164                 :          0 :             retVal = ExecutableDialogResults::CANCEL;
     165                 :          0 :             break;
     166                 :            :         default:
     167                 :          0 :             retVal = 0;
     168                 :          0 :             break;
     169                 :            :     }
     170                 :            : 
     171                 :          0 :     return retVal;
     172                 :            : }
     173                 :            : 
     174                 :            : //------------------------------------------------------------------------------------
     175                 :            : // XCancellable
     176                 :            : //------------------------------------------------------------------------------------
     177                 :            : 
     178                 :          0 : void SAL_CALL SalGtkFolderPicker::cancel() throw( uno::RuntimeException )
     179                 :            : {
     180                 :          0 :     SolarMutexGuard g;
     181                 :            : 
     182                 :          0 :     OSL_ASSERT( m_pDialog != NULL );
     183                 :            : 
     184                 :            :     // TODO m_pImpl->cancel();
     185                 :          0 : }
     186                 :            : 
     187                 :            : uno::Reference< ui::dialogs::XFolderPicker >
     188                 :          0 : GtkInstance::createFolderPicker( const uno::Reference< uno::XComponentContext > &xMSF )
     189                 :            : {
     190                 :            :     return uno::Reference< ui::dialogs::XFolderPicker >(
     191                 :          0 :                 new SalGtkFolderPicker( xMSF ) );
     192                 :            : }
     193                 :            : 
     194                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10