bump product version to 4.1.6.2
[LibreOffice.git] / ucb / source / cacher / cacheddynamicresultset.cxx
blob8b9f1a9a69591d8cb29d6dfdc54d6c40371b851a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <cacheddynamicresultset.hxx>
22 #include <com/sun/star/sdbc/XResultSet.hpp>
23 #include <cachedcontentresultset.hxx>
24 #include <osl/diagnose.h>
25 #include <comphelper/processfactory.hxx>
27 using namespace com::sun::star::lang;
28 using namespace com::sun::star::sdbc;
29 using namespace com::sun::star::ucb;
30 using namespace com::sun::star::uno;
33 CachedDynamicResultSet::CachedDynamicResultSet(
34 Reference< XDynamicResultSet > xOrigin
35 , const Reference< XContentIdentifierMapping > & xContentMapping
36 , const Reference< XMultiServiceFactory > & xSMgr )
37 : DynamicResultSetWrapper( xOrigin, comphelper::getComponentContext(xSMgr) )
38 , m_xContentIdentifierMapping( xContentMapping )
40 impl_init();
43 CachedDynamicResultSet::~CachedDynamicResultSet()
45 impl_deinit();
48 //virtual
49 void SAL_CALL CachedDynamicResultSet
50 ::impl_InitResultSetOne( const Reference< XResultSet >& xResultSet )
52 DynamicResultSetWrapper::impl_InitResultSetOne( xResultSet );
53 OSL_ENSURE( m_xSourceResultOne.is(), "need source resultset" );
55 Reference< XResultSet > xCache(
56 new CachedContentResultSet( m_xContext, m_xSourceResultOne, m_xContentIdentifierMapping ) );
58 osl::Guard< osl::Mutex > aGuard( m_aMutex );
59 m_xMyResultOne = xCache;
62 //virtual
63 void SAL_CALL CachedDynamicResultSet
64 ::impl_InitResultSetTwo( const Reference< XResultSet >& xResultSet )
66 DynamicResultSetWrapper::impl_InitResultSetTwo( xResultSet );
67 OSL_ENSURE( m_xSourceResultTwo.is(), "need source resultset" );
69 Reference< XResultSet > xCache(
70 new CachedContentResultSet( m_xContext, m_xSourceResultTwo, m_xContentIdentifierMapping ) );
72 osl::Guard< osl::Mutex > aGuard( m_aMutex );
73 m_xMyResultTwo = xCache;
76 //--------------------------------------------------------------------------
77 // XInterface methods.
78 //--------------------------------------------------------------------------
79 XINTERFACE_COMMON_IMPL( CachedDynamicResultSet )
81 Any SAL_CALL CachedDynamicResultSet
82 ::queryInterface( const Type& rType )
83 throw ( RuntimeException )
85 //list all interfaces inclusive baseclasses of interfaces
87 Any aRet = DynamicResultSetWrapper::queryInterface( rType );
88 if( aRet.hasValue() )
89 return aRet;
91 aRet = cppu::queryInterface( rType,
92 static_cast< XTypeProvider* >( this )
93 , static_cast< XServiceInfo* >( this )
95 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
98 //--------------------------------------------------------------------------
99 // XTypeProvider methods.
100 //--------------------------------------------------------------------------
101 //list all interfaces exclusive baseclasses
102 XTYPEPROVIDER_IMPL_4( CachedDynamicResultSet
103 , XTypeProvider
104 , XServiceInfo
105 , XDynamicResultSet
106 , XSourceInitialization
109 //--------------------------------------------------------------------------
110 // XServiceInfo methods.
111 //--------------------------------------------------------------------------
113 XSERVICEINFO_NOFACTORY_IMPL_1( CachedDynamicResultSet,
114 OUString( "com.sun.star.comp.ucb.CachedDynamicResultSet" ),
115 OUString( CACHED_DRS_SERVICE_NAME ) );
117 //--------------------------------------------------------------------------
118 // own methds. ( inherited )
119 //--------------------------------------------------------------------------
120 //virtual
121 void SAL_CALL CachedDynamicResultSet
122 ::impl_disposing( const EventObject& Source )
123 throw( RuntimeException )
125 DynamicResultSetWrapper::impl_disposing( Source );
126 m_xContentIdentifierMapping.clear();
129 //--------------------------------------------------------------------------
130 //--------------------------------------------------------------------------
131 // class CachedDynamicResultSetFactory
132 //--------------------------------------------------------------------------
133 //--------------------------------------------------------------------------
135 CachedDynamicResultSetFactory::CachedDynamicResultSetFactory(
136 const Reference< XMultiServiceFactory > & rSMgr )
138 m_xSMgr = rSMgr;
141 CachedDynamicResultSetFactory::~CachedDynamicResultSetFactory()
145 //--------------------------------------------------------------------------
146 // CachedDynamicResultSetFactory XInterface methods.
147 //--------------------------------------------------------------------------
149 XINTERFACE_IMPL_3( CachedDynamicResultSetFactory,
150 XTypeProvider,
151 XServiceInfo,
152 XCachedDynamicResultSetFactory );
154 //--------------------------------------------------------------------------
155 // CachedDynamicResultSetFactory XTypeProvider methods.
156 //--------------------------------------------------------------------------
158 XTYPEPROVIDER_IMPL_3( CachedDynamicResultSetFactory,
159 XTypeProvider,
160 XServiceInfo,
161 XCachedDynamicResultSetFactory );
163 //--------------------------------------------------------------------------
164 // CachedDynamicResultSetFactory XServiceInfo methods.
165 //--------------------------------------------------------------------------
167 XSERVICEINFO_IMPL_1( CachedDynamicResultSetFactory,
168 OUString( "com.sun.star.comp.ucb.CachedDynamicResultSetFactory" ),
169 OUString( CACHED_DRS_FACTORY_NAME ) );
171 //--------------------------------------------------------------------------
172 // Service factory implementation.
173 //--------------------------------------------------------------------------
175 ONE_INSTANCE_SERVICE_FACTORY_IMPL( CachedDynamicResultSetFactory );
177 //--------------------------------------------------------------------------
178 // CachedDynamicResultSetFactory XCachedDynamicResultSetFactory methods.
179 //--------------------------------------------------------------------------
181 //virtual
182 Reference< XDynamicResultSet > SAL_CALL CachedDynamicResultSetFactory
183 ::createCachedDynamicResultSet(
184 const Reference< XDynamicResultSet > & SourceStub
185 , const Reference< XContentIdentifierMapping > & ContentIdentifierMapping )
186 throw( RuntimeException )
188 Reference< XDynamicResultSet > xRet;
189 xRet = new CachedDynamicResultSet( SourceStub, ContentIdentifierMapping, m_xSMgr );
190 return xRet;
194 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */