LCOV - code coverage report
Current view: top level - ucb/source/ucp/cmis - cmis_provider.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 54 0.0 %
Date: 2014-11-03 Functions: 0 21 0.0 %
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             : 
      10             : #include <stdio.h>
      11             : 
      12             : #include <comphelper/processfactory.hxx>
      13             : #include <ucbhelper/contentidentifier.hxx>
      14             : #include <ucbhelper/contenthelper.hxx>
      15             : #include <com/sun/star/ucb/ContentCreationException.hpp>
      16             : 
      17             : #include "cmis_content.hxx"
      18             : #include "cmis_provider.hxx"
      19             : #include "cmis_repo_content.hxx"
      20             : 
      21             : using namespace com::sun::star;
      22             : 
      23             : namespace cmis
      24             : {
      25             : uno::Reference< com::sun::star::ucb::XContent > SAL_CALL
      26           0 : ContentProvider::queryContent(
      27             :             const uno::Reference<
      28             :                     com::sun::star::ucb::XContentIdentifier >& Identifier )
      29             :     throw( com::sun::star::ucb::IllegalIdentifierException,
      30             :            uno::RuntimeException, std::exception )
      31             : {
      32           0 :     osl::MutexGuard aGuard( m_aMutex );
      33             : 
      34             :     // Check, if a content with given id already exists...
      35           0 :     uno::Reference< ucb::XContent > xContent = queryExistingContent( Identifier ).get();
      36           0 :     if ( xContent.is() )
      37           0 :         return xContent;
      38             : 
      39             :     try
      40             :     {
      41           0 :         URL aUrl( Identifier->getContentIdentifier( ) );
      42           0 :         if ( aUrl.getRepositoryId( ).isEmpty( ) )
      43             :         {
      44           0 :             xContent = new RepoContent( m_xContext, this, Identifier );
      45           0 :             registerNewContent( xContent );
      46             :         }
      47             :         else
      48             :         {
      49           0 :             xContent = new Content( m_xContext, this, Identifier );
      50           0 :             registerNewContent( xContent );
      51           0 :         }
      52             :     }
      53           0 :     catch ( com::sun::star::ucb::ContentCreationException const & )
      54             :     {
      55           0 :         throw com::sun::star::ucb::IllegalIdentifierException();
      56             :     }
      57             : 
      58           0 :     if ( !xContent->getIdentifier().is() )
      59           0 :         throw com::sun::star::ucb::IllegalIdentifierException();
      60             : 
      61           0 :     return xContent;
      62             : }
      63             : 
      64           0 : libcmis::Session* ContentProvider::getSession( const OUString& sBindingUrl )
      65             : {
      66           0 :     libcmis::Session* pSession = NULL;
      67           0 :     std::map< OUString, libcmis::Session* >::iterator it = m_aSessionCache.find( sBindingUrl );
      68           0 :     if ( it != m_aSessionCache.end( ) )
      69             :     {
      70           0 :         pSession = it->second;
      71             :     }
      72           0 :     return pSession;
      73             : }
      74             : 
      75           0 : void ContentProvider::registerSession( const OUString& sBindingUrl, libcmis::Session* pSession )
      76             : {
      77           0 :     m_aSessionCache.insert( std::pair< OUString, libcmis::Session* >( sBindingUrl, pSession ) );
      78           0 : }
      79             : 
      80           0 : ContentProvider::ContentProvider(
      81             :     const uno::Reference< uno::XComponentContext >& rxContext )
      82           0 : : ::ucbhelper::ContentProviderImplHelper( rxContext )
      83             : {
      84           0 : }
      85             : 
      86           0 : ContentProvider::~ContentProvider()
      87             : {
      88           0 : }
      89             : 
      90             : //XInterface
      91           0 : void SAL_CALL ContentProvider::acquire()
      92             :     throw()
      93             : {
      94           0 :     OWeakObject::acquire();
      95           0 : }
      96             : 
      97           0 : void SAL_CALL ContentProvider::release()
      98             :     throw()
      99             : {
     100           0 :     OWeakObject::release();
     101           0 : }
     102             : 
     103           0 : css::uno::Any SAL_CALL ContentProvider::queryInterface( const css::uno::Type & rType )
     104             :     throw( css::uno::RuntimeException, std::exception )
     105             : {
     106             :     css::uno::Any aRet = cppu::queryInterface( rType,
     107             :                                                (static_cast< lang::XTypeProvider* >(this)),
     108             :                                                (static_cast< lang::XServiceInfo* >(this)),
     109             :                                                (static_cast< css::ucb::XContentProvider* >(this))
     110           0 :                                                );
     111           0 :     return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
     112             : }
     113             : 
     114           0 : XTYPEPROVIDER_IMPL_3( ContentProvider,
     115             :                       lang::XTypeProvider,
     116             :                       lang::XServiceInfo,
     117             :                       com::sun::star::ucb::XContentProvider );
     118             : 
     119           0 : XSERVICEINFO_IMPL_1_CTX( ContentProvider,
     120             :                      OUString("com.sun.star.comp.CmisContentProvider"),
     121             :                      OUString("com.sun.star.ucb.CmisContentProvider") );
     122             : 
     123           0 : ONE_INSTANCE_SERVICE_FACTORY_IMPL( ContentProvider );
     124             : 
     125             : }
     126             : 
     127           0 : extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL ucpcmis1_component_getFactory( const sal_Char *pImplName,
     128             :     void *pServiceManager, void * )
     129             : {
     130           0 :     void * pRet = 0;
     131             : 
     132             :     uno::Reference< lang::XMultiServiceFactory > xSMgr
     133           0 :         (reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ) );
     134           0 :     uno::Reference< lang::XSingleServiceFactory > xFactory;
     135             : 
     136           0 :     if ( ::cmis::ContentProvider::getImplementationName_Static().equalsAscii( pImplName ) )
     137           0 :         xFactory = ::cmis::ContentProvider::createServiceFactory( xSMgr );
     138             : 
     139           0 :     if ( xFactory.is() )
     140             :     {
     141           0 :         xFactory->acquire();
     142           0 :         pRet = xFactory.get();
     143             :     }
     144             : 
     145           0 :     return pRet;
     146           0 : }
     147             : 
     148             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10