LCOV - code coverage report
Current view: top level - ucbhelper/source/client - fileidentifierconverter.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 12 12 100.0 %
Date: 2012-08-25 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 14 24 58.3 %

           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 <ucbhelper/fileidentifierconverter.hxx>
      21                 :            : #include <com/sun/star/ucb/ContentProviderInfo.hpp>
      22                 :            : #include <com/sun/star/ucb/XContentProviderManager.hpp>
      23                 :            : #include <com/sun/star/ucb/XFileIdentifierConverter.hpp>
      24                 :            : #include <com/sun/star/uno/Reference.hxx>
      25                 :            : #include <com/sun/star/uno/Sequence.hxx>
      26                 :            : #include <osl/diagnose.h>
      27                 :            : #include <rtl/ustring.hxx>
      28                 :            : #include <sal/types.h>
      29                 :            : 
      30                 :            : using namespace com::sun::star;
      31                 :            : 
      32                 :            : namespace ucbhelper {
      33                 :            : 
      34                 :            : //============================================================================
      35                 :            : //
      36                 :            : //  getLocalFileURL
      37                 :            : //
      38                 :            : //============================================================================
      39                 :            : 
      40                 :            : rtl::OUString
      41                 :      25089 : getLocalFileURL() SAL_THROW((uno::RuntimeException))
      42                 :            : {
      43                 :            :     // If there were more file systems than just "file:///" (e.g., the obsolete
      44                 :            :     // "vnd.sun.star.wfs:///"), this code should query all relevant UCPs for
      45                 :            :     // their com.sun.star.ucb.XFileIdentifierConverter.getFileProviderLocality
      46                 :            :     // and return the most local one:
      47                 :      25089 :     return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file:///"));
      48                 :            : }
      49                 :            : 
      50                 :            : //============================================================================
      51                 :            : //
      52                 :            : //  getFileURLFromSystemPath
      53                 :            : //
      54                 :            : //============================================================================
      55                 :            : 
      56                 :            : rtl::OUString
      57                 :      13514 : getFileURLFromSystemPath(
      58                 :            :     uno::Reference< ucb::XContentProviderManager > const & rManager,
      59                 :            :     rtl::OUString const & rBaseURL,
      60                 :            :     rtl::OUString const & rSystemPath)
      61                 :            :     SAL_THROW((uno::RuntimeException))
      62                 :            : {
      63                 :            :     OSL_ASSERT(rManager.is());
      64                 :            : 
      65                 :            :     uno::Reference< ucb::XFileIdentifierConverter >
      66 [ +  - ][ +  - ]:      13514 :         xConverter(rManager->queryContentProvider(rBaseURL), uno::UNO_QUERY);
                 [ +  - ]
      67         [ +  + ]:      13514 :     if (xConverter.is())
      68 [ +  - ][ +  - ]:      13494 :         return xConverter->getFileURLFromSystemPath(rBaseURL, rSystemPath);
      69                 :            :     else
      70                 :      13514 :         return rtl::OUString();
      71                 :            : }
      72                 :            : 
      73                 :            : //============================================================================
      74                 :            : //
      75                 :            : //  getSystemPathFromFileURL
      76                 :            : //
      77                 :            : //============================================================================
      78                 :            : 
      79                 :            : rtl::OUString
      80                 :      11331 : getSystemPathFromFileURL(
      81                 :            :     uno::Reference< ucb::XContentProviderManager > const & rManager,
      82                 :            :     rtl::OUString const & rURL)
      83                 :            :     SAL_THROW((uno::RuntimeException))
      84                 :            : {
      85                 :            :     OSL_ASSERT(rManager.is());
      86                 :            : 
      87                 :            :     uno::Reference< ucb::XFileIdentifierConverter >
      88 [ +  - ][ +  - ]:      11331 :         xConverter(rManager->queryContentProvider(rURL), uno::UNO_QUERY);
                 [ +  - ]
      89         [ +  + ]:      11331 :     if (xConverter.is())
      90 [ +  - ][ +  - ]:       9719 :         return xConverter->getSystemPathFromFileURL(rURL);
      91                 :            :     else
      92                 :      11331 :         return rtl::OUString();
      93                 :            : }
      94                 :            : 
      95                 :            : }
      96                 :            : 
      97                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10