LCOV - code coverage report
Current view: top level - fpicker/source/generic - fpicker.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 66 0.0 %
Date: 2012-08-25 Functions: 0 9 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 "sal/types.h"
      21                 :            : #include "rtl/ustring.hxx"
      22                 :            : 
      23                 :            : #include "cppuhelper/implementationentry.hxx"
      24                 :            : #include "com/sun/star/lang/XMultiComponentFactory.hpp"
      25                 :            : 
      26                 :            : #include "svtools/miscopt.hxx"
      27                 :            : #include "svl/pickerhistoryaccess.hxx"
      28                 :            : 
      29                 :            : #include "vcl/svapp.hxx"
      30                 :            : 
      31                 :            : #ifdef WNT
      32                 :            : #define GradientStyle_RECT BLA_GradientStyle_RECT
      33                 :            : #include <windows.h>
      34                 :            : #undef GradientStyle_RECT
      35                 :            : #include <odma_lib.hxx>
      36                 :            : #endif
      37                 :            : 
      38                 :            : namespace css = com::sun::star;
      39                 :            : 
      40                 :            : using css::uno::Reference;
      41                 :            : using css::uno::Sequence;
      42                 :            : using rtl::OUString;
      43                 :            : 
      44                 :            : /*
      45                 :            :  * FilePicker implementation.
      46                 :            :  */
      47                 :          0 : static OUString FilePicker_getSystemPickerServiceName()
      48                 :            : {
      49                 :            : #ifdef UNX
      50                 :          0 :     OUString aDesktopEnvironment (Application::GetDesktopEnvironment());
      51                 :          0 :     if (aDesktopEnvironment.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("tde")))
      52                 :          0 :         return OUString (RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.ui.dialogs.TDEFilePicker"));
      53                 :          0 :     else if (aDesktopEnvironment.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("kde")))
      54                 :          0 :         return OUString (RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.ui.dialogs.KDEFilePicker"));
      55                 :          0 :     else if (aDesktopEnvironment.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("kde4")))
      56                 :          0 :         return OUString (RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.ui.dialogs.KDE4FilePicker"));
      57                 :          0 :     else if (aDesktopEnvironment.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("macosx")))
      58                 :          0 :         return OUString (RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.ui.dialogs.AquaFilePicker"));
      59                 :            :     else
      60                 :          0 :         return OUString (RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.ui.dialogs.SystemFilePicker"));
      61                 :            : #endif
      62                 :            : #ifdef WNT
      63                 :            :     if (SvtMiscOptions().TryODMADialog() && ::odma::DMSsAvailable()) {
      64                 :            :         return OUString (RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.ui.dialogs.ODMAFilePicker"));
      65                 :            :     }
      66                 :            :     return OUString (RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.ui.dialogs.Win32FilePicker"));
      67                 :            : #endif
      68                 :            : }
      69                 :            : 
      70                 :          0 : static Reference< css::uno::XInterface > FilePicker_createInstance (
      71                 :            :     Reference< css::uno::XComponentContext > const & rxContext)
      72                 :            : {
      73                 :          0 :     Reference< css::uno::XInterface > xResult;
      74                 :            : 
      75                 :          0 :     if (!rxContext.is())
      76                 :            :         return xResult;
      77                 :            : 
      78                 :          0 :     Reference< css::lang::XMultiComponentFactory > xFactory (rxContext->getServiceManager());
      79                 :          0 :     if (xFactory.is() && SvtMiscOptions().UseSystemFileDialog())
      80                 :            :     {
      81                 :          0 :         xResult = Reference< css::uno::XInterface >( Application::createFilePicker( rxContext ) );
      82                 :            : 
      83                 :          0 :         if (!xResult.is())
      84                 :            :         {
      85                 :            :             try
      86                 :            :             {
      87                 :          0 :                 xResult = xFactory->createInstanceWithContext (
      88                 :            :                         FilePicker_getSystemPickerServiceName(),
      89                 :          0 :                         rxContext);
      90                 :            :             }
      91                 :          0 :             catch (css::uno::Exception const &)
      92                 :            :             {
      93                 :            :                 // Handled below (see @ fallback).
      94                 :            :             }
      95                 :            :         }
      96                 :            :     }
      97                 :            : 
      98                 :            : 
      99                 :          0 :     if (!xResult.is() && xFactory.is())
     100                 :            :     {
     101                 :            :         // Always fall back to OfficeFilePicker.
     102                 :          0 :         xResult = xFactory->createInstanceWithContext (
     103                 :            :                 OUString (RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.OfficeFilePicker")),
     104                 :          0 :                 rxContext);
     105                 :            :     }
     106                 :          0 :     if (xResult.is())
     107                 :            :     {
     108                 :            :         // Add to FilePicker history.
     109                 :          0 :         svt::addFilePicker (xResult);
     110                 :            :     }
     111                 :          0 :     return xResult;
     112                 :            : }
     113                 :            : 
     114                 :          0 : static OUString FilePicker_getImplementationName()
     115                 :            : {
     116                 :          0 :     return OUString (RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.comp.fpicker.FilePicker"));
     117                 :            : }
     118                 :            : 
     119                 :          0 : static Sequence< OUString > FilePicker_getSupportedServiceNames()
     120                 :            : {
     121                 :          0 :     Sequence< OUString > aServiceNames(1);
     122                 :            :     aServiceNames.getArray()[0] =
     123                 :          0 :         OUString (RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker"));
     124                 :          0 :     return aServiceNames;
     125                 :            : }
     126                 :            : 
     127                 :            : /*
     128                 :            :  * FolderPicker implementation.
     129                 :            :  */
     130                 :          0 : static OUString FolderPicker_getSystemPickerServiceName()
     131                 :            : {
     132                 :          0 :     OUString aDesktopEnvironment (Application::GetDesktopEnvironment());
     133                 :            : #ifdef UNX
     134                 :          0 :     if (aDesktopEnvironment.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("tde")))
     135                 :          0 :         return OUString (RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.ui.dialogs.TDEFolderPicker"));
     136                 :          0 :     else if (aDesktopEnvironment.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("kde")))
     137                 :          0 :         return OUString (RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.ui.dialogs.KDEFolderPicker"));
     138                 :          0 :     else if (aDesktopEnvironment.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("macosx")))
     139                 :          0 :         return OUString (RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.ui.dialogs.AquaFolderPicker"));
     140                 :            : #endif
     141                 :            : #ifdef WNT
     142                 :            :     if (SvtMiscOptions().TryODMADialog() && ::odma::DMSsAvailable()) {
     143                 :            :         return OUString (RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.ui.dialogs.ODMAFolderPicker"));
     144                 :            :     }
     145                 :            : #endif
     146                 :          0 :     return OUString (RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.ui.dialogs.SystemFolderPicker"));
     147                 :            : }
     148                 :            : 
     149                 :          0 : static Reference< css::uno::XInterface > FolderPicker_createInstance (
     150                 :            :     Reference< css::uno::XComponentContext > const & rxContext)
     151                 :            : {
     152                 :          0 :     Reference< css::uno::XInterface > xResult;
     153                 :            : 
     154                 :          0 :     if (!rxContext.is())
     155                 :            :         return xResult;
     156                 :            : 
     157                 :          0 :     Reference< css::lang::XMultiComponentFactory > xFactory (rxContext->getServiceManager());
     158                 :          0 :     if (xFactory.is() && SvtMiscOptions().UseSystemFileDialog())
     159                 :            :     {
     160                 :          0 :         xResult = Reference< css::uno::XInterface >( Application::createFolderPicker( rxContext ) );
     161                 :          0 :         if (!xResult.is())
     162                 :            :         {
     163                 :            :             try
     164                 :            :             {
     165                 :          0 :                 xResult = xFactory->createInstanceWithContext (
     166                 :            :                                 FolderPicker_getSystemPickerServiceName(),
     167                 :          0 :                                 rxContext);
     168                 :            :             }
     169                 :          0 :             catch (css::uno::Exception const &)
     170                 :            :             {
     171                 :            :                 // Handled below (see @ fallback).
     172                 :            :             }
     173                 :            :         }
     174                 :            :     }
     175                 :          0 :     if (!xResult.is() && xFactory.is() )
     176                 :            :     {
     177                 :            :         // Always fall back to OfficeFolderPicker.
     178                 :          0 :         xResult = xFactory->createInstanceWithContext (
     179                 :            :                 OUString (RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.OfficeFolderPicker")),
     180                 :          0 :                 rxContext);
     181                 :            :     }
     182                 :          0 :     if (xResult.is())
     183                 :            :     {
     184                 :            :         // Add to FolderPicker history.
     185                 :          0 :         svt::addFolderPicker (xResult);
     186                 :            :     }
     187                 :          0 :     return xResult;
     188                 :            : }
     189                 :            : 
     190                 :          0 : static OUString FolderPicker_getImplementationName()
     191                 :            : {
     192                 :          0 :     return OUString (RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.comp.fpicker.FolderPicker"));
     193                 :            : }
     194                 :            : 
     195                 :          0 : static Sequence< OUString > FolderPicker_getSupportedServiceNames()
     196                 :            : {
     197                 :          0 :     Sequence< OUString > aServiceNames(1);
     198                 :            :     aServiceNames.getArray()[0] =
     199                 :          0 :         OUString (RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FolderPicker"));
     200                 :          0 :     return aServiceNames;
     201                 :            : }
     202                 :            : 
     203                 :            : /*
     204                 :            :  * Implementation entries.
     205                 :            :  */
     206                 :            : static cppu::ImplementationEntry g_entries[] =
     207                 :            : {
     208                 :            :     {
     209                 :            :         FilePicker_createInstance,
     210                 :            :         FilePicker_getImplementationName,
     211                 :            :         FilePicker_getSupportedServiceNames,
     212                 :            :         cppu::createSingleComponentFactory, 0, 0
     213                 :            :     },
     214                 :            :     {
     215                 :            :         FolderPicker_createInstance,
     216                 :            :         FolderPicker_getImplementationName,
     217                 :            :         FolderPicker_getSupportedServiceNames,
     218                 :            :         cppu::createSingleComponentFactory, 0, 0
     219                 :            :     },
     220                 :            :     { 0, 0, 0, 0, 0, 0 }
     221                 :            : };
     222                 :            : 
     223                 :            : /*
     224                 :            :  * Public (exported) interface.
     225                 :            :  */
     226                 :            : extern "C"
     227                 :            : {
     228                 :          0 : SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory (
     229                 :            :     const sal_Char * pImplementationName, void * pServiceManager, void * pRegistryKey)
     230                 :            : {
     231                 :            :     return cppu::component_getFactoryHelper (
     232                 :          0 :         pImplementationName, pServiceManager, pRegistryKey, g_entries);
     233                 :            : }
     234                 :            : 
     235                 :            : } // extern "C"
     236                 :            : 
     237                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10