LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/ucb/source/cacher - cacheddynamicresultsetstub.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 60 0.0 %
Date: 2013-07-09 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             : //--------------------------------------------------------------------------
      80           0 : XINTERFACE_COMMON_IMPL( CachedDynamicResultSetStub )
      81             : 
      82           0 : Any SAL_CALL CachedDynamicResultSetStub
      83             :     ::queryInterface( const Type&  rType )
      84             :     throw ( RuntimeException )
      85             : {
      86             :     //list all interfaces inclusive baseclasses of interfaces
      87             : 
      88           0 :     Any aRet = DynamicResultSetWrapper::queryInterface( rType );
      89           0 :     if( aRet.hasValue() )
      90           0 :         return aRet;
      91             : 
      92           0 :     aRet = cppu::queryInterface( rType,
      93             :                 static_cast< XTypeProvider* >( this )
      94             :                 , static_cast< XServiceInfo* >( this )
      95           0 :                 );
      96           0 :     return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
      97             : }
      98             : 
      99             : //--------------------------------------------------------------------------
     100             : // XTypeProvider methods.
     101             : //--------------------------------------------------------------------------
     102             : //list all interfaces exclusive baseclasses
     103           0 : XTYPEPROVIDER_IMPL_5( CachedDynamicResultSetStub
     104             :                     , XTypeProvider
     105             :                     , XServiceInfo
     106             :                     , XDynamicResultSet
     107             :                     , XDynamicResultSetListener
     108             :                     , XSourceInitialization
     109             :                     );
     110             : 
     111             : //--------------------------------------------------------------------------
     112             : // XServiceInfo methods.
     113             : //--------------------------------------------------------------------------
     114             : 
     115           0 : XSERVICEINFO_NOFACTORY_IMPL_1( CachedDynamicResultSetStub,
     116             :                         OUString( "com.sun.star.comp.ucb.CachedDynamicResultSetStub" ),
     117             :                         OUString( CACHED_DRS_STUB_SERVICE_NAME ) );
     118             : 
     119             : //--------------------------------------------------------------------------
     120             : //--------------------------------------------------------------------------
     121             : // class CachedDynamicResultSetStubFactory
     122             : //--------------------------------------------------------------------------
     123             : //--------------------------------------------------------------------------
     124             : 
     125           0 : CachedDynamicResultSetStubFactory::CachedDynamicResultSetStubFactory(
     126           0 :         const Reference< XComponentContext > & rxContext )
     127             : {
     128           0 :     m_xContext = rxContext;
     129           0 : }
     130             : 
     131           0 : CachedDynamicResultSetStubFactory::~CachedDynamicResultSetStubFactory()
     132             : {
     133           0 : }
     134             : 
     135             : //--------------------------------------------------------------------------
     136             : // CachedDynamicResultSetStubFactory XInterface methods.
     137             : //--------------------------------------------------------------------------
     138             : 
     139           0 : XINTERFACE_IMPL_3( CachedDynamicResultSetStubFactory,
     140             :                    XTypeProvider,
     141             :                    XServiceInfo,
     142             :                    XCachedDynamicResultSetStubFactory );
     143             : 
     144             : //--------------------------------------------------------------------------
     145             : // CachedDynamicResultSetStubFactory XTypeProvider methods.
     146             : //--------------------------------------------------------------------------
     147             : 
     148           0 : XTYPEPROVIDER_IMPL_3( CachedDynamicResultSetStubFactory,
     149             :                       XTypeProvider,
     150             :                          XServiceInfo,
     151             :                       XCachedDynamicResultSetStubFactory );
     152             : 
     153             : //--------------------------------------------------------------------------
     154             : // CachedDynamicResultSetStubFactory XServiceInfo methods.
     155             : //--------------------------------------------------------------------------
     156             : 
     157           0 : XSERVICEINFO_IMPL_1_CTX( CachedDynamicResultSetStubFactory,
     158             :                      OUString( "com.sun.star.comp.ucb.CachedDynamicResultSetStubFactory" ),
     159             :                      OUString( CACHED_DRS_STUB_FACTORY_NAME ) );
     160             : 
     161             : //--------------------------------------------------------------------------
     162             : // Service factory implementation.
     163             : //--------------------------------------------------------------------------
     164             : 
     165           0 : ONE_INSTANCE_SERVICE_FACTORY_IMPL( CachedDynamicResultSetStubFactory );
     166             : 
     167             : //--------------------------------------------------------------------------
     168             : // CachedDynamicResultSetStubFactory XCachedDynamicResultSetStubFactory methods.
     169             : //--------------------------------------------------------------------------
     170             : 
     171             : //virtual
     172           0 : Reference< XDynamicResultSet > SAL_CALL CachedDynamicResultSetStubFactory
     173             :     ::createCachedDynamicResultSetStub(
     174             :             const Reference< XDynamicResultSet > & Source )
     175             :             throw( RuntimeException )
     176             : {
     177           0 :     Reference< XDynamicResultSet > xRet;
     178           0 :     xRet = new CachedDynamicResultSetStub( Source, m_xContext );
     179           0 :     return xRet;
     180             : }
     181             : 
     182             : //virtual
     183           0 : void SAL_CALL CachedDynamicResultSetStubFactory
     184             :     ::connectToCache(
     185             :               const Reference< XDynamicResultSet > & Source
     186             :             , const Reference< XDynamicResultSet > & TargetCache
     187             :             , const Sequence< NumberedSortingInfo > & SortingInfo
     188             :             , const Reference< XAnyCompareFactory > & CompareFactory
     189             :             )
     190             :             throw (  ListenerAlreadySetException
     191             :             , AlreadyInitializedException
     192             :             , RuntimeException )
     193             : {
     194             :     OSL_ENSURE( Source.is(), "a Source is needed" );
     195             :     OSL_ENSURE( TargetCache.is(), "a TargetCache is needed" );
     196             : 
     197           0 :     Reference< XDynamicResultSet > xSource( Source );
     198           0 :     if( SortingInfo.getLength() &&
     199           0 :         !( xSource->getCapabilities() & ContentResultSetCapability::SORTED )
     200             :         )
     201             :     {
     202           0 :         Reference< XSortedDynamicResultSetFactory > xSortFactory;
     203             :         try
     204             :         {
     205           0 :             xSortFactory = SortedDynamicResultSetFactory::create( m_xContext );
     206             :         }
     207           0 :         catch ( Exception const & )
     208             :         {
     209             :         }
     210             : 
     211           0 :         if( xSortFactory.is() )
     212             :         {
     213             :             Reference< XDynamicResultSet > xSorted(
     214           0 :                 xSortFactory->createSortedDynamicResultSet(
     215           0 :                     Source, SortingInfo, CompareFactory ) );
     216           0 :             if( xSorted.is() )
     217           0 :                 xSource = xSorted;
     218           0 :         }
     219             :     }
     220             : 
     221             :     Reference< XDynamicResultSet > xStub(
     222           0 :         new CachedDynamicResultSetStub( xSource, m_xContext ) );
     223             : 
     224           0 :     Reference< XSourceInitialization > xTarget( TargetCache, UNO_QUERY );
     225             :     OSL_ENSURE( xTarget.is(), "Target must have interface XSourceInitialization" );
     226             : 
     227           0 :     xTarget->setSource( xStub );
     228           0 : }
     229             : 
     230             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10