LCOV - code coverage report
Current view: top level - ucb/source/ucp/gio - gio_provider.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 33 38 86.8 %
Date: 2014-11-03 Functions: 12 17 70.6 %
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             : #include <ucbhelper/contentidentifier.hxx>
      21             : #include <ucbhelper/contenthelper.hxx>
      22             : #include <com/sun/star/ucb/ContentCreationException.hpp>
      23             : #include "gio_provider.hxx"
      24             : #include "gio_content.hxx"
      25             : 
      26             : #include <stdio.h>
      27             : 
      28             : using namespace com::sun::star;
      29             : 
      30             : namespace gio
      31             : {
      32             : uno::Reference< com::sun::star::ucb::XContent > SAL_CALL
      33        7346 : ContentProvider::queryContent(
      34             :             const uno::Reference<
      35             :                     com::sun::star::ucb::XContentIdentifier >& Identifier )
      36             :     throw( com::sun::star::ucb::IllegalIdentifierException,
      37             :            uno::RuntimeException, std::exception )
      38             : {
      39             : #if OSL_DEBUG_LEVEL > 1
      40             :     fprintf(stderr, "QueryContent: '%s'",
      41             :        OUStringToOString
      42             :        (Identifier->getContentIdentifier(), RTL_TEXTENCODING_UTF8).getStr());
      43             : #endif
      44             : 
      45        7346 :     osl::MutexGuard aGuard( m_aMutex );
      46             : 
      47             :     // Check, if a content with given id already exists...
      48        7346 :     uno::Reference< ucb::XContent > xContent = queryExistingContent( Identifier ).get();
      49        7346 :     if ( xContent.is() )
      50           0 :         return xContent;
      51             : 
      52             :     try
      53             :     {
      54        7346 :         xContent = new ::gio::Content(m_xContext, this, Identifier);
      55             :     }
      56           0 :     catch ( com::sun::star::ucb::ContentCreationException const & )
      57             :     {
      58           0 :         throw com::sun::star::ucb::IllegalIdentifierException();
      59             :     }
      60             : 
      61        7346 :     if ( !xContent->getIdentifier().is() )
      62           0 :         throw com::sun::star::ucb::IllegalIdentifierException();
      63             : 
      64        7346 :     return xContent;
      65             : }
      66             : 
      67          54 : ContentProvider::ContentProvider(
      68             :     const uno::Reference< uno::XComponentContext >& rxContext )
      69          54 : : ::ucbhelper::ContentProviderImplHelper( rxContext )
      70             : {
      71          54 : }
      72             : 
      73         108 : ContentProvider::~ContentProvider()
      74             : {
      75         108 : }
      76             : 
      77             : // XInterface
      78       89893 : void SAL_CALL ContentProvider::acquire()
      79             :     throw()
      80             : {
      81       89893 :     OWeakObject::acquire();
      82       89893 : }
      83             : 
      84       89893 : void SAL_CALL ContentProvider::release()
      85             :     throw()
      86             : {
      87       89893 :     OWeakObject::release();
      88       89893 : }
      89             : 
      90        7610 : css::uno::Any SAL_CALL ContentProvider::queryInterface( const css::uno::Type & rType )
      91             :     throw( css::uno::RuntimeException, std::exception )
      92             : {
      93             :     css::uno::Any aRet = cppu::queryInterface( rType,
      94             :                                                (static_cast< lang::XTypeProvider* >(this)),
      95             :                                                (static_cast< lang::XServiceInfo* >(this)),
      96             :                                                (static_cast< css::ucb::XContentProvider* >(this))
      97        7610 :                                                );
      98        7610 :     return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
      99             : }
     100             : 
     101           0 : XTYPEPROVIDER_IMPL_3( ContentProvider,
     102             :                       lang::XTypeProvider,
     103             :                       lang::XServiceInfo,
     104             :                       com::sun::star::ucb::XContentProvider );
     105             : 
     106         216 : XSERVICEINFO_IMPL_1_CTX( ContentProvider,
     107             :                      OUString( "com.sun.star.comp.GIOContentProvider" ),
     108             :                      OUString( "com.sun.star.ucb.GIOContentProvider" ) );
     109             : 
     110          54 : ONE_INSTANCE_SERVICE_FACTORY_IMPL( ContentProvider );
     111             : 
     112             : }
     113             : 
     114          54 : extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL ucpgio1_component_getFactory( const sal_Char *pImplName,
     115             :     void *pServiceManager, void * )
     116             : {
     117          54 :     void * pRet = 0;
     118             : 
     119             :     uno::Reference< lang::XMultiServiceFactory > xSMgr
     120          54 :         (reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ) );
     121         108 :     uno::Reference< lang::XSingleServiceFactory > xFactory;
     122             : #if !GLIB_CHECK_VERSION(2,36,0)
     123             :     g_type_init();
     124             : #endif
     125          54 :     if ( ::gio::ContentProvider::getImplementationName_Static().equalsAscii( pImplName ) )
     126          54 :         xFactory = ::gio::ContentProvider::createServiceFactory( xSMgr );
     127             : 
     128          54 :     if ( xFactory.is() )
     129             :     {
     130          54 :         xFactory->acquire();
     131          54 :         pRet = xFactory.get();
     132             :     }
     133             : 
     134         108 :     return pRet;
     135             : }
     136             : 
     137             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10