LCOV - code coverage report
Current view: top level - ucb/source/cacher - cacheddynamicresultsetstub.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 73 0.0 %
Date: 2014-04-14 Functions: 0 32 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             :  * 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             : #include <cacheddynamicresultsetstub.hxx>
      22             : #include <com/sun/star/sdbc/XResultSet.hpp>
      23             : #include <cachedcontentresultsetstub.hxx>
      24             : #include <com/sun/star/ucb/ContentResultSetCapability.hpp>
      25             : #include <com/sun/star/ucb/SortedDynamicResultSetFactory.hpp>
      26             : #include <osl/diagnose.h>
      27             : #include <comphelper/processfactory.hxx>
      28             : 
      29             : using namespace com::sun::star::lang;
      30             : using namespace com::sun::star::sdbc;
      31             : using namespace com::sun::star::ucb;
      32             : using namespace com::sun::star::uno;
      33             : 
      34             : 
      35           0 : CachedDynamicResultSetStub::CachedDynamicResultSetStub(
      36             :         Reference< XDynamicResultSet > xOrigin
      37             :         , const Reference< XComponentContext > & rxContext )
      38           0 :         : DynamicResultSetWrapper( xOrigin, rxContext )
      39             : {
      40             :     OSL_ENSURE( m_xContext.is(), "need Multiservicefactory to create stub" );
      41           0 :     impl_init();
      42           0 : }
      43             : 
      44           0 : CachedDynamicResultSetStub::~CachedDynamicResultSetStub()
      45             : {
      46           0 :     impl_deinit();
      47           0 : }
      48             : 
      49             : //virtual
      50           0 : void SAL_CALL CachedDynamicResultSetStub
      51             :     ::impl_InitResultSetOne( const Reference< XResultSet >& xResultSet )
      52             : {
      53           0 :     DynamicResultSetWrapper::impl_InitResultSetOne( xResultSet );
      54             :     OSL_ENSURE( m_xSourceResultOne.is(), "need source resultset" );
      55             : 
      56             :     Reference< XResultSet > xStub(
      57           0 :         new CachedContentResultSetStub( m_xSourceResultOne ) );
      58             : 
      59           0 :     osl::Guard< osl::Mutex > aGuard( m_aMutex );
      60           0 :     m_xMyResultOne = xStub;
      61           0 : }
      62             : 
      63             : //virtual
      64           0 : void SAL_CALL CachedDynamicResultSetStub
      65             :     ::impl_InitResultSetTwo( const Reference< XResultSet >& xResultSet )
      66             : {
      67           0 :     DynamicResultSetWrapper::impl_InitResultSetTwo( xResultSet );
      68             :     OSL_ENSURE( m_xSourceResultTwo.is(), "need source resultset" );
      69             : 
      70             :     Reference< XResultSet > xStub(
      71           0 :         new CachedContentResultSetStub( m_xSourceResultTwo ) );
      72             : 
      73           0 :     osl::Guard< osl::Mutex > aGuard( m_aMutex );
      74           0 :     m_xMyResultTwo = xStub;
      75           0 : }
      76             : 
      77             : 
      78             : // XInterface methods.
      79           0 : void SAL_CALL CachedDynamicResultSetStub::acquire()
      80             :     throw()
      81             : {
      82           0 :     OWeakObject::acquire();
      83           0 : }
      84             : 
      85           0 : void SAL_CALL CachedDynamicResultSetStub::release()
      86             :     throw()
      87             : {
      88           0 :     OWeakObject::release();
      89           0 : }
      90             : 
      91           0 : Any SAL_CALL CachedDynamicResultSetStub
      92             :     ::queryInterface( const Type&  rType )
      93             :     throw ( RuntimeException, std::exception )
      94             : {
      95             :     //list all interfaces inclusive baseclasses of interfaces
      96             : 
      97           0 :     Any aRet = DynamicResultSetWrapper::queryInterface( rType );
      98           0 :     if( aRet.hasValue() )
      99           0 :         return aRet;
     100             : 
     101           0 :     aRet = cppu::queryInterface( rType,
     102             :                 static_cast< XTypeProvider* >( this )
     103             :                 , static_cast< XServiceInfo* >( this )
     104           0 :                 );
     105           0 :     return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
     106             : }
     107             : 
     108             : 
     109             : // XTypeProvider methods.
     110             : 
     111             : //list all interfaces exclusive baseclasses
     112           0 : XTYPEPROVIDER_IMPL_5( CachedDynamicResultSetStub
     113             :                     , XTypeProvider
     114             :                     , XServiceInfo
     115             :                     , XDynamicResultSet
     116             :                     , XDynamicResultSetListener
     117             :                     , XSourceInitialization
     118             :                     );
     119             : 
     120             : 
     121             : // XServiceInfo methods.
     122             : 
     123             : 
     124           0 : XSERVICEINFO_NOFACTORY_IMPL_1( CachedDynamicResultSetStub,
     125             :                         OUString( "com.sun.star.comp.ucb.CachedDynamicResultSetStub" ),
     126             :                         OUString( CACHED_DRS_STUB_SERVICE_NAME ) );
     127             : 
     128             : 
     129             : 
     130             : // class CachedDynamicResultSetStubFactory
     131             : 
     132             : 
     133             : 
     134           0 : CachedDynamicResultSetStubFactory::CachedDynamicResultSetStubFactory(
     135           0 :         const Reference< XComponentContext > & rxContext )
     136             : {
     137           0 :     m_xContext = rxContext;
     138           0 : }
     139             : 
     140           0 : CachedDynamicResultSetStubFactory::~CachedDynamicResultSetStubFactory()
     141             : {
     142           0 : }
     143             : 
     144             : 
     145             : // CachedDynamicResultSetStubFactory XInterface methods.
     146           0 : void SAL_CALL CachedDynamicResultSetStubFactory::acquire()
     147             :     throw()
     148             : {
     149           0 :     OWeakObject::acquire();
     150           0 : }
     151             : 
     152           0 : void SAL_CALL CachedDynamicResultSetStubFactory::release()
     153             :     throw()
     154             : {
     155           0 :     OWeakObject::release();
     156           0 : }
     157             : 
     158           0 : css::uno::Any SAL_CALL CachedDynamicResultSetStubFactory::queryInterface( const css::uno::Type & rType )
     159             :     throw( css::uno::RuntimeException, std::exception )
     160             : {
     161             :     css::uno::Any aRet = cppu::queryInterface( rType,
     162             :                                                (static_cast< XTypeProvider* >(this)),
     163             :                                                (static_cast< XServiceInfo* >(this)),
     164             :                                                (static_cast< XCachedDynamicResultSetStubFactory* >(this))
     165           0 :                                                );
     166           0 :     return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
     167             : }
     168             : 
     169             : // CachedDynamicResultSetStubFactory XTypeProvider methods.
     170             : 
     171             : 
     172           0 : XTYPEPROVIDER_IMPL_3( CachedDynamicResultSetStubFactory,
     173             :                       XTypeProvider,
     174             :                          XServiceInfo,
     175             :                       XCachedDynamicResultSetStubFactory );
     176             : 
     177             : 
     178             : // CachedDynamicResultSetStubFactory XServiceInfo methods.
     179             : 
     180             : 
     181           0 : XSERVICEINFO_IMPL_1_CTX( CachedDynamicResultSetStubFactory,
     182             :                      OUString( "com.sun.star.comp.ucb.CachedDynamicResultSetStubFactory" ),
     183             :                      OUString( CACHED_DRS_STUB_FACTORY_NAME ) );
     184             : 
     185             : 
     186             : // Service factory implementation.
     187             : 
     188             : 
     189           0 : ONE_INSTANCE_SERVICE_FACTORY_IMPL( CachedDynamicResultSetStubFactory );
     190             : 
     191             : 
     192             : // CachedDynamicResultSetStubFactory XCachedDynamicResultSetStubFactory methods.
     193             : 
     194             : 
     195             : //virtual
     196           0 : Reference< XDynamicResultSet > SAL_CALL CachedDynamicResultSetStubFactory
     197             :     ::createCachedDynamicResultSetStub(
     198             :             const Reference< XDynamicResultSet > & Source )
     199             :             throw( RuntimeException, std::exception )
     200             : {
     201           0 :     Reference< XDynamicResultSet > xRet;
     202           0 :     xRet = new CachedDynamicResultSetStub( Source, m_xContext );
     203           0 :     return xRet;
     204             : }
     205             : 
     206             : //virtual
     207           0 : void SAL_CALL CachedDynamicResultSetStubFactory
     208             :     ::connectToCache(
     209             :               const Reference< XDynamicResultSet > & Source
     210             :             , const Reference< XDynamicResultSet > & TargetCache
     211             :             , const Sequence< NumberedSortingInfo > & SortingInfo
     212             :             , const Reference< XAnyCompareFactory > & CompareFactory
     213             :             )
     214             :             throw (  ListenerAlreadySetException
     215             :             , AlreadyInitializedException
     216             :             , RuntimeException, std::exception )
     217             : {
     218             :     OSL_ENSURE( Source.is(), "a Source is needed" );
     219             :     OSL_ENSURE( TargetCache.is(), "a TargetCache is needed" );
     220             : 
     221           0 :     Reference< XDynamicResultSet > xSource( Source );
     222           0 :     if( SortingInfo.getLength() &&
     223           0 :         !( xSource->getCapabilities() & ContentResultSetCapability::SORTED )
     224             :         )
     225             :     {
     226           0 :         Reference< XSortedDynamicResultSetFactory > xSortFactory;
     227             :         try
     228             :         {
     229           0 :             xSortFactory = SortedDynamicResultSetFactory::create( m_xContext );
     230             :         }
     231           0 :         catch ( Exception const & )
     232             :         {
     233             :         }
     234             : 
     235           0 :         if( xSortFactory.is() )
     236             :         {
     237             :             Reference< XDynamicResultSet > xSorted(
     238           0 :                 xSortFactory->createSortedDynamicResultSet(
     239           0 :                     Source, SortingInfo, CompareFactory ) );
     240           0 :             if( xSorted.is() )
     241           0 :                 xSource = xSorted;
     242           0 :         }
     243             :     }
     244             : 
     245             :     Reference< XDynamicResultSet > xStub(
     246           0 :         new CachedDynamicResultSetStub( xSource, m_xContext ) );
     247             : 
     248           0 :     Reference< XSourceInitialization > xTarget( TargetCache, UNO_QUERY );
     249             :     OSL_ENSURE( xTarget.is(), "Target must have interface XSourceInitialization" );
     250             : 
     251           0 :     xTarget->setSource( xStub );
     252           0 : }
     253             : 
     254             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10