LCOV - code coverage report
Current view: top level - ucb/source/cacher - cacheddynamicresultsetstub.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 61 0.0 %
Date: 2012-08-25 Functions: 0 32 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <cacheddynamicresultsetstub.hxx>
      31                 :            : #include <com/sun/star/sdbc/XResultSet.hpp>
      32                 :            : #include <cachedcontentresultsetstub.hxx>
      33                 :            : #include <com/sun/star/ucb/ContentResultSetCapability.hpp>
      34                 :            : #include <com/sun/star/ucb/XSortedDynamicResultSetFactory.hpp>
      35                 :            : #include <osl/diagnose.h>
      36                 :            : 
      37                 :            : using namespace com::sun::star::lang;
      38                 :            : using namespace com::sun::star::sdbc;
      39                 :            : using namespace com::sun::star::ucb;
      40                 :            : using namespace com::sun::star::uno;
      41                 :            : 
      42                 :            : using ::rtl::OUString;
      43                 :            : 
      44                 :          0 : CachedDynamicResultSetStub::CachedDynamicResultSetStub(
      45                 :            :         Reference< XDynamicResultSet > xOrigin
      46                 :            :         , const Reference< XMultiServiceFactory > & xSMgr )
      47                 :          0 :         : DynamicResultSetWrapper( xOrigin, xSMgr )
      48                 :            : {
      49                 :            :     OSL_ENSURE( m_xSMgr.is(), "need Multiservicefactory to create stub" );
      50                 :          0 :     impl_init();
      51                 :          0 : }
      52                 :            : 
      53                 :          0 : CachedDynamicResultSetStub::~CachedDynamicResultSetStub()
      54                 :            : {
      55                 :          0 :     impl_deinit();
      56                 :          0 : }
      57                 :            : 
      58                 :            : //virtual
      59                 :          0 : void SAL_CALL CachedDynamicResultSetStub
      60                 :            :     ::impl_InitResultSetOne( const Reference< XResultSet >& xResultSet )
      61                 :            : {
      62                 :          0 :     DynamicResultSetWrapper::impl_InitResultSetOne( xResultSet );
      63                 :            :     OSL_ENSURE( m_xSourceResultOne.is(), "need source resultset" );
      64                 :            : 
      65                 :            :     Reference< XResultSet > xStub(
      66                 :          0 :         new CachedContentResultSetStub( m_xSourceResultOne ) );
      67                 :            : 
      68                 :          0 :     osl::Guard< osl::Mutex > aGuard( m_aMutex );
      69                 :          0 :     m_xMyResultOne = xStub;
      70                 :          0 : }
      71                 :            : 
      72                 :            : //virtual
      73                 :          0 : void SAL_CALL CachedDynamicResultSetStub
      74                 :            :     ::impl_InitResultSetTwo( const Reference< XResultSet >& xResultSet )
      75                 :            : {
      76                 :          0 :     DynamicResultSetWrapper::impl_InitResultSetTwo( xResultSet );
      77                 :            :     OSL_ENSURE( m_xSourceResultTwo.is(), "need source resultset" );
      78                 :            : 
      79                 :            :     Reference< XResultSet > xStub(
      80                 :          0 :         new CachedContentResultSetStub( m_xSourceResultTwo ) );
      81                 :            : 
      82                 :          0 :     osl::Guard< osl::Mutex > aGuard( m_aMutex );
      83                 :          0 :     m_xMyResultTwo = xStub;
      84                 :          0 : }
      85                 :            : 
      86                 :            : //--------------------------------------------------------------------------
      87                 :            : // XInterface methods.
      88                 :            : //--------------------------------------------------------------------------
      89                 :          0 : XINTERFACE_COMMON_IMPL( CachedDynamicResultSetStub )
      90                 :            : 
      91                 :          0 : Any SAL_CALL CachedDynamicResultSetStub
      92                 :            :     ::queryInterface( const Type&  rType )
      93                 :            :     throw ( RuntimeException )
      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                 :            :     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< XMultiServiceFactory > & rSMgr )
     136                 :            : {
     137                 :          0 :     m_xSMgr = rSMgr;
     138                 :          0 : }
     139                 :            : 
     140                 :          0 : CachedDynamicResultSetStubFactory::~CachedDynamicResultSetStubFactory()
     141                 :            : {
     142                 :          0 : }
     143                 :            : 
     144                 :            : //--------------------------------------------------------------------------
     145                 :            : // CachedDynamicResultSetStubFactory XInterface methods.
     146                 :            : //--------------------------------------------------------------------------
     147                 :            : 
     148                 :          0 : XINTERFACE_IMPL_3( CachedDynamicResultSetStubFactory,
     149                 :            :                    XTypeProvider,
     150                 :            :                    XServiceInfo,
     151                 :            :                    XCachedDynamicResultSetStubFactory );
     152                 :            : 
     153                 :            : //--------------------------------------------------------------------------
     154                 :            : // CachedDynamicResultSetStubFactory XTypeProvider methods.
     155                 :            : //--------------------------------------------------------------------------
     156                 :            : 
     157                 :          0 : XTYPEPROVIDER_IMPL_3( CachedDynamicResultSetStubFactory,
     158                 :            :                       XTypeProvider,
     159                 :            :                          XServiceInfo,
     160                 :            :                       XCachedDynamicResultSetStubFactory );
     161                 :            : 
     162                 :            : //--------------------------------------------------------------------------
     163                 :            : // CachedDynamicResultSetStubFactory XServiceInfo methods.
     164                 :            : //--------------------------------------------------------------------------
     165                 :            : 
     166                 :          0 : XSERVICEINFO_IMPL_1( CachedDynamicResultSetStubFactory,
     167                 :            :                      OUString( "com.sun.star.comp.ucb.CachedDynamicResultSetStubFactory" ),
     168                 :          0 :                      OUString( CACHED_DRS_STUB_FACTORY_NAME ) );
     169                 :            : 
     170                 :            : //--------------------------------------------------------------------------
     171                 :            : // Service factory implementation.
     172                 :            : //--------------------------------------------------------------------------
     173                 :            : 
     174                 :          0 : ONE_INSTANCE_SERVICE_FACTORY_IMPL( CachedDynamicResultSetStubFactory );
     175                 :            : 
     176                 :            : //--------------------------------------------------------------------------
     177                 :            : // CachedDynamicResultSetStubFactory XCachedDynamicResultSetStubFactory methods.
     178                 :            : //--------------------------------------------------------------------------
     179                 :            : 
     180                 :            : //virtual
     181                 :          0 : Reference< XDynamicResultSet > SAL_CALL CachedDynamicResultSetStubFactory
     182                 :            :     ::createCachedDynamicResultSetStub(
     183                 :            :             const Reference< XDynamicResultSet > & Source )
     184                 :            :             throw( RuntimeException )
     185                 :            : {
     186                 :          0 :     Reference< XDynamicResultSet > xRet;
     187                 :          0 :     xRet = new CachedDynamicResultSetStub( Source, m_xSMgr );
     188                 :          0 :     return xRet;
     189                 :            : }
     190                 :            : 
     191                 :            : //virtual
     192                 :          0 : void SAL_CALL CachedDynamicResultSetStubFactory
     193                 :            :     ::connectToCache(
     194                 :            :               const Reference< XDynamicResultSet > & Source
     195                 :            :             , const Reference< XDynamicResultSet > & TargetCache
     196                 :            :             , const Sequence< NumberedSortingInfo > & SortingInfo
     197                 :            :             , const Reference< XAnyCompareFactory > & CompareFactory
     198                 :            :             )
     199                 :            :             throw (  ListenerAlreadySetException
     200                 :            :             , AlreadyInitializedException
     201                 :            :             , RuntimeException )
     202                 :            : {
     203                 :            :     OSL_ENSURE( Source.is(), "a Source is needed" );
     204                 :            :     OSL_ENSURE( TargetCache.is(), "a TargetCache is needed" );
     205                 :            : 
     206                 :          0 :     Reference< XDynamicResultSet > xSource( Source );
     207                 :          0 :     if( SortingInfo.getLength() &&
     208                 :          0 :         !( xSource->getCapabilities() & ContentResultSetCapability::SORTED )
     209                 :            :         )
     210                 :            :     {
     211                 :          0 :         Reference< XSortedDynamicResultSetFactory > xSortFactory;
     212                 :            :         try
     213                 :            :         {
     214                 :            :             xSortFactory = Reference< XSortedDynamicResultSetFactory >(
     215                 :          0 :                 m_xSMgr->createInstance( OUString( "com.sun.star.ucb.SortedDynamicResultSetFactory" ) ),
     216                 :          0 :                 UNO_QUERY );
     217                 :            :         }
     218                 :          0 :         catch ( Exception const & )
     219                 :            :         {
     220                 :            :         }
     221                 :            : 
     222                 :          0 :         if( xSortFactory.is() )
     223                 :            :         {
     224                 :            :             Reference< XDynamicResultSet > xSorted(
     225                 :          0 :                 xSortFactory->createSortedDynamicResultSet(
     226                 :          0 :                     Source, SortingInfo, CompareFactory ) );
     227                 :          0 :             if( xSorted.is() )
     228                 :          0 :                 xSource = xSorted;
     229                 :          0 :         }
     230                 :            :     }
     231                 :            : 
     232                 :            :     Reference< XDynamicResultSet > xStub(
     233                 :          0 :         new CachedDynamicResultSetStub( xSource, m_xSMgr ) );
     234                 :            : 
     235                 :          0 :     Reference< XSourceInitialization > xTarget( TargetCache, UNO_QUERY );
     236                 :            :     OSL_ENSURE( xTarget.is(), "Target must have interface XSourceInitialization" );
     237                 :            : 
     238                 :          0 :     xTarget->setSource( xStub );
     239                 :          0 : }
     240                 :            : 
     241                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10