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

Generated by: LCOV version 1.11