LCOV - code coverage report
Current view: top level - ucbhelper/source/provider - contentidentifier.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 22 38 57.9 %
Date: 2015-06-13 12:38:46 Functions: 8 12 66.7 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11