LCOV - code coverage report
Current view: top level - ucbhelper/source/provider - contentidentifier.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 27 49 55.1 %
Date: 2012-08-25 Functions: 9 13 69.2 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 10 66 15.2 %

           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                 :            : 
      21                 :            : /**************************************************************************
      22                 :            :                                 TODO
      23                 :            :  **************************************************************************
      24                 :            : 
      25                 :            :  *************************************************************************/
      26                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      27                 :            : #include <ucbhelper/contentidentifier.hxx>
      28                 :            : #include <cppuhelper/typeprovider.hxx>
      29                 :            : #include <osl/mutex.hxx>
      30                 :            : 
      31                 :            : using namespace com::sun::star::uno;
      32                 :            : using namespace com::sun::star::lang;
      33                 :            : using namespace com::sun::star::ucb;
      34                 :            : 
      35                 :            : using ::rtl::OUString;
      36                 :            : 
      37                 :            : namespace ucbhelper
      38                 :            : {
      39                 :            : 
      40                 :            : //=========================================================================
      41                 :            : //=========================================================================
      42                 :            : //
      43                 :            : // struct ContentIdentifier_Impl.
      44                 :            : //
      45                 :            : //=========================================================================
      46                 :            : //=========================================================================
      47                 :            : 
      48         [ +  - ]:        925 : struct ContentIdentifier_Impl
      49                 :            : {
      50                 :            :     Reference< XMultiServiceFactory > m_xSMgr;
      51                 :            :     OUString                          m_aContentId;
      52                 :            :     OUString                          m_aProviderScheme;
      53                 :            :     osl::Mutex                        m_aMutex;
      54                 :            : 
      55                 :            :     ContentIdentifier_Impl( const Reference< XMultiServiceFactory >& rSMgr,
      56                 :            :                               const OUString& rURL );
      57                 :            : };
      58                 :            : 
      59                 :            : //=========================================================================
      60                 :            : //
      61                 :            : // ContentIdentifier_Impl Implementation.
      62                 :            : //
      63                 :            : //=========================================================================
      64                 :            : 
      65                 :        925 : ContentIdentifier_Impl::ContentIdentifier_Impl(
      66                 :            :                   const Reference< XMultiServiceFactory >& rSMgr,
      67                 :            :                   const OUString& rURL )
      68         [ +  - ]:        925 : : m_xSMgr( rSMgr )
      69                 :            : {
      70                 :            :     // Normalize URL scheme ( it's case insensitive ).
      71                 :            : 
      72                 :            :     // The content provider scheme is the part before the first ':'
      73                 :            :     // within the content id.
      74                 :        925 :     sal_Int32 nPos = rURL.indexOf( ':', 0 );
      75         [ +  - ]:        925 :     if ( nPos != -1 )
      76                 :            :     {
      77                 :        925 :         OUString aScheme( rURL.copy( 0, nPos ) );
      78                 :        925 :         m_aProviderScheme = aScheme.toAsciiLowerCase();
      79                 :        925 :         m_aContentId = rURL.replaceAt( 0, nPos, aScheme );
      80                 :            :     }
      81                 :        925 : }
      82                 :            : 
      83                 :            : //=========================================================================
      84                 :            : //
      85                 :            : // ContentIdentifier Implementation.
      86                 :            : //
      87                 :            : //=========================================================================
      88                 :            : 
      89                 :        913 : ContentIdentifier::ContentIdentifier(
      90                 :            :                         const Reference< XMultiServiceFactory >& rxSMgr,
      91                 :        913 :                         const OUString& rURL )
      92                 :            : {
      93 [ +  - ][ +  - ]:        913 :     m_pImpl = new ContentIdentifier_Impl( rxSMgr, rURL );
      94                 :        913 : }
      95                 :            : 
      96                 :            : //=========================================================================
      97                 :         12 : ContentIdentifier::ContentIdentifier( const OUString& rURL )
      98                 :            : {
      99                 :            :     m_pImpl = new ContentIdentifier_Impl(
     100 [ +  - ][ +  - ]:         12 :                     Reference< XMultiServiceFactory >(), rURL );
     101                 :         12 : }
     102                 :            : 
     103                 :            : //=========================================================================
     104                 :            : // virtual
     105                 :        925 : ContentIdentifier::~ContentIdentifier()
     106                 :            : {
     107 [ +  - ][ +  - ]:        925 :     delete m_pImpl;
     108         [ -  + ]:       1850 : }
     109                 :            : 
     110                 :            : //=========================================================================
     111                 :            : //
     112                 :            : // XInterface methods.
     113                 :            : //
     114                 :            : //=========================================================================
     115                 :            : 
     116                 :            : //=========================================================================
     117                 :            : // virtual
     118                 :       2380 : void SAL_CALL ContentIdentifier::acquire() throw()
     119                 :            : {
     120                 :       2380 :     OWeakObject::acquire();
     121                 :       2380 : }
     122                 :            : 
     123                 :            : //=========================================================================
     124                 :            : // virtual
     125                 :       2380 : void SAL_CALL ContentIdentifier::release() throw()
     126                 :            : {
     127                 :       2380 :     OWeakObject::release();
     128                 :       2380 : }
     129                 :            : 
     130                 :            : //=========================================================================
     131                 :            : // virtual
     132                 :            : Any SAL_CALL
     133                 :          0 : ContentIdentifier::queryInterface( const Type & rType )
     134                 :            :     throw ( RuntimeException )
     135                 :            : {
     136                 :            :     Any aRet = cppu::queryInterface( rType,
     137                 :            :                 static_cast< XTypeProvider * >( this ),
     138         [ #  # ]:          0 :                 static_cast< XContentIdentifier * >( this ) );
     139                 :            : 
     140 [ #  # ][ #  # ]:          0 :     return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
     141                 :            : }
     142                 :            : 
     143                 :            : //=========================================================================
     144                 :            : //
     145                 :            : // XTypeProvider methods.
     146                 :            : //
     147                 :            : //=========================================================================
     148                 :            : 
     149                 :            : // virtual
     150                 :            : Sequence< sal_Int8 > SAL_CALL
     151                 :          0 : ContentIdentifier::getImplementationId()
     152                 :            :     throw( RuntimeException )
     153                 :            : {
     154                 :            :     static cppu::OImplementationId* pId = NULL;
     155         [ #  # ]:          0 :       if ( !pId )
     156                 :            :       {
     157 [ #  # ][ #  # ]:          0 :         osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
     158         [ #  # ]:          0 :           if ( !pId )
     159                 :            :           {
     160 [ #  # ][ #  # ]:          0 :               static cppu::OImplementationId id( sal_False );
     161                 :          0 :               pId = &id;
     162         [ #  # ]:          0 :           }
     163                 :            :       }
     164                 :          0 :       return (*pId).getImplementationId();
     165                 :            : }
     166                 :            : 
     167                 :            : //=========================================================================
     168                 :            : // virtual
     169                 :            : Sequence< com::sun::star::uno::Type > SAL_CALL
     170                 :          0 : ContentIdentifier::getTypes()
     171                 :            :     throw( RuntimeException )
     172                 :            : {
     173                 :            :     static cppu::OTypeCollection* pCollection = NULL;
     174         [ #  # ]:          0 :       if ( !pCollection )
     175                 :            :       {
     176 [ #  # ][ #  # ]:          0 :         osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
     177         [ #  # ]:          0 :         if ( !pCollection )
     178                 :            :         {
     179                 :            :             static cppu::OTypeCollection collection(
     180                 :            :                     getCppuType( static_cast<
     181         [ #  # ]:          0 :                         Reference < XTypeProvider > * >( 0 ) ),
     182                 :            :                     getCppuType( static_cast<
     183 [ #  # ][ #  # ]:          0 :                         Reference< XContentIdentifier > * >( 0 ) ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     184                 :          0 :             pCollection = &collection;
     185         [ #  # ]:          0 :         }
     186                 :            :     }
     187                 :          0 :     return (*pCollection).getTypes();
     188                 :            : }
     189                 :            : 
     190                 :            : //=========================================================================
     191                 :            : //
     192                 :            : // XContentIdentifier methods.
     193                 :            : //
     194                 :            : //=========================================================================
     195                 :            : 
     196                 :            : // virtual
     197                 :       2001 : OUString SAL_CALL ContentIdentifier::getContentIdentifier()
     198                 :            :     throw( RuntimeException )
     199                 :            : {
     200                 :       2001 :     return m_pImpl->m_aContentId;
     201                 :            : }
     202                 :            : 
     203                 :            : //=========================================================================
     204                 :            : // virtual
     205                 :          0 : OUString SAL_CALL ContentIdentifier::getContentProviderScheme()
     206                 :            :     throw( RuntimeException )
     207                 :            : {
     208                 :          0 :     return m_pImpl->m_aProviderScheme;
     209                 :            : }
     210                 :            : 
     211                 :            : } /* namespace ucbhelper */
     212                 :            : 
     213                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10