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

Generated by: LCOV version 1.10